Geometry class final

Base class for all classes that represent geometric shapes.

Geometry is the base class for two-dimensional (x,y) and three-dimensional (x,y,z) geometries, such as ArcGISPoint, Multipoint, Polyline, Polygon, and Envelope. It represents real-world objects by defining a shape at a specific geographic location, and is used throughout the API to represent the shapes of features and graphics, layer extents, viewpoints, and GPS locations. It is also used to define the inputs and outputs for spatial analysis and geoprocessing operations, and to measure distances and areas.

All types of geometry have the following characteristics:

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

Immutability

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 important benefits to your app. They are inherently thread-safe, help prevent inadvertent changes, and allow for certain performance optimizations.

If you want to modify the shape of a Geometry there are two options available:

  • GeometryBuilder. Use a geometry builder if you want to incrementally reshape a geometry. If you want to reshape a Polygon, for example, then pass the polygon to a PolygonBuilder. The polygon builder copies the polygon and provides methods to add, update, and delete the polygon parts and segment vertices. The geometry builder represents the state of a geometry under modification, and you can obtain it at any time using GeometryBuilder.toGeometry.
  • GeometryEditor. Use a geometry editor if you want to allow the user to interactively modify an existing geometry. Start the GeometryEditor by passing the geometry to GeometryEditor.start(Geometry). The start method signals to the geometry editor to start capturing user interaction with the map through mouse or touch gestures.

Note that the GeometryEngine offers a range of topological and spatial transformations that can create a new geometry from an existing geometry. The GeometryEngine allows you to perform actions on an existing geometry, such as a buffer, cut, clip, densify, or project, to produce a new output geometry. See GeometryEngine to explore various supported geometric operations.

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 GeoViewController 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 ArcGISPoint, 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, Geometry.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.

Implemented types
Mixed in types
Implementers

Constructors

Geometry.fromJson(Map<String, dynamic> json)
factory
Geometry.fromJsonString(String jsonString)
factory

Properties

dimension GeometryDimension
Indicates the dimensionality of a Geometry, relating to the number of spatial dimensions in which the geometry may have a size.
no setter
extent Envelope
The minimum enclosing bounding-box (or Envelope) that covers the geometry.
no setter
geometryType GeometryType
This indicates the type of geometrical shape it can represent, such as Envelope, Point or Polygon.
no setter
hasCurves bool
True if this geometry contains curve segments, false otherwise.
no setter
hashCode int
The hash code for this object.
no setteroverride
hasM bool
True if the geometry has m values (measure values), false otherwise.
no setter
hasZ bool
True if the geometry has z-coordinate values, false otherwise.
no setter
isEmpty bool
True if the geometry is empty, false otherwise.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
spatialReference SpatialReference?
The spatial reference for this geometry.
no setter

Methods

equalsWithTolerance({required Geometry right, required double tolerance}) bool
Checks if two geometries are approximately the same within the given tolerance.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() Map<String, dynamic>
Returns a JSON representation of this Object in the data type used by jsonDecode.
inherited
toJsonString() String
Returns a JSON representation of this Object as a String.
override
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
override

Static Methods

fromJsonWithSpatialReference({required String inputJson, required SpatialReference? spatialReference}) Geometry?
Creates a geometry from an ArcGIS JSON geometry representation.