34#include <NDEVR/CoordinateProjection.h>
35#include <NDEVR/Dictionary.h>
36#include <NDEVR/String.h>
37#include <NDEVR/Pointer.h>
38#include <NDEVR/File.h>
39#include <NDEVR/UUID.h>
43 template<u
int01 t_dims,
class t_type,
class t_vertex>
75 template<
class t_type>
Stores an angle in an optimized internal format with support for efficient trigonometric operations.
A specification of upper and lower bounds in N-dimensions.
The equivelent of std::vector but with a bit more control.
Provides a constant, unmodifiable pointer that has shared ownership of a dynamically allocated object...
Forward declaration of the File class.
Stores Coordinate Projections See https://ndevr.org/coordinate-projection/.
ConstPointer< Unit > unitFromString(const StringView &unit)
Looks up or creates a Unit from a string representation.
void addProjection(const CoordinateProjection &projection)
Adds a coordinate projection to the manager.
UUID m_wgs84_id
Cached UUID of the WGS 84 projection.
Buffer< UUID > m_utm_projections
List of UUIDs for the registered UTM projections.
static CoordinateProjection & BestUTMProjectionInfo()
Returns a mutable reference to the CoordinateProjection info for the auto-selected best UTM projectio...
static Buffer< VerticalDatum > GetVerticalDatums()
Returns a list of all known vertical datums.
Buffer< UUID > getProjections(const StringView &search_string=StringView()) const
Returns a list of projection UUIDs, optionally filtered by a search string.
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.
void readDirectoryStructure(File &top_dir, File &save_as)
Reads coordinate projection definitions from a directory structure and saves the consolidated result.
Bounds< 2, fltp08 > convertToWGS84(UUID from_id, const Bounds< 3, fltp08 > &bounds) const
Converts 3D bounds from the specified projection to WGS 84 geographic coordinates.
void createUTMCoordinateProjections()
Creates and registers all standard UTM coordinate projections (zones 1-60, north and south).
static UUID UseBestUTMProjectionID()
Returns a sentinel UUID indicating that the best UTM projection should be auto-selected.
bool hasDownloader() const
Checks whether a downloader function has been configured.
void invalidateConverterCache(UUID projection_id)
Invalidates any cached converter for the specified projection, forcing re-creation on next use.
bool hasProjection(UUID projection_id) const
Checks whether a projection with the given UUID exists in the manager.
const Dictionary< UUID, CoordinateProjection > & projections() const
Returns a const reference to the dictionary of all stored projections.
Buffer< UUID > bestProjectionsLatLon(const Vertex< 2, fltp08 > &lat_lon) const
Returns a ranked list of projections suitable for a given latitude/longitude coordinate.
Bounds< 2, fltp08 > convertToWGS84(UUID from_id, const Bounds< 2, fltp08 > &bounds) const
Converts 2D bounds from the specified projection to WGS 84 geographic coordinates.
Dictionary< String, ConstPointer< Unit > > m_units
Cache of parsed units keyed by their string names.
void setCoordinateFile(File &file)
Sets the file used for reading and writing coordinate projection data.
Dictionary< UUID, CoordinateProjection > m_projections
Dictionary of all registered coordinate projections keyed by UUID.
ConstPointer< UnitOption > wGS84UnitOption()
Returns a UnitOption representing conversion to WGS 84.
void setVerticalDatum(UUID projection_id, const String &authority, uint04 authority_number)
Sets the vertical datum for a given projection.
Vertex< 3, fltp08 > convertFromWGS84(UUID from_id, const Vertex< 3, fltp08 > &location) const
Converts a 3D vertex from WGS 84 to the specified projection.
Dictionary< UUID, CoordinateConverter * > m_wgs_84_converter
Cache of converters from various projections to WGS 84.
Bounds< 2, fltp08 > convertFromWGS84(UUID from_id, const Bounds< 2, Angle< fltp08 > > &bounds) const
Converts 2D angle-based bounds from WGS 84 to the specified projection.
UUID bestUTMProjectionLatLon(const Vertex< 2, fltp08 > &lat_lon) const
Determines the best UTM projection for a given latitude/longitude coordinate.
LineSegment< 2, fltp08 > convertToWGS84(UUID from_id, const LineSegment< 2, fltp08 > &segment) const
Converts a 2D line segment from the specified projection to WGS 84.
CoordinateConverter * wgs84Converter(UUID from_id) const
Retrieves or creates a converter from the specified projection to WGS 84.
UUID bestUTMProjectionMeters(const Vertex< 2, fltp08 > &northing_easting) const
Determines the best UTM projection for a given coordinate in meters.
void writeCoordinateFile(File &file) const
Writes all stored coordinate projections to the specified file.
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.
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.
const CoordinateProjection & get(UUID id) const
Returns the coordinate projection data for the given UUID.
void setDownloader(std::function< void(const StringView &, std::function< void(const StringView &)>)> downloader)
Sets the download function used to retrieve remote projection data.
ConstPointer< Unit > wGS84Unit(UUID from_id)
Returns a unit that converts from the specified projection to WGS 84.
static CoordinateProjectionManager & DefaultInstance()
Returns the singleton default instance of the CoordinateProjectionManager.
File m_coordinate_file
The file used for persistent coordinate projection storage.
Bounds< 2, fltp08 > convertFromWGS84(UUID from_id, const Bounds< 2, fltp08 > &bounds) const
Converts 2D bounds from WGS 84 to the specified projection.
void readCoordinateFile(File &file)
Reads coordinate projection definitions from the specified file.
UUID epsgProjection(uint04 epsg_number) const
Returns the UUID of the projection with the given EPSG number.
void cleanup()
Removes unused or invalid entries and frees associated resources.
static bool HasEngine()
Checks whether a coordinate projection engine (e.g., PROJ) is available.
std::function< void(const StringView &, std::function< void(const StringView &)>)> m_downloader
Callback used to download remote projection definitions.
String createWKTString(UUID id, const UnitManager &manager) const
Creates a Well-Known Text (WKT) string for the specified projection.
static VerticalDatum GetVerticalDatum(uint04 authority_number)
Returns the vertical datum matching the given authority number.
Bounds< 2, fltp08 > convertFromWGS84(UUID from_id, const Bounds< 3, fltp08 > &bounds) const
Converts 3D bounds from WGS 84 to the specified projection.
UUID getProjection(const StringView &name) const
Looks up a projection UUID by its name.
UUID wgs84Projection() const
Returns the UUID of the WGS 84 geographic projection.
Vertex< 3, fltp08 > convertToWGS84(UUID from_id, const Vertex< 3, fltp08 > &location) const
Converts a 3D vertex from the specified projection to WGS 84.
const CoordinateProjection & currentProjection() const
Returns the currently active coordinate projection.
void processWKT(CoordinateProjection &projection, Scanner &scan)
Parses a Well-Known Text (WKT) string and populates the given projection.
void readDirectoryStructure(File &top_dir)
Reads coordinate projection definitions from a directory structure.
void downloadAllProjections()
Downloads definitions for all known projections from the remote source.
void processJSON(CoordinateProjection &projection, JSONNode &json)
Parses a JSON node and populates the given projection.
A program-defined unit that can be used for some specific task different from a program-wide unit.
A hash-based key-value store, useful for quick associative lookups.
Provides a modifiable pointer that has shared ownership of a dynamically allocated object.
Logic for reading or writing to a file as well as navigating filesystems or other common file operati...
JavaScript Object Notation or JSON is an open - standard file format that uses human - readable text ...
A specific unit that can convert between coordinate projections.
static constexpr StringView LatLonUnitName()
Returns the canonical name identifier for the lat/lon unit.
static DynamicPointer< CustomUnit > CustomLatLonUnit()
Creates and returns a custom unit for latitude/longitude coordinates.
A sequence of connected line segments defined by ordered vertices along a path.
Contains methods for easily reading objects in an ascii stream using set deliminators and line logic.
The core String View class for the NDEVR API.
The core String class for the NDEVR API.
Any text displayed to the user should be defined as a TranslatedString which allows the program to lo...
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
Manages a collection of units across multiple data categories with INI persistence.
A definition of how to describe a particular set of data to a custom category of unit.
A point in N-dimensional space, used primarily for spatial location information.
The primary namespace for the NDEVR SDK.
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
double fltp08
Defines an alias representing an 8 byte floating-point number.
Basic data about a particular coordinate projection.
Data about a vertical coordinate reference system (e.g.
TranslatedString name
The display name of the vertical datum.
String authority
The authority defining this vertical datum (e.g., "EPSG").
uint04 authority_number
The authority-assigned code for this vertical datum.