-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake_test_layers.sh
More file actions
248 lines (223 loc) · 7.59 KB
/
Copy pathmake_test_layers.sh
File metadata and controls
248 lines (223 loc) · 7.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
#!/usr/bin/env bash
set -euo pipefail
# ------------------------------------------------------------
# PDOK GeoPackage Testset (Amersfoort / RD New) - bash only
# Bronnen: JSON-FG + GML | Converter: uitsluitend GDAL/ogr2ogr
# ------------------------------------------------------------
OUT_DIR="out"
SRC_DIR="src"
GPKG="${OUT_DIR}/pdok_amersfoort_test.gpkg"
# RD New referentiepunt (Onze Lieve Vrouwetoren)
RD_X=155000.0
RD_Y=463000.0
# Kleine offsets (meters) rond het referentiepunt (5 punten)
OFFS=(
"5 5"
"10 -5"
"-15 12"
"20 -20"
"-25 -10"
)
# Hulpfunctie: float optellen met awk
addf() { awk -v a="$1" -v b="$2" 'BEGIN{printf("%.3f", a+b)}'; }
rm -rf "${OUT_DIR}" "${SRC_DIR}"
mkdir -p "${OUT_DIR}" "${SRC_DIR}"
# ------------------------------------------------------------
# 1) VALID: JSON-FG met Z en compound CRS (RD+NAP) -> OK
# Laagnaam: valid_point_z_rdnap_ok
# ------------------------------------------------------------
cat > "${SRC_DIR}/valid_point_z_rdnap_ok.json" <<'JSON'
{
"type": "FeatureCollection",
"conformsTo": ["http://www.opengis.net/spec/json-fg-1/0.3/core"],
"features": [
JSON
i=0
for pair in "${OFFS[@]}"; do
dx=$(awk '{print $1}' <<<"$pair")
dy=$(awk '{print $2}' <<<"$pair")
x=$(addf "${RD_X}" "${dx}")
y=$(addf "${RD_Y}" "${dy}")
z="1.230"
comma=","
[ "$i" -eq 4 ] && comma=""
cat >> "${SRC_DIR}/valid_point_z_rdnap_ok.json" <<JSON
{
"type": "Feature",
"id": "v1-$i",
"place": { "type": "Point", "coordinates": [${x}, ${y}, ${z}] },
"coordRefSys": {
"type": "CompoundCRS",
"components": [
{ "type": "OGC", "id": "http://www.opengis.net/def/crs/EPSG/0/28992" },
{ "type": "OGC", "id": "http://www.opengis.net/def/crs/EPSG/0/5709" }
]
},
"properties": { "note": "Z=hoogte t.o.v. NAP, compound CRS RD+NAP" }
${comma}
JSON
i=$((i+1))
done
echo ' ] }' >> "${SRC_DIR}/valid_point_z_rdnap_ok.json"
# ------------------------------------------------------------
# 2) INVALID: JSON-FG met Z maar GEEN verticaal CRS -> ERROR
# Laagnaam: invalid_point_z_no_crs
# ------------------------------------------------------------
cat > "${SRC_DIR}/invalid_point_z_no_crs.json" <<'JSON'
{
"type": "FeatureCollection",
"conformsTo": ["http://www.opengis.net/spec/json-fg-1/0.3/core"],
"features": [
JSON
i=0
for pair in "${OFFS[@]}"; do
dx=$(awk '{print $1}' <<<"$pair")
dy=$(awk '{print $2}' <<<"$pair")
# halve offset
hx=$(awk -v v="$dx" 'BEGIN{printf("%.3f", v/2)}')
hy=$(awk -v v="$dy" 'BEGIN{printf("%.3f", v/2)}')
x=$(addf "${RD_X}" "${hx}")
y=$(addf "${RD_Y}" "${hy}")
z="0.750"
comma=","
[ "$i" -eq 4 ] && comma=""
cat >> "${SRC_DIR}/invalid_point_z_no_crs.json" <<JSON
{
"type": "Feature",
"id": "i1-$i",
"place": { "type": "Point", "coordinates": [${x}, ${y}, ${z}] },
"coordRefSys": { "type": "OGC", "id": "http://www.opengis.net/def/crs/EPSG/0/28992" },
"properties": { "note": "Z zonder verticaal CRS (alleen RD)" }
${comma}
JSON
i=$((i+1))
done
echo ' ] }' >> "${SRC_DIR}/invalid_point_z_no_crs.json"
# ------------------------------------------------------------
# 3) WARNING/ERROR: GML met POINT ZM (XYZM) ZONDER measure-attributen
# Laagnaam: warning_point_zm_no_attrs
# ------------------------------------------------------------
cat > "${SRC_DIR}/warning_point_zm_no_attrs.gml" <<'GML'
<?xml version="1.0" encoding="UTF-8"?>
<gml:FeatureCollection
xmlns:gml="http://www.opengis.net/gml">
<gml:featureMembers>
GML
for pair in "${OFFS[@]}"; do
dx=$(awk '{print $1}' <<<"$pair")
dy=$(awk '{print $2}' <<<"$pair")
x=$(addf "${RD_X}" "${dx}")
y=$(addf "${RD_Y}" "${dy}")
z="1.500"
m="0.450"
cat >> "${SRC_DIR}/warning_point_zm_no_attrs.gml" <<GML
<gml:featureMember>
<gml:Point srsName="urn:ogc:def:crs:EPSG::28992" srsDimension="4">
<gml:pos>${x} ${y} ${z} ${m}</gml:pos>
</gml:Point>
</gml:featureMember>
GML
done
cat >> "${SRC_DIR}/warning_point_zm_no_attrs.gml" <<'GML'
</gml:featureMembers>
</gml:FeatureCollection>
GML
# ------------------------------------------------------------
# 4) OK: JSON-FG 2D met measure ALS ATTRIBUUT (unit + meaning)
# Laagnaam: ok_point_2d_with_measure_attrs
# ------------------------------------------------------------
cat > "${SRC_DIR}/ok_point_2d_with_measure_attrs.json" <<'JSON'
{
"type": "FeatureCollection",
"conformsTo": ["http://www.opengis.net/spec/json-fg-1/0.3/core"],
"features": [
JSON
i=0
for pair in "${OFFS[@]}"; do
dx=$(awk '{print $1}' <<<"$pair")
dy=$(awk '{print $2}' <<<"$pair")
# derde offset
tx=$(awk -v v="$dx" 'BEGIN{printf("%.3f", v/3)}')
ty=$(awk -v v="$dy" 'BEGIN{printf("%.3f", v/3)}')
x=$(addf "${RD_X}" "${tx}")
y=$(addf "${RD_Y}" "${ty}")
# measure_value: 0.42 + i*0.01
mv=$(awk -v i="$i" 'BEGIN{printf("%.2f", 0.42 + i*0.01)}')
comma=","
[ "$i" -eq 4 ] && comma=""
cat >> "${SRC_DIR}/ok_point_2d_with_measure_attrs.json" <<JSON
{
"type": "Feature",
"id": "ok2d-$i",
"place": { "type": "Point", "coordinates": [${x}, ${y}] },
"coordRefSys": { "type": "OGC", "id": "http://www.opengis.net/def/crs/EPSG/0/28992" },
"properties": {
"measure_value": ${mv},
"measure_unit": "m",
"observed_property": "waterLevel",
"note": "M als attribuut met eenheid/semantiek"
}
${comma}
JSON
i=$((i+1))
done
echo ' ] }' >> "${SRC_DIR}/ok_point_2d_with_measure_attrs.json"
# ------------------------------------------------------------
# 5) INVALID: JSON-FG met mixed 2D/3D in één laag -> ERROR
# Laagnaam: invalid_mixed_dimensions
# ------------------------------------------------------------
cat > "${SRC_DIR}/invalid_mixed_dimensions.json" <<'JSON'
{
"type": "FeatureCollection",
"conformsTo": ["http://www.opengis.net/spec/json-fg-1/0.3/core"],
"features": [
JSON
i=0
for pair in "${OFFS[@]}"; do
dx=$(awk '{print $1}' <<<"$pair")
dy=$(awk '{print $2}' <<<"$pair")
x=$(addf "${RD_X}" "${dx}")
y=$(addf "${RD_Y}" "${dy}")
if (( i % 2 == 0 )); then
coords="[${x}, ${y}]"
note="2D point"
else
coords="[${x}, ${y}, 0.900]"
note="3D point (Z)"
fi
comma=","
[ "$i" -eq 4 ] && comma=""
cat >> "${SRC_DIR}/invalid_mixed_dimensions.json" <<JSON
{
"type": "Feature",
"id": "mix-$i",
"place": { "type": "Point", "coordinates": ${coords} },
"coordRefSys": { "type": "OGC", "id": "http://www.opengis.net/def/crs/EPSG/0/28992" },
"properties": { "note": "${note}" }
${comma}
JSON
i=$((i+1))
done
echo ' ] }' >> "${SRC_DIR}/invalid_mixed_dimensions.json"
# ------------------------------------------------------------
# Bouw het GeoPackage met uitsluitend GDAL/ogr2ogr
# ------------------------------------------------------------
rm -f "${GPKG}"
# 1) valid Z met compound CRS
ogr2ogr -f GPKG "${GPKG}" "JSONFG:${SRC_DIR}/valid_point_z_rdnap_ok.json" \
-nln valid_point_z_rdnap_ok
# 2) invalid Z zonder verticaal CRS
ogr2ogr -f GPKG -update -append "${GPKG}" "JSONFG:${SRC_DIR}/invalid_point_z_no_crs.json" \
-nln invalid_point_z_no_crs
# 3) ZM zonder measure-attributen (GML)
ogr2ogr -f GPKG -update -append "${GPKG}" "${SRC_DIR}/warning_point_zm_no_attrs.gml" \
-nln warning_point_zm_no_attrs
# 4) 2D met measure als attribuut (OK)
ogr2ogr -f GPKG -update -append "${GPKG}" "JSONFG:${SRC_DIR}/ok_point_2d_with_measure_attrs.json" \
-nln ok_point_2d_with_measure_attrs
# 5) mixed 2D/3D in één laag (ERROR)
ogr2ogr -f GPKG -update -append "${GPKG}" "JSONFG:${SRC_DIR}/invalid_mixed_dimensions.json" \
-nln invalid_mixed_dimensions
echo "✅ Klaar: ${GPKG}"
echo " Lagen en samenvatting:"
ogrinfo -ro -so "${GPKG}"