Skip to content

Commit d97f3da

Browse files
committed
Experiments …
1 parent 32dea1e commit d97f3da

40 files changed

Lines changed: 8382 additions & 520 deletions

.ddev/config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ composer_version: "2"
1414
web_environment: []
1515
nodejs_version: "24"
1616
corepack_enable: false
17+
disable_upload_dirs_warning: true
1718

1819
# Key features of DDEV's config.yaml:
1920

.ddev/docker-compose.scorpio.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
networks:
2+
scorpio:
3+
4+
# https://docs.ddev.com/en/stable/users/extend/custom-docker-services/
5+
services:
6+
scorpio:
7+
container_name: "ddev-${DDEV_SITENAME}-scorpio"
8+
hostname: scorpio.local
9+
image: scorpiobroker/all-in-one-runner:java-latest
10+
restart: "no"
11+
ports:
12+
- "9090"
13+
environment:
14+
- VIRTUAL_HOST=${DDEV_HOSTNAME}
15+
- HTTP_EXPOSE=9090:9999
16+
- DBHOST=scorpio-db
17+
depends_on:
18+
- "scorpio-db"
19+
networks:
20+
- default
21+
- scorpio
22+
platform: "linux/amd64"
23+
24+
scorpio-db:
25+
container_name: "ddev-${DDEV_SITENAME}-scorpio-db"
26+
image: postgis/postgis
27+
environment:
28+
- POSTGRES_USER=ngb
29+
- POSTGRES_PASSWORD=ngb
30+
- POSTGRES_DB=ngb
31+
networks:
32+
- scorpio
33+
volumes:
34+
- ./data/scorpio-db:/var/lib/postgresql/data
35+
platform: "linux/amd64"
36+
# https://stackoverflow.com/a/58806511
37+
command: ["postgres", "-c", "log_statement=all"]

.env

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,7 @@ APP_SHARE_DIR=var/share
2525
# See https://symfony.com/doc/current/routing.html#generating-urls-in-commands
2626
DEFAULT_URI=http://localhost
2727
###< symfony/routing ###
28+
29+
###> app ###
30+
APP_BROKER_BASE_URI=http://scorpio.local:9090/
31+
###< app ###

.env.test

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# define your env variables for the test env here
2+
KERNEL_CLASS='App\Kernel'
3+
APP_SECRET='$ecretf0rt3st'

.gitignore

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.ddev/data
2+
.idea
13

24
###> symfony/framework-bundle ###
35
/.env.local
@@ -8,3 +10,26 @@
810
/var/
911
/vendor/
1012
###< symfony/framework-bundle ###
13+
14+
###> phpunit/phpunit ###
15+
/phpunit.xml
16+
/.phpunit.cache/
17+
###< phpunit/phpunit ###
18+
19+
###> friendsofphp/php-cs-fixer ###
20+
/.php-cs-fixer.php
21+
/.php-cs-fixer.cache
22+
###< friendsofphp/php-cs-fixer ###
23+
24+
###> vincentlanglet/twig-cs-fixer ###
25+
/.twig-cs-fixer.cache
26+
###< vincentlanglet/twig-cs-fixer ###
27+
28+
###> phpstan/phpstan ###
29+
phpstan.neon
30+
###< phpstan/phpstan ###
31+
32+
###> symfony/asset-mapper ###
33+
/public/assets/
34+
/assets/vendor/
35+
###< symfony/asset-mapper ###

.php-cs-fixer.dist.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
// This file is copied from config/symfony/php/.php-cs-fixer.dist.php in https://github.com/itk-dev/devops_itkdev-docker.
3+
// Feel free to edit the file, but consider making a pull request if you find a general issue with the file.
4+
5+
// https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/master/doc/config.rst
6+
7+
$finder = new PhpCsFixer\Finder();
8+
// Check all files …
9+
$finder->in(__DIR__);
10+
// … that are not ignored by VCS
11+
$finder->ignoreVCSIgnored(true);
12+
13+
$config = new PhpCsFixer\Config();
14+
$config->setFinder($finder);
15+
16+
$config->setRules([
17+
'@Symfony' => true,
18+
]);
19+
20+
return $config;

.twig-cs-fixer.dist.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
// This file is copied from config/symfony/twig/.twig-cs-fixer.dist.php in https://github.com/itk-dev/devops_itkdev-docker.
3+
// Feel free to edit the file, but consider making a pull request if you find a general issue with the file.
4+
5+
// https://github.com/VincentLanglet/Twig-CS-Fixer/blob/main/docs/configuration.md#configuration-file
6+
7+
$finder = new TwigCsFixer\File\Finder();
8+
// Check all files …
9+
$finder->in(__DIR__);
10+
// … that are not ignored by VCS
11+
$finder->ignoreVCSIgnored(true);
12+
13+
$config = new TwigCsFixer\Config\Config();
14+
$config->setFinder($finder);
15+
16+
return $config;

Notes.md

Lines changed: 0 additions & 9 deletions
This file was deleted.

README.md

Lines changed: 151 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,157 @@
11
# Enter
22

3-
We use [DDEV](https://ddev.com/) for development:
3+
We use [DDEV](https://ddev.com/) and [Task](https://taskfile.dev/) for development:
44

55
``` shell
6-
ddev start
6+
task site:install
7+
8+
``` shell
9+
task site:update
710
ddev launch
811
```
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

Comments
 (0)