Skip To Content ArcGIS for Developers Sign In Dashboard

Geometry Class

(Esri::ArcGISRuntime::Geometry)

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

Header: #include <Geometry>
Since: Esri::ArcGISRuntime 100.0
Inherits: JsonSerializable
Inherited By:

Esri::ArcGISRuntime::Envelope, Esri::ArcGISRuntime::Multipart, Esri::ArcGISRuntime::Multipoint, and Esri::ArcGISRuntime::Point

Public Functions

Geometry()
Geometry(const Geometry &other)
Geometry(Geometry &&other)
~Geometry()
int dimension() const
bool equalsWithTolerance(const Geometry &other, double tolerance) const
Envelope extent() const
GeometryType geometryType() const
bool hasCurves() const
bool hasM() const
bool hasZ() const
bool isEmpty() const
SpatialReference spatialReference() const
Geometry &operator=(const Geometry &other)
Geometry &operator=(Geometry &&other)
bool operator==(const Geometry &other) const

Reimplemented Public Functions

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

Static Public Members

Geometry fromJson(const QString &json)

Detailed Description

Base class for classes that represent geometric shapes.

This class is the base class for two-dimensional (x,y) or three-dimensional (x,y,z) geometries such as Point and Polyline objects. Objects that inherit from the Geometry class may also include an m (measure) value for each vertex.

Geometries are used throughout the API, for example to define the shape of a feature or graphic, the extent of a layer, or as inputs and outputs of different types of task.

Geometries are immutable. Instead of changing the properties of existing geometries, create new instances, or use a corresponding GeometryBuilder. GeometryEngine offers a range of topological and relational operations and spatial transformations that create new geometries, for example project, move, scale, rotate, buffer, union, and so on.

Coordinate units

Geometries describe geographic objects using the specific coordinate system provided as its SpatialReference. The SpatialReference may be null. Graphics that have geometries with null SpatialReference will be treated as if they have the same SpatialReference as the containing MapView; if the coordinates are in a different SpatialReference, the graphics may not display in the correct location, or at all.

Dimension

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

  • 0 - points and multipoints
  • 1 - lines and polylines
  • 2 - polygons and envelopes
  • 3 - objects with volume

Serializing to JSON

Geometries 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.

Valid polygons have at least three vertices, and valid polylines, two vertices. When there are not enough of them, JSON serialization copies existing vertices to reach the minimum vertex count. This results in invalid (degenerate) geometries that can be parsed as the valid JSON for those geometry types.

See also GeometryBuilder and GeometryEngine.

Member Function Documentation

Geometry::Geometry()

Default constructor. Creates an empty Geometry.

Geometry::Geometry(const Geometry &other)

Copy constructor from other Geometry.

Geometry::Geometry(Geometry &&other)

Move constructor from other Geometry.

Geometry::~Geometry()

Destructor.

int Geometry::dimension() const

Returns the topological dimensionality.

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

  • 0 - points and multipoints
  • 1 - lines and polylines
  • 2 - polygons and envelopes
  • 3 - objects with volume

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

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

Envelope Geometry::extent() const

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

[static] 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.

GeometryType Geometry::geometryType() const

Gets the geometry type.

Returns the geometry type enumeration.

bool Geometry::hasCurves() const

Returns true if this geometry has curves.

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.

SpatialReference Geometry::spatialReference() const

Gets the SpatialReference of the Geometry.

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

[virtual] QString Geometry::toJson() const

Reimplemented from JsonSerializable::toJson().

Converts a geometry into an ArcGIS json geometry representation.

Returns this Geometry represented as a JSON String.

[virtual] QJsonObject Geometry::unknownJson() const

Reimplemented from JsonSerializable::unknownJson().

Gets the unknown JSON of this object.

See also JsonSerializable.

[virtual] QJsonObject Geometry::unsupportedJson() const

Reimplemented from JsonSerializable::unsupportedJson().

Gets the unsupported JSON of this object.

See also JsonSerializable.

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

Assignment operator from other Geometry.

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

Move operator from other Geometry.

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

Equivalency operator.

Returns whether this object and other are equivalent.


Feedback on this topic?