[GIS] Polygon coordinates Format in Openlayers

openlayers-2

I am new to Openlayers and I am moving my application from Google Map to Openlayers. And also successfully displaying Polygons (coordinates captured via Google Map in Decimal Degrees – default for Google Maps), When I am drawing the polygon on a layer and on onFeaturesAdded Event, while getting co-ordinates of added feature like this

 var tArr = event.features[0].geometry.getVertices();

output comes out like

[POINT(-919690.32419922 -5068080.7227148),POINT(1780677.0106836 -6868325.6126367),POINT(1819812.7691602 -6868325.6126367)

But, while I am drawing this feature back to OpenLayers displays NOTHING.

Questions are :

1). Google Uses Decimal Degrees Notions to give points of Geometry, Openlayers give in which GIS notation ? (searched on web found nothing)

2). When I am saving co-ordinates in same Projection and redrawing it back, give nothing to me, why ?

thanks for any help.

Best Answer

If question is about converting geometry to string; and then converting string back to geometry, I suggest to use WKT format (http://en.wikipedia.org/wiki/Well-known_text).

Convert geometry to WKT string:

var myWkt = event.features[0].geometry.toString();

and re-creating geometry from WKT string:

var myGeom = new OpenLayers.Geometry.fromWKT(myWkt);
var myFeat = new OpenLayers.Feature.Vector(myGeom);
vectorLayer.addFeatures(myFeat);

And forget that Decimal degrees stuff :) It just means, coordinates are represented as decimal numbers (i.e. 25.5 instead of 25* 30').