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

addGroupToLayer fails in some cases #2

Closed marr closed 6 years ago

marr commented 6 years ago

Hi, Thanks for the work on this library! I think it will be a good solution once i can get my svg to parse correctly. I am using the geoFromSVGXML function and getting an error in the addGroupToLayer call.

I've screenshotted it in case that helps but what seems to be happening is that the method expects el.$$ to be an array, and in the case I am seeing, its actually undefined. screen shot 2017-08-16 at 9 27 19 am

Phrogz commented 6 years ago

Thanks for the report. It would help most to have a pared-down version of your SVG that reproduces this problem, but let me look into the underlying xml2js library and see if I can suss out why it doesn't have a $$ collection.

A random guess: does your SVG file have group elements with no child elements, e.g. <g …/> or <g …></g> ? If so, you can either pre-process your SVG files and hand-delete these, or you can add a simple (if el.$$) prefix before that offending line, until I get a chance to release a fixed version.

marr commented 6 years ago

Thanks for the response Phrogz. I believe it is due to the empty <g />. I can submit a PR.