Class Geometry
 java.lang.Object

 com.esri.arcgisruntime.geometry.Geometry

 All Implemented Interfaces:
JsonSerializable
 Direct Known Subclasses:
Envelope
,Multipart
,Multipoint
,Point
public abstract class Geometry extends Object implements JsonSerializable
Base class for classes that represent geometric shapes. The subtype is indicated bygetGeometryType()
. Geometries are used to define the shape of a feature or graphic, the extent of a layer, and as inputs and outputs of different types of task.Geometries are immutable. Instead of changing the properties of existing geometries, create new instances using the overloaded constructors, or use a corresponding
GeometryBuilder
to construct geometries stepbystep.The
SpatialReference
of a geometry may be null. Graphics with geometries that have a null SpatialReference will be treated as if they have the same SpatialReference as the containingMapView
; if the coordinates are in a different SpatialReference, the graphics may not display in the correct location, or at all.The
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. Many operations require input Geometries to besimple
.This class also provides the
toJson()
andfromJson(String)
methods to convert a Geometry to and from a JSON representation.


Constructor Summary
Constructors Constructor Description Geometry()

Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Geometry geometry, double tolerance)
Checks if a given geometry is equal to this one within a given tolerance.boolean
equals(Object obj)
static Geometry
fromJson(String json)
Creates a new Geometry from an ArcGIS JSON geometry representation.static Geometry
fromJson(String json, SpatialReference spatialReference)
Creates a new Geometry from an ArcGIS JSON geometry representation, and the given SpatialReference.GeometryDimension
getDimension()
Gets the dimension of this Geometry, relating to the number of spatial dimensions in which the geometry may have a size.Envelope
getExtent()
Gets an Envelope representing the spatial extent of this Geometry, the smallest Envelope that completely contains the Geometry.GeometryType
getGeometryType()
Gets the type of this Geometry, indicating the subclass, and the type of geometrical shape it can represent.SpatialReference
getSpatialReference()
Gets the SpatialReference of this Geometry.Map<String,Object>
getUnknownJson()
A Geometry never has any unknown JSON so this returns an empty Map.Map<String,Object>
getUnsupportedJson()
A Geometry never has any unsupported JSON so this returns an empty Map.boolean
hasCurves()
Indicates if this Geometry contains Segments that represent true curves.int
hashCode()
boolean
hasM()
Indicates if this Geometry has mvalues.boolean
hasZ()
Indicates if this Geometry has zvalues.boolean
isEmpty()
Indicates if this Geometry is empty.String
toJson()
Returns an ArcGIS JSON geometry representation of this Geometry.



Method Detail

fromJson
public static Geometry fromJson(String json)
Creates a new Geometry from an ArcGIS JSON geometry representation.See the ArcGIS REST API help topic on Geometry objects for more information.
 Parameters:
json
 a string containing an ArcGIS JSON representation of a geometry Returns:
 a new Geometry constructed from the
json
string, or null if a geometry couldn't be constructed  Throws:
IllegalArgumentException
 if json is null or empty Since:
 100.0.0

fromJson
public static Geometry fromJson(String json, SpatialReference spatialReference)
Creates a new Geometry from an ArcGIS JSON geometry representation, and the given SpatialReference. Any SpatialReference defined in the JSON representation will be ignored in favor of thespatialReference
parameter.See the ArcGIS REST API help topic on Geometry objects for more information.
 Parameters:
json
 a string containing an ArcGIS JSON representation of a GeometryspatialReference
 a SpatialReference to assign to the new Geometry Returns:
 a new Geometry constructed from the
json
string, or null if a geometry couldn't be constructed  Throws:
IllegalArgumentException
 if json is null or empty Since:
 100.0.0

getSpatialReference
public SpatialReference getSpatialReference()
Gets the SpatialReference of this Geometry. TheSpatialReference
of a Geometry defines how the coordinates of the Geometry correspond to locations in the real world. Returns:
 the SpatialReference of this Geometry
 Since:
 100.0.0

getDimension
public GeometryDimension getDimension()
Gets the dimension of this Geometry, relating to the number of spatial dimensions in which the geometry may have a size. Returns:
 the dimension of this Geometry
 Since:
 100.0.0

getExtent
public Envelope getExtent()
Gets an Envelope representing the spatial extent of this Geometry, the smallest Envelope that completely contains the Geometry.If the Geometry has
zvalues
andmvalues
, these will be reflected in the properties of the returned Envelope. For anempty
Geometry, the extent Envelope will also be empty. For aPoint
geometry, the extent will have zero width and height. Returns:
 the extent of this Geometry
 Since:
 100.0.0

getGeometryType
public GeometryType getGeometryType()
Gets the type of this Geometry, indicating the subclass, and the type of geometrical shape it can represent. Returns:
 the type of this Geometry
 Since:
 100.0.0

