利用OpenLayers创建wkt字符串
2016-01-29 15:23 xiashengwang 阅读(1730) 评论(0) 编辑 收藏 举报var polygon = OpenLayers.Geometry.Polygon.createRegularPolygon(new OpenLayers.Geometry.Point(6, 49), 2, 18, 0); var feature = new OpenLayers.Feature.Vector(polygon); var wkt_c = new OpenLayers.Format.WKT(); var wktString = wkt_c.write(feature); var projection = new OpenLayers.Projection("EPSG:4326"); var testarea = polygon.getGeodesicArea(projection).toFixed(2); //var testarea = polygon.getGeodesicArea().toFixed(2); //default:EPSG:4326
创建出来的数据,大概是这个样子:
"POLYGON((6.027164 49.524078,6.088064 49.680508,5.948726 49.772232,5.941587 49.91943,6.03742 50.064381,6.147439 50.130783,6.211109 50.166946,6.312177 50.134426,6.340263 49.998951,6.525142 49.858585,6.734586 49.815399,6.715019 49.685902,6.603117 49.621159,6.636707 49.462303,6.57162 49.490456,6.315996 49.495625,6.027164 49.524078))"