Skip to content

Commit d207d6a

Browse files
authored
Merge pull request #88 from terminusdb/nuclear_geojson
Nuclear geojson
2 parents 01ca9f5 + 896b08e commit d207d6a

File tree

3 files changed

+65
-28
lines changed

3 files changed

+65
-28
lines changed

nuclear/geo_schema.json

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,35 @@
11
[
22
{ "@type" : "Class",
3-
"@id" : "GeoCoordinate",
4-
"@subdocument" : [],
5-
"@key" : { "@type" : "Lexical",
6-
"@fields" : ["latitude", "longitude"] },
7-
"latitude" : "xsd:decimal",
8-
"longitude" : "xsd:decimal"
3+
"@id" : "GeoJSON",
4+
"@abstract" : [],
5+
"bbox" : { "@class" : "xsd:double",
6+
"@dimensions" : 1,
7+
"@type" : "Array" }
98
},
10-
119
{ "@type" : "Class",
12-
"@id" : "GeoPerimeter",
13-
"@subdocument" : [],
14-
"@key" : { "@type" : "Lexical",
15-
"@fields" : ["perimeter"] },
16-
"perimeter" : { "@type" : "List",
17-
"@class" : "GeoCoordinate" }
10+
"@id" : "Geometry",
11+
"@inherits": "GeoJSON",
12+
"@abstract" : [],
13+
"@unfoldable" : []
14+
},
15+
{
16+
"@id": "Point",
17+
"@inherits": "Geometry",
18+
"@type": "Class",
19+
"coordinates": {
20+
"@class": "xsd:double",
21+
"@dimensions": 1,
22+
"@type": "Array"
23+
},
24+
"type": "Point_Type"
25+
},
26+
{
27+
"@id": "Point_Type",
28+
"@type": "Enum",
29+
"@value": [
30+
"Point"
31+
]
1832
},
19-
2033
{ "@type" : "Class",
2134
"@id" : "Country",
2235
"@key" : { "@type" : "Lexical",

nuclear/nuclear.md

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,16 @@ if there is a problem getting into our account.
3232
```python
3333
team = os.environ['TERMINUSDB_TEAM']
3434
team_quoted = urllib.parse.quote(team)
35+
####
36+
# To use TerminusCMS
3537
client = WOQLClient(f"https://cloud.terminusdb.com/{team_quoted}/")
3638
# make sure you have put the token in environment variable
37-
# https://docs.terminusdb.com/v10.0/#/terminusx/get-your-api-key
39+
# https://terminusdb.com/docs/terminuscms/get-api-key
3840
client.connect(team=team, use_token=True)
41+
####
42+
# to connect locally, comment the above client and call and try this instead:
43+
# client = WOQLClient("http://localhost:6363/")
44+
#client.connect(team=team)
3945
```
4046

4147
Once we are in, we can start to build our data product. A data product
@@ -63,17 +69,20 @@ prefixes = {'@base' : 'http://lib.terminusdb.com/nuclear/',
6369

6470
Now we get to the meat. We will want to describe *where* our reactors
6571
are. In order to do that we need a geo-coordinate. Hence we've created
66-
a small schema called `geo_schema.json`, which has (among other
67-
things), the following definition:
72+
a small schema called `geo_schema.json`, which is a subset of the
73+
GeoJSON schema, and has (among other things) a point type, with the
74+
following definition:
6875

6976
```json
70-
{ "@type" : "Class",
71-
"@id" : "GeoCoordinate",
72-
"@subdocument" : [],
73-
"@key" : { "@type" : "Lexical",
74-
"@fields" : ["latitude", "longitude"] },
75-
"latitude" : "xsd:decimal",
76-
"longitude" : "xsd:decimal"
77+
{ "@id": "Point",
78+
"@inherits": "Geometry",
79+
"@type": "Class",
80+
"coordinates": {
81+
"@class": "xsd:decimal",
82+
"@dimensions": 1,
83+
"@type": "Array"
84+
},
85+
"type": "Point_Type"
7786
}
7887
```
7988

@@ -370,9 +379,9 @@ def import_nuclear(client):
370379
plant = { '@type' : "NuclearPowerPlant",
371380
'name' : name,
372381
'country' : { '@ref' : f"Country/{country_long}" },
373-
'location' : { '@type' : 'GeoCoordinate',
374-
'latitude' : latitude,
375-
'longitude' : longitude },
382+
'location' : { '@type' : "Point",
383+
'type' : "Point",
384+
'coordinates': [latitude, longitude] },
376385
'capacity' : { '@type' : 'Quantity',
377386
'unit' : 'Unit/MWe',
378387
'quantity' : capacity_mw },

nuclear/nuclear_schema.json

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,25 @@
4444
"reactors" : "Reactors that are present at the power plant"
4545
}
4646
},
47+
"@metadata" : {
48+
"order_by" : [
49+
"name",
50+
"country",
51+
"capacity",
52+
"owner",
53+
"commissioning_year",
54+
"location",
55+
"capacity_factor",
56+
"output",
57+
"url",
58+
"gppd_idnr",
59+
"reactors"
60+
]
61+
},
4762
"@key" : { "@type" : "Lexical",
4863
"@fields" : ["name"] },
4964
"name" : "xsd:string",
50-
"location" : "GeoCoordinate",
65+
"location" : "Point",
5166
"country" : "Country",
5267
"capacity" : "Quantity",
5368
"capacity_factor" : { "@type" : "Set",

0 commit comments

Comments
 (0)