hasM
public boolean hasM()
Indicates if this Geometry has mvalues. Mvalues are often referred to as measures, and are used in linear referencing workflows on linear datasets. NaN is a valid mvalue.If true, mvalues are stored for each vertex of the Geometry. Geometries with mvalues are created by using setters or constructors that take an mvalue as a parameter.
Feature classes define whether their geometries have mvalues or not. When developing an editing workflow, you must ensure that this value matches that of the feature class in which the Geometry will be stored. The removeZ, removeM, and removeZAndM methods of
GeometryEngine
can be used to create new geometries without z and mvalue from existing geometries that have the values. See the ArcGIS Desktop help topic Defining feature class properties for more information. Returns:
 true if this Geometry has mvalues; false otherwise
 Since:
 100.0.0
 See Also:
hasZ()
,GeometryEngine.removeM(Geometry)
,GeometryEngine.removeZ(Geometry)
,GeometryEngine.removeZAndM(Geometry)

hasZ
public boolean hasZ()
Indicates if this Geometry has zvalues. Zvalues are generally used as a zcoordinate, indicating height or elevation. NaN is a valid zvalue.If true, zvalues are stored for each vertex of the Geometry. Geometries with zvalues are created by using setters or constructors that take a zvalue as a parameter.
Feature classes define whether their geometries have zvalues or not. When developing an editing workflow, you must ensure that this value matches that of the feature class in which the Geometry will be stored. The removeZ, removeM, and removeZAndM methods of
GeometryEngine
can be used to create new geometries without z and mvalue from existing geometries that have the values. See the ArcGIS Desktop help topic Defining feature class properties for more information. Returns:
 true if this Geometry has zvalues; false otherwise
 Since:
 100.0.0
 See Also:
hasM()
,GeometryEngine.removeM(Geometry)
,GeometryEngine.removeZ(Geometry)
,GeometryEngine.removeZAndM(Geometry)

hasCurves
public boolean hasCurves()
Indicates if this Geometry contains Segments that represent true curves.The ArcGIS system supports polygon and polyline geometries that contain curved segments in some types of data, for example geodatabases, feature services, and JSON. At the current release this SDK can display curved geometries, but you cannot work with curves using the API; any curved segments in a geometry will be represented as
LineSegments
, and the curve information will be lost. In editing workflows, use this method to determine if this geometry contains curve information which would be lost if used in an editing workflow. Returns:
 true if this Geometry contains curved segments; false otherwise
 Since:
 100.0.0

isEmpty
public boolean isEmpty()
Indicates if this Geometry is empty. An empty Geometry is a valid object, but has no location in space.For an empty Geometry,
hasZ()
andhasM()
return false, andgetExtent()
returns an empty Envelope. Returns:
 true if this Geometry is empty; false otherwise
 Since:
 100.0.0

toJson
public String toJson()
Returns an ArcGIS JSON geometry representation of this Geometry.See the ArcGIS REST API help topic on Geometry objects for more information.
 Specified by:
toJson
in interfaceJsonSerializable
 Returns:
 a string containing the JSON representation of this geometry
 Since:
 100.0.0

getUnknownJson
public Map<String,Object> getUnknownJson()
A Geometry never has any unknown JSON so this returns an empty Map. Specified by:
getUnknownJson
in interfaceJsonSerializable
 Returns:
 an empty unmodifiable Map
 Since:
 100.0.0

getUnsupportedJson
public Map<String,Object> getUnsupportedJson()
A Geometry never has any unsupported JSON so this returns an empty Map. Specified by:
getUnsupportedJson
in interfaceJsonSerializable
 Returns:
 an empty unmodifiable Map
 Since:
 100.0.0

equals
public boolean equals(Object obj)
This method is more stringent than the
GeometryEngine.equals(Geometry, Geometry)
method, as in addition to these checks, this method checks that each vertex in a Multipoint or Multipart geometry is in the same order; parts of Multiparts must also begin and end at the same Point.

equals
public boolean equals(Geometry geometry, double tolerance)
Checks if a given geometry is equal to this one within a given tolerance.This method performs a lightweight comparison of the geometries, such as might be useful when writing test code. It uses the tolerance to compare each of x, y, and any other values the geometries possess (such as z or m) independently in the manner:
abs(value1  value2) <= tolerance
.Returns true if the difference of each is within the tolerance and all other properties of the geometries are exactly equal (spatial reference, vertex count, etc.). A single tolerance is used even if the units for the horizontal coordinates and other values differ, for example horizontal coordinates in degrees and vertical coordinates in meters.
This method does not respect modular arithmetic of spatial references which wrap around, so longitudes of 180 and +180 degrees are considered to differ by 360 degrees.
 Parameters:
geometry
 the geometry to checktolerance
 the tolerance Returns:
 true if the geometries are equal, within the tolerance, otherwise false
 Since:
 100.1.0
 See Also:
equals(Object)

