udGeoZone

udGeoZone.h provides support for transforming geodetic and cartesian coordinates

Defines

udGeoZone_SetFromWKT

Enums

enum udGeoZoneEllipsoid

Supported udGeoZone ellipsoids

Values:

ValueDescription
udGZE_WGS84EPSG:7030.
udGZE_Airy1830EPSG:7001.
udGZE_AiryModifiedEPSG:7002.
udGZE_Bessel1841EPSG:7004.
udGZE_BesselModifiedEPSG:7005.
udGZE_Clarke1866EPSG:7008.
udGZE_Clarke1880IGNEPSG:7011.
udGZE_GRS80EPSG:7019.
udGZE_Intl1924EPSG:7022 (Same numbers as Hayford).
udGZE_WGS72EPSG:7043.
udGZE_CGCS2000EPSG:1024.
udGZE_Clarke1858EPSG:7007.
udGZE_Clarke1880FOOTEPSG:7055.
udGZE_Krassowsky1940EPSG:7024.
udGZE_Everest1930MEPSG:7018.
udGZE_Mars
udGZE_Moon
udGZE_IAG1975
udGZE_Everest1830
udGZE_GRS67
udGZE_ANSEPSG:7003.
udGZE_INSEPSG:7021.
udGZE_Count

enum udGeoZoneGeodeticDatum

Supported udGeoZone geodetic datums

Values:

ValueDescription
udGZGD_WGS84EPSG:4326.
udGZGD_ED50EPSG:4230.
udGZGD_ETRS89EPSG:4258,4936.
udGZGD_TM75EPSG:4300.
udGZGD_NAD27EPSG:4267.
udGZGD_NAD27CGQ77EPSG:4609.
udGZGD_NAD83EPSG:4269.
udGZGD_NAD83_1996EPSG:6307.
udGZGD_NAD83_CSRSEPSG:2955.
udGZGD_NAD83_NSRS2007EPSG:3465.
udGZGD_NAD83_2011EPSG:6318.
udGZGD_NTFEPSG:4275.
udGZGD_OSGB36EPSG:4277.
udGZGD_PotsdamEPSG:4746.
udGZGD_TokyoEPSG:7414.
udGZGD_WGS72EPSG:4322.
udGZGD_JGD2000EPSG:4612.
udGZGD_JGD2011EPSG:6668.
udGZGD_GDA94EPSG:4283.
udGZGD_GDA2020EPSG:7844.
udGZGD_RGF93EPSG:4171.
udGZGD_NAD83_HARNEPSG:4152.
udGZGD_CGCS2000EPSG:4490.
udGZGD_HK1980EPSG:4611.
udGZGD_SVY21EPSG:4757.
udGZGD_MGIEPSG:6312.
udGZGD_NZGD2000EPSG:2193.
udGZGD_AMERSFOORTEPSG:28992.
udGZGD_TRI1903EPSG:30200.
udGZGD_VANUA1915EPSG:3139.
udGZGD_DEALUL1970EPSG:31700.
udGZGD_SINGGRIDEPSG:19920.
udGZGD_MARS_MERCEPSG:49974,49975.
udGZGD_MARS_PCPFEPSG:8705.
udGZGD_MOON_MERCEPSG:30174,30175.
udGZGD_MOON_PCPFEPSG:30100,30100.
udGZGD_DBREFEPSG:5681.
udGZGD_DHDNEPSG:4314.
udGZGD_SJTSK03EPSG:8353.
udGZGD_PULK1942EPSG:4284.
udGZGD_PULK194258EPSG:4179.
udGZGD_PULK194283EPSG:4178.
udGZGD_PULK1995EPSG:20004.
udGZGD_WGS_72BEEPSG:32401.
udGZGD_BEIJING1954EPSG:21413.
udGZGD_NEWBEIJINGEPSG:4555.
udGZGD_XIAN1980EPSG:4610.
udGZGD_TIMB1948EPSG:28973.
udGZGD_NZGD49EPSG:4272.
udGZGD_SWEREF99EPSG:4619.
udGZGD_SAD69EPSG:4291.
udGZGD_GR96EPSG:4747.
udGZGD_DGN95EPSG:4755.
udGZGD_UCS2000EPSG:5561.
udGZGD_H94EPSG:4148.
udGZGD_ID74EPSG:4238.
udGZGD_NGO1948EPSG:4273.
udGZGD_RGF93v2bEPSG:9782.
udGZGD_Count

enum udGeoZoneProjectionType

Supported udGeoZone projection types

Values:

