mongoose-geojson-schema
Advanced tools
Comparing version 2.1.1 to 2.1.2
43
index.js
@@ -55,38 +55,9 @@ /** | ||
} | ||
switch (geojson.type) { | ||
case 'Point': | ||
validatePointObject(geojson); | ||
break; | ||
case 'MultiPoint': | ||
validateMultiPointObject(geojson); | ||
break; | ||
case 'LineString': | ||
validateLineStringObject(geojson); | ||
break; | ||
case 'MultiLineString': | ||
validateMultiLineStringObject(geojson); | ||
break; | ||
case 'Polygon': | ||
validatePolygonObject(geojson); | ||
break; | ||
case 'MultiPolygon': | ||
validateMultiPolygonObject(geojson); | ||
break; | ||
case 'Geometry': | ||
validateGeometryObject(geojson); | ||
break; | ||
case 'GeometryCollection': | ||
validateGeometryCollectionObject(geojson); | ||
break; | ||
case 'Feature': | ||
validateFeatureObject(geojson); | ||
break; | ||
case 'FeatureCollection': | ||
validateFeatureCollectionObject(geojson); | ||
break; | ||
default: | ||
throw new mongoose.Error(geojson.type + ' is not a valid GeoJSON type'); | ||
var TypeClass = mongoose.Schema.Types[geojson.type]; | ||
if (!TypeClass) { | ||
throw new mongoose.Error(geojson.type + ' is not a valid GeoJSON type'); | ||
} | ||
return geojson; | ||
return TypeClass.prototype.cast.apply(this, arguments); | ||
}; | ||
@@ -115,3 +86,3 @@ | ||
} | ||
// longitude must be within bounds | ||
// must have two numbers | ||
if (typeof coordinates[0] !== 'number' || typeof coordinates[1] !== 'number') { | ||
@@ -123,3 +94,3 @@ throw new mongoose.Error('Point must have two numbers'); | ||
if (coordinates[0] > 180 || coordinates[0] < -180) { | ||
throw new mongoose.Error('Point' + coordinates[0] + ' should be within the boundaries of latitude'); | ||
throw new mongoose.Error('Point' + coordinates[0] + ' should be within the boundaries of longitude'); | ||
} | ||
@@ -126,0 +97,0 @@ // latitude must be within bounds |
{ | ||
"name": "mongoose-geojson-schema", | ||
"version": "2.1.1", | ||
"version": "2.1.2", | ||
"description": "Schema definitions for GeoJSON types for use with Mongoose JS", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -108,3 +108,3 @@ /** | ||
var error = geoJSON.validateSync(); | ||
expect(error.errors.point.reason.message).to.contain('should be within the boundaries of latitude'); | ||
expect(error.errors.point.reason.message).to.contain('should be within the boundaries of longitude'); | ||
}); | ||
@@ -111,0 +111,0 @@ |
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
42400
1057