SWMMVis  6.0.0-alpha.4
Qt6/C++ GIS-based graphical user interface for the SWMMVis engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
SpatialReferenceSystem Class Reference

Represents a coordinate reference system backed by a GDAL OGRSpatialReference. More...

#include <spatialreferencesystem.h>

Inheritance diagram for SpatialReferenceSystem:
Collaboration diagram for SpatialReferenceSystem:

Classes

struct  LinearUnitInfo
 Planar linear-unit information used by the 2D mesh writer. More...
 

Signals

void propertyChanged (const QString &propertyName)
 Emitted when any property changes.
 

Public Member Functions

 SpatialReferenceSystem (const QString &authName="EPSG", int code=4326, QObject *parent=nullptr)
 Constructs a CRS from an EPSG code.
 
 SpatialReferenceSystem (const QString &wktOrProj, QObject *parent=nullptr)
 Constructs a CRS from a WKT or PROJ string.
 
 SpatialReferenceSystem (const SpatialReferenceSystem &other, QObject *parent=nullptr)
 Copy-constructs from another SpatialReferenceSystem.
 
virtual ~SpatialReferenceSystem ()
 
QString authName () const
 Returns the authority name (e.g. "EPSG", "ESRI").
 
int code () const
 Returns the numeric authority code, or -1 if not known.
 
QString description () const
 Returns a human-readable description/name for this CRS.
 
void setDescription (const QString &description)
 Sets a custom description for this CRS.
 
QString toWkt () const
 Exports this CRS as a WKT2 string.
 
QString toProj4 () const
 Exports this CRS as a legacy PROJ.4 string.
 
QString toAuthority () const
 Returns the "AUTHORITY:CODE" string, e.g. "EPSG:4326".
 
bool isGeographic () const
 Returns true when the CRS uses geographic (angular) coordinates.
 
bool isProjected () const
 Returns true when the CRS is a projected (Cartesian) CRS.
 
bool equals (const SpatialReferenceSystem &other) const
 Returns true when this CRS equals other (within GDAL tolerance).
 
QString linearUnitsName () const
 Returns the name of the linear unit (e.g. "metre", "US survey foot"). Returns an empty string for geographic CRSes.
 
double linearUnitsToMetres () const
 Returns the conversion factor from the linear unit to metres. Returns 1.0 for geographic CRSes.
 
QString angularUnitsName () const
 Returns the name of the angular unit (e.g. "degree"). Returns an empty string for projected CRSes.
 
LinearUnitInfo planarLinearUnit () const
 Returns a LinearUnitInfo describing the planar linear unit.
 
OGRSpatialReference * ogrSpatialReference () const
 Returns a non-owning pointer to the underlying OGRSpatialReference.
 
OGRCoordinateTransformation * createTransformationTo (const SpatialReferenceSystem &target) const
 Creates a new OGRCoordinateTransformation from this CRS to target.
 
bool isLocal () const
 

Static Public Member Functions

static SpatialReferenceSystemfromWktOrProj (const QString &wktOrProj, QObject *parent=nullptr)
 Creates a SpatialReferenceSystem from a WKT or PROJ string.
 
static SpatialReferenceSystemfromAuthCode (const QString &authName, int code, QObject *parent=nullptr)
 Creates a SpatialReferenceSystem from an authority code.
 
static SpatialReferenceSystemuntitled (QObject *parent=nullptr)
 Creates a local / untitled CRS for models with no coordinate system defined. Coordinates are treated as raw Cartesian values; no reprojection is possible.
 
static SpatialReferenceSystemlocalFromMapUnits (const QString &mapUnits, QObject *parent=nullptr)
 Creates a local CRS with linear units derived from the SWMM [MAP] section Units field (e.g. "FEET" or "METERS"). Distances and the scale bar will show correct values without requiring a geographic CRS.
 

Properties

QString authName
 
int code
 
QString description
 
