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
66class 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);
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
142};
143
144/************************************************************************/
145/* OGRSpatialReference */
146/************************************************************************/
147
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 public:
180 explicit OGRSpatialReference(const char * = nullptr);
183
184 virtual ~OGRSpatialReference();
185
186 static void DestroySpatialReference(OGRSpatialReference *poSRS);
187
188 OGRSpatialReference &operator=(const OGRSpatialReference &);
190
191 int Reference();
192 int Dereference();
193 int GetReferenceCount() const;
194 void Release();
195
196 const char *GetName() const;
197
198 OGRSpatialReference *Clone() const;
199 OGRSpatialReference *CloneGeogCS() const;
200
201 void dumpReadable();
202 OGRErr exportToWkt(char **) const;
203 OGRErr exportToWkt(char **ppszWKT, const char *const *papszOptions) const;
204 OGRErr exportToPrettyWkt(char **, int = FALSE) const;
205 // cppcheck-suppress functionStatic
206 OGRErr exportToPROJJSON(char **, const char *const *papszOptions) const;
207 OGRErr exportToProj4(char **) const;
208 OGRErr exportToPCI(char **, char **, double **) const;
209 OGRErr exportToUSGS(long *, long *, double **, long *) const;
210 OGRErr exportToXML(char **, const char * = nullptr) const;
211 OGRErr exportToPanorama(long *, long *, long *, long *, double *) const;
212 OGRErr exportToERM(char *pszProj, char *pszDatum, char *pszUnits);
213 OGRErr exportToMICoordSys(char **) const;
214
215 OGRErr importFromWkt(char **)
217 CPL_WARN_DEPRECATED(
218 "Use importFromWkt(const char**) or importFromWkt(const char*)")
220 ;
221
222 OGRErr importFromWkt(const char **);
224 OGRErr importFromWkt(const char *pszInput, CSLConstList papszOptions);
225 OGRErr importFromWkt(const char **ppszInput, CSLConstList papszOptions);
227 OGRErr importFromWkt(const char *);
228 OGRErr importFromProj4(const char *);
229 OGRErr importFromEPSG(int);
230 OGRErr importFromEPSGA(int);
231 OGRErr importFromESRI(char **);
232 OGRErr importFromPCI(const char *, const char * = nullptr,
233 double * = nullptr);
234
235#define USGS_ANGLE_DECIMALDEGREES 0
236#define USGS_ANGLE_PACKEDDMS \
237 TRUE
238#define USGS_ANGLE_RADIANS 2
239 OGRErr importFromUSGS(long iProjSys, long iZone, double *padfPrjParams,
240 long iDatum,
241 int nUSGSAngleFormat = USGS_ANGLE_PACKEDDMS);
242 OGRErr importFromPanorama(long, long, long, double *);
243 OGRErr importVertCSFromPanorama(int);
244 OGRErr importFromOzi(const char *const *papszLines);
245 OGRErr importFromWMSAUTO(const char *pszAutoDef);
246 OGRErr importFromXML(const char *);
247 OGRErr importFromDict(const char *pszDict, const char *pszCode);
248 OGRErr importFromURN(const char *);
249 OGRErr importFromCRSURL(const char *);
250 OGRErr importFromERM(const char *pszProj, const char *pszDatum,
251 const char *pszUnits);
252 OGRErr importFromUrl(const char *);
253 OGRErr importFromMICoordSys(const char *);
254
255 OGRErr morphToESRI();
256 OGRErr morphFromESRI();
257
259 convertToOtherProjection(const char *pszTargetProjection,
260 const char *const *papszOptions = nullptr) const;
261
262 OGRErr Validate() const;
263 OGRErr StripVertical();
264
265 bool StripTOWGS84IfKnownDatumAndAllowed();
266 bool StripTOWGS84IfKnownDatum();
267
268 int EPSGTreatsAsLatLong() const;
269 int EPSGTreatsAsNorthingEasting() const;
270 int GetAxesCount() const;
271 const char *GetAxis(const char *pszTargetKey, int iAxis,
272 OGRAxisOrientation *peOrientation,
273 double *pdfConvFactor = nullptr) const;
274 OGRErr SetAxes(const char *pszTargetKey, const char *pszXAxisName,
275 OGRAxisOrientation eXAxisOrientation,
276 const char *pszYAxisName,
277 OGRAxisOrientation eYAxisOrientation);
278
279 OSRAxisMappingStrategy GetAxisMappingStrategy() const;
280 void SetAxisMappingStrategy(OSRAxisMappingStrategy);
281 const std::vector<int> &GetDataAxisToSRSAxisMapping() const;
282 OGRErr SetDataAxisToSRSAxisMapping(const std::vector<int> &mapping);
283
284 // Machinery for accessing parse nodes
285
287 OGR_SRSNode *GetRoot();
289 const OGR_SRSNode *GetRoot() const;
290 void SetRoot(OGR_SRSNode *);
291
292 OGR_SRSNode *GetAttrNode(const char *);
293 const OGR_SRSNode *GetAttrNode(const char *) const;
294 const char *GetAttrValue(const char *, int = 0) const;
295
296 OGRErr SetNode(const char *, const char *);
297 OGRErr SetNode(const char *, double);
298
299 OGRErr
300 SetLinearUnitsAndUpdateParameters(const char *pszName, double dfInMeters,
301 const char *pszUnitAuthority = nullptr,
302 const char *pszUnitCode = nullptr);
303 OGRErr SetLinearUnits(const char *pszName, double dfInMeters);
304 OGRErr SetTargetLinearUnits(const char *pszTargetKey, const char *pszName,
305 double dfInMeters,
306 const char *pszUnitAuthority = nullptr,
307 const char *pszUnitCode = nullptr);
308
309 double GetLinearUnits(char **) const
311 CPL_WARN_DEPRECATED("Use GetLinearUnits(const char**) instead")
313 ;
314 double GetLinearUnits(const char ** = nullptr) const;
316 double GetLinearUnits(std::nullptr_t) const
317 {
318 return GetLinearUnits(static_cast<const char **>(nullptr));
319 }
322 double GetTargetLinearUnits(const char *pszTargetKey,
323 char **ppszRetName) const
325 CPL_WARN_DEPRECATED(
326 "Use GetTargetLinearUnits(const char*, const char**)")
328 ;
329 double GetTargetLinearUnits(const char *pszTargetKey,
330 const char **ppszRetName = nullptr) const;
332 double GetTargetLinearUnits(const char *pszTargetKey, std::nullptr_t) const
333 {
334 return GetTargetLinearUnits(pszTargetKey,
335 static_cast<const char **>(nullptr));
336 }
339 OGRErr SetAngularUnits(const char *pszName, double dfInRadians);
340 double GetAngularUnits(char **) const
342 CPL_WARN_DEPRECATED("Use GetAngularUnits(const char**) instead")
344 ;
345 double GetAngularUnits(const char ** = nullptr) const;
347 double GetAngularUnits(std::nullptr_t) const
348 {
349 return GetAngularUnits(static_cast<const char **>(nullptr));
350 }
353 double GetPrimeMeridian(char **) const
355 CPL_WARN_DEPRECATED("Use GetPrimeMeridian(const char**) instead")
357 ;
358 double GetPrimeMeridian(const char ** = nullptr) const;
360 double GetPrimeMeridian(std::nullptr_t) const
361 {
362 return GetPrimeMeridian(static_cast<const char **>(nullptr));
363 }
366 bool IsEmpty() const;
367 int IsGeographic() const;
368 int IsDerivedGeographic() const;
369 int IsProjected() const;
370 int IsGeocentric() const;
371 bool IsDynamic() const;
372 int IsLocal() const;
373 int IsVertical() const;
374 int IsCompound() const;
375 int IsSameGeogCS(const OGRSpatialReference *) const;
376 int IsSameGeogCS(const OGRSpatialReference *,
377 const char *const *papszOptions) const;
378 int IsSameVertCS(const OGRSpatialReference *) const;
379 int IsSame(const OGRSpatialReference *) const;
380 int IsSame(const OGRSpatialReference *,
381 const char *const *papszOptions) const;
382
383 void Clear();
384 OGRErr SetLocalCS(const char *);
385 OGRErr SetProjCS(const char *);
386 OGRErr SetProjection(const char *);
387 OGRErr SetGeocCS(const char *pszGeocName);
388 OGRErr SetGeogCS(const char *pszGeogName, const char *pszDatumName,
389 const char *pszEllipsoidName, double dfSemiMajor,
390 double dfInvFlattening, const char *pszPMName = nullptr,
391 double dfPMOffset = 0.0, const char *pszUnits = nullptr,
392 double dfConvertToRadians = 0.0);
393 OGRErr SetWellKnownGeogCS(const char *);
394 OGRErr CopyGeogCSFrom(const OGRSpatialReference *poSrcSRS);
395 OGRErr SetVertCS(const char *pszVertCSName, const char *pszVertDatumName,
396 int nVertDatumClass = 2005);
397 OGRErr SetCompoundCS(const char *pszName,
398 const OGRSpatialReference *poHorizSRS,
399 const OGRSpatialReference *poVertSRS);
400
401 void SetCoordinateEpoch(double dfCoordinateEpoch);
402 double GetCoordinateEpoch() const;
403
404 // cppcheck-suppress functionStatic
405 OGRErr PromoteTo3D(const char *pszName);
406 // cppcheck-suppress functionStatic
407 OGRErr DemoteTo2D(const char *pszName);
408
409 OGRErr SetFromUserInput(const char *);
410
411 static const char *const SET_FROM_USER_INPUT_LIMITATIONS[];
412 static CSLConstList SET_FROM_USER_INPUT_LIMITATIONS_get();
413
414 OGRErr SetFromUserInput(const char *, CSLConstList papszOptions);
415
416 OGRErr SetTOWGS84(double, double, double, double = 0.0, double = 0.0,
417 double = 0.0, double = 0.0);
418 OGRErr GetTOWGS84(double *padfCoef, int nCoeff = 7) const;
419 OGRErr AddGuessedTOWGS84();
420
421 double GetSemiMajor(OGRErr * = nullptr) const;
422 double GetSemiMinor(OGRErr * = nullptr) const;
423 double GetInvFlattening(OGRErr * = nullptr) const;
424 double GetEccentricity() const;
425 double GetSquaredEccentricity() const;
426
427 OGRErr SetAuthority(const char *pszTargetKey, const char *pszAuthority,
428 int nCode);
429
430 OGRErr AutoIdentifyEPSG();
431 OGRSpatialReferenceH *FindMatches(char **papszOptions, int *pnEntries,
432 int **ppanMatchConfidence) const;
434 FindBestMatch(int nMinimumMatchConfidence = 90,
435 const char *pszPreferredAuthority = "EPSG",
436 CSLConstList papszOptions = nullptr) const;
437
438 int GetEPSGGeogCS() const;
439
440 const char *GetAuthorityCode(const char *pszTargetKey) const;
441 const char *GetAuthorityName(const char *pszTargetKey) const;
442 char *GetOGCURN() const;
443
444 bool GetAreaOfUse(double *pdfWestLongitudeDeg, double *pdfSouthLatitudeDeg,
445 double *pdfEastLongitudeDeg, double *pdfNorthLatitudeDeg,
446 const char **ppszAreaName) const;
447
448 const char *GetExtension(const char *pszTargetKey, const char *pszName,
449 const char *pszDefault = nullptr) const;
450 OGRErr SetExtension(const char *pszTargetKey, const char *pszName,
451 const char *pszValue);
452
453 int FindProjParm(const char *pszParameter,
454 const OGR_SRSNode *poPROJCS = nullptr) const;
455 OGRErr SetProjParm(const char *, double);
456 double GetProjParm(const char *, double = 0.0, OGRErr * = nullptr) const;
457
458 OGRErr SetNormProjParm(const char *, double);
459 double GetNormProjParm(const char *, double = 0.0,
460 OGRErr * = nullptr) const;
461
462 static int IsAngularParameter(const char *);
463 static int IsLongitudeParameter(const char *);
464 static int IsLinearParameter(const char *);
465
467 OGRErr SetACEA(double dfStdP1, double dfStdP2, double dfCenterLat,
468 double dfCenterLong, double dfFalseEasting,
469 double dfFalseNorthing);
470
472 OGRErr SetAE(double dfCenterLat, double dfCenterLong, double dfFalseEasting,
473 double dfFalseNorthing);
474
476 OGRErr SetBonne(double dfStdP1, double dfCentralMeridian,
477 double dfFalseEasting, double dfFalseNorthing);
478
480 OGRErr SetCEA(double dfStdP1, double dfCentralMeridian,
481 double dfFalseEasting, double dfFalseNorthing);
482
484 OGRErr SetCS(double dfCenterLat, double dfCenterLong, double dfFalseEasting,
485 double dfFalseNorthing);
486
488 OGRErr SetEC(double dfStdP1, double dfStdP2, double dfCenterLat,
489 double dfCenterLong, double dfFalseEasting,
490 double dfFalseNorthing);
491
493 OGRErr SetEckert(int nVariation, double dfCentralMeridian,
494 double dfFalseEasting, double dfFalseNorthing);
495
497 OGRErr SetEckertIV(double dfCentralMeridian, double dfFalseEasting,
498 double dfFalseNorthing);
499
501 OGRErr SetEckertVI(double dfCentralMeridian, double dfFalseEasting,
502 double dfFalseNorthing);
503
505 OGRErr SetEquirectangular(double dfCenterLat, double dfCenterLong,
506 double dfFalseEasting, double dfFalseNorthing);
508 OGRErr SetEquirectangular2(double dfCenterLat, double dfCenterLong,
509 double dfPseudoStdParallel1,
510 double dfFalseEasting, double dfFalseNorthing);
511
513 OGRErr SetGEOS(double dfCentralMeridian, double dfSatelliteHeight,
514 double dfFalseEasting, double dfFalseNorthing);
515
517 OGRErr SetGH(double dfCentralMeridian, double dfFalseEasting,
518 double dfFalseNorthing);
519
521 OGRErr SetIGH();
522
524 OGRErr SetGS(double dfCentralMeridian, double dfFalseEasting,
525 double dfFalseNorthing);
526
528 OGRErr SetGaussSchreiberTMercator(double dfCenterLat, double dfCenterLong,
529 double dfScale, double dfFalseEasting,
530 double dfFalseNorthing);
531
533 OGRErr SetGnomonic(double dfCenterLat, double dfCenterLong,
534 double dfFalseEasting, double dfFalseNorthing);
535
537 OGRErr SetHOM(double dfCenterLat, double dfCenterLong, double dfAzimuth,
538 double dfRectToSkew, double dfScale, double dfFalseEasting,
539 double dfFalseNorthing);
540
542 OGRErr SetHOM2PNO(double dfCenterLat, double dfLat1, double dfLong1,
543 double dfLat2, double dfLong2, double dfScale,
544 double dfFalseEasting, double dfFalseNorthing);
545
547 OGRErr SetHOMAC(double dfCenterLat, double dfCenterLong, double dfAzimuth,
548 double dfRectToSkew, double dfScale, double dfFalseEasting,
549 double dfFalseNorthing);
550
552 OGRErr SetLOM(double dfCenterLat, double dfCenterLong, double dfAzimuth,
553 double dfScale, double dfFalseEasting,
554 double dfFalseNorthing);
555
557 OGRErr SetIWMPolyconic(double dfLat1, double dfLat2, double dfCenterLong,
558 double dfFalseEasting, double dfFalseNorthing);
559
561 OGRErr SetKrovak(double dfCenterLat, double dfCenterLong, double dfAzimuth,
562 double dfPseudoStdParallelLat, double dfScale,
563 double dfFalseEasting, double dfFalseNorthing);
564
566 OGRErr SetLAEA(double dfCenterLat, double dfCenterLong,
567 double dfFalseEasting, double dfFalseNorthing);
568
570 OGRErr SetLCC(double dfStdP1, double dfStdP2, double dfCenterLat,
571 double dfCenterLong, double dfFalseEasting,
572 double dfFalseNorthing);
573
575 OGRErr SetLCC1SP(double dfCenterLat, double dfCenterLong, double dfScale,
576 double dfFalseEasting, double dfFalseNorthing);
577
579 OGRErr SetLCCB(double dfStdP1, double dfStdP2, double dfCenterLat,
580 double dfCenterLong, double dfFalseEasting,
581 double dfFalseNorthing);
582
584 OGRErr SetMC(double dfCenterLat, double dfCenterLong, double dfFalseEasting,
585 double dfFalseNorthing);
586
588 OGRErr SetMercator(double dfCenterLat, double dfCenterLong, double dfScale,
589 double dfFalseEasting, double dfFalseNorthing);
590
592 OGRErr SetMercator2SP(double dfStdP1, double dfCenterLat,
593 double dfCenterLong, double dfFalseEasting,
594 double dfFalseNorthing);
595
597 OGRErr SetMollweide(double dfCentralMeridian, double dfFalseEasting,
598 double dfFalseNorthing);
599
601 OGRErr SetNZMG(double dfCenterLat, double dfCenterLong,
602 double dfFalseEasting, double dfFalseNorthing);
603
605 OGRErr SetOS(double dfOriginLat, double dfCMeridian, double dfScale,
606 double dfFalseEasting, double dfFalseNorthing);
607
609 OGRErr SetOrthographic(double dfCenterLat, double dfCenterLong,
610 double dfFalseEasting, double dfFalseNorthing);
611
613 OGRErr SetPolyconic(double dfCenterLat, double dfCenterLong,
614 double dfFalseEasting, double dfFalseNorthing);
615
617 OGRErr SetPS(double dfCenterLat, double dfCenterLong, double dfScale,
618 double dfFalseEasting, double dfFalseNorthing);
619
621 OGRErr SetRobinson(double dfCenterLong, double dfFalseEasting,
622 double dfFalseNorthing);
623
625 OGRErr SetSinusoidal(double dfCenterLong, double dfFalseEasting,
626 double dfFalseNorthing);
627
629 OGRErr SetStereographic(double dfCenterLat, double dfCenterLong,
630 double dfScale, double dfFalseEasting,
631 double dfFalseNorthing);
632
634 OGRErr SetSOC(double dfLatitudeOfOrigin, double dfCentralMeridian,
635 double dfFalseEasting, double dfFalseNorthing);
636
638 OGRErr SetTM(double dfCenterLat, double dfCenterLong, double dfScale,
639 double dfFalseEasting, double dfFalseNorthing);
640
642 OGRErr SetTMVariant(const char *pszVariantName, double dfCenterLat,
643 double dfCenterLong, double dfScale,
644 double dfFalseEasting, double dfFalseNorthing);
645
647 OGRErr SetTMG(double dfCenterLat, double dfCenterLong,
648 double dfFalseEasting, double dfFalseNorthing);
649
651 OGRErr SetTMSO(double dfCenterLat, double dfCenterLong, double dfScale,
652 double dfFalseEasting, double dfFalseNorthing);
653
655 OGRErr SetTPED(double dfLat1, double dfLong1, double dfLat2, double dfLong2,
656 double dfFalseEasting, double dfFalseNorthing);
657
659 OGRErr SetVDG(double dfCenterLong, double dfFalseEasting,
660 double dfFalseNorthing);
661
663 OGRErr SetUTM(int nZone, int bNorth = TRUE);
664 int GetUTMZone(int *pbNorth = nullptr) const;
665
667 OGRErr SetWagner(int nVariation, double dfCenterLat, double dfFalseEasting,
668 double dfFalseNorthing);
669
671 OGRErr SetQSC(double dfCenterLat, double dfCenterLong);
672
674 OGRErr SetSCH(double dfPegLat, double dfPegLong, double dfPegHeading,
675 double dfPegHgt);
676
678 OGRErr
679 SetVerticalPerspective(double dfTopoOriginLat, double dfTopoOriginLon,
680 double dfTopoOriginHeight, double dfViewPointHeight,
681 double dfFalseEasting, double dfFalseNorthing);
682
684 OGRErr SetDerivedGeogCRSWithPoleRotationGRIBConvention(
685 const char *pszCRSName, double dfSouthPoleLat, double dfSouthPoleLon,
686 double dfAxisRotation);
687
689 OGRErr SetDerivedGeogCRSWithPoleRotationNetCDFCFConvention(
690 const char *pszCRSName, double dfGridNorthPoleLat,
691 double dfGridNorthPoleLon, double dfNorthPoleGridLon);
692
694 OGRErr SetStatePlane(int nZone, int bNAD83 = TRUE,
695 const char *pszOverrideUnitName = nullptr,
696 double dfOverrideUnit = 0.0);
697
699 OGRErr ImportFromESRIStatePlaneWKT(int nCode, const char *pszDatumName,
700 const char *pszUnitsName, int nPCSCode,
701 const char *pszCRSName = nullptr);
702
704 OGRErr ImportFromESRIWisconsinWKT(const char *pszPrjName,
705 double dfCentralMeridian,
706 double dfLatOfOrigin,
707 const char *pszUnitsName,
708 const char *pszCRSName = nullptr);
709
711 void UpdateCoordinateSystemFromGeogCRS();
714 static OGRSpatialReference *GetWGS84SRS();
715
720 {
721 return reinterpret_cast<OGRSpatialReferenceH>(poSRS);
722 }
723
728 {
729 return reinterpret_cast<OGRSpatialReference *>(hSRS);
730 }
731};
732
733/************************************************************************/
734/* OGRCoordinateTransformation */
735/* */
736/* This is really just used as a base class for a private */
737/* implementation. */
738/************************************************************************/
739
750{
751 public:
753 {
754 }
755
756 static void DestroyCT(OGRCoordinateTransformation *poCT);
757
758 // From CT_CoordinateTransformation
759
762
765
767 virtual bool GetEmitErrors() const
768 {
769 return false;
770 }
771
773 virtual void SetEmitErrors(bool /*bEmitErrors*/)
774 {
775 }
776
777 // From CT_MathTransform
778
796 int Transform(int nCount, double *x, double *y, double *z = nullptr,
797 int *pabSuccess = nullptr);
798
817 virtual int Transform(int nCount, double *x, double *y, double *z,
818 double *t, int *pabSuccess) = 0;
819
839 virtual int TransformWithErrorCodes(int nCount, double *x, double *y,
840 double *z, double *t,
841 int *panErrorCodes);
842
879 virtual int TransformBounds(const double xmin, const double ymin,
880 const double xmax, const double ymax,
881 double *out_xmin, double *out_ymin,
882 double *out_xmax, double *out_ymax,
883 const int densify_pts)
884 {
885 (void)xmin;
886 (void)xmax;
887 (void)ymin;
888 (void)ymax;
889 (void)densify_pts;
890 *out_xmin = HUGE_VAL;
891 *out_ymin = HUGE_VAL;
892 *out_xmax = HUGE_VAL;
893 *out_ymax = HUGE_VAL;
894 CPLError(CE_Failure, CPLE_AppDefined,
895 "TransformBounds not implemented.");
896 return false;
897 }
898
903 static inline OGRCoordinateTransformationH
905 {
906 return reinterpret_cast<OGRCoordinateTransformationH>(poCT);
907 }
908
913 static inline OGRCoordinateTransformation *
915 {
916 return reinterpret_cast<OGRCoordinateTransformation *>(hCT);
917 }
918
922 virtual OGRCoordinateTransformation *Clone() const = 0;
923
934};
935
938 const OGRSpatialReference *poTarget);
939
947{
949 private:
950 friend class OGRProjCT;
951 struct Private;
952 std::unique_ptr<Private> d;
955 public:
960 operator=(const OGRCoordinateTransformationOptions &);
962
963 bool SetAreaOfInterest(double dfWestLongitudeDeg, double dfSouthLatitudeDeg,
964 double dfEastLongitudeDeg,
965 double dfNorthLatitudeDeg);
966 bool SetDesiredAccuracy(double dfAccuracy);
967 bool SetBallparkAllowed(bool bAllowBallpark);
968
969 bool SetCoordinateOperation(const char *pszCT, bool bReverseCT);
971 void SetSourceCenterLong(double dfCenterLong);
972 void SetTargetCenterLong(double dfCenterLong);
974};
975
977 const OGRSpatialReference *poSource, const OGRSpatialReference *poTarget,
979
980#endif /* ndef OGR_SPATIALREF_H_INCLUDED */
Convenient string class based on std::string.
Definition cpl_string.h:312
Interface for transforming between coordinate systems.
Definition ogr_spatialref.h:750
virtual OGRSpatialReference * GetSourceCS()=0
Fetch internal source coordinate system.
virtual void SetEmitErrors(bool)
Set if the transformer must emit CPLError.
Definition ogr_spatialref.h:773
int Transform(int nCount, double *x, double *y, double *z=nullptr, int *pabSuccess=nullptr)
Transform points from source to destination space.
virtual OGRSpatialReference * GetTargetCS()=0
Fetch internal target coordinate system.
virtual int TransformWithErrorCodes(int nCount, double *x, double *y, double *z, double *t, int *panErrorCodes)
Transform points from source to destination space.
virtual OGRCoordinateTransformation * GetInverse() const =0
Return a coordinate transformation that performs the inverse transformation of the current one.
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:879
virtual bool GetEmitErrors() const
Whether the transformer will emit CPLError.
Definition ogr_spatialref.h:767
virtual int Transform(int nCount, double *x, double *y, double *z, double *t, int *pabSuccess)=0
Transform points from source to destination space.
static OGRCoordinateTransformation * FromHandle(OGRCoordinateTransformationH hCT)
Convert a OGRCoordinateTransformationH to a OGRCoordinateTransformation*.
Definition ogr_spatialref.h:914
static OGRCoordinateTransformationH ToHandle(OGRCoordinateTransformation *poCT)
Convert a OGRCoordinateTransformation* to a OGRCoordinateTransformationH.
Definition ogr_spatialref.h:904
virtual OGRCoordinateTransformation * Clone() const =0
Clone.
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition ogr_spatialref.h:167
static OGRSpatialReferenceH ToHandle(OGRSpatialReference *poSRS)
Convert a OGRSpatialReference* to a OGRSpatialReferenceH.
Definition ogr_spatialref.h:719
static OGRSpatialReference * FromHandle(OGRSpatialReferenceH hSRS)
Convert a OGRSpatialReferenceH to a OGRSpatialReference*.
Definition ogr_spatialref.h:727
Objects of this class are used to represent value nodes in the parsed representation of the WKT SRS f...
Definition ogr_spatialref.h:67
int GetChildCount() const
Get number of children nodes.
Definition ogr_spatialref.h:91
const char * GetValue() const
Fetch value string for this node.
Definition ogr_spatialref.h:108
int IsLeafNode() const
Return whether this is a leaf node.
Definition ogr_spatialref.h:86
#define CPLE_AppDefined
Application defined error.
Definition cpl_error.h:100
#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:1049
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition cpl_port.h:1190
Various convenience functions for working with strings and string lists.
void * OGRCoordinateTransformationH
Opaque type for a coordinate transformation object.
Definition ogr_api.h:83
void * OGRSpatialReferenceH
Opaque type for a spatial reference system.
Definition ogr_api.h:81
int OGRErr
Type for a OGR error.
Definition ogr_core.h:378
#define USGS_ANGLE_PACKEDDMS
Angle is in packed degree minute second.
Definition ogr_spatialref.h:236
OGRCoordinateTransformation * OGRCreateCoordinateTransformation(const OGRSpatialReference *poSource, const OGRSpatialReference *poTarget)
Create transformation object.
Definition ogrct.cpp:873
C spatial reference system services and defines.
OSRAxisMappingStrategy
Data axis to CRS axis mapping strategy.
Definition ogr_srs_api.h:656
OGRAxisOrientation
Axis orientations (corresponds to CS_AxisOrientationEnum).
Definition ogr_srs_api.h:49
Context for coordinate transformation.
Definition ogr_spatialref.h:947
Listener that is notified of modification to nodes.
Definition ogr_spatialref.h:71
virtual void notifyChange(OGR_SRSNode *)=0
Method triggered when a node is modified.