Skip to content

Commit bd67a19

Browse files
authored
Merge pull request #7 from cividi/fix-json-schema
an initial json schema
2 parents 0bc41ed + 42ead6d commit bd67a19

File tree

7 files changed

+8273
-56
lines changed

7 files changed

+8273
-56
lines changed

.github/workflows/test.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Validate Data Package and Schema
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
repository_dispatch:
8+
9+
jobs:
10+
validate:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v2
14+
- uses: actions/setup-node@v2
15+
with:
16+
node-version: "12"
17+
- name: Install data-cli
18+
run: |
19+
npm install
20+
- name: Validate Data Package and Schema
21+
shell: "bash"
22+
id: validation
23+
run: |
24+
out=$(npm run test)
25+
out="${out//'%'/'%25'}"
26+
out="${out//$'\n'/'%0A'}"
27+
out="${out//$'\r'/'%0D'}"
28+
echo $out
29+
echo "::set-output name=data-validate::$out\n"
30+
- name: Check for Failure
31+
if: contains(steps.validation.outputs.data-validate,'Error')
32+
env:
33+
OUTPUT: ${{ steps.validation.outputs.data-validate }}
34+
run: |
35+
echo $OUTPUT
36+
exit 1

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
process
2+
node_modules

README.md

Lines changed: 127 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,51 @@
1-
# Geospatial Datapackage Specification
1+
# (Geo) Spatial Data Package Specification
22

