NDEVR
API Documentation
CoordinateProjectionManager

Stores Coordinate Projections See https://ndevr.org/coordinate-projection/. More...

Collaboration diagram for CoordinateProjectionManager:
[legend]

Public Member Functions

void addProjection (const CoordinateProjection &projection)
 Adds a coordinate projection to the manager.
Buffer< UUIDbestProjectionsLatLon (const Vertex< 2, fltp08 > &lat_lon) const
 Returns a ranked list of projections suitable for a given latitude/longitude coordinate.
UUID bestUTMProjectionLatLon (const Vertex< 2, fltp08 > &lat_lon) const
 Determines the best UTM projection for a given latitude/longitude coordinate.
UUID bestUTMProjectionMeters (const Vertex< 2, fltp08 > &northing_easting) const
 Determines the best UTM projection for a given coordinate in meters.
void cleanup ()
 Removes unused or invalid entries and frees associated resources.
Bounds< 2, fltp08convertFromWGS84 (UUID from_id, const Bounds< 2, Angle< fltp08 > > &bounds) const
 Converts 2D angle-based bounds from WGS 84 to the specified projection.
Bounds< 2, fltp08convertFromWGS84 (UUID from_id, const Bounds< 2, fltp08 > &bounds) const
 Converts 2D bounds from WGS 84 to the specified projection.
Bounds< 2, fltp08convertFromWGS84 (UUID from_id, const Bounds< 3, fltp08 > &bounds) const
 Converts 3D bounds from WGS 84 to the specified projection.
Vertex< 3, fltp08convertFromWGS84 (UUID from_id, const Vertex< 3, fltp08 > &location) const
 Converts a 3D vertex from WGS 84 to the specified projection.
Bounds< 2, fltp08convertToWGS84 (UUID from_id, const Bounds< 2, fltp08 > &bounds) const
 Converts 2D bounds from the specified projection to WGS 84 geographic coordinates.
Bounds< 2, fltp08convertToWGS84 (UUID from_id, const Bounds< 3, fltp08 > &bounds) const
 Converts 3D bounds from the specified projection to WGS 84 geographic coordinates.
Buffer< Vertex< 2, fltp08 > > convertToWGS84 (UUID from_id, const Buffer< Vertex< 2, fltp08 > > &locations) const
 Converts a buffer of 2D vertices from the specified projection to WGS 84.
LineSegment< 2, fltp08convertToWGS84 (UUID from_id, const LineSegment< 2, fltp08 > &segment) const
 Converts a 2D line segment from the specified projection to WGS 84.
Polyline< 2, fltp08, Vertex< 2, fltp08 > > convertToWGS84 (UUID from_id, const Polyline< 2, fltp08, Vertex< 2, fltp08 > > &segment) const
 Converts a 2D polyline from the specified projection to WGS 84.
Vertex< 3, fltp08convertToWGS84 (UUID from_id, const Vertex< 3, fltp08 > &location) const
 Converts a 3D vertex from the specified projection to WGS 84.
void createUTMCoordinateProjections ()
 Creates and registers all standard UTM coordinate projections (zones 1-60, north and south).
String createWKTString (UUID id, const UnitManager &manager) const
 Creates a Well-Known Text (WKT) string for the specified projection.
const CoordinateProjectioncurrentProjection () const
 Returns the currently active coordinate projection.
void downloadAllProjections ()
 Downloads definitions for all known projections from the remote source.
bool downloadEPSGProjection (uint04 epsg_code, std::function< void(uint04 code, UUID projection)> finished_callback, bool force_download=false)
 Downloads the projection definition for a specific EPSG code.
UUID epsgProjection (uint04 epsg_number) const
 Returns the UUID of the projection with the given EPSG number.
const CoordinateProjectionget (UUID id) const
 Returns the coordinate projection data for the given UUID.
UUID getProjection (const StringView &name) const
 Looks up a projection UUID by its name.
Buffer< UUIDgetProjections (const StringView &search_string=StringView()) const
 Returns a list of projection UUIDs, optionally filtered by a search string.
bool hasDownloader () const
 Checks whether a downloader function has been configured.
bool hasProjection (UUID projection_id) const
 Checks whether a projection with the given UUID exists in the manager.
void invalidateConverterCache (UUID projection_id)
 Invalidates any cached converter for the specified projection, forcing re-creation on next use.
void processJSON (CoordinateProjection &projection, JSONNode &json)
 Parses a JSON node and populates the given projection.
