Trim/Extend

URL:
https://<root>/Utilities/Geometry/GeometryServer/trimExtend
Methods:
GET
Version Introduced:
10.0

Description

The trimExtend operation is performed on a geometry service resource. This operation trims or 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 following parameters table.

Request parameters

ParameterDetails

polylines

Specifies 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 the same as the structure of the JSON polyline objects returned by the ArcGIS REST API.

Syntax

Use dark colors for code blocksCopy
1
[<polyline1>, <polyline2>, ..., <polylineN>]

Example:

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[
  {
    "paths" :
    [
      [[-117,34],[-116,34],[-117,33]],
      [[-115,44],[-114,43],[-115,43]]
    ]
  },
  {
    "paths" :
    [
      [[32,17],[31,17],[30,17],[30,16]]
    ]
  }
]

trimExtendTo

Specifies a polyline that is used as a guide for trimming or extending input polylines. The spatial reference of the polylines is specified by sr. The structure of each polyline is the same as the structure of the JSON polyline objects returned by the ArcGIS REST API.

Syntax

Use dark colors for code blocksCopy
1
<polyline>

Example

Use dark colors for code blocksCopy
1
2
3
4
5
6
{
  "paths": [
    [[-117,34],[-116,34],[-117,33]],
    [[-115,44],[-114,43],[-115,43]]
  ]
}

sr

Specifies 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 Using a spatial reference.

extendHow (optional)

Sets a flag that is used along with the trimExtend operation.

  • 0 — By default, an extension considers both ends of a path. 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 endpoint 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. It is 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 empty. It is incompatible with esriKeepAttributes.
  • 8 — Do not extend the "from" end of any path.
  • 16 — Do not extend the "to" end of any path.

f

The response format. The default format is html.

Values: html | json | pjson

Example usage

The following is a sample request URL for trimExtend that demonstrates how two input polyline segments can be trimmed or extended:

Use dark colors for code blocksCopy
1
https://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/Geometry/GeometryServer/trimExtend?sr=2229&polylines=[{"paths":[[[6805512,1843725],[6805496,1844963]]]},{"paths":[[[6805532,1842246],[6805523,1842901]]]}]&trimExtendTo={"paths":[[[6804206,1843554],[6805395,1843570],[6805514,1843607],[6805740,1843619]]]}&extendHow=1&f=html

JSON Response syntax

Use dark colors for code blocksCopy
1
2
3
4
{
  "geometryType": "<esriGeometryPolyline>",
  "geometries": [<geometry1>, <geometry2>, ..., <polylineN>]
}

JSON Response example

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
{
  "geometryType": "esriGeometryPolyline",
  "geometries": [
    {
      "paths": [
        [
          [
            6805513.5270143142,
            1843606.8529860612
          ],
          [
            6805496.0001066327,
            1844962.9999830574
          ]
        ]
      ]
    },
    {
      "paths": [
        [
          [
            6805532.0000346303,
            1842245.9998396486
          ],
          [
            6805513.3022866584,
            1843606.7831129492
          ]
        ]
      ]
    }
  ]
}

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.