|
|
Raben Systems
Inc. |
| Software Development Services
|
Lets get started by defining an interface
that will be used by different types of map projections. Most of the methods
are simple setters and getters for the variables needed to compute projections,
such as the center coordinate, the radius, and screen coordinate of the center
point of the projection. The interface defines setters and getters for variables
needed to draw an overlay showing lines of latitude and longitude. Methods for
converting a screen point to a coordinate and coordinate to a screen point are
defined as well. Since overlay grid and text can have lots of points, a couple
methods were added to retrieve the grid and text as shapes, to speed up the
computation a bit.
1 /*
2 * MapProjection.java
3 *
4 * Copyright (c) 2002, 2003, Raben Systems, Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are met:
9 *
10 * Redistributions of source code must retain the above copyright notice,
11 * this list of conditions and the following disclaimer.
12 *
13 * Redistributions in binary form must reproduce the above copyright notice,
14 * this list of conditions and the following disclaimer in the documentation
15 * and/or other materials provided with the distribution.
16 *
17 * Neither the name of Raben Systems, Inc. nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
32 *
33 * Created on June 6, 2002, 6:19 PM
34 */
35
36 package com.raben.projection.map;
37 import java.awt.geom.Point2D;
38 import java.awt.geom.GeneralPath;
39 import java.awt.Graphics2D;
40
41 /***
42 * Interface for map projection
43 * @author Vern Raben
44 * @version $Revision: 1.2 $ $Date: 2003/10/10 18:04:23 $
45 */
46 public interfaceMapProjection {
47
48 /*** Get center coordinate in radians
49 * @return Value of property centerCoordinate.
50 */
51 java.awt.geom.Point2D getCenterCoordinate();
52
53 /*** Set longitude and latitude of the center coordinate in radians
54 * @param centerCoordinate Point2D in radians
55 */
56 void setCenterCoordinate(java.awt.geom.Point2D centerCoordinate);
57
58 /*** Get screen coordinates of center of map
59 * @return screen coordinates of the center of map
60 */
61 java.awt.geom.Point2D getCenterPoint();
62
63 /***
64 * Set centerPoint screen coordinate
65 * @param centerPoint Point2D The screen Location of the center of map
66 */
67 void setCenterPoint(java.awt.geom.Point2D centerPoint);
68
69 /*** Get radius (equatorial radius for ellipsoid)
70 * @return Value of property radius.
71 */
72 double getRadius();
73
74 /***
75 * Set radius (equatorial radius for ellipsoid)
76 * @param radius New value of property radius.
77 */
78 void setRadius(double radius);
79
80 /***
81 * Get overlay grid for map
82 * @return mapOverlay GeneneralPath
83 */
84 GeneralPath getOverlayGridPath();
85
86 /***
87 * Set overlay grid longitude increment in radians
88 * @param longitudeIncrement Amount longitude is incremented when drawing
89 * grid
90 */
91 void setOverlayGridLongitudeIncrement(double longitudeIncrement);
92
93
94 /***
95 * Get overlay grid longitude increment in radians
96 * @return double Amount longitude is incremented when drawing grid
97 */
98 double getOverlayGridLongitudeIncrement();
99
100 /***
101 * Set overlay grid latitude increment in radians
102 * @param latitudeIncrement Amount latitude is incremented when drawing grid
103 */
104 void setOverlayGridLatitudeIncrement(double latitudeIncrement);
105
106 /***
107 * Get overlay grid latitude increment in radians
108 * @return double Amount latitude is incremented when drawing grid
109 */
110 double getOverlayGridLatitudeIncrement();
111
112 /***
113 * Set overlay grid incrment in radians along the grid line
114 * @param gridIncrement in radians
115 */
116 void setOverlayGridIncrement(double gridIncrement);
117
118 /***
119 * Get overlay grid incrment in radians along the grid line
120 * @return double Grid increment in radians along grid line
121 */
122 double getOverlayGridIncrement();
123
124 /*** Get text overlay for the map
125 * @param g2D Graphics resource
126 * @return mapOverlayText GeneralPath
127 */
128 GeneralPath getTextPath(Graphics2D g2D);
129
130 /***
131 * Add overlay text
132 * @param coordTxt to be added to overlay
133 */
134 void addOverlayText(CoordinateText coordTxt);
135
136 /***
137 * Get coordinate for a given Location in screen coordinates
138 * @param loc Point2D Screen Location
139 * @return Point2D Coordinate of the point in radians
140 */
141 Point2D getCoordinateForLocation(Point2D loc);
142
143 /***
144 * Get latitude range in radians (example -PI/4 to +PI/4 = PI/2)
145 * Default is PI
146 * @return latitude range in radians
147 */
148 double getLatitudeRange();
149
150
151 /***
152 * Get Location for specified coordinate in radians
153 * @param coordinate Point2D Longitude and latitude of coordinate in radians
154 * @return Point2D Screen Location of the coordinate
155 */
156 Point2D getLocationForCoordinate(Point2D coordinate);
157
158 /***
159 * Normalize coordinate so that longitude is in the range -PI to +PI
160 * radians and latitude is in the range -PI_OVER_2 to +PI_OVER_2 radians;
161 * @param coordinate in radians
162 */
163 void normalizeCoordinate(Point2D coordinate);
164
165 /***
166 * Set latitude range in radians (example -PI/4 to +PI/4 = PI/2)
167 * @param latitudeRange double in radians
168 */
169 void setLatitudeRange(double latitudeRange);
170
171 /***
172 * Convert coordinate in radians to degrees
173 * @param radians Point2D coordinate in radians
174 * @return Point2D coordinate in degrees
175 */
176 Point2D toDegrees(Point2D radians);
177
178 /***
179 * Convert coordinate in degrees to radians
180 * @param degrees Point2D in degrees
181 * @return Point2D Coordinate in radians
182 */
183 Point2D toRadians(Point2D degrees);
184
185 /***
186 * Get eccentricity for ellipsoid
187 * @return double
188 */
189 double getEccentricity();
190
191 /***
192 * Set eccentricity for ellipsoid
193 * @param eccentricity double
194 */
195 void setEccentricity(double eccentricity);
196
197 /*** Normalize latitude so that its in range -PI_OVER_2 to +PI_OVER_2
198 * @param latitude double (in radians)
199 * @return double Normalized latitude in radians
200 */
201 double normalizeLatitude(double latitude);
202
203 /*** Normalize longitude so that its in range -PI to +PI
204 * @param longitude double (in radians)
205 * @return double Normalize longitude in radians
206 */
207 double normalizeLongitude(double longitude);
208
209 /*** Get projection name
210 * @return ProjectionName
211 */
212 ProjectionName getProjectionName();
213
214 /*** Getter for property textRadius.
215 * @return Value of property textRadius.
216 */
217 double getTextRadius();
218
219 /*** Setter for property textRadius.
220 * @param textRadius New value of property textRadius.
221 */
222 void setTextRadius(double textRadius);
223
224 /*** Set coordinate text to be displayed
225 * @param coordinateTextList The list of coordinate text to be displayed
226 */
227 void setCoordinateTextList(CoordinateTextList coordinateTextList);
228
229 /*** Set whether projection is mirrored by display routine
230 * affects text display only
231 * @param textMirrored True if the text should be mirrored
232 * (flipped horizontally)
233 */
234 void setTextMirrored(boolean textMirrored);
235
236 /*** Returns whther or not text is inverted (flipped vertically)
237 * @return Value of property inverted.
238 */
239 boolean isTextInverted();
240
241 /***
242 * Returns whether text is mirrored (flipped horizontally)
243 * @return Value of property mirror.
244 */
245 boolean isTextMirrored();
246
247 /*** Set whether or not text is inverted (flipped vertically)
248 * @param textInverted True if text should be inverted
249 */
250 void setTextInverted(boolean textInverted);
251
252 }
253
Next
we'll define a skeletal implementation of the MapProjection interface

