Class: GeometryServiceE-mail This Topic Printable Version Give Us Feedback

Description

Represents a geometry service resource exposed by the ArcGIS Server REST API. It is used to perform various operations on geometries such as project, simplify, buffer, and relationships. For more details on constant values, see esriGeometryRelationEnum.

Class hierarchy

esri.tasks.GeometryService

Constructor

Constructor Description
esri.tasks.GeometryService(url) Creates a new GeometryService object. A URL is a required parameter.

Properties

Property Type Description
url String URL to the ArcGIS Server REST resource that represents a locator service. To obtain the URL, use Services Directory.

Constants

Constant Description
SPATIAL_REL_COINCIDENCE The boundaries of the geometries must share an intersection, but the relationship between the interiors of the shapes is not considered (they could overlap, one could be contained in the other, or their interiors could be disjoint). This relation applies to polylines and polygons.
SPATIAL_REL_CROSS Two polylines cross if they share only points in common, at least one of which is not an endpoint. A polyline and an polygon cross if they share a polyline in common on the interior of the polygon which is not equivalent to the entire polyline. Cross is a Clementini operator. If either one of the geometries is empty, the geometries do not cross.
SPATIAL_REL_DISJOINT Two geometries are disjoint if their intersection is empty. Two geometries intersect if disjoint is "false".
SPATIAL_REL_IN The base geometry is within the comparison geometry if the base geometry is the intersection of the geometries and the intersection of their interiors is not empty. An empty geometry is within another geometry, unless the other geometry is empty.
SPATIAL_REL_INTERIORINTERSECTION Geometries intersect excluding boundary touch.
SPATIAL_REL_INTERSECTION Geometry interiors intersect or boundaries touch, same as 'not disjoint'.
SPATIAL_REL_LINETOUCH Two geometries are said to touch when the intersection of the geometries is non-empty, but the intersection of their interiors is empty. This evaluates if the touch occurs along a boundary (not a point). Valid for polygons.
SPATIAL_REL_OVERLAP Two polylines share a common sub-line, or two polygons share a common sub-area. Two geometries do not overlap if either one is empty.
SPATIAL_REL_POINTTOUCH Two geometries are said to touch when the intersection of the geometries is non-empty, but the intersection of their interiors is empty. This evaluates if the touch occurs at a point (not a boundary).
SPATIAL_REL_RELATION Allows specification of any relationship defined using the Shape Comparison Language.
SPATIAL_REL_TOUCH The union of esriGeometryRelationPointTouch and esriGeometryRelationLineTouch. Two geometries are said to touch when the intersection of the geometries is non-empty, but the intersection of their interiors is empty. For example, a point touches a polyline only if the point is coincident with one of the polyline end points. If either one of the two geometries is empty, the geometries are not touched.
SPATIAL_REL_WITHIN Same as esriGeometryRelationIn but also allows polylines that are strictly on the boundaries of polygons to be considered in the polygon.

Methods

Method Return Value Description
areasAndLengths(graphics, callback?, errback?) dojo.Deferred Gets the areas and lengths for a Graphic[] when the geometry type is Polygon.
buffer(bufferParameters, callback?, errback?) dojo.Deferred Creates buffer polygons at a specified distance around the given geometries. On completion, the onBufferComplete event is fired and the optional callback function is invoked. Both the callback and event handlers receive an array of Graphic that contains the buffer polygons.
labelPoints(polygons, callback?, errback?) dojo.Deferred Calculates an interior point for each polygon specified. These interior points can be used by clients for labeling the polygons.
lengths(graphics, callback?, errback?) dojo.Deferred Gets the lengths for a Graphic[] when the geometry type is Polyline.
project(graphics, outSpatialReference, callback?, errback?) dojo.Deferred Projects a set of geometries into a new spatial reference. On completion, the onProjectComplete event is fired and the optional callback function is invoked. Both the callback and event handlers receive an array of Graphic that contains the projected geometries.
relation(graphics1, graphics2, spatialRelationship, comparisonString?, callback?, errback?) dojo.Deferred Computes the set of pairs of geometries from graphics1 and graphics2 that belong to the specified relation. Both arrays are assumed to be in the same spatial reference. The relations are evaluated in 2D. Z coordinates are not used. Geometry types cannot be mixed within an array.
simplify(graphics, callback?, errback?) dojo.Deferred Alters the given geometries to make their definitions topologically legal with respect to their geometry type. On completion, the onSimplifyComplete event is fired and the optional callback function is invoked. Both the callback and event handlers receive an array of Graphic that contains the simplified geometries.

