forked from echoes-xyz/mongoose-geojson-schema
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGeoJSON.js
88 lines (73 loc) · 1.94 KB
/
GeoJSON.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/**
* GeoJSON Schemas for Mongoose
*
* rough GeoJSON schemas for use with mongoose schema creation
*
* Based on GeoJSON Spec @ http://geojson.org/geojson-spec.html
*
* Created by Ben Dalton (ben@rideamigos) on 3/27/14.
* Copyright RideAmigos (http://rideamigos.com)
**/
var GeoJSON;
module.exports = GeoJSON = {}
GeoJSON.Geometry = {
'type' : { type: String, enum: ["Point", "MultiPoint", "LineString", "MultiLineString", "Polygon", "MultiPolygon"] },
coordinates: []
}
GeoJSON.Point = {
'type' : { type: String, default: "Point" },
coordinates: [
{type: "Number"}
]
}
GeoJSON.MultiPoint = {
'type' : { type: String, default: "MultiPoint" },
coordinates: [
{type: "Array"}
]
}
GeoJSON.MultiLineString = {
'type' : { type: String, default: "MultiLineString" },
coordinates: [
{type: "Array"}
]
}
GeoJSON.Polygon = {
'type' : { type: String, default: "Polygon" },
coordinates: [
{type: "Array"}
]
}
GeoJSON.MultiPolygon = {
'type' : { type: String, default: "MultiPolygon" },
coordinates: [
{type: "Array"}
]
}
GeoJSON.GeometryCollection = {
'type' : { type: String, default: "GeometryCollection" },
geometries: [GeoJSON.Geometry]
}
GeoJSON.Feature = {
id : { type: "String" },
'type' : { type: String, default: "Feature" },
geometry : GeoJSON.Geometry,
properties: {type: "Object"}
}
GeoJSON.FeatureCollection = {
'type' : { type: String, default: "FeatureCollection" },
features: [ GeoJSON.Feature ]
}
GeoJSON.requiredAddressFeature = {
id : { type: "String" },
'type' : { type: String, default: "Feature", required:true },
geometry : {
'type':{type:String,default:"Point",required:true},
coordinates:{type:"Array",required:true}
},
properties: {type: "Object"}
}
GeoJSON.validatePointCoordinates = function(value,message){
"use strict";
var msg = message || "Must provide valid coordinates for Point Geometry";
}