2014-02-21 44 views
0

我在SVG中有很多几何图形。为了能够在Openlayers矢量图层中编辑它们,我想转换svg几何图形,例如转换为geoJSON格式,以便我可以轻松将它们添加到Openlayers图层。SVG路径属性d例如geoJSON

FROM:

path xmlns="http://www.w3.org/2000/svg" id="G0W9Q7bC" d="M29.68 -30.10l-12.94 9.61 220.96 157.25 67.98-166.86-276.00 .00"/> 

path xmlns="http://www.w3.org/2000/svg" id="G0W9Q7bA" d="M1223.26 349.19l-167.71 93.84 265.54 117.80-70.46 71.27 145.87 .00 .00-53.18-173.24-229.73"/> 

path xmlns="http://www.w3.org/2000/svg" id="G0W9Q7bz_0" d="M1281.16 265.33l .00-111.81 115.34 .00M1396.50 265.33l-115.34 .00"/> 

TO:

{ 
    "type": "FeatureCollection", 
    "features": [ 
    { 
     "type": "Feature", 
     "properties": { 
     }, 
     "geometry": { 
     "type": "Polygon", 
     "coordinates": [ 
      [ 
      [ 
       568420.74334458, 
       121173.52026851001 
      ], 
      [ 
       568420.74334458, 
       135550.45067237 
      ], 
      [ 
       598372.6816859602, 
       135550.45067237 
      ], 
      [ 
       598372.6816859602, 
       121173.52026851001 
      ], 
      [ 
       568420.74334458, 
       121173.52026851001 
      ] 
      ] 
     ] 
     } 
    } 
    ] 
} 

是否有一个JS框架,可以处理呢?

回答

0

也许你不需要使用OpenLayers。您可以使用d3绘制地图。 d3还有一个lot of methods可以帮助你进行转换。