ValueDescription
udGZPT_Unknown
udGZPT_ECEF
udGZPT_LongLat
udGZPT_LatLong
udGZPT_TransverseMercator
udGZPT_LambertConformalConic2SP
udGZPT_WebMercator
udGZPT_CassiniSoldner
udGZPT_CassiniSoldnerHyperbolic
udGZPT_SterographicObliqueNEquatorial
udGZPT_SterographicPolar_vB
udGZPT_Mercator
udGZPT_Krovak
udGZPT_KrovakNorthOrientated
udGZPT_HotineObliqueMercatorvA
udGZPT_HotineObliqueMercatorvB
udGZPT_AlbersEqualArea
udGZPT_EquidistantCylindrical
udGZPT_Count

Functions

enum udError udGeoZone_LoadZonesFromJSON(const char *pJSONStr, int *pLoaded, int *pFailed)

Loads a set of zones from a JSON file where each member is defined as “AUTHORITY:SRID” (eg. “EPSG:32756”)

ParameterDescription
pJSONStrA JSON-formatted string containing all the zones
pLoadedPointer to an integer that has the count of zones successfully loaded
pFailedPointer to an integer that has the count of zones unsuccessfully loaded

Returns: A udError code

enum udError udGeoZone_UnloadZones()

Unloads all loaded zones (only needs to be called once to unload all)

  • Returns: A udError code, typically udE_Success

enum udError udGeoZone_FindSRID(int32_t *pSRIDCode, const udDouble3 *pLatLong, enum udGeoZoneGeodeticDatum datum)

Find an appropriate SRID code for a given lat/long within UTM/WGS84 (for example using datum udGZGD_WGS84)

ParameterDescription
pSRIDCodeA pointer to which the SRID code is written upon success
pLatLongA pointer to a udDouble3 where x is the latitude, y is the longitude (z is ignored)
datumThe geodetic datum (normally udGZGD_WGS84)

Returns: A udError code

enum udError udGeoZone_SetFromSRID(struct udGeoZone *pZone, int32_t sridCode)

Set the zone structure parameters from a given srid code

ParameterDescription
pZoneA udGeoZone structure that will be overwritten with parameters for the given sridCode
sridCodeThe sridCode for the desired zone

Returns: A udError code

enum udError udGeoZone_SetFromWellKnownText(struct udGeoZone *pZone, const char *pWKT)

Initialise a geozone structure from well known text

ParameterDescription
pZoneA udGeoZone structure that will be overwritten with parameters taken from the supplied Well Known Text
pWKTA Well Known Text formatted string

Returns: A udError code

enum udError udGeoZone_GetWellKnownText(const char **ppWKT, const struct udGeoZone *pZone)

Get the Well Known Text for a zone

!NOTE The Well Known Text must be freed using udGeoZone_FreeWellKnownText

ParameterDescription
ppWKTA pointer to a string pointer that will be assigned with an allocated WKT string for the given zone
pZoneA valid udGeoZone structure used to generate the Well Known Text

Returns: A udError code

void udGeoZone_FreeWellKnownText(const char **ppWKT)

Free the Well Known Text returned by udGeoZone_GetWellKnownText

ParameterDescription
ppWKTA pointer to a string pointer that was returned by udGeoZone_GetWellKnownText

enum udError udGeoZone_LatLongToCartesian(udDouble3 *pCartesian, const struct udGeoZone *pZone, const udDouble3 *pLatLong, enum udGeoZoneGeodeticDatum datum)

Convert a point from lat/long to the cartesian coordinate system defined by the zone

ParameterDescription
pCartesianA pointer to a udDouble3 overwritten with the cartesian value of the transformed LatLong
pZoneA valid udGeoZone defining the coordinate system
pLatLongA pointer to a udDouble3 containing the Latitude in x, Longitude in y, and altitude in Z
datumThe geodetic datum for the latlong coordinates, typically udGZGD_WGS84

Returns: A udError code

enum udError udGeoZone_CartesianToLatLong(udDouble3 *pLatLong, const struct udGeoZone *pZone, const udDouble3 *pPosition, enum udGeoZoneGeodeticDatum datum)

Convert a point from the cartesian coordinate system defined by the zone to lat/long

ParameterDescription
pLatLongA pointer to a udDouble3 overwritten with the transformed Latitude in x, Longitude in y, and altitude in Z
pZoneA valid udGeoZone defining the coordinate system
pCartesianA pointer to a udDouble3 containing the cartesian coordinates
datumThe geodetic datum for the latlong coordinates, typically udGZGD_WGS84

Returns: A udError code

enum udError udGeoZone_LatLongToGeocentric(udDouble3 *pGeocentric, const udDouble3 *pLatLong, const struct udGeoZoneEllipsoidInfo *pEllipsoid)

Conversion to and from Geocentric

ParameterDescription
pGeocentricA pointer to a udDouble3 overwritten with the transformed geocentric coordinates
pLatLongA pointer to a udDouble3 containing the Latitude in x, Longitude in y, and altitude in Z
pEllipsoidThe ellipsoid parameters as specified in the datum

Returns: A udError code

