繁体   English   中英

SVG路径属性d例如为geoJSON

[英]SVG path attribute d to e.g. geoJSON

我在SVG中有很多几何形状。 为了能够在Openlayers矢量图层中进行编辑,我想将svg几何形状转换为geoJSON格式,以便可以轻松地将它们添加到Openlayers图层中。

从:

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"/>

至:

{
  "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框架?

也许您不需要使用OpenLayers。 您可以使用d3绘制地图。 d3也有很多方法可以帮助您进行转换。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM