Geometry Class

  • Geometry
  • class Esri::ArcGISRuntime::Geometry

    Base class for classes that represent geometric shapes. More...

    Public Functions

    Geometry(const Esri::ArcGISRuntime::Geometry &other)
    Geometry(Esri::ArcGISRuntime::Geometry &&other)
    virtual ~Geometry() override
    Esri::ArcGISRuntime::GeometryDimension dimension() const
    bool equalsWithTolerance(const Esri::ArcGISRuntime::Geometry &other, double tolerance) const
    Esri::ArcGISRuntime::Envelope extent() const
    Esri::ArcGISRuntime::GeometryType geometryType() const
    bool hasCurves() const
    bool hasM() const
    bool hasZ() const
    bool isEmpty() const
    Esri::ArcGISRuntime::SpatialReference spatialReference() const
    bool operator!=(const Esri::ArcGISRuntime::Geometry &other) const
    Esri::ArcGISRuntime::Geometry &operator=(const Esri::ArcGISRuntime::Geometry &other)
    Esri::ArcGISRuntime::Geometry &operator=(Esri::ArcGISRuntime::Geometry &&other)
    bool operator==(const Esri::ArcGISRuntime::Geometry &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::Geometry fromJson(const QString &json)

    Detailed Description

    Geometry is the base class for two-dimensional (x,y) or three-dimensional (x,y,z) geometries. Objects that inherit from the Geometry class may also include a measure (m-value) for each vertex. The Geometry class provides functionality common to all types of geometry. Point, Multipoint, Polyline, Polygon, and Envelope all inherit from Geometry and represent different types of shapes.

    Geometry represents real-world objects by defining a shape at a specific geographic location. It is used throughout this API to represent the shapes of features and graphics, layer extents, viewpoints, and GPS locations. It is also used, for example, to define inputs and outputs for spatial analysis and geoprocessing operations and to measure distances and areas.

    All types of geometry:

    • Have a SpatialReference indicating the coordinate system used by its coordinates
    • Can be empty, indicating that they have no specific location or shape
    • May have z-values and/or m-values to define elevation and measures respectively
    • Can be converted to and from JSON to be persisted or to be exchanged directly with REST services


    Most geometries are created and not changed for their lifetime. Examples include features created to be stored in a geodatabase or read from a non-editable layer, and features returned from tasks such as a spatial query, geocode operation, network trace, or geoprocessing task. Immutable geometries (geometries that cannot be changed) offer some important benefits to your app. They are inherently thread-safe, help prevent inadvertent changes, and allow for certain performance optimizations.

    Instead of changing the properties of existing geometries, you can create and update geometries using the various subclasses of GeometryBuilder (for example, PolygonBuilder), which can represent the state of a geometry under construction while allowing modifications, thus enabling editing workflows.

    Additionally, GeometryEngine offers a range of topological and spatial transformations that read the content of existing geometries and create new geometries, for example, project, buffer, union, and so on. Relational tests such as intersects and overlaps are also available on GeometryEngine.

    Coordinate units

    The coordinates that define a geometry are only meaningful in the context of the geometry's SpatialReference. The vertices and spatial reference together allow your app to translate a real-world object from its location on the Earth to its location on your map or scene.

    In some cases, a geometry's spatial reference may not be set. For example, a Graphic that does not have a spatial reference is drawn using the same spatial reference as the MapView to which it was added. If the coordinates are in a different spatial reference, the graphics may not display in the correct location, or at all.

    When using GeometryBuilder to create a Polyline or Polygon from a collection of Point, you don't need to set the spatial reference of every point before you add it to the builder, as it is assigned the spatial reference of the builder itself. In most other cases, such as when using a geometry in geometry operations or when editing a feature table, spatialReference must be set.

    Spatial reference and projection

    Changing the coordinates of a geometry to have the same shape and location represented using a different SpatialReference is known as "projection" or sometimes as "reprojection". Because geometries are immutable, they do not have any member methods that project, transform, or otherwise modify their content.

    See also GeometryEngine, GeometryBuilder, and GeometryEditor.

    Member Function Documentation


    Default constructor. Creates an empty Geometry.

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

    Copy constructor from other Geometry.

    Geometry::Geometry(Esri::ArcGISRuntime::Geometry &&other)

    Move constructor from other Geometry.

    [override virtual] Geometry::~Geometry()


    Esri::ArcGISRuntime::GeometryDimension Geometry::dimension() const

    Returns the number of dimensions for the geometry.

    Every non-empty Geometry has an inherent dimension (sometimes called the topological dimensionality) that indicates the general class of the Geometry.

    Returns GeometryDimension::Unknown if an error occurs.

    bool Geometry::equalsWithTolerance(const Esri::ArcGISRuntime::Geometry &other, double tolerance) const

    Returns whether this object and other are equal within the tolerance.

    Esri::ArcGISRuntime::Envelope Geometry::extent() const

    Returns the smallest rectangular bounding-box that covers the geometry.

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

    Creates this geometry from an ArcGIS json geometry representation.

    Returns a Geometry created using the data in the json parameter.

    Geometry can be serialized and de-serialized to and from JSON. The ArcGIS REST API documentation describes the JSON representation of geometry objects. You can use this encoding and decoding mechanism to exchange geometries with REST Web services or to store them in text files.

    Esri::ArcGISRuntime::GeometryType Geometry::geometryType() const

    Gets the geometry type.

    Returns the geometry type enumeration.

    bool Geometry::hasCurves() const

    Returns true if this geometry contains curve segments; false otherwise.

    ArcGIS software supports polygon and polyline geometries that contain curve segments (where Segment::isCurve is true, sometimes known as true curves or nonlinear segments). Curves may be present in certain types of data - for example Mobile Map Packages (MMPK) or geometry JSON. When connecting to ArcGIS feature services that support true curves, this API retrieves densified versions of curve feature geometries by default.

    If a polygon or polyline geometry contains curve segments, this property returns true. Prior to Esri::ArcGISRuntime 100.12, it was not possible to access curve segments, and only LineSegment instances would be returned when iterating through the segments in a Polygon or Polyline object, regardless of this property.

    From Esri::ArcGISRuntime 100.12, you can use curve segments when using a MultipartBuilder to create or edit polygon and polyline geometries, and also get curve segments when iterating through the segments of existing Multipart geometries when this property returns true.

    You can also choose to return true curves from feature services by using ArcGISRuntimeEnvironment::serviceCurveGeometryMode.

    bool Geometry::hasM() const

    Returns true if this geometry contains m-values (measure values).

    bool Geometry::hasZ() const

    Returns true if this geometry contains z-coordinate values.

    Only 3D geometries contain z-coordinate values.

    bool Geometry::isEmpty() const

    Gets whether this Geometry is empty.

    A Geometry is empty if it does not contain any valid geographic coordinates. If a SpatialReference was specified, but still no valid coordinates exist, then the Geometry is still empty.

    Returns true if empty.

    Esri::ArcGISRuntime::SpatialReference Geometry::spatialReference() const

    Gets the SpatialReference of the Geometry.

    Returns the spatial reference of the coordinates assigned to the Geometry.

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

    Reimplements: JsonSerializable::toJson() const.

    Converts a geometry into an ArcGIS json geometry representation.

    Returns this Geometry represented as a JSON String.

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

    Reimplements: JsonSerializable::unknownJson() const.

    Gets the unknown JSON of this object.

    See also JsonSerializable.

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

    Reimplements: JsonSerializable::unsupportedJson() const.

    Gets the unsupported JSON of this object.

    See also JsonSerializable.

    [since Esri::ArcGISRuntime 200.2] bool Geometry::operator!=(const Esri::ArcGISRuntime::Geometry &other) const

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

    This function was introduced in Esri::ArcGISRuntime 200.2.

    See also Geometry::operator==.

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

    Assignment operator from other Geometry.

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

    Move operator from other Geometry.

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

    Equivalency operator.

    Returns whether this object and other are equivalent.

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