enum udError udGeoZone_GeocentricToLatLong(udDouble3 *pLatLong, const udDouble3 *pGeoCentric, const struct udGeoZoneEllipsoidInfo *pEllipsoid)

Conversion to and from Geocentric

ParameterDescription
pLatLongA pointer to a udDouble3 with the Latitude in x, Longitude in y, and altitude in Z
pGeocentricA pointer to a udDouble3 containing the geocentric coordinates
pEllipsoidThe ellipsoid parameters as specified in the datum

Returns: A udError code

enum udError udGeoZone_ConvertDatum(udDouble3 *pOutLatLong, const udDouble3 *pInLatLong, enum udGeoZoneGeodeticDatum currentDatum, enum udGeoZoneGeodeticDatum newDatum)

Convert a lat/long pair in one datum to another datum

ParameterDescription
pOutLatLongA pointer to a udDouble3 with the output Latitude in x, Longitude in y, and altitude in Z
pInLatLongA pointer to a udDouble3 with the input Latitude in x, Longitude in y, and altitude in Z
currentDatumThe datum that the pInLatLong references
newDatumThe datum that the pOutLatLong references

Returns: A udError code

enum udError udGeoZone_TransformPoint(udDouble3 *pTransformed, const udDouble3 *pPoint, const struct udGeoZone *pSourceZone, const struct udGeoZone *pDestZone)

Transform a point from one zone to another

ParameterDescription
pTransformedA pointer to a udDouble3 with the output transformed coordinates, which may be cartesian or latlong depending on the destination zone
pPointA pointer to a udDouble3 with the input coordinates, which may be cartesian or latlong depending on the source zone
pSourceZoneThe zone that pPoint references
pDestZoneThe zone the point is transformed to, which pTransformed references

Returns: A udError code

enum udError udGeoZone_TransformMatrix(udDouble4x4 *pTransformed, const udDouble4x4 *pMatrix, const struct udGeoZone *pSourceZone, const struct udGeoZone *pDestZone)

Transform a matrix from one zone to another

ParameterDescription
pTransformedA pointer to a matrix that has been transformed to the destination zone
pMatrixA pointer to a matrix that is in the source zone coordinate system
pSourceZoneThe zone that pMatrix references
pDestZoneThe zone that pTransformed references

Returns: A udError code

enum udError udGeoZone_UpdateSphereoidInfo(struct udGeoZone *pZone)

Complete setup of a udGeoZone

!NOTE This is called after changing parameters of the zone

ParameterDescription
pZoneThe zone to complete the setup of

Returns: A udError code

Structs

struct udGeoZone

udGeoZone structure. Do not rely on element order as they may change in a future release.

FieldTypeDescription
datumenum udGeoZoneGeodeticDatum
projectionenum udGeoZoneProjectionType
latLongBoundMinudDouble2
latLongBoundMaxudDouble2
meridiandouble
paralleldoubleParallel of origin for Transverse Mercator.
latProjCentredoubleLatitude of Projection Centre for Krovak Projection.
coLatConeAxisdoubleCo Latitude of the cone axis for Krovak Projection.
flatteningdouble
semiMajorAxisdouble
semiMinorAxisdouble
thirdFlatteningdouble
eccentricitydouble
eccentricitySqdouble
radiusdouble
scaleFactordouble
n[10]double
alpha[9]double
beta[9]double
firstParalleldouble
secondParalleldouble
falseNorthingdouble
falseEastingdouble
unitMetreScaledouble1.0 for metres, 0.3048006096012192 for feet
zoneint32_t
sridint32_t
datumShortName[16]char
datumName[64]char
zoneName[64]charFull name for zone, only 33 characters required for longest known name “Japan Plane Rectangular CS XVIII”.
displayName[128]charThis is the human readable name; often just datumShortName & zoneName concatenated.
knownDatumcharboolean
datumSridint32_t
toWGS84charboolean
axisInfocharboolean
zoneSpheroidenum udGeoZoneEllipsoid
paramsHelmert7[7]doubleTO-WGS84 as { Tx, Ty, Tz, Rx, Ry, Rz, DS }.

struct udGeoZoneGeodeticDatumDescriptor

Geodetic Datum descriptor, stored globally as g_udGZ_GeodeticDatumDescriptors

FieldTypeDescription
pFullNameconst char \*
pShortNameconst char \*
pDatumNameconst char \*
ellipsoidenum udGeoZoneEllipsoid
paramsHelmert7[7]doubleTO-WGS84 as { Tx, Ty, Tz, Rx, Ry, Rz, DS }.
epsgint32_tepsg code for the datum
authorityint32_tauthority for this datum
exportAxisInfochar
exportToWGS84char

struct udGeoZoneEllipsoidInfo

Ellipsoid info

FieldTypeDescription
pNameconst char \*
semiMajorAxisdouble
flatteningdouble
authorityEpsgint32_t