Available with Location Referencing license.
- URL:https://<LinearReferencingService-url>/applyEdits(POST only)
- Required Capability:Event Editing, Network Editing
- Version Introduced:10.6
Description
License:
The ArcGIS Location Referencing license is required to use this resource.
This operation applies a batch of event or route changes to the editable linear referencing layers in the service.
Currently, only point and linear event layers, network (route) layers, and calibration point layers can be edited.
Edits can only be applied to event feature classes that are local to the LRS geodatabase. External event tables are treated as read-only data sources and do not support web editing.
All edits sent in one request are applied in a single database transaction to maintain data integrity. If any of the individual edits fail, the entire transaction is rolled back and none of the changes are applied. An edit operation can only include layers that exist in a single database workspace. An error message is returned if an edit request specifies layers defined in different workspaces.
Note:
If conflict prevention is enabled, locks must be acquired before running applyEdits, or an error that lists the missing locks is returned.
Request parameters
Parameter | Details |
---|---|
f | Optional parameter to specify the response format. The default response format is html. Values: html | json |
edits | This parameter is required. Description: A batch of changes to apply to the editable layers in the service. Each layer can receive a distinct set of additions, updates, and deletions. The format of the change records depends on the layer type being edited.
|
gdbVersion | Optional parameter to specify the geodatabase version to use. If this parameter is not specified, the published map's version is used. Syntax: gdbVersion=<version> Example: gdbVersion="user1.version1" |
returnEditMoment | Optional parameter to specify whether the response reports the time edits that were applied. If returnEditMoment=true, the server returns the time edits that were applied in the response's editMoment key. The default value is false. Values: true|false This parameter was added at 10.6.1. |
sessionId | Optional parameter set by a client during long transaction editing on a branch version. The sessionId parameter value is a GUID that clients establish at the beginning and use throughout the edit session. The sessonId parameter ensures isolation during the edit session. Syntax: sessionId=<guid> Example: sessionId="{E81C2E2D-C6A7-40CB-BF61-FB499E53DD1D}" This parameter was added at 10.6.1. |
returnServiceEditsOption | Optional parameter that returns features edited due to the geodatabase behavior that results from applying the edits. For example, if a feature is deleted and it is the origin in a composite relationship, the destination feature is automatically deleted from the geodatabase. If returnServiceEditsOption is set to originalAndCurrentFeatures, the deleted destination feature is returned along with a reference to the deleted original feature in the response. Note that, even for deletions, the geometry and attributes of the edited feature are returned. Results returned from applyEdits are organized layer by layer. If returnServiceEditsOption is set to originalAndCurrentFeatures, each layer can have edited features returned in an editedFeatures object. Service-level applyEdits response structure: The editedFeatures object returns full features, including the original features prior to deletion, the original and current features for updates, and the current rows for inserts that can contain implicit changes (for example, as a result of a calculation rule). editedFeatures response structure: The response includes no editedFeatures values and exceededTransferLimit=true if the count of edited features to return is more than the maxRecordCount value. If clients are using this parameter to maintain a cache, they should invalidate the cache when exceededTransferLimit=true is returned. If the server encounters an error when generating the list of edits in the response, exceededTransferLimit=true is also returned. Edited features are returned in the spatial reference of the feature service as defined by the services spatialReference object or by the spatialReference value of the layers extent object. The default value is none, which does not include editedFeatures values. Values: none|originalAndCurrentFeatures This parameter was added at 10.6.1. |
Example usage
The following examples demonstrate how to add events to an event layer.
Example 1
A URL for adding new events to a point event layer is shown.
https://sampleserver/arcgis/rest/services/MyLRS/MapServer/exts/LRServer/applyEdits?f=json&edits=[{"id":1,"adds":[{"attributes":{"route_id":"I90","event_id":"ABC123","meas":48.5}}]}]
Example 2
A URL for adding new events to a linear event layer is shown.
https://sampleserver/arcgis/rest/services/MyLRS/MapServer/exts/LRServer/applyEdits?f=json&edits=[{"id":2,"adds":[{"attributes":{"RouteID":"US101","EventID":"ABC123","FromMeasure":20,"ToMeasure":25.75}}]}]
Example 3
A URL for adding new events with a temporal view date range is shown.
https://sampleserver/arcgis/rest/services/MyLRS/MapServer/exts/LRServer/applyEdits?f=json&edits=[{"id":3,"adds":[{"attributes":{"ROUTEID":"SR85","EVENTID":"ABC123","MEAS":35,"FROM_DATE":1230768000000,"TO_DATE":1262304000000}}]}]
Example 4
A URL for adding new events with measure merging is shown.
https://sampleserver/arcgis/rest/services/MyLRS/MapServer/exts/LRServer/applyEdits?f=json&edits=[{"id":2,"allowMerge":true,"adds":[{"attributes":{"RouteID":"US101","EventID":"ABC123","Pavement":"concrete","FromMeasure":20,"ToMeasure":25.75}}]}]
Example 5
A URL for adding new events with measure overlap retirement is shown.
https://sampleserver/arcgis/rest/services/MyLRS/MapServer/exts/LRServer/applyEdits?f=json&edits=[{"id":2,"retireMeasureOverlap":true,"adds":[{"attributes":{"RouteID":"US101","EventID":"ABC123","FromMeasure":20,"ToMeasure":25.75}}]}]
Example 6
A URL for adding new events with referent locations is shown.
https://sampleserver/arcgis/rest/services/MyLRS/MapServer/exts/LRServer/applyEdits?f=json&edits=[{"id":2,"allowMerge":true,"retireMeasureOverlap":true,"adds":[{"attributes":{"RouteID":"US101","EventID":"ABC123","SpeedLimit":65,"FromMeasure":20,"ToMeasure":25.75,"FromRefMethod":12,"FromRefLocation":"{E9A2157D-DFD5-4696-943F-B35DD77C0BBE}","FromRefOffset":"125","ToRefMethod":20,"ToRefLocation":"{C061ECEC-C0BA-462D-BB73-DA175EAEFBD2}","ToRefOffset":"-50.3"}}]}]
Example 7
A URL for updating events using a WHERE clause is shown.
https://sampleserver/arcgis/rest/services/MyLRS/MapServer/exts/LRServer/applyEdits?f=json&edits=[{"id":2,"updates":[{"where":"Pavement = 'asphalt' and LaneCount = 2","attributes":{"LastPaved":1262304000000}}]}]
Example 8
A URL for updating events by event ID is shown.
https://sampleserver/arcgis/rest/services/MyLRS/MapServer/exts/LRServer/applyEdits?f=json&edits=[{"id":2,"updates":[{"eventId":"ABC123","attributes":{"FromMeasure":42.5,"ToDate":null}}]}]
Example 9
A URL for deleting events using a WHERE clause is shown.
https://sampleserver/arcgis/rest/services/MyLRS/MapServer/exts/LRServer/applyEdits?f=json&edits=[{"id":2,"deletes":[{"where":"RouteType = 'IN' and LaneCount < 3"}]}]
Example 10
A URL for deleting events by event ID is shown.
https://sampleserver/arcgis/rest/services/MyLRS/MapServer/exts/LRServer/applyEdits?f=json&edits=[{"id":4,"deletes":[{"eventId":500},{"eventId":501}]},{"id":1,"deletes":[{"eventId":"ABC123"}]}]
Example 11
A URL for adding calibration points is shown.
https://sampleserver/arcgis/rest/services/MyLRS/MapServer/exts/LRServer/applyEdits?f=json&edits=[{"id" : 0, "addCalibrationPoints" : [{ "networkLayerId": 2, "routeId": "US101", "fromDate": 1520318060000, "geometry": { "x":34, "y": 117}, "measure": 101 }] }]
Example 12
A URL for updating calibration points is shown.
https://sampleserver/arcgis/rest/services/MyLRS/MapServer/exts/LRServer/applyEdits?f=json&edits=[{"id" : 0, "updateCalibrationPoints" : [{ "objectId": 777, measure: 107 }] }]
Example 13
A URL for deleting calibration points is shown.
https://sampleserver/arcgis/rest/services/MyLRS/MapServer/exts/LRServer/applyEdits?f=json&edits=[{"id":0,"deleteCalibrationPoints":[{"objectId":777}]}]
Example 14
A URL for splitting a centerline is shown.
Note:
Centerlines cannot be split at endpoints.
https://sampleserver/arcgis/rest/services/MyLRS/MapServer/exts/LRServer/applyEdits?f=json&edits=[{"id":7,"splitCenterline":{"objectId":14166,"geometry":{"x":1276002.55695067,"y":12351516.6711279},"spatialReference":{"wkid":102013}}}]
Example 15
A URL for splitting centerlines into singlepart features is shown.
https://sampleserver/arcgis/rest/services/MyLRS/MapServer/exts/LRServer/applyEdits?f=json&edits=[{"id":7,"splitCenterlinesIntoSingleparts":{"objectIds":[14166,14177]}}]
Example 16
A URL for splitting an event is shown.
https://sampleserver/arcgis/rest/services/MyLRS/MapServer/exts/LRServer/applyEdits?f=json&edits=[{"id":2,"splitEvent":{"objectId":4801,"routeId":"{78F14930-E693-45A9-B895-6595932E5650}","measure":255.16499999999999,"fromDate":1651536000000,"toDate":253402300799999,"attributes":{"dblField":1,"NotNull":2},"attributes2":{"dblField":null,"NotNull":4}}}]
Example 17
A URL for merging two events is shown.
https://sampleserver/arcgis/rest/services/MyLRS/MapServer/exts/LRServer/applyEdits?f=json&edits=[{"id":2,"mergeEvents":{"objectIds":[4801,4802],"objectIdToPreserve":4801,"fromDate":1651536000000,"toDate":253402300799999,"attributes":{"dblField":1,"NotNull":2}}}]
JSON Response syntax
Example of a successful response
{
"success" : true
}
If an error occurs, the operation fails and rolls back, for example, if any line (or route) that is being edited has a lock.
{
"error" : { "code" : <errorCode>, "message" : "<errorMessage>" },
"missingLocks" :
{"networkId" : "<networkId>", "routeId" : "<routeId>"}, |
{"networkId" : "<networkId>", "lineId" : "<lineId>"}, ...}
}
Example of a successful split centerline response
Note:
At 10.9 or later, this result is an array of new centerline object IDs that were created as part of the split operation. In earlier releases, the response format had a single objectId value.
{
"objectIds": [newCenterlineOID1, newCenterlineOID2, ...]
}
Example of a successful split event or merge events response
{
"objectIds": [newEventOID1, newEventOID2, ...]
}