Skip to content

Commit

Permalink
Integrate with GeoJSON v1.0.5
Browse files Browse the repository at this point in the history
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
jviotti committed Jan 29, 2025
1 parent cd3eab6 commit 52bb3a9
Showing 23 changed files with 363 additions and 2 deletions.
1 change: 1 addition & 0 deletions DEPENDENCIES
Original file line number Diff line number Diff line change
@@ -39,3 +39,4 @@ jsonschema-draft7 https://github.com/json-schema-org/json-schema-spec 567f768506
jsonschema-draft6 https://github.com/json-schema-org/json-schema-spec 59ed5f6fc6f6386e23ca51d7f31d7fe9cf696713
jsonschema-draft4 https://github.com/json-schema-org/json-schema-spec dba92b702c94858162f653590230e7573c8b7dd0
openapi https://github.com/OAI/OpenAPI-Specification 3.1.1
geojson-1-0-5 https://github.com/geojson/schema v1.0.5
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM ghcr.io/sourcemeta/registry-ee:main AS builder
RUN apt-get --yes update && apt-get install --yes --no-install-recommends make
RUN apt-get --yes update && apt-get install --yes --no-install-recommends make nodejs
COPY configuration.json /app/configuration.json
COPY vendor /app/vendor
COPY Makefile /app/Makefile
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
NODE ?= node
MKDIR ?= mkdir
CMAKE ?= cmake

# For local development, assuming https://github.com/sourcemeta/registry
# is cloned and built as a sibling directory of this repository
REGISTRY ?= ../registry/build/dist/bin
@@ -15,8 +18,13 @@ endif
all: prepare index
$(REGISTRY)/sourcemeta-registry-server $(OUTPUT)

$(BUILD)/geojson-1-0-5/%.json: vendor/geojson-1-0-5/bin/format.js vendor/geojson-1-0-5/src/schema/%.js
$(MKDIR) -p $(dir $@)
$(NODE) $< $(word 2,$^) > $@