void processWKT (CoordinateProjection &projection, Scanner &scan)
 Parses a Well-Known Text (WKT) string and populates the given projection.
const Dictionary< UUID, CoordinateProjection > & projections () const
 Returns a const reference to the dictionary of all stored projections.
void readCoordinateFile (File &file)
 Reads coordinate projection definitions from the specified file.
void readDirectoryStructure (File &top_dir)
 Reads coordinate projection definitions from a directory structure.
void readDirectoryStructure (File &top_dir, File &save_as)
 Reads coordinate projection definitions from a directory structure and saves the consolidated result.
void setCoordinateFile (File &file)
 Sets the file used for reading and writing coordinate projection data.
void setDownloader (std::function< void(const StringView &, std::function< void(const StringView &)>)> downloader)
 Sets the download function used to retrieve remote projection data.
void setVerticalDatum (UUID projection_id, const String &authority, uint04 authority_number)
 Sets the vertical datum for a given projection.
CoordinateConverterwgs84Converter (UUID from_id) const
 Retrieves or creates a converter from the specified projection to WGS 84.
UUID wgs84Projection () const
 Returns the UUID of the WGS 84 geographic projection.
ConstPointer< UnitwGS84Unit (UUID from_id)
 Returns a unit that converts from the specified projection to WGS 84.
ConstPointer< UnitOptionwGS84UnitOption ()
 Returns a UnitOption representing conversion to WGS 84.
void writeCoordinateFile (File &file) const
 Writes all stored coordinate projections to the specified file.

Static Public Member Functions

static CoordinateProjectionBestUTMProjectionInfo ()
 Returns a mutable reference to the CoordinateProjection info for the auto-selected best UTM projection.
static CoordinateProjectionManagerDefaultInstance ()
 Returns the singleton default instance of the CoordinateProjectionManager.
static VerticalDatum GetVerticalDatum (uint04 authority_number)
 Returns the vertical datum matching the given authority number.
static Buffer< VerticalDatumGetVerticalDatums ()
 Returns a list of all known vertical datums.
static bool HasEngine ()
 Checks whether a coordinate projection engine (e.g., PROJ) is available.
static UUID UseBestUTMProjectionID ()
 Returns a sentinel UUID indicating that the best UTM projection should be auto-selected.

Protected Member Functions

ConstPointer< UnitunitFromString (const StringView &unit)
 Looks up or creates a Unit from a string representation.

Protected Attributes

File m_coordinate_file
 The file used for persistent coordinate projection storage.
std::function< void(const StringView &, std::function< void(const StringView &)>)> m_downloader
 Callback used to download remote projection definitions.
Dictionary< UUID, CoordinateProjectionm_projections
 Dictionary of all registered coordinate projections keyed by UUID.
Dictionary< String, ConstPointer< Unit > > m_units
 Cache of parsed units keyed by their string names.
Buffer< UUIDm_utm_projections
 List of UUIDs for the registered UTM projections.
UUID m_wgs84_id = Constant<UUID>::Invalid
 Cached UUID of the WGS 84 projection.
Dictionary< UUID, CoordinateConverter * > m_wgs_84_converter
 Cache of converters from various projections to WGS 84.

Detailed Description

Member Function Documentation

◆ addProjection()

void CoordinateProjectionManager::addProjection ( const CoordinateProjection & projection)

Adds a coordinate projection to the manager.

Parameters
[in]projectionThe coordinate projection to add.

◆ bestProjectionsLatLon()

Buffer< UUID > CoordinateProjectionManager::bestProjectionsLatLon ( const Vertex< 2, fltp08 > & lat_lon) const

Returns a ranked list of projections suitable for a given latitude/longitude coordinate.

Parameters
[in]lat_lonThe geographic coordinate as (latitude, longitude) in degrees.
Returns
A buffer of projection UUIDs ordered by suitability.

◆ BestUTMProjectionInfo()

CoordinateProjection & CoordinateProjectionManager::BestUTMProjectionInfo ( )
static

Returns a mutable reference to the CoordinateProjection info for the auto-selected best UTM projection.

Returns
A reference to the best UTM CoordinateProjection.

◆ bestUTMProjectionLatLon()

UUID CoordinateProjectionManager::bestUTMProjectionLatLon ( const Vertex< 2, fltp08 > & lat_lon) const

Determines the best UTM projection for a given latitude/longitude coordinate.

Parameters
[in]lat_lonThe geographic coordinate as (latitude, longitude) in degrees.
Returns
The UUID of the best-matching UTM projection.

