Publish and use ArcGIS Server services - feature service (feature server)

I wrote about mapserver and imageserver before, and I have been thinking about writing an operation tutorial for ArcGIS Server to publish feature services (featureserver), but I have not freed up. Recently, I have carefully sorted out the definition of feature services, data production and finally How to publish Introduction to the understanding of element services;

Still in the original way, let's first summarize why we wrote this blog post, and then introduce the principle and operation of element services;

Why write this blog post:

People often get very confused about the various services of arcgis: map service: publish and use ArcGIS Server service - map service (Mapserver)
feature service: publish and use ArcGIS Server service - feature server (feature server)
image service: Publish and use ArcGIS Server service - image service (image server)
OGC service: publish and use ArcGIS Server service - OGC service (WMS/WMTS/WFS/WCS/WPS)
cache service: publish and use ArcGIS Server service - cache Service (TileServer) (1)
Cache service: manage and migrate ArcGIS Server service and cache service (TileServer) (2)
Geoprocessing service, vector tile service, scene service,
geographic data service, and geometry service, KML service, geocoding service , Locator Maritime Server, Path Service, Schematics Service, Flow Service, Public Facilities Network Service, Workflow Manager Service, etc.; this article is to sort out the operation of Feature Server;

The software environment used in this article is: ArcGIS version 10.8.1, PostgreSql 9.4; For those who don’t care about the definition and concept of feature services, you can skip directly to 5. Feature service preparation/registration/publishing—operation examples and 6. ArcGIS API for JavaScript calls the service to publish and call;

If you want to have a more comprehensive understanding of the services of arcgis server, please follow the link: A brief introduction to the various service types of arcgis server

1. What is the difference between a feature service and a hosted feature service?

1.1 Official definition of element services

First understand that the Feature Service feature service is a service type running on the ArcGIS GIS Server site .

Feature services allow you to make feature data and nonspatial tables stored in databases available on the Internet or an intranet .

The data of the Feature Service is stored in a database accessed through ArcSDE (such as PostgreSQL, SQL Server or Oracle). Before creating data, you need to configure the SDE connection in arcmap, and then you can operate the enterprise-level geodatabase to create feature classes.

1.2 What is a hosted feature service

Managed feature service, as the name implies, is to store data in the managed library of ArcGIS Data store and publish it as a feature service ;

What is ArcGIS Data store? There are three libraries in it: relational library, slice library, and space-time library. One of them is a relational database, which is still a PG library in essence, and is used to store managed feature services published by the portal; for details, please refer to
:
Click on ArcGIS Data Store's spatial database (relational library/slicing library/time-space library) A little thing about the experience of the beginning of love

1.3 What is the difference between a feature service and a hosted feature service?

common ground :

Both belong to the category of feature services, and both can be implemented to allow you to use and modify feature data and non-spatial tables stored in databases on the Internet or Intranet .

difference:

Both are data stored in the database, and the feature service is to register SDE through arcmap and then publish the feature class in sde;

The hosted feature service can be published through arcgis Pro, arcmap or portal. After publishing, the data is stored in the ArcGIS Data store, and the hosted feature service is called to edit and modify, which modifies the feature class stored in the ArcGIS Data store;

Of course publishing a hosted feature service with support for multiple sources allows you to do this. Hosted feature layers can be published in any of the following ways:

Comma-separated value (CSV) file
containing coordinates or addresses Microsoft Excel file (.xlsx or .xls) containing coordinates or addresses
GeoJSON file or zipped shapefile
feature collection
Zipped file geodatabase
ArcGIS Pro map and ArcMap document
template or existing feature map layer

1.4. Why publish element services?

When operating the urls of various types of services on the web side, the functions and positioning of each service are different; but if you need to implement the online editing function of ArcGIS Server and edit and modify the function of local data that can be saved in real time , this time we need to use Feature Service;

Here's an overview of why you should use feature services:

  • I need to keep my data in my source enterprise geodatabase or database because other applications access my system of record.

  • I want to quickly share all feature classes and tables accessed through a database connection file to allow other members of my ArcGIS—Enterprise portal to view the data.

  • There is no immediate need for custom symbology and extents in the layer.

  • Editors will update the data directly in the data source, and I want those changes to be reflected in the feature service.
    Tip: You can choose to publish only one map service if you want to access data in an enterprise geodatabase or database as read-only features.

  • In addition to the previous requirements, I also want other people to edit the data through the feature service, and when they access it through other clients, I can see the changes to the data source as well.

  • Others need to edit feature services while disconnected from the network, but I want their offline edits to be synced with my system of record.

  • I have file data sources such as CSV, Microsoft Excel spreadsheets, and shapefiles that I want to create a feature service from.

  • Data exists in my geodatabase or database, but I also want to create a copy of the data to share with the public and for community input.

  • I have data in my geodatabase or database, but I also want to create a copy of the data to share with my organization or some members of my organization.

  • I use ArcGIS GeoEvent Server to stream real-time data, but would like to archive some of it locally.

2. Applicable requirements for element service data sources

2.1 Whether the data source is stored in a database, workgroup geodatabase, or enterprise geodatabase, the following requirements apply:

(1) Data published to a feature service must come from a single source geodatabase or database. It is not possible to publish data from multiple database connections in a single map.

(2) A valid spatial reference must be defined for the data. If not defined, it is specified in ArcMap or ArcGIS Pro before publishing. Data cannot be published without a spatial reference defined.

(3) View-based layers do not support feature services. Publishing a feature service containing a view is not supported because the view cannot be edited using an ArcGIS client, but the feature service can be enabled for editing. To use the data in a view for reference in a map or application, publish the view in a map service.

(4) The database account stored together with the database connection file registered to the GIS Server site must have the required permissions to access the data. If the feature service will remain read-only, the account only needs to choose access permissions for the data. If you want to use a feature service for editing, you must grant edit permissions to the data. If the database connection registered to the site uses operating system authentication, the ArcGIS Server account must be granted these permissions.

(5) It is recommended to include only data to be edited in maps published as editable feature services. Publish data that you don't want to edit, such as basemap layers, as another service.

2.2 Enterprise or Workgroup Geodatabase Specific Requirements

The feature service requirements listed here are specific to data stored in an enterprise or workgroup geodatabase. Your data needs to meet the requirements described in the sections above, as well as the requirements described in this section.

(1) Tables or feature classes that are not registered in the geodatabase can be published; however, views are not supported.

(2) If editing is permitted on a feature service, and the feature service contains feature classes participating in a geometric network, the feature class data must be in the same projection and coordinate reference system as the editing client application. For example, if you plan to add a feature service to Map Viewer for editing, the data must be stored in WGS 1984 Web Mercator (Auxiliary Sphere). You cannot just change the projection in ArcMap or the ArcGIS Pro map before publishing; the data must use the same projection or coordinate reference system as the editing client.

(3) Versioned (traditional and branched) and non-versioned geodatabase data are supported in feature services. It is recommended that you use nonversioned data in feature services because the scale range of nonversioned data is more editable. There are also some complex data types (for example, network edges), however, they must be versioned in order to be editable through the feature service.
To edit branch versioned data, you must publish the feature layer in ArcGIS Pro that references the registered data.

(4) You cannot publish feature access enabled map services through ArcMap documents, or feature layers that reference registered data through ArcGIS Pro, if any of the following layers exist in the map: (dimension/layer
group/based on Layers and tables for views/query layers/rasters/Terrains including virtual columns, where clauses, or joins)

(5) When publishing layers that reference registered data through ArcGIS Pro, you can include annotation layers in the map. Annotation layers cannot be included when publishing a feature access enabled map service from an ArcMap map document.
The parcel fabric is always read-only when accessed through a feature service.

(6) Layers belonging to complex types (such as geometric networks and network datasets) can be published, but feature services do not return the types themselves. For example, you can query layers participating in a network dataset, but not the network.

(7) Beginning at 10.8.1, you can include a topology that contains branched versioned feature classes in a feature service. Because you can only edit branch-versioned data through a feature service, you can include the topology in the feature service to validate the topology after editing and to correct any topology errors caused by the edits.

