gooderp18绿色标准版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

800 lines
33KB

  1. /******************************************************************************
  2. * $Id: ogr_spatialref.h aa2b46947ceef81934fef5a0fd4da1862ce71245 2019-05-23 21:34:37 +0200 Even Rouault $
  3. *
  4. * Project: OpenGIS Simple Features Reference Implementation
  5. * Purpose: Classes for manipulating spatial reference systems in a
  6. * platform non-specific manner.
  7. * Author: Frank Warmerdam, warmerdam@pobox.com
  8. *
  9. ******************************************************************************
  10. * Copyright (c) 1999, Les Technologies SoftMap Inc.
  11. * Copyright (c) 2008-2013, Even Rouault <even dot rouault at mines-paris dot org>
  12. *
  13. * Permission is hereby granted, free of charge, to any person obtaining a
  14. * copy of this software and associated documentation files (the "Software"),
  15. * to deal in the Software without restriction, including without limitation
  16. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  17. * and/or sell copies of the Software, and to permit persons to whom the
  18. * Software is furnished to do so, subject to the following conditions:
  19. *
  20. * The above copyright notice and this permission notice shall be included
  21. * in all copies or substantial portions of the Software.
  22. *
  23. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  24. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  25. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  26. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  27. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  28. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  29. * DEALINGS IN THE SOFTWARE.
  30. ****************************************************************************/
  31. #ifndef OGR_SPATIALREF_H_INCLUDED
  32. #define OGR_SPATIALREF_H_INCLUDED
  33. #include "cpl_string.h"
  34. #include "ogr_srs_api.h"
  35. #include <cstddef>
  36. #include <map>
  37. #include <memory>
  38. #include <vector>
  39. /**
  40. * \file ogr_spatialref.h
  41. *
  42. * Coordinate systems services.
  43. */
  44. /************************************************************************/
  45. /* OGR_SRSNode */
  46. /************************************************************************/
  47. /**
  48. * Objects of this class are used to represent value nodes in the parsed
  49. * representation of the WKT SRS format. For instance UNIT["METER",1]
  50. * would be rendered into three OGR_SRSNodes. The root node would have a
  51. * value of UNIT, and two children, the first with a value of METER, and the
  52. * second with a value of 1.
  53. *
  54. * Normally application code just interacts with the OGRSpatialReference
  55. * object, which uses the OGR_SRSNode to implement its data structure;
  56. * however, this class is user accessible for detailed access to components
  57. * of an SRS definition.
  58. */
  59. class CPL_DLL OGR_SRSNode
  60. {
  61. public:
  62. /** Listener that is notified of modification to nodes. */
  63. struct Listener
  64. {
  65. virtual ~Listener();
  66. /** Method triggered when a node is modified. */
  67. virtual void notifyChange(OGR_SRSNode*) = 0;
  68. };
  69. explicit OGR_SRSNode(const char * = nullptr);
  70. ~OGR_SRSNode();
  71. /** Register a (single) listener. */
  72. void RegisterListener(const std::shared_ptr<Listener>& listener);
  73. /** Return whether this is a leaf node.
  74. * @return TRUE or FALSE
  75. */
  76. int IsLeafNode() const { return nChildren == 0; }
  77. int GetChildCount() const { return nChildren; }
  78. OGR_SRSNode *GetChild( int );
  79. const OGR_SRSNode *GetChild( int ) const;
  80. OGR_SRSNode *GetNode( const char * );
  81. const OGR_SRSNode *GetNode( const char * ) const;
  82. void InsertChild( OGR_SRSNode *, int );
  83. void AddChild( OGR_SRSNode * );
  84. int FindChild( const char * ) const;
  85. void DestroyChild( int );
  86. void ClearChildren();
  87. void StripNodes( const char * );
  88. const char *GetValue() const { return pszValue; }
  89. void SetValue( const char * );
  90. void MakeValueSafe();
  91. OGR_SRSNode *Clone() const;
  92. OGRErr importFromWkt( char ** )
  93. /*! @cond Doxygen_Suppress */
  94. CPL_WARN_DEPRECATED("Use importFromWkt(const char**)")
  95. /*! @endcond */
  96. ;
  97. OGRErr importFromWkt( const char ** );
  98. OGRErr exportToWkt( char ** ) const;
  99. OGRErr exportToPrettyWkt( char **, int = 1) const;
  100. private:
  101. char *pszValue;
  102. OGR_SRSNode **papoChildNodes;
  103. OGR_SRSNode *poParent;
  104. int nChildren;
  105. int NeedsQuoting() const;
  106. OGRErr importFromWkt( const char **, int nRecLevel, int* pnNodes );
  107. std::weak_ptr<Listener> m_listener{};
  108. void notifyChange();
  109. CPL_DISALLOW_COPY_ASSIGN(OGR_SRSNode)
  110. };
  111. /************************************************************************/
  112. /* OGRSpatialReference */
  113. /************************************************************************/
  114. /**
  115. * This class represents an OpenGIS Spatial Reference System, and contains
  116. * methods for converting between this object organization and well known
  117. * text (WKT) format. This object is reference counted as one instance of
  118. * the object is normally shared between many OGRGeometry objects.
  119. *
  120. * Normally application code can fetch needed parameter values for this
  121. * SRS using GetAttrValue(), but in special cases the underlying parse tree
  122. * (or OGR_SRSNode objects) can be accessed more directly.
  123. *
  124. * See <a href="osr_tutorial.html">the tutorial</a> for more information on
  125. * how to use this class.
  126. *
  127. * Consult also the <a href="wktproblems.html">OGC WKT Coordinate System Issues</a> page
  128. * for implementation details of WKT in OGR.
  129. */
  130. class CPL_DLL OGRSpatialReference
  131. {
  132. struct Private;
  133. std::unique_ptr<Private> d;
  134. void GetNormInfo() const;
  135. OGRErr importFromURNPart(const char* pszAuthority,
  136. const char* pszCode,
  137. const char* pszURN);
  138. static CPLString lookupInDict( const char *pszDictFile,
  139. const char *pszCode );
  140. public:
  141. OGRSpatialReference(const OGRSpatialReference&);
  142. explicit OGRSpatialReference(const char * = nullptr);
  143. virtual ~OGRSpatialReference();
  144. static void DestroySpatialReference(OGRSpatialReference* poSRS);
  145. OGRSpatialReference &operator=(const OGRSpatialReference&);
  146. int Reference();
  147. int Dereference();
  148. int GetReferenceCount() const;
  149. void Release();
  150. const char* GetName() const;
  151. OGRSpatialReference *Clone() const;
  152. OGRSpatialReference *CloneGeogCS() const;
  153. void dumpReadable();
  154. OGRErr exportToWkt( char ** ) const;
  155. OGRErr exportToWkt( char ** ppszWKT, const char* const* papszOptions ) const;
  156. OGRErr exportToPrettyWkt( char **, int = FALSE) const;
  157. OGRErr exportToProj4( char ** ) const;
  158. OGRErr exportToPCI( char **, char **, double ** ) const;
  159. OGRErr exportToUSGS( long *, long *, double **, long * ) const;
  160. OGRErr exportToXML( char **, const char * = nullptr ) const;
  161. OGRErr exportToPanorama( long *, long *, long *, long *,
  162. double * ) const;
  163. OGRErr exportToERM( char *pszProj, char *pszDatum, char *pszUnits );
  164. OGRErr exportToMICoordSys( char ** ) const;
  165. OGRErr importFromWkt( char ** )
  166. /*! @cond Doxygen_Suppress */
  167. CPL_WARN_DEPRECATED("Use importFromWkt(const char**) or importFromWkt(const char*)")
  168. /*! @endcond */
  169. ;
  170. OGRErr importFromWkt( const char ** );
  171. OGRErr importFromWkt( const char* );
  172. OGRErr importFromProj4( const char * );
  173. OGRErr importFromEPSG( int );
  174. OGRErr importFromEPSGA( int );
  175. OGRErr importFromESRI( char ** );
  176. OGRErr importFromPCI( const char *, const char * = nullptr,
  177. double * = nullptr );
  178. #define USGS_ANGLE_DECIMALDEGREES 0 /**< Angle is in decimal degrees. */
  179. #define USGS_ANGLE_PACKEDDMS TRUE /**< Angle is in packed degree minute second. */
  180. #define USGS_ANGLE_RADIANS 2 /**< Angle is in radians. */
  181. OGRErr importFromUSGS( long iProjSys, long iZone,
  182. double *padfPrjParams, long iDatum,
  183. int nUSGSAngleFormat = USGS_ANGLE_PACKEDDMS );
  184. OGRErr importFromPanorama( long, long, long, double* );
  185. OGRErr importFromOzi( const char * const* papszLines );
  186. OGRErr importFromWMSAUTO( const char *pszAutoDef );
  187. OGRErr importFromXML( const char * );
  188. OGRErr importFromDict( const char *pszDict, const char *pszCode );
  189. OGRErr importFromURN( const char * );
  190. OGRErr importFromCRSURL( const char * );
  191. OGRErr importFromERM( const char *pszProj, const char *pszDatum,
  192. const char *pszUnits );
  193. OGRErr importFromUrl( const char * );
  194. OGRErr importFromMICoordSys( const char * );
  195. OGRErr morphToESRI();
  196. OGRErr morphFromESRI();
  197. OGRSpatialReference* convertToOtherProjection(
  198. const char* pszTargetProjection,
  199. const char* const* papszOptions = nullptr ) const;
  200. OGRErr Validate() const;
  201. OGRErr StripVertical();
  202. int EPSGTreatsAsLatLong() const;
  203. int EPSGTreatsAsNorthingEasting() const;
  204. int GetAxesCount() const;
  205. const char *GetAxis( const char *pszTargetKey, int iAxis,
  206. OGRAxisOrientation *peOrientation ) const;
  207. OGRErr SetAxes( const char *pszTargetKey,
  208. const char *pszXAxisName,
  209. OGRAxisOrientation eXAxisOrientation,
  210. const char *pszYAxisName,
  211. OGRAxisOrientation eYAxisOrientation );
  212. OSRAxisMappingStrategy GetAxisMappingStrategy() const;
  213. void SetAxisMappingStrategy(OSRAxisMappingStrategy);
  214. const std::vector<int>& GetDataAxisToSRSAxisMapping() const;
  215. OGRErr SetDataAxisToSRSAxisMapping(const std::vector<int>& mapping);
  216. // Machinery for accessing parse nodes
  217. //! Return root node
  218. OGR_SRSNode *GetRoot();
  219. //! Return root node
  220. const OGR_SRSNode *GetRoot() const;
  221. void SetRoot( OGR_SRSNode * );
  222. OGR_SRSNode *GetAttrNode(const char *);
  223. const OGR_SRSNode *GetAttrNode(const char *) const;
  224. const char *GetAttrValue(const char *, int = 0) const;
  225. OGRErr SetNode( const char *, const char * );
  226. OGRErr SetNode( const char *, double );
  227. OGRErr SetLinearUnitsAndUpdateParameters( const char *pszName,
  228. double dfInMeters,
  229. const char *pszUnitAuthority = nullptr,
  230. const char *pszUnitCode = nullptr );
  231. OGRErr SetLinearUnits( const char *pszName, double dfInMeters );
  232. OGRErr SetTargetLinearUnits( const char *pszTargetKey,
  233. const char *pszName,
  234. double dfInMeters,
  235. const char *pszUnitAuthority = nullptr,
  236. const char *pszUnitCode = nullptr);
  237. double GetLinearUnits( char ** ) const CPL_WARN_DEPRECATED("Use GetLinearUnits(const char**) instead");
  238. double GetLinearUnits( const char ** = nullptr ) const;
  239. /*! @cond Doxygen_Suppress */
  240. double GetLinearUnits( std::nullptr_t ) const
  241. { return GetLinearUnits( static_cast<const char**>(nullptr) ); }
  242. /*! @endcond */
  243. double GetTargetLinearUnits( const char *pszTargetKey,
  244. char ** ppszRetName ) const
  245. CPL_WARN_DEPRECATED("Use GetTargetLinearUnits(const char*, const char**)");
  246. double GetTargetLinearUnits( const char *pszTargetKey,
  247. const char ** ppszRetName = nullptr ) const;
  248. /*! @cond Doxygen_Suppress */
  249. double GetTargetLinearUnits( const char *pszTargetKey, std::nullptr_t ) const
  250. { return GetTargetLinearUnits( pszTargetKey, static_cast<const char**>(nullptr) ); }
  251. /*! @endcond */
  252. OGRErr SetAngularUnits( const char *pszName, double dfInRadians );
  253. double GetAngularUnits( char ** ) const CPL_WARN_DEPRECATED("Use GetAngularUnits(const char**) instead");
  254. double GetAngularUnits( const char ** = nullptr ) const;
  255. /*! @cond Doxygen_Suppress */
  256. double GetAngularUnits( std::nullptr_t ) const
  257. { return GetAngularUnits( static_cast<const char**>(nullptr) ); }
  258. /*! @endcond */
  259. double GetPrimeMeridian( char ** ) const CPL_WARN_DEPRECATED("Use GetPrimeMeridian(const char**) instead");
  260. double GetPrimeMeridian( const char ** = nullptr ) const;
  261. /*! @cond Doxygen_Suppress */
  262. double GetPrimeMeridian( std::nullptr_t ) const
  263. { return GetPrimeMeridian( static_cast<const char**>(nullptr) ); }
  264. /*! @endcond */
  265. bool IsEmpty() const;
  266. int IsGeographic() const;
  267. int IsProjected() const;
  268. int IsGeocentric() const;
  269. int IsLocal() const;
  270. int IsVertical() const;
  271. int IsCompound() const;
  272. int IsSameGeogCS( const OGRSpatialReference * ) const;
  273. int IsSameGeogCS( const OGRSpatialReference *,
  274. const char* const * papszOptions ) const;
  275. int IsSameVertCS( const OGRSpatialReference * ) const;
  276. int IsSame( const OGRSpatialReference * ) const;
  277. int IsSame( const OGRSpatialReference *,
  278. const char* const * papszOptions ) const;
  279. void Clear();
  280. OGRErr SetLocalCS( const char * );
  281. OGRErr SetProjCS( const char * );
  282. OGRErr SetProjection( const char * );
  283. OGRErr SetGeocCS( const char * pszGeocName );
  284. OGRErr SetGeogCS( const char * pszGeogName,
  285. const char * pszDatumName,
  286. const char * pszEllipsoidName,
  287. double dfSemiMajor, double dfInvFlattening,
  288. const char * pszPMName = nullptr,
  289. double dfPMOffset = 0.0,
  290. const char * pszUnits = nullptr,
  291. double dfConvertToRadians = 0.0 );
  292. OGRErr SetWellKnownGeogCS( const char * );
  293. OGRErr CopyGeogCSFrom( const OGRSpatialReference * poSrcSRS );
  294. OGRErr SetVertCS( const char *pszVertCSName,
  295. const char *pszVertDatumName,
  296. int nVertDatumClass = 2005 );
  297. OGRErr SetCompoundCS( const char *pszName,
  298. const OGRSpatialReference *poHorizSRS,
  299. const OGRSpatialReference *poVertSRS );
  300. OGRErr SetFromUserInput( const char * );
  301. OGRErr SetTOWGS84( double, double, double,
  302. double = 0.0, double = 0.0, double = 0.0,
  303. double = 0.0 );
  304. OGRErr GetTOWGS84( double *padfCoef, int nCoeff = 7 ) const;
  305. double GetSemiMajor( OGRErr * = nullptr ) const;
  306. double GetSemiMinor( OGRErr * = nullptr ) const;
  307. double GetInvFlattening( OGRErr * = nullptr ) const;
  308. double GetEccentricity() const;
  309. double GetSquaredEccentricity() const;
  310. OGRErr SetAuthority( const char * pszTargetKey,
  311. const char * pszAuthority,
  312. int nCode );
  313. OGRErr AutoIdentifyEPSG();
  314. OGRSpatialReferenceH* FindMatches( char** papszOptions,
  315. int* pnEntries,
  316. int** ppanMatchConfidence ) const;
  317. int GetEPSGGeogCS() const;
  318. const char *GetAuthorityCode( const char * pszTargetKey ) const;
  319. const char *GetAuthorityName( const char * pszTargetKey ) const;
  320. bool GetAreaOfUse( double* pdfWestLongitudeDeg,
  321. double* pdfSouthLatitudeDeg,
  322. double* pdfEastLongitudeDeg,
  323. double* pdfNorthLatitudeDeg,
  324. const char **ppszAreaName ) const;
  325. const char *GetExtension( const char *pszTargetKey,
  326. const char *pszName,
  327. const char *pszDefault = nullptr ) const;
  328. OGRErr SetExtension( const char *pszTargetKey,
  329. const char *pszName,
  330. const char *pszValue );
  331. int FindProjParm( const char *pszParameter,
  332. const OGR_SRSNode *poPROJCS=nullptr ) const;
  333. OGRErr SetProjParm( const char *, double );
  334. double GetProjParm( const char *, double =0.0, OGRErr* = nullptr ) const;
  335. OGRErr SetNormProjParm( const char *, double );
  336. double GetNormProjParm( const char *, double=0.0, OGRErr* =nullptr)const;
  337. static int IsAngularParameter( const char * );
  338. static int IsLongitudeParameter( const char * );
  339. static int IsLinearParameter( const char * );
  340. /** Albers Conic Equal Area */
  341. OGRErr SetACEA( double dfStdP1, double dfStdP2,
  342. double dfCenterLat, double dfCenterLong,
  343. double dfFalseEasting, double dfFalseNorthing );
  344. /** Azimuthal Equidistant */
  345. OGRErr SetAE( double dfCenterLat, double dfCenterLong,
  346. double dfFalseEasting, double dfFalseNorthing );
  347. /** Bonne */
  348. OGRErr SetBonne( double dfStdP1, double dfCentralMeridian,
  349. double dfFalseEasting, double dfFalseNorthing );
  350. /** Cylindrical Equal Area */
  351. OGRErr SetCEA( double dfStdP1, double dfCentralMeridian,
  352. double dfFalseEasting, double dfFalseNorthing );
  353. /** Cassini-Soldner */
  354. OGRErr SetCS( double dfCenterLat, double dfCenterLong,
  355. double dfFalseEasting, double dfFalseNorthing );
  356. /** Equidistant Conic */
  357. OGRErr SetEC( double dfStdP1, double dfStdP2,
  358. double dfCenterLat, double dfCenterLong,
  359. double dfFalseEasting, double dfFalseNorthing );
  360. /** Eckert I */
  361. OGRErr SetEckert( int nVariation, double dfCentralMeridian,
  362. double dfFalseEasting, double dfFalseNorthing );
  363. /** Eckert IV */
  364. OGRErr SetEckertIV( double dfCentralMeridian,
  365. double dfFalseEasting, double dfFalseNorthing );
  366. /** Eckert VI */
  367. OGRErr SetEckertVI( double dfCentralMeridian,
  368. double dfFalseEasting, double dfFalseNorthing );
  369. /** Equirectangular */
  370. OGRErr SetEquirectangular(double dfCenterLat, double dfCenterLong,
  371. double dfFalseEasting, double dfFalseNorthing );
  372. /** Equirectangular generalized form : */
  373. OGRErr SetEquirectangular2( double dfCenterLat, double dfCenterLong,
  374. double dfPseudoStdParallel1,
  375. double dfFalseEasting, double dfFalseNorthing );
  376. /** Geostationary Satellite */
  377. OGRErr SetGEOS( double dfCentralMeridian, double dfSatelliteHeight,
  378. double dfFalseEasting, double dfFalseNorthing );
  379. /** Goode Homolosine */
  380. OGRErr SetGH( double dfCentralMeridian,
  381. double dfFalseEasting, double dfFalseNorthing );
  382. /** Interrupted Goode Homolosine */
  383. OGRErr SetIGH();
  384. /** Gall Stereograpic */
  385. OGRErr SetGS( double dfCentralMeridian,
  386. double dfFalseEasting, double dfFalseNorthing );
  387. /** Gauss Schreiber Transverse Mercator */
  388. OGRErr SetGaussSchreiberTMercator(double dfCenterLat, double dfCenterLong,
  389. double dfScale,
  390. double dfFalseEasting, double dfFalseNorthing );
  391. /** Gnomonic */
  392. OGRErr SetGnomonic(double dfCenterLat, double dfCenterLong,
  393. double dfFalseEasting, double dfFalseNorthing );
  394. /** Hotine Oblique Mercator */
  395. OGRErr SetHOM( double dfCenterLat, double dfCenterLong,
  396. double dfAzimuth, double dfRectToSkew,
  397. double dfScale,
  398. double dfFalseEasting, double dfFalseNorthing );
  399. /** Hotine Oblique Mercator 2 points */
  400. OGRErr SetHOM2PNO( double dfCenterLat,
  401. double dfLat1, double dfLong1,
  402. double dfLat2, double dfLong2,
  403. double dfScale,
  404. double dfFalseEasting, double dfFalseNorthing );
  405. /** Hotine Oblique Mercator Azimuth Center / Variant B */
  406. OGRErr SetHOMAC( double dfCenterLat, double dfCenterLong,
  407. double dfAzimuth, double dfRectToSkew,
  408. double dfScale,
  409. double dfFalseEasting, double dfFalseNorthing );
  410. /** Laborde Oblique Mercator */
  411. OGRErr SetLOM( double dfCenterLat, double dfCenterLong,
  412. double dfAzimuth,
  413. double dfScale,
  414. double dfFalseEasting, double dfFalseNorthing );
  415. /** International Map of the World Polyconic */
  416. OGRErr SetIWMPolyconic( double dfLat1, double dfLat2,
  417. double dfCenterLong,
  418. double dfFalseEasting,
  419. double dfFalseNorthing );
  420. /** Krovak Oblique Conic Conformal */
  421. OGRErr SetKrovak( double dfCenterLat, double dfCenterLong,
  422. double dfAzimuth, double dfPseudoStdParallelLat,
  423. double dfScale,
  424. double dfFalseEasting, double dfFalseNorthing );
  425. /** Lambert Azimuthal Equal-Area */
  426. OGRErr SetLAEA( double dfCenterLat, double dfCenterLong,
  427. double dfFalseEasting, double dfFalseNorthing );
  428. /** Lambert Conformal Conic */
  429. OGRErr SetLCC( double dfStdP1, double dfStdP2,
  430. double dfCenterLat, double dfCenterLong,
  431. double dfFalseEasting, double dfFalseNorthing );
  432. /** Lambert Conformal Conic 1SP */
  433. OGRErr SetLCC1SP( double dfCenterLat, double dfCenterLong,
  434. double dfScale,
  435. double dfFalseEasting, double dfFalseNorthing );
  436. /** Lambert Conformal Conic (Belgium) */
  437. OGRErr SetLCCB( double dfStdP1, double dfStdP2,
  438. double dfCenterLat, double dfCenterLong,
  439. double dfFalseEasting, double dfFalseNorthing );
  440. /** Miller Cylindrical */
  441. OGRErr SetMC( double dfCenterLat, double dfCenterLong,
  442. double dfFalseEasting, double dfFalseNorthing );
  443. /** Mercator 1SP */
  444. OGRErr SetMercator( double dfCenterLat, double dfCenterLong,
  445. double dfScale,
  446. double dfFalseEasting, double dfFalseNorthing );
  447. /** Mercator 2SP */
  448. OGRErr SetMercator2SP( double dfStdP1,
  449. double dfCenterLat, double dfCenterLong,
  450. double dfFalseEasting, double dfFalseNorthing );
  451. /** Mollweide */
  452. OGRErr SetMollweide( double dfCentralMeridian,
  453. double dfFalseEasting, double dfFalseNorthing );
  454. /** New Zealand Map Grid */
  455. OGRErr SetNZMG( double dfCenterLat, double dfCenterLong,
  456. double dfFalseEasting, double dfFalseNorthing );
  457. /** Oblique Stereographic */
  458. OGRErr SetOS( double dfOriginLat, double dfCMeridian,
  459. double dfScale,
  460. double dfFalseEasting,double dfFalseNorthing);
  461. /** Orthographic */
  462. OGRErr SetOrthographic( double dfCenterLat, double dfCenterLong,
  463. double dfFalseEasting,double dfFalseNorthing);
  464. /** Polyconic */
  465. OGRErr SetPolyconic( double dfCenterLat, double dfCenterLong,
  466. double dfFalseEasting, double dfFalseNorthing );
  467. /** Polar Stereographic */
  468. OGRErr SetPS( double dfCenterLat, double dfCenterLong,
  469. double dfScale,
  470. double dfFalseEasting, double dfFalseNorthing);
  471. /** Robinson */
  472. OGRErr SetRobinson( double dfCenterLong,
  473. double dfFalseEasting, double dfFalseNorthing );
  474. /** Sinusoidal */
  475. OGRErr SetSinusoidal( double dfCenterLong,
  476. double dfFalseEasting, double dfFalseNorthing );
  477. /** Stereographic */
  478. OGRErr SetStereographic( double dfCenterLat, double dfCenterLong,
  479. double dfScale,
  480. double dfFalseEasting,double dfFalseNorthing);
  481. /** Swiss Oblique Cylindrical */
  482. OGRErr SetSOC( double dfLatitudeOfOrigin, double dfCentralMeridian,
  483. double dfFalseEasting, double dfFalseNorthing );
  484. /** Transverse Mercator */
  485. OGRErr SetTM( double dfCenterLat, double dfCenterLong,
  486. double dfScale,
  487. double dfFalseEasting, double dfFalseNorthing );
  488. /** Transverse Mercator variants. */
  489. OGRErr SetTMVariant( const char *pszVariantName,
  490. double dfCenterLat, double dfCenterLong,
  491. double dfScale,
  492. double dfFalseEasting, double dfFalseNorthing );
  493. /** Tunesia Mining Grid */
  494. OGRErr SetTMG( double dfCenterLat, double dfCenterLong,
  495. double dfFalseEasting, double dfFalseNorthing );
  496. /** Transverse Mercator (South Oriented) */
  497. OGRErr SetTMSO( double dfCenterLat, double dfCenterLong,
  498. double dfScale,
  499. double dfFalseEasting, double dfFalseNorthing );
  500. /** Two Point Equidistant */
  501. OGRErr SetTPED( double dfLat1, double dfLong1,
  502. double dfLat2, double dfLong2,
  503. double dfFalseEasting, double dfFalseNorthing );
  504. /** VanDerGrinten */
  505. OGRErr SetVDG( double dfCenterLong,
  506. double dfFalseEasting, double dfFalseNorthing );
  507. /** Universal Transverse Mercator */
  508. OGRErr SetUTM( int nZone, int bNorth = TRUE );
  509. int GetUTMZone( int *pbNorth = nullptr ) const;
  510. /** Wagner I -- VII */
  511. OGRErr SetWagner( int nVariation, double dfCenterLat,
  512. double dfFalseEasting, double dfFalseNorthing );
  513. /** Quadrilateralized Spherical Cube */
  514. OGRErr SetQSC(double dfCenterLat, double dfCenterLong);
  515. /** Spherical, Cross-track, Height */
  516. OGRErr SetSCH( double dfPegLat, double dfPegLong,
  517. double dfPegHeading, double dfPegHgt);
  518. /** State Plane */
  519. OGRErr SetStatePlane( int nZone, int bNAD83 = TRUE,
  520. const char *pszOverrideUnitName = nullptr,
  521. double dfOverrideUnit = 0.0 );
  522. /** ImportFromESRIStatePlaneWKT */
  523. OGRErr ImportFromESRIStatePlaneWKT(
  524. int nCode, const char* pszDatumName, const char* pszUnitsName,
  525. int nPCSCode, const char* pszCRSName = nullptr );
  526. /** ImportFromESRIWisconsinWKT */
  527. OGRErr ImportFromESRIWisconsinWKT(
  528. const char* pszPrjName, double dfCentralMeridian, double dfLatOfOrigin,
  529. const char* pszUnitsName, const char* pszCRSName = nullptr );
  530. static OGRSpatialReference* GetWGS84SRS();
  531. /** Convert a OGRSpatialReference* to a OGRSpatialReferenceH.
  532. * @since GDAL 2.3
  533. */
  534. static inline OGRSpatialReferenceH ToHandle(OGRSpatialReference* poSRS)
  535. { return reinterpret_cast<OGRSpatialReferenceH>(poSRS); }
  536. /** Convert a OGRSpatialReferenceH to a OGRSpatialReference*.
  537. * @since GDAL 2.3
  538. */
  539. static inline OGRSpatialReference* FromHandle(OGRSpatialReferenceH hSRS)
  540. { return reinterpret_cast<OGRSpatialReference*>(hSRS); }
  541. };
  542. /************************************************************************/
  543. /* OGRCoordinateTransformation */
  544. /* */
  545. /* This is really just used as a base class for a private */
  546. /* implementation. */
  547. /************************************************************************/
  548. /**
  549. * Interface for transforming between coordinate systems.
  550. *
  551. * Currently, the only implementation within OGR is OGRProjCT, which
  552. * requires the PROJ library.
  553. *
  554. * Also, see OGRCreateCoordinateTransformation() for creating transformations.
  555. */
  556. class CPL_DLL OGRCoordinateTransformation
  557. {
  558. public:
  559. virtual ~OGRCoordinateTransformation() {}
  560. static void DestroyCT(OGRCoordinateTransformation* poCT);
  561. // From CT_CoordinateTransformation
  562. /** Fetch internal source coordinate system. */
  563. virtual OGRSpatialReference *GetSourceCS() = 0;
  564. /** Fetch internal target coordinate system. */
  565. virtual OGRSpatialReference *GetTargetCS() = 0;
  566. /** Whether the transformer will emit CPLError */
  567. virtual bool GetEmitErrors() const { return false; }
  568. /** Set if the transformer must emit CPLError */
  569. virtual void SetEmitErrors(bool /*bEmitErrors*/) {}
  570. // From CT_MathTransform
  571. /**
  572. * Transform points from source to destination space.
  573. *
  574. * This method is the same as the C function OCTTransformEx().
  575. *
  576. * @param nCount number of points to transform.
  577. * @param x array of nCount X vertices, modified in place. Should not be NULL.
  578. * @param y array of nCount Y vertices, modified in place. Should not be NULL.
  579. * @param z array of nCount Z vertices, modified in place. Might be NULL.
  580. * @param pabSuccess array of per-point flags set to TRUE if that point
  581. * transforms, or FALSE if it does not. Might be NULL.
  582. *
  583. * @return TRUE if some or all points transform successfully, or FALSE if
  584. * if none transform.
  585. */
  586. int Transform( int nCount,
  587. double *x, double *y, double *z = nullptr,
  588. int *pabSuccess = nullptr );
  589. /**
  590. * Transform points from source to destination space.
  591. *
  592. * This method is the same as the C function OCTTransform4D().
  593. *
  594. * @param nCount number of points to transform.
  595. * @param x array of nCount X vertices, modified in place. Should not be NULL.
  596. * @param y array of nCount Y vertices, modified in place. Should not be NULL.
  597. * @param z array of nCount Z vertices, modified in place. Might be NULL.
  598. * @param t array of nCount time values, modified in place. Might be NULL.
  599. * @param pabSuccess array of per-point flags set to TRUE if that point
  600. * transforms, or FALSE if it does not. Might be NULL.
  601. *
  602. * @return TRUE if some or all points transform successfully, or FALSE if
  603. * if none transform.
  604. */
  605. virtual int Transform( int nCount,
  606. double *x, double *y,
  607. double *z, double *t,
  608. int *pabSuccess ) = 0;
  609. /** Convert a OGRCoordinateTransformation* to a OGRCoordinateTransformationH.
  610. * @since GDAL 2.3
  611. */
  612. static inline OGRCoordinateTransformationH ToHandle(OGRCoordinateTransformation* poCT)
  613. { return reinterpret_cast<OGRCoordinateTransformationH>(poCT); }
  614. /** Convert a OGRCoordinateTransformationH to a OGRCoordinateTransformation*.
  615. * @since GDAL 2.3
  616. */
  617. static inline OGRCoordinateTransformation* FromHandle(OGRCoordinateTransformationH hCT)
  618. { return reinterpret_cast<OGRCoordinateTransformation*>(hCT); }
  619. };
  620. OGRCoordinateTransformation CPL_DLL *
  621. OGRCreateCoordinateTransformation( const OGRSpatialReference *poSource,
  622. const OGRSpatialReference *poTarget );
  623. /**
  624. * Context for coordinate transformation.
  625. *
  626. * @since GDAL 3.0
  627. */
  628. struct CPL_DLL OGRCoordinateTransformationOptions
  629. {
  630. private:
  631. friend class OGRProjCT;
  632. struct Private;
  633. std::unique_ptr<Private> d;
  634. public:
  635. OGRCoordinateTransformationOptions();
  636. ~OGRCoordinateTransformationOptions();
  637. bool SetAreaOfInterest(double dfWestLongitudeDeg,
  638. double dfSouthLatitudeDeg,
  639. double dfEastLongitudeDeg,
  640. double dfNorthLatitudeDeg);
  641. bool SetCoordinateOperation(const char* pszCT, bool bReverseCT);
  642. /*! @cond Doxygen_Suppress */
  643. void SetSourceCenterLong(double dfCenterLong);
  644. void SetTargetCenterLong(double dfCenterLong);
  645. /*! @endcond */
  646. };
  647. OGRCoordinateTransformation CPL_DLL *
  648. OGRCreateCoordinateTransformation( const OGRSpatialReference *poSource,
  649. const OGRSpatialReference *poTarget,
  650. const OGRCoordinateTransformationOptions& options );
  651. #endif /* ndef OGR_SPATIALREF_H_INCLUDED */
上海开阖软件有限公司 沪ICP备12045867号-1