3-
This is an example Geospatial Data Package.
3+
This document outlines a (geo) spatial data package [profile](https://specs.frictionlessdata.io/profiles/) for [JSON-based](https://en.wikipedia.org/wiki/JSON) [Frictionless Data Packages](https://specs.frictionlessdata.io/data-package/), also called a Snapshot.
44

5-
This datapackage follows the [Frictionless Data Specification](https://frictionlessdata.io) and defines a way of specifying a simple map view based on geojsons as a data resource to the package.
5+
It follows the [Frictionless Data Specification](https://frictionlessdata.io) and provides a simple, human-readable way of defining map views with [styled](https://github.com/cividi/simplestyle-extended-spec) [GeoJSON](https://geojson.org) documents.
66

7-
## Datapackage Structure
7+
## Usage
88

9-
### Licenses and Sources
9+
### Editor Linting
10+
11+
To add linting support to your editor (e.g. VS Code has built in support) you can check directly against the [JSON schema `schema/snapshot.json`](schema/snapshot.json).
12+
13+
Simply add
14+
```json
15+
"$schema": "https://raw.githubusercontent.com/cividi/spatial-data-package-spec/main/schemas/snapshot.json"
16+
```
17+
to your data package and enable linting support for JSON schemas.
18+
19+
### Validation with Frictionless Tools
20+
21+
Make sure to include
22+
```json
23+
"profile": "https://raw.githubusercontent.com/cividi/spatial-data-package-spec/main/schemas/snapshot.json"
24+
```
25+
in your Snapshot file. You can then use Frictionless Tools, e.g. data-cli to validate the schema and tabular data:
26+
```sh
27+
data validate . # Looks for datapackage.json in current folder
28+
```
29+
30+
## Detailed Data Package Structure
31+
32+
In addition to the basic structure of a Data Package (cf. [Frictionless Data Package](https://specs.frictionlessdata.io/data-package/)) requiring
33+
34+
1. a `name` and
35+
1. a `resource`
1036

11-
- `Licenses:` Defines the details of the licenses
12-
- `Sources`: Sources that have been used as input
37+
a Snapshots (Spatial Data Package) also require (technical details see below)
38+
39+
1. a `view` – Defining how the map can be rendered
40+
1. a `source` – Listing data sources
41+
1. `resource`s added to a `view` to be either
42+
- a simple-style GeoJSON – for Lines, Polygons, Markers
43+
- a simple-style-extended GeoJSON – for Circles
44+
- a mapbox style URL – for a background map
45+
46+
### Examples
47+
48+
A valid example can be found in [`datapackage.json`](datapackage.json).
1349

1450
### Resources
1551

@@ -18,7 +54,7 @@ An array of resources with links to or the data itself. Includes a resource `nam
1854
Possible Mediatypes
1955

2056
- `application/geo+json`: GeoJSON with [Mapbox Simple Styles](https://github.com/mapbox/simplestyle-spec)
21-
- `application/vnd.simplestyle-extended`: GeoJSON with [Extended Simple Styles](https://github.com/cividitech/simplestyle-extended-spec)
57+
- `application/vnd.simplestyle-extended`: GeoJSON with [Extended Simple Styles](https://github.com/cividi/simplestyle-extended-spec)
2258
- `application/vnd.mapbox-vector-tile`: Mapbox URI for styled vector tiles
2359

2460
### Views
@@ -31,54 +67,110 @@ For a map view compatible with the [Gemeindescan-Project](https://bitbucket.org/
3167

3268
```json
3369
{
34-
"name": "mapview",
35-
"resources": [
36-
"geojson-resource-name-1",
37-
"geojson-resource-name-2",
38-
"mapbox-resource-name"
70+
"name": "package-name",
71+
"profile": "https://raw.githubusercontent.com/cividi/spatial-data-package-spec/main/schemas/snapshot.json",
72+
"views":[
73+
{
74+
"name": "mapview",
75+
"resources": [
76+
"geojson-resource-name-1",
77+
"mapbox-resource-name"
78+
],
79+
"specType": "gemeindescanSnapshot",
80+
"spec": {
81+
"title": "Snapshot Title",
82+
"description": "Snapshot Description",
83+
"bounds": [
84+
"geo:47.43668029143545,9.355459213256836",
85+
"geo:47.483104811626674,9.424123764038086"
86+
],
87+
"legend": [{
88+
"label": "Legend text",
89+
"shape": "square",
90+
"size": 0.5,
91+
"primary": true,
92+
"fillColor": "#ffffff",
93+
"fillOpacity": 0.2,
94+
"strokeColor": "#000000",
95+
"strokeOpacity": 1,
96+
"strokeWidth": 1
97+
}]
98+
}
99+
}
39100
],
40-
"specType": "gemeindescanSnapshot",
41-
"spec": {
42-
"title": "Snapshot Title",
43-
"description": "Snapshot Description",
44-
"bounds": [
45-
"geo:47.43668029143545,9.355459213256836",
46-
"geo:47.483104811626674,9.424123764038086"
47-
],
48-
"legend": [{
49-
"shape": "square",
50-
"size": 0.5,
51-
"color": "#fff",
52-
"opacity": 0.2,
53-
"label": "Legend text",
54-
"primary": true
55-
}]
56-
}
101+
"resources":[
102+
{
103+
"name": "geojson-resource-name-1",
104+
"mediatype": "application/vnd.simplestyle-extended",
105+
"data": {
106+
"type": "FeatureCollection",
107+
"features": [{
108+
"type": "Feature",
109+
"geometry": {
110+
"type": "Point",
111+
"coordinates": [9.38771, 47.46058]
112+
},
113+
"properties": {
114+
"fid": 1,
115+
"radius": 200,
116+
"fillColor": "red",
117+
"fillOpacity": 0.2,
118+
"title": "Centerpoint",
119+
"color": "red",
120+
"weight": 1,
121+
"opacity": 0.8
122+
}
123+
}]
124+
}
125+
},
126+
{
127+
"path": "mapbox://styles/gemeindescan/ckc4sha4310d21iszp8ri17u2",
128+
"mediatype": "application/vnd.mapbox-vector-tile",
129+
"name": "mapbox-resource-name"
130+
}
131+
]
57132
}
58133
```
59134

60135
- `name`: name of the view (unique within datapackage)
61136
- `resources`: an array of resource-names (see above) in order of rendering, first will be lowest in render order
62-
- `specType`: currently only `map` is supported here
137+
- `specType`: currently only `gemeindescanSnapshot` is supported here
63138
- `spec`: Metainformation to render a full map view
64139
- `title`: Title of the View
65140
- `description`: Description of the View
66141
- `bounds`: array of bounding box support geopoints, denoted as Geo-URI as defined by [RFC5870](https://tools.ietf.org/html/rfc5870), latitude first
67142
- `legend`: Legend entries for the view
143+
- `label`: legend entry text
68144
- `shape`: one of square, circle or line
69145
- `size`: relative size in percent, either size of the sqaure or circle or line thickness
70-
- `color`: fill/main color
71-
- `opacity`: opacity value
72-
- `label`: legend entry text
73146
- `primary`: can be used for simplifying the legend to less elements in size constraint contexts
147+
- `fillColor`: fill/main color
148+
- `fillOpacity`: opacity value
149+
- `strokeColor`: stroke color
150+
- `strokeOpacity`: stroke opacity
151+
- `strokeWidth`: stroke width
152+
153+
### Licenses and Sources
154+
155+
- `Licenses:` *optional* Defines the details of the licenses
156+
- `Sources`: Sources that have been used
74157

75158
### Contributors and Maintainers
76159

77160
Each represents an array of people and institutions, companies involved in creating and maintaining the datapackage.
78161

162+
## Unit testing
163+
164+
To validate [`datapackage.json`](datapackage.json) against the current schema, run
165+
166+
```sh
167+
npm install
168+
npm run test
169+
```
170+
79171
## Sample Data
80172

81-
Data comes from open data sources via the [CIVIDI project](https://cividi.ch).
173+
Data comes from open data sources via the [cividi project](https://cividi.ch).
82174

83175
## License
84176

datapackage.json

Lines changed: 38 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,9 @@
22
"name": "gemeindescan-snapshot-sample",
33
"title": "Gemeindescan Snapshot Sample",
44
"keywords": ["europe", "switzerland", "gemeindescan", "geodata"],
5-
"format": "geojson",
5+
"profile": "https://raw.githubusercontent.com/cividi/spatial-data-package-spec/main/schemas/snapshot.json",
66
"description": "",
7-
"datapackage_version": "1.0.0",
8-
"gemeindescan_version": "0.2",
9-
"last_modified": "2020-02-17",
10-
"version": "1.0.0",
7+
"last_modified": "2021-02-20",
118
"license": "ODC-By-1.0",
129
"licenses": [{
1310
"type": "ODC-By-1.0",
@@ -17,9 +14,11 @@
1714
"title": "swissBOUNDARIES3D municipal boundaries",
1815
"url": "https://opendata.swiss/en/dataset/swissboundaries3d-gemeindegrenzen"
1916
}],
20-
"resources": [{
17+
"resources": [
18+
{
2119
"title": "Gemeinden",
2220
"description": "Gemeinde und Nachbargemeinden",
21+
"profile": "https://json.schemastore.org/geojson",
2322
"mediatype": "application/geo+json",
2423
"name": "gemeinden-geojson",
2524
"data": {
@@ -8850,6 +8849,7 @@
88508849
}, {
88518850
"name": "circle-layer",
88528851
"mediatype": "application/vnd.simplestyle-extended",
8852+
"profile": "https://json.schemastore.org/geojson",
88538853
"data": {
88548854
"type": "FeatureCollection",
88558855
"features": [{
@@ -8861,18 +8861,18 @@
88618861
"properties": {
88628862
"fid": 1,
88638863
"radius": 200,
8864-
"fill": "red",
8865-
"fill-opacity": 0.2,
8864+
"fillColor": "red",
8865+
"fillOpacity": 0.2,
88668866
"title": "Centerpoint",
8867-
"stroke": "red",
8868-
"stroke-width": 1,
8869-
"stroke-opacity": 0.8
8867+
"color": "red",
8868+
"weight": 1,
8869+
"opacity": 0.8
88708870
}
88718871
}]
88728872
}
88738873
},
88748874
{
8875-
"path": "mapbox://styles/gemeindescan/ck6qnoijj28od1is9u1wbb3vr",
8875+
"path": "mapbox://styles/gemeindescan/ckc4sha4310d21iszp8ri17u2",
88768876
"mediatype": "application/vnd.mapbox-vector-tile",
88778877
"name": "mapbox-background"
88788878
}
@@ -8894,20 +8894,37 @@
88948894
"geo:47.483104811626674,9.424123764038086"
88958895
],
88968896
"legend": [{
8897+
"label": "Square",
88978898
"shape": "square",
8899+
"primary": false,
88988900
"size": 1,
8899-
"color": "#32b6ca",
8900-
"opacity": 1,
8901-
"label": "Gemeinde",
8902-
"primary": true
8901+
"fillColor": "#32b6ca",
8902+
"fillOpacity": 0.6,
8903+
"strokeColor": "#32b6ca",
8904+
"strokeOpacity": 1,
8905+
"strokeWidth": 1.5
89038906
},
89048907
{
8905-
"shape": "square",
8908+
"label": "Circle",
8909+
"shape": "circle",
8910+
"primary": true,
8911+
"size": 1,
8912+
"fillColor": "#6a6a6a",
8913+
"fillOpacity": 0.2,
8914+
"strokeColor": "#6a6a6a",
8915+
"strokeOpacity": 0.25,
8916+
"strokeWidth": 1
8917+
},
8918+
{
8919+
"label": "Line",
8920+
"shape": "line",
8921+
"primary": true,
89068922
"size": 1,
8907-
"color": "#6a6a6a",
8908-
"opacity": 1,
8909-
"label": "Nachbargemeinde",
8910-
"primary": true
8923+
"fillColor": "#000",
8924+
"fillOpacity": 0,
8925+
"strokeColor": "#000000",
8926+
"strokeOpacity": 1,
8927+
"strokeWidth": 0.5
89118928
}
89128929
]
89138930
}

0 commit comments

Comments
 (0)