Ither Posted January 2, 2020 Report Posted January 2, 2020 What causes the route_details column to be empty on a pirep? I have detected that PIREPS like this don't show navaids on the PIREP map. a:0:{} I dont' quite understand the reason because I see it on some that have 1 navaid, or 4 navaids--but then I have another with 4 navaids and route details showing. Ignore the one in image that says "Enter"; pilot didn't actually enter route from Simbrief. Low down: basically any PIREP with route_details that only has "a:0:{}" shows zero navaids on map. Let's look at bottom one; ID #91 with route BOCAP -- that is valid fix that I pulled from ForeFlight (on my table) to go from KCRG to KGNV -- it is in my navdata database with correct lat/lon; type = 5. It doesn't show at all. Here is a image of my table. https://imgur.com/a/21toxlU Quote
Administrators ProAvia Posted January 2, 2020 Administrators Report Posted January 2, 2020 Quote Low down: basically any PIREP with route_details that only has "a:0:{}" shows zero navaids on map If that's the case, the system isn't recognizing any of the routing besides dep/arr points - whether theu are in the navdata tavle or not. Quote
Ither Posted January 2, 2020 Author Report Posted January 2, 2020 2 hours ago, ProAvia said: If that's the case, the system isn't recognizing any of the routing besides dep/arr points - whether theu are in the navdata tavle or not. Is there way to debug that to see why? I'm just curious if it's because the navaid is at ID 82,345 (something insane like that.) Quote
Administrators ProAvia Posted January 2, 2020 Administrators Report Posted January 2, 2020 The record ID of the fix makes no difference - Can you provide the info from the navdata table for that fix? Quote
Ither Posted January 2, 2020 Author Report Posted January 2, 2020 Here you go. https://imgur.com/a/jnvvVpl I cross checked the data to ForeFlight; the fix is right from lat/lng. Quote
web541 Posted January 3, 2020 Report Posted January 3, 2020 Provided that the route isn't empty, the `route_details` field should populate automatically as seen here https://github.com/DavidJClark/phpvms_5.5.x/blob/master/core/common/PIREPData.class.php#L643 which will then call NavData::parseRoute() leading to here where it finds the waypoint in your `_navdata` table https://github.com/DavidJClark/phpvms_5.5.x/blob/master/core/common/NavData.class.php#L311 It's possible that it's not finding the waypoint in the table properly and thus not saving the route_details in PIREPData. Quote
Ither Posted January 3, 2020 Author Report Posted January 3, 2020 (edited) 50 minutes ago, web541 said: Provided that the route isn't empty, the `route_details` field should populate automatically as seen here https://github.com/DavidJClark/phpvms_5.5.x/blob/master/core/common/PIREPData.class.php#L643 which will then call NavData::parseRoute() leading to here where it finds the waypoint in your `_navdata` table https://github.com/DavidJClark/phpvms_5.5.x/blob/master/core/common/NavData.class.php#L311 It's possible that it's not finding the waypoint in the table properly and thus not saving the route_details in PIREPData. @web541any idea where I would start looking? I ran SQL search on name = "BOCAP" and pulled it up. It's not just this 1; I've seeing more in pirep table that are like that. Just wondering if it's an optimization issue or something? Maybe I'm not letting it run long enough to search 80k rows? I'm on a VPS so I got plenty of power--just wondering now if maybe php or MySql isn't configured right. Edited January 3, 2020 by Ither Quote
web541 Posted January 3, 2020 Report Posted January 3, 2020 During the flight and before you file the PIREP, is the route_details column of the `acarsdata` table also empty? If so then it is probably a parsing issue where it can't find the waypoint in the table. I guess you could check the values of $results here https://github.com/DavidJClark/phpvms_5.5.x/blob/master/core/common/NavData.class.php#L315 but if it's empty it would return an array which is what we are seeing I think. Quote
Administrators ProAvia Posted January 3, 2020 Administrators Report Posted January 3, 2020 I wonder if there is any chance the skin you are using is causing this? I don't think it would. But, maybe try changing to the default crystal skin and see if the issue is still there. Any chance a module you installed included anything that could have changed the navdata calls? Quote
Ither Posted January 3, 2020 Author Report Posted January 3, 2020 @web541 @ProAvia Ok; so couple things I figured out and fixed -- the navaid rawdata column parsing issue was a db timeout setting (actually on MySQL). I fixed that sometime yesterday because when I tried to run the navdata fsbuild script I would get "mysql server gone away." I suspect that fixed it since now I got the rawdata column populated with the BOCAP waypoint. Now a new twist of events; I saw the navaid on the ACARS live flight map but not on PIREP. Got to looking at code and noticed this; // rendering for if there's smartcars data if(flight.rawdata instanceof Object && flight.rawdata.points !== undefined && Array.isArray(flight.rawdata.points) ) { $.each(flight.rawdata.points, function(i, nav) { if(nav.lat === undefined || nav.lng === undefined) { return; } path.push(L.latLng(nav.lat, nav.lng)); }); } else { $.each(flight.route_details, function(i, nav) { const loc = L.latLng(nav.lat, nav.lng); const icon = (nav.type === 3) ? MapFeatures.icons.vor : MapFeatures.icons.fix; points.push(loc); const marker = L.marker(loc, { icon: icon, title: nav.title, }) .bindPopup(tmpl("navpoint_bubble", { nav: nav })) .addTo(map); }); } I'm not good with JS but the IF/ELSE is pretty explainable--however I want both route data and flight path data--so I removed the "ELSE" statement and now my PIREP map shoulds navaids and the flown path. // rendering for if there's smartcars data if(flight.rawdata instanceof Object && flight.rawdata.points !== undefined && Array.isArray(flight.rawdata.points) ) { $.each(flight.rawdata.points, function(i, nav) { if(nav.lat === undefined || nav.lng === undefined) { return; } path.push(L.latLng(nav.lat, nav.lng)); }); } $.each(flight.route_details, function(i, nav) { const loc = L.latLng(nav.lat, nav.lng); const icon = (nav.type === 3) ? MapFeatures.icons.vor : MapFeatures.icons.fix; points.push(loc); const marker = L.marker(loc, { icon: icon, title: nav.title, }) .bindPopup(tmpl("navpoint_bubble", { nav: nav })) .addTo(map); }); Quote
Administrators ProAvia Posted January 3, 2020 Administrators Report Posted January 3, 2020 Great! So it's all working as you expected now? What file is that code from above? Quote
Ither Posted January 3, 2020 Author Report Posted January 3, 2020 33 minutes ago, ProAvia said: Great! So it's all working as you expected now? What file is that code from above? It's working exactly as I wanted now. The file above is the acarsmap.js Quote
Administrators ProAvia Posted January 3, 2020 Administrators Report Posted January 3, 2020 Default or edited for smartCARS? Quote
Ither Posted January 3, 2020 Author Report Posted January 3, 2020 3 hours ago, ProAvia said: Default or edited for smartCARS? Edited to use the data from CC Flight Tracker (which is really their functions pushing data in the rawdata field.) Quote
web541 Posted January 3, 2020 Report Posted January 3, 2020 Yeah where did you get that code from? It looks like nothing is happening with these lines: path.push(L.latLng(nav.lat, nav.lng)); points.push(loc); As in there's nothing in that snippet to say that they are being added to the map, although the navaids look like they should be showing up from the .addTo(map); Can you check that you've added that snipped in correctly? Also, what is actually missing right now (flight path or navaids), if anything? Quote
Ither Posted January 3, 2020 Author Report Posted January 3, 2020 @web541 It's only part of my JS. I didn't copy the whole thing. However, here is the entire thing. It works GREAT. /** * phpVMS - Virtual Airline Administration Software * Copyright (c) 2008 Nabeel Shahzad * For more information, visit www.phpvms.net * Forums: http://www.phpvms.net/forum * Documentation: http://www.phpvms.net/docs * * phpVMS is licenced under the following license: * Creative Commons Attribution Non-commercial Share Alike (by-nc-sa) * View license.txt in the root, or visit http://creativecommons.org/licenses/by-nc-sa/3.0/ * * @author Nabeel Shahzad * @copyright Copyright (c) 2008, Nabeel Shahzad * @link http://www.phpvms.net * @license http://creativecommons.org/licenses/by-nc-sa/3.0/ * * Rewritten for Google Maps v3 */ /** * */ function renderAcarsMap(opts) { let bounds = []; let selPath = []; let selPoints = [], selMarkers = []; let selDepMarker, selArrMarker, selPointsLayer, selPathLayer; let flightMarkers = []; let headingIcons = {}; let info_window = null; let run_once = false; opts = Object.assign({ render_elem: 'routemap', provider: 'OpenStreetMap.Mapnik', autozoom: false, zoom: 5, refreshTime: 12000, autorefresh: true }, opts); const map = createMap(opts); /** * Get the marker for a specific heading * @param {*} heading */ const getHeadingIcon = (heading) => { if (!(heading in headingIcons)) { headingIcons[heading] = L.icon({ iconUrl: url + "uploads/maps/heading/" + heading + ".png", iconSize: [35, 35] }); } return headingIcons[heading]; }; /** * Clear all of the markers and selected points */ const clearSelMarkers = () => { if (selDepMarker) { selDepMarker.remove(); selDepMarker = null; } if (selArrMarker) { selArrMarker.remove(); selArrMarker = null; } if (selPointsLayer) { selPointsLayer.remove(); selPointsLayer = null; } if (selPathLayer) { selPathLayer.remove(); selPathLayer = null; } for (let i in selMarkers) { selMarkers[i].remove(); } selPoints = []; selPath = []; }; /** * Draw the points/route for a flight * @param {*} features */ const flightClick = (flight) => { clearSelMarkers(); const depCoords = L.latLng(flight.deplat, flight.deplng); selDepMarker = L.marker(depCoords, { icon: MapFeatures.icons.departure, }).addTo(map); const arrCoords = L.latLng(flight.arrlat, flight.arrlng); selArrMarker = L.marker(arrCoords, { icon: MapFeatures.icons.arrival, }).addTo(map); selPoints.push(depCoords); $.each(flight.route_details, function(i, nav) { const loc = L.latLng(nav.lat, nav.lng); const icon = (nav.type === 3) ? MapFeatures.icons.vor : MapFeatures.icons.fix; selPoints.push(loc); const marker = L.marker(loc, { icon: icon, title: nav.title, }) .bindPopup(tmpl("navpoint_bubble", { nav: nav })).on("popupopen", () => { $(".leaflet-popup-close-button").on("click", e => { clearSelMarkers(); }) }) .addTo(map); selMarkers.push(marker); }); selPoints.push(arrCoords); selPointsLayer = L.geodesic([selPoints], { weight: 3, opacity: 0.3, color: '#000000', steps: 4 }).addTo(map); /*map.fitBounds(selPointsLayer.getBounds(),{padding: [200, 200]});*/ /* Attempt to show flight path */ $.post("/action.php/trackflight/getposreps", { pilotid: flight.pilotid.substring(3), flightnum: flight.flightnum }) .done(function( dirflts ) { $.each(dirflts, function(i, nav) { if(nav.latitude === undefined || nav.longitude === undefined) { return; } const ploc = L.latLng(nav.latitude, nav.longitude) selPath.push(ploc); }); selPathLayer = L.geodesic([selPath], { weight: 4, opacity: 0.5, color: 'red', steps: 8 }).addTo(map); }); }; /** * * @param {*} data */ const populateMap = (data) => { clearMap(); $("#pilotlist").html(""); /*if (data.length == 0) { return false; }*/ if (data.length == 0) { $("#acars_map_divider").hide(); $("#acars_map_table").hide(); // Or .css("display", "none"); return false; } $("#acars_map_divider").hide(); $("#acars_map_table").show(); // or .css("display", "block"); let lat, lng; let details, row, pilotlink; bounds = []; $.each(data, function(i, flight) { if (flight == null || flight.lat == null || flight.lng == null || flight.lat == "" || flight.lng == "") { return; } flight.lat = Number(flight.lat); flight.lng = Number(flight.lng); lat = flight.lat; lng = flight.lng; if (i % 2 == 0) flight.trclass = "even"; else flight.trclass = "odd"; // Pull ze templates! const map_row = tmpl("acars_map_row", { flight: flight }); const detailed_bubble = tmpl("acars_map_bubble", { flight: flight }); $('#pilotlist').append(map_row); const pos = L.latLng(lat, lng); const marker = L.marker(pos, { icon: getHeadingIcon(flight.heading), zIndexOffset: 1000, }) .on('click', (e) => { flightClick(flight); }) .bindPopup(detailed_bubble).on("popupopen", () => { $(".leaflet-popup-close-button").on("click", e => { clearSelMarkers(); }) }) .addTo(map); flightMarkers.push(marker); bounds.push(pos); /* Clear everything when Popup closes */ /* marker.getPopup().on('remove', function() { clearSelMarkers(); /*map.setZoom(opts.zoom);*/ /*});*/ }); // If they selected autozoom, only do the zoom first time if (opts.autozoom == true && run_once == false) { map.fitBounds(bounds); run_once = true; } } /** * Clear all markers and layers */ const clearMap = () => { // clear markers for (let i in flightMarkers) { flightMarkers[i].remove(); } }; /** * */ const liveRefresh = () => { $.ajax({ type: "GET", url: url + "/action.php/acars/data", dataType: "json", cache: false, success: function(data) { populateMap(data); } }); }; /** * Render * */ liveRefresh(); if (opts.autorefresh == true) { setInterval(function() { liveRefresh(); }, opts.refreshTime); } } Quote
web541 Posted January 3, 2020 Report Posted January 3, 2020 Oops didn't get the memo that you had fixed it already, good job 👍 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.