Events

Event Description
onAreasAndLengthsComplete(areasAndLengths) Fires when the areasAndLengths operation is complete.
onBufferComplete(graphics) Fires when the buffer operation is complete.
onError(error) Fires when an error occurs when executing the task.
onLabelPointsComplete(labelPoints) Fires when the labelPoints operation is complete.
onLengthsComplete(lengths) Fires when the lengths operation is complete.
onProjectComplete(graphics) Fires when the project operation is complete.
onRelationComplete(relationships) Fires when the relation operation is complete.
onSimplifyComplete(graphics) Fires when the simplify operation is complete.
Constructor Detail

esri.tasks.GeometryService(url)

Creates a new GeometryService object. A URL is a required parameter.
Parameters:
<String> url Required URL to the ArcGIS Server REST resource that represents a geometry service. An example is http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Locators/ESRI_Geocode_USA/GeocodeServer. For more information on constructing a URL, see The Services Directory and the REST API.
Properties Detail

<String> url

URL to the ArcGIS Server REST resource that represents a locator service. To obtain the URL, use Services Directory.
Methods Detail

areasAndLengths(graphics, callback?, errback?)

Gets the areas and lengths for a Graphic[] when the geometry type is Polygon.

The return object of dojo.Deferred was added at v1.4. (As of v1.1)
Return value: dojo.Deferred
Input Parameters:
<Graphic[]> graphics Required The graphic used to calculate areas and lengths.
<Function> callback Optional The function to call when the method has completed. The arguments in the function are the same as the onAreasAndLengthsComplete event.
<Function> errback Optional An error object is returned if an error occurs on the Server during task execution. (As of v1.3)
See also:
onAreaAndLengthsComplete   onError  

buffer(bufferParameters, callback?, errback?)

Creates buffer polygons at a specified distance around the given geometries. On completion, the onBufferComplete event is fired and the optional callback function is invoked. Both the callback and event handlers receive an array of Graphic that contains the buffer polygons.

The return object of dojo.Deferred was added at v1.4.
Return value: dojo.Deferred
Input Parameters:
<BufferParameters> bufferParameters Required Specifies the input geometries, buffer distances, and other options.
<Function> callback Optional The function to call when the method has completed. The arguments in the function are the same as the onBufferComplete event.
<Function> errback Optional An error object is returned if an error occurs on the Server during task execution. (As of v1.3)
See also:
onBufferComplete   onError  

labelPoints(polygons, callback?, errback?)

Calculates an interior point for each polygon specified. These interior points can be used by clients for labeling the polygons.

The return object of dojo.Deferred was added at v1.4. (As of v1.2)
Return value: dojo.Deferred
Input Parameters:
<Graphic[]> polygons Required The graphics to process.
<Function> callback Optional The function to call when the method has completed. The arguments in the function are the same as the onLabelPointsComplete event.
<Function> errback Optional An error object is returned if an error occurs on the Server during task execution. (As of v1.3)
See also:
onLabelPointsComplete   onError  

lengths(graphics, callback?, errback?)

Gets the lengths for a Graphic[] when the geometry type is Polyline.

The return object of dojo.Deferred was added at v1.4. (As of v1.1)
Return value: dojo.Deferred
Input Parameters:
<Graphic[]> graphics Required The graphic used to calculate lengths.
<Function> callback Optional The function to call when the method has completed. The arguments in the function are the same as the onLengthsComplete event.
<Function> errback Optional An error object is returned if an error occurs on the Server during task execution. (As of v1.3)
See also:
onLengthsComplete   onError  

project(graphics, outSpatialReference, callback?, errback?)

Projects a set of geometries into a new spatial reference. On completion, the onProjectComplete event is fired and the optional callback function is invoked. Both the callback and event handlers receive an array of Graphic that contains the projected geometries.

