commited for presentation.
This commit is contained in:
@@ -39,6 +39,15 @@ export default class GeoJson {
|
||||
return ['Point', 'LineString', 'Polygon', 'MultiPoint', 'MultiLineString', 'MultiPolygon']
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes a JSON object that contains a FeatureCollection and returns an array
|
||||
* of GeoJson objects.
|
||||
*
|
||||
* @static
|
||||
* @param {array} featureCollection - Array of GeoJSON objects that were contained in the feature collection.
|
||||
* @returns {array} Returns an array of geo json objects.
|
||||
* @memberof GeoJson
|
||||
*/
|
||||
static unwrapFeatureCollection(featureCollection) {
|
||||
if (featureCollection.features == null) {
|
||||
console.error(
|
||||
@@ -63,12 +72,22 @@ export default class GeoJson {
|
||||
return list
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates and converts one set of coordinates of a specific type.
|
||||
*
|
||||
* @static
|
||||
* @param {string} type - Type of the GeoJson.
|
||||
* @param {array} coordinates - array of points.
|
||||
* @returns {array}
|
||||
* @memberof GeoJson
|
||||
*/
|
||||
static validateAndConvert(type, coordinates) {
|
||||
let converted = null
|
||||
|
||||
if (!GeoJson.validateType(type)) throw new GeoJson.InvalidTypeError(type)
|
||||
else {
|
||||
if (GeoJson.validateCoordinates(type, coordinates)) {
|
||||
let converted = GeoJson.convert(type, coordinates)
|
||||
return converted
|
||||
converted = GeoJson.convert(type, coordinates)
|
||||
} else {
|
||||
console.error(
|
||||
`Coordinates are invalid. They must be in format of type '${type} - ${GeoJson._getFormatStringOfType(
|
||||
@@ -77,6 +96,8 @@ export default class GeoJson {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return converted
|
||||
}
|
||||
|
||||
static validateType(type) {
|
||||
|
||||
Reference in New Issue
Block a user