Estoy usando Javascript, jQuery, Java, GeoServer, OpenLayers y PostGIS.
Usando la clase java ResultSet
devuelvo esta cadena:
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))
Bastante largo, ¿no? Entonces, usando la función ajax de JQuery, cojo esta cadena y ahora quiero convertirla en a OpenLayers.Geometry.Polygon
, esta es la línea donde uso la función 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);
}
});
¿Cómo puedo hacer la conversión?
¿console.log (data.d) le da su cadena de polígono WKT? (POLYGON ((516000)?
—
CaptDragon
usar una consulta WFS probablemente funcionaría mejor
—
Ian Turton