@hestia-earth/schema-validation 23.4.1 → 23.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hestia-earth/schema-validation",
3
- "version": "23.4.1",
3
+ "version": "23.5.0",
4
4
  "description": "Hestia Schema Validation",
5
5
  "main": "index.js",
6
6
  "typings": "index.d.ts",
@@ -26,6 +26,7 @@
26
26
  "dependencies": {
27
27
  "@hestia-earth/schema": "*",
28
28
  "@hestia-earth/json-schema": "*",
29
- "ajv": "^6.12.6"
29
+ "ajv": "^6.12.6",
30
+ "geojson-validation": "^1.0.2"
30
31
  }
31
32
  }
@@ -70,18 +70,20 @@ var validate_1 = require("./validate");
70
70
  var _a = __read(process.argv.slice(2), 3), DOMAIN = _a[0], folder = _a[1], strictMode = _a[2];
71
71
  var domain = "https://".concat(DOMAIN || process.env.DOMAIN || 'www.hestia.earth');
72
72
  var loadFile = function (filename) { return JSON.parse((0, fs_1.readFileSync)(filename, 'utf8')); };
73
- var extensions = [
74
- 'jsonld',
75
- 'json',
76
- 'hestia'
77
- ];
78
- var findFiles = function (directory) { return (0, fs_1.readdirSync)(directory)
79
- .map(function (path) {
80
- var isDirectory = (0, fs_1.lstatSync)((0, path_1.join)(directory, path)).isDirectory();
81
- return isDirectory ? findFiles((0, path_1.join)(directory, path)) : (extensions.includes(path.split('.')[1]) ? (0, path_1.join)(directory, path) : null);
82
- })
83
- .flat()
84
- .filter(Boolean); };
73
+ var extensions = ['jsonld', 'json', 'hestia'];
74
+ var findFiles = function (directory) {
75
+ return (0, fs_1.readdirSync)(directory)
76
+ .map(function (path) {
77
+ var isDirectory = (0, fs_1.lstatSync)((0, path_1.join)(directory, path)).isDirectory();
78
+ return isDirectory
79
+ ? findFiles((0, path_1.join)(directory, path))
80
+ : extensions.includes(path.split('.')[1])
81
+ ? (0, path_1.join)(directory, path)
82
+ : null;
83
+ })
84
+ .flat()
85
+ .filter(Boolean);
86
+ };
85
87
  var run = function () { return __awaiter(void 0, void 0, void 0, function () {
86
88
  var contentValidator, jsonldFiles, results, jsonldFiles_1, jsonldFiles_1_1, filepath, content, nodes, allErrors, nodes_1, nodes_1_1, node, errors, e_1_1, success, e_2_1;
87
89
  var e_2, _a, e_1, _b;
@@ -101,8 +103,8 @@ var run = function () { return __awaiter(void 0, void 0, void 0, function () {
101
103
  filepath = jsonldFiles_1_1.value;
102
104
  console.log('Validating', filepath);
103
105
  content = loadFile(filepath);
104
- nodes = (Array.isArray(content) ? content : ('nodes' in content ? content.nodes : [content]))
105
- .map(function (node) { return node['@type'] || node.type ? node : null; })
106
+ nodes = (Array.isArray(content) ? content : 'nodes' in content ? content.nodes : [content])
107
+ .map(function (node) { return (node['@type'] || node.type ? node : null); })
106
108
  .filter(Boolean);
107
109
  allErrors = [];
108
110
  _c.label = 3;
package/validate.d.ts CHANGED
@@ -11,8 +11,8 @@ import { definitions } from '@hestia-earth/json-schema';
11
11
  export declare const validateContent: (ajv: Ajv.Ajv, schemas: definitions) => (content: HestiaJson<SchemaType>) => Promise<{
12
12
  success: any;
13
13
  errors: {
14
- schema?: any;
15
14
  parentSchema?: object;
15
+ schema?: any;
16
16
  dataPath: string;
17
17
  schemaPath: string;
18
18
  params: Ajv.ErrorParameters;
@@ -32,8 +32,8 @@ export declare const initAjv: () => Ajv.Ajv;
32
32
  export declare const validator: (domain?: string, strictMode?: boolean) => (content: HestiaJson<SchemaType>) => Promise<{
33
33
  success: any;
34
34
  errors: {
35
- schema?: any;
36
35
  parentSchema?: object;
36
+ schema?: any;
37
37
  dataPath: string;
38
38
  schemaPath: string;
39
39
  params: Ajv.ErrorParameters;
package/validate.js CHANGED
@@ -63,7 +63,6 @@ var Ajv = require("ajv");
63
63
  var schema_1 = require("@hestia-earth/schema");
64
64
  var json_schema_1 = require("@hestia-earth/json-schema");
65
65
  var validators_1 = require("./validators");
66
- var geojsonSchema = 'http://json.schemastore.org/geojson';
67
66
  var existingNodeRequired = Object.freeze({ required: ['@id', '@type'] });
68
67
  var validateSchemaType = function (schemas, content) {
69
68
  var type = content['@type'] || content.type;
@@ -72,14 +71,18 @@ var validateSchemaType = function (schemas, content) {
72
71
  }
73
72
  return true;
74
73
  };
75
- var ignoreSchemaKeywords = [
76
- 'if', validators_1.uniqueArrayItem, validators_1.arraySameSize
77
- ];
74
+ var ignoreSchemaKeywords = ['if', validators_1.arraySameSize, validators_1.geojson, validators_1.uniqueArrayItem];
75
+ var includeSchema = function (keyword, schema) {
76
+ return [!ignoreSchemaKeywords.includes(keyword), typeof schema === 'object'].every(Boolean);
77
+ };
78
+ var includeParentSchema = function (keyword, schema, parentSchema) {
79
+ return [includeSchema(keyword, schema), !(0, schema_1.isTypeNode)(parentSchema.title)].every(Boolean);
80
+ };
78
81
  // using `verbose: true` includes data which we don't need
79
82
  var cleanErrors = function (errors) {
80
83
  return errors.map(function (_a) {
81
84
  var keyword = _a.keyword, data = _a.data, schema = _a.schema, parentSchema = _a.parentSchema, error = __rest(_a, ["keyword", "data", "schema", "parentSchema"]);
82
- return (__assign(__assign({ keyword: keyword }, error), (ignoreSchemaKeywords.includes(keyword) ? {} : { schema: schema, parentSchema: parentSchema })));
85
+ return (__assign(__assign(__assign({ keyword: keyword }, error), (!!schema && includeSchema(keyword, schema) ? { schema: schema } : {})), (!!parentSchema && includeParentSchema(keyword, schema, parentSchema) ? { parentSchema: parentSchema } : {})));
83
86
  });
84
87
  };
85
88
  /**
@@ -116,7 +119,6 @@ var initAjv = function () {
116
119
  verbose: true
117
120
  });
118
121
  ajv.addMetaSchema(require('ajv/lib/refs/json-schema-draft-04.json'));
119
- ajv.addSchema(require('./json-schema/geojson.json'), geojsonSchema);
120
122
  (0, validators_1.init)(ajv);
121
123
  return ajv;
122
124
  };
@@ -1,2 +1,4 @@
1
+ import { Ajv, SchemaValidateFunction } from 'ajv';
1
2
  export declare const keyword = "arraySameSize";
2
- export declare function arraySameSizeValidate(keys: string[], items: any[], _schema: any, dataPath: string, item: any): boolean;
3
+ export declare const validate: SchemaValidateFunction;
4
+ export declare const init: (ajv: Ajv) => Ajv;
@@ -1,22 +1,33 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.arraySameSizeValidate = exports.keyword = void 0;
3
+ exports.init = exports.validate = exports.keyword = void 0;
4
4
  exports.keyword = 'arraySameSize';
5
- function arraySameSizeValidate(keys, items, _schema, dataPath, item) {
6
- var current = items.length;
7
- var errors = keys
8
- .filter(function (key) { return key in item; })
5
+ var validate = function (schema, data, _parentSchema, dataPath, parentData) {
6
+ var current = data.length;
7
+ var errors = schema
8
+ .filter(function (key) { return key in parentData; })
9
9
  .map(function (key) {
10
- var expected = item[key].length;
11
- return current !== expected ? {
12
- dataPath: dataPath,
13
- keyword: exports.keyword,
14
- message: "must contain as many items as ".concat(key, "s"),
15
- params: { keyword: exports.keyword, current: current, expected: expected }
16
- } : null;
10
+ var expected = parentData[key].length;
11
+ return current !== expected
12
+ ? {
13
+ dataPath: dataPath,
14
+ keyword: exports.keyword,
15
+ schemaPath: '#/invalid',
16
+ message: "must contain as many items as ".concat(key, "s"),
17
+ params: { keyword: exports.keyword, current: current, expected: expected }
18
+ }
19
+ : null;
17
20
  })
18
21
  .filter(Boolean);
19
- arraySameSizeValidate.errors = errors;
22
+ exports.validate.errors = errors;
20
23
  return errors.length === 0;
21
- }
22
- exports.arraySameSizeValidate = arraySameSizeValidate;
24
+ };
25
+ exports.validate = validate;
26
+ var init = function (ajv) {
27
+ return ajv.addKeyword(exports.keyword, {
28
+ type: 'array',
29
+ errors: 'full',
30
+ validate: exports.validate
31
+ });
32
+ };
33
+ exports.init = init;
@@ -1,2 +1,4 @@
1
+ import { Ajv, SchemaValidateFunction } from 'ajv';
1
2
  export declare const keyword = "datePattern";
2
- export declare function datePatternValidate(_enabled: boolean, value: string | string[], _schema: any, dataPath: string): boolean;
3
+ export declare const validate: SchemaValidateFunction;
4
+ export declare const init: (ajv: Ajv) => Ajv;
@@ -1,18 +1,32 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.datePatternValidate = exports.keyword = void 0;
3
+ exports.init = exports.validate = exports.keyword = void 0;
4
4
  var isValidDate = function (date) { return isFinite(new Date(date).getTime()); };
5
5
  exports.keyword = 'datePattern';
6
- function datePatternValidate(_enabled, value, _schema, dataPath) {
6
+ var validate = function (_schema, value, _parentSchema, dataPath) {
7
7
  var values = Array.isArray(value) ? value : [value];
8
8
  var errors = values
9
- .map(function (v, index) { return isValidDate(v) ? null : {
10
- dataPath: "".concat(dataPath).concat(Array.isArray(value) ? "[".concat(index, "]") : ''),
11
- keyword: exports.keyword,
12
- message: 'not a valid date'
13
- }; })
9
+ .map(function (v, index) {
10
+ return isValidDate(v)
11
+ ? null
12
+ : {
13
+ dataPath: "".concat(dataPath).concat(Array.isArray(value) ? "[".concat(index, "]") : ''),
14
+ keyword: exports.keyword,
15
+ schemaPath: '#/invalid',
16
+ message: 'not a valid date',
17
+ params: {}
18
+ };
19
+ })
14
20
  .filter(Boolean);
15
- datePatternValidate.errors = errors;
21
+ exports.validate.errors = errors;
16
22
  return errors.length === 0;
17
- }
18
- exports.datePatternValidate = datePatternValidate;
23
+ };
24
+ exports.validate = validate;
25
+ var init = function (ajv) {
26
+ return ajv.addKeyword(exports.keyword, {
27
+ type: ['string', 'array'],
28
+ errors: 'full',
29
+ validate: exports.validate
30
+ });
31
+ };
32
+ exports.init = init;
@@ -0,0 +1,4 @@
1
+ import { Ajv, SchemaValidateFunction } from 'ajv';
2
+ export declare const keyword = "geojson";
3
+ export declare const validate: SchemaValidateFunction;
4
+ export declare const init: (ajv: Ajv) => Ajv;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.init = exports.validate = exports.keyword = void 0;
4
+ var gjv = require("geojson-validation");
5
+ exports.keyword = 'geojson';
6
+ var validate = function (_schema, value, _parentSchema, dataPath) {
7
+ var isValid = gjv.valid(value);
8
+ var errors = [
9
+ isValid
10
+ ? null
11
+ : {
12
+ dataPath: dataPath,
13
+ keyword: exports.keyword,
14
+ schemaPath: '#/invalid',
15
+ message: 'not a valid GeoJSON',
16
+ params: {}
17
+ }
18
+ ].filter(Boolean);
19
+ exports.validate.errors = errors;
20
+ return isValid;
21
+ };
22
+ exports.validate = validate;
23
+ var init = function (ajv) {
24
+ return ajv.addKeyword(exports.keyword, {
25
+ type: 'object',
26
+ errors: 'full',
27
+ validate: exports.validate
28
+ });
29
+ };
30
+ exports.init = init;
@@ -1,6 +1,7 @@
1
1
  import { Ajv } from 'ajv';
2
2
  import { keyword as arraySameSize } from './arraySameSize';
3
3
  import { keyword as datePattern } from './datePattern';
4
+ import { keyword as geojson } from './geojson';
4
5
  import { keyword as uniqueArrayItem } from './uniqueArrayItem';
5
- export { arraySameSize, datePattern, uniqueArrayItem };
6
+ export { arraySameSize, datePattern, geojson, uniqueArrayItem };
6
7
  export declare const init: (ajv: Ajv) => void;
@@ -1,27 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.init = exports.uniqueArrayItem = exports.datePattern = exports.arraySameSize = void 0;
3
+ exports.init = exports.uniqueArrayItem = exports.geojson = exports.datePattern = exports.arraySameSize = void 0;
4
4
  var arraySameSize_1 = require("./arraySameSize");
5
5
  Object.defineProperty(exports, "arraySameSize", { enumerable: true, get: function () { return arraySameSize_1.keyword; } });
6
6
  var datePattern_1 = require("./datePattern");
7
7
  Object.defineProperty(exports, "datePattern", { enumerable: true, get: function () { return datePattern_1.keyword; } });
8
+ var geojson_1 = require("./geojson");
9
+ Object.defineProperty(exports, "geojson", { enumerable: true, get: function () { return geojson_1.keyword; } });
8
10
  var uniqueArrayItem_1 = require("./uniqueArrayItem");
9
11
  Object.defineProperty(exports, "uniqueArrayItem", { enumerable: true, get: function () { return uniqueArrayItem_1.keyword; } });
10
12
  var init = function (ajv) {
11
- ajv.addKeyword(arraySameSize_1.keyword, {
12
- type: 'array',
13
- errors: 'full',
14
- validate: arraySameSize_1.arraySameSizeValidate
15
- });
16
- ajv.addKeyword(datePattern_1.keyword, {
17
- type: ['string', 'array'],
18
- errors: 'full',
19
- validate: datePattern_1.datePatternValidate
20
- });
21
- ajv.addKeyword(uniqueArrayItem_1.keyword, {
22
- type: 'array',
23
- errors: 'full',
24
- validate: uniqueArrayItem_1.uniqueArrayItemValidate
25
- });
13
+ (0, arraySameSize_1.init)(ajv);
14
+ (0, datePattern_1.init)(ajv);
15
+ (0, geojson_1.init)(ajv);
16
+ (0, uniqueArrayItem_1.init)(ajv);
26
17
  };
27
18
  exports.init = init;
@@ -1,2 +1,4 @@
1
+ import { Ajv, SchemaValidateFunction } from 'ajv';
1
2
  export declare const keyword = "uniqueArrayItem";
2
- export declare function uniqueArrayItemValidate(keys: string[], items: any[], _schema?: any, dataPath?: string): boolean;
3
+ export declare const validate: SchemaValidateFunction;
4
+ export declare const init: (ajv: Ajv) => Ajv;
@@ -11,30 +11,47 @@ var __assign = (this && this.__assign) || function () {
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.uniqueArrayItemValidate = exports.keyword = void 0;
15
- var getByKey = function (prev, curr) { return !curr || !prev ? prev : (Array.isArray(prev) ? prev.map(function (item) { return getItemValue(item, curr); }) : (prev ? prev[curr] : undefined)); };
16
- var getItemValue = function (item, key) {
17
- return key.split('.').reduce(getByKey, item);
14
+ exports.init = exports.validate = exports.keyword = void 0;
15
+ var getByKey = function (prev, curr) {
16
+ return !curr || !prev
17
+ ? prev
18
+ : Array.isArray(prev)
19
+ ? prev.map(function (item) { return getItemValue(item, curr); })
20
+ : prev
21
+ ? prev[curr]
22
+ : undefined;
18
23
  };
24
+ var getItemValue = function (item, key) { return key.split('.').reduce(getByKey, item); };
19
25
  exports.keyword = 'uniqueArrayItem';
20
- function uniqueArrayItemValidate(keys, items, _schema, dataPath) {
26
+ var validate = function (schema, data, _parentSchema, dataPath) {
21
27
  if (dataPath === void 0) { dataPath = ''; }
22
- var values = items.map(function (item) { return JSON.stringify(keys.reduce(function (prev, key) {
23
- var _a;
24
- return (__assign(__assign({}, prev), (_a = {}, _a[key] = getItemValue(item, key), _a)));
25
- }, {})); });
28
+ var values = data.map(function (item) {
29
+ return JSON.stringify(schema.reduce(function (prev, key) {
30
+ var _a;
31
+ return (__assign(__assign({}, prev), (_a = {}, _a[key] = getItemValue(item, key), _a)));
32
+ }, {}));
33
+ });
26
34
  var indexes = values
27
- .map(function (value, index) { return values.findIndex(function (otherValue, otherValueIndex) {
28
- return otherValueIndex !== index && otherValue === value;
29
- }); })
35
+ .map(function (value, index) {
36
+ return values.findIndex(function (otherValue, otherValueIndex) { return otherValueIndex !== index && otherValue === value; });
37
+ })
30
38
  .filter(function (index) { return index >= 0; })
31
39
  .sort();
32
- uniqueArrayItemValidate.errors = indexes.map(function (index) { return ({
40
+ exports.validate.errors = indexes.map(function (index) { return ({
33
41
  dataPath: "".concat(dataPath, "[").concat(index, "]"),
34
42
  keyword: exports.keyword,
43
+ schemaPath: '#/invalid',
35
44
  message: 'every item in the list should be unique',
36
- params: { keyword: exports.keyword, keys: keys }
45
+ params: { keyword: exports.keyword, keys: schema }
37
46
  }); });
38
47
  return indexes.length === 0;
39
- }
40
- exports.uniqueArrayItemValidate = uniqueArrayItemValidate;
48
+ };
49
+ exports.validate = validate;
50
+ var init = function (ajv) {
51
+ return ajv.addKeyword(exports.keyword, {
52
+ type: 'array',
53
+ errors: 'full',
54
+ validate: exports.validate
55
+ });
56
+ };
57
+ exports.init = init;
@@ -1,462 +0,0 @@
1
- {
2
- "$schema": "http://json-schema.org/draft-04/schema#",
3
- "title": "GeoJSON Object",
4
- "type": "object",
5
- "description": "This object represents a geometry, feature, or collection of features.",
6
- "additionalProperties": true,
7
- "required": [
8
- "type"
9
- ],
10
- "properties": {
11
- "type": {
12
- "title": "Type",
13
- "type": "string",
14
- "description": "The type of GeoJSON object.",
15
- "enum": [
16
- "Point",
17
- "MultiPoint",
18
- "LineString",
19
- "MultiLineString",
20
- "Polygon",
21
- "MultiPolygon",
22
- "GeometryCollection",
23
- "Feature",
24
- "FeatureCollection"
25
- ]
26
- },
27
- "crs": {
28
- "title": "Coordinate Reference System (CRS)",
29
- "description": "The coordinate reference system (CRS) of a GeoJSON object is determined by its `crs` member (referred to as the CRS object below). If an object has no crs member, then its parent or grandparent object's crs member may be acquired. If no crs member can be so acquired, the default CRS shall apply to the GeoJSON object.\n\n* The default CRS is a geographic coordinate reference system, using the WGS84 datum, and with longitude and latitude units of decimal degrees.\n\n* The value of a member named `crs` must be a JSON object (referred to as the CRS object below) or JSON null. If the value of CRS is null, no CRS can be assumed.\n\n* The crs member should be on the top-level GeoJSON object in a hierarchy (in feature collection, feature, geometry order) and should not be repeated or overridden on children or grandchildren of the object.\n\n* A non-null CRS object has two mandatory members: `type` and `properties`.\n\n* The value of the type member must be a string, indicating the type of CRS object.\n\n* The value of the properties member must be an object.\n\n* CRS shall not change coordinate ordering.",
30
- "oneOf": [
31
- {
32
- "type": "null"
33
- },
34
- {
35
- "type": "object",
36
- "required": [
37
- "type",
38
- "properties"
39
- ],
40
- "properties": {
41
- "type": {
42
- "title": "CRS Type",
43
- "type": "string",
44
- "description": "The value of the type member must be a string, indicating the type of CRS object.",
45
- "minLength": 1
46
- },
47
- "properties": {
48
- "title": "CRS Properties",
49
- "type": "object"
50
- }
51
- }
52
- }
53
- ],
54
- "not": {
55
- "anyOf": [
56
- {
57
- "properties": {
58
- "type": {
59
- "enum": [
60
- "name"
61
- ]
62
- },
63
- "properties": {
64
- "not": {
65
- "required": [
66
- "name"
67
- ],
68
- "properties": {
69
- "name": {
70
- "type": "string",
71
- "minLength": 1
72
- }
73
- }
74
- }
75
- }
76
- }
77
- },
78
- {
79
- "properties": {
80
- "type": {
81
- "enum": [
82
- "link"
83
- ]
84
- },
85
- "properties": {
86
- "not": {
87
- "title": "Link Object",
88
- "type": "object",
89
- "required": [
90
- "href"
91
- ],
92
- "properties": {
93
- "href": {
94
- "title": "href",
95
- "type": "string",
96
- "description": "The value of the required `href` member must be a dereferenceable URI.",
97
- "format": "uri"
98
- },
99
- "type": {
100
- "title": "Link Object Type",
101
- "type": "string",
102
- "description": "The value of the optional `type` member must be a string that hints at the format used to represent CRS parameters at the provided URI. Suggested values are: `proj4`, `ogcwkt`, `esriwkt`, but others can be used."
103
- }
104
- }
105
- }
106
- }
107
- }
108
- }
109
- ]
110
- }
111
- },
112
- "bbox": {
113
- "title": "Bounding Box",
114
- "type": "array",
115
- "description": "To include information on the coordinate range for geometries, features, or feature collections, a GeoJSON object may have a member named `bbox`. The value of the bbox member must be a 2*n array where n is the number of dimensions represented in the contained geometries, with the lowest values for all axes followed by the highest values. The axes order of a bbox follows the axes order of geometries. In addition, the coordinate reference system for the bbox is assumed to match the coordinate reference system of the GeoJSON object of which it is a member.",
116
- "minItems": 4,
117
- "items": {
118
- "type": "number"
119
- }
120
- }
121
- },
122
- "oneOf": [
123
- {
124
- "title": "Point",
125
- "description": "For type `Point`, the `coordinates` member must be a single position.",
126
- "required": [
127
- "coordinates"
128
- ],
129
- "properties": {
130
- "type": {
131
- "enum": [
132
- "Point"
133
- ]
134
- },
135
- "coordinates": {
136
- "allOf": [
137
- {
138
- "$ref": "#/definitions/coordinates"
139
- },
140
- {
141
- "$ref": "#/definitions/position"
142
- }
143
- ]
144
- }
145
- },
146
- "allOf": [
147
- {
148
- "$ref": "#/definitions/geometry"
149
- }
150
- ]
151
- },
152
- {
153
- "title": "Multi Point Geometry",
154
- "description": "For type `MultiPoint`, the `coordinates` member must be an array of positions.",
155
- "required": [
156
- "coordinates"
157
- ],
158
- "properties": {
159
- "type": {
160
- "enum": [
161
- "MultiPoint"
162
- ]
163
- },
164
- "coordinates": {
165
- "allOf": [
166
- {
167
- "$ref": "#/definitions/coordinates"
168
- },
169
- {
170
- "items": {
171
- "$ref": "#/definitions/position"
172
- }
173
- }
174
- ]
175
- }
176
- },
177
- "allOf": [
178
- {
179
- "$ref": "#/definitions/geometry"
180
- }
181
- ]
182
- },
183
- {
184
- "title": "Line String",
185
- "description": "For type `LineString`, the `coordinates` member must be an array of two or more positions.\n\nA LinearRing is closed LineString with 4 or more positions. The first and last positions are equivalent (they represent equivalent points). Though a LinearRing is not explicitly represented as a GeoJSON geometry type, it is referred to in the Polygon geometry type definition.",
186
- "required": [
187
- "coordinates"
188
- ],
189
- "properties": {
190
- "type": {
191
- "enum": [
192
- "LineString"
193
- ]
194
- },
195
- "coordinates": {
196
- "$ref": "#/definitions/lineStringCoordinates"
197
- }
198
- },
199
- "allOf": [
200
- {
201
- "$ref": "#/definitions/geometry"
202
- }
203
- ]
204
- },
205
- {
206
- "title": "MultiLineString",
207
- "description": "For type `MultiLineString`, the `coordinates` member must be an array of LineString coordinate arrays.",
208
- "required": [
209
- "coordinates"
210
- ],
211
- "properties": {
212
- "type": {
213
- "enum": [
214
- "MultiLineString"
215
- ]
216
- },
217
- "coordinates": {
218
- "allOf": [
219
- {
220
- "$ref": "#/definitions/coordinates"
221
- },
222
- {
223
- "items": {
224
- "$ref": "#/definitions/lineStringCoordinates"
225
- }
226
- }
227
- ]
228
- }
229
- },
230
- "allOf": [
231
- {
232
- "$ref": "#/definitions/geometry"
233
- }
234
- ]
235
- },
236
- {
237
- "title": "Polygon",
238
- "description": "For type `Polygon`, the `coordinates` member must be an array of LinearRing coordinate arrays. For Polygons with multiple rings, the first must be the exterior ring and any others must be interior rings or holes.",
239
- "required": [
240
- "coordinates"
241
- ],
242
- "properties": {
243
- "type": {
244
- "enum": [
245
- "Polygon"
246
- ]
247
- },
248
- "coordinates": {
249
- "$ref": "#/definitions/polygonCoordinates"
250
- }
251
- },
252
- "allOf": [
253
- {
254
- "$ref": "#/definitions/geometry"
255
- }
256
- ]
257
- },
258
- {
259
- "title": "Multi-Polygon Geometry",
260
- "description": "For type `MultiPolygon`, the `coordinates` member must be an array of Polygon coordinate arrays.",
261
- "required": [
262
- "coordinates"
263
- ],
264
- "properties": {
265
- "type": {
266
- "enum": [
267
- "MultiPolygon"
268
- ]
269
- },
270
- "coordinates": {
271
- "allOf": [
272
- {
273
- "$ref": "#/definitions/coordinates"
274
- },
275
- {
276
- "items": {
277
- "$ref": "#/definitions/polygonCoordinates"
278
- }
279
- }
280
- ]
281
- }
282
- },
283
- "allOf": [
284
- {
285
- "$ref": "#/definitions/geometry"
286
- }
287
- ]
288
- },
289
- {
290
- "title": "Geometry Collection",
291
- "description": "A GeoJSON object with type `GeometryCollection` is a geometry object which represents a collection of geometry objects.\n\nA geometry collection must have a member with the name `geometries`. The value corresponding to `geometries` is an array. Each element in this array is a GeoJSON geometry object.",
292
- "required": [
293
- "geometries"
294
- ],
295
- "properties": {
296
- "type": {
297
- "enum": [
298
- "GeometryCollection"
299
- ]
300
- },
301
- "geometries": {
302
- "title": "Geometries",
303
- "type": "array",
304
- "items": {
305
- "$ref": "#/definitions/geometry"
306
- }
307
- }
308
- },
309
- "allOf": [
310
- {
311
- "$ref": "#/definitions/geometry"
312
- }
313
- ]
314
- },
315
- {
316
- "$ref": "#/definitions/feature"
317
- },
318
- {
319
- "title": "Feature Collection",
320
- "description": "A GeoJSON object with the type `FeatureCollection` is a feature collection object.\n\nAn object of type `FeatureCollection` must have a member with the name `features`. The value corresponding to `features` is an array. Each element in the array is a feature object as defined above.",
321
- "required": [
322
- "features"
323
- ],
324
- "properties": {
325
- "type": {
326
- "enum": [
327
- "FeatureCollection"
328
- ]
329
- },
330
- "features": {
331
- "title": "Features",
332
- "type": "array",
333
- "items": {
334
- "$ref": "#/definitions/feature"
335
- }
336
- }
337
- }
338
- }
339
- ],
340
- "definitions": {
341
- "coordinates": {
342
- "title": "Coordinates",
343
- "type": "array",
344
- "items": {
345
- "oneOf": [
346
- {
347
- "type": "array"
348
- },
349
- {
350
- "type": "number"
351
- }
352
- ]
353
- }
354
- },
355
- "geometry": {
356
- "title": "Geometry",
357
- "description": "A geometry is a GeoJSON object where the type member's value is one of the following strings: `Point`, `MultiPoint`, `LineString`, `MultiLineString`, `Polygon`, `MultiPolygon`, or `GeometryCollection`.",
358
- "properties": {
359
- "type": {
360
- "enum": [
361
- "Point",
362
- "MultiPoint",
363
- "LineString",
364
- "MultiLineString",
365
- "Polygon",
366
- "MultiPolygon",
367
- "GeometryCollection"
368
- ]
369
- }
370
- }
371
- },
372
- "feature": {
373
- "title": "Feature",
374
- "description": "A GeoJSON object with the type `Feature` is a feature object.\n\n* A feature object must have a member with the name `geometry`. The value of the geometry member is a geometry object as defined above or a JSON null value.\n\n* A feature object must have a member with the name `properties`. The value of the properties member is an object (any JSON object or a JSON null value).\n\n* If a feature has a commonly used identifier, that identifier should be included as a member of the feature object with the name `id`.",
375
- "required": [
376
- "geometry",
377
- "properties"
378
- ],
379
- "properties": {
380
- "type": {
381
- "enum": [
382
- "Feature"
383
- ]
384
- },
385
- "geometry": {
386
- "title": "Geometry",
387
- "oneOf": [
388
- {
389
- "$ref": "#/definitions/geometry"
390
- },
391
- {
392
- "type": "null"
393
- }
394
- ]
395
- },
396
- "properties": {
397
- "title": "Properties",
398
- "oneOf": [
399
- {
400
- "type": "object"
401
- },
402
- {
403
- "type": "null"
404
- }
405
- ]
406
- },
407
- "id": {}
408
- }
409
- },
410
- "linearRingCoordinates": {
411
- "title": "Linear Ring Coordinates",
412
- "description": "A LinearRing is closed LineString with 4 or more positions. The first and last positions are equivalent (they represent equivalent points). Though a LinearRing is not explicitly represented as a GeoJSON geometry type, it is referred to in the Polygon geometry type definition.",
413
- "allOf": [
414
- {
415
- "$ref": "#/definitions/lineStringCoordinates"
416
- },
417
- {
418
- "minItems": 4
419
- }
420
- ]
421
- },
422
- "lineStringCoordinates": {
423
- "title": "Line String Coordinates",
424
- "description": "For type `LineString`, the `coordinates` member must be an array of two or more positions.",
425
- "allOf": [
426
- {
427
- "$ref": "#/definitions/coordinates"
428
- },
429
- {
430
- "minLength": 2,
431
- "items": {
432
- "$ref": "#/definitions/position"
433
- }
434
- }
435
- ]
436
- },
437
- "polygonCoordinates": {
438
- "title": "Polygon Coordinates",
439
- "description": "For type `Polygon`, the `coordinates` member must be an array of LinearRing coordinate arrays. For Polygons with multiple rings, the first must be the exterior ring and any others must be interior rings or holes.",
440
- "allOf": [
441
- {
442
- "$ref": "#/definitions/coordinates"
443
- },
444
- {
445
- "items": {
446
- "$ref": "#/definitions/linearRingCoordinates"
447
- }
448
- }
449
- ]
450
- },
451
- "position": {
452
- "title": "Position",
453
- "type": "array",
454
- "description": "A position is the fundamental geometry construct. The `coordinates` member of a geometry object is composed of one position (in the case of a Point geometry), an array of positions (LineString or MultiPoint geometries), an array of arrays of positions (Polygons, MultiLineStrings), or a multidimensional array of positions (MultiPolygon).\n\nA position is represented by an array of numbers. There must be at least two elements, and may be more. The order of elements must follow x, y, z order (easting, northing, altitude for coordinates in a projected coordinate reference system, or longitude, latitude, altitude for coordinates in a geographic coordinate reference system). Any number of additional elements are allowed -- interpretation and meaning of additional elements is beyond the scope of this specification.",
455
- "minItems": 2,
456
- "additionalItems": true,
457
- "items": {
458
- "type": "number"
459
- }
460
- }
461
- }
462
- }