The return object of dojo.Deferred was added at v1.4.
Return value: dojo.Deferred
Input Parameters:
<Graphic[]> graphics Required The graphic to project.
<SpatialReference> outSpatialReference Required The well-known ID of a spatial reference.
{"wkid" : 4326} 
<Function> callback Optional The function to call when the method has completed. The arguments in the function are the same as the onProjectComplete event.
<Function> errback Optional An error object is returned if an error occurs on the Server during task execution. (As of v1.3)
See also:
onProjectComplete   onError  

relation(graphics1, graphics2, spatialRelationship, comparisonString?, callback?, errback?)

Computes the set of pairs of geometries from graphics1 and graphics2 that belong to the specified relation. Both arrays are assumed to be in the same spatial reference. The relations are evaluated in 2D. Z coordinates are not used. Geometry types cannot be mixed within an array.

The return object of dojo.Deferred was added at v1.4. (As of v1.2)
Return value: dojo.Deferred
Input Parameters:
<Graphic[]> graphics1 Required The first set of graphics in the comparison.
<Graphic[]> graphics2 Required The second set of graphics in the comparison.
<String> spatialRelationship Required See the Constants table for valid values. For a detailed description of relations, see esriGeometryRelationEnum .
<String> comparisonString Optional The Shape Comparison Language string to be evaluated.
<Function> callback Optional The function to call when the method has completed. The arguments in the function are the same as the onRelationComplete event.
<Function> errback Optional An error object is returned if an error occurs on the Server during task execution. (As of v1.3)
See also:
onRelationComplete   onError  

simplify(graphics, callback?, errback?)

Alters the given geometries to make their definitions topologically legal with respect to their geometry type. On completion, the onSimplifyComplete event is fired and the optional callback function is invoked. Both the callback and event handlers receive an array of Graphic that contains the simplified geometries.

The return object of dojo.Deferred was added at v1.4.
Return value: dojo.Deferred
Input Parameters:
<Graphic[]> graphics Required The graphic to simplify.
<Function> callback Optional The function to call when the method has completed. The arguments in the function are the same as the onSimplifyComplete event.
<Function> errback Optional An error object is returned if an error occurs on the Server during task execution. (As of v1.3)
See also:
onSimplifyComplete   onError  

Events Detail

onAreasAndLengthsComplete(areasAndLengths)

Fires when the areasAndLengths operation is complete. (As of v1.1)
Arguments:
<Object> areasAndLengths The object with the areas and lengths. The format is { areas : Number[], lengths : Number[] }.

onBufferComplete(graphics)

Fires when the buffer operation is complete.
Arguments:
<Graphic[]> graphics The graphics representing the buffer.
See also:
buffer  

onError(error)

Fires when an error occurs when executing the task. (As of v1.3)
Arguments:
<Error> error ArcGIS Server error message returned in a JavaScript error object.
See also:
project   simplify   areasAndLengths   lengths   buffer   labelPoints   relation  

onLabelPointsComplete(labelPoints)

Fires when the labelPoints operation is complete. (As of v1.2)
Arguments:
<Graphic[]> labelPoints The graphics representing the points calculated inside the polygons.
See also:
labelPoints  

onLengthsComplete(lengths)

Fires when the lengths operation is complete. (As of v1.1)
Arguments:
<Object> lengths The object with the areas and lengths. The format is { lengths : Number[] }.
See also:
lengths  

onProjectComplete(graphics)

Fires when the project operation is complete.
Arguments:
<Graphic[]> graphics The projected graphics.
See also:
project  

onRelationComplete(relationships)

Fires when the relation operation is complete. (As of v1.2)
Arguments:
<Object[]> relationships Indices in the two input geometries that met the specified relationship. The array contains the following properties: graphic1Index, graphic2index, graphic1, graphic2

      function relateGeometries() {
        geometryService.relation(graphics1, graphics2, esri.tasks.GeometryService.SPATIAL_REL_WITHIN, null, processRelations);
      }
      function processRelations(relations) {
        var symbol = new esri.symbol.SimpleMarkerSymbol().setColor(new dojo.Color([0, 255, 0]));

        // highlight all graphic1 graphics that met the spatial relation against the second geometry
        for (var i = 0; i < relations.length; i++) {
          var relatedGraphic = relations[i].graphic1;
          relatedGraphic.setSymbol(symbol);
        }
      }

See also:
relation  

onSimplifyComplete(graphics)

Fires when the simplify operation is complete.
Arguments:
<Graphic[]> graphics The simpified graphics.
See also:
simplify