◆ bestUTMProjectionMeters()

UUID CoordinateProjectionManager::bestUTMProjectionMeters ( const Vertex< 2, fltp08 > & northing_easting) const

Determines the best UTM projection for a given coordinate in meters.

Parameters
[in]northing_eastingThe coordinate in meters.
Returns
The UUID of the best-matching UTM projection.

◆ convertFromWGS84() [1/4]

Bounds< 2, fltp08 > CoordinateProjectionManager::convertFromWGS84 ( UUID from_id,
const Bounds< 2, Angle< fltp08 > > & bounds ) const

Converts 2D angle-based bounds from WGS 84 to the specified projection.

Parameters
[in]from_idThe UUID of the target projection.
[in]boundsThe 2D angle bounds in WGS 84.
Returns
The converted 2D bounds in the target projection.

◆ convertFromWGS84() [2/4]

Bounds< 2, fltp08 > CoordinateProjectionManager::convertFromWGS84 ( UUID from_id,
const Bounds< 2, fltp08 > & bounds ) const

Converts 2D bounds from WGS 84 to the specified projection.

Parameters
[in]from_idThe UUID of the target projection.
[in]boundsThe 2D bounds in WGS 84 (latitude/longitude).
Returns
The converted 2D bounds in the target projection.

◆ convertFromWGS84() [3/4]

Bounds< 2, fltp08 > CoordinateProjectionManager::convertFromWGS84 ( UUID from_id,
const Bounds< 3, fltp08 > & bounds ) const

Converts 3D bounds from WGS 84 to the specified projection.

Parameters
[in]from_idThe UUID of the target projection.
[in]boundsThe 3D bounds in WGS 84.
Returns
The converted 2D bounds in the target projection.

◆ convertFromWGS84() [4/4]

Vertex< 3, fltp08 > CoordinateProjectionManager::convertFromWGS84 ( UUID from_id,
const Vertex< 3, fltp08 > & location ) const

Converts a 3D vertex from WGS 84 to the specified projection.

Parameters
[in]from_idThe UUID of the target projection.
[in]locationThe 3D vertex in WGS 84 to convert.
Returns
The converted 3D vertex in the target projection.

◆ convertToWGS84() [1/6]

Bounds< 2, fltp08 > CoordinateProjectionManager::convertToWGS84 ( UUID from_id,
const Bounds< 2, fltp08 > & bounds ) const

Converts 2D bounds from the specified projection to WGS 84 geographic coordinates.

Parameters
[in]from_idThe UUID of the source projection.
[in]boundsThe 2D bounds to convert.
Returns
The converted 2D bounds in WGS 84 (latitude/longitude).

◆ convertToWGS84() [2/6]

Bounds< 2, fltp08 > CoordinateProjectionManager::convertToWGS84 ( UUID from_id,
const Bounds< 3, fltp08 > & bounds ) const

Converts 3D bounds from the specified projection to WGS 84 geographic coordinates.

Parameters
[in]from_idThe UUID of the source projection.
[in]boundsThe 3D bounds to convert.
Returns
The converted 2D bounds in WGS 84 (latitude/longitude).

◆ convertToWGS84() [3/6]

Buffer< Vertex< 2, fltp08 > > CoordinateProjectionManager::convertToWGS84 ( UUID from_id,
const Buffer< Vertex< 2, fltp08 > > & locations ) const

Converts a buffer of 2D vertices from the specified projection to WGS 84.

Parameters
[in]from_idThe UUID of the source projection.
[in]locationsThe buffer of 2D vertices to convert.
Returns
A buffer of converted 2D vertices in WGS 84.

◆ convertToWGS84() [4/6]

LineSegment< 2, fltp08 > CoordinateProjectionManager::convertToWGS84 ( UUID from_id,
const LineSegment< 2, fltp08 > & segment ) const

Converts a 2D line segment from the specified projection to WGS 84.

Parameters
[in]from_idThe UUID of the source projection.
[in]segmentThe line segment to convert.
Returns
The converted line segment in WGS 84 coordinates.

◆ convertToWGS84() [5/6]

Polyline< 2, fltp08, Vertex< 2, fltp08 > > CoordinateProjectionManager::convertToWGS84 ( UUID from_id,
const Polyline< 2, fltp08, Vertex< 2, fltp08 > > & segment ) const

Converts a 2D polyline from the specified projection to WGS 84.

