|
1 | 1 | # Enter |
2 | 2 |
|
3 | | -We use [DDEV](https://ddev.com/) for development: |
| 3 | +We use [DDEV](https://ddev.com/) and [Task](https://taskfile.dev/) for development: |
4 | 4 |
|
5 | 5 | ``` shell |
6 | | -ddev start |
| 6 | +task site:install |
| 7 | + |
| 8 | +``` shell |
| 9 | +task site:update |
7 | 10 | ddev launch |
8 | 11 | ``` |
| 12 | + |
| 13 | +## Broker |
| 14 | + |
| 15 | +A [Scorpio Broker](https://scorpio.readthedocs.io/) is part of the development setup. |
| 16 | + |
| 17 | +``` shell |
| 18 | +ddev exec "curl --silent http://scorpio.local:9090/ngsi-ld/v1/types | jq" |
| 19 | +``` |
| 20 | + |
| 21 | +Load some example data: |
| 22 | + |
| 23 | +``` shell name=import-toilet |
| 24 | +ddev console app:broker:entity:delete toilet |
| 25 | +ddev console app:broker:import:geojson toilet 'https://webkort.aarhuskommune.dk/spatialmap?page=get_geojson_opendata&datasource=andre_toiletter' |
| 26 | +ddev exec "curl --silent http://scorpio.local:9090/ngsi-ld/v1/entities --get --data-urlencode type=toilet" | jq '.[]|with_entries(select([.key] | inside(["id", "type", "location"])))' |
| 27 | +``` |
| 28 | + |
| 29 | +``` shell name=import-handicapparkering |
| 30 | +ddev console app:broker:entity:delete handicapparkering |
| 31 | +ddev console app:broker:import:geojson handicapparkering 'https://webkort.aarhuskommune.dk/spatialmap?page=get_geojson_opendata&datasource=invap' |
| 32 | +ddev exec "curl --silent http://scorpio.local:9090/ngsi-ld/v1/entities --get --data-urlencode type=handicapparkering" | jq '.[]|with_entries(select([.key] | inside(["id", "type", "location"])))' |
| 33 | +``` |
| 34 | + |
| 35 | +``` shell name=import-hundeskov |
| 36 | +ddev console app:broker:entity:delete hundeskov |
| 37 | +ddev console app:broker:import:geojson hundeskov 'https://webkort.aarhuskommune.dk/spatialmap?page=get_geojson_opendata&datasource=hundeskove_friluftsliv_aarhus' |
| 38 | +ddev exec "curl --silent http://scorpio.local:9090/ngsi-ld/v1/entities --get --data-urlencode type=hundeskov" | jq '.[]|with_entries(select([.key] | inside(["id", "type", "location", "geometry"])))' |
| 39 | +``` |
| 40 | + |
| 41 | + |
| 42 | +### Broker API request examples |
| 43 | + |
| 44 | +<https://scorpio.readthedocs.io/en/latest/API_walkthrough.html#entity-creation> |
| 45 | + |
| 46 | +``` shell name=scorpio-entity-create substitutions="{«entity-type»: Room, «entity-id»: 'house2:smartrooms:room1'}" |
| 47 | +ddev exec "curl --silent http://scorpio.local:9090/ngsi-ld/v1/entities --header 'content-type: application/json' --data @-" <<'JSON' |
| 48 | +{ |
| 49 | + "type": "«entity-type»", |
| 50 | + "id": "«entity-id»" |
| 51 | +} |
| 52 | +JSON |
| 53 | +
|
| 54 | +
|
| 55 | +# EPSG:4326?! |
| 56 | +ddev exec "curl --silent http://scorpio.local:9090/ngsi-ld/v1/entities/«entity-id»/attrs --header 'content-type: application/json' --data @-" <<'JSON' |
| 57 | +{ |
| 58 | + "location": { |
| 59 | + "type": "geo:json", |
| 60 | + "value": { |
| 61 | + "type": "Point", |
| 62 | + "coordinates": [ |
| 63 | + 10.15711687080293, 56.126271111641266 |
| 64 | + ] |
| 65 | + } |
| 66 | + } |
| 67 | +} |
| 68 | +JSON |
| 69 | +
|
| 70 | +
|
| 71 | +# Get the entities |
| 72 | +ddev exec "curl --silent --header 'accept: application/ld+json' http://scorpio.local:9090/ngsi-ld/v1/entities?type=«entity-type» | jq" |
| 73 | +
|
| 74 | +# Get the entities as GeoJSON |
| 75 | +ddev exec "curl --silent --header 'accept: application/geo+json' http://scorpio.local:9090/ngsi-ld/v1/entities?type=«entity-type» | jq" |
| 76 | +``` |
| 77 | + |
| 78 | +> [!CAUTION] |
| 79 | +> Excuse me what?! |
| 80 | +> |
| 81 | +> ``` shell |
| 82 | +> ddev exec "curl --silent --header 'accept: application/geo+json' 'http://scorpio.local:9090/ngsi-ld/v1/entities?georel=near;maxDistance%3D%3D2000&geometry=Point&coordinates=%5B8,40%5D'" |
| 83 | +> ddev exec "curl --silent --header 'accept: application/geo+json' 'http://scorpio.local:9090/ngsi-ld/v1/entities?georel=near;maxDistance==2000&geometry=Point&coordinates=%5B8,40%5D'" |
| 84 | +> ddev exec "curl --silent --header 'accept: application/geo+json' 'http://scorpio.local:9090/ngsi-ld/v1/entities?georel=near;maxDistance==2000&geometry=Point&coordinates=[10,56]'" |
| 85 | +> > ``` |
| 86 | + |
| 87 | +## GeoJSON |
| 88 | + |
| 89 | +* "[Position](https://datatracker.ietf.org/doc/html/rfc7946#section-3.1.1)": `(longitude, latitude)` |
| 90 | + * "[Coordinate Reference System](https://datatracker.ietf.org/doc/html/rfc7946#section-4)" |
| 91 | + * But … <https://gis.stackexchange.com/a/437311> |
| 92 | + |
| 93 | + <https://www.opendata.dk/city-of-aarhus/toiletter-i-aarhus-kommune> → <https://webkort.aarhuskommune.dk/spatialmap?page=get_geojson_opendata&datasource=andre_toiletter>: |
| 94 | + |
| 95 | + ```json |
| 96 | + { |
| 97 | + "type": "FeatureCollection", |
| 98 | + "crs": { |
| 99 | + "type": "name", |
| 100 | + "properties": { |
| 101 | + "name": "EPSG:25832" |
| 102 | + } |
| 103 | + }, |
| 104 | + "bbox": [563262.0903961, 6209995.05346621, 579587.800694027, 6231954.36230685], |
| 105 | + "features": [ |
| 106 | + { |
| 107 | + "type": "Feature", |
| 108 | + "geometry": { |
| 109 | + "type": "MultiPoint", |
| 110 | + "coordinates": [ |
| 111 | + [576933.018139537, 6218035.22691216] |
| 112 | + ] |
| 113 | + }, |
| 114 | + "properties": { |
| 115 | + … |
| 116 | + ``` |
| 117 | +
|
| 118 | +* <https://geojson.com/> |
| 119 | +
|
| 120 | +
|
| 121 | +--- |
| 122 | +
|
| 123 | +* <https://http.dev/tools> |
| 124 | +* <https://httpbin.io/> |
| 125 | +* <https://epsg.io/transform#s_srs=4326&t_srs=25832&x=NaN&y=NaN> |
| 126 | +* <https://fiware-datamodels.readthedocs.io/en/stable/guidelines/index.html#modelling-location> |
| 127 | +
|
| 128 | +Must `location` be a `Point` in ngsi-ld? |
| 129 | +
|
| 130 | +``` shell |
| 131 | +ddev exec --service scorpio-db "psql ngb ngb" |
| 132 | +``` |
| 133 | +
|
| 134 | +``` sql |
| 135 | +2026-08-30 10:26:19.789 UTC [41] LOG: execute 0000000: WITH D0 AS (SELECT ID, ENTITY, TRUE as PARENT FROM ENTITY WHERE ST_DWithin( location::geography, ST_SetSRID(ST_GeomFromGeoJSON('{"type": "Point", "coordinates": [10.236808047161853,56.101226991176155] }'), 4326)::geography, 2000.0) ORDER BY createdAt limit $1 offset $2) SELECT ID, ENTITY, PARENT FROM D0 |
| 136 | +``` |
| 137 | +
|
| 138 | +<https://postgis.net/docs/ST_GeomFromGeoJSON.html> |
| 139 | +
|
| 140 | +``` shell |
| 141 | +ddev exec --service scorpio-db "psql ngb ngb" <<< "SELECT id , e_types, location FROM entity;" |
| 142 | +``` |
| 143 | +
|
| 144 | +``` shell name=hmm |
| 145 | +ddev console app:import:geojson toilet 'https://webkort.aarhuskommune.dk/spatialmap?page=get_geojson_opendata&datasource=andre_toiletter' \ |
| 146 | + && ddev exec --service scorpio-db "psql ngb ngb" <<< "SELECT id , e_types, ST_AsText(location) AS location FROM entity WHERE id = 'toilet:0000';" \ |
| 147 | + && ddev exec --service scorpio-db "psql ngb ngb" <<< "SELECT temporalentity_id, ST_AsText(location) AS location, ST_asText(geovalue) AS geovalue, createdat FROM temporalentityattrinstance WHERE temporalentity_id = 'toilet:0000' ORDER BY createdat DESC LIMIT 10;" |
| 148 | +``` |
| 149 | +
|
| 150 | +<https://www.opendata.dk/search?q=res_format:GeoJSON%20organization:city-of-aarhus> |
| 151 | +
|
| 152 | +* [Public toilets in Aarhus Municipality](https://www.opendata.dk/city-of-aarhus/toiletter-i-aarhus-kommune) |
| 153 | + * [Offentlige toiletter](http://webkort.aarhuskommune.dk/spatialmap?page=get_geojson_opendata&datasource=andre_toiletter): <http://webkort.aarhuskommune.dk/spatialmap?page=get_geojson_opendata&datasource=andre_toiletter> |
| 154 | +* [Parking in Aarhus Municipality – Zones, Permits and Spaces](https://www.opendata.dk/city-of-aarhus/parkering-i-aarhus-kommune) |
| 155 | + * [Handicapparkering](https://webkort.aarhuskommune.dk/spatialmap?page=get_geojson_opendata&datasource=invap): <https://webkort.aarhuskommune.dk/spatialmap?page=get_geojson_opendata&datasource=invap> |
| 156 | +
|
| 157 | +* <https://enter.ddev.site:33001/data/ngsi-ld/v1/types> |
0 commit comments