Long time no talk all.
Hope everyone is well!
I’ve been fighting the navdata point display on the maps and have finally gotten it to point where I am happy, however I discovered an issue I can’t quite figure out.
When you run the parseRoute to generate the waypoints on the live map; it goes through airways and finds the entry/exit and everything in between. This works fine when the entry to exit is position (going forward) but when it’s backwards it doesn’t pull anything.
I have this particular airway where I’m entering at sequence 36 - KULIS and exiting at sequence 20 - SIDAK. It will not pull the values for sequence 35 to 21.
Here is a JSON dump of the data after parsing;
route\_details: ANSOK: {id: "70025", name: "ANSOK", title: "", airway: "UZ42", airway\_type: "H", …} ASEGI: {id: "70035", name: "ASEGI", title: "", airway: "UZ42", airway\_type: "H", …} ASODA: {id: "70020", name: "ASODA", title: "", airway: "UZ42", airway\_type: "H", …} BCO: {id: "70037", name: "BCO", title: "", airway: "UZ42", airway\_type: "H", …} CLIZA: {id: "70033", name: "CLIZA", title: "", airway: "UZ42", airway\_type: "H", …} CPN: {id: "70030", name: "CPN", title: "", airway: "UZ42", airway\_type: "H", …} DANLI: {id: "70036", name: "DANLI", title: "", airway: "UZ42", airway\_type: "H", …} DUBDU: {id: "70031", name: "DUBDU", title: "", airway: "UZ42", airway\_type: "H", …} EKIDI: {id: "70040", name: "EKIDI", title: "", airway: "UZ42", airway\_type: "H", …} ENROD: {id: "70016", name: "ENROD", title: "", airway: "UZ42", airway\_type: "H", …} ENRUB: {id: "70015", name: "ENRUB", title: "", airway: "UZ42", airway\_type: "H", …} ESORU: {id: "70042", name: "ESORU", title: "", airway: "UZ42", airway\_type: "H", …} EVMIM: {id: "70027", name: "EVMIM", title: "", airway: "UZ42", airway\_type: "H", …} GEKEM: {id: "70019", name: "GEKEM", title: "", airway: "UZ42", airway\_type: "H", …} GENKO: {id: "70039", name: "GENKO", title: "", airway: "UZ42", airway\_type: "H", …} GRD: {id: "70014", name: "GRD", title: "", airway: "UZ42", airway\_type: "H", …} ILSAN: {id: "70029", name: "ILSAN", title: "", airway: "UZ42", airway\_type: "H", …} KULIS: {id: "57176", name: "KULIS", title: "KULIS", airway: "UM415", airway\_type: "H", …} LOKAM: {id: "70032", name: "LOKAM", title: "", airway: "UZ42", airway\_type: "H", …} MUPAG: {id: "70034", name: "MUPAG", title: "", airway: "UZ42", airway\_type: "H", …} NEKOP: {id: "70038", name: "NEKOP", title: "", airway: "UZ42", airway\_type: "H", …} NEVKU: {id: "70022", name: "NEVKU", title: "", airway: "UZ42", airway\_type: "H", …} OBLUG: {id: "70026", name: "OBLUG", title: "", airway: "UZ42", airway\_type: "H", …} OPLEM: {id: "70021", name: "OPLEM", title: "", airway: "UZ42", airway\_type: "H", …} PUMRO: {id: "70018", name: "PUMRO", title: "", airway: "UZ42", airway\_type: "H", …} SIDAK: {id: "69160", name: "SIDAK", title: "", airway: "UZ22", airway\_type: "H", …} UGOVU: {id: "70028", name: "UGOVU", title: "", airway: "UZ42", airway\_type: "H", …} UGPOP: {id: "70041", name: "UGPOP", title: "", airway: "UZ42", airway\_type: "H", …} UKLIM: {id: "70023", name: "UKLIM", title: "", airway: "UZ42", airway\_type: "H", …} UMSIL: {id: "69161", name: "UMSIL", title: "", airway: "UZ22", airway\_type: "H", …} UTLUP: {id: "70024", name: "UTLUP", title: "", airway: "UZ42", airway\_type: "H", …} VAGOR: {id: "69162", name: "VAGOR", title: "", airway: "UZ22", airway\_type: "H", …} VALEV: {id: "70017", name: "VALEV", title: "", airway: "UZ42", airway\_type: "H", …}
Here is my entry waypoint
KULIS: airway: "UM415" airway\_type: "H" freq: "" id: "57176" lat: "-13.477331" lng: "-74.951080" loc: "SAM" name: "KULIS" seq: "36" title: "KULIS" type: "5"
You can see seq = 36, my exit waypoint for this is seq = 20.
SIDAK AIRAWAY: UM415 SEQ: 20
Here’s the function in NavData.class.php
public static function parseRoute($schedule) { $fromlat = $schedule-\>deplat; $fromlng = $schedule-\>deplng; $route\_string = $schedule-\>route; if ($route\_string == '') { return array(); } // Remove any SID/STAR text //$route\_string = str\_replace('SID', '', $route\_string); //$route\_string = str\_replace('STAR', '', $route\_string); $route\_string = str\_replace('DCT', '', $route\_string); $navpoints = array(); $all\_points = explode(' ', $route\_string); foreach ($all\_points as $key =\> $value) { if (empty($value) === true) { continue; } $navpoints[] = strtoupper(trim($value)); } $allpoints = array(); $total = count($navpoints); $airways = self::getAirways($navpoints); for ($i = 0; $i \< $total; $i++) { $name = self::cleanName($navpoints[$i]); /\* the current point is an airway, so go through the airway list and add each corresponding point between the entry and exit to the list. \*/ if (isset($airways[$name])) { $entry\_name = self::cleanName($navpoints[$i - 1]); $exit\_name = self::cleanName($navpoints[$i + 1]); $entry = self::getPointIndex($entry\_name, $airways[$name]); $exit = self::getPointIndex($exit\_name, $airways[$name]); if ($entry == -1) { $entry = $exit; } else { /\* Add information abotu the entry point in first, if it's valid and exists \*/ $allpoints[$entry\_name] = $airways[$name][$entry]; } if ($exit == -1) { continue; } if ($entry \< $exit) { # Go forwards through the list adding each one for ($l = $entry; $l \<= $exit; $l++) { $allpoints[$airways[$name][$l]-\>name] = $airways[$name][$l]; } } elseif ($entry \> $exit) { # Go backwards through the list for ($l = $exit; $l \>= $entry; $l--) { $point\_name = self::cleanName($airways[$name][$l]-\>name); $allpoints[$point\_name] = $airways[$name][$l]; } } elseif ($entry == $exit) { $point\_name = self::cleanName($airways[$name][$l]-\>name); $allpoints[$point\_name] = $airways[$name][$entry]; } # Now add the exit point, and increment the main counter by one if ($exit \> -1) { $allpoints[$exit\_name] = $airways[$name][$exit]; } continue; } else { /\* This nav point already exists in the list, don't add it again \*/ if (isset($allpoints[$navpoints[$i]])) { continue; } /\* Means it is a track, so go into processing it See if it's something like XXXX/YYYY \*/ if (substr\_count($navpoints[$i], '/') \> 0) { $name = $navpoints[$i]; $point\_name = explode('/', $name); preg\_match(self::$nat\_pattern, $point\_name[0], $matches); $coord = $matches[1]; $lat = $matches[2] . $coord[0] . $coord[1] . '.' . $coord[2] . $coord[3]; /\* Match the second set of coordinates \*/ # Read the second set preg\_match(self::$nat\_pattern, $point\_name[1], $matches); if ($matches == 0) { continue; } $coord = $matches[1]; $lng = $matches[2] . $coord[0] . $coord[1] . $coord[2] . '.' . $coord[3]; /\* Now convert into decimal coordinates \*/ $coords = $lat . ' ' . $lng; $coords = Util::get\_coordinates($coords); if (empty($coords['lat']) || empty($coords['lng'])) { unset($allpoints[$navpoints[$i]]); continue; } $tmp = new stdClass(); $tmp-\>id = 0; $tmp-\>type = NAV\_TRACK; $tmp-\>name = $name; $tmp-\>title = $name; $tmp-\>lat = $coords['lat']; $tmp-\>lng = $coords['lng']; $tmp-\>airway = ''; $tmp-\>sequence = 0; $tmp-\>freq = ''; $allpoints[$navpoints[$i]] = $tmp; unset($point\_name); unset($matches); unset($tmp); } else { $allpoints[$navpoints[$i]] = $navpoints[$i]; $navpoint\_list[] = $navpoints[$i]; } } } $navpoint\_list\_details = self::getNavDetails($navpoint\_list); foreach ($navpoint\_list\_details as $point =\> $list) { $allpoints[$point] = $list; } unset($navpoint\_list\_details); /\* How will this work - loop through each point, and decide which one we'll use, determined by the one which is the shortest distance from the previous Go in the order of the ones passed in. \*/ foreach ($allpoints as $point\_name =\> $point\_details) { if (is\_string($point\_details)) { unset($allpoints[$point\_name]); continue; } if (!is\_array($point\_details)) { continue; } $results\_count = count($point\_details); if ($results\_count == 1) { $allpoints[$point\_name] = $point\_details[0]; } elseif ($results\_count \> 1) { /\* There is more than one, so find the one with the shortest distance from the previous point out of all the ones \*/ $index = 0; $dist = 0; /\* Set the inital settings \*/ $lowest\_index = 0; $lowest = $point\_details[$lowest\_index]; $lowest\_dist = SchedulesData::distanceBetweenPoints($fromlat, $fromlng, $lowest-\> lat, $lowest-\>lng); foreach ($point\_details as $p) { $dist = SchedulesData::distanceBetweenPoints($fromlat, $fromlng, $p-\>lat, $p-\> lng); if ($dist \< $lowest\_dist) { $lowest\_index = $index; $lowest\_dist = $dist; } $index++; } $allpoints[$point\_name] = $point\_details[$lowest\_index]; } $fromlat = $allpoints[$point\_name]-\>lat; $fromlng = $allpoints[$point\_name]-\>lng; } return $allpoints; }
If anyone has any ideas I’m all ears–been plugging at this for about a week now.
Every single airway that is punched into route works without issue if the entry sequence number is less than exit sequence number so that it’s moving forward in gathering the waypoint info.