Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Commit 06cad92

Browse files
committed
fixed elevator related issues; outline missing titles; reworked long+lat gathering
* if elevator is wheelchair suitable, it is also "available"; before that change, it could be "not available" which makes no sense in this case * long+lat gathering was reworked, but it seems for some buidlings, we cannot gather these, because additional info's like "Zi. 314" confuse Google API
1 parent 7af492b commit 06cad92

File tree

4 files changed

+1010
-1039
lines changed

4 files changed

+1010
-1039
lines changed

enrich-table-csv.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
if (false === file_exists('table.csv')) {
3838
throw new Exception('File table.csv not found. Aborting ...');
39+
return;
3940
}
4041

4142
$mdbDatabaseCSVExport = loadCSVFileIntoArray('table.csv');
@@ -164,6 +165,10 @@
164165
$extractedData[$key]['Personenaufzug-vorhanden'] = 'ja';
165166
} else {
166167
$extractedData[$key]['Personenaufzug-vorhanden'] = 'nein';
168+
169+
if ('ja' == $extractedData[$key]['Personenaufzug-rollstuhlgerecht']) {
170+
$extractedData[$key]['Personenaufzug-vorhanden'] = 'ja';
171+
}
167172
}
168173

169174
// WC fully accessable for wheelchair users
@@ -192,6 +197,11 @@
192197

193198
foreach ($extractedData as $key => $extractedEntry) {
194199
foreach ($mdbDatabaseCSVExport as $key => $originalEntry) {
200+
if (!isset($originalEntry[5]) || !isset($originalEntry[7])) {
201+
echo PHP_EOL . 'Title information missing...';
202+
var_dump($originalEntry);
203+
}
204+
195205
$street = preg_replace('/(\(.*?\))/si', '', $originalEntry[7]);
196206

197207
// if title of mdb-dataset matches with one of the online ones

functions.php

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ function getLongLatForAddress($title, $street, $zip, $city)
111111
$entry->lat = "";
112112
}
113113
// if long and lat is not set, try to get it from google
114-
if ('' == $entry->long && '' == $entry->lat) {
114+
if (1 > (float)$entry->long || 1 > (float)$entry->lat) {
115115
$curl = new Curl\Curl();
116116

117117
// ask google for geometry information for a given address
@@ -122,17 +122,28 @@ function getLongLatForAddress($title, $street, $zip, $city)
122122
// store JSON result
123123
$latLongInformation = json_decode(json_encode($curl->response), true);
124124

125-
if (isset($latLongInformation['results'][0]['geometry']['location']['lat'])
126-
&& isset($latLongInformation['results'][0]['geometry']['location']['lng'])) {
127-
$entry->lng = $latLongInformation['results'][0]['geometry']['location']['lng'];
128-
$entry->lat = $latLongInformation['results'][0]['geometry']['location']['lat'];
125+
if (isset($latLongInformation['results'][0]['geometry']['location']['lat'])) {
126+
$lat = $latLongInformation['results'][0]['geometry']['location']['lat'];
127+
} else {
128+
$lat = 0;
129+
}
130+
131+
if (isset($latLongInformation['results'][0]['geometry']['location']['lng'])) {
132+
$long = $latLongInformation['results'][0]['geometry']['location']['lng'];
133+
} else {
134+
$long = 0;
135+
}
136+
137+
if (0 < (float)$lat && 0 < (float)$long) {
138+
$entry->lng = $long;
139+
$entry->lat = $lat;
129140
R::store($entry);
130141
} else {
131142
echo PHP_EOL . PHP_EOL . $title;
132143
echo PHP_EOL . $street .' '. $zip .' '. $city;
133144
echo PHP_EOL . 'no lat OR long';
134-
$entry->lng = '';
135-
$entry->lat = '';
145+
$entry->lng = $long;
146+
$entry->lat = $lat;
136147
}
137148
}
138149

geo-info.sqlite3

-14 KB
Binary file not shown.

0 commit comments

Comments
 (0)