[[TranslatedPages(outdated=This page is partly incomplete and outdated. See EPSG:4326 and the proj4 plugin exists !)]] [[PageOutline(1-10,Table of Contents)]] = Understanding JOSM Coordinates = == Openstreetmap coordinates == Openstreetmap uses Latitude/Longitude coordinates in the [https://en.wikipedia.org/wiki/World_Geodetic_System WGS84] [https://en.wikipedia.org/wiki/Geodetic_datum geodetic datum] (being compatible with GPS) for its [osmwiki:Data_Primitives#Node nodes], stored in decimal degree notation with 7 decimal places in the [osmwiki:.osm .osm] XML files. The same spot on earth would have slightly different Latitude/Longitude values in other coordinate systems, depending on the respective [https://en.wikipedia.org/wiki/Reference_ellipsoid reference ellipsoid] and reference points being used. == Editor coordinates == === Java === To render nodes and ways on the rectangular, flat computer screen, the location of the nodes needs to be reversibly mapped into a [https://en.wikipedia.org/wiki/Cartesian_coordinates cartesian] coordinate system, i.e. having perpendicular axes. JOSM uses the [http://java.sun.com/docs/books/tutorial/2d/overview/index.htm Java 2D graphics API] to take care of the rendering process. The Java API implements the concept of a [http://java.sun.com/docs/books/tutorial/2d/overview/coordinate.html user space] that could be understood as a large canvas with an origin (0,0) in the top left corner, and virtually infinite extension to the right (x) and down (y). Java 2D supports both integers and single or double precision float variables for the (x,y) pair. When displaying an area from this virtual canvas to the limited device space, the screen window in this case, Java internally converts these (x,y) coordinates to screen coordinates, automatically during rendering. Although negative coordinates, going left of or above the (0,0) origin, are theoretically possible, it is not recommended to draw outside of the available screen space, as not all Java version work reliably with points outside of the visible area. === JOSM === JOSM defines the coordinates to be used both for Lat/Lon representation as well as the EastNorth editor canvas as '''{{{double float}}}''' in the class [source:/trunk/src/org/openstreetmap/josm/data/coor/Coordinate.java Coordinate]. ==== LatLon ==== The class [source:/trunk/src/org/openstreetmap/josm/data/coor/LatLon.java LatLon] inherits from [source:/trunk/src/org/openstreetmap/josm/data/coor/Coordinate.java Coordinate] and provides checks for the legitimate bounds of being within -90,90 for the latitude or -180,180 for the longitude. ==== EastNorth ==== The class [source:/trunk/src/org/openstreetmap/josm/data/coor/EastNorth.java EastNorth] inherits from [source:/trunk/src/org/openstreetmap/josm/data/coor/Coordinate.java Coordinate]. {{{east()}}} returns the x and {{{north()}}} returns the y coordinate. This means that the numerical value of east() ''increases'' towards East, while the value of north() ''decreases'' towards North. The class also provides some methods for manipulating the coordinates. === Projection === The reversible mapping from LatLon coordinates to a flat map or the flat computer screen is a [https://en.wikipedia.org/wiki/Map_projection projection]. JOSM supports a number of different projections because they have different use cases, in particular in the representation of shapes or the usage of different source material which comes already projected, such as printed maps, land registry data, satellite imagery, WMS servers, etc. to be traced over. Some WMS servers may support a variety of projections on request, others are limited to a specific one. The projections are defined in classes in [source:/trunk/src/org/openstreetmap/josm/data/projection org.openstreetmap.josm.data.projection]. Using JOSM, the projection can be switched in the Preferences menu. Current versions of JOSM support switching without restart. When switching projection, the same LatLon coordinate becomes represented as different numerical values of EastNorth. The bidirectional conversion between LatLon and EastNorth is the core calculation of each implementation of the class [source:/trunk/src/org/openstreetmap/josm/data/projection/Projection.java Projection]. The implementation needs to take care that the valid range of LatLon values is mapped to a valid range of EastNorth values. Since some projections are valid only for certain regions of the earth, the implementation can also define boundaries in which JOSM can edit, i.e. pan the device window over the user space. Some use cases for projections supported in JOSM are summarised below. ==== Mercator ==== The cylindrical [https://en.wikipedia.org/wiki/Mercator_projection Mercator] projection, named after its inventor, maps meridians and parallels straight and perpendicular. In JOSM, e.g. small round objects such as roundabouts appear as a circle, and rectangular buildings are seen rectangular. Disadvantage is the stretching of the poles to infinity. Currently Mercator is the standard projection in JOSM. Most WMS servers don't support this projection, but JOSM does display EPSG:4326 data also for Mercator projection (which is not completely correct, but the resulting errors are small in the current version of the software). ==== EPSG:4326 ==== [https://en.wikipedia.org/wiki/EPSG:4326 EPSG:4326] is a common Lat/Lon coordinate reference system that refers to WGS84. (discuss need for WMS servers / Landsat and Yahoo Sat usage) ==== UTM ==== The [https://en.wikipedia.org/wiki/Transverse_Mercator_projection Transverse Mercator] projection is an adaptation of the Mercator projection, rotating the cylinder 90°. The [https://en.wikipedia.org/wiki/Universal_Transverse_Mercator_coordinate_system Universal Transverse Mercator] (UTM) with its 60 zones, as well as a number of national grid reference systems, are based on this projection. Within UTM zones or the national grid systems, a reference of 2-dimensional cartesian coordinates can be defined, typically given in [https://en.wikipedia.org/wiki/Universal_Transverse_Mercator_coordinate_system#Locating_a_position_using_UTM_coordinates Eastings and Northings] as a meter value from a particular point of origin. These Eastings and Northings must not be confused with the EastNorth coordinate within JOSM. ==== Country-specific projections ==== Many countries specify their own reference systems, some based on Transverse Mercator, some not. In general, JOSM can support any of these systems as soon as the LatLon to EastNorth conversion has been implemented. It is planned to have support for PROJ4 library as plugin, which supports lots of transformations.