Parameters
[in]from_idThe UUID of the source projection.
[in]segmentThe polyline to convert.
Returns
The converted polyline in WGS 84 coordinates.

◆ convertToWGS84() [6/6]

Vertex< 3, fltp08 > CoordinateProjectionManager::convertToWGS84 ( UUID from_id,
const Vertex< 3, fltp08 > & location ) const

Converts a 3D vertex from the specified projection to WGS 84.

Parameters
[in]from_idThe UUID of the source projection.
[in]locationThe 3D vertex to convert.
Returns
The converted 3D vertex in WGS 84 coordinates.

◆ createWKTString()

String CoordinateProjectionManager::createWKTString ( UUID id,
const UnitManager & manager ) const

Creates a Well-Known Text (WKT) string for the specified projection.

Parameters
[in]idThe UUID of the projection.
[in]managerThe UnitManager used for unit lookups during WKT generation.
Returns
The WKT string representation of the projection.

◆ currentProjection()

const CoordinateProjection & CoordinateProjectionManager::currentProjection ( ) const

Returns the currently active coordinate projection.

Returns
A const reference to the current CoordinateProjection.

◆ DefaultInstance()

CoordinateProjectionManager & CoordinateProjectionManager::DefaultInstance ( )
static

Returns the singleton default instance of the CoordinateProjectionManager.

Returns
A reference to the default CoordinateProjectionManager.

◆ downloadEPSGProjection()

bool CoordinateProjectionManager::downloadEPSGProjection ( uint04 epsg_code,
std::function< void(uint04 code, UUID projection)> finished_callback,
bool force_download = false )

Downloads the projection definition for a specific EPSG code.

Parameters
[in]epsg_codeThe EPSG code to download.
[in]finished_callbackCalled when the download completes, with the EPSG code and resulting projection UUID.
[in]force_downloadIf true, re-downloads even if the projection already exists locally.
Returns
True if the download was initiated.

◆ epsgProjection()

UUID CoordinateProjectionManager::epsgProjection ( uint04 epsg_number) const

Returns the UUID of the projection with the given EPSG number.

Parameters
[in]epsg_numberThe EPSG authority code.
Returns
The UUID of the matching projection, or an invalid UUID if not found.

◆ get()

const CoordinateProjection & CoordinateProjectionManager::get ( UUID id) const

Returns the coordinate projection data for the given UUID.

Parameters
[in]idThe UUID of the projection to retrieve.
Returns
A const reference to the CoordinateProjection.

◆ getProjection()

UUID CoordinateProjectionManager::getProjection ( const StringView & name) const

Looks up a projection UUID by its name.

Parameters
[in]nameThe name of the projection to find.
Returns
The UUID of the matching projection, or an invalid UUID if not found.

◆ getProjections()

Buffer< UUID > CoordinateProjectionManager::getProjections ( const StringView & search_string = StringView()) const

Returns a list of projection UUIDs, optionally filtered by a search string.

Parameters
[in]search_stringAn optional filter applied to projection names.
Returns
A buffer of matching projection UUIDs.

◆ GetVerticalDatum()

VerticalDatum CoordinateProjectionManager::GetVerticalDatum ( uint04 authority_number)
static

Returns the vertical datum matching the given authority number.

Parameters
[in]authority_numberThe authority code identifying the vertical datum.
Returns
The matching VerticalDatum.

◆ GetVerticalDatums()

Buffer< VerticalDatum > CoordinateProjectionManager::GetVerticalDatums ( )
static

Returns a list of all known vertical datums.

Returns
A buffer of VerticalDatum entries.

◆ hasDownloader()

bool CoordinateProjectionManager::hasDownloader ( ) const

Checks whether a downloader function has been configured.

Returns
True if a downloader is available.

◆ HasEngine()

bool CoordinateProjectionManager::HasEngine ( )
static

Checks whether a coordinate projection engine (e.g., PROJ) is available.

Returns
True if a projection engine is loaded and operational.

◆ hasProjection()

bool CoordinateProjectionManager::hasProjection ( UUID projection_id) const

Checks whether a projection with the given UUID exists in the manager.

Parameters
[in]projection_idThe UUID to look up.
Returns
True if the projection exists.

◆ invalidateConverterCache()

void CoordinateProjectionManager::invalidateConverterCache ( UUID projection_id)

Invalidates any cached converter for the specified projection, forcing re-creation on next use.

Parameters
[in]projection_idThe UUID of the projection whose converter cache should be cleared.

◆ processJSON()

