Hide Table of Contents
esri/dijit/util
esri/layer/pixelFilters
esri/process
esri/support
esri/workers
Class: LengthsParameters

require(["esri/tasks/LengthsParameters"], function(LengthsParameters) { /* code goes here */ });

Description

(Added at v2.0)
Sets the length units and other parameters for Lengths operation.

Samples

Search for samples that use this class.

Constructors

NameSummary
new LengthsParameters()Creates a new LengthsParameter object.

Properties

NameTypeSummary
calculationTypeStringDefines the type of calculation for the geometry.
geodesicBooleanIf polylines are in geographic coordinate system, then geodesic needs to be set to true in order to calculate the ellipsoidal shortest path distance between each pair of the vertices in the polylines.
lengthUnitNumber | StringThe length unit in which perimeters of polygons will be calculated.
polylinesGeometry[]The array of polylines whose lengths are to be computed.
Constructor Details

new LengthsParameters()

Creates a new LengthsParameter object.
Property Details

<String> calculationType

Defines the type of calculation for the geometry. The type can be one of the following:
  • planar: Planar measurements use 2D Cartesian mathematics to calculate length. Use this type if the length needs to be calculated in the input spatial reference otherwise use preserveShape.
  • geodesic: Use this type to calculate an area or length using only the vertices of the polygon to define the lines connecting the vertices as geodesic segments independent of the actual shape of the polygon. Note: a geodesic segment is the shortest path between two points on an ellipsoid.
  • preserveShape: Calculate the area or length of the geometry on the surface of the Earth ellipsoid, for geometries defined in a projected or geographic coordinate system. This method preserves the shape of the geometry in its coordinate system which means the true area or length will be calculated for the geometry that is displayed on the map.
Requires ArcGIS Server 10.1 or greater (Added at v3.0)
Sample:

lengthParams.calculationType = 'preserveShape';

<Boolean> geodesic

If polylines are in geographic coordinate system, then geodesic needs to be set to true in order to calculate the ellipsoidal shortest path distance between each pair of the vertices in the polylines. The output if lengthUnit if not specified is returned in meters.

Note:If you are using an ArcGIS Server 10.1 or greater then use the calculationType property instead.

Known values: true | false
Sample:

lengthParams.geodesic = true;

<Number | String> lengthUnit

The length unit in which perimeters of polygons will be calculated. See the constants table of GeometryService for a list of valid values.
Sample:
require([
  "esri/tasks/LengthsParameters", "esri/tasks/GeometryService", ... 
], function(LengthsParameters, ... ) {
  var lengthParams = new LengthsParameters();
  lengthParams.lengthUnit = GeometryService.UNIT_METER;
  ...
});

<Geometry[]> polylines

The array of polylines whose lengths are to be computed. The spatial reference of the polylines is specified by sr. The structure of each polyline in the array is same as the structure of the JSON polyline objects returned by the ArcGIS REST API.
Sample:

lengthParams.polylines = [geometry];

Show Modal