GDAL

ogr_spatialref.h
Go to the documentation of this file.
1 /******************************************************************************
2 * $Id$
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 spatialys.com>
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
32 #ifndef OGR_SPATIALREF_H_INCLUDED
33 #define OGR_SPATIALREF_H_INCLUDED
34
35 #include "cpl_string.h"
36 #include "ogr_srs_api.h"
37
38 #include <cstddef>
39 #include <map>
40 #include <memory>
41 #include <vector>
42
49 /************************************************************************/
50 /* OGR_SRSNode */
51 /************************************************************************/
52
66 class CPL_DLL OGR_SRSNode
67 {
68 public:
70 struct Listener
71 {
72 virtual ~Listener();
74 virtual void notifyChange(OGR_SRSNode *) = 0;
75 };
76
77 explicit OGR_SRSNode(const char * = nullptr);
78 ~OGR_SRSNode();
79
81 void RegisterListener(const std::shared_ptr<Listener> &listener);
82
86 int IsLeafNode() const
87 {
88 return nChildren == 0;
89 }
90
91 int GetChildCount() const
92 {
93 return nChildren;
94 }
95 OGR_SRSNode *GetChild(int);
96 const OGR_SRSNode *GetChild(int) const;
97
98 OGR_SRSNode *GetNode(const char *);
99 const OGR_SRSNode *GetNode(const char *) const;
100
101 void InsertChild(OGR_SRSNode *, int);
102 void AddChild(OGR_SRSNode *);
103 int FindChild(const char *) const;
104 void DestroyChild(int);
105 void ClearChildren();
106 void StripNodes(const char *);
107
108 const char *GetValue() const
109 {
110 return pszValue;
111 }
112 void SetValue(const char *);
113
114 void MakeValueSafe();
115
116 OGR_SRSNode *Clone() const;
117
118 OGRErr importFromWkt(char **)
120 CPL_WARN_DEPRECATED("Use importFromWkt(const char**)")
122 ;
123 OGRErr importFromWkt(const char **);
124 OGRErr exportToWkt(char **) const;
125 OGRErr exportToPrettyWkt(char **, int = 1) const;
126
127 private:
128 char *pszValue;
129
130 OGR_SRSNode **papoChildNodes;
131 OGR_SRSNode *poParent;
132
133 int nChildren;
134
135 int NeedsQuoting() const;
136 OGRErr importFromWkt(const char **, int nRecLevel, int *pnNodes);
137
138 std::weak_ptr<Listener> m_listener{};
139 void notifyChange();
140
141 CPL_DISALLOW_COPY_ASSIGN(OGR_SRSNode)
142 };
143
144 /************************************************************************/
145 /* OGRSpatialReference */
146 /************************************************************************/
147
166 class CPL_DLL OGRSpatialReference
167 {
168 struct Private;
169 std::unique_ptr<Private> d;
170
171 void GetNormInfo() const;
172
173 // No longer used with PROJ >= 8.1.0
174 OGRErr importFromURNPart(const char *pszAuthority, const char *pszCode,
175 const char *pszURN);
176
177 static CPLString lookupInDict(const char *pszDictFile, const char *pszCode);
178
179 OGRErr GetWKT2ProjectionMethod(const char **ppszMethodName,
180 const char **ppszMethodAuthName = nullptr,
181 const char **ppszMethodCode = nullptr) const;
182
183 public:
184 explicit OGRSpatialReference(const char * = nullptr);
185 OGRSpatialReference(const OGRSpatialReference &);
186 OGRSpatialReference(OGRSpatialReference &&);
187
188 virtual ~OGRSpatialReference();
189
190 static void DestroySpatialReference(OGRSpatialReference *poSRS);
191
192 OGRSpatialReference &operator=(const OGRSpatialReference &);
193 OGRSpatialReference &operator=(OGRSpatialReference &&);
194
195 int Reference();
196 int Dereference();
197 int GetReferenceCount() const;
198 void Release();
199
200 const char *GetName() const;
201
202 OGRSpatialReference *Clone() const;
203 OGRSpatialReference *CloneGeogCS() const;
204
205 void dumpReadable();
206 OGRErr exportToWkt(char **) const;
207 OGRErr exportToWkt(char **ppszWKT, const char *const *papszOptions) const;
208 OGRErr exportToPrettyWkt(char **, int = FALSE) const;
209 // cppcheck-suppress functionStatic
210 OGRErr exportToPROJJSON(char **, const char *const *papszOptions) const;
211 OGRErr exportToProj4(char **) const;
212 OGRErr exportToPCI(char **, char **, double **) const;
213 OGRErr exportToUSGS(long *, long *, double **, long *) const;
214 OGRErr exportToXML(char **, const char * = nullptr) const;
215 OGRErr exportToPanorama(long *, long *, long *, long *, double *) const;
216 OGRErr exportVertCSToPanorama(int *) const;
217 OGRErr exportToERM(char *pszProj, char *pszDatum, char *pszUnits);
218 OGRErr exportToMICoordSys(char **) const;
219
220 OGRErr importFromWkt(char **)
222 CPL_WARN_DEPRECATED(
223 "Use importFromWkt(const char**) or importFromWkt(const char*)")
225 ;
226
227 OGRErr importFromWkt(const char **);
229 OGRErr importFromWkt(const char *pszInput, CSLConstList papszOptions);
230 OGRErr importFromWkt(const char **ppszInput, CSLConstList papszOptions);
232 OGRErr importFromWkt(const char *);
233 OGRErr importFromProj4(const char *);
234 OGRErr importFromEPSG(int);
235 OGRErr importFromEPSGA(int);
236 OGRErr importFromESRI(char **);
237 OGRErr importFromPCI(const char *, const char * = nullptr,
238 const double * = nullptr);
239
240 #define USGS_ANGLE_DECIMALDEGREES 0
241 #define USGS_ANGLE_PACKEDDMS \
242 TRUE
243 #define USGS_ANGLE_RADIANS 2
244 OGRErr importFromUSGS(long iProjSys, long iZone, double *padfPrjParams,
245 long iDatum,
246 int nUSGSAngleFormat = USGS_ANGLE_PACKEDDMS);
247 OGRErr importFromPanorama(long, long, long, double *, bool bNorth = true);
248 OGRErr importVertCSFromPanorama(int);
249 OGRErr importFromOzi(const char *const *papszLines);
250 OGRErr importFromWMSAUTO(const char *pszAutoDef);
251 OGRErr importFromXML(const char *);
252 OGRErr importFromDict(const char *pszDict, const char *pszCode);
253 OGRErr importFromURN(const char *);
254 OGRErr importFromCRSURL(const char *);
255 OGRErr importFromERM(const char *pszProj, const char *pszDatum,
256 const char *pszUnits);
257 OGRErr importFromUrl(const char *);
258 OGRErr importFromMICoordSys(const char *);
259
260 OGRErr morphToESRI();
261 OGRErr morphFromESRI();
262
263 OGRSpatialReference *
264 convertToOtherProjection(const char *pszTargetProjection,
265 const char *const *papszOptions = nullptr) const;
266
267 OGRErr Validate() const;
268 OGRErr StripVertical();
269
270 bool StripTOWGS84IfKnownDatumAndAllowed();
271 bool StripTOWGS84IfKnownDatum();
272
273 int EPSGTreatsAsLatLong() const;
274 int EPSGTreatsAsNorthingEasting() const;
275 int GetAxesCount() const;
276 const char *GetAxis(const char *pszTargetKey, int iAxis,
277 OGRAxisOrientation *peOrientation,
278 double *pdfConvFactor = nullptr) const;
279 OGRErr SetAxes(const char *pszTargetKey, const char *pszXAxisName,
280 OGRAxisOrientation eXAxisOrientation,
281 const char *pszYAxisName,
282 OGRAxisOrientation eYAxisOrientation);
283
284 OSRAxisMappingStrategy GetAxisMappingStrategy() const;
285 void SetAxisMappingStrategy(OSRAxisMappingStrategy);
286 const std::vector<int> &GetDataAxisToSRSAxisMapping() const;
287 OGRErr SetDataAxisToSRSAxisMapping(const std::vector<int> &mapping);
288
289 // Machinery for accessing parse nodes
290
292 OGR_SRSNode *GetRoot();
294 const OGR_SRSNode *GetRoot() const;
295 void SetRoot(OGR_SRSNode *);
296
297 OGR_SRSNode *GetAttrNode(const char *);
298 const OGR_SRSNode *GetAttrNode(const char *) const;
299 const char *GetAttrValue(const char *, int = 0) const;
300
301 OGRErr SetNode(const char *, const char *);
302 // cppcheck-suppress functionStatic
303 OGRErr SetNode(const char *, double);
304
305 OGRErr
306 SetLinearUnitsAndUpdateParameters(const char *pszName, double dfInMeters,
307 const char *pszUnitAuthority = nullptr,
308 const char *pszUnitCode = nullptr);
309 OGRErr SetLinearUnits(const char *pszName, double dfInMeters);
310 OGRErr SetTargetLinearUnits(const char *pszTargetKey, const char *pszName,
311 double dfInMeters,
312 const char *pszUnitAuthority = nullptr,
313 const char *pszUnitCode = nullptr);
314
315 double GetLinearUnits(char **) const
317 CPL_WARN_DEPRECATED("Use GetLinearUnits(const char**) instead")
319 ;
320 double GetLinearUnits(const char ** = nullptr) const;
322 double GetLinearUnits(std::nullptr_t) const
323 {
324 return GetLinearUnits(static_cast<const char **>(nullptr));
325 }
328 double GetTargetLinearUnits(const char *pszTargetKey,
329 char **ppszRetName) const
331 CPL_WARN_DEPRECATED(
332 "Use GetTargetLinearUnits(const char*, const char**)")
334 ;
335 double GetTargetLinearUnits(const char *pszTargetKey,
336 const char **ppszRetName = nullptr) const;
338 double GetTargetLinearUnits(const char *pszTargetKey, std::nullptr_t) const
339 {
340 return GetTargetLinearUnits(pszTargetKey,
341 static_cast<const char **>(nullptr));
342 }
345 OGRErr SetAngularUnits(const char *pszName, double dfInRadians);
346 double GetAngularUnits(char **) const
348 CPL_WARN_DEPRECATED("Use GetAngularUnits(const char**) instead")
350 ;
351 double GetAngularUnits(const char ** = nullptr) const;
353 double GetAngularUnits(std::nullptr_t) const
354 {
355 return GetAngularUnits(static_cast<const char **>(nullptr));
356 }
359 double GetPrimeMeridian(char **) const
361 CPL_WARN_DEPRECATED("Use GetPrimeMeridian(const char**) instead")
363 ;
364 double GetPrimeMeridian(const char ** = nullptr) const;
366 double GetPrimeMeridian(std::nullptr_t) const
367 {
368 return GetPrimeMeridian(static_cast<const char **>(nullptr));
369 }
372 bool IsEmpty() const;
373 int IsGeographic() const;
374 int IsDerivedGeographic() const;
375 int IsProjected() const;
376 int IsGeocentric() const;
377 bool IsDynamic() const;
378
379 // cppcheck-suppress functionStatic
380 bool HasPointMotionOperation() const;
381
382 int IsLocal() const;
383 int IsVertical() const;
384 int IsCompound() const;
385 int IsSameGeogCS(const OGRSpatialReference *) const;
386 int IsSameGeogCS(const OGRSpatialReference *,
387 const char *const *papszOptions) const;
388 int IsSameVertCS(const OGRSpatialReference *) const;
389 int IsSame(const OGRSpatialReference *) const;
390 int IsSame(const OGRSpatialReference *,
391 const char *const *papszOptions) const;
392
393 void Clear();
394 OGRErr SetLocalCS(const char *);
395 OGRErr SetProjCS(const char *);
396 OGRErr SetProjection(const char *);
397 OGRErr SetGeocCS(const char *pszGeocName);
398 OGRErr SetGeogCS(const char *pszGeogName, const char *pszDatumName,
399 const char *pszEllipsoidName, double dfSemiMajor,
400 double dfInvFlattening, const char *pszPMName = nullptr,
401 double dfPMOffset = 0.0, const char *pszUnits = nullptr,
402 double dfConvertToRadians = 0.0);
403 OGRErr SetWellKnownGeogCS(const char *);
404 OGRErr CopyGeogCSFrom(const OGRSpatialReference *poSrcSRS);
405 OGRErr SetVertCS(const char *pszVertCSName, const char *pszVertDatumName,
406 int nVertDatumClass = 2005);
407 OGRErr SetCompoundCS(const char *pszName,
408 const OGRSpatialReference *poHorizSRS,
409 const OGRSpatialReference *poVertSRS);
410
411 void SetCoordinateEpoch(double dfCoordinateEpoch);
412 double GetCoordinateEpoch() const;
413
414 // cppcheck-suppress functionStatic
415 OGRErr PromoteTo3D(const char *pszName);
416 // cppcheck-suppress functionStatic
417 OGRErr DemoteTo2D(const char *pszName);
418
419 OGRErr SetFromUserInput(const char *);
420
421 static const char *const SET_FROM_USER_INPUT_LIMITATIONS[];
422 static CSLConstList SET_FROM_USER_INPUT_LIMITATIONS_get();
423
424 OGRErr SetFromUserInput(const char *, CSLConstList papszOptions);
425
426 OGRErr SetTOWGS84(double, double, double, double = 0.0, double = 0.0,
427 double = 0.0, double = 0.0);
428 OGRErr GetTOWGS84(double *padfCoef, int nCoeff = 7) const;
429 OGRErr AddGuessedTOWGS84();
430
431 double GetSemiMajor(OGRErr * = nullptr) const;
432 double GetSemiMinor(OGRErr * = nullptr) const;
433 double GetInvFlattening(OGRErr * = nullptr) const;
434 double GetEccentricity() const;
435 double GetSquaredEccentricity() const;
436
437 OGRErr SetAuthority(const char *pszTargetKey, const char *pszAuthority,
438 int nCode);
439
440 OGRErr AutoIdentifyEPSG();
441 OGRSpatialReferenceH *FindMatches(char **papszOptions, int *pnEntries,
442 int **ppanMatchConfidence) const;
443 OGRSpatialReference *
444 FindBestMatch(int nMinimumMatchConfidence = 90,
445 const char *pszPreferredAuthority = "EPSG",
446 CSLConstList papszOptions = nullptr) const;
447
448 int GetEPSGGeogCS() const;
449
450 const char *GetAuthorityCode(const char *pszTargetKey) const;
451 const char *GetAuthorityName(const char *pszTargetKey) const;
452 char *GetOGCURN() const;
453
454 bool GetAreaOfUse(double *pdfWestLongitudeDeg, double *pdfSouthLatitudeDeg,
455 double *pdfEastLongitudeDeg, double *pdfNorthLatitudeDeg,
456 const char **ppszAreaName) const;
457
458 const char *GetExtension(const char *pszTargetKey, const char *pszName,
459 const char *pszDefault = nullptr) const;
460 OGRErr SetExtension(const char *pszTargetKey, const char *pszName,
461 const char *pszValue);
462
463 int FindProjParm(const char *pszParameter,
464 const OGR_SRSNode *poPROJCS = nullptr) const;
465 OGRErr SetProjParm(const char *, double);
466 double GetProjParm(const char *, double = 0.0, OGRErr * = nullptr) const;
467
468 OGRErr SetNormProjParm(const char *, double);
469 double GetNormProjParm(const char *, double = 0.0,
470 OGRErr * = nullptr) const;
471
472 static int IsAngularParameter(const char *);
473 static int IsLongitudeParameter(const char *);
474 static int IsLinearParameter(const char *);
475
477 OGRErr SetACEA(double dfStdP1, double dfStdP2, double dfCenterLat,
478 double dfCenterLong, double dfFalseEasting,
479 double dfFalseNorthing);
480
482 OGRErr SetAE(double dfCenterLat, double dfCenterLong, double dfFalseEasting,
483 double dfFalseNorthing);
484
486 OGRErr SetBonne(double dfStdP1, double dfCentralMeridian,
487 double dfFalseEasting, double dfFalseNorthing);
488
490 OGRErr SetCEA(double dfStdP1, double dfCentralMeridian,
491 double dfFalseEasting, double dfFalseNorthing);
492
494 OGRErr SetCS(double dfCenterLat, double dfCenterLong, double dfFalseEasting,
495 double dfFalseNorthing);
496
498 OGRErr SetEC(double dfStdP1, double dfStdP2, double dfCenterLat,
499 double dfCenterLong, double dfFalseEasting,
500 double dfFalseNorthing);
501
503 OGRErr SetEckert(int nVariation, double dfCentralMeridian,
504 double dfFalseEasting, double dfFalseNorthing);
505
507 OGRErr SetEckertIV(double dfCentralMeridian, double dfFalseEasting,
508 double dfFalseNorthing);
509
511 OGRErr SetEckertVI(double dfCentralMeridian, double dfFalseEasting,
512 double dfFalseNorthing);
513
515 OGRErr SetEquirectangular(double dfCenterLat, double dfCenterLong,
516 double dfFalseEasting, double dfFalseNorthing);
518 OGRErr SetEquirectangular2(double dfCenterLat, double dfCenterLong,
519 double dfPseudoStdParallel1,
520 double dfFalseEasting, double dfFalseNorthing);
521
523 OGRErr SetGEOS(double dfCentralMeridian, double dfSatelliteHeight,
524 double dfFalseEasting, double dfFalseNorthing);
525
527 OGRErr SetGH(double dfCentralMeridian, double dfFalseEasting,
528 double dfFalseNorthing);
529
531 OGRErr SetIGH();
532
534 OGRErr SetGS(double dfCentralMeridian, double dfFalseEasting,
535 double dfFalseNorthing);
536
538 OGRErr SetGaussSchreiberTMercator(double dfCenterLat, double dfCenterLong,
539 double dfScale, double dfFalseEasting,
540 double dfFalseNorthing);
541
543 OGRErr SetGnomonic(double dfCenterLat, double dfCenterLong,
544 double dfFalseEasting, double dfFalseNorthing);
545
547 OGRErr SetHOM(double dfCenterLat, double dfCenterLong, double dfAzimuth,
548 double dfRectToSkew, double dfScale, double dfFalseEasting,
549 double dfFalseNorthing);
550
552 OGRErr SetHOM2PNO(double dfCenterLat, double dfLat1, double dfLong1,
553 double dfLat2, double dfLong2, double dfScale,
554 double dfFalseEasting, double dfFalseNorthing);
555
557 OGRErr SetHOMAC(double dfCenterLat, double dfCenterLong, double dfAzimuth,
558 double dfRectToSkew, double dfScale, double dfFalseEasting,
559 double dfFalseNorthing);
560
562 OGRErr SetLOM(double dfCenterLat, double dfCenterLong, double dfAzimuth,
563 double dfScale, double dfFalseEasting,
564 double dfFalseNorthing);
565
567 OGRErr SetIWMPolyconic(double dfLat1, double dfLat2, double dfCenterLong,
568 double dfFalseEasting, double dfFalseNorthing);
569
571 OGRErr SetKrovak(double dfCenterLat, double dfCenterLong, double dfAzimuth,
572 double dfPseudoStdParallelLat, double dfScale,
573 double dfFalseEasting, double dfFalseNorthing);
574
576 OGRErr SetLAEA(double dfCenterLat, double dfCenterLong,
577 double dfFalseEasting, double dfFalseNorthing);
578
580 OGRErr SetLCC(double dfStdP1, double dfStdP2, double dfCenterLat,
581 double dfCenterLong, double dfFalseEasting,
582 double dfFalseNorthing);
583
585 OGRErr SetLCC1SP(double dfCenterLat, double dfCenterLong, double dfScale,
586 double dfFalseEasting, double dfFalseNorthing);
587
589 OGRErr SetLCCB(double dfStdP1, double dfStdP2, double dfCenterLat,
590 double dfCenterLong, double dfFalseEasting,
591 double dfFalseNorthing);
592
594 OGRErr SetMC(double dfCenterLat, double dfCenterLong, double dfFalseEasting,
595 double dfFalseNorthing);
596
598 OGRErr SetMercator(double dfCenterLat, double dfCenterLong, double dfScale,
599 double dfFalseEasting, double dfFalseNorthing);
600
602 OGRErr SetMercator2SP(double dfStdP1, double dfCenterLat,
603 double dfCenterLong, double dfFalseEasting,
604 double dfFalseNorthing);
605
607 OGRErr SetMollweide(double dfCentralMeridian, double dfFalseEasting,
608 double dfFalseNorthing);
609
611 OGRErr SetNZMG(double dfCenterLat, double dfCenterLong,
612 double dfFalseEasting, double dfFalseNorthing);
613
615 OGRErr SetOS(double dfOriginLat, double dfCMeridian, double dfScale,
616 double dfFalseEasting, double dfFalseNorthing);
617
619 OGRErr SetOrthographic(double dfCenterLat, double dfCenterLong,
620 double dfFalseEasting, double dfFalseNorthing);
621
623 OGRErr SetPolyconic(double dfCenterLat, double dfCenterLong,
624 double dfFalseEasting, double dfFalseNorthing);
625
627 OGRErr SetPS(double dfCenterLat, double dfCenterLong, double dfScale,
628 double dfFalseEasting, double dfFalseNorthing);
629
631 OGRErr SetRobinson(double dfCenterLong, double dfFalseEasting,
632 double dfFalseNorthing);
633
635 OGRErr SetSinusoidal(double dfCenterLong, double dfFalseEasting,
636 double dfFalseNorthing);
637
639 OGRErr SetStereographic(double dfCenterLat, double dfCenterLong,
640 double dfScale, double dfFalseEasting,
641 double dfFalseNorthing);
642
644 OGRErr SetSOC(double dfLatitudeOfOrigin, double dfCentralMeridian,
645 double dfFalseEasting, double dfFalseNorthing);
646
648 OGRErr SetTM(double dfCenterLat, double dfCenterLong, double dfScale,
649 double dfFalseEasting, double dfFalseNorthing);
650
652 OGRErr SetTMVariant(const char *pszVariantName, double dfCenterLat,
653 double dfCenterLong, double dfScale,
654 double dfFalseEasting, double dfFalseNorthing);
655
657 OGRErr SetTMG(double dfCenterLat, double dfCenterLong,
658 double dfFalseEasting, double dfFalseNorthing);
659
661 OGRErr SetTMSO(double dfCenterLat, double dfCenterLong, double dfScale,
662 double dfFalseEasting, double dfFalseNorthing);
663
665 OGRErr SetTPED(double dfLat1, double dfLong1, double dfLat2, double dfLong2,
666 double dfFalseEasting, double dfFalseNorthing);
667
669 OGRErr SetVDG(double dfCenterLong, double dfFalseEasting,
670 double dfFalseNorthing);
671
673 OGRErr SetUTM(int nZone, int bNorth = TRUE);
674 int GetUTMZone(int *pbNorth = nullptr) const;
675
677 OGRErr SetWagner(int nVariation, double dfCenterLat, double dfFalseEasting,
678 double dfFalseNorthing);
679
681 OGRErr SetQSC(double dfCenterLat, double dfCenterLong);
682
684 OGRErr SetSCH(double dfPegLat, double dfPegLong, double dfPegHeading,
685 double dfPegHgt);
686
688 OGRErr
689 SetVerticalPerspective(double dfTopoOriginLat, double dfTopoOriginLon,
690 double dfTopoOriginHeight, double dfViewPointHeight,
691 double dfFalseEasting, double dfFalseNorthing);
692
694 OGRErr SetDerivedGeogCRSWithPoleRotationGRIBConvention(
695 const char *pszCRSName, double dfSouthPoleLat, double dfSouthPoleLon,
696 double dfAxisRotation);
697
699 OGRErr SetDerivedGeogCRSWithPoleRotationNetCDFCFConvention(
700 const char *pszCRSName, double dfGridNorthPoleLat,
701 double dfGridNorthPoleLon, double dfNorthPoleGridLon);
702
704 OGRErr SetStatePlane(int nZone, int bNAD83 = TRUE,
705 const char *pszOverrideUnitName = nullptr,
706 double dfOverrideUnit = 0.0);
707
709 OGRErr ImportFromESRIStatePlaneWKT(int nCode, const char *pszDatumName,
710 const char *pszUnitsName, int nPCSCode,
711 const char *pszCRSName = nullptr);
712
714 OGRErr ImportFromESRIWisconsinWKT(const char *pszPrjName,
715 double dfCentralMeridian,
716 double dfLatOfOrigin,
717 const char *pszUnitsName,
718 const char *pszCRSName = nullptr);
719
721 void UpdateCoordinateSystemFromGeogCRS();
724 static OGRSpatialReference *GetWGS84SRS();
725
729 static inline OGRSpatialReferenceH ToHandle(OGRSpatialReference *poSRS)
730 {
731 return reinterpret_cast<OGRSpatialReferenceH>(poSRS);
732 }
733
737 static inline OGRSpatialReference *FromHandle(OGRSpatialReferenceH hSRS)
738 {
739 return reinterpret_cast<OGRSpatialReference *>(hSRS);
740 }
741 };
742
744 struct CPL_DLL OGRSpatialReferenceReleaser
745 {
746 void operator()(OGRSpatialReference *poSRS) const
747 {
748 if (poSRS)
749 poSRS->Release();
750 }
751 };
754 /************************************************************************/
755 /* OGRCoordinateTransformation */
756 /* */
757 /* This is really just used as a base class for a private */
758 /* implementation. */
759 /************************************************************************/
760
770 class CPL_DLL OGRCoordinateTransformation
771 {
772 public:
773 virtual ~OGRCoordinateTransformation()
774 {
775 }
776
777 static void DestroyCT(OGRCoordinateTransformation *poCT);
778
779 // From CT_CoordinateTransformation
780
782 virtual const OGRSpatialReference *GetSourceCS() const = 0;
783
785 virtual const OGRSpatialReference *GetTargetCS() const = 0;
786
788 virtual bool GetEmitErrors() const
789 {
790 return false;
791 }
792
794 virtual void SetEmitErrors(bool /*bEmitErrors*/)
795 {
796 }
797
798 // From CT_MathTransform
799
817 int Transform(int nCount, double *x, double *y, double *z = nullptr,
818 int *pabSuccess = nullptr);
819
838 virtual int Transform(int nCount, double *x, double *y, double *z,
839 double *t, int *pabSuccess) = 0;
840
860 virtual int TransformWithErrorCodes(int nCount, double *x, double *y,
861 double *z, double *t,
862 int *panErrorCodes);
863
900 virtual int TransformBounds(const double xmin, const double ymin,
901 const double xmax, const double ymax,
902 double *out_xmin, double *out_ymin,
903 double *out_xmax, double *out_ymax,
904 const int densify_pts)
905 {
906 (void)xmin;
907 (void)xmax;
908 (void)ymin;
909 (void)ymax;
910 (void)densify_pts;
911 *out_xmin = HUGE_VAL;
912 *out_ymin = HUGE_VAL;
913 *out_xmax = HUGE_VAL;
914 *out_ymax = HUGE_VAL;
915 CPLError(CE_Failure, CPLE_AppDefined,
916 "TransformBounds not implemented.");
917 return false;
918 }
919
924 static inline OGRCoordinateTransformationH
925 ToHandle(OGRCoordinateTransformation *poCT)
926 {
927 return reinterpret_cast<OGRCoordinateTransformationH>(poCT);
928 }
929
934 static inline OGRCoordinateTransformation *
935 FromHandle(OGRCoordinateTransformationH hCT)
936 {
937 return reinterpret_cast<OGRCoordinateTransformation *>(hCT);
938 }
939
943 virtual OGRCoordinateTransformation *Clone() const = 0;
944
954 virtual OGRCoordinateTransformation *GetInverse() const = 0;
955 };
956
957 OGRCoordinateTransformation CPL_DLL *
958 OGRCreateCoordinateTransformation(const OGRSpatialReference *poSource,
959 const OGRSpatialReference *poTarget);
960
967 struct CPL_DLL OGRCoordinateTransformationOptions
968 {
970 private:
971 friend class OGRProjCT;
972 struct Private;
973 std::unique_ptr<Private> d;
976 public:
977 OGRCoordinateTransformationOptions();
978 OGRCoordinateTransformationOptions(
979 const OGRCoordinateTransformationOptions &);
980 OGRCoordinateTransformationOptions &
981 operator=(const OGRCoordinateTransformationOptions &);
982 ~OGRCoordinateTransformationOptions();
983
984 bool SetAreaOfInterest(double dfWestLongitudeDeg, double dfSouthLatitudeDeg,
985 double dfEastLongitudeDeg,
986 double dfNorthLatitudeDeg);
987 bool SetDesiredAccuracy(double dfAccuracy);
988 bool SetBallparkAllowed(bool bAllowBallpark);
989 bool SetOnlyBest(bool bOnlyBest);
990
991 bool SetCoordinateOperation(const char *pszCT, bool bReverseCT);
993 void SetSourceCenterLong(double dfCenterLong);
994 void SetTargetCenterLong(double dfCenterLong);
996 };
997
998 OGRCoordinateTransformation CPL_DLL *OGRCreateCoordinateTransformation(
999 const OGRSpatialReference *poSource, const OGRSpatialReference *poTarget,
1000 const OGRCoordinateTransformationOptions &options);
1001
1002 #endif /* ndef OGR_SPATIALREF_H_INCLUDED */
OGR_SRSNode::GetChildCount
int GetChildCount() const
Definition: ogr_spatialref.h:91
OGRCreateCoordinateTransformation
OGRCoordinateTransformation * OGRCreateCoordinateTransformation(const OGRSpatialReference *poSource, const OGRSpatialReference *poTarget)
Create transformation object.
Definition: ogrct.cpp:935
OGRSpatialReference::Release
void Release()
Decrements the reference count by one, and destroy if zero.
Definition: ogrspatialreference.cpp:1094
OGRCoordinateTransformationOptions
Context for coordinate transformation.
Definition: ogr_spatialref.h:967
OGRCoordinateTransformation::TransformBounds
virtual int TransformBounds(const double xmin, const double ymin, const double xmax, const double ymax, double *out_xmin, double *out_ymin, double *out_xmax, double *out_ymax, const int densify_pts)
Transform boundary.
Definition: ogr_spatialref.h:900
OGRSpatialReference
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition: ogr_spatialref.h:166
OGRCoordinateTransformation::ToHandle
static OGRCoordinateTransformationH ToHandle(OGRCoordinateTransformation *poCT)
Convert a OGRCoordinateTransformation* to a OGRCoordinateTransformationH.
Definition: ogr_spatialref.h:925
OGR_SRSNode::IsLeafNode
int IsLeafNode() const
Return whether this is a leaf node.
Definition: ogr_spatialref.h:86
OGRSpatialReference::FromHandle
static OGRSpatialReference * FromHandle(OGRSpatialReferenceH hSRS)
Convert a OGRSpatialReferenceH to a OGRSpatialReference*.
Definition: ogr_spatialref.h:737
CPLString
Convenient string class based on std::string.
Definition: cpl_string.h:311
OGRSpatialReference::ToHandle
static OGRSpatialReferenceH ToHandle(OGRSpatialReference *poSRS)
Convert a OGRSpatialReference* to a OGRSpatialReferenceH.
Definition: ogr_spatialref.h:729
OSRAxisMappingStrategy
OSRAxisMappingStrategy
Data axis to CRS axis mapping strategy.
Definition: ogr_srs_api.h:658
OGR_SRSNode::GetValue
const char * GetValue() const
Definition: ogr_spatialref.h:108
OGRSpatialReferenceH
void * OGRSpatialReferenceH
Opaque type for a spatial reference system.
Definition: ogr_api.h:81
OGR_SRSNode::Listener
Listener that is notified of modification to nodes.
Definition: ogr_spatialref.h:70
OGRCoordinateTransformationH
void * OGRCoordinateTransformationH
Opaque type for a coordinate transformation object.
Definition: ogr_api.h:83
OGRCoordinateTransformation::SetEmitErrors
virtual void SetEmitErrors(bool)
Set if the transformer must emit CPLError.
Definition: ogr_spatialref.h:794
CSLConstList
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition: cpl_port.h:1178
ogr_srs_api.h
cpl_string.h
OGRAxisOrientation
OGRAxisOrientation
Axis orientations (corresponds to CS_AxisOrientationEnum).
Definition: ogr_srs_api.h:50
CPLError
void CPLError(CPLErr eErrClass, CPLErrorNum err_no, const char *fmt,...)
Report an error.
Definition: cpl_error.cpp:323
OGRCoordinateTransformation
Interface for transforming between coordinate systems.
Definition: ogr_spatialref.h:770
OGRCoordinateTransformation::FromHandle
static OGRCoordinateTransformation * FromHandle(OGRCoordinateTransformationH hCT)
Convert a OGRCoordinateTransformationH to a OGRCoordinateTransformation*.
Definition: ogr_spatialref.h:935
OGRErr
int OGRErr
Type for a OGR error.
Definition: ogr_core.h:378
OGRCoordinateTransformation::GetEmitErrors
virtual bool GetEmitErrors() const
Whether the transformer will emit CPLError.
Definition: ogr_spatialref.h:788
USGS_ANGLE_PACKEDDMS
#define USGS_ANGLE_PACKEDDMS
Angle is in packed degree minute second.
Definition: ogr_spatialref.h:241
OGR_SRSNode
Objects of this class are used to represent value nodes in the parsed representation of the WKT SRS f...
Definition: ogr_spatialref.h:66
CPL_DISALLOW_COPY_ASSIGN
#define CPL_DISALLOW_COPY_ASSIGN(ClassName)
Helper to remove the copy and assignment constructors so that the compiler will not generate the defa...
Definition: cpl_port.h:1042
CPLE_AppDefined
#define CPLE_AppDefined
Application defined error.
Definition: cpl_error.h:100