I'm creating a simple application that allows visualizing OSM XML data.

I've been following JOSM as a guide, and I'm trying to understand how you can map the long, lat of the XML data to x, y screen coordinates.

I see that there's a link to slippy map tiles that gives an equation, to map to a tileset once given a zoom factor, long and lat. This may be related to my question but I don't think it gives the proper answer.

I'm good with graphics programming and I understand how to use the bounding box to get the screen coordinates if everything was given in an x,y coordinate information. But, everything is in the lon and lat, which means there has to be a projection.

How does JOSM or another application go from lon, lat to x, y on a flat screen simply using the OSM xml data(like JOSM)?


lon, lat system assumes that earth is round, but our screen is flat so they are not useful for displaying on the screen. The workaround for this is called projection where we convert the lat-lon to x-y cartesian(graph) system. It is a complex process but many tools to help you with that. proj4 is a good place to start.

This page shows the formula for conversion. https://www.movable-type.co.uk/scripts/latlong-utm-mgrs.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.