QString wkt
 
QString proj4
 
bool isGeographic
 
bool isProjected
 
QString linearUnits
 

Detailed Description

Represents a coordinate reference system backed by a GDAL OGRSpatialReference.

Provides access to CRS metadata (authority, code, description, units) and factory methods for creating coordinate transformations between two CRSes. Retains ownership of the underlying OGRSpatialReference.

Constructor & Destructor Documentation

◆ SpatialReferenceSystem() [1/3]

SpatialReferenceSystem::SpatialReferenceSystem ( const QString &  authName = "EPSG",
int  code = 4326,
QObject *  parent = nullptr 
)
explicit

Constructs a CRS from an EPSG code.

Parameters
authNameAuthority name, e.g. "EPSG" (default).
codeNumeric authority code, e.g. 4326 (WGS 84, default).
parentQt parent object.

◆ SpatialReferenceSystem() [2/3]

SpatialReferenceSystem::SpatialReferenceSystem ( const QString &  wktOrProj,
QObject *  parent = nullptr 
)
explicit

Constructs a CRS from a WKT or PROJ string.

Parameters
wktOrProjWKT or PROJ.4/PROJ string representation.
parentQt parent object.

◆ SpatialReferenceSystem() [3/3]

SpatialReferenceSystem::SpatialReferenceSystem ( const SpatialReferenceSystem other,
QObject *  parent = nullptr 
)
explicit

Copy-constructs from another SpatialReferenceSystem.

◆ ~SpatialReferenceSystem()

SpatialReferenceSystem::~SpatialReferenceSystem ( )
virtual

Member Function Documentation

◆ angularUnitsName()

QString SpatialReferenceSystem::angularUnitsName ( ) const

Returns the name of the angular unit (e.g. "degree"). Returns an empty string for projected CRSes.

◆ authName()

QString SpatialReferenceSystem::authName ( ) const

Returns the authority name (e.g. "EPSG", "ESRI").

◆ code()

int SpatialReferenceSystem::code ( ) const

Returns the numeric authority code, or -1 if not known.

◆ createTransformationTo()

OGRCoordinateTransformation * SpatialReferenceSystem::createTransformationTo ( const SpatialReferenceSystem target) const

Creates a new OGRCoordinateTransformation from this CRS to target.

Caller takes ownership of the returned object; destroy it with OGRCoordinateTransformation::DestroyCT() or delete.

Parameters
targetDestination CRS.
Returns
A new transformation, or nullptr on failure.
Here is the caller graph for this function:

◆ description()

QString SpatialReferenceSystem::description ( ) const

Returns a human-readable description/name for this CRS.

Here is the call graph for this function:

◆ equals()

bool SpatialReferenceSystem::equals ( const SpatialReferenceSystem other) const

Returns true when this CRS equals other (within GDAL tolerance).

Here is the caller graph for this function:

◆ fromAuthCode()

SpatialReferenceSystem * SpatialReferenceSystem::fromAuthCode ( const QString &  authName,
int  code,
QObject *  parent = nullptr 
)
static

Creates a SpatialReferenceSystem from an authority code.

Parameters
authNamee.g. "EPSG".
codeNumeric EPSG/authority code.
parentQt parent for the new object.
Returns
New SpatialReferenceSystem (caller owns it), or nullptr on failure.
Here is the caller graph for this function:

◆ fromWktOrProj()

SpatialReferenceSystem * SpatialReferenceSystem::fromWktOrProj ( const QString &  wktOrProj,
QObject *  parent = nullptr 
)
static

Creates a SpatialReferenceSystem from a WKT or PROJ string.

Parameters
wktOrProjWKT or PROJ string.
parentQt parent for the new object.
Returns
New SpatialReferenceSystem (caller owns it), or nullptr on failure.
Here is the caller graph for this function:

◆ isGeographic()

bool SpatialReferenceSystem::isGeographic ( ) const

