I need to store the geometry of a certain feature with OpenLayers.Control.WMSGetFeatureInfo
and I'm using these parameters to get it in JSON format
output:'features',
infoFormat:'application/json',
format: new OpenLayers.Format.JSON,
After I store the geometry from the JSON, I'm writing a WKT string with it to get something like.
"MULTIPOLYGON(((-8.098636886812224 39.016921320632704, -8.098572979051546 39.016543430309326,)))"
The problem is that I don't know why but the JSON geometry object is coming with a comma between the LAT and LONG like so:
"MULTIPOLYGON(((-8.098636886812224,39.016921320632704, -8.098572979051546, 39.016543430309326)))"
What's the best way to get a correct WKT string from the event.features JSON Object or in alternative how to replace every other comma with a blank space using a regular expression in JavaScript?
Replacing the first and keeping the second?
Best Answer
So after I got everything to work I want to share the code. I didn't need the WKT after all, I managed to save the geometry with GeoJSON only.
The result is this and with every property of the clicked features saved in a array so I can edit them later.