• ArcGIS Server在线编辑功能


    如何通过javascript调用REST服务实现编辑功能呢?

    Apply Edits (Feature Service)应用编辑(要素服务)

    URL:http://<featureservice-url>/applyEdits(POST only)

    Required Capability:Create,Update,Delete. Create required to add features, Update required to update features, and Delete required to delete features.

    需要的功能:创建,更新,删除。Create用来添加要素,Update用来更新要素,Delete用来删除要素。

    Version Introduced:10.1

     

    Description描述

    This operation is supported at 10.1 and later.

    该操作支持10.1和以上的版本。

    The applyEdits operation applies edits to features associated with multiple layers or tables in a single call (POST only). This operation is performed on a feature service resource. The result of this operation is an array of edit results for each layer/table edited. Each edit result identifies a single feature on a layer or table and indicates whether the edits were successful or not. If an edit is not successful, the edit result also includes an error code and an error description.

    applyEdits操作在一次调用中对与多个图层或表格关联的要素应用编辑(仅限POST)。该操作在要素服务资源上执行。该操作的结果是返回编辑结果。每个编辑结果标识图层或表格上的单个要素,并指示编辑是否成功。如果编辑不成功,则编辑结果还包括错误代码和错误说明。

    You can provide arguments to the applyEdits operation as defined in the following parameters table:

    可以按照以下参数表中的定义为applyEdits操作提供参数:

    Request parameters请求参数

     

    Parameter参数

    Details详情

    f

    Description: The response format. The default response format is html.

    描述:响应格式。默认的返回格式为html。

    Values: html | json

    edits

    Description: The array of layers to be edited.

    描述:需要编辑的图层。

    Features to be added or updated to a feature layer should include the geometry.

    对于要素图层,需要添加的要素,或者更新,应该包含几何信息。

    Records to be added or updated to a table should not include the geometry.

    对于表格来说,添加的记录或者更新,不应该包括几何信息。

    For features that are updated, the attributes property of the feature should include the object ID of the feature along with the other attributes:

    对于需要更新的要素,要素的属性属性应该包含object ID,和其他属性:

     
    "attributes" : {
      "OBJECTID" : 37,
      "OWNER" : "Joe Smith",
      "VALUE" : 94820.37,
      "APPROVED" : true,
      "LASTUPDATE" : 1227667627940
    }
    

    Syntax:语法:

     
    [
    { "id" : <layerId1>,
        "adds" : [<feature1>, <feature2>],
        "updates" : [<feature1>, <feature2>],
        "deletes" : [<objectID1>, <objectID2>]
    },
    { "id" : <layerId2>,
        "adds" : [<feature1>, <feature2>],
        "updates" : [<feature1>, <feature2>],
        "deletes" : [<objectID1>, <objectID2>]
    }  
    ]
    

    Example:例子:

     
    [
        {
             "id" : 0,
            "adds" : [
                {
                    "geometry" : {
        		     "x": -143.501,
        		     "y": 57.043000000000006
                    },
                    "attributes" : {
                        "datetime" : 1272210710000,
                        "depth" : 31.100000000000001,
                        "region" : "Andreanof Islands, Aleutian Islands, Alaska" 
                    } 
                },
                {
                    "geometry" : {
                        	"x" : -72.865099999999927,
                        "y" : -37.486599999999953 
                    },
                    "attributes" : {
                        "datetime" : 1272210142999,
                        "depth" : "40.x",
                        "region" : "Bio-Bio, Chile" 
                    } 
                } 
            ],
             "updates" : [
                {
                    "geometry" : {
                        "x" : -149.450,
                        "y" : 60.120 
                    },
                    "attributes" : {
                        "OBJECTID" : 50,
                        "datetime" : 1272210710000,
                        "region" : "Andreanof Islands, Aleutian Islands, Alaska" 
                    } 
                } 
            ],
            "deletes" : [
                19,23 
            ] 
        },
        {
            "id" : 1,
            "deletes" : [
                34,44 
            ] 
        } 
    ]
    
    gdbVersion

    //This option was added at 10.1

    Description: Geodatabase version to apply the edits. This parameter applies only if the isDataVersioned property of the layer is true.

    If the gdbVersion parameter is not specified, edits are made to the published map’s version.

    Syntax: gdbVersion=<version>

    Example: gdbVersion=SDE.DEFAULT

    rollbackOnFailure

    //This option was added at 10.1

    Description: Optional parameter to specify if the edits should be applied only if all submitted edits succeed. If false, the server will apply the edits that succeed even if some of the submitted edits fail. If true, the server will apply the edits only if all edits succeed. The default value is true.

    Not all data supports setting this parameter. Query the supportsRollbackonFailureParameter property of the layer to determine whether or not a layer supports setting this parameter. If supportsRollbackOnFailureParameter = false for a layer, then when editing this layer, rollbackOnFailure will always be true, regardless of how the parameter is set. However, if supportsRollbackonFailureParameter = true, this means the rollbackOnFailure parameter value will be honored on edit operations.

    Values: true|false

    Example: rollbackOnFailure=true

    Example usage

    Apply edits on a feature service resource:

    http://services.myserver.com/lidGgNLxw9LL0SbI/ArcGIS/rest/services/PoolPermits/FeatureServer/applyEdits

    Sample input for adds, represented by an array of features:

     
    [
        {
            "id" : 0,
            "adds" : [
                {
                    "geometry" : {
        		            "x": -143.501,
        		            "y": 57.043000000000006
                    },
                    "attributes" : {
                        "datetime" : 1272210710000,
                        "depth" : 31.100000000000001,
                        "region" : "Andreanof Islands, Aleutian Islands, Alaska" 
                    } 
                },
                {
                    "geometry" : {
                        	"x" : -72.865099999999927,
                        "y" : -37.486599999999953 
                    },
                    "attributes" : {
                        "datetime" : 1272210142999,
                        "depth" : "40.x",
                        "region" : "Bio-Bio, Chile" 
                    } 
                } 
            ],
            "updates" : [
                {
                    "geometry" : {
                        "x" : -149.450,
                        "y" : 60.120 
                    },
                    "attributes" : {
                        "OBJECTID" : 50,
                        "datetime" : 1272210710000,
                        "region" : "Andreanof Islands, Aleutian Islands, Alaska" 
                    } 
                } 
            ],
            "deletes" : [
                19,23 
            ] 
        },
        {
            "id" : 1,
            "deletes" : [
                34,44 
            ] 
        } 
    ]
    

    JSON response syntax

     

     
    [
      {   
        "id" : <layerId1>,
        "addResults" : [
        {
          "objectId" : <objectId1>,
          "globalId" : <globalId1>,
          "success" : <true | false>,
          "error" : { //only if success is false
            "code" : <code1>,
            "description" : "<description1>",
          }
        },
        {
          "objectId" : <objectId2>,
          "globalId" : <globalId2>,
          "success" : <true | false>,
          "error" : { //only if success is false
            "code" : <code2>,
            "description" : "<description2>",
          }
        }
      ],
      "updateResults" : [
        {
          "objectId" : <objectId1>,
          "globalId" : <globalId1>,
          "success" : <true | false>,
          "error" : { //only if success is false
            "code" : <code1>,
            "description" : "<description1>",
          }
        },
        {
          "objectId" : <objectId2>,
          "globalId" : <globalId2>,
          "success" : <true | false>,
          "error" : { //only if success is false
            "code" : <code2>,
            "description" : "<description2>",
          }
        }
      ],
      "deleteResults" : [
        {
          "objectId" : <objectId1>,
          "globalId" : <globalId1>,
          "success" : <true | false>,
          "error" : { //only if success is false
            "code" : <code1>,
            "description" : "<description1>",
          }
        },
        {
          "objectId" : <objectId2>,
          "globalId" : <globalId2>,
          "success" : <true | false>,
          "error" : { //only if success is false
            "code" : <code2>,
            "description" : "<description2>",
          }
        }
      ]
    },
    {   
        "id" : <layerId2>,
        "addResults" : [
        {
          "objectId" : <objectId1>,
          "globalId" : <globalId1>,
          "success" : <true | false>,
          "error" : { //only if success is false
            "code" : <code1>,
            "description" : "<description1>",
          }
        },
        {
          "objectId" : <objectId2>,
          "globalId" : <globalId2>,
          "success" : <true | false>,
          "error" : { //only if success is false
            "code" : <code2>,
            "description" : "<description2>",
          }
        }
      ],
      "updateResults" : [
        {
          "objectId" : <objectId1>,
          "globalId" : <globalId1>,
          "success" : <true | false>,
          "error" : { //only if success is false
            "code" : <code1>,
            "description" : "<description1>",
          }
        },
        {
          "objectId" : <objectId2>,
          "globalId" : <globalId2>,
          "success" : <true | false>,
          "error" : { //only if success is false
            "code" : <code2>,
            "description" : "<description2>",
          }
        }
      ],
      "deleteResults" : [
        {
          "objectId" : <objectId1>,
          "globalId" : <globalId1>,
          "success" : <true | false>,
          "error" : { //only if success is false
            "code" : <code1>,
            "description" : "<description1>",
          }
        },
        {
          "objectId" : <objectId2>,
          "globalId" : <globalId2>,
          "success" : <true | false>,
          "error" : { //only if success is false
            "code" : <code2>,
            "description" : "<description2>",
          }
        }
      ]
    }
    ]
    

    JSON response example

    [
     {
      "id": 0,
      "addResults": [
       {
        "objectId": 617,
        "globalId" : "{be6557a4-2204-4a66-a901-7295080003a6}",
        "success": true
       },
       {
        "success": false,
        "error": {
         "code": -2147217395,
         "description": "Setting of Value for depth failed."
        }
       }
      ],
      "updateResults": [
       {
        "objectId": 50,
        "globalId" : "{09b3b932-a75c-4438-837e-9a17f84113d5}",
        "success": true
       }
      ],
      "deleteResults": [
       {
        "objectId": 19,
        "success": true
       },
       {
        "objectId": 23,
        "success": true
       }
      ]
     },
     {
      "id": 1,
      "deleteResults": [
       {
        "objectId": 34,
        "success": true
       },
       {
        "objectId": 44,
        "success": true
       }
      ]
     }
    ]

     得用什么js库实现json的服务调用呢?

    https://www.imooc.com/wenda/detail/606042

    Openlayer调用arcgis的REST服务的代码https://www.osgeo.cn/info/21a83  https://www.cnblogs.com/janehlp/p/3269692.html

    ArcGIS Server JavaScript REST:https://www.cnblogs.com/esrichina/archive/2013/05/24/3096938.html

    REST和JSON的关系:REST是一种服务设计规范,JSON是一种数据传输格式。它们共同组成了API

    ArcGIS JavaScript API开发:https://wenku.baidu.com/view/ec103b52ad02de80d4d84058.html

    javascript调用REST服务:https://www.cnblogs.com/johnonsoftware/p/3757249.html  https://www.imooc.com/wenda/detail/606042

  • 相关阅读:
    Using sudo inside a docker container
    python enumerate用法总结
    如何保存Keras模型
    python pickle模块
    如何选择开源项目的license
    github在线创建文件夹
    关于python3.4版本中的zip函数
    使用sqoop 在关系型数据库和Hadoop之间实现数据的抽取
    HBase Shell 常见操作
    Java API 实现HBase的数据添加与过滤查询
  • 原文地址:https://www.cnblogs.com/2008nmj/p/14067103.html
Copyright © 2020-2023  润新知