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

orientation issue #1

Open gearye opened 7 years ago

gearye commented 7 years ago

The top of the SVG I am converting is oriented just west of north. When converted with svg2geojson it scales and centers the image correctly but it ends up rotated and mirrored. The bounding rect of my SVG ends up oriented perfectly north-south / east-west in the geojson.

test.svg.txt test.geojson.txt

Phrogz commented 7 years ago

Confirmed. When I wrote this I knew that I was making an assumption that SVG Y axis was aligned with north up. This is what the cryptic second bullet point in the TODO section of the readme refers to.

How important is this to you? Would entering four registration points work for you?

gearye commented 7 years ago

I was able to get what I needed by hacking in my own converter. Not a rush, but for my use case the best solution is using my own coordinate converter. If there was a way to pass that in I would be golden. Thanks!

Phrogz commented 7 years ago

To be clear, the sort of converter you're taking about is supplying a custom function that is supplied an SVG coordinate pair, and you return a GPS long/lat pair? That's a moderately simple change that is be happy to add as an option on the library side. I'll also consider if there's a reasonable way to make that happen using the command-line converter.

Aditya-Sh commented 6 years ago

I am having similar issues regarding orientation. Can you guide as to what I can do solve this or some example of convertor that solves this?

Phrogz commented 6 years ago

@Aditya-Sh Can you please be very clear about what your situation is? I'd be happy to help with a solution, but I want to ensure that I'm satisfying the need correctly.

Aditya-Sh commented 6 years ago

Hello, the problem I am facing is my svg is not oriented properly when converted to geojson. screen shot 2017-10-25 at 8 59 59 pm

As you see in the image, i want top of my svg to be parallel with 'CARR ST' on map. Am I not providing proper geo tags or something else is wrong?

Phrogz commented 6 years ago

Thanks for the details. You're not doing anything wrong. I just have not implemented any feature to allow rotation. Which of the following options would you prefer?

  1. Specify an angle to rotate north along with your two corners. This should be the simplest to code up, but I've not thought it through fully. I'm not sure how easy it would be to use. (Would it be easy for you to calculate the angle of deviation from north for your SVG? Maybe?) svg2geojson-rotation1-2cornerswithangle

  2. Use three corners to represent a rotated rectangle. This one requires you to have one point that shares the latitude of one point and the longitude of another. Pretty easy to use, but might be sometimes hard to find points that happen to match with features in your map. svg2geojson-rotation2-3corners

  3. Use four corners to represent arbitrary points on the map. This might also be used to stretch or skew the map in addition to rotating it, but (if I do the math right) should work without skew if your SVG and GPS coordinates are consistent. This one is probably the most work (though I've worked through the math before), certainly the most powerful, possibly the most convenient, but also possibly error-prone. svg2geojson-rotation3-4corners

Phrogz commented 6 years ago

BTW, after I made my graphics I realize that they don't really match your specific situation, since you actually want your buildings to rotate counter-clockwise, and the graphics for 1 and 2 would end up rotating the other way.

sushilkjaiswar commented 6 years ago

Hi Phrogz,

Aditya and I are looking at this issue together and I was thinking which option is better to handle any common projection we use for conversion. I think if first option can be easily achieved if we provide additional info like rotation point and angle of rotation to existing inputs for conversion. But I don't know how it will work for different projections. If above is not a feasible or complex solution than option 3 is better solution.