Returns true when the CRS uses geographic (angular) coordinates.

◆ isLocal()

bool SpatialReferenceSystem::isLocal ( ) const

Returns true when this is a local (non-geographic, non-projected) CRS.

Here is the caller graph for this function:

◆ isProjected()

bool SpatialReferenceSystem::isProjected ( ) const

Returns true when the CRS is a projected (Cartesian) CRS.

◆ linearUnitsName()

QString SpatialReferenceSystem::linearUnitsName ( ) const

Returns the name of the linear unit (e.g. "metre", "US survey foot"). Returns an empty string for geographic CRSes.

◆ linearUnitsToMetres()

double SpatialReferenceSystem::linearUnitsToMetres ( ) const

Returns the conversion factor from the linear unit to metres. Returns 1.0 for geographic CRSes.

Here is the caller graph for this function:

◆ localFromMapUnits()

SpatialReferenceSystem * SpatialReferenceSystem::localFromMapUnits ( const QString &  mapUnits,
QObject *  parent = nullptr 
)
static

Creates a local CRS with linear units derived from the SWMM [MAP] section Units field (e.g. "FEET" or "METERS"). Distances and the scale bar will show correct values without requiring a geographic CRS.

Parameters
mapUnitsValue of the [MAP] Units line (case-insensitive: "FEET"/"METERS"/…).
parentQt parent for the new object.
Here is the caller graph for this function:

◆ ogrSpatialReference()

OGRSpatialReference * SpatialReferenceSystem::ogrSpatialReference ( ) const

Returns a non-owning pointer to the underlying OGRSpatialReference.

Warning
Caller must not delete the returned pointer.
Here is the caller graph for this function:

◆ planarLinearUnit()

SpatialReferenceSystem::LinearUnitInfo SpatialReferenceSystem::planarLinearUnit ( ) const

Returns a LinearUnitInfo describing the planar linear unit.

Use this at every boundary that must convert between project-CRS XY and engine-SI metres (2D mesh write/read).

◆ propertyChanged

void SpatialReferenceSystem::propertyChanged ( const QString &  propertyName)
signal

Emitted when any property changes.

Parameters
propertyNameName of the changed Q_PROPERTY.
Here is the caller graph for this function:

◆ setDescription()

void SpatialReferenceSystem::setDescription ( const QString &  description)

Sets a custom description for this CRS.

Here is the call graph for this function:

◆ toAuthority()

QString SpatialReferenceSystem::toAuthority ( ) const

Returns the "AUTHORITY:CODE" string, e.g. "EPSG:4326".

Here is the caller graph for this function:

◆ toProj4()

QString SpatialReferenceSystem::toProj4 ( ) const

Exports this CRS as a legacy PROJ.4 string.

Returns
PROJ.4 string, or an empty string on failure.

◆ toWkt()

QString SpatialReferenceSystem::toWkt ( ) const

Exports this CRS as a WKT2 string.

Returns
WKT2 representation, or an empty string on failure.
Here is the caller graph for this function:

◆ untitled()

SpatialReferenceSystem * SpatialReferenceSystem::untitled ( QObject *  parent = nullptr)
static

Creates a local / untitled CRS for models with no coordinate system defined. Coordinates are treated as raw Cartesian values; no reprojection is possible.

Here is the caller graph for this function:

Property Documentation

◆ authName

QString SpatialReferenceSystem::authName
read

◆ code

int SpatialReferenceSystem::code
read

◆ description

QString SpatialReferenceSystem::description
readwrite

◆ isGeographic

bool SpatialReferenceSystem::isGeographic
read

◆ isProjected

bool SpatialReferenceSystem::isProjected
read

◆ linearUnits

QString SpatialReferenceSystem::linearUnits
read

◆ proj4

QString SpatialReferenceSystem::proj4
read

◆ wkt

QString SpatialReferenceSystem::wkt
read

The documentation for this class was generated from the following files: