graphstream/gs-core

Setting stretch factor to represent a map

Reiszecke opened this issue · 2 comments

I want to show a street map of Berlin, coordinates between 52.5780792, 13.2261165 and 52.4470608, 13.488403. The graph is really stretched, I'm not sure why but probably because the earth is wider than it is high. Please see the picture, left is the GraphStream, right is the same map in JOSM (the correct one).

Screenshot 2019-08-23 at 15 02 17

For my needs, the Graph doesn't have to be perfect, it doesn't have to account for the "roundness" of the earth, making parts in the south more narrow than the north etc. I just want to be able to set a somewhat straight ratio. The ratio should be something around 2:1.

I have tried messing around with
.getCamera().setBounds() and .getCamera().setGraphViewport() but I don't think this is the right way of setting this up, I must be missing something here.

pigne commented

You are using longitude and latitude values as if they where cartesian coordinates but they are not. You need to project your coordinates into a map coordinate system. You should check out about Map Projection, then pickup the projection algorithm you want and find a tool to compute the projection for you (I have used JMPL in the past) to help you produce new "x" ant "y" attributes that are the result of the convertion of latitude and longitude.

Thank you for your reply, I appreciate it.

For now I've just scaled every x value with -2 and rotated the app by 90 degrees. A little hacky but that works for now. Didn't know about Map Projection as a term and JMPL, will do that, thank you man.