OpenLDBWS Callingpoints

58 views
Skip to first unread message

Dereck Jones

unread,
Jul 13, 2021, 1:12:10 PMJul 13
to A gathering place for the Open Rail Data community
Hi all, I just want to know why when I call data using "GetDepBoardWithDetails" the calling data returned has duplicate station names. There's probably a very good reason but for a newb it looks confusing.The departure station is London Gatwick [crs] => GTW. The data returned looks like this.

.GTW.png

Any feedback would be great.

Peter Hicks

unread,
Jul 13, 2021, 1:17:15 PMJul 13
to A gathering place for the Open Rail Data community
Hi Dereck

Are these not the calling points for the services returned?  I see different calling patterns in order for each.

What's the code you're using to generate this list?

Peter Hicks
Director
OpenTrainTimes Ltd.


--
You received this message because you are subscribed to the Google Groups "A gathering place for the Open Rail Data community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openraildata-t...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/openraildata-talk/20bc38bd-5e7c-4e6d-9271-73c26a85a9fen%40googlegroups.com.


OpenTrainTimes Ltd. registered in England and Wales, company no. 09504022.
Registered office: Suite 1-3, Hop Exchange, 24 Southwark Street, London SE1 1TY

RailAleFan

unread,
Jul 13, 2021, 1:32:41 PMJul 13
to A gathering place for the Open Rail Data community
Hi Dereck,

Checkout Example 3a (not on the repo) which is GTW  detailed departures and covers pretty much everything...


Cheers

Dereck Jones

unread,
Jul 13, 2021, 2:34:18 PMJul 13
to A gathering place for the Open Rail Data community
Hi Peter,
My code is below, please bare in mind I'm new to PHP so the code may be messy.

require("OpenLDBWS.php");
$OpenLDBWS = new OpenLDBWS("My Token");
$response = $OpenLDBWS->GetDepBoardWithDetails(100,"GTW",0,0,60,120);
header("Content-Type: text/plain");
//print_r ($response);
if (isset($response->GetStationBoardResult->trainServices->service))
      {
         foreach($response->GetStationBoardResult->trainServices->service as $service)
        {
          $destinations = array();
          foreach($service->destination->location as $location)
          {
            $destinations[] = $location->locationName;
$desticrs[] = $location->crs;
          }
$recordtime = substr($response->GetStationBoardResult->generatedAt, 0, 16);
$origin_location = $response->GetStationBoardResult->locationName;
$origin_crs= $response->GetStationBoardResult->crs;
        $time = $service->std;
$serviceID = $service->serviceID;
$operator = $service->operator;
        $dest = implode($destinations);
$dest_crs = implode($desticrs);
        $plat = $service->platform;
        $est= $service->etd;
$datetime = substr($recordtime, 0, 16);
$recordtime = str_replace('T',' ',$recordtime); 
$recordtime = date("Y-m-d H:i",strtotime($recordtime));
// Perform lookup on ServiceID
$query_service_lookup = "SELECT * FROM UKRail_departboards WHERE ServiceID = '".$serviceID."'";
$service_lookup = mysqli_query($navex, $query_service_lookup  ) or die(mysqli_error($navex));
$row_lookup = mysqli_fetch_assoc($service_lookup);
$totalRows_service_lookup = mysqli_num_rows($service_lookup);
// If ServiceID is found, update if required
do {
if($row_lookup['Estimated'] != $est ||$row_lookup['Platform'] != $plat ){
$query_p = "UPDATE UKRail_departboards Set Estimated = '".$est."', Platform = '".$plat."' WHERE ServiceID = '".$serviceID."' ";
  $p = mysqli_query($navex, $query_p) or die(mysqli_error($navex));
  }
// If no ServiceID found, insert new record
if(empty($row_lookup['ServiceID'])){
$insertSQL = "INSERT INTO UKRail_departboards (RecordDate, ServiceID, Origin_location, Origin_crs, Platform, ScheduleTime, Estimated, Dest_location, Dest_crs, Operator) VALUES ('".$recordtime."', '".$serviceID."','".$origin_location."', '".$origin_crs."', '".$plat."', '".$time."', '".$est."','".$dest."', '".$dest_crs ."', '".$operator."')";
$Result1 = mysqli_query($navex,$insertSQL) or die(mysqli_error($navex));
}

} while($row_lookup = mysqli_fetch_assoc($service_lookup));
// Read Calling at data
$callingpoints = array();
       foreach($service->subsequentCallingPoints->callingPointList as $callingPointList)
{
  foreach($callingPointList->callingPoint as $calling)
  {
      $call = $calling->locationName;
// Insert CallingPoints
  $insertSQL = "INSERT INTO UKRail_departboard_calling_points (ServiceID, CallingPoint, Origin_location) VALUES ('".$serviceID."','".$call."','".$crs."')";
$Result1 = mysqli_query($navex,$insertSQL) or die(mysqli_error($navex));
  
  }
}
}
}

Reply all
Reply to author
Forward
0 new messages