(8) Feature services allow queries on related data only when the relationship is defined through a geodatabase relationship class. When a published map document has layers and tables related through a geodatabase relationship class, the feature service allows queries on the layers to return objects in the related table. To support queries that return related objects, the tables and layers involved in the relationship class must be included in the published map document. If the original or target layer or table is not contained in the map document, the feature service will ignore the relationship.
Note:
For attribute relationship classes, the relationship class table needs to be included in the map document.

(9) To maintain a utility network, you must publish it as a feature layer through ArcGIS Pro.

4. Use the feature service method and client

4.1 ArcGIS API for JavaScript client

ArcGIS API for JavaScript provides the most advanced web editing capabilities and customization options. If you enjoy programming with this API, you can provide web users with a cutting-edge experience by tailoring your editing scheme to specific purposes, goals, or organizational policies. For example, you can use ArcGIS API for JavaScript to:

Edit "selection-only" layers
Track edits (for enterprise geodatabases, not available in databases.)
Use ownership-based access control to control access to features
Prevent users from editing feature geometry Dynamically
create, delete, and change geodatabase version
edits Cartographic representations
Get a REST endpoint for a feature service
You can get a REST endpoint or URL link for a feature service by browsing to the service in the ArcGIS Server Services Catalog. For example, the default URL for a feature service in the Services Catalog is http://gisserver.domain.com:6080/arcgis/rest/services/folder/service/FeatureServer. A zero-based integer can be appended to the URL to refer to a specific layer within the service. For example, if the URL link ends with /0, it refers to the first layer in the service.

4.2 ArcGIS Desktop

ArcGIS Desktop allows you to edit data in feature services. The workflow for editing in ArcGIS Desktop is fundamentally different from editing a feature service through a web application.

4.3 Keeping in sync with feature services (ArcGIS REST API)

Feature services include operations that support offline editing workflows. In an offline environment, a client (for example, a runtime or mobile device) can make local edits and synchronize content changes with the server when the client reconnects to the feature service. This feature is called synchronization and is available through the ArcGIS REST API.

Note: The following is the unfinished part. I will give him a screenshot next week and write a detailed process;

5. Element service preparation/registration/release—operation example

5.1 Arcmap publishes feature services

To publish feature services in arcmap, you first need to have an enterprise-level geographic database, so some friends will ask, what is the difference between an enterprise-level geographic database and an ordinary database?
First of all, spatial databases are divided into three types: personal geographic database (.mdb), file geographic library (.gdb), and enterprise geographic database (.sde); and our sde is enterprise geographic data, which actually exists in the common database SQL Server , Oracle, PostgreSQL and other databases, a spatial type of relational database;

Then we have this enterprise-level geographic database, and we can import our shp data into sde to become a feature class (feature class);

Next, you only need to register the enterprise-level geographic database on the server, and then publish it as a feature service;
(1) Create an enterprise-level geographic database in ArcGIS desktop.
Before creating sde, the computer must have PG installed, and the editor installed PG9.6 on this machine;
insert image description here

Then with sde, we can use the Create Enterprise Geodatabase in the toolbox to create our own spatial database in PG;

insert image description here
insert image description here
1) Database platform: PostgreSQL

2) Example: refers to the address of the database you connect to, my local IP is 192.168.0.173

3) Database: qw, which is the name of the enterprise-level geographic database prepared for ArcGIS in PG

4) Database administrator: PG administrator account

5) Geodatabase administrator: the account of the ArcGIS administrator, the default is sde

6) Authorization file:
This license file has two authorizations,

  • One is the .ecp license file of arcgis server;
  • One is where the arcgis server license is written to the computer. My location is as follows:
    C:\Program Files (x86)\ESRI\License10.7\sysgen
    C:\Program Files\ESRI\License10.7\sysgen
    insert image description here
    This example creates A spatial relational database named qw;

(2) Connect to the database in ArcGIS desktop
insert image description here
insert image description here


