Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit bc0ebd8

Browse files
committedJul 14, 2020
Use discriminator on GeoJSON types
1 parent e1c243f commit bc0ebd8

File tree

2 files changed

+84
-62
lines changed

2 files changed

+84
-62
lines changed
 

‎geojson-ld.yaml

+71-42
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@
33
# see https://github.com/smart-data-models
44

55
# Standard GeoJSON terms.
6-
Geometry:
6+
Geometry:
77
description: "GeoJSon geometry"
88
externalDocs:
99
url: "http://geojson.org/geojson-spec.html#geometry-objects"
10-
properties:
11-
type:
10+
type: object
11+
discriminator:
12+
propertyName: type
13+
properties:
14+
type:
15+
type: string
1216
description: "the geometry type"
1317
enum:
1418
- Point
@@ -17,21 +21,50 @@ Geometry:
1721
- MultiPoint
1822
- MultiLineString
1923
- MultiPolygon
20-
type: string
21-
required:
24+
required:
2225
- type
23-
type: object
26+
- coordinates
2427
x-ngsi:
2528
type: GeoProperty
29+
30+
Point:
31+
allOf:
32+
-
33+
$ref: "#/Geometry"
34+
-
35+
properties:
36+
type:
37+
type: string
38+
description: "the geometry type"
39+
enum:
40+
- Point
41+
coordinates: &Position
42+
items:
43+
type: number
44+
maxItems: 3
45+
minItems: 2
46+
type: array
47+
description: "GeoJSON Point"
48+
externalDocs:
49+
url: "http://geojson.org/geojson-spec.html#id2"
50+
type: object
51+
x-ngsi:
52+
uri: "https://purl.org/geojson/vocab#Point"
53+
uri-prefix: "https://purl.org/geojson/vocab#"
54+
2655
LineString:
2756
allOf:
2857
-
2958
$ref: "#/Geometry"
3059
-
3160
properties:
61+
type:
62+
type: string
63+
description: "the geometry type"
64+
enum:
65+
- LineString
3266
coordinates:
33-
items:
34-
$ref: "#/Point2D"
67+
items: *Position
3568
type: array
3669
description: "GeoJSON LineString"
3770
externalDocs:
@@ -40,16 +73,20 @@ LineString:
4073
x-ngsi:
4174
uri: "https://purl.org/geojson/vocab#LineString"
4275
uri-prefix: "https://purl.org/geojson/vocab#"
43-
MultiLineString:
76+
MultiLineString:
4477
allOf:
4578
-
4679
$ref: "#/Geometry"
4780
-
4881
properties:
82+
type:
83+
type: string
84+
description: "the geometry type"
85+
enum:
86+
- MultiLineString
4987
coordinates:
5088
items:
51-
items:
52-
$ref: "#/Point2D"
89+
items: *Position
5390
type: array
5491
type: array
5592
description: "GeoJSON Multi Line String"
@@ -59,15 +96,19 @@ MultiLineString:
5996
x-ngsi:
6097
uri: "https://purl.org/geojson/vocab#MultiLineString"
6198
uri-prefix: "https://purl.org/geojson/vocab#"
62-
MultiPoint:
99+
MultiPoint:
63100
allOf:
64101
-
65102
$ref: "#/Geometry"
66103
-
67104
properties:
105+
type:
106+
type: string
107+
description: "the geometry type"
108+
enum:
109+
- MultiPoint
68110
coordinates:
69-
items:
70-
$ref: "#/Point2D"
111+
items: *Position
71112
type: array
72113
description: "GeoJSON Multi Point"
73114
externalDocs:
@@ -76,17 +117,21 @@ MultiPoint:
76117
x-ngsi:
77118
uri: "https://purl.org/geojson/vocab#MultiPoint"
78119
uri-prefix: "https://purl.org/geojson/vocab#"
79-
MultiPolygon:
120+
MultiPolygon:
80121
allOf:
81122
-
82123
$ref: "#/Geometry"
83124
-
84125
properties:
126+
type:
127+
type: string
128+
description: "the geometry type"
129+
enum:
130+
- MultiPolygon
85131
coordinates:
86132
items:
87133
items:
88-
items:
89-
$ref: "#/Point2D"
134+
items: *Position
90135
type: array
91136
type: array
92137
type: array
@@ -97,37 +142,21 @@ MultiPolygon:
97142
x-ngsi:
98143
uri: "https://purl.org/geojson/vocab#MultiPolygon"
99144
uri-prefix: "https://purl.org/geojson/vocab#"
100-
Point:
101-
allOf:
102-
-
103-
$ref: "#/Geometry"
104-
-
105-
properties:
106-
coordinates:
107-
$ref: "#/Point2D"
108-
description: "GeoJSON Point"
109-
externalDocs:
110-
url: "http://geojson.org/geojson-spec.html#id2"
111-
type: object
112-
x-ngsi:
113-
uri: "https://purl.org/geojson/vocab#Point"
114-
uri-prefix: "https://purl.org/geojson/vocab#"
115-
Point2D:
116-
items:
117-
type: number
118-
maxItems: 2
119-
minItems: 2
120-
type: array
145+
121146
Polygon:
122147
allOf:
123148
-
124149
$ref: "#/Geometry"
125150
-
126-
properties:
151+
properties:
152+
type:
153+
type: string
154+
description: "the geometry type"
155+
enum:
156+
- Polygon
127157
coordinates:
128158
items:
129-
items:
130-
$ref: "#/Point2D"
159+
items: *Position
131160
type: array
132161
type: array
133162
description: "GeoJSON Polygon"
@@ -136,4 +165,4 @@ Polygon:
136165
type: object
137166
x-ngsi:
138167
uri: "https://purl.org/geojson/vocab#Polygon"
139-
uri-prefix: "https://purl.org/geojson/vocab#"
168+
uri-prefix: "https://purl.org/geojson/vocab#"

‎ngsi-ld.yaml

+13-20
Original file line numberDiff line numberDiff line change
@@ -65,26 +65,19 @@ location:
6565
description: "The current location of the item\n"
6666
externalDocs:
6767
url: "http://geojson.org/geojson-spec.html#geometry-objects"
68-
properties:
69-
coordinates:
70-
oneOf:
71-
-
72-
$ref: "./geojson-ld.yaml#/Point/allOf/1/properties/coordinates"
73-
-
74-
$ref: "./geojson-ld.yaml#/LineString/allOf/1/properties/coordinates"
75-
-
76-
$ref: "./geojson-ld.yaml#/Polygon/allOf/1/properties/coordinates"
77-
-
78-
$ref: "./geojson-ld.yaml#/MultiPoint/allOf/1/properties/coordinates"
79-
-
80-
$ref: "./geojson-ld.yaml#/MultiLineString/allOf/1/properties/coordinates"
81-
-
82-
$ref: "./geojson-ld.yaml#/MultiPolygon/allOf/1/properties/coordinates"
83-
type:
84-
$ref: "./geojson-ld.yaml#/Geometry/properties/type"
85-
required:
86-
- type
87-
- coordinates
68+
oneOf:
69+
-
70+
$ref: "./geojson-ld.yaml#Point"
71+
-
72+
$ref: "./geojson-ld.yaml#LineString"
73+
-
74+
$ref: "./geojson-ld.yaml#Polygon"
75+
-
76+
$ref: "./geojson-ld.yaml#MultiPoint"
77+
-
78+
$ref: "./geojson-ld.yaml#MultiLineString"
79+
-
80+
$ref: "./geojson-ld.yaml#MultiPolygon"
8881
type: object
8982
x-ngsi:
9083
model:

0 commit comments

Comments
 (0)
Please sign in to comment.