--- a/include/common-transit.inc.php +++ b/include/common-transit.inc.php @@ -45,6 +45,32 @@ return ""; } } + +$serviceAlertCause = Array( +"UNKNOWN_CAUSE" => "Unknown cause", +"OTHER_CAUSE" => "Other cause", +"TECHNICAL_PROBLEM" => "Technical problem", +"STRIKE" => "Strike", +"DEMONSTRATION" => "Demonstration", +"ACCIDENT" => "Accident", +"HOLIDAY" => "Holiday", +"WEATHER" => "Weather", +"MAINTENANCE" => "Maintenance", +"CONSTRUCTION" => "Construction", +"POLICE_ACTIVITY" => "Police activity", +"MEDICAL_EMERGENCY" => "Medical emergency" +); +$serviceAlertEffect = Array( +"NO_SERVICE" => "No service", +"REDUCED_SERVICE" => "Reduced service", +"SIGNIFICANT_DELAYS" => "Significant delays", +"DETOUR" => "Detour", +"ADDITIONAL_SERVICE" => "Additional service", +"MODIFIED_SERVICE" => "Modified service", +"OTHER_EFFECT" => "Other effect", +"UNKNOWN_EFFECT" => "Unknown effect", +"STOP_MOVED" => "Stop moved"); + function getServiceAlerts($filter_class, $filter_id) { /* @@ -54,14 +80,21 @@ - stop - trip - network - - patterns (WHERE=) + - classes (WHERE=) - route (short_name or route_id) - street - stop - - trip */ + - trip + Currently support: + network inform + trip patch: stop remove + street inform: route inform, trip inform, stop inform + route patch: trip remove + */ $return = Array(); -$return['header']['gtrtfs_version'] = "1"; +$return['header']['gtfs_realtime_version'] = "1"; $return['header']['timestamp'] = time(); +$return['header']['incrementality'] = "FULL_DATASET"; $return['entities'] = Array(); foreach(getCurrentAlerts() as $alert) { $informedEntities = getInformedAlerts($alert['id'],$_REQUEST['filter_class'],$_REQUEST['filter_id']); @@ -70,8 +103,12 @@ $entity['id'] = $alert['id']; $entity['alert']['active_period']['start'] = $alert['start']; $entity['alert']['active_period']['end'] = $alert['end']; - $entity['alert']['url']['translation'] = $alert['url']; - $entity['alert']['description']['translation'] = $alert['description']; + $entity['alert']['url']['translation']['text'] = $alert['url']; + $entity['alert']['url']['translation']['language'] = 'en'; + $entity['alert']['header_text']['translation']['text'] = $alert['header']; + $entity['alert']['header_text']['translation']['language'] = 'en'; + $entity['alert']['description_text']['translation']['text'] = $alert['description']; + $entity['alert']['description_text']['translation']['language'] = 'en'; foreach ($informedEntities as $informedEntity) { $informed = Array(); @@ -97,8 +134,8 @@ $id = $value; } } - $return[$class][$id]['entity'] = $entity; - $return[$class][$id]['action'] = $informed["x-action"]; + $return[$class][$id][]['entity'] = $entity; + $return[$class][$id][]['action'] = $informed["x-action"]; } } }