00001
00096 #ifndef INC_MI32_SPATREFEXT_H
00097 #define INC_MI32_SPATREFEXT_H
00098
00099 #ifndef INC_MI32_SPATREF_H
00100 #include <mi32/spatref.h>
00101 #endif
00102
00103 #ifndef INC_MI32_SIMPLEAR_H
00104 #include <mi32/simplear.h>
00105 #endif
00106
00107 #ifndef INC_MI32_CTRLPT_H
00108 #include <mi32/ctrlpt.h>
00109 #endif
00110
00111 #ifndef INC_MI32_CODESPACE_H
00112 #include <mi32/codespace.h>
00113 #endif
00114
00115 class FILEPATH;
00116 class TRANS2D_AFFINE;
00117 class GDALDataset;
00118 class IDENTIFIER;
00119 class IDENTIFIERLIST;
00120
00121 #ifdef GEOMDLL
00122 #define LIBEXPORT MI_DLLEXPORT
00123 #define CLASSLIBEXPORT MI_DLLCLASSEXPORT
00124 #else
00125 #define CLASSLIBEXPORT MI_DLLCLASSIMPORT
00126 #define LIBEXPORT MI_DLLIMPORT
00127 #endif
00128
00129 namespace SPATREF {
00130
00131
00132
00135 class CLASSLIBEXPORT OGC_WKT {
00136 public:
00137
00139 static ERRVALUE ConvertFromCRS (
00140 const COORDREFSYS& CoordRefSys,
00141 MISTRING& wktstr,
00142 CODESPACE codespace
00143 );
00144
00146 static ERRVALUE ConvertToCRS (
00147 const MISTRING& wktstr,
00148 COORDREFSYS& CoordRefSys,
00149 CODESPACE codespace
00150 );
00151
00154 static int GetName (
00155 const COORDOPMETHOD& method,
00156 CODESPACE codespace,
00157 MISTRING& name
00158 );
00159
00161 explicit OGC_WKT (
00162 CODESPACE codespace
00163 );
00164
00166 OGC_WKT (
00167 const OGC_WKT& rhs
00168 );
00169
00171 OGC_WKT (
00172 const MISTRING& wktstr,
00173 CODESPACE codespace
00174 );
00175
00177 OGC_WKT (
00178 const COORDREFSYS& CoordRefSys,
00179 CODESPACE codespace
00180 );
00181
00182
00183 ~OGC_WKT ();
00184
00186 OGC_WKT& operator= (
00187 const OGC_WKT& rhs
00188 );
00189
00191 OGC_WKT& operator= (
00192 const MISTRING& wktstr
00193 );
00194
00196 OGC_WKT& operator= (
00197 const COORDREFSYS& CoordRefSys
00198 );
00199
00201 ERRVALUE GetCoordRefSys (
00202 COORDREFSYS& CoordRefSys
00203 );
00204
00206 ERRVALUE GetString (
00207 MISTRING& wktstr
00208 );
00209
00211 void SetCodeSpace (
00212 CODESPACE codespace
00213 );
00214
00215 private:
00216 COORDREFSYS m_CoordRefSys;
00217 MISTRING m_wktstr;
00218 CODESPACE m_codespace;
00219 };
00220
00221
00222
00224 class CLASSLIBEXPORT OGC_URN {
00225 public:
00226
00228 static ERRVALUE ConvertFromCoordOpDef (
00229 const COORDOPDEF& CoordOpDef,
00230 MISTRING& urnstr
00231 );
00232
00234 static ERRVALUE ConvertFromCRS (
00235 const COORDREFSYS& CoordRefSys,
00236 MISTRING& urnstr
00237 );
00238
00240 static ERRVALUE ConvertToCoordOpDef (
00241 const MISTRING& urnstr,
00242 COORDOPDEF& CoordOpDef
00243 );
00244
00246 static ERRVALUE ConvertToCRS (
00247 const MISTRING& urnstr,
00248 COORDREFSYS& CoordRefSys
00249 );
00250
00252 static ERRVALUE ConvertToId (
00253 const MISTRING& urnstr,
00254 const char *objectType,
00255 IDENTIFIER& id
00256 );
00257
00259 static ERRVALUE ExtractFromIdList (
00260 const IDENTIFIERLIST& IdList,
00261 const char *objectType,
00262 const char *ogcversion,
00263 MISTRING& urnstr
00264 );
00265
00266 };
00267
00268
00269
00271 class CLASSLIBEXPORT ESRI {
00272 public:
00273
00276 static ERRVALUE ConvertFromCRS (
00277 const COORDREFSYS& CoordRefSys,
00278 MISTRINGLIST& StrList,
00279 bool GetWKT = true
00280 );
00281
00284 static ERRVALUE ConvertFromCRS (
00285 const COORDREFSYS& CoordRefSys,
00286 const FILEPATH& fp,
00287 bool GetWKT = true
00288 );
00289
00291 static ERRVALUE ConvertToCRS (
00292 const MISTRINGLIST& StrList,
00293 COORDREFSYS& CoordRefSys,
00294 double& xshift,
00295 double& yshift,
00296 double& scale
00297 );
00298
00300 static ERRVALUE ConvertToCRS (
00301 const FILEPATH& fp,
00302 COORDREFSYS& CoordRefSys,
00303 double& xshift,
00304 double& yshift,
00305 double& scale
00306 );
00307
00311 static int ConvertZoneToLegacyMI (
00312 int esrizone
00313 );
00314 };
00315
00316
00317
00319 class CLASSLIBEXPORT FGDC {
00320 public:
00321
00323 static ERRVALUE ConvertToCRS (
00324 const XMLNODE *pNodeSpRef,
00325 COORDREFSYS& CoordRefSys
00326 );
00327 };
00328
00329
00330
00332 class CLASSLIBEXPORT GDAL {
00333 public:
00334 static ERRVALUE ConvertToCRS (
00335 const GDALDataset& dataset,
00336 COORDREFSYS& CoordRefSys,
00337 TRANS2D_AFFINE& Trans,
00338 SIMPLE_ARRAY<CTRLPOINT3>& ControlPoints
00339 );
00340 };
00341
00342
00343
00345 class CLASSLIBEXPORT MAPINFO {
00346 public:
00349 static int ConvertFromCRS (
00350 const COORDREFSYS& CoordRefSys,
00351 SIMPLE_ARRAY<char>& string
00352 );
00353
00355 static ERRVALUE ConvertToCRS (
00356 const char *string,
00357 COORDREFSYS& CoordRefSys
00358 );
00359
00361 static ERRVALUE ReadTAB (
00362 const FILEPATH& filepath,
00363 COORDREFSYS& CoordRefSys,
00364 SIMPLE_ARRAY<CTRLPOINT3>& points
00365 );
00366
00367 };
00368
00369
00370
00371
00373 class CLASSLIBEXPORT TYDAC {
00374 public:
00377 static int ConvertFromCRS (
00378 const COORDREFSYS& CoordRefSys,
00379 SIMPLE_ARRAY<char>& string
00380 );
00381
00383 static ERRVALUE ConvertToCRS (
00384 const char *string,
00385 COORDREFSYS& CoordRefSys
00386 );
00387
00388 };
00389
00390
00391
00393 class CLASSLIBEXPORT ERMAPPER {
00394 public:
00397 static int ConvertFromCRS (
00398 const COORDREFSYS& CoordRefSys,
00399 SIMPLE_ARRAY<char>& DatumStr,
00400 SIMPLE_ARRAY<char>& ProjectionStr,
00401 SIMPLE_ARRAY<char>& CoordTypeStr
00402 );
00403
00405 static ERRVALUE ConvertToCRS (
00406 const char *DatumStr,
00407 const char *ProjectionStr,
00408 const char *CoordTypeStr,
00409 COORDREFSYS& CoordRefSys
00410 );
00411 };
00412
00413
00414
00416 class CLASSLIBEXPORT GEOTIFF {
00417 public:
00418
00420 class CLASSLIBEXPORT READER {
00421 public:
00424 virtual bool v_GetKeyValue (UINT16 key, double& value) const = 0;
00425
00428 virtual bool v_GetKeyValue (UINT16 key, UINT16& value) const = 0;
00429 };
00430
00431 class CLASSLIBEXPORT READER_MEMORY : public READER {
00432 public:
00433 READER_MEMORY ();
00434 virtual ~READER_MEMORY ();
00436 ERRVALUE Initialize (
00437 const UINT16 *GeoKeyDirectoryBuffer,
00438 int GeoKeyDirectoryNumItems,
00439 const double *GeoDoubleParmsBuffer,
00440 int GeoDoubleParmsNumItems
00441 );
00442 private:
00443 #ifndef GENERATING_DOXYGEN_OUTPUT
00444 struct GEOKEY {
00445 UINT16 m_key;
00446 UINT16 m_location;
00447 UINT16 m_count;
00448 UINT16 m_ValueOffset;
00449 };
00450 SIMPLE_ARRAY<GEOKEY> m_GeoKeys;
00451 SIMPLE_ARRAY<double> m_DoubleParms;
00452 virtual bool v_GetKeyValue (UINT16 key, double& value) const;
00453 virtual bool v_GetKeyValue (UINT16 key, UINT16& value) const;
00454 #endif
00455 };
00456
00458 class WRITER {
00459 public:
00461 virtual ERRVALUE v_SetKeyValue (UINT16 key, double value) = 0;
00462
00464 virtual ERRVALUE v_SetKeyValue (UINT16 key, UINT16 value) = 0;
00465
00467 virtual ERRVALUE v_SetKeyValue (UINT16 key, const char *string) = 0;
00468 };
00469
00470 class CLASSLIBEXPORT WRITER_MEMORY : public WRITER {
00471 public:
00472 WRITER_MEMORY ();
00473 virtual ~WRITER_MEMORY ();
00474 const double* GetDoubleParmsBuffer (
00475 ) const { return (m_DoubleParms); }
00476 const UINT16* GetGeoKeyDirectoryBuffer (
00477 ) const { return (reinterpret_cast<const UINT16*>(&m_GeoKeys[0])); }
00478 UINT16 GetNumDoubleParms (
00479 ) const { return (static_cast<UINT16>(m_DoubleParms.GetNumItems())); }
00480 UINT16 GetNumGeoKeys (
00481 ) const { return (static_cast<UINT16>(m_GeoKeys.GetNumItems())); }
00482 private:
00483 #ifndef GENERATING_DOXYGEN_OUTPUT
00484 struct GEOKEY {
00485 UINT16 m_key;
00486 UINT16 m_location;
00487 UINT16 m_count;
00488 UINT16 m_ValueOffset;
00489 };
00490 SIMPLE_ARRAY<GEOKEY> m_GeoKeys;
00491 SIMPLE_ARRAY<double> m_DoubleParms;
00492
00493 virtual ERRVALUE v_SetKeyValue (UINT16 key, double value);
00494 virtual ERRVALUE v_SetKeyValue (UINT16 key, UINT16 value);
00495 virtual ERRVALUE v_SetKeyValue (UINT16 key, const char *string);
00496 #endif
00497 };
00498
00501 static int ConvertFromCRS (
00502 const COORDREFSYS& CoordRefSys,
00503 WRITER& writer,
00504 bool WriteUserDefinedCRS,
00505 bool& WroteProjAsGeographic
00506 );
00507
00509 static ERRVALUE ConvertToCRS (
00510 const READER& reader,
00511 COORDREFSYS& CoordRefSys,
00512 CODESPACE codespace = CODESPACE_EPSG
00513 );
00514 };
00515
00516
00517
00518
00521 int LIBEXPORT ReadImageGeoreference (
00522 const FILEPATH& imgfilepath,
00523 SPATREF::COORDREFSYS& CoordRefSys,
00524 TRANS2D_AFFINE& TransAffine,
00525 SIMPLE_ARRAY<CTRLPOINT3>& CtrlPoints
00526 );
00527
00528
00529
00530 };
00531
00532 #undef CLASSLIBEXPORT
00533 #undef LIBEXPORT
00534
00535 #endif // INC_MI32_SPATREFEXT_H