Jump to content

Recommended Posts

Posted

I want to make a foreach loop with the schedule route and the nav data, so basically display the data for each waypoint in the route. I noticed there is a function called parseRoute($schedule), which I tried to implement by nothing happened.

Any ideas???

  • Moderators
Posted

I been trying to chase that, but I'm still no expert yet. :P

But I'll try again and see what I can make out of it.

  • Moderators
Posted

Here's what I have so far. No luck... Hopefully someone with a knowledge of it will come by.

<?php
$fromlat = $schedule->deplat;
$fromlng = $schedule->deplng;
$route_string = $schedule->route;
$routedata = NavData::parseRoute($fromlat, $fromlng, $route_string);
$route_string = array();
?>
<table>
<thead>
<tr>
<th>Lat</th>
<th>Long</th>
</tr>
</thead>
<tbody>
<?php
foreach($routedata as $routeline) {
?>
<tr>
<td align="center"><?php echo $routeline->lat; ?></td>
<td align="center"><?php echo $routeline->lng; ?></td>
</tr>
<?php
}
?>
</tbody>
</table>

Guest lorathon
Posted

Here you go

<?php
$params->deplat = 1;
$params->deplng = 1;
$params->route = 'HEL UT6 PEVEN UL990 PERRY';

$routedata = NavData::parseRoute($params);
?>
<table>
<thead>
 <tr>
  <th>Lat</th>
  <th>Long</th>
 </tr>
</thead>
<tbody>
<?php
foreach($routedata as $routeline) {
 ?>
 <tr>
  <td align="center"><?php echo $routeline->lat; ?></td>
  <td align="center"><?php echo $routeline->lng; ?></td>
 </tr>
<?php
}
?>
</tbody>
</table>

Guest lorathon
Posted

So I am confused? Is the loop working at all? It is one my site. If you want the name then just expand the table. The table that Kyle wrote has just the lat/lng but all columns can be put into the table.

  • Moderators
Posted

Still not working for me :/

It worked for me. Did you change code on top and set it where your getting the data.

$params->deplat = 1;
$params->deplng = 1;
$params->route = 'HEL UT6 PEVEN UL990 PERRY';

So, if your doing it in the schedules detail page, this is the code..

<?php
$params->deplat = $schedule->deplat;
$params->deplng = $schedule->deplng;
$params->route = $schedule->route;
$routedata = NavData::parseRoute($params);
?>
<table>
<thead>
 <tr>
  <th>Lat</th>
  <th>Long</th>
 </tr>
</thead>
<tbody>
<?php
foreach($routedata as $routeline) {
 ?>
 <tr>
  <td align="center"><?php echo $routeline->lat; ?></td>
  <td align="center"><?php echo $routeline->lng; ?></td>
 </tr>
<?php
}
?>
</tbody>
</table>

Posted

Nope not working:

<?php
$params->deplat = $schedule->deplat;
$params->deplng = $schedule->deplng;
$params->route = $route;
$routedata = NavData::parseRoute($params);
?>
<table>
<thead>
 <tr>
  <th>Lat</th>
  <th>Long</th>
 </tr>
</thead>
<tbody>
<?php
foreach($routedata as $routeline) {
 ?>
 <tr>
  <td align="center"><?php echo $routeline->lat; ?></td>
  <td align="center"><?php echo $routeline->lng; ?></td>
 </tr>
<?php
}
?>
</tbody>
</table>

Guest lorathon
Posted

How are you filling the $schedule array and the $route variable?

Posted

By the way this is in a file called briefing.php in my public_html directory.

Schedule:

$schedule = SchedulesData::GetScheduleDetailed (all I can remember off the top of my head)

$route is $schedule->route but with some characters removed as some of my routes had '?' instead of a space so I used str_replace to do replace that with a space.

Guest lorathon
Posted

Then change this

$params->deplat = $schedule->deplat;
$params->deplng = $schedule->deplng;
$params->route = $route;

to this

$params->deplat = $schedule->deplat;
$params->deplng = $schedule->deplng;
$params->route = $schedule->route;

And then expand the table to show what you wish. The route must be part of the schedule for this to work

Guest lorathon
Posted

Send me the complete code from the page you are attempting to use this in. PM it.

Guest lorathon
Posted

If you use this

<?php
$params->deplat = 1;
$params->deplng = 1;
$params->route = 'HEL UT6 PEVEN UL990 PERRY';
$routedata = NavData::parseRoute($params);
?>
<table>
<thead>
 <tr>
  <th>Lat</th>
  <th>Long</th>
 </tr>
</thead>
<tbody>
<?php
foreach($routedata as $routeline) {
 ?>
 <tr>
  <td align="center"><?php echo $routeline->lat; ?></td>
  <td align="center"><?php echo $routeline->lng; ?></td>
 </tr>
<?php
}
?>
</tbody>
</table>

And nothing shows up then there is something wrong. This supplies the start lat/lng and the route. I would check your DB and ensure that the navdata table is there.

  • Moderators
Posted

From what itrobb is saying, I agree and it doesn't look like he has or not have the navdata tables set up or not correct.

Do you have a table like navdata or phpvms_navdata in your database? Double check and if it is empty or not there, then you would need to import one from the latest phpVMS Version.

  • 1 month later...
Posted

OK it works and I now have the lat and long for each waypoint, but how can I retrieve the rest of the data for each waypoint (type, freq etc) by using the coordinates?

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...