source: josm/trunk/src/org/openstreetmap/josm/data/projection/Projection.java@ 12820

Last change on this file since 12820 was 12818, checked in by bastiK, 7 years ago

see #15229 - move Bounds#visitEdge to Projection#visitOutline

  • joins 2 implementations of the same algorithm
  • removes dependency of Bounds on Projection
  • Property svn:eol-style set to native
File size: 4.5 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data.projection;
3
4import java.util.function.Consumer;
5
6import org.openstreetmap.josm.data.Bounds;
7import org.openstreetmap.josm.data.ProjectionBounds;
8import org.openstreetmap.josm.data.coor.EastNorth;
9import org.openstreetmap.josm.data.coor.LatLon;
10
11/**
12 * A projection, i.e. a class that supports conversion from lat/lon
13 * to east/north and back.
14 *
15 * The conversion from east/north to the screen coordinates is simply a scale
16 * factor and x/y offset.
17 */
18public interface Projection extends Projecting {
19 /**
20 * The default scale factor in east/north units per pixel
21 * ({@link org.openstreetmap.josm.gui.NavigatableComponent#getState})).
22 * FIXME: misnomer
23 * @return the scale factor
24 */
25 double getDefaultZoomInPPD();
26
27 /**
28 * Convert from easting/norting to lat/lon.
29 *
30 * @param en the geographical point to convert (in projected coordinates)
31 * @return the corresponding lat/lon (WGS84)
32 */
33 LatLon eastNorth2latlon(EastNorth en);
34
35 /**
36 * Describe the projection in one or two words.
37 * @return the name / description
38 */
39 @Override
40 String toString();
41
42 /**
43 * Return projection code.
44 *
45 * This should be a unique identifier.
46 * If projection supports parameters, return a different code
47 * for each set of parameters.
48 *
49 * The EPSG code can be used (if defined for the projection).
50 *
51 * @return the projection identifier
52 */
53 String toCode();
54
55 /**
56 * Get a filename compatible string (for the cache directory).
57 * @return the cache directory name (base name)
58 * @deprecated unused - remove in 2017-07
59 */
60 @Deprecated
61 String getCacheDirectoryName();
62
63 /**
64 * Get the bounds of the world.
65 * @return the supported lat/lon rectangle for this projection
66 */
67 Bounds getWorldBoundsLatLon();
68
69 /**
70 * Get an approximate EastNorth box around the lat/lon world bounds.
71 *
72 * Note: The projection is only valid within the bounds returned by
73 * {@link #getWorldBoundsLatLon()}. The lat/lon bounds need not be a
74 * rectangular shape in east/north space. This method returns a box that
75 * contains this shape.
76 *
77 * @return EastNorth box around the lat/lon world bounds
78 */
79 ProjectionBounds getWorldBoundsBoxEastNorth();
80
81 /**
82 * Find lat/lon-box containing all the area of a given rectangle in
83 * east/north space.
84 *
85 * This is an approximate method. Points outside of the world should be ignored.
86 *
87 * @param pb the rectangle in projected space
88 * @return minimum lat/lon box, that when projected, covers <code>pb</code>
89 */
90 Bounds getLatLonBoundsBox(ProjectionBounds pb);
91
92 /**
93 * Get a box in east/north space of this projection, that fully contains an
94 * east/north box of another projection.
95 *
96 * Reprojecting a rectangular box from one projection to another may distort/rotate
97 * the shape of the box, so in general one needs to walk along the boundary
98 * in small steps to get a reliable result.
99 *
100 * This is an approximate method.
101 *
102 * @param box the east/north box given in projection <code>boxProjection</code>
103 * @param boxProjection the projection of <code>box</code>
104 * @return an east/north box in this projection, containing the given box
105 */
106 ProjectionBounds getEastNorthBoundsBox(ProjectionBounds box, Projection boxProjection);
107
108 /**
109 * Get the number of meters per unit of this projection. This more
110 * defines the scale of the map, than real conversion of unit to meters
111 * as this value is more less correct only along certain lines of true scale.
112 *
113 * Used by WMTS to properly scale tiles
114 * @return meters per unit of projection
115 */
116 double getMetersPerUnit();
117
118 /**
119 * Does this projection natural order of coordinates is North East,
120 * instead of East North
121 *
122 * @return true if natural order of coordinates is North East, false if East North
123 */
124 boolean switchXY();
125
126 /**
127 * Visit points along the edge of this bounds instance.
128 * <p>
129 * Depending on the shape in east/north space, it may simply visit the 4 corners
130 * or (more generally) several points along the curved edges.
131 * @param bounds the lat/lon rectangle to trace
132 * @param visitor a function to call for the points on the edge.
133 * @since 12818
134 */
135 void visitOutline(Bounds bounds, Consumer<EastNorth> visitor);
136}
Note: See TracBrowser for help on using the repository browser.