SpatialReference Class

  • SpatialReference
  • class Esri::ArcGISRuntime::SpatialReference

    A spatial reference that defines how coordinates correspond to locations in the real world. More...

    Header: #include <SpatialReference.h>
    Since: Esri::ArcGISRuntime 100.0
    Inherits: Esri::ArcGISRuntime::JsonSerializable

    Public Functions

    SpatialReference()
    SpatialReference(const QString &wkText)
    SpatialReference(int wkid)
    SpatialReference(int wkid, int verticalWkid)
    SpatialReference(const Esri::ArcGISRuntime::SpatialReference &other)
    SpatialReference(Esri::ArcGISRuntime::SpatialReference &&other)
    virtual ~SpatialReference() override
    Esri::ArcGISRuntime::SpatialReference baseGeographic() const
    double convergenceAngle(const Esri::ArcGISRuntime::Point &point) const
    bool hasVertical() const
    bool isEmpty() const
    bool isGeographic() const
    bool isPannable() const
    bool isProjected() const
    Esri::ArcGISRuntime::Unit unit() const
    Esri::ArcGISRuntime::LinearUnit verticalUnit() const
    int verticalWkid() const
    QString wkText() const
    int wkid() const
    bool operator!=(const Esri::ArcGISRuntime::SpatialReference &other) const
    Esri::ArcGISRuntime::SpatialReference &operator=(const Esri::ArcGISRuntime::SpatialReference &other)
    Esri::ArcGISRuntime::SpatialReference &operator=(Esri::ArcGISRuntime::SpatialReference &&other)
    bool operator==(const Esri::ArcGISRuntime::SpatialReference &other) const

    Reimplemented Public Functions

    virtual QString toJson() const override
    virtual QJsonObject unknownJson() const override
    virtual QJsonObject unsupportedJson() const override

    Static Public Members

    Esri::ArcGISRuntime::SpatialReference fromJson(const QString &json)
    Esri::ArcGISRuntime::SpatialReference webMercator()
    Esri::ArcGISRuntime::SpatialReference wgs84()

    Detailed Description

    Instances of this class represent a specific coordinate system, identified by a well-known ID (WKID) number or well-known text (WKT) string. SpatialReferences are immutable.

    SpatialReferences allow disparate spatial data to be consistently viewed and analyzed together. Geometry, Layer, and GraphicsOverlay classes have a SpatialReference that determines the system in which the data is stored, and the SpatialReference of each GeoView determines how it displays the data it contains. There are two main categories of coordinate system that can be represented by a SpatialReference:

    • Geographic coordinate systems use a three-dimensional spherical surface to define locations on the earth. Coordinates are defined using angular units such as degrees.
    • Projected coordinate systems use flat, two-dimensional surface to define locations on the earth. Coordinates are defined using linear units such as meters or miles.

    In some cases, more than one WKID value can refer to the same spatial reference. For example, 3857 and 102100 both refer to WGS 1984 Web Mercator (Auxiliary Sphere). There can also be subtle differences between two WKT strings that represent the same spatial reference. To mitigate this situation, the SpatialReference class provides spatial reference comparison methods.

    Use the Create method to create a SpatialReference by specifying the WKID of a coordinate system, or use the members of SpatialReferences to return instances of the most commonly used SpatialReferences.

    SpatialReference ensures that you can accurately view, query, and analyze the layers of a GeoModel.

    The spatial reference value is available from a map or scene after loading has completed, and is immutable. If you want to set this value for a new map or scene, use the Map constructor with the spatialReference parameter or the Scene constructor with the sceneViewTilingScheme parameter.

    See Projected Coordinate Systems and Geographic Coordinate Systems for the list of supported spatial references and their corresponding definition strings.

    See https://developers.arcgis.com/documentation/spatial-references/ for more information about spatial references.

    Member Function Documentation

    SpatialReference::SpatialReference()

    Default constructor. Constructs an empty SpatialReference object.

    The WKID and vertical WKID are set to -1 and the WKT is set to an empty string.

    [explicit] SpatialReference::SpatialReference(const QString &wkText)

    Constructor using a wkText (well-known text string) that represents the spatial reference.

    The wkid property is also initialized based on the provided wkText. You can use a wkText extracted from another SpatialReference. If the wkText parameter is a null or empty string, this method creates an empty SpatialReference.

    [explicit] SpatialReference::SpatialReference(int wkid)

    Constructor using a wkid (well-known ID) that represents the spatial reference.

    Tolerance is set to 0.0.

    SpatialReference::SpatialReference(int wkid, int verticalWkid)

    Constructor using a wkid (well-known ID) that represents the spatial reference and a verticalWkid (vertical coordinate system well-known ID).

    SpatialReference::SpatialReference(const Esri::ArcGISRuntime::SpatialReference &other)

    Copy constructor from other SpatialReference.

    SpatialReference::SpatialReference(Esri::ArcGISRuntime::SpatialReference &&other)

    Move constructor from other SpatialReference.

    [override virtual] SpatialReference::~SpatialReference()

    Destructor.

    Esri::ArcGISRuntime::SpatialReference SpatialReference::baseGeographic() const

    Returns the base geographic coordinate system if this is a projected coordinate system.

    [since Esri::ArcGISRuntime 100.3] double SpatialReference::convergenceAngle(const Esri::ArcGISRuntime::Point &point) const

    Returns the grid convergence in degrees for a spatial reference at a given point.

    The grid convergence is the angle between True North and Grid North at a point on a map. The grid convergence can be used to convert a horizontal direction expressed as an azimuth in a geographic coordinate system (relative to True North) to a direction expressed as a bearing in a projected coordinate system (relative to Grid North), and vice versa.

    Sign convention

    The grid convergence returned by this method is positive when Grid North lies east of True North. The following formula demonstrates how to obtain a bearing (b) from an azimuth (a) using the grid convergence (c) returned by this method:

    b = a - c

    This sign convention is sometimes named the Gauss-Bomford convention.

    Other notes

    • Returns 0 if the spatial reference is a geographic coordinate system.
    • Returns NAN if the point is outside the projection's horizon or on error.
    • If the point has no spatial reference, it is assumed to be in the given spatial reference.
    • If the point's spatial reference differs from the spatial reference given, its location is transformed automatically to the given spatial reference.

    This function was introduced in Esri::ArcGISRuntime 100.3.

    [static] Esri::ArcGISRuntime::SpatialReference SpatialReference::fromJson(const QString &json)

    Creates a new SpatialReference from an ArcGIS JSON representation.

    • json - The JSON text.

    [since Esri::ArcGISRuntime 100.9] bool SpatialReference::hasVertical() const

    Returns true if spatial reference has a vertical coordinate system set; false otherwise.

    A spatial reference can optionally include a definition for a vertical coordinate system (VCS), which can be used to interpret the z-values of a geometry. A VCS defines linear units of measure, the origin of z-values, and whether z-values are "positive up" (representing heights above a surface) or "positive down" (indicating that values are depths below a surface).

    A SpatialReference may have a VCS set, for example by calling the SpatialReference::SpatialReference(int, int) constructor. SpatialReference::verticalWkid, SpatialReference::wkText, and SpatialReference::verticalUnit provide more information about the specific VCS set on this instance.

    VCSs are used when projecting geometries using a HorizontalVerticalTransformation.

    This function was introduced in Esri::ArcGISRuntime 100.9.

    See also SpatialReference::verticalWkid and SpatialReference::verticalUnit.

    bool SpatialReference::isEmpty() const

    Returns true if this SpatialReference is empty.

    bool SpatialReference::isGeographic() const

    Returns true if this is a geographic coordinate system.

    bool SpatialReference::isPannable() const

    Returns true if this SpatialReference supports wrap around.

    bool SpatialReference::isProjected() const

    Returns true if this SpatialReference is a projected coordinate system.

    [override virtual] QString SpatialReference::toJson() const

    Reimplements: JsonSerializable::toJson() const.

    Returns this SpatialReference as an ArcGIS json SpatialReference representation.

    Esri::ArcGISRuntime::Unit SpatialReference::unit() const

    The unit of measure for the horizontal coordinate system of this spatial reference.

    Returns a null Unit if the spatial reference is invalid.

    [override virtual] QJsonObject SpatialReference::unknownJson() const

    Reimplements: JsonSerializable::unknownJson() const.

    Gets the unknown JSON of this object.

    See also JsonSerializable.

    [override virtual] QJsonObject SpatialReference::unsupportedJson() const

    Reimplements: JsonSerializable::unsupportedJson() const.

    Gets the unsupported JSON of this object.

    See also JsonSerializable.

    [since Esri::ArcGISRuntime 100.14] Esri::ArcGISRuntime::LinearUnit SpatialReference::verticalUnit() const

    Returns the unit of measure for the vertical coordinate system of this spatial reference. Will return an empty unit if hasVertical is false.

    This function was introduced in Esri::ArcGISRuntime 100.14.

    int SpatialReference::verticalWkid() const

    Returns the vertical coordinate system well-known spatial reference identifier (WKID).

    The well-known ID for the vertical coordinate system (VCS), or 0 if the spatial reference has no VCS or has a custom VCS.

    Note: In versions prior to Esri::ArcGISRuntime 100.9. This method returned -1 if no vertical WKID had been specified.

    [static] Esri::ArcGISRuntime::SpatialReference SpatialReference::webMercator()

    Returns a spatial reference representing the WebMercator coordinate system (WKID:102100)

    [static] Esri::ArcGISRuntime::SpatialReference SpatialReference::wgs84()

    Returns a spatial reference representing the WGS84 coordinate system (WKID:4326).

    QString SpatialReference::wkText() const

    Returns the well-known text representation.

    Returns the well-known text for the horizontal and vertical coordinate system. Returns an empty string if no WKT has been specified or if the SpatialReference is invalid.

    This method always returns the minimal text representation that uniquely identifies a given SpatialReference.

    int SpatialReference::wkid() const

    Returns the well-known spatial reference identifier (WKID).

    The well-known ID for the horizontal coordinate system, or 0 if the spatial reference has a custom horizontal coordinate system. Returns 0 if no WKID has been specified.

    Note: In versions prior to Esri::ArcGISRuntime 100.9. This method returned -1 if no WKID had been specified.

    bool SpatialReference::operator!=(const Esri::ArcGISRuntime::SpatialReference &other) const

    Inequality operator. Returns true if this object and other are not equal.

    See also SpatialReference::operator==.

    Esri::ArcGISRuntime::SpatialReference &SpatialReference::operator=(const Esri::ArcGISRuntime::SpatialReference &other)

    Assignment operator from other SpatialReference.

    Esri::ArcGISRuntime::SpatialReference &SpatialReference::operator=(Esri::ArcGISRuntime::SpatialReference &&other)

    Move operator from other SpatialReference.

    bool SpatialReference::operator==(const Esri::ArcGISRuntime::SpatialReference &other) const

    Equivalency operator. Returns true if this object and other are equal.

    This is the only valid way to compare two spatial references. Comparing individual attributes for two objects can return misleading results and should be avoided.

    Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.