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 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 OGRErr SetNode(const char *, double);
303
304 OGRErr
305 SetLinearUnitsAndUpdateParameters(const char *pszName, double dfInMeters,
306 const char *pszUnitAuthority = nullptr,
307 const char *pszUnitCode = nullptr);
308 OGRErr SetLinearUnits(const char *pszName, double dfInMeters);
309 OGRErr SetTargetLinearUnits(const char *pszTargetKey, const char *pszName,
310 double dfInMeters,
311 const char *pszUnitAuthority = nullptr,
312 const char *pszUnitCode = nullptr);
313
314 double GetLinearUnits(char **) const
316 CPL_WARN_DEPRECATED("Use GetLinearUnits(const char**) instead")
318 ;
319 double GetLinearUnits(const char ** = nullptr) const;
321 double GetLinearUnits(std::nullptr_t) const
322 {
323 return GetLinearUnits(static_cast<const char **>(nullptr));
324 }
327 double GetTargetLinearUnits(const char *pszTargetKey,
328 char **ppszRetName) const
330 CPL_WARN_DEPRECATED(
331 "Use GetTargetLinearUnits(const char*, const char**)")
333 ;
334 double GetTargetLinearUnits(const char *pszTargetKey,
335 const char **ppszRetName = nullptr) const;
337 double GetTargetLinearUnits(const char *pszTargetKey, std::nullptr_t) const
338 {
339 return GetTargetLinearUnits(pszTargetKey,
340 static_cast<const char **>(nullptr));
341 }
344 OGRErr SetAngularUnits(const char *pszName, double dfInRadians);
345 double GetAngularUnits(char **) const
347 CPL_WARN_DEPRECATED("Use GetAngularUnits(const char**) instead")
349 ;
350 double GetAngularUnits(const char ** = nullptr) const;
352 double GetAngularUnits(std::nullptr_t) const
353 {
354 return GetAngularUnits(static_cast<const char **>(nullptr));
355 }
358 double GetPrimeMeridian(char **) const
360 CPL_WARN_DEPRECATED("Use GetPrimeMeridian(const char**) instead")
362 ;
363 double GetPrimeMeridian(const char ** = nullptr) const;
365 double GetPrimeMeridian(std::nullptr_t) const
366 {
367 return GetPrimeMeridian(static_cast<const char **>(nullptr));
368 }
371 bool IsEmpty() const;
372 int IsGeographic() const;
373 int IsDerivedGeographic() const;
374 int IsProjected() const;
375 int IsGeocentric() const;
376 bool IsDynamic() const;
377 int IsLocal() const;
378 int IsVertical() const;
379 int IsCompound() const;
380 int IsSameGeogCS(const OGRSpatialReference *) const;
381 int IsSameGeogCS(const OGRSpatialReference *,
382 const char *const *papszOptions) const;
383 int IsSameVertCS(const OGRSpatialReference *) const;
384 int IsSame(const OGRSpatialReference *) const;
385 int IsSame(const OGRSpatialReference *,
386 const char *const *papszOptions) const;
387
388 void Clear();
389 OGRErr SetLocalCS(const char *);
390 OGRErr SetProjCS(const char *);
391 OGRErr SetProjection(const char *);
392 OGRErr SetGeocCS(const char *pszGeocName);
393 OGRErr SetGeogCS(const char *pszGeogName, const char *pszDatumName,
394 const char *pszEllipsoidName, double dfSemiMajor,
395 double dfInvFlattening, const char *pszPMName = nullptr,
396 double dfPMOffset = 0.0, const char *pszUnits = nullptr,
397 double dfConvertToRadians = 0.0);
398 OGRErr SetWellKnownGeogCS(const char *);
399 OGRErr CopyGeogCSFrom(const OGRSpatialReference *poSrcSRS);
400 OGRErr SetVertCS(const char *pszVertCSName, const char *pszVertDatumName,
401 int nVertDatumClass = 2005);
402 OGRErr SetCompoundCS(const char *pszName,
403 const OGRSpatialReference *poHorizSRS,
404 const OGRSpatialReference *poVertSRS);
405
406 void SetCoordinateEpoch(double dfCoordinateEpoch);
407 double GetCoordinateEpoch() const;
408
409 // cppcheck-suppress functionStatic
410 OGRErr PromoteTo3D(const char *pszName);
411 // cppcheck-suppress functionStatic
412 OGRErr DemoteTo2D(const char *pszName);
413
414 OGRErr SetFromUserInput(const char *);
415
416 static const char *const SET_FROM_USER_INPUT_LIMITATIONS[];
417 static CSLConstList SET_FROM_USER_INPUT_LIMITATIONS_get();
418
419 OGRErr SetFromUserInput(const char *, CSLConstList papszOptions);
420
421 OGRErr SetTOWGS84(double, double, double, double = 0.0, double = 0.0,
422 double = 0.0, double = 0.0);
423 OGRErr GetTOWGS84(double *padfCoef, int nCoeff = 7) const;
424 OGRErr AddGuessedTOWGS84();
425
426 double GetSemiMajor(OGRErr * = nullptr) const;
427 double GetSemiMinor(OGRErr * = nullptr) const;
428 double GetInvFlattening(OGRErr * = nullptr) const;
429 double GetEccentricity() const;
430 double GetSquaredEccentricity() const;
431
432 OGRErr SetAuthority(const char *pszTargetKey, const char *pszAuthority,
433 int nCode);
434
435 OGRErr AutoIdentifyEPSG();
436 OGRSpatialReferenceH *FindMatches(char **papszOptions, int *pnEntries,
437 int **ppanMatchConfidence) const;
438 OGRSpatialReference *
439 FindBestMatch(int nMinimumMatchConfidence = 90,
440 const char *pszPreferredAuthority = "EPSG",
441 CSLConstList papszOptions = nullptr) const;
442
443 int GetEPSGGeogCS() const;
444
445 const char *GetAuthorityCode(const char *pszTargetKey) const;
446 const char *GetAuthorityName(const char *pszTargetKey) const;
447 char *GetOGCURN() const;
448
449 bool GetAreaOfUse(double *pdfWestLongitudeDeg, double *pdfSouthLatitudeDeg,
450 double *pdfEastLongitudeDeg, double *pdfNorthLatitudeDeg,
451 const char **ppszAreaName) const;
452
453 const char *GetExtension(const char *pszTargetKey, const char *pszName,
454 const char *pszDefault = nullptr) const;
455 OGRErr SetExtension(const char *pszTargetKey, const char *pszName,
456 const char *pszValue);
457
458 int FindProjParm(const char *pszParameter,
459 const OGR_SRSNode *poPROJCS = nullptr) const;
460 OGRErr SetProjParm(const char *, double);
461 double GetProjParm(const char *, double = 0.0, OGRErr * = nullptr) const;
462
463 OGRErr SetNormProjParm(const char *, double);
464 double GetNormProjParm(const char *, double = 0.0,
465 OGRErr * = nullptr) const;
466
467 static int IsAngularParameter(const char *);
468 static int IsLongitudeParameter(const char *);
469 static int IsLinearParameter(const char *);
470
472 OGRErr SetACEA(double dfStdP1, double dfStdP2, double dfCenterLat,
473 double dfCenterLong, double dfFalseEasting,
474 double dfFalseNorthing);
475
477 OGRErr SetAE(double dfCenterLat, double dfCenterLong, double dfFalseEasting,
478 double dfFalseNorthing);
479
481 OGRErr SetBonne(double dfStdP1, double dfCentralMeridian,
482 double dfFalseEasting, double dfFalseNorthing);
483
485 OGRErr SetCEA(double dfStdP1, double dfCentralMeridian,
486 double dfFalseEasting, double dfFalseNorthing);
487
489 OGRErr SetCS(double dfCenterLat, double dfCenterLong, double dfFalseEasting,
490 double dfFalseNorthing);
491
493 OGRErr SetEC(double dfStdP1, double dfStdP2, double dfCenterLat,
494 double dfCenterLong, double dfFalseEasting,
495 double dfFalseNorthing);
496
498 OGRErr SetEckert(int nVariation, double dfCentralMeridian,
499 double dfFalseEasting, double dfFalseNorthing);
500
502 OGRErr SetEckertIV(double dfCentralMeridian, double dfFalseEasting,
503 double dfFalseNorthing);
504
506 OGRErr SetEckertVI(double dfCentralMeridian, double dfFalseEasting,
507 double dfFalseNorthing);
508
510 OGRErr SetEquirectangular(double dfCenterLat, double dfCenterLong,
511 double dfFalseEasting, double dfFalseNorthing);
513 OGRErr SetEquirectangular2(double dfCenterLat, double dfCenterLong,
514 double dfPseudoStdParallel1,
515 double dfFalseEasting, double dfFalseNorthing);
516
518 OGRErr SetGEOS(double dfCentralMeridian, double dfSatelliteHeight,
519 double dfFalseEasting, double dfFalseNorthing);
520
522 OGRErr SetGH(double dfCentralMeridian, double dfFalseEasting,
523 double dfFalseNorthing);
524
526 OGRErr SetIGH();
527
529 OGRErr SetGS(double dfCentralMeridian, double dfFalseEasting,
530 double dfFalseNorthing);
531
533 OGRErr SetGaussSchreiberTMercator(double dfCenterLat, double dfCenterLong,
534 double dfScale, double dfFalseEasting,
535 double dfFalseNorthing);
536
538 OGRErr SetGnomonic(double dfCenterLat, double dfCenterLong,
539 double dfFalseEasting, double dfFalseNorthing);
540
542 OGRErr SetHOM(double dfCenterLat, double dfCenterLong, double dfAzimuth,
543 double dfRectToSkew, double dfScale, double dfFalseEasting,
544 double dfFalseNorthing);
545
547 OGRErr SetHOM2PNO(double dfCenterLat, double dfLat1, double dfLong1,
548 double dfLat2, double dfLong2, double dfScale,
549 double dfFalseEasting, double dfFalseNorthing);
550
552 OGRErr SetHOMAC(double dfCenterLat, double dfCenterLong, double dfAzimuth,
553 double dfRectToSkew, double dfScale, double dfFalseEasting,
554 double dfFalseNorthing);
555
557 OGRErr SetLOM(double dfCenterLat, double dfCenterLong, double dfAzimuth,
558 double dfScale, double dfFalseEasting,
559 double dfFalseNorthing);
560
562 OGRErr SetIWMPolyconic(double dfLat1, double dfLat2, double dfCenterLong,
563 double dfFalseEasting, double dfFalseNorthing);
564
566 OGRErr SetKrovak(double dfCenterLat, double dfCenterLong, double dfAzimuth,
567 double dfPseudoStdParallelLat, double dfScale,
568 double dfFalseEasting, double dfFalseNorthing);
569
571 OGRErr SetLAEA(double dfCenterLat, double dfCenterLong,
572 double dfFalseEasting, double dfFalseNorthing);
573
575 OGRErr SetLCC(double dfStdP1, double dfStdP2, double dfCenterLat,
576 double dfCenterLong, double dfFalseEasting,
577 double dfFalseNorthing);
578
580 OGRErr SetLCC1SP(double dfCenterLat, double dfCenterLong, double dfScale,
581 double dfFalseEasting, double dfFalseNorthing);
582
584 OGRErr SetLCCB(double dfStdP1, double dfStdP2, double dfCenterLat,
585 double dfCenterLong, double dfFalseEasting,
586 double dfFalseNorthing);
587
589 OGRErr SetMC(double dfCenterLat, double dfCenterLong, double dfFalseEasting,
590 double dfFalseNorthing);
591
593 OGRErr SetMercator(double dfCenterLat, double dfCenterLong, double dfScale,
594 double dfFalseEasting, double dfFalseNorthing);
595
597 OGRErr SetMercator2SP(double dfStdP1, double dfCenterLat,
598 double dfCenterLong, double dfFalseEasting,
599 double dfFalseNorthing);
600
602 OGRErr SetMollweide(double dfCentralMeridian, double dfFalseEasting,
603 double dfFalseNorthing);
604
606 OGRErr SetNZMG(double dfCenterLat, double dfCenterLong,
607 double dfFalseEasting, double dfFalseNorthing);
608
610 OGRErr SetOS(double dfOriginLat, double dfCMeridian, double dfScale,
611 double dfFalseEasting, double dfFalseNorthing);
612
614 OGRErr SetOrthographic(double dfCenterLat, double dfCenterLong,
615 double dfFalseEasting, double dfFalseNorthing);
616
618 OGRErr SetPolyconic(double dfCenterLat, double dfCenterLong,
619 double dfFalseEasting, double dfFalseNorthing);
620
622 OGRErr SetPS(double dfCenterLat, double dfCenterLong, double dfScale,
623 double dfFalseEasting, double dfFalseNorthing);
624
626 OGRErr SetRobinson(double dfCenterLong, double dfFalseEasting,
627 double dfFalseNorthing);
628
630 OGRErr SetSinusoidal(double dfCenterLong, double dfFalseEasting,
631 double dfFalseNorthing);
632
634 OGRErr SetStereographic(double dfCenterLat, double dfCenterLong,
635 double dfScale, double dfFalseEasting,
636 double dfFalseNorthing);
637
639 OGRErr SetSOC(double dfLatitudeOfOrigin, double dfCentralMeridian,
640 double dfFalseEasting, double dfFalseNorthing);
641
643 OGRErr SetTM(double dfCenterLat, double dfCenterLong, double dfScale,
644 double dfFalseEasting, double dfFalseNorthing);
645
647 OGRErr SetTMVariant(const char *pszVariantName, double dfCenterLat,
648 double dfCenterLong, double dfScale,
649 double dfFalseEasting, double dfFalseNorthing);
650
652 OGRErr SetTMG(double dfCenterLat, double dfCenterLong,
653 double dfFalseEasting, double dfFalseNorthing);
654
656 OGRErr SetTMSO(double dfCenterLat, double dfCenterLong, double dfScale,
657 double dfFalseEasting, double dfFalseNorthing);
658
660 OGRErr SetTPED(double dfLat1, double dfLong1, double dfLat2, double dfLong2,
661 double dfFalseEasting, double dfFalseNorthing);
662
664 OGRErr SetVDG(double dfCenterLong, double dfFalseEasting,
665 double dfFalseNorthing);
666
668 OGRErr SetUTM(int nZone, int bNorth = TRUE);
669 int GetUTMZone(int *pbNorth = nullptr) const;
670
672 OGRErr SetWagner(int nVariation, double dfCenterLat, double dfFalseEasting,
673 double dfFalseNorthing);
674
676 OGRErr SetQSC(double dfCenterLat, double dfCenterLong);
677
679 OGRErr SetSCH(double dfPegLat, double dfPegLong, double dfPegHeading,
680 double dfPegHgt);
681
683 OGRErr
684 SetVerticalPerspective(double dfTopoOriginLat, double dfTopoOriginLon,
685 double dfTopoOriginHeight, double dfViewPointHeight,
686 double dfFalseEasting, double dfFalseNorthing);
687
689 OGRErr SetDerivedGeogCRSWithPoleRotationGRIBConvention(
690 const char *pszCRSName, double dfSouthPoleLat, double dfSouthPoleLon,
691 double dfAxisRotation);
692
694 OGRErr SetDerivedGeogCRSWithPoleRotationNetCDFCFConvention(
695 const char *pszCRSName, double dfGridNorthPoleLat,
696 double dfGridNorthPoleLon, double dfNorthPoleGridLon);
697
699 OGRErr SetStatePlane(int nZone, int bNAD83 = TRUE,
700 const char *pszOverrideUnitName = nullptr,
701 double dfOverrideUnit = 0.0);
702
704 OGRErr ImportFromESRIStatePlaneWKT(int nCode, const char *pszDatumName,
705 const char *pszUnitsName, int nPCSCode,
706 const char *pszCRSName = nullptr);
707
709 OGRErr ImportFromESRIWisconsinWKT(const char *pszPrjName,
710 double dfCentralMeridian,
711 double dfLatOfOrigin,
712 const char *pszUnitsName,
713 const char *pszCRSName = nullptr);
714
716 void UpdateCoordinateSystemFromGeogCRS();
719 static OGRSpatialReference *GetWGS84SRS();
720
724 static inline OGRSpatialReferenceH ToHandle(OGRSpatialReference *poSRS)
725 {
726 return reinterpret_cast<OGRSpatialReferenceH>(poSRS);
727 }
728
732 static inline OGRSpatialReference *FromHandle(OGRSpatialReferenceH hSRS)
733 {
734 return reinterpret_cast<OGRSpatialReference *>(hSRS);
735 }
736 };
737
739 struct CPL_DLL OGRSpatialReferenceReleaser
740 {
741 void operator()(OGRSpatialReference *poSRS) const
742 {
743 if (poSRS)
744 poSRS->Release();
745 }
746 };
749 /************************************************************************/
750 /* OGRCoordinateTransformation */
751 /* */
752 /* This is really just used as a base class for a private */
753 /* implementation. */
754 /************************************************************************/
755
765 class CPL_DLL OGRCoordinateTransformation
766 {
767 public:
768 virtual ~OGRCoordinateTransformation()
769 {
770 }
771
772 static void DestroyCT(OGRCoordinateTransformation *poCT);
773
774 // From CT_CoordinateTransformation
775
777 virtual const OGRSpatialReference *GetSourceCS() const = 0;
778
780 virtual const OGRSpatialReference *GetTargetCS() const = 0;
781
783 virtual bool GetEmitErrors() const
784 {
785 return false;
786 }
787
789 virtual void SetEmitErrors(bool /*bEmitErrors*/)
790 {
791 }
792
793 // From CT_MathTransform
794
812 int Transform(int nCount, double *x, double *y, double *z = nullptr,
813 int *pabSuccess = nullptr);
814
833 virtual int Transform(int nCount, double *x, double *y, double *z,
834 double *t, int *pabSuccess) = 0;
835
855 virtual int TransformWithErrorCodes(int nCount, double *x, double *y,
856 double *z, double *t,
857 int *panErrorCodes);
858
895 virtual int TransformBounds(const double xmin, const double ymin,
896 const double xmax, const double ymax,
897 double *out_xmin, double *out_ymin,
898 double *out_xmax, double *out_ymax,
899 const int densify_pts)
900 {
901 (void)xmin;
902 (void)xmax;
903 (void)ymin;
904 (void)ymax;
905 (void)densify_pts;
906 *out_xmin = HUGE_VAL;
907 *out_ymin = HUGE_VAL;
908 *out_xmax = HUGE_VAL;
909 *out_ymax = HUGE_VAL;
910 CPLError(CE_Failure, CPLE_AppDefined,
911 "TransformBounds not implemented.");
912 return false;
913 }
914
919 static inline OGRCoordinateTransformationH
920 ToHandle(OGRCoordinateTransformation *poCT)
921 {
922 return reinterpret_cast<OGRCoordinateTransformationH>(poCT);
923 }
924
929 static inline OGRCoordinateTransformation *
930 FromHandle(OGRCoordinateTransformationH hCT)
931 {
932 return reinterpret_cast<OGRCoordinateTransformation *>(hCT);
933 }
934
938 virtual OGRCoordinateTransformation *Clone() const = 0;
939
949 virtual OGRCoordinateTransformation *GetInverse() const = 0;
950 };
951
952 OGRCoordinateTransformation CPL_DLL *
953 OGRCreateCoordinateTransformation(const OGRSpatialReference *poSource,
954 const OGRSpatialReference *poTarget);
955
962 struct CPL_DLL OGRCoordinateTransformationOptions
963 {
965 private:
966 friend class OGRProjCT;
967 struct Private;
968 std::unique_ptr<Private> d;
971 public:
972 OGRCoordinateTransformationOptions();
973 OGRCoordinateTransformationOptions(
974 const OGRCoordinateTransformationOptions &);
975 OGRCoordinateTransformationOptions &
976 operator=(const OGRCoordinateTransformationOptions &);
977 ~OGRCoordinateTransformationOptions();
978
979 bool SetAreaOfInterest(double dfWestLongitudeDeg, double dfSouthLatitudeDeg,
980 double dfEastLongitudeDeg,
981 double dfNorthLatitudeDeg);
982 bool SetDesiredAccuracy(double dfAccuracy);
983 bool SetBallparkAllowed(bool bAllowBallpark);
984
985 bool SetCoordinateOperation(const char *pszCT, bool bReverseCT);
987 void SetSourceCenterLong(double dfCenterLong);
988 void SetTargetCenterLong(double dfCenterLong);
990 };
991
992 OGRCoordinateTransformation CPL_DLL *OGRCreateCoordinateTransformation(
993 const OGRSpatialReference *poSource, const OGRSpatialReference *poTarget,
994 const OGRCoordinateTransformationOptions &options);
995
996 #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:873
OGRSpatialReference::Release
void Release()
Decrements the reference count by one, and destroy if zero.
Definition: ogrspatialreference.cpp:1073
OGRCoordinateTransformationOptions
Context for coordinate transformation.
Definition: ogr_spatialref.h:962
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:895
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:920
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:732
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:724
OSRAxisMappingStrategy
OSRAxisMappingStrategy
Data axis to CRS axis mapping strategy.
Definition: ogr_srs_api.h:655
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:789
CSLConstList
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition: cpl_port.h:1195
ogr_srs_api.h
cpl_string.h
OGRAxisOrientation
OGRAxisOrientation
Axis orientations (corresponds to CS_AxisOrientationEnum).
Definition: ogr_srs_api.h:48
CPLError
void CPLError(CPLErr eErrClass, CPLErrorNum err_no, const char *fmt,...)
Report an error.
Definition: cpl_error.cpp:329
OGRCoordinateTransformation
Interface for transforming between coordinate systems.
Definition: ogr_spatialref.h:765
OGRCoordinateTransformation::FromHandle
static OGRCoordinateTransformation * FromHandle(OGRCoordinateTransformationH hCT)
Convert a OGRCoordinateTransformationH to a OGRCoordinateTransformation*.
Definition: ogr_spatialref.h:930
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:783
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:1051
CPLE_AppDefined
#define CPLE_AppDefined
Application defined error.
Definition: cpl_error.h:100