(3) There are two registration methods for registering the enterprise-level geographic database to the server :
first, register the enterprise-level geographic data on the server before publishing:
insert image description here
insert image description here
insert image description here
click ok;
insert image description here
insert image description here
second:
when publishing again, an error will be reported during analysis: Just click to register; as shown below:

insert image description here

(4) Arcmap publishes feature services
Since I use the first type of registration, I register the enterprise-level geographic database on the server before publishing;
so we can directly create a new data release;

The figure below shows that we can import existing shp data into our enterprise-level geographic database and create our own data;

insert image description here
The following figure shows that we create new data in our own enterprise-level geographic database, and then click File -> Share in -> Service to open the share as service panel, click Publish Service: publish the entire operation process of feature class as feature server:
insert image description here
After publishing, let's go to the server to check:
insert image description here
insert image description here

5.2 arcgis pro publish map service

(1) Create an enterprise-level geographic database in ArcGIS Pro.
This step can be done in arcmap; it can also be done in arcgis Pro; then let's take a look at where these toolboxes and links are located. The parameters of the tools are the same, so we won't operate them one by one;
First create an enterprise-level geographic database, which is also in the data management toolbox:
insert image description here
(2) Connect to the database in ArcGIS Pro
Then the link to the created sde can be in the catalog:
insert image description here
or in the menu bar:
insert image description here

insert image description here
The linked sde is like this:
insert image description here

(3) arcgis pro registration and publishing feature services
insert image description here

(4) Go to the portal to verify the released feature services;
insert image description here
Note: Since the map service is the basis, when publishing, it will release the map service by default; that is to say, when we release the feature service, both the portal and the server There are two services, one is feature service and the other is map service; we only need to call the URL of the corresponding service when developing JS;

6. ArcGIS API for JavaScript call service

The JS layer sets the classes corresponding to different services for processing:
ElevationLayer
FeatureLayer
ImageryLayer
IntegratedMeshLayer
MapImageLayer
MapNotesLayer
PointCloudLayer
SceneLayer
StreamLayer
TileLayer
VectorTileLayer
CSVLayer
GeoRSSLayer
GraphicsLayer
GroupLayer
KMLLayer
OpenStreetMapLayer er
WebTileLayer
WMSLayer
WMTSLayer

We locate the layer level of the feature service:
insert image description here
, and then copy the url: https://t460p.esrichina.com/server/rest/services/test1010/FeatureServer/0

When calling the feature service in JS, the featurelayer class is used. The following is my test code;

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <meta
      name="viewport"
      content="initial-scale=1,maximum-scale=1,user-scalable=no"
    />
    <title>
      Intro to FeatureLayer | Sample | ArcGIS API for JavaScript 4.17
    </title>

    <link
      rel="stylesheet"
      href="https://js.arcgis.com/4.17/esri/themes/light/main.css"
    />
    <script src="https://js.arcgis.com/4.17/"></script>

    <style>
      html,
      body,
      #viewDiv {
    
    
        padding: 0;
        margin: 0;
        height: 100%;
        width: 100%;
      }
    </style>

    <script>
      require([
        "esri/Map",
        "esri/views/MapView",
        "esri/layers/FeatureLayer"
      ], function (Map, MapView, FeatureLayer) {
    
    
        var map = new Map({
    
    
          basemap: "topo"
        });

        var view = new MapView({
    
    
          container: "viewDiv",
          map: map,

          extent: {
    
    
            // autocasts as new Extent()
            xmin: -47.628,
            ymin: -7.808,
            xmax: -0.269,
            ymax: 29.76570000,
            spatialReference: 102100
          }
        });

        /********************
         * Add feature layer
         ********************/

        // Carbon storage of trees in Warren Wilson College.
        var featureLayer = new FeatureLayer({
    
    
          url:
            "https://t460p.esrichina.com/server/rest/services/test1010/FeatureServer/0"
        });

        map.add(featureLayer);
      });
    </script>
  </head>

  <body>
    <div id="viewDiv"></div>
  </body>
</html>

If you need to test, locate your own rest service and modify the extent:
insert image description here

The specific display effect of the JS call is as follows:insert image description here

Guess you like

Origin blog.csdn.net/weixin_40625478/article/details/108377466