distance


URI

<geometry_uri>/distance[.<format>]

Supported methods

GET, HEAD

Parent resource

geometry

Introduction

distance represents an algorithm resource. As a child resource of geometry resource, it is used to calculating distance according to specified parameters (point2Ds and unit), which need to be included in URI and cannot be placed in the request body.

Supported Methods:

Supported output formats: RJSON, JSON, HTML, XML.

Resource hierarchy

HTTP request methods

Execute HTTP request on the following URI, here we take rjosn as the output format as an example. Where, supermapiserver is the server name.

http://supermapiserver:8090/iserver/services/geometry/restjsr/v1/geometry/distance.rjson

GET request

Used to calculates distance according to specified parameters.

Request parameter

The following request parameters used when calculating distance need to be containd in URI and cannot be placed in the request body.

Name Type Definition
point2Ds Point2D[] [Required] Points used to calculate distance.
unit Unit [Required] The expected unit of the returned result.
prjCoordSys PrjCoordSys

[Required]

The coordinate reference system of the points used to calculate distance.

You can build a PrjCoordSys object with its fields structure, and you also can build it by passing the epsgCode, such as:

prjCoordSys={"epsgCode":3857}.

_cache boolean

[Required]

Whether to use cache. Defaults to true. false means all the caches are disabled.

mode

DistanceMode[]

[Optional] Distance measurement mode. Including:

Geodesic: The geodesic mode, which means to calculate the shortest distance along the earth ellipsoid, is used by default.

Planar: Planar mode, which means to calculate two-point linear distance, only valid when the coordinate system of the points to be calcuted is the projection coordinate system.

Response structure

By executing a GET request on distance resource, the returned response structure is as follows:

Field Type Description
distance double Distance result.
unit Unit Unit of the distance result.

Response example

By executing a GET request on distance resource with URI: http://supermapiserver:8090/iserver/services/geometry/restjsr/v1/geometry/distance?point2Ds=[{%22x%22:%2023.00,%22y%22:34.00},{%22x%22:%2053.55,%22y%22:12.66},{%22x%22:%2073.88,%22y%22:12.6}]&unit=KILOMETER&prjCoordSys={epsgcode:4326}&distanceMode=Geodesic the returned response result in rjosn format is as follows:

{

  "area": -1,

  "distance": 6098.355576672728,

  "unit": "KILOMETER"

}

HEAD request

Returns the same HTTP response header as the GET request, but no response entity, which can be used to retrieve the meta data contained in response message header without having to transmit the entire response content. Meta data information includes media type, character coding, compression coding, entity content length, etc.

HEAD request is used to determine whether the distance resource exists, or if the client has the authority to access it. By executing an HEAD request with a .<format> URI, you can quickly determine whether the distance resource supports the <format> representation.

See