Defines common members for all specific types of geometry.
AGSGeometry represents real-world objects by defining a shape at a specific geographic location. It is used throughout the 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.
The AGSGeometry class provides functionality common to all types of geometry. AGSPoint, AGSMultipoint, AGSPolyline, AGSPolygon, and AGSEnvelope all inherit from AGSGeometry and represent different types of shapes.
All types of geometry:
- have an
AGSSpatialReference 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 some important benefits to your app. They are inherently thread-safe, help prevent inadvertent changes, and allow for certain performance optimizations.
On the surface, immutability may appear to present a problem when attempting to edit existing geometries. Creating and updating, however, is handled by the various types of AGSGeometryBuilder, which are designed to represent the state of a geometry under construction while allowing modifications, thus enabling editing workflows.
Spatial reference and projection The coordinates that define a geometry are only meaningful in the context of the geometry's AGSSpatialReference. 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. An AGSGraphic that does not have a spatial reference is drawn using the same spatial reference as the AGSMapView to which it was added. When using AGSGeometryBuilder to create an AGSPolyline or AGSPolygon from a collection of AGSPoint, you don't need to set the spatial reference of every point before you add it to the builder, as it will be 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, AGSGeometry::spatialReference must be set.
Changing the coordinates of a geometry to have the same shape and location represented using a different AGSSpatialReference 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.
AGSGeometryEngine, however, provides a wide range of methods that read the content of geometries and modify that content to create new geometries. There are methods to AGSGeometryEngine::projectWithGeometry:spatialReference:, AGSGeometryEngine::moveGeodeticWithPointCollection:distance:distanceUnit:azimuth:azimuthUnit:curveType:, AGSGeometryEngine::cutWithGeometry:cutter:, AGSGeometryEngine::densifyWithGeometry:maxSegmentLength:, and AGSGeometryEngine::generalizeWithGeometry:maxDeviation:removeDegenerateParts: geometries.
- See also
AGSGeometryEngine for performing operations on geometries
-
AGSGeometryBuilder for constructing or modifying geometries
- Since
- 100