Comparing version 0.0.5 to 0.0.6
{ | ||
"name": "geojsonjs", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "Build and validate GeoJSON", | ||
@@ -5,0 +5,0 @@ "main": "./src/index.js", |
@@ -1,2 +0,2 @@ | ||
import { CoordinatesTypes, Feature, FeatureCollection, Geometry, ValidationResult } from './types'; | ||
import { AllTypes, CoordinatesTypes, Feature, FeatureCollection, Geometry, ValidationResult } from './types'; | ||
export declare function validateCoordinatesByDepth(coordinates: any[], depth?: number): boolean; | ||
@@ -8,1 +8,2 @@ export declare function validateCoordinates(type: string, coordinates: CoordinatesTypes): ValidationResult; | ||
export declare function validateFeatureCollection(geom: FeatureCollection): ValidationResult; | ||
export declare function validateGeometryTypes(types: string | string[], geom: AllTypes): ValidationResult; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.validateFeatureCollection = exports.validateFeatures = exports.validateFeature = exports.validateGeometry = exports.validateCoordinates = exports.validateCoordinatesByDepth = void 0; | ||
exports.validateGeometryTypes = exports.validateFeatureCollection = exports.validateFeatures = exports.validateFeature = exports.validateGeometry = exports.validateCoordinates = exports.validateCoordinatesByDepth = void 0; | ||
const lodash_1 = require("lodash"); | ||
const types_1 = require("./types"); | ||
const helpers_1 = require("./helpers"); | ||
function transformResponse(error, data) { | ||
@@ -102,2 +103,20 @@ if (error) { | ||
exports.validateFeatureCollection = validateFeatureCollection; | ||
function validateGeometryTypes(types, geom) { | ||
if (!Array.isArray(types)) | ||
types = [types]; | ||
const everyTypeValid = types.every((t) => Object.values(types_1.GeometryType).includes(t)); | ||
if (!everyTypeValid) { | ||
throw new Error(`Passed types are not valid - ["${types.join("', '")}"]`); | ||
} | ||
const invalidTypes = (0, helpers_1.getGeometries)(geom) | ||
.map((item) => item.type) | ||
.filter((t) => !types.includes(t)); | ||
if (!(invalidTypes === null || invalidTypes === void 0 ? void 0 : invalidTypes.length)) { | ||
return transformResponse(types_1.ValidationError.INVALID_TYPE, { | ||
types: invalidTypes, | ||
}); | ||
} | ||
return transformResponse(); | ||
} | ||
exports.validateGeometryTypes = validateGeometryTypes; | ||
//# sourceMappingURL=validate.js.map |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33878
345