|
@@ -44,10 +44,10 @@ discard block |
|
|
block discarded – undo |
|
44
|
44
|
$gpx .= '<gpx xmlns="http://www.topografix.com/GPX/1/1" xmlns:gpsies="http://www.gpsies.com/GPX/1/0" creator="GPSies http://www.gpsies.com - Sendl.-O&apos;sch-heim" version="1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd http://www.gpsies.com/GPX/1/0 http://www.gpsies.com/gpsies.xsd">'; |
|
45
|
45
|
$gpx .= '<trk>'; |
|
46
|
46
|
$gpx .= '<trkseg>'; |
|
47
|
|
- foreach($spotter_history_array as $spotter_data) { |
|
48
|
|
- $gpx .= '<trkpt lat="'.sprintf("%.8f",$spotter_data['latitude']).'" lon="'.sprintf("%.8f",$spotter_data['longitude']).'">'; |
|
49
|
|
- if (isset($spotter_data['altitude'])) $gpx .= '<ele>'.sprintf("%.6f",$spotter_data['altitude']).'</ele>'; |
|
50
|
|
- $gpx .= '<time>'.date("Y-m-d\TH:i:s\Z",strtotime($spotter_data['date'])).'</time>'; |
|
|
47
|
+ foreach ($spotter_history_array as $spotter_data) { |
|
|
48
|
+ $gpx .= '<trkpt lat="'.sprintf("%.8f", $spotter_data['latitude']).'" lon="'.sprintf("%.8f", $spotter_data['longitude']).'">'; |
|
|
49
|
+ if (isset($spotter_data['altitude'])) $gpx .= '<ele>'.sprintf("%.6f", $spotter_data['altitude']).'</ele>'; |
|
|
50
|
+ $gpx .= '<time>'.date("Y-m-d\TH:i:s\Z", strtotime($spotter_data['date'])).'</time>'; |
|
51
|
51
|
$gpx .= '</trkpt>'; |
|
52
|
52
|
} |
|
53
|
53
|
$gpx .= '</trkseg>'; |
|
@@ -84,18 +84,18 @@ discard block |
|
|
block discarded – undo |
|
84
|
84
|
global $globalMapMatchingMaxPts, $globalTrackMatchingAppKey, $globalTrackMatchingAppId; |
|
85
|
85
|
if (!isset($globalMapMatchingMaxPts)) $globalMapMatchingMaxPts = 100; |
|
86
|
86
|
if (count($spotter_history_array) < 2) return $spotter_history_array; |
|
87
|
|
- if (count($spotter_history_array) > $globalMapMatchingMaxPts) $spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts); |
|
|
87
|
+ if (count($spotter_history_array) > $globalMapMatchingMaxPts) $spotter_history_array = array_slice($spotter_history_array, -$globalMapMatchingMaxPts); |
|
88
|
88
|
$data = $this->create_gpx($spotter_history_array); |
|
89
|
89
|
$url = 'https://test.roadmatching.com/rest/mapmatch/?app_id='.$globalTrackMatchingAppId.'&app_key='.$globalTrackMatchingAppKey.'&output.waypoints=true'; |
|
90
|
90
|
$Common = new Common(); |
|
91
|
|
- $matching = $Common->getData($url,'post',$data,array('Content-Type: application/gpx+xml','Accept: application/json')); |
|
92
|
|
- $matching = json_decode($matching,true); |
|
|
91
|
+ $matching = $Common->getData($url, 'post', $data, array('Content-Type: application/gpx+xml', 'Accept: application/json')); |
|
|
92
|
+ $matching = json_decode($matching, true); |
|
93
|
93
|
if (isset($matching['diary']['entries'][0]['route']['links'])) { |
|
94
|
94
|
$spotter_history_array = array(); |
|
95
|
95
|
foreach ($matching['diary']['entries'][0]['route']['links'] as $match) { |
|
96
|
96
|
if (isset($match['wpts'])) { |
|
97
|
97
|
foreach ($match['wpts'] as $coord) { |
|
98
|
|
- $spotter_history_array[] = array('longitude' => $coord['x'],'latitude' => $coord['y']); |
|
|
98
|
+ $spotter_history_array[] = array('longitude' => $coord['x'], 'latitude' => $coord['y']); |
|
99
|
99
|
} |
|
100
|
100
|
} |
|
101
|
101
|
} |
|
@@ -115,22 +115,22 @@ discard block |
|
|
block discarded – undo |
|
115
|
115
|
if (count($spotter_history_array) < 2) return $spotter_history_array; |
|
116
|
116
|
$spotter_history_initial_array = array(); |
|
117
|
117
|
if (count($spotter_history_array) > $globalMapMatchingMaxPts) { |
|
118
|
|
- $spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts); |
|
119
|
|
- $spotter_history_initial_array = array_slice($spotter_history_array,0,count($spotter_history_array)-$globalMapMatchingMaxPts); |
|
|
118
|
+ $spotter_history_array = array_slice($spotter_history_array, -$globalMapMatchingMaxPts); |
|
|
119
|
+ $spotter_history_initial_array = array_slice($spotter_history_array, 0, count($spotter_history_array) - $globalMapMatchingMaxPts); |
|
120
|
120
|
} |
|
121
|
121
|
$data = $this->create_gpx($spotter_history_array); |
|
122
|
122
|
$url = 'https://graphhopper.com/api/1/match?vehicle=car&points_encoded=0&instructions=false&key='.$globalGraphHopperKey; |
|
123
|
123
|
$Common = new Common(); |
|
124
|
|
- $matching = $Common->getData($url,'post',$data,array('Content-Type: application/gpx+xml')); |
|
125
|
|
- $matching = json_decode($matching,true); |
|
|
124
|
+ $matching = $Common->getData($url, 'post', $data, array('Content-Type: application/gpx+xml')); |
|
|
125
|
+ $matching = json_decode($matching, true); |
|
126
|
126
|
if (isset($matching['paths'][0]['points']['coordinates'])) { |
|
127
|
127
|
$spotter_history_array = array(); |
|
128
|
128
|
foreach ($matching['paths'][0]['points']['coordinates'] as $match) { |
|
129
|
129
|
$coord = $match; |
|
130
|
|
- $spotter_history_array[] = array('longitude' => $coord[0],'latitude' => $coord[1]); |
|
|
130
|
+ $spotter_history_array[] = array('longitude' => $coord[0], 'latitude' => $coord[1]); |
|
131
|
131
|
} |
|
132
|
132
|
} |
|
133
|
|
- $spotter_history_array = array_merge($spotter_history_initial_array,$spotter_history_array); |
|
|
133
|
+ $spotter_history_array = array_merge($spotter_history_initial_array, $spotter_history_array); |
|
134
|
134
|
$spotter_history_array[0]['mapmatching_engine'] = 'graphhopper'; |
|
135
|
135
|
return $spotter_history_array; |
|
136
|
136
|
} |
|
@@ -146,23 +146,23 @@ discard block |
|
|
block discarded – undo |
|
146
|
146
|
if (count($spotter_history_array) < 2) return $spotter_history_array; |
|
147
|
147
|
$spotter_history_initial_array = array(); |
|
148
|
148
|
if (count($spotter_history_array) > $globalMapMatchingMaxPts) { |
|
149
|
|
- $spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts); |
|
150
|
|
- $spotter_history_initial_array = array_slice($spotter_history_array,0,count($spotter_history_array)-$globalMapMatchingMaxPts); |
|
|
149
|
+ $spotter_history_array = array_slice($spotter_history_array, -$globalMapMatchingMaxPts); |
|
|
150
|
+ $spotter_history_initial_array = array_slice($spotter_history_array, 0, count($spotter_history_array) - $globalMapMatchingMaxPts); |
|
151
|
151
|
} |
|
152
|
152
|
$data = $this->create_gpx($spotter_history_array); |
|
153
|
153
|
$url = 'https://mapmatching.flightairmap.com/api/1/match?vehicle=car&points_encoded=0&instructions=false'; |
|
154
|
154
|
//$url = 'https://mapmatching.flightairmap.com/api/1/match?vehicle=car&points_encoded=0'; |
|
155
|
155
|
$Common = new Common(); |
|
156
|
|
- $matching = $Common->getData($url,'post',$data,array('Content-Type: application/gpx+xml')); |
|
157
|
|
- $matching = json_decode($matching,true); |
|
|
156
|
+ $matching = $Common->getData($url, 'post', $data, array('Content-Type: application/gpx+xml')); |
|
|
157
|
+ $matching = json_decode($matching, true); |
|
158
|
158
|
if (isset($matching['paths'][0]['points']['coordinates'])) { |
|
159
|
159
|
$spotter_history_array = array(); |
|
160
|
160
|
foreach ($matching['paths'][0]['points']['coordinates'] as $match) { |
|
161
|
161
|
$coord = $match; |
|
162
|
|
- $spotter_history_array[] = array('longitude' => $coord[0],'latitude' => $coord[1]); |
|
|
162
|
+ $spotter_history_array[] = array('longitude' => $coord[0], 'latitude' => $coord[1]); |
|
163
|
163
|
} |
|
164
|
164
|
} |
|
165
|
|
- $spotter_history_array = array_merge($spotter_history_initial_array,$spotter_history_array); |
|
|
165
|
+ $spotter_history_array = array_merge($spotter_history_initial_array, $spotter_history_array); |
|
166
|
166
|
$spotter_history_array[0]['mapmatching_engine'] = 'fam'; |
|
167
|
167
|
return $spotter_history_array; |
|
168
|
168
|
} |
|
@@ -178,8 +178,8 @@ discard block |
|
|
block discarded – undo |
|
178
|
178
|
if (count($spotter_history_array) < 2) return $spotter_history_array; |
|
179
|
179
|
$spotter_history_initial_array = array(); |
|
180
|
180
|
if (count($spotter_history_array) > $globalMapMatchingMaxPts) { |
|
181
|
|
- $spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts); |
|
182
|
|
- $spotter_history_initial_array = array_slice($spotter_history_array,0,count($spotter_history_array)-$globalMapMatchingMaxPts); |
|
|
181
|
+ $spotter_history_array = array_slice($spotter_history_array, -$globalMapMatchingMaxPts); |
|
|
182
|
+ $spotter_history_initial_array = array_slice($spotter_history_array, 0, count($spotter_history_array) - $globalMapMatchingMaxPts); |
|
183
|
183
|
} |
|
184
|
184
|
$coord = ''; |
|
185
|
185
|
$ts = ''; |
|
@@ -195,15 +195,15 @@ discard block |
|
|
block discarded – undo |
|
195
|
195
|
$url = 'https://router.project-osrm.org/match/v1/driving/'.$coord.'?timestamps='.$ts.'&overview=full&geometries=geojson&tidy=true&gaps=ignore'; |
|
196
|
196
|
$Common = new Common(); |
|
197
|
197
|
$matching = $Common->getData($url); |
|
198
|
|
- $matching = json_decode($matching,true); |
|
|
198
|
+ $matching = json_decode($matching, true); |
|
199
|
199
|
if (isset($matching['matchings'][0]['geometry']['coordinates'])) { |
|
200
|
200
|
$spotter_history_array = array(); |
|
201
|
201
|
foreach ($matching['matchings'][0]['geometry']['coordinates'] as $match) { |
|
202
|
202
|
$coord = $match; |
|
203
|
|
- $spotter_history_array[] = array('longitude' => $coord[0],'latitude' => $coord[1]); |
|
|
203
|
+ $spotter_history_array[] = array('longitude' => $coord[0], 'latitude' => $coord[1]); |
|
204
|
204
|
} |
|
205
|
205
|
} |
|
206
|
|
- $spotter_history_array = array_merge($spotter_history_initial_array,$spotter_history_array); |
|
|
206
|
+ $spotter_history_array = array_merge($spotter_history_initial_array, $spotter_history_array); |
|
207
|
207
|
$spotter_history_array[0]['mapmatching_engine'] = 'osmr'; |
|
208
|
208
|
return $spotter_history_array; |
|
209
|
209
|
} |
|
@@ -219,8 +219,8 @@ discard block |
|
|
block discarded – undo |
|
219
|
219
|
if (count($spotter_history_array) < 2) return $spotter_history_array; |
|
220
|
220
|
$spotter_history_initial_array = array(); |
|
221
|
221
|
if (count($spotter_history_array) > $globalMapMatchingMaxPts) { |
|
222
|
|
- $spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts); |
|
223
|
|
- $spotter_history_initial_array = array_slice($spotter_history_array,0,count($spotter_history_array)-$globalMapMatchingMaxPts); |
|
|
222
|
+ $spotter_history_array = array_slice($spotter_history_array, -$globalMapMatchingMaxPts); |
|
|
223
|
+ $spotter_history_initial_array = array_slice($spotter_history_array, 0, count($spotter_history_array) - $globalMapMatchingMaxPts); |
|
224
|
224
|
} |
|
225
|
225
|
$coord = ''; |
|
226
|
226
|
$ts = ''; |
|
@@ -237,15 +237,15 @@ discard block |
|
|
block discarded – undo |
|
237
|
237
|
$url = 'https://api.mapbox.com/matching/v5/mapbox/driving/'.$coord.'?access_token='.$globalMapboxToken.'×tamps='.$ts.'&overview=full&tidy=true&geometries=geojson'; |
|
238
|
238
|
$Common = new Common(); |
|
239
|
239
|
$matching = $Common->getData($url); |
|
240
|
|
- $matching = json_decode($matching,true); |
|
|
240
|
+ $matching = json_decode($matching, true); |
|
241
|
241
|
if (isset($matching['matchings'][0]['geometry']['coordinates'])) { |
|
242
|
242
|
$spotter_history_array = array(); |
|
243
|
243
|
foreach ($matching['matchings'][0]['geometry']['coordinates'] as $match) { |
|
244
|
244
|
$coord = $match; |
|
245
|
|
- $spotter_history_array[] = array('longitude' => $coord[0],'latitude' => $coord[1]); |
|
|
245
|
+ $spotter_history_array[] = array('longitude' => $coord[0], 'latitude' => $coord[1]); |
|
246
|
246
|
} |
|
247
|
247
|
} |
|
248
|
|
- $spotter_history_array = array_merge($spotter_history_initial_array,$spotter_history_array); |
|
|
248
|
+ $spotter_history_array = array_merge($spotter_history_initial_array, $spotter_history_array); |
|
249
|
249
|
$spotter_history_array[0]['mapmatching_engine'] = 'mapbox'; |
|
250
|
250
|
return $spotter_history_array; |
|
251
|
251
|
} |