svn-gvsig-desktop / trunk / libraries / libjni-mrsid / include / base / lti_geoCoord.h @ 3539
History | View | Annotate | Download (8.72 KB)
1 |
/* $Id: lti_geoCoord.h 3539 2006-01-09 12:23:20Z nacho $ */
|
---|---|
2 |
/* //////////////////////////////////////////////////////////////////////////
|
3 |
// //
|
4 |
// This code is Copyright (c) 2004 LizardTech, Inc, 1008 Western Avenue, //
|
5 |
// Suite 200, Seattle, WA 98104. Unauthorized use or distribution //
|
6 |
// prohibited. Access to and use of this code is permitted only under //
|
7 |
// license from LizardTech, Inc. Portions of the code are protected by //
|
8 |
// US and foreign patents and other filings. All Rights Reserved. //
|
9 |
// //
|
10 |
////////////////////////////////////////////////////////////////////////// */
|
11 |
/* PUBLIC */
|
12 |
|
13 |
#ifndef LTI_GEOCOORD_H
|
14 |
#define LTI_GEOCOORD_H
|
15 |
|
16 |
// lt_lib_base
|
17 |
#include "lt_base.h" |
18 |
#include "lti_scene.h" |
19 |
|
20 |
#if defined(LT_COMPILER_MS)
|
21 |
#pragma warning(push,4) |
22 |
#endif
|
23 |
|
24 |
|
25 |
LT_BEGIN_NAMESPACE(LizardTech) |
26 |
|
27 |
|
28 |
class LTFileSpec; |
29 |
class LTIOStreamInf; |
30 |
class LTIMetadataDatabase; |
31 |
|
32 |
/**
|
33 |
* represents a geographic coordinate
|
34 |
*
|
35 |
* The LTIGeoCoord class contains geographic coordinate information: x and
|
36 |
* y resolution, upper left point, and x and y rotation.
|
37 |
*
|
38 |
* @note As per the conventions for georeferenced images, the Y resolution is
|
39 |
* typically a negative value.
|
40 |
*/
|
41 |
class LTIGeoCoord |
42 |
{ |
43 |
public:
|
44 |
/**
|
45 |
* constructor
|
46 |
*
|
47 |
* Creates an LTIGeoCoord object with the given coordinate information.
|
48 |
*
|
49 |
* @param xUL upper-left x position
|
50 |
* @param yUL upper-left y position
|
51 |
* @param xRes x resolution
|
52 |
* @param yRes y resolution
|
53 |
* @param xRot x rotation
|
54 |
* @param yRot y rotation
|
55 |
*/
|
56 |
LTIGeoCoord(double xUL, double yUL, |
57 |
double xRes, double yRes, |
58 |
double xRot, double yRot); |
59 |
|
60 |
/**
|
61 |
* copy constructor
|
62 |
*/
|
63 |
LTIGeoCoord(const LTIGeoCoord&);
|
64 |
|
65 |
/**
|
66 |
* destructor
|
67 |
*/
|
68 |
~LTIGeoCoord(); |
69 |
|
70 |
/**
|
71 |
* assignment operator
|
72 |
*/
|
73 |
LTIGeoCoord& operator=(const LTIGeoCoord&);
|
74 |
|
75 |
/**
|
76 |
* equality operator
|
77 |
*/
|
78 |
bool operator==(const LTIGeoCoord&) const; |
79 |
|
80 |
/**
|
81 |
* inequality operator
|
82 |
*/
|
83 |
bool operator!=(const LTIGeoCoord&) const; |
84 |
|
85 |
/**
|
86 |
* get the upper-left X position
|
87 |
*
|
88 |
* Returns the upper-left X position.
|
89 |
*
|
90 |
* @return the upper-left X position
|
91 |
*/
|
92 |
double getX() const; |
93 |
|
94 |
/**
|
95 |
* get the upper-left Y position
|
96 |
*
|
97 |
* Returns the upper-left Y position.
|
98 |
*
|
99 |
* @return the upper-left Y position
|
100 |
*/
|
101 |
double getY() const; |
102 |
|
103 |
/**
|
104 |
* get the X resolution
|
105 |
*
|
106 |
* Returns the X resolution
|
107 |
*
|
108 |
* @return the X resolution
|
109 |
*/
|
110 |
double getXRes() const; |
111 |
|
112 |
/**
|
113 |
* get the Y resolution
|
114 |
*
|
115 |
* Returns the Y resolution
|
116 |
*
|
117 |
* @return the Y resolution
|
118 |
*/
|
119 |
double getYRes() const; |
120 |
|
121 |
/**
|
122 |
* get the X rotation
|
123 |
*
|
124 |
* Returns the X rotation
|
125 |
*
|
126 |
* @return the X rotation
|
127 |
*/
|
128 |
double getXRot() const; |
129 |
|
130 |
/**
|
131 |
* get the Y rotation
|
132 |
*
|
133 |
* Returns the Y rotation
|
134 |
*
|
135 |
* @return the Y rotation
|
136 |
*/
|
137 |
double getYRot() const; |
138 |
|
139 |
/**
|
140 |
* get the coordinate information
|
141 |
*
|
142 |
* Returns all the coordinate information. This is equivalent to calling
|
143 |
* getXUL(), getXRes(), etc.
|
144 |
*
|
145 |
* @param xUL upper-left x position
|
146 |
* @param yUL upper-left y position
|
147 |
* @param xRes x resolution
|
148 |
* @param yRes y resolution
|
149 |
* @param xRot x rotation
|
150 |
* @param yRot y rotation
|
151 |
*/
|
152 |
void get(double& xUL, double& yUL, |
153 |
double& xRes, double& yRes, |
154 |
double& xRot, double& yRot) const; |
155 |
|
156 |
/**
|
157 |
* convert a pixel coordinate to geo coordinate
|
158 |
*
|
159 |
* @param pixelX x pixel position
|
160 |
* @param pixelY y pixel position
|
161 |
* @param mag magnification level (pixelX, pixelY) are in
|
162 |
* @param geoX x geo position
|
163 |
* @param geoY y geo position
|
164 |
* @return status code indicating success or failure
|
165 |
*/
|
166 |
LT_STATUS pixelToGeo(double pixelX, double pixelY, double mag, |
167 |
double &geoX, double &geoY) const; |
168 |
|
169 |
/**
|
170 |
* convert a geo coordinate to pixel coordinate
|
171 |
*
|
172 |
* @param geoX x geo position
|
173 |
* @param geoY y geo position
|
174 |
* @param mag magnification level (pixelX, pixelY) will be in
|
175 |
* @param pixelX x pixel position
|
176 |
* @param pixelY y pixel position
|
177 |
* @return status code indicating success or failure
|
178 |
*/
|
179 |
LT_STATUS geoToPixel(double geoX, double geoY, double mag, |
180 |
double &pixelX, double &pixelY) const; |
181 |
|
182 |
/**
|
183 |
* get the coordinate information for a given scene
|
184 |
*
|
185 |
* Return a LTIGeoCoord object for the center of the upper-left
|
186 |
* pixel of the given scene.
|
187 |
*
|
188 |
* @param scene scene
|
189 |
* @return a LTIGeoCoord object for scene
|
190 |
*/
|
191 |
LTIGeoCoord getGeoCoordForScene(const LTIScene &scene) const; |
192 |
|
193 |
/**
|
194 |
* set the upper-left X position
|
195 |
*
|
196 |
* Sets the upper-left X position.
|
197 |
*
|
198 |
* @param x the upper-left X position
|
199 |
*/
|
200 |
void setX(double x); |
201 |
|
202 |
/**
|
203 |
* set the upper-left Y position
|
204 |
*
|
205 |
* Sets the upper-left Y position.
|
206 |
*
|
207 |
* @param y the upper-left Y position
|
208 |
*/
|
209 |
void setY(double y); |
210 |
|
211 |
/**
|
212 |
* set the X resolution
|
213 |
*
|
214 |
* Sets the X resolution
|
215 |
*
|
216 |
* @param xRes the X resolution
|
217 |
*/
|
218 |
void setXRes(double xRes); |
219 |
|
220 |
/**
|
221 |
* set the Y resolution
|
222 |
*
|
223 |
* Sets the Y resolution
|
224 |
*
|
225 |
* @param yRes the Y resolution
|
226 |
*/
|
227 |
void setYRes(double yRes); |
228 |
|
229 |
/**
|
230 |
* write data to world file
|
231 |
*
|
232 |
* This function writes the geographic data out in "world file" format
|
233 |
* to the specified file. If \a extension is not NULL, the extension
|
234 |
* will be used to replace the extension in the filename.
|
235 |
*
|
236 |
* @param fileSpec the name of the world file to write to
|
237 |
* @param determineExtension if true, replace extension in \a fileSpec; otherwise, just use \a fileSpec
|
238 |
* @return status code indicating success or failure
|
239 |
*/
|
240 |
LT_STATUS writeWorldFile(const LTFileSpec& fileSpec,
|
241 |
bool determineExtension) const; |
242 |
|
243 |
/**
|
244 |
* read data from world file
|
245 |
*
|
246 |
* This function reads the geographic data in from the given "world file", if file present. If no world
|
247 |
* file found, \a fileFound set to false and returns LT_STS_Success.
|
248 |
*
|
249 |
* @param fileSpec the name of the world file to read from
|
250 |
* @param determineExtension if true, replace extension in \a fileSpec; otherwise, just use \a fileSpec
|
251 |
* @param fileFound will be if true, if world file was found and read
|
252 |
* @return status code indicating success or failure
|
253 |
*/
|
254 |
LT_STATUS readWorldFile(const LTFileSpec& fileSpec,
|
255 |
bool determineExtension,
|
256 |
bool& fileFound);
|
257 |
|
258 |
/**
|
259 |
* read data from world file, via a stream
|
260 |
*
|
261 |
* This function reads the geographic data in from the given "world file",
|
262 |
* using an LTIOStreamInf interface.
|
263 |
*
|
264 |
* @param stream the world file data read from
|
265 |
* @return status code indicating success or failure
|
266 |
*/
|
267 |
LT_STATUS readWorldFile(LTIOStreamInf& stream); |
268 |
|
269 |
/**
|
270 |
* get file extension text
|
271 |
*
|
272 |
* This function computes the "official" world file extension for the
|
273 |
* given image file name. Typically this is formed by concatenating the
|
274 |
* first and last letters of the image file extension and a 'w', e.g.
|
275 |
* "foo.jpg" returns "jgw".
|
276 |
*
|
277 |
* If the first and last characters of the extension are both uppercase,
|
278 |
* then the 'W' is uppercase, e.g. "foo.JPG" return "JPW".
|
279 |
*
|
280 |
* The \c ext parameter must be allocated to be at least 4 bytes prior to
|
281 |
* the call.
|
282 |
*
|
283 |
* @param fileSpec the name of the image file
|
284 |
* @param ext an array of (at least) 4 bytes
|
285 |
* @return status code indicating success or failure
|
286 |
*/
|
287 |
static LT_STATUS getWorldFileExtension(const LTFileSpec& fileSpec, |
288 |
char* ext);
|
289 |
|
290 |
|
291 |
/**
|
292 |
* write data to metadata
|
293 |
*
|
294 |
* This function writes the geographic data out to the metadata.
|
295 |
*
|
296 |
* @param metadata the metadata database to write to
|
297 |
* @return status code indicating success or failure
|
298 |
*/
|
299 |
LT_STATUS writeMetadata(LTIMetadataDatabase &metadata) const;
|
300 |
|
301 |
/**
|
302 |
* read data from metadata
|
303 |
*
|
304 |
* This function reads the geographic data in from the given metadata database.
|
305 |
*
|
306 |
* @param metadata the metadata database to read from
|
307 |
* @param found will be if true, if metadata has geographic data
|
308 |
* @return status code indicating success or failure
|
309 |
*/
|
310 |
LT_STATUS readMetadata(const LTIMetadataDatabase &metadata, bool &found); |
311 |
|
312 |
private:
|
313 |
double m_xUL;
|
314 |
double m_yUL;
|
315 |
double m_xRes;
|
316 |
double m_yRes;
|
317 |
double m_xRot;
|
318 |
double m_yRot;
|
319 |
}; |
320 |
|
321 |
|
322 |
LT_END_NAMESPACE(LizardTech) |
323 |
|
324 |
#if defined(LT_COMPILER_MS)
|
325 |
#pragma warning(pop)
|
326 |
#endif
|
327 |
|
328 |
#endif // LTI_GEOCOORD_H |