@@ -44,10 +44,10 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -46,7 +46,9 @@ discard block |
||
| 46 | 46 | $gpx .= '<trkseg>'; |
| 47 | 47 | foreach($spotter_history_array as $spotter_data) { |
| 48 | 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>'; |
|
| 49 | + if (isset($spotter_data['altitude'])) { |
|
| 50 | + $gpx .= '<ele>'.sprintf("%.6f",$spotter_data['altitude']).'</ele>'; |
|
| 51 | + } |
|
| 50 | 52 | $gpx .= '<time>'.date("Y-m-d\TH:i:s\Z",strtotime($spotter_data['date'])).'</time>'; |
| 51 | 53 | $gpx .= '</trkpt>'; |
| 52 | 54 | } |
@@ -82,9 +84,15 @@ discard block |
||
| 82 | 84 | |
| 83 | 85 | public function TrackMatching($spotter_history_array) { |
| 84 | 86 | global $globalMapMatchingMaxPts, $globalTrackMatchingAppKey, $globalTrackMatchingAppId; |
| 85 | - if (!isset($globalMapMatchingMaxPts)) $globalMapMatchingMaxPts = 100; |
|
| 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 (!isset($globalMapMatchingMaxPts)) { |
|
| 88 | + $globalMapMatchingMaxPts = 100; |
|
| 89 | + } |
|
| 90 | + if (count($spotter_history_array) < 2) { |
|
| 91 | + return $spotter_history_array; |
|
| 92 | + } |
|
| 93 | + if (count($spotter_history_array) > $globalMapMatchingMaxPts) { |
|
| 94 | + $spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts); |
|
| 95 | + } |
|
| 88 | 96 | $data = $this->create_gpx($spotter_history_array); |
| 89 | 97 | $url = 'https://test.roadmatching.com/rest/mapmatch/?app_id='.$globalTrackMatchingAppId.'&app_key='.$globalTrackMatchingAppKey.'&output.waypoints=true'; |
| 90 | 98 | $Common = new Common(); |
@@ -111,8 +119,12 @@ discard block |
||
| 111 | 119 | */ |
| 112 | 120 | public function GraphHopper($spotter_history_array) { |
| 113 | 121 | global $globalMapMatchingMaxPts, $globalGraphHopperKey; |
| 114 | - if (!isset($globalMapMatchingMaxPts)) $globalMapMatchingMaxPts = 100; |
|
| 115 | - if (count($spotter_history_array) < 2) return $spotter_history_array; |
|
| 122 | + if (!isset($globalMapMatchingMaxPts)) { |
|
| 123 | + $globalMapMatchingMaxPts = 100; |
|
| 124 | + } |
|
| 125 | + if (count($spotter_history_array) < 2) { |
|
| 126 | + return $spotter_history_array; |
|
| 127 | + } |
|
| 116 | 128 | $spotter_history_initial_array = array(); |
| 117 | 129 | if (count($spotter_history_array) > $globalMapMatchingMaxPts) { |
| 118 | 130 | $spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts); |
@@ -142,8 +154,12 @@ discard block |
||
| 142 | 154 | */ |
| 143 | 155 | public function FAMMapMatching($spotter_history_array) { |
| 144 | 156 | global $globalMapMatchingMaxPts, $globalGraphHopperKey; |
| 145 | - if (!isset($globalMapMatchingMaxPts)) $globalMapMatchingMaxPts = 100; |
|
| 146 | - if (count($spotter_history_array) < 2) return $spotter_history_array; |
|
| 157 | + if (!isset($globalMapMatchingMaxPts)) { |
|
| 158 | + $globalMapMatchingMaxPts = 100; |
|
| 159 | + } |
|
| 160 | + if (count($spotter_history_array) < 2) { |
|
| 161 | + return $spotter_history_array; |
|
| 162 | + } |
|
| 147 | 163 | $spotter_history_initial_array = array(); |
| 148 | 164 | if (count($spotter_history_array) > $globalMapMatchingMaxPts) { |
| 149 | 165 | $spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts); |
@@ -174,8 +190,12 @@ discard block |
||
| 174 | 190 | */ |
| 175 | 191 | public function osmr($spotter_history_array) { |
| 176 | 192 | global $globalMapMatchingMaxPts; |
| 177 | - if (!isset($globalMapMatchingMaxPts)) $globalMapMatchingMaxPts = 50; |
|
| 178 | - if (count($spotter_history_array) < 2) return $spotter_history_array; |
|
| 193 | + if (!isset($globalMapMatchingMaxPts)) { |
|
| 194 | + $globalMapMatchingMaxPts = 50; |
|
| 195 | + } |
|
| 196 | + if (count($spotter_history_array) < 2) { |
|
| 197 | + return $spotter_history_array; |
|
| 198 | + } |
|
| 179 | 199 | $spotter_history_initial_array = array(); |
| 180 | 200 | if (count($spotter_history_array) > $globalMapMatchingMaxPts) { |
| 181 | 201 | $spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts); |
@@ -185,11 +205,17 @@ discard block |
||
| 185 | 205 | $ts = ''; |
| 186 | 206 | $rd = ''; |
| 187 | 207 | foreach ($spotter_history_array as $spotter_data) { |
| 188 | - if ($coord != '') $coord .= ';'; |
|
| 208 | + if ($coord != '') { |
|
| 209 | + $coord .= ';'; |
|
| 210 | + } |
|
| 189 | 211 | $coord .= $spotter_data['longitude'].','.$spotter_data['latitude']; |
| 190 | - if ($ts != '') $ts .= ';'; |
|
| 212 | + if ($ts != '') { |
|
| 213 | + $ts .= ';'; |
|
| 214 | + } |
|
| 191 | 215 | $ts .= strtotime($spotter_data['date']); |
| 192 | - if ($rd != '') $rd .= ';'; |
|
| 216 | + if ($rd != '') { |
|
| 217 | + $rd .= ';'; |
|
| 218 | + } |
|
| 193 | 219 | $rd .= '20'; |
| 194 | 220 | } |
| 195 | 221 | $url = 'https://router.project-osrm.org/match/v1/driving/'.$coord.'?timestamps='.$ts.'&overview=full&geometries=geojson&tidy=true&gaps=ignore'; |
@@ -215,8 +241,12 @@ discard block |
||
| 215 | 241 | */ |
| 216 | 242 | public function mapbox($spotter_history_array) { |
| 217 | 243 | global $globalMapMatchingMaxPts, $globalMapboxToken; |
| 218 | - if (!isset($globalMapMatchingMaxPts)) $globalMapMatchingMaxPts = 60; |
|
| 219 | - if (count($spotter_history_array) < 2) return $spotter_history_array; |
|
| 244 | + if (!isset($globalMapMatchingMaxPts)) { |
|
| 245 | + $globalMapMatchingMaxPts = 60; |
|
| 246 | + } |
|
| 247 | + if (count($spotter_history_array) < 2) { |
|
| 248 | + return $spotter_history_array; |
|
| 249 | + } |
|
| 220 | 250 | $spotter_history_initial_array = array(); |
| 221 | 251 | if (count($spotter_history_array) > $globalMapMatchingMaxPts) { |
| 222 | 252 | $spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts); |
@@ -226,11 +256,17 @@ discard block |
||
| 226 | 256 | $ts = ''; |
| 227 | 257 | $rd = ''; |
| 228 | 258 | foreach ($spotter_history_array as $spotter_data) { |
| 229 | - if ($coord != '') $coord .= ';'; |
|
| 259 | + if ($coord != '') { |
|
| 260 | + $coord .= ';'; |
|
| 261 | + } |
|
| 230 | 262 | $coord .= $spotter_data['longitude'].','.$spotter_data['latitude']; |
| 231 | - if ($ts != '') $ts .= ';'; |
|
| 263 | + if ($ts != '') { |
|
| 264 | + $ts .= ';'; |
|
| 265 | + } |
|
| 232 | 266 | $ts .= strtotime($spotter_data['date']); |
| 233 | - if ($rd != '') $rd .= ';'; |
|
| 267 | + if ($rd != '') { |
|
| 268 | + $rd .= ';'; |
|
| 269 | + } |
|
| 234 | 270 | $rd .= '20'; |
| 235 | 271 | } |
| 236 | 272 | //$url = 'https://api.mapbox.com/matching/v5/mapbox/driving/'.$coord.'?access_token='.$globalMapboxToken.'×tamps='.$ts.'&overview=full&tidy=true&geometries=geojson&radiuses='.$rd; |