Module types for ol/geom
This commit is contained in:
@@ -83,7 +83,7 @@ inherits(GeoJSON, JSONFeature);
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, function(GeoJSONObject): ol.geom.Geometry>}
|
||||
* @type {Object.<string, function(GeoJSONObject): module:ol/geom/Geometry~Geometry>}
|
||||
*/
|
||||
const GEOMETRY_READERS = {
|
||||
'Point': readPointGeometry,
|
||||
@@ -98,7 +98,7 @@ const GEOMETRY_READERS = {
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, function(ol.geom.Geometry, module:ol/format/Feature~WriteOptions=): (GeoJSONGeometry|GeoJSONGeometryCollection)>}
|
||||
* @type {Object.<string, function(module:ol/geom/Geometry~Geometry, module:ol/format/Feature~WriteOptions=): (GeoJSONGeometry|GeoJSONGeometryCollection)>}
|
||||
*/
|
||||
const GEOMETRY_WRITERS = {
|
||||
'Point': writePointGeometry,
|
||||
@@ -115,14 +115,14 @@ const GEOMETRY_WRITERS = {
|
||||
/**
|
||||
* @param {GeoJSONGeometry|GeoJSONGeometryCollection} object Object.
|
||||
* @param {module:ol/format/Feature~ReadOptions=} opt_options Read options.
|
||||
* @return {ol.geom.Geometry} Geometry.
|
||||
* @return {module:ol/geom/Geometry~Geometry} Geometry.
|
||||
*/
|
||||
function readGeometry(object, opt_options) {
|
||||
if (!object) {
|
||||
return null;
|
||||
}
|
||||
const geometryReader = GEOMETRY_READERS[object.type];
|
||||
return /** @type {ol.geom.Geometry} */ (transformWithOptions(
|
||||
return /** @type {module:ol/geom/Geometry~Geometry} */ (transformWithOptions(
|
||||
geometryReader(object), false, opt_options)
|
||||
);
|
||||
}
|
||||
@@ -131,13 +131,13 @@ function readGeometry(object, opt_options) {
|
||||
/**
|
||||
* @param {GeoJSONGeometryCollection} object Object.
|
||||
* @param {module:ol/format/Feature~ReadOptions=} opt_options Read options.
|
||||
* @return {ol.geom.GeometryCollection} Geometry collection.
|
||||
* @return {module:ol/geom/GeometryCollection~GeometryCollection} Geometry collection.
|
||||
*/
|
||||
function readGeometryCollectionGeometry(object, opt_options) {
|
||||
const geometries = object.geometries.map(
|
||||
/**
|
||||
* @param {GeoJSONGeometry} geometry Geometry.
|
||||
* @return {ol.geom.Geometry} geometry Geometry.
|
||||
* @return {module:ol/geom/Geometry~Geometry} geometry Geometry.
|
||||
*/
|
||||
function(geometry) {
|
||||
return readGeometry(geometry, opt_options);
|
||||
@@ -148,7 +148,7 @@ function readGeometryCollectionGeometry(object, opt_options) {
|
||||
|
||||
/**
|
||||
* @param {GeoJSONGeometry} object Object.
|
||||
* @return {ol.geom.Point} Point.
|
||||
* @return {module:ol/geom/Point~Point} Point.
|
||||
*/
|
||||
function readPointGeometry(object) {
|
||||
return new Point(object.coordinates);
|
||||
@@ -157,7 +157,7 @@ function readPointGeometry(object) {
|
||||
|
||||
/**
|
||||
* @param {GeoJSONGeometry} object Object.
|
||||
* @return {ol.geom.LineString} LineString.
|
||||
* @return {module:ol/geom/LineString~LineString} LineString.
|
||||
*/
|
||||
function readLineStringGeometry(object) {
|
||||
return new LineString(object.coordinates);
|
||||
@@ -166,7 +166,7 @@ function readLineStringGeometry(object) {
|
||||
|
||||
/**
|
||||
* @param {GeoJSONGeometry} object Object.
|
||||
* @return {ol.geom.MultiLineString} MultiLineString.
|
||||
* @return {module:ol/geom/MultiLineString~MultiLineString} MultiLineString.
|
||||
*/
|
||||
function readMultiLineStringGeometry(object) {
|
||||
return new MultiLineString(object.coordinates);
|
||||
@@ -175,7 +175,7 @@ function readMultiLineStringGeometry(object) {
|
||||
|
||||
/**
|
||||
* @param {GeoJSONGeometry} object Object.
|
||||
* @return {ol.geom.MultiPoint} MultiPoint.
|
||||
* @return {module:ol/geom/MultiPoint~MultiPoint} MultiPoint.
|
||||
*/
|
||||
function readMultiPointGeometry(object) {
|
||||
return new MultiPoint(object.coordinates);
|
||||
@@ -184,7 +184,7 @@ function readMultiPointGeometry(object) {
|
||||
|
||||
/**
|
||||
* @param {GeoJSONGeometry} object Object.
|
||||
* @return {ol.geom.MultiPolygon} MultiPolygon.
|
||||
* @return {module:ol/geom/MultiPolygon~MultiPolygon} MultiPolygon.
|
||||
*/
|
||||
function readMultiPolygonGeometry(object) {
|
||||
return new MultiPolygon(object.coordinates);
|
||||
@@ -193,7 +193,7 @@ function readMultiPolygonGeometry(object) {
|
||||
|
||||
/**
|
||||
* @param {GeoJSONGeometry} object Object.
|
||||
* @return {ol.geom.Polygon} Polygon.
|
||||
* @return {module:ol/geom/Polygon~Polygon} Polygon.
|
||||
*/
|
||||
function readPolygonGeometry(object) {
|
||||
return new Polygon(object.coordinates);
|
||||
@@ -201,19 +201,19 @@ function readPolygonGeometry(object) {
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.geom.Geometry} geometry Geometry.
|
||||
* @param {module:ol/geom/Geometry~Geometry} geometry Geometry.
|
||||
* @param {module:ol/format/Feature~WriteOptions=} opt_options Write options.
|
||||
* @return {GeoJSONGeometry|GeoJSONGeometryCollection} GeoJSON geometry.
|
||||
*/
|
||||
function writeGeometry(geometry, opt_options) {
|
||||
const geometryWriter = GEOMETRY_WRITERS[geometry.getType()];
|
||||
return geometryWriter(/** @type {ol.geom.Geometry} */ (
|
||||
return geometryWriter(/** @type {module:ol/geom/Geometry~Geometry} */ (
|
||||
transformWithOptions(geometry, true, opt_options)), opt_options);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.geom.Geometry} geometry Geometry.
|
||||
* @param {module:ol/geom/Geometry~Geometry} geometry Geometry.
|
||||
* @return {GeoJSONGeometryCollection} Empty GeoJSON geometry collection.
|
||||
*/
|
||||
function writeEmptyGeometryCollectionGeometry(geometry) {
|
||||
@@ -225,7 +225,7 @@ function writeEmptyGeometryCollectionGeometry(geometry) {
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.geom.GeometryCollection} geometry Geometry.
|
||||
* @param {module:ol/geom/GeometryCollection~GeometryCollection} geometry Geometry.
|
||||
* @param {module:ol/format/Feature~WriteOptions=} opt_options Write options.
|
||||
* @return {GeoJSONGeometryCollection} GeoJSON geometry collection.
|
||||
*/
|
||||
@@ -243,7 +243,7 @@ function writeGeometryCollectionGeometry(geometry, opt_options) {
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.geom.LineString} geometry Geometry.
|
||||
* @param {module:ol/geom/LineString~LineString} geometry Geometry.
|
||||
* @param {module:ol/format/Feature~WriteOptions=} opt_options Write options.
|
||||
* @return {GeoJSONGeometry} GeoJSON geometry.
|
||||
*/
|
||||
@@ -256,7 +256,7 @@ function writeLineStringGeometry(geometry, opt_options) {
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.geom.MultiLineString} geometry Geometry.
|
||||
* @param {module:ol/geom/MultiLineString~MultiLineString} geometry Geometry.
|
||||
* @param {module:ol/format/Feature~WriteOptions=} opt_options Write options.
|
||||
* @return {GeoJSONGeometry} GeoJSON geometry.
|
||||
*/
|
||||
@@ -269,7 +269,7 @@ function writeMultiLineStringGeometry(geometry, opt_options) {
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.geom.MultiPoint} geometry Geometry.
|
||||
* @param {module:ol/geom/MultiPoint~MultiPoint} geometry Geometry.
|
||||
* @param {module:ol/format/Feature~WriteOptions=} opt_options Write options.
|
||||
* @return {GeoJSONGeometry} GeoJSON geometry.
|
||||
*/
|
||||
@@ -282,7 +282,7 @@ function writeMultiPointGeometry(geometry, opt_options) {
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.geom.MultiPolygon} geometry Geometry.
|
||||
* @param {module:ol/geom/MultiPolygon~MultiPolygon} geometry Geometry.
|
||||
* @param {module:ol/format/Feature~WriteOptions=} opt_options Write options.
|
||||
* @return {GeoJSONGeometry} GeoJSON geometry.
|
||||
*/
|
||||
@@ -299,7 +299,7 @@ function writeMultiPolygonGeometry(geometry, opt_options) {
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.geom.Point} geometry Geometry.
|
||||
* @param {module:ol/geom/Point~Point} geometry Geometry.
|
||||
* @param {module:ol/format/Feature~WriteOptions=} opt_options Write options.
|
||||
* @return {GeoJSONGeometry} GeoJSON geometry.
|
||||
*/
|
||||
@@ -312,7 +312,7 @@ function writePointGeometry(geometry, opt_options) {
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.geom.Polygon} geometry Geometry.
|
||||
* @param {module:ol/geom/Polygon~Polygon} geometry Geometry.
|
||||
* @param {module:ol/format/Feature~WriteOptions=} opt_options Write options.
|
||||
* @return {GeoJSONGeometry} GeoJSON geometry.
|
||||
*/
|
||||
@@ -419,7 +419,7 @@ GeoJSON.prototype.readFeaturesFromObject = function(object, opt_options) {
|
||||
* @function
|
||||
* @param {Document|Node|Object|string} source Source.
|
||||
* @param {module:ol/format/Feature~ReadOptions=} opt_options Read options.
|
||||
* @return {ol.geom.Geometry} Geometry.
|
||||
* @return {module:ol/geom/Geometry~Geometry} Geometry.
|
||||
* @api
|
||||
*/
|
||||
GeoJSON.prototype.readGeometry;
|
||||
@@ -551,7 +551,7 @@ GeoJSON.prototype.writeFeaturesObject = function(features, opt_options) {
|
||||
* Encode a geometry as a GeoJSON string.
|
||||
*
|
||||
* @function
|
||||
* @param {ol.geom.Geometry} geometry Geometry.
|
||||
* @param {module:ol/geom/Geometry~Geometry} geometry Geometry.
|
||||
* @param {module:ol/format/Feature~WriteOptions=} opt_options Write options.
|
||||
* @return {string} GeoJSON.
|
||||
* @api
|
||||
@@ -562,7 +562,7 @@ GeoJSON.prototype.writeGeometry;
|
||||
/**
|
||||
* Encode a geometry as a GeoJSON object.
|
||||
*
|
||||
* @param {ol.geom.Geometry} geometry Geometry.
|
||||
* @param {module:ol/geom/Geometry~Geometry} geometry Geometry.
|
||||
* @param {module:ol/format/Feature~WriteOptions=} opt_options Write options.
|
||||
* @return {GeoJSONGeometry|GeoJSONGeometryCollection} Object.
|
||||
* @override
|
||||
|
||||
Reference in New Issue
Block a user