Simplify typing in EsriJSON format
This commit is contained in:
+14
-18
@@ -410,15 +410,15 @@ function readPolygonGeometry(object) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {import("../geom/Geometry.js").default} geometry Geometry.
|
* @param {import("../geom/Point.js").default} geometry Geometry.
|
||||||
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
|
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
|
||||||
* @return {EsriJSONPoint} EsriJSON geometry.
|
* @return {EsriJSONPoint} EsriJSON geometry.
|
||||||
*/
|
*/
|
||||||
function writePointGeometry(geometry, opt_options) {
|
function writePointGeometry(geometry, opt_options) {
|
||||||
const coordinates = /** @type {import("../geom/Point.js").default} */ (geometry).getCoordinates();
|
const coordinates = geometry.getCoordinates();
|
||||||
/** @type {EsriJSONPoint} */
|
/** @type {EsriJSONPoint} */
|
||||||
let esriJSON;
|
let esriJSON;
|
||||||
const layout = /** @type {import("../geom/Point.js").default} */ (geometry).getLayout();
|
const layout = geometry.getLayout();
|
||||||
if (layout === GeometryLayout.XYZ) {
|
if (layout === GeometryLayout.XYZ) {
|
||||||
esriJSON = {
|
esriJSON = {
|
||||||
x: coordinates[0],
|
x: coordinates[0],
|
||||||
@@ -466,12 +466,11 @@ function getHasZM(geometry) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {import("../geom/Geometry.js").default} geometry Geometry.
|
* @param {import("../geom/LineString.js").default} lineString Geometry.
|
||||||
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
|
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
|
||||||
* @return {EsriJSONPolyline} EsriJSON geometry.
|
* @return {EsriJSONPolyline} EsriJSON geometry.
|
||||||
*/
|
*/
|
||||||
function writeLineStringGeometry(geometry, opt_options) {
|
function writeLineStringGeometry(lineString, opt_options) {
|
||||||
const lineString = /** @type {import("../geom/LineString.js").default} */ (geometry);
|
|
||||||
const hasZM = getHasZM(lineString);
|
const hasZM = getHasZM(lineString);
|
||||||
return {
|
return {
|
||||||
hasZ: hasZM.hasZ,
|
hasZ: hasZM.hasZ,
|
||||||
@@ -484,12 +483,11 @@ function writeLineStringGeometry(geometry, opt_options) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {import("../geom/Geometry.js").default} geometry Geometry.
|
* @param {import("../geom/Polygon.js").default} polygon Geometry.
|
||||||
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
|
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
|
||||||
* @return {EsriJSONPolygon} EsriJSON geometry.
|
* @return {EsriJSONPolygon} EsriJSON geometry.
|
||||||
*/
|
*/
|
||||||
function writePolygonGeometry(geometry, opt_options) {
|
function writePolygonGeometry(polygon, opt_options) {
|
||||||
const polygon = /** @type {import("../geom/Polygon.js").default} */ (geometry);
|
|
||||||
// Esri geometries use the left-hand rule
|
// Esri geometries use the left-hand rule
|
||||||
const hasZM = getHasZM(polygon);
|
const hasZM = getHasZM(polygon);
|
||||||
return {
|
return {
|
||||||
@@ -501,12 +499,11 @@ function writePolygonGeometry(geometry, opt_options) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {import("../geom/Geometry.js").default} geometry Geometry.
|
* @param {import("../geom/MultiLineString.js").default} multiLineString Geometry.
|
||||||
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
|
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
|
||||||
* @return {EsriJSONPolyline} EsriJSON geometry.
|
* @return {EsriJSONPolyline} EsriJSON geometry.
|
||||||
*/
|
*/
|
||||||
function writeMultiLineStringGeometry(geometry, opt_options) {
|
function writeMultiLineStringGeometry(multiLineString, opt_options) {
|
||||||
const multiLineString = /** @type {import("../geom/MultiLineString.js").default} */ (geometry);
|
|
||||||
const hasZM = getHasZM(multiLineString);
|
const hasZM = getHasZM(multiLineString);
|
||||||
return {
|
return {
|
||||||
hasZ: hasZM.hasZ,
|
hasZ: hasZM.hasZ,
|
||||||
@@ -517,12 +514,11 @@ function writeMultiLineStringGeometry(geometry, opt_options) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {import("../geom/Geometry.js").default} geometry Geometry.
|
* @param {import("../geom/MultiPoint.js").default} multiPoint Geometry.
|
||||||
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
|
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
|
||||||
* @return {EsriJSONMultipoint} EsriJSON geometry.
|
* @return {EsriJSONMultipoint} EsriJSON geometry.
|
||||||
*/
|
*/
|
||||||
function writeMultiPointGeometry(geometry, opt_options) {
|
function writeMultiPointGeometry(multiPoint, opt_options) {
|
||||||
const multiPoint = /** @type {import("../geom/MultiPoint.js").default} */ (geometry);
|
|
||||||
const hasZM = getHasZM(multiPoint);
|
const hasZM = getHasZM(multiPoint);
|
||||||
return {
|
return {
|
||||||
hasZ: hasZM.hasZ,
|
hasZ: hasZM.hasZ,
|
||||||
@@ -533,13 +529,13 @@ function writeMultiPointGeometry(geometry, opt_options) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {import("../geom/Geometry.js").default} geometry Geometry.
|
* @param {import("../geom/MultiPolygon.js").default} geometry Geometry.
|
||||||
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
|
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
|
||||||
* @return {EsriJSONPolygon} EsriJSON geometry.
|
* @return {EsriJSONPolygon} EsriJSON geometry.
|
||||||
*/
|
*/
|
||||||
function writeMultiPolygonGeometry(geometry, opt_options) {
|
function writeMultiPolygonGeometry(geometry, opt_options) {
|
||||||
const hasZM = getHasZM(/** @type {import("../geom/MultiPolygon.js").default} */(geometry));
|
const hasZM = getHasZM(geometry);
|
||||||
const coordinates = /** @type {import("../geom/MultiPolygon.js").default} */ (geometry).getCoordinates(false);
|
const coordinates = geometry.getCoordinates(false);
|
||||||
const output = [];
|
const output = [];
|
||||||
for (let i = 0; i < coordinates.length; i++) {
|
for (let i = 0; i < coordinates.length; i++) {
|
||||||
for (let x = coordinates[i].length - 1; x >= 0; x--) {
|
for (let x = coordinates[i].length - 1; x >= 0; x--) {
|
||||||
|
|||||||
@@ -718,8 +718,7 @@ class WKT extends TextFeature {
|
|||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
writeGeometryText(geometry, opt_options) {
|
writeGeometryText(geometry, opt_options) {
|
||||||
return encode(/** @type {import("../geom/Geometry.js").default} */ (
|
return encode(transformGeometryWithOptions(geometry, true, opt_options));
|
||||||
transformGeometryWithOptions(geometry, true, opt_options)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user