-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconverter.php
41 lines (30 loc) · 1.04 KB
/
converter.php
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
<?php
$input = json_decode(file_get_contents('dpsg.json'));
$output = new stdClass();
foreach($input as $dioezeseKomplex) {
if(!is_object($dioezeseKomplex)) {
continue;
}
$dioezeseEinfach = new stdClass;
if(property_exists($dioezeseKomplex, 'bezirke') && is_array($dioezeseKomplex->bezirke)) {
foreach($dioezeseKomplex->bezirke as $bezirkKomplex) {
if(!is_object($bezirkKomplex)) {
continue;
}
$bezirkEinfach = array();
if(property_exists($bezirkKomplex, 'staemme') && is_array($bezirkKomplex->staemme)) {
foreach($bezirkKomplex->staemme as $stammKomplex) {
if(!is_object($stammKomplex)) {
continue;
}
array_push($bezirkEinfach, $stammKomplex->name);
}
}
$bezirkName = $bezirkKomplex->name;
$dioezeseEinfach->$bezirkName = $bezirkEinfach;
}
}
$dioezeseName = $dioezeseKomplex->name;
$output->$dioezeseName = $dioezeseEinfach;
}
file_put_contents('dpsg_einfach.json', json_encode($output, JSON_PRETTY_PRINT + JSON_UNESCAPED_UNICODE));