void CoordinateProjectionManager::processJSON ( CoordinateProjection & projection,
JSONNode & json )

Parses a JSON node and populates the given projection.

Parameters
[in]projectionThe projection to populate with parsed JSON data.
[in]jsonThe JSON node containing projection definition.

◆ processWKT()

void CoordinateProjectionManager::processWKT ( CoordinateProjection & projection,
Scanner & scan )

Parses a Well-Known Text (WKT) string and populates the given projection.

Parameters
[in]projectionThe projection to populate with parsed WKT data.
[in]scanThe scanner positioned at the WKT content.

◆ projections()

const Dictionary< UUID, CoordinateProjection > & CoordinateProjectionManager::projections ( ) const
inline

Returns a const reference to the dictionary of all stored projections.

Returns
The dictionary mapping UUIDs to CoordinateProjection objects.

Definition at line 345 of file CoordinateProjectionManager.h.

References m_projections.

◆ readCoordinateFile()

void CoordinateProjectionManager::readCoordinateFile ( File & file)

Reads coordinate projection definitions from the specified file.

Parameters
[in]fileThe file containing coordinate projection data.

◆ readDirectoryStructure() [1/2]

void CoordinateProjectionManager::readDirectoryStructure ( File & top_dir)

Reads coordinate projection definitions from a directory structure.

Parameters
[in]top_dirThe top-level directory to scan for projection files.

◆ readDirectoryStructure() [2/2]

void CoordinateProjectionManager::readDirectoryStructure ( File & top_dir,
File & save_as )

Reads coordinate projection definitions from a directory structure and saves the consolidated result.

Parameters
[in]top_dirThe top-level directory to scan for projection files.
[in]save_asThe file to save the consolidated projection data to.

◆ setCoordinateFile()

void CoordinateProjectionManager::setCoordinateFile ( File & file)

Sets the file used for reading and writing coordinate projection data.

Parameters
[in]fileThe file to use as the coordinate projection database.

◆ setDownloader()

void CoordinateProjectionManager::setDownloader ( std::function< void(const StringView &, std::function< void(const StringView &)>)> downloader)

Sets the download function used to retrieve remote projection data.

Parameters
[in]downloaderA callable that takes a URL and a completion callback receiving the downloaded content.

◆ setVerticalDatum()

void CoordinateProjectionManager::setVerticalDatum ( UUID projection_id,
const String & authority,
uint04 authority_number )

Sets the vertical datum for a given projection.

Parameters
[in]projection_idThe UUID of the projection to update.
[in]authorityThe authority name (e.g., "EPSG").
[in]authority_numberThe authority code for the vertical datum.

◆ unitFromString()

ConstPointer< Unit > CoordinateProjectionManager::unitFromString ( const StringView & unit)
protected

Looks up or creates a Unit from a string representation.

Parameters
[in]unitThe string name of the unit.
Returns
A ConstPointer to the Unit matching the given string.

◆ UseBestUTMProjectionID()

UUID CoordinateProjectionManager::UseBestUTMProjectionID ( )
static

Returns a sentinel UUID indicating that the best UTM projection should be auto-selected.

Returns
A UUID used as a placeholder for automatic UTM projection selection.

◆ wgs84Converter()

CoordinateConverter * CoordinateProjectionManager::wgs84Converter ( UUID from_id) const

Retrieves or creates a converter from the specified projection to WGS 84.

Parameters
[in]from_idThe UUID of the source projection.
Returns
A pointer to the CoordinateConverter, or nullptr if conversion is not possible.

◆ wgs84Projection()

UUID CoordinateProjectionManager::wgs84Projection ( ) const

Returns the UUID of the WGS 84 geographic projection.

Returns
The UUID identifying the WGS 84 projection.

◆ wGS84Unit()

ConstPointer< Unit > CoordinateProjectionManager::wGS84Unit ( UUID from_id)

Returns a unit that converts from the specified projection to WGS 84.

Parameters
[in]from_idThe UUID of the source projection.
Returns
A ConstPointer to the Unit for the conversion.

◆ wGS84UnitOption()

ConstPointer< UnitOption > CoordinateProjectionManager::wGS84UnitOption ( )

Returns a UnitOption representing conversion to WGS 84.

Returns
A ConstPointer to the WGS 84 UnitOption.

◆ writeCoordinateFile()

void CoordinateProjectionManager::writeCoordinateFile ( File & file) const

Writes all stored coordinate projections to the specified file.

Parameters
[in]fileThe file to write coordinate projection data to.

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