11.1.6. Miscellaneous

Get resource data

Geodatata can be fetched for vector and raster layers. For vector layers (PostGIS and Vector) geodata returns in GeoJSON or CSV formats. For raster layers (Raster, WMS) - tiles (:term`TMS`:) or image. For QGIS styles - qml file.

GeoJSON

The following request returns GeoJSON file from vector layer:

Не рекомендуется, начиная с версии 2.2.

GET /resource/(int: id)/geojson/

Добавлено в версии 3.0.

GET /api/resource/(int: id)/geojson

GeoJSON file request

Request Headers:
 
Parameters:
  • id – resource identificator
Status Codes:

Example request:

GET /api/resource/55/geojson HTTP/1.1
Host: ngw_url
Accept: */*

CSV

The following request returns CSV file from vector layer:

Добавлено в версии 3.0.

GET /api/resource/(int: id)/csv

CSV file request

Request Headers:
 
Parameters:
  • id – resource identificator
Status Codes:

Example request:

GET /api/resource/55/csv HTTP/1.1
Host: ngw_url
Accept: */*

TMS

The following request returns TMS from raster layer:

Не рекомендуется, начиная с версии 2.2.

GET /resource/(int: id)/tms?z=(int: z)&x=(int: x)&y=(int: y)

Добавлено в версии 3.0.

GET /api/component/render/tile?z=(int: z)&x=(int: x)&y=(int: y)&resource=(int: id1),(int: id2)...

Tile request

Request Headers:
 
Parameters:
  • id2 (id1,) – style resources id’s
  • z – zoom level
  • x – tile number on x axis (horisontal)
  • y – tile number on y axis (vertical)
Status Codes:

Примечание

Styles order should be from lower to upper.

Example request:

GET /api/component/render/tile?z=7&x=84&y=42&resource=234 HTTP/1.1
Host: ngw_url
Accept: */*

QML Style (QGIS Layer style)

The following request returns QML from QGIS style:

Добавлено в версии 3.0.1.

GET /api/resource/(int: id)/qml

QML file request

Request Headers:
 
Parameters:
  • id – resource identificator
Status Codes:

Example request:

GET /api/resource/56/qml HTTP/1.1
Host: ngw_url
Accept: */*

MVT (vector tiles)

MVT data can be fetched only for NextGIS Web vector layer.

The following request returns MVT data:

Добавлено в версии 3.0.3.

GET /api/resource/(int: id)/(int: z)/(int: x)/(int: y).mvt

MVT request

Request Headers:
 
Parameters:
  • id – resource identificator
  • z – zoom level
  • x – x tile column
  • y – y tile row
Status Codes:

Example request:

GET /api/resource/56/11/1234/543.mvt HTTP/1.1
Host: ngw_url
Accept: */*

Get resource permissions

To get resource permissions execute following request. Returned json may vary depends on resource type.

The following request returns resource permissions:

GET /api/resource/(int: id)/permission

Permissions request

Request Headers:
 
Parameters:
  • id – resource identificator
Status Codes:

Example request:

GET /api/resource/56/permission HTTP/1.1
Host: ngw_url
Accept: */*

Example response:

{
    "resource": {
        "read": true,
        "create": true,
        "update": true,
        "delete": true,
        "manage_children": true,
        "change_permissions": true
    },
    "datastruct": {
        "read": true,
        "write": true
    },
    "data": {
        "read": true,
        "write": true
    },
    "metadata": {
        "read": true,
        "write": true
    }
}

User managment

To get user desctription by it identificator execute following request:

Добавлено в версии 2.3.

GET /api/component/auth/user/(int: id)

Example request:

GET /api/component/auth/user/4 HTTP/1.1
Host: ngw_url
Accept: */*

Example response:

{
  "description": null,
  "disabled": false,
  "display_name": "\u0410\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440",
  "id": 4,
  "keyname": "administrator",
  "member_of": [
    5
  ],
  "superuser": false,
  "system": false
}

To create new user execute following request:

Добавлено в версии 2.3.

POST /api/component/auth/user/

Request to create new user.

Request Headers:
 
Request JSON Object:
 
  • display_name (string) – user full name
  • keyname (string) – user login
  • description (string) – user description
  • password (string) – user password
Response JSON Object:
 
  • id – new user identifier
Status Codes:

Example request:

POST /api/component/auth/user/ HTTP/1.1
Host: ngw_url
Accept: */*

{
  "description": null,
  "display_name": "another test",
  "keyname": "test1",
  "password": "test123"
}

Example response:

{
  "id": 4
}

To create new group execute following request:

Добавлено в версии 2.3.

POST /api/component/auth/group

Request to create new group

To self create user (anonymouse user) execute following request:

Добавлено в версии 2.3.

POST /api/component/auth/register

Request to create new user

Request Headers:
 
Request JSON Object:
 
  • display_name (string) – user full name
  • keyname (string) – user login
  • description (string) – user description
  • password (string) – user password
Status Codes:

Administrator can configure anonymous user registration to the specific group (via setting checkbox on group in administrative user interface).

This feature requires the special section in NGW config file:

[auth]
register = true

To get current user details execute following request:

POST /api/component/auth/current_user

Request to get current user details

Request Headers:
 
Response JSON Object:
 
  • keyname (string) – user login
  • display_name (string) – user name
  • id (int) – user identifier
Status Codes:

Example response:

{
    "keyname": "administrator",
    "display_name": "Администратор",
    "id": 4
}

Identification by polygon

To get features intersected by a polygon execute following request.

PUT /feature_layer/identify

Identification request

Request Headers:
 
Request JSON Object:
 
  • srs (int) – Spatial reference id
  • geom (string) – Polygon in WKT
Request JSON Array of Objects:
 
  • layers (int) – layes id array
Status Codes:

Example request:

POST /feature_layer/identify HTTP/1.1
Host: ngw_url
Accept: */*

{
    "srs":3857,
    "geom":"POLYGON((4188625.8318882 7511123.3382522,4188683.1596594 7511123.
                     3382522,4188683.1596594 7511180.6660234,4188625.8318882
                     7511180.6660234,4188625.8318882 7511123.3382522))",
    "layers":[2,5]
}

Example response:

{
  "2": {
    "featureCount": 1,
    "features": [
      {
        "fields": {
          "Id": 25,
          "name": "\u0426\u0435\u0440\u043a\u043e\u0432\u044c \u0412\u0432
                   \u0435\u0434\u0435\u043d\u0438\u044f \u041f\u0440\u0435
                   \u0441\u0432\u044f\u0442\u043e\u0439 \u0411\u043e\u0433
                   \u043e\u0440\u043e\u0434\u0438\u0446\u044b \u0432\u043e
                   \u0425\u0440\u0430\u043c \u043d\u0430 \u0411\u043e\u043b
                   \u044c\u0448\u043e\u0439 \u041b\u0443\u0431\u044f\u043d
                   \u043a\u0435, 1514-1925"
        },
        "id": 3,
        "label": "#3",
        "layerId": 2
      }
    ]
  },
  "5": {
    "featureCount": 0,
    "features": []
  },
  "featureCount": 1
}