Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mongoose-geojson-schema

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongoose-geojson-schema - npm Package Compare versions

Comparing version 2.1.2 to 2.1.3

.jshintrc

71

index.js

@@ -14,2 +14,3 @@ /**

var Schema = mongoose.Schema;
var Types = mongoose.Types;
var crs = {};

@@ -50,3 +51,6 @@

GeoJSON.schemaName = 'GeoJSON';
GeoJSON.prototype = Object.create(mongoose.SchemaType.prototype);
GeoJSON.prototype.constructor = GeoJSON;

@@ -67,2 +71,3 @@ GeoJSON.prototype.cast = function(geojson) {

Schema.Types.GeoJSON = GeoJSON;
Types.GeoJSON = GeoJSON;

@@ -79,2 +84,4 @@

Point.schemaName = 'Point';
function validatePoint(coordinates) {

@@ -89,2 +96,6 @@ // must be an array (object)

}
// must have real numbers
if (isNaN(coordinates[0]) || isNaN(coordinates[1])) {
throw new mongoose.Error('Point must have real numbers');
}
// must have two numbers

@@ -107,2 +118,3 @@ if (typeof coordinates[0] !== 'number' || typeof coordinates[1] !== 'number') {

Point.prototype = Object.create(mongoose.SchemaType.prototype);
Point.prototype.constructor = Point;

@@ -128,3 +140,4 @@ Point.prototype.cast = function(point) {

mongoose.Schema.Types.Point = Point;
Schema.Types.Point = Point;
Types.Point = Point;

@@ -140,2 +153,4 @@ /**

MultiPoint.schemaName = 'MultiPoint';
function validateMultiPoint(coordinates) {

@@ -148,2 +163,3 @@ for (var i = 0; i < coordinates.length; i++) {

MultiPoint.prototype = Object.create(mongoose.SchemaType.prototype);
MultiPoint.prototype.constructor = MultiPoint;

@@ -171,3 +187,4 @@ MultiPoint.prototype.cast = function(multipoint) {

mongoose.Schema.Types.MultiPoint = MultiPoint;
Schema.Types.MultiPoint = MultiPoint;
Types.MultiPoint = MultiPoint;

@@ -183,2 +200,4 @@ /**

LineString.schemaName = 'LineString';
function validateLineString(coordinates) {

@@ -191,2 +210,3 @@ for (var i = 0; i < coordinates.length; i++) {

LineString.prototype = Object.create(mongoose.SchemaType.prototype);
LineString.prototype.constructor = LineString;

@@ -214,3 +234,4 @@ LineString.prototype.cast = function(linestring) {

mongoose.Schema.Types.LineString = LineString;
Schema.Types.LineString = LineString;
Types.LineString = LineString;

@@ -226,2 +247,4 @@ /**

MultiLineString.schemaName = 'MultiLineString';
function validateMultiLineString(coordinates) {

@@ -234,2 +257,3 @@ for (var i = 0; i < coordinates.length; i++) {

MultiLineString.prototype = Object.create(mongoose.SchemaType.prototype);
MultiLineString.prototype.constructor = MultiLineString;

@@ -252,4 +276,6 @@ MultiLineString.prototype.cast = function(multilinestring) {

mongoose.Schema.Types.MultiLineString = MultiLineString;
Schema.Types.MultiLineString = MultiLineString;
Types.MultiLineString = MultiLineString;
/**

@@ -264,2 +290,4 @@ * @SchemaType Polygon

Polygon.schemaName = 'Polygon';
function arraysEqual(arr1, arr2) {

@@ -290,2 +318,3 @@ if(arr1.length !== arr2.length) return false;

Polygon.prototype = Object.create(mongoose.SchemaType.prototype);
Polygon.prototype.constructor = Polygon;

@@ -309,3 +338,4 @@ Polygon.prototype.cast = function(polygon) {

mongoose.Schema.Types.Polygon = Polygon;
Schema.Types.Polygon = Polygon;
Types.Polygon = Polygon;

@@ -321,2 +351,4 @@ /**

MultiPolygon.schemaName = 'MultiPolygon';
function validateMultiPolygon(coordinates) {

@@ -329,2 +361,3 @@ for (var i = 0; i < coordinates.length; i++) {

MultiPolygon.prototype = Object.create(mongoose.SchemaType.prototype);
MultiPolygon.prototype.constructor = MultiPolygon;

@@ -352,3 +385,4 @@ MultiPolygon.prototype.cast = function(multipolygon) {

mongoose.Schema.Types.MultiPolygon = MultiPolygon;
Schema.Types.MultiPolygon = MultiPolygon;
Types.MultiPolygon = MultiPolygon;

@@ -364,2 +398,4 @@ /**

Geometry.schemaName = 'Geometry';
function validateGeometry(geometry) {

@@ -391,5 +427,5 @@ switch (geometry.type) {

Geometry.prototype = Object.create(mongoose.SchemaType.prototype);
Geometry.prototype.constructor = Geometry;
Geometry.prototype.cast = function(geometry) {
// console.log(geometry);
// must be an array (object)

@@ -408,3 +444,4 @@ if (!geometry.type) {

mongoose.Schema.Types.Geometry = Geometry;
Schema.Types.Geometry = Geometry;
Types.Geometry = Geometry;

@@ -420,2 +457,4 @@ /**

GeometryCollection.schemaName = 'GeometryCollection';
function validateGeometries(geometries) {

@@ -428,2 +467,3 @@ for (var i = 0; i < geometries.length; i++) {

GeometryCollection.prototype = Object.create(mongoose.SchemaType.prototype);
GeometryCollection.prototype.constructor = GeometryCollection;

@@ -444,3 +484,4 @@ GeometryCollection.prototype.cast = function(geometrycollection) {

mongoose.Schema.Types.GeometryCollection = GeometryCollection;
Schema.Types.GeometryCollection = GeometryCollection;
Types.GeometryCollection = GeometryCollection;

@@ -456,2 +497,4 @@ /**

Feature.schemaName = 'Feature';
function validateFeature(feature) {

@@ -477,2 +520,3 @@ if (!feature.type) {

Feature.prototype = Object.create(mongoose.SchemaType.prototype);
Feature.prototype.constructor = Feature;

@@ -484,3 +528,4 @@ Feature.prototype.cast = function(feature) {

mongoose.Schema.Types.Feature = Feature;
Schema.Types.Feature = Feature;
Types.Feature = Feature;

@@ -496,2 +541,4 @@ /**

FeatureCollection.schemaName = 'FeatureCollection';
function validateFeatureCollection(featurecollection) {

@@ -505,2 +552,3 @@ for (var i = 0; i < featurecollection.features.length; i++) {

FeatureCollection.prototype = Object.create(mongoose.SchemaType.prototype);
FeatureCollection.prototype.constructor = FeatureCollection;

@@ -527,2 +575,3 @@ FeatureCollection.prototype.cast = function(featurecollection) {

mongoose.Schema.Types.FeatureCollection = FeatureCollection;
Schema.Types.FeatureCollection = FeatureCollection;
Types.FeatureCollection = FeatureCollection;

18

package.json
{
"name": "mongoose-geojson-schema",
"version": "2.1.2",
"version": "2.1.3",
"description": "Schema definitions for GeoJSON types for use with Mongoose JS",
"main": "index.js",
"scripts": {
"test": "grunt"
"test": "gulp"
},

@@ -26,3 +26,5 @@ "keywords": [

"author": "Ben Dalton <ben@rideamigos.com>",
"contributors": ["Josh Kopeček <josh@echoes.xyz>"],
"contributors": [
"Josh Kopeček <josh@echoes.xyz>"
],
"license": "MIT",

@@ -32,9 +34,11 @@ "devDependencies": {

"chai": "~3.5.0",
"grunt": "~1.0.1",
"grunt-contrib-jshint": "^1.0.0",
"grunt-mocha-test": "~0.12.7",
"gulp": "^3.9.1",
"gulp-jshint": "^2.1.0",
"gulp-mocha": "^4.3.1",
"jshint": "^2.9.5",
"jshint-stylish": "^2.2.1",
"mocha": "^2.4.5",
"mongoose": "~4.4.12",
"mongoose": "^4.10.8",
"supertest": "^1.2.0"
}
}

@@ -65,3 +65,3 @@ # mongoose-geojson-schema

type: "Point",
point: [-113.806458, 44.847784]
coordinates: [-113.806458, 44.847784]
},

@@ -68,0 +68,0 @@ point: {

@@ -119,2 +119,9 @@ /**

it("should fail with a Point with NaN", function () {
pointData.point = [NaN, NaN];
var geoJSON = new GeoJSON(pointData);
var error = geoJSON.validateSync();
expect(error.errors.point.message).to.contain('Cast to Point failed');
});
it("should fail when Point is not described as a Point", function () {

@@ -291,2 +298,9 @@ pointData.point.type = "Square";

it("should succeed with a null value for the polygon field", function () {
polygonData.polygon = null;
var geoJSON = new GeoJSON(polygonData);
var error = geoJSON.validateSync();
expect(error).to.be.an('undefined');
});
it("should fail with a badly formed Polygon", function () {

@@ -293,0 +307,0 @@ polygonData.polygon.coordinates[0][2] = 12345349884848;

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc