Phrogz / svg2geojson

Converts an SVG file with added geo-referencing tags into one or more GeoJSON files.
MIT License
57 stars 30 forks source link

element id not written correctly #9

Open bockoblur opened 4 years ago

bockoblur commented 4 years ago

Hi. I have svg file with path ids (like id="some_string")

and running your tool with -d option gives me the following output:

{ 
 {"type":"Feature",
  "properties":{
   "svgID":"#[object Object]"   /* <--- note object id! */
},
  "geometry":{
      _etc, the rest is ok_
 ]
 }`

Note that path ids are #[object Object] instead of string ids. Bug? Or am I doing something wrong?

bockoblur commented 4 years ago

On closer inspection of source code, I found what the error is:

Line 273 of svg2geojson.js

should read:

geo.coordinates.debugId = (el.$ && el.$.id) ? `${el.$.id.value}` : fallback;

instead of

geo.coordinates.debugId = (el.$ && el.$.id) ? `#${el.$.id}` : fallback;

Note the added .value property of id object, which is the actual string containing the svg elements' id attribute.

roxanalascu commented 2 years ago

Hi @Phrogz, Thank you for this nice lib! Do you think this issue could be solved any time soon? It seems to be a very easy fix :) Thank you!