Estou usando Javascript, jQuery, Java, GeoServer, OpenLayers e PostGIS.
Usando a classe java ResultSet
, retorno esta String:
POLYGON((516000 2135000,515039.264020162 2125245.48389919,512193.976625564 2115865.82838175,507573.480615127 2107221.48834902,501355.339059327 2099644.66094067,493778.51165098 2093426.51938487,485134.171618255 2088806.02337444,475754.516100806 2085960.73597984,466000 2085000,456245.483899194 2085960.73597984,446865.828381746 2088806.02337444,438221.48834902 2093426.51938487,430644.660940673 2099644.66094067,424426.519384873 2107221.48834902,419806.023374436 2115865.82838175,416960.735979839 2125245.48389919,416000 2135000,416960.735979838 2144754.51610081,419806.023374436 2154134.17161825,424426.519384873 2162778.51165098,430644.660940673 2170355.33905933,438221.48834902 2176573.48061513,446865.828381745 2181193.97662556,456245.483899193 2184039.26402016,466000 2185000,475754.516100806 2184039.26402016,485134.171618254 2181193.97662556,493778.51165098 2176573.48061513,501355.339059327 2170355.33905933,507573.480615127 2162778.51165098,512193.976625564 2154134.17161825,515039.264020161 2144754.51610081,516000 2135000))
Muito tempo, não é? Então, usando a função ajax do JQuery, eu pego essa String e agora quero convertê-la em a OpenLayers.Geometry.Polygon
, esta é a linha em que uso a função ajax:
$.ajax({
url:"Catcher",
data:query,
type:"POST",
dataType:"text",
success:function(data){
var fea=new OpenLayers.Feature.Vector(data); //this doesn't work
vectorLayer.addFeatures([fea]); // here I add the feature to the vector layer I created as a global variable
map.zoomToExtent(bounds);
}
});
Como posso fazer a conversão?
console.log (data.d) fornece sua sequência de polígonos WKT? (POLYGON ((516000)?
—
CaptDragon
usando uma consulta WFS provavelmente funcionaria melhor
—
Ian Turton