FRAMES | NO FRAMES Description | Parameters | Examples | Response
Trim / Extend (Operation)
URL http://<geometryservice-url>/trimExtend
Parent Resource Geometry Service

Description

The trimExtend operation is performed on a geometry service resource. This operation trims / extends each polyline specified in the input array, using the user specified guide polylines. When trimming features, the part to the left of the oriented cutting line is preserved in the output and the other part is discarded. An empty polyline is added to the output array if the corresponding input polyline is neither cut nor extended.

You can provide arguments to the trimExtend operation as query parameters defined in the parameters table below.

Parameters

Parameter Details
f Description: The response format. The default response format is html.

Values : html | json
polylines Description : An array of polylines to be trimmed or extended. The spatial reference of the polylines is specified by sr. The structure of each polyline in the array is same as the structure of the JSON polyline objects returned by the ArcGIS REST API.

Syntax and Examples:

JSON Structures:

Syntax:

Example:

[
 {
   "paths" : [
    [[-117,34],[-116,34],[-117,33]],
    [[-115,44],[-114,43],[-115,43]]
   ]
 },
{
  "paths" : [
  [[32.49,17.83],[31.96,17.59],[30.87,17.01],[30.11,16.86]]
 ]
}
]
        
trimExtendTo Description : A polyline which is used as a guide for trimming / extending input polylines. The spatial reference of the polylines is specified by sr. The structure of each polyline is same as the structure of the JSON polyline objects returned by the ArcGIS REST API.

Syntax and Examples:

JSON Structures:

Syntax:

Example:

 {
   "paths" : [
    [[-117,34],[-116,34],[-117,33]],
    [[-115,44],[-114,43],[-115,43]]
   ]
 }
        
sr Description: The well-known ID of the spatial reference or a spatial reference json object for the input polylines. For a list of valid WKID values, see Projected coordinate Systems and Geographic coordinate Systems.
extendHow (optional) Description: A flag which is used along with the trimExtend operation.

0 - By default, extension considers both ends of paths. The old ends remain and new points are added to the extended ends. The new points have attributes that are extrapolated from adjacent existing segments.

1 - If an extension is performed at an end, relocate the end point to the new position instead of leaving the old point and adding a new point at the new position.

2 - If an extension is performed at an end, do not extrapolate the end-segment's attributes for the new point. Instead, make its attributes the same as the current end. Incompatible with esriNoAttributes.

4 - If an extension is performed at an end, do not extrapolate the end-segment's attributes for the new point. Instead, make its attributes be empty. Incompatible with esriKeepAttributes.

8 - Do not extend the 'from' end of any path.

16 - Do not extend the 'to' end of any path.

Example Usage

Example 1: In this example, two input polyline segments are trimmed / extended.

http://sampleserver3.arcgisonline.com/arcgis/rest/services/Geometry/GeometryServer/trimExtend?
sr=2229
&polylines=[{"paths" : [[[6805512.658537939,1843725.7846097648],[6805496.38855736,1844963.0199961811]]]},{"paths" : [[[6805532.382251769,1842246.5625026077],[6805523.806809604,1842901.206206441]]]}]
&trimExtendTo={"paths" : [[[6804206.368171528,1843554.492957607],[6805395.769992188,1843570.1779655963],[6805514.211684436,1843607.5194263458],[6805740.688921779,1843619.888168022]]]}
&extendHow=2
&f=html

JSON Response Syntax

{
  "geometryType" : "<esriGeometryPolyline>",
  "geometries" : [ <geometry1>, <geometry2> ]
}

JSON Response Example

{
  "geometries" : 
  [
    {
      "paths" : 
      [
        [
          [6805514.21365289, 1843607.51942632], 
          [6805512.65853788, 1843725.78460972], 
          [6805496.3885573, 1844963.01999615]
        ]
      ]
    }, 
    {
      "paths" : 
      [
        [
          [6805532.38225172, 1842246.56250256], 
          [6805523.80680956, 1842901.2062064], 
          [6805514.55420339, 1843607.53812706]
        ]
      ]
    }
  ]
}