.PHONY: prepare
prepare:
prepare: \
$(patsubst vendor/geojson-1-0-5/src/schema/%.js,$(BUILD)/geojson-1-0-5/%.json,$(wildcard vendor/geojson-1-0-5/src/schema/*.js))
$(LDD) $(REGISTRY)/sourcemeta-registry-index
$(LDD) $(REGISTRY)/sourcemeta-registry-server

10 changes: 10 additions & 0 deletions configuration.json
Original file line number Diff line number Diff line change
@@ -124,6 +124,12 @@
"email": "tsc@openapi.groups.io",
"github": "oai",
"website": "https://openapis.org"
},
"geojson": {
"title": "GeoJSON",
"description": "A format for encoding a variety of geographic data structures",
"github": "geojson",
"website": "https://geojson.org"
}
},
"schemas": {
@@ -301,6 +307,10 @@
"openapi/v3.0": {
"base": "https://spec.openapis.org/oas/3.0/schema/2021-09-28",
"path": "./vendor/openapi/schemas/v3.0"
},
"geojson/v1.0.5": {
"base": "https://geojson.org/schema",
"path": "./build/geojson-1-0-5"
}
}
}
7 changes: 7 additions & 0 deletions vendor/geojson-1-0-5.mask
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
test/
package-lock.json
bin/transform-package-json.js
Makefile
package-lock.json
package.json
readme.md
42 changes: 42 additions & 0 deletions vendor/geojson-1-0-5/bin/format.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env node
import path from 'path';

async function main() {
const baseURL = 'https://geojson.org/schema/';
const command = path.basename(process.argv[1]);
const usage = `${command} <input>
Provided the path to a schema module (e.g. src/schema/Point.js), ${command}
will write the formatted JSON schema to stdout.
`;

if (!process.argv[2]) {
throw new Error(usage);
}

const input = path.resolve(process.argv[2]);

let schema;
try {
const mod = await import(input);
schema = mod.default;
} catch (err) {
throw new Error(`Failed to import ${input}: ${err.message}\n`);
}

return Object.assign(
{
$schema: 'http://json-schema.org/draft-07/schema#',
$id: `${baseURL}${path.basename(input)}on`,
},
schema
);
}

main()
.then((schema) => {
process.stdout.write(JSON.stringify(schema, null, 2) + '\n');
})
.catch((err) => {
process.stderr.write(err.message + '\n', () => process.exit(1));
});
21 changes: 21 additions & 0 deletions vendor/geojson-1-0-5/license.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# MIT License

Copyright (c) 2018 Tim Schaub

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
39 changes: 39 additions & 0 deletions vendor/geojson-1-0-5/src/schema/Feature.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import BoundingBox from './ref/BoundingBox.js';
import GeometryCollection from './GeometryCollection.js';
import LineString from './LineString.js';
import MultiLineString from './MultiLineString.js';
import MultiPoint from './MultiPoint.js';
import MultiPolygon from './MultiPolygon.js';
import Point from './Point.js';
import Polygon from './Polygon.js';

export default {
title: 'GeoJSON Feature',
type: 'object',
required: ['type', 'properties', 'geometry'],
properties: {
type: {
type: 'string',
enum: ['Feature'],
},
id: {
oneOf: [{type: 'number'}, {type: 'string'}],
},
properties: {
oneOf: [{type: 'null'}, {type: 'object'}],
},
geometry: {
oneOf: [
{type: 'null'},
Point,
LineString,
Polygon,
MultiPoint,
MultiLineString,
MultiPolygon,
GeometryCollection,
],
},
bbox: BoundingBox,
},
};
19 changes: 19 additions & 0 deletions vendor/geojson-1-0-5/src/schema/FeatureCollection.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import BoundingBox from './ref/BoundingBox.js';
import Feature from './Feature.js';

export default {
title: 'GeoJSON FeatureCollection',
type: 'object',
required: ['type', 'features'],
properties: {
type: {
type: 'string',
enum: ['FeatureCollection'],
},
features: {
type: 'array',
items: Feature,
},
bbox: BoundingBox,
},
};
24 changes: 24 additions & 0 deletions vendor/geojson-1-0-5/src/schema/GeoJSON.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import Feature from './Feature.js';
import FeatureCollection from './FeatureCollection.js';
import GeometryCollection from './GeometryCollection.js';
import LineString from './LineString.js';
import MultiLineString from './MultiLineString.js';
import MultiPoint from './MultiPoint.js';
import MultiPolygon from './MultiPolygon.js';
import Point from './Point.js';
import Polygon from './Polygon.js';

export default {
title: 'GeoJSON',
oneOf: [
Point,
LineString,
Polygon,
MultiPoint,
MultiLineString,
MultiPolygon,
GeometryCollection,
Feature,
FeatureCollection,
],
};
18 changes: 18 additions & 0 deletions vendor/geojson-1-0-5/src/schema/Geometry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import LineString from './LineString.js';
import MultiLineString from './MultiLineString.js';
import MultiPoint from './MultiPoint.js';
import MultiPolygon from './MultiPolygon.js';
import Point from './Point.js';
import Polygon from './Polygon.js';

export default {
title: 'GeoJSON Geometry',
oneOf: [
Point,
LineString,
Polygon,
MultiPoint,
MultiLineString,
MultiPolygon,
],
};
33 changes: 33 additions & 0 deletions vendor/geojson-1-0-5/src/schema/GeometryCollection.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import BoundingBox from './ref/BoundingBox.js';
import LineString from './LineString.js';
import MultiLineString from './MultiLineString.js';
import MultiPoint from './MultiPoint.js';
import MultiPolygon from './MultiPolygon.js';
import Point from './Point.js';
import Polygon from './Polygon.js';

export default {
title: 'GeoJSON GeometryCollection',
type: 'object',
required: ['type', 'geometries'],
properties: {
type: {
type: 'string',
enum: ['GeometryCollection'],
},
geometries: {
type: 'array',
items: {
oneOf: [
Point,
LineString,
Polygon,
MultiPoint,
MultiLineString,
MultiPolygon,
],
},
},
bbox: BoundingBox,
},
};
16 changes: 16 additions & 0 deletions vendor/geojson-1-0-5/src/schema/LineString.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import BoundingBox from './ref/BoundingBox.js';
import LineStringCoordinates from './ref/LineStringCoordinates.js';

export default {
title: 'GeoJSON LineString',
type: 'object',
required: ['type', 'coordinates'],
properties: {
type: {
type: 'string',
enum: ['LineString'],
},
coordinates: LineStringCoordinates,
bbox: BoundingBox,
},
};
19 changes: 19 additions & 0 deletions vendor/geojson-1-0-5/src/schema/MultiLineString.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import BoundingBox from './ref/BoundingBox.js';
import LineStringCoordinates from './ref/LineStringCoordinates.js';

export default {
title: 'GeoJSON MultiLineString',
type: 'object',
required: ['type', 'coordinates'],
properties: {
type: {
type: 'string',
enum: ['MultiLineString'],
},
coordinates: {
type: 'array',
items: LineStringCoordinates,
},
bbox: BoundingBox,
},
};
19 changes: 19 additions & 0 deletions vendor/geojson-1-0-5/src/schema/MultiPoint.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import BoundingBox from './ref/BoundingBox.js';
import PointCoordinates from './ref/PointCoordinates.js';

export default {
title: 'GeoJSON MultiPoint',
type: 'object',
required: ['type', 'coordinates'],
properties: {
type: {
type: 'string',
enum: ['MultiPoint'],
},
coordinates: {
type: 'array',
items: PointCoordinates,
},
bbox: BoundingBox,
},
};
19 changes: 19 additions & 0 deletions vendor/geojson-1-0-5/src/schema/MultiPolygon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import BoundingBox from './ref/BoundingBox.js';
import PolygonCoordinates from './ref/PolygonCoordinates.js';

export default {
title: 'GeoJSON MultiPolygon',
type: 'object',
required: ['type', 'coordinates'],
properties: {
type: {
type: 'string',
enum: ['MultiPolygon'],
},
coordinates: {
type: 'array',
items: PolygonCoordinates,
},
bbox: BoundingBox,
},
};
16 changes: 16 additions & 0 deletions vendor/geojson-1-0-5/src/schema/Point.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import BoundingBox from './ref/BoundingBox.js';
import PointCoordinates from './ref/PointCoordinates.js';

export default {
title: 'GeoJSON Point',
type: 'object',
required: ['type', 'coordinates'],
properties: {
type: {
type: 'string',
enum: ['Point'],
},
coordinates: PointCoordinates,
bbox: BoundingBox,
},
};
16 changes: 16 additions & 0 deletions vendor/geojson-1-0-5/src/schema/Polygon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import BoundingBox from './ref/BoundingBox.js';
import PolygonCoordinates from './ref/PolygonCoordinates.js';

export default {
title: 'GeoJSON Polygon',
type: 'object',
required: ['type', 'coordinates'],
properties: {
type: {
type: 'string',
enum: ['Polygon'],
},
coordinates: PolygonCoordinates,
bbox: BoundingBox,
},
};
7 changes: 7 additions & 0 deletions vendor/geojson-1-0-5/src/schema/ref/BoundingBox.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default {
type: 'array',
minItems: 4,
items: {
type: 'number',
},
};
7 changes: 7 additions & 0 deletions vendor/geojson-1-0-5/src/schema/ref/LineStringCoordinates.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import PointCoordinates from './PointCoordinates.js';

export default {
type: 'array',
minItems: 2,
items: PointCoordinates,
};
7 changes: 7 additions & 0 deletions vendor/geojson-1-0-5/src/schema/ref/LinearRingCoordinates.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import PointCoordinates from './PointCoordinates.js';

export default {
type: 'array',
minItems: 4,
items: PointCoordinates,
};
7 changes: 7 additions & 0 deletions vendor/geojson-1-0-5/src/schema/ref/PointCoordinates.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default {
type: 'array',
minItems: 2,
items: {
type: 'number',
},
};
6 changes: 6 additions & 0 deletions vendor/geojson-1-0-5/src/schema/ref/PolygonCoordinates.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import LinearRingCoordinates from './LinearRingCoordinates.js';

export default {
type: 'array',
items: LinearRingCoordinates,
};

0 comments on commit 52bb3a9

Please sign in to comment.