com.esri.core.geometry
Class GeometryEngine

java.lang.Object
  extended by com.esri.core.geometry.GeometryEngine

public class GeometryEngine
extends Object

Provides services that operate on geometry instances.

Since:
1.0

Constructor Summary
GeometryEngine()
           
 
Method Summary
static Polygon[] buffer(Geometry[] geometries, SpatialReference spatialReference, double[] distances, Unit unit, boolean toUnionResults)
          Calculates a buffer polygon for each geometry at each of the corresponding specified distances.
static Polygon buffer(Geometry geometry, SpatialReference spatialReference, double distance, Unit unit)
          Calculates buffer polygon of the geometry as specified by the distance input.
static Geometry clip(Geometry geometry, Envelope envelope, SpatialReference spatialReference)
          Calculates the clipped geometry from an target geometry by an envelope.
static boolean contains(Geometry geometry1, Geometry geometry2, SpatialReference spatialReference)
          Indicates if one geometry contains another geometry.
static boolean crosses(Geometry geometry1, Geometry geometry2, SpatialReference spatialReference)
          Indicates if one geometry crosses another geometry.
static Geometry difference(Geometry inputGeometry, Geometry substractor, SpatialReference spatialReference)
          Creates the difference of two geometries.
static double distance(Geometry geometry1, Geometry geometry2, SpatialReference spatialReference)
          Calculates the 2D planar distance between two geometries.
static boolean equals(Geometry geometry1, Geometry geometry2, SpatialReference spatialReference)
          Indicates if two geometries are equal.
static double geodesicLength(Geometry geometry, SpatialReference spatialReference, LinearUnit lengthUnit)
          A geodesic length is the shortest distance between any two points on the earth's surface when the earth's surface is approximated by a spheroid.
static Geometry geometryFromEsriShape(byte[] esriShapeBuffer, Geometry.Type geometryType)
          Imports geometry from the ESRI shape file format.
static byte[] geometryToEsriShape(Geometry geometry)
          Exports geometry to the ESRI shape file format.
static String geometryToJson(int wkid, Geometry geometry)
          Deprecated. 
static String geometryToJson(SpatialReference spatialReference, Geometry geometry)
          Exports the specified geometry instance to its JSON representation.
static Proximity2DResult getNearestCoordinate(Geometry geometry, Point inputPoint, boolean bTestPolygonInterior)
          Finds the coordinate of the geometry which is closest to the specified point.
static Proximity2DResult getNearestVertex(Geometry geometry, Point inputPoint)
          Finds nearest vertex on the geometry which is closed to the specified point.
static Proximity2DResult[] getNearestVertices(Geometry geometry, Point inputPoint, double searchRadius, int maxVertexCountToReturn)
          Finds all vertices in the given distance from the specified point, sorted from the closest to the furthest.
static Geometry intersect(Geometry inputGeometry, Geometry intersector, SpatialReference spatialReference)
          Creates a geometry through intersection between two geometries.
static MapGeometry jsonToGeometry(org.codehaus.jackson.JsonParser json)
          Imports the MapGeometry from it's JSON representation.
static Point project(double x, double y, SpatialReference sr)
          Projects the given point from EPSG:4326 to the output Spatial Reference.
static Geometry project(Geometry geometry, SpatialReference inputSR, SpatialReference outputSR)
          Projects the given geometry instance from the input spatial reference to the output Spatial Reference.
static Geometry simplify(Geometry geometry, SpatialReference spatialReference)
          Performs the simplify operation on the geometry.
static boolean touches(Geometry geometry1, Geometry geometry2, SpatialReference spatialReference)
          Indicates if one geometry touches another geometry.
static Geometry union(Geometry[] geometries, SpatialReference spatialReference)
          Constructs a new geometry by union an array of geometries.
static boolean within(Geometry geometry1, Geometry geometry2, SpatialReference spatialReference)
          Indicates if one geometry is within another geometry.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GeometryEngine

public GeometryEngine()
Method Detail

project

public static Geometry project(Geometry geometry,
                               SpatialReference inputSR,
                               SpatialReference outputSR)
Projects the given geometry instance from the input spatial reference to the output Spatial Reference. To perform the projection, this method creates an instance of the ProjectionTransformation using the domain of the input spatial reference as the area of interest.

Parameters:
geometry - The input geometry to be projected.
inputSR - The spatial reference of the input geometry.
outputSR - The spatial reference to project the geometry to.
Returns:
Returns the projected geometry.
Since:
1.0

project

public static Point project(double x,
                            double y,
                            SpatialReference sr)
Projects the given point from EPSG:4326 to the output Spatial Reference.

Parameters:
x - the x
y - the y
sr - The spatial reference to project the geometry to.
Returns:
Returns the projected geometry.
Since:
1.0

jsonToGeometry

public static MapGeometry jsonToGeometry(org.codehaus.jackson.JsonParser json)
Imports the MapGeometry from it's JSON representation. M and Z values are not imported from JSON representation.

Parameters:
json - The JSON representation of the geometry (with spatial reference).
Returns:
The MapGeometry instance containing the imported geometry and it's spatial reference.
Since:
1.0

geometryToJson

@Deprecated
public static String geometryToJson(int wkid,
                                               Geometry geometry)
Deprecated. 

Exports the specified geometry instance to its Json representation.

Parameters:
wkid - The spatial reference Well Known ID to be used for the Json representation.
geometry - The geometry to be exported to JSON.
Returns:
The JSON representation of the specified Geometry.
Since:
1.0
See Also:
geometryToJson(SpatialReference spatialiReference, Geometry geometry)

geometryToJson

public static String geometryToJson(SpatialReference spatialReference,
                                    Geometry geometry)
Exports the specified geometry instance to its JSON representation. M and Z values are not imported from JSON representation.

Parameters:
spatialReference - The spatial reference of associated object.
geometry - The geometry.
Returns:
String The JSON representation of the specified geometry.
Since:
1.0

geometryFromEsriShape

public static Geometry geometryFromEsriShape(byte[] esriShapeBuffer,
                                             Geometry.Type geometryType)
Imports geometry from the ESRI shape file format.

Parameters:
esriShapeBuffer - The buffer containing geometry in the ESRI shape file format.
geometryType - The required type of the Geometry to be imported. Use Geometry.Type.Unknown if the geometry type needs to be determined from the buffer content.
Returns:
The geometry or null if the buffer contains null shape.
Throws:
GeometryException - when the geometryType is not Geometry.Type.Unknown and the buffer contains geometry that cannot be converted to the given geometryType. or the buffer is corrupt. Another exception possible is IllegalArgumentsException.
Since:
1.0

geometryToEsriShape

public static byte[] geometryToEsriShape(Geometry geometry)
Exports geometry to the ESRI shape file format.

Parameters:
geometry - The geometry to export. (null value is not allowed)
Returns:
Array containing the exported ESRI shape file.
Since:
1.0

union

public static Geometry union(Geometry[] geometries,
                             SpatialReference spatialReference)
Constructs a new geometry by union an array of geometries. All inputs must be of the same type of geometries and share one spatial reference.

Parameters:
geometries - The geometries to union.
spatialReference - The spatial reference of the geometries.
Returns:
The geometry object representing the resultant union.
Since:
1.0

difference

public static Geometry difference(Geometry inputGeometry,
                                  Geometry substractor,
                                  SpatialReference spatialReference)
Creates the difference of two geometries. The resultant geometry is the part of inputGeometry not in the substractor. The dimension of substractor has to be equal to or greater than that of inputGeometry.

Parameters:
inputGeometry - The geometry being subtracted.
substractor - The geometry object to subtract from.
spatialReference - The spatial reference of the geometries.
Returns:
The geometry of the differences.
Since:
1.0

equals

public static boolean equals(Geometry geometry1,
                             Geometry geometry2,
                             SpatialReference spatialReference)
Indicates if two geometries are equal.

Parameters:
geometry1 - Geometry.
geometry2 - Geometry.
spatialReference - The spatial reference of the geometries.
Returns:
True if both geometry objects are equal.
Since:
1.0

intersect

public static Geometry intersect(Geometry inputGeometry,
                                 Geometry intersector,
                                 SpatialReference spatialReference)
Creates a geometry through intersection between two geometries.

Parameters:
inputGeometry - Geometry.
intersector - Geometry
spatialReference - The spatial reference of the geometries.
Returns:
The geometry created through intersection.
Since:
1.0

within

public static boolean within(Geometry geometry1,
                             Geometry geometry2,
                             SpatialReference spatialReference)
Indicates if one geometry is within another geometry.

Parameters:
geometry1 - The base geometry that is tested for within relationship to the other geometry.
geometry2 - The comparison geometry that is tested for the contains relationship to the other geometry.
spatialReference - The spatial reference of the geometries.
Returns:
True if the first geometry (geometry1) is within the other geometry (geometry2).
Since:
1.0

contains

public static boolean contains(Geometry geometry1,
                               Geometry geometry2,
                               SpatialReference spatialReference)
Indicates if one geometry contains another geometry.

Parameters:
geometry1 - The geometry that is tested for the contains relationship to the other geometry..
geometry2 - The geometry that is tested for within relationship to the other geometry.
spatialReference - The spatial reference of the geometries.
Returns:
True if geometry1 contains geometry2.
Since:
1.0

crosses

public static boolean crosses(Geometry geometry1,
                              Geometry geometry2,
                              SpatialReference spatialReference)
Indicates if one geometry crosses another geometry.

Parameters:
geometry1 - The geometry to cross.
geometry2 - The geometry being crossed.
spatialReference - The spatial reference of the geometries.
Returns:
True if geometry1 crosses geometry2
Since:
1.0.

touches

public static boolean touches(Geometry geometry1,
                              Geometry geometry2,
                              SpatialReference spatialReference)
Indicates if one geometry touches another geometry.

Parameters:
geometry1 - The geometry to touch.
geometry2 - The geometry to be touched.
spatialReference - The spatial reference of the geometries.
Returns:
True if geometry1 touches geometry2.
Since:
1.0

distance

public static double distance(Geometry geometry1,
                              Geometry geometry2,
                              SpatialReference spatialReference)
Calculates the 2D planar distance between two geometries.

Parameters:
geometry1 - Geometry.
geometry2 - Geometry.
spatialReference - The spatial reference of the geometries.
Returns:
The distance between the two geometries.
Since:
1.0

clip

public static Geometry clip(Geometry geometry,
                            Envelope envelope,
                            SpatialReference spatialReference)
Calculates the clipped geometry from an target geometry by an envelope.

Parameters:
geometry - The geometry to be clipped.
envelope - The envelope used to clip.
spatialReference - The spatial reference of the geometries.
Returns:
The geometry created by the clipping.
Since:
1.0

buffer

public static Polygon[] buffer(Geometry[] geometries,
                               SpatialReference spatialReference,
                               double[] distances,
                               Unit unit,
                               boolean toUnionResults)
Calculates a buffer polygon for each geometry at each of the corresponding specified distances. It is assumed all geometries have the same spatial reference. The unit variable defines the unit of all the distances. If unit == null then the unit of distances is assumed to be that of the spatial reference. There is an option to union the returned geometries.

Parameters:
geometries - An array of geometries to be buffered.
spatialReference - The spatial reference of the geometries.
distances - The corresponding distances for the input geometries to be buffered.
unit - The unit of the values in the distances array. Must be of the same unit type as spatial reference.
toUnionResults - True if all geometries buffered at a given distance are to be unioned into a single polygon.
Returns:
The buffer of the geometries.
Since:
1.0

buffer

public static Polygon buffer(Geometry geometry,
                             SpatialReference spatialReference,
                             double distance,
                             Unit unit)
Calculates buffer polygon of the geometry as specified by the distance input. If unit == null, then the distance is assumed to be in the unit of the spatial reference.

Parameters:
geometry - Geometry to be buffered.
spatialReference - The spatial reference of the geometry.
distance - The specified distance for buffer.
unit - The unit of the values in the distances array. Must be of the same unit type as spatial reference.
Returns:
The buffer polygon at the specified distances.
Since:
1.0

getNearestCoordinate

public static Proximity2DResult getNearestCoordinate(Geometry geometry,
                                                     Point inputPoint,
                                                     boolean bTestPolygonInterior)
Finds the coordinate of the geometry which is closest to the specified point.

Parameters:
inputPoint - The point to find the nearest coordinate in the geometry for.
geometry - The geometry to consider.
Returns:
Proximity2DResult containing the nearest coordinate
Since:
1.0.

getNearestVertex

public static Proximity2DResult getNearestVertex(Geometry geometry,
                                                 Point inputPoint)
Finds nearest vertex on the geometry which is closed to the specified point.

Parameters:
inputPoint - The point to find the nearest vertex of the geometry for.
geometry - The geometry to consider.
Returns:
Proximity2DResult containing the nearest vertex.
Since:
1.0

getNearestVertices

public static Proximity2DResult[] getNearestVertices(Geometry geometry,
                                                     Point inputPoint,
                                                     double searchRadius,
                                                     int maxVertexCountToReturn)
Finds all vertices in the given distance from the specified point, sorted from the closest to the furthest.

Parameters:
inputPoint - The point to start from.
geometry - The geometry to consider.
searchRadius - The search radius.
maxVertexCountToReturn - The maximum number number of vertices to return.
Returns:
Proximity2DResult containing the array of nearest vertices.
Since:
1.0

simplify

public static Geometry simplify(Geometry geometry,
                                SpatialReference spatialReference)
Performs the simplify operation on the geometry.

Parameters:
geometry - The geometry to be simplified.
spatialReference - The spatial reference of the geometry to be simplified.
Returns:
The simplified geometry.
Since:
1.0

geodesicLength

public static double geodesicLength(Geometry geometry,
                                    SpatialReference spatialReference,
                                    LinearUnit lengthUnit)
A geodesic length is the shortest distance between any two points on the earth's surface when the earth's surface is approximated by a spheroid.

Parameters:
geometry - The input geometry.
spatialReference - The spatial reference in which the coordinates of the geometry are defined. This spatial reference can be a Geographic Coordinate System or a Projected Coordinate System, but it cannot be local.
lengthUnit - The units to return the length in. If null is specified, the length is returned in meters.
Returns:
The geodesic length of geometry. Note: This method will always return 0 for Point and MultiPoint instances.
Since:
1.0


Copyright © 2012. All Rights Reserved.