1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.data.projection;
|
---|
3 |
|
---|
4 | import java.util.Map;
|
---|
5 |
|
---|
6 | import org.openstreetmap.josm.data.ProjectionBounds;
|
---|
7 | import org.openstreetmap.josm.data.coor.EastNorth;
|
---|
8 | import org.openstreetmap.josm.data.coor.ILatLon;
|
---|
9 | import org.openstreetmap.josm.data.coor.LatLon;
|
---|
10 |
|
---|
11 | /**
|
---|
12 | * Classes implementing this are able to project between screen (east/north) and {@link LatLon} coordinates.
|
---|
13 | * <p>
|
---|
14 | * Each instance is backed by a base projection but may e.g. offset the resulting position.
|
---|
15 | * @author Michael Zangl
|
---|
16 | * @since 10805
|
---|
17 | */
|
---|
18 | public interface Projecting {
|
---|
19 |
|
---|
20 | /**
|
---|
21 | * Convert from lat/lon to easting/northing.
|
---|
22 | * <p>
|
---|
23 | * This method exists to not break binary compatibility with old plugins
|
---|
24 | *
|
---|
25 | * @param ll the geographical point to convert (in WGS84 lat/lon)
|
---|
26 | * @return the corresponding east/north coordinates
|
---|
27 | * @see ILatLon#getEastNorth(Projecting)
|
---|
28 | */
|
---|
29 | default EastNorth latlon2eastNorth(LatLon ll) {
|
---|
30 | return latlon2eastNorth((ILatLon) ll);
|
---|
31 | }
|
---|
32 |
|
---|
33 | /**
|
---|
34 | * Convert from lat/lon to easting/northing. This method uses the newer {@link ILatLon} interface.
|
---|
35 | *
|
---|
36 | * @param ll the geographical point to convert (in WGS84 lat/lon)
|
---|
37 | * @return the corresponding east/north coordinates
|
---|
38 | * @see ILatLon#getEastNorth(Projecting) as shorthand.
|
---|
39 | * @since 12161
|
---|
40 | */
|
---|
41 | EastNorth latlon2eastNorth(ILatLon ll);
|
---|
42 |
|
---|
43 | /**
|
---|
44 | * Convert a east/north coordinate to the {@link LatLon} coordinate.
|
---|
45 | * This method clamps the lat/lon coordinate to the nearest point in the world bounds.
|
---|
46 | * @param en east/north
|
---|
47 | * @return The lat/lon coordinate.
|
---|
48 | */
|
---|
49 | LatLon eastNorth2latlonClamped(EastNorth en);
|
---|
50 |
|
---|
51 | /**
|
---|
52 | * Gets the base projection instance used.
|
---|
53 | * This may be the same as this one or a different one if this one is translated in east/north space.
|
---|
54 | * @return The projection.
|
---|
55 | */
|
---|
56 | Projection getBaseProjection();
|
---|
57 |
|
---|
58 | /**
|
---|
59 | * Returns an map or (subarea, projecting) paris that contains projecting instances to convert the coordinates inside the given area.
|
---|
60 | * This can be used by projections to support continuous projections.
|
---|
61 | *
|
---|
62 | * It is possible that the area covered by the map is bigger than the one given as area. There may be holes.
|
---|
63 | * @param area The base area
|
---|
64 | * @return a map of non-overlapping {@link ProjectionBounds} instances mapped to the {@link Projecting} object to use for that area.
|
---|
65 | */
|
---|
66 | Map<ProjectionBounds, Projecting> getProjectingsForArea(ProjectionBounds area);
|
---|
67 |
|
---|
68 | /**
|
---|
69 | * Gets the object used as cache identifier when caching results of this projection.
|
---|
70 | * @return The object to use as cache key
|
---|
71 | * @since 10827
|
---|
72 | */
|
---|
73 | default Object getCacheKey() {
|
---|
74 | return this;
|
---|
75 | }
|
---|
76 | }
|
---|