Merge new gtfs-realtime into existing servicealerts architecture
--- a/about.php
+++ b/about.php
@@ -21,6 +21,10 @@
, <a href="http://itunes.apple.com/au/app/act-buses/id376634797?mt=8">ACT Buses by David Sullivan</a>)
and Android (<a href="https://market.android.com/details?id=com.action">MyBus 2.0 by Imagine Team</a>)
<br />
+GTFS-realtime API;
+Alerts and Trip Updates (but only Cancelled or Stop Skipped)
+Default format binary but can get JSON by adding ?ascii=yes
+<br />
<br />
<small>Disclaimer: The content of this website is of a general and informative nature. Please check with printed timetables or those available on http://action.act.gov.au before your trip.
Whilst every effort has been made to ensure the high quality and accuracy of the Site, the Author makes no warranty,
--- a/include/common-template.inc.php
+++ b/include/common-template.inc.php
@@ -156,11 +156,11 @@
echo '<div id="servicewarning">Buses are running on an altered timetable today due to industrial action/public holiday. See <a href="http://www.action.act.gov.au">http://www.action.act.gov.au</a> for details.</div>';
}
}
- if ($serviceAlertsEnabled) {
- $serviceAlerts = getServiceAlerts("network","network");
- foreach ($serviceAlerts['entities'] as $entity) {
- echo "<div id='servicewarning'>".date("F j, g:i a",strtotime($entity['alert']['active_period']['start']))." to ". date("F j, g:i a", strtotime($entity['alert']['active_period']['end']))."{$entity['alert']['header_text']['translation']['text']}<br>Warning: {$entity['alert']['description_text']['translation']['text']}
- <br><a href='{$entity['alert']['url']['translation']['text']}'>Source</a> </div>";
+ if ($GTFSREnabled) {
+ $serviceAlerts = getServiceAlertsAsArray("agency","0");
+ foreach ($serviceAlerts['entity'] as $entity) {
+ echo "<div id='servicewarning'>".date("F j, g:i a",strtotime($entity['alert']['active_period'][0]['start']))." to ". date("F j, g:i a", strtotime($entity['alert']['active_period'][0]['end']))."{$entity['alert']['header_text']['translation'][0]['text']}<br>Warning: {$entity['alert']['description_text']['translation'][0]['text']}
+ <br><a href='{$entity['alert']['url']['translation'][0]['text']}'>Source</a> </div>";
}
}
}
--- a/include/common-transit.inc.php
+++ b/include/common-transit.inc.php
@@ -45,7 +45,7 @@
return "";
}
}
-
+if ($GTFSREnabled) {
$serviceAlertCause = Array(
"UNKNOWN_CAUSE" => "Unknown cause",
"OTHER_CAUSE" => "Other cause",
@@ -71,7 +71,22 @@
"UNKNOWN_EFFECT" => "Unknown effect",
"STOP_MOVED" => "Stop moved");
-function getServiceAlerts($filter_class, $filter_id) {
+set_include_path(get_include_path() . PATH_SEPARATOR . $labsPath."lib/Protobuf-PHP/library/DrSlump/");
+
+include_once("Protobuf.php");
+include_once("Protobuf/Message.php");
+include_once("Protobuf/Registry.php");
+include_once("Protobuf/Descriptor.php");
+include_once("Protobuf/Field.php");
+
+include_once($labsPath."lib/Protobuf-PHP/gtfs-realtime.php");
+include_once("Protobuf/CodecInterface.php");
+include_once("Protobuf/Codec/PhpArray.php");
+include_once("Protobuf/Codec/Binary.php");
+include_once("Protobuf/Codec/Binary/Writer.php");
+include_once("Protobuf/Codec/Json.php");
+
+function getServiceAlerts($filter_class = "", $filter_id = "") {
/*
also need last modified epoch of client gtfs
@@ -91,40 +106,82 @@
street inform: route inform, trip inform, stop inform
route patch: trip remove
*/
-$return = Array();
-$return['header']['gtfs_realtime_version'] = "1";
-$return['header']['timestamp'] = time();
-$return['header']['incrementality'] = "FULL_DATASET";
-$return['entities'] = Array();
+ $fm = new transit_realtime\FeedMessage();
+$fh = new transit_realtime\FeedHeader();
+$fh->setGtfsRealtimeVersion(1);
+$fh->setTimestamp(time());
+$fm->setHeader($fh);
foreach(getCurrentAlerts() as $alert) {
- $informedEntities = getInformedAlerts($alert['id'],$_REQUEST['filter_class'],$_REQUEST['filter_id']);
+$fe = new transit_realtime\FeedEntity();
+ $fe->setId($alert['id']);
+ $fe->setIsDeleted(false);
+ $alert = new transit_realtime\Alert();
+ $tr = new transit_realtime\TimeRange();
+ $tr->setStart($alert['start']);
+ $tr->setEnd($alert['end']);
+ $alert-> addActivePeriod($tr);
+ $informedEntities = getInformedAlerts($alert['id'],$_REQUEST['filter_class'],$_REQUEST['filter_id']);
if (sizeof($informedEntities) >0) {
- $entity = Array();
- $entity['id'] = $alert['id'];
- $entity['alert']['active_period']['start'] = $alert['start'];
- $entity['alert']['active_period']['end'] = $alert['end'];
- $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();
- $informed[$informedEntity['informed_class']."_id"] = $informedEntity['informed_id'];
- if ($informedEntity['informed_action'] != "") $informed["x-action"] = $informedEntity['informed_action'];
- $informed[$informedEntity['class']."_type"] = $informedEntity['type'];
- $entity['informed'][] = $informed;
- }
- $return['entities'][] = $entity;
- }
-}
-return $return;
+ $informed = Array();
+ $es = new transit_realtime\EntitySelector();
+ if ($informedEntity['informed_class'] == "agency") {
+ $es->setAgencyId($informedEntity['informed_id']);
+ }
+ if ($informedEntity['informed_class'] == "stop") {
+ $es->setStopId($informedEntity['informed_id']);
+ }
+ if ($informedEntity['informed_class'] == "route") {
+ $es->setRouteId($informedEntity['informed_id']);
+ }
+ if ($informedEntity['informed_class'] == "trip") {
+ $td = new transit_realtime\TripDescriptor();
+ $td->setTripId($informedEntity['informed_id']);
+ $es->setTrip($td);
+ }
+ $alert-> addInformedEntity($es);
+ }
+ $alert->setCause(constant("transit_realtime\Alert\Cause::".$alert['cause']));
+ $alert->setEffect(constant("transit_realtime\Alert\Effect::".$alert['effect']));
+ $tsUrl = new transit_realtime\TranslatedString();
+ $tUrl = new transit_realtime\TranslatedString\Translation();
+ $tUrl->setText($alert['url']);
+ $tUrl->setLanguage("en");
+ $tsUrl->addTranslation($tUrl);
+ $alert->setUrl($tsUrl);
+ $tsHeaderText= new transit_realtime\TranslatedString();
+ $tHeaderText = new transit_realtime\TranslatedString\Translation();
+ $tHeaderText->setText($alert['header']);
+ $tHeaderText->setLanguage("en");
+ $tsHeaderText->addTranslation($tHeaderText);
+ $alert->setHeaderText($tsHeaderText);
+ $tsDescriptionText= new transit_realtime\TranslatedString();
+ $tDescriptionText = new transit_realtime\TranslatedString\Translation();
+ $tDescriptionText->setText($alert['description']);
+ $tDescriptionText->setLanguage("en");
+ $tsDescriptionText->addTranslation($tDescriptionText);
+ $alert->setDescriptionText($tsDescriptionText);
+ $fe->setAlert($alert);
+$fm->addEntity($fe);
+}
+return $fm;
+}
+function getServiceAlertsAsArray($filter_class = "", $filter_id = "") {
+ $codec = new DrSlump\Protobuf\Codec\PhpArray();
+ return $codec->encode(getServiceAlerts($filter_class, $filter_id));
+}
+
+function getServiceAlertsAsBinary($filter_class = "", $filter_id = "") {
+ $codec = new DrSlump\Protobuf\Codec\Binary();
+ return $codec->encode(getServiceAlerts($filter_class, $filter_id));
+}
+
+function getServiceAlertsAsJSON($filter_class = "", $filter_id = "") {
+ $codec = new DrSlump\Protobuf\Codec\Json();
+ return $codec->encode(getServiceAlerts($filter_class, $filter_id));
}
function getServiceAlertsByClass() {
$return = Array();
- $alerts = getServiceAlerts("","");
+ $alerts = getServiceAlertsAsArray("","");
foreach ($alerts['entities'] as $entity) {
foreach ($entity['informed'] as $informed) {
foreach($informed as $key => $value){
@@ -134,10 +191,70 @@
$id = $value;
}
}
- $return[$class][$id][]['entity'] = $entity;
- $return[$class][$id][]['action'] = $informed["x-action"];
- }
- }
+ $return[$class][$id][] = $entity;
+ }
+ }
+}
+
+function getTripUpdates($filter_class = "", $filter_id = "") {
+ $fm = new transit_realtime\FeedMessage();
+$fh = new transit_realtime\FeedHeader();
+$fh->setGtfsRealtimeVersion(1);
+$fh->setTimestamp(time());
+$fm->setHeader($fh);
+foreach(getCurrentAlerts() as $alert) {
+ $informedEntities = getInformedAlerts($alert['id'],$_REQUEST['filter_class'],$_REQUEST['filter_id']);
+ $stops = Array();
+ $routestrips = Array();
+ if (sizeof($informedEntities) >0) {
+ if ($informedEntity['informed_class'] == "stop" && $informed["x-action"] == "remove") {
+ $stops[] = $informedEntity['informed_id'];
+ }
+ if (($informedEntity['informed_class'] == "route" || $informedEntity['informed_class'] == "trip") && $informed["x-action"] == "patch" ) {
+ $routestrips[] = Array( "id" => $informedEntity['informed_id'],
+ "type"=>$informedEntity['informed_class']);
+ }
+ }
+foreach ($routestrips as $routetrip) {
+$fe = new transit_realtime\FeedEntity();
+ $fe->setId($alert['id'].$routetrip['id']);
+ $fe->setIsDeleted(false);
+ $tu = new transit_realtime\TripUpdate();
+ $td = new transit_realtime\TripDescriptor();
+ if ($routetrip['type'] == "route") {
+ $td->setRouteId($routetrip['id']);
+ } else if ($routetrip['type'] == "trip") {
+ $td->setTripId($routetrip['id']);
+ }
+ $tu->setTrip($td);
+ foreach ($stops as $stop) {
+ $stu = new transit_realtime\TripUpdate\StopTimeUpdate();
+ $stu->setStopId($stop);
+ $stu->setScheduleRelationship(transit_realtime\TripUpdate\StopTimeUpdate\ScheduleRelationship::SKIPPED);
+ $tu->addStopTimeUpdate($stu);
+ }
+ $fe->setTripUpdate($tu);
+$fm->addEntity($fe);
+}
+
+}
+return $fm;
+
+}
+function getTripUpdatesAsArray($filter_class = "", $filter_id = "") {
+ $codec = new DrSlump\Protobuf\Codec\PhpArray();
+ return $codec->encode(getTripUpdates($filter_class, $filter_id));
+}
+
+function getTripUpdatesAsBinary($filter_class = "", $filter_id = "") {
+ $codec = new DrSlump\Protobuf\Codec\Binary();
+ return $codec->encode(getTripUpdates($filter_class, $filter_id));
+}
+
+function getTripUpdatesAsJSON($filter_class = "", $filter_id = "") {
+ $codec = new DrSlump\Protobuf\Codec\Json();
+ return $codec->encode(getTripUpdates($filter_class, $filter_id));
+}
}
?>
--- a/include/common.inc.php
+++ b/include/common.inc.php
@@ -10,7 +10,7 @@
"database",
"other"
);
-$serviceAlertsEnabled = true;
+$GTFSREnabled = true;
$cloudmadeAPIkey = "daa03470bb8740298d4b10e3f03d63e6";
$googleMapsAPIkey = "ABQIAAAA95XYXN0cki3Yj_Sb71CFvBTPaLd08ONybQDjcH_VdYtHHLgZvRTw2INzI_m17_IoOUqH3RNNmlTk1Q";
$otpAPIurl = 'http://localhost:8080/opentripplanner-api-webapp/';
@@ -32,7 +32,7 @@
function isDebugServer()
{
- return php_sapi_name() == "cli" || isset($_SERVER['SERVER_NAME']) && ( $_SERVER['SERVER_NAME'] == "10.0.1.154" || $_SERVER['SERVER_NAME'] == "10.1.0.4" || $_SERVER['SERVER_NAME'] ==
+ return php_sapi_name() == "cli" || isset($_SERVER['SERVER_NAME']) && ( $_SERVER['SERVER_NAME'] == "azusa" || $_SERVER['SERVER_NAME'] == "vanille" || $_SERVER['SERVER_NAME'] ==
"localhost" || $_SERVER['SERVER_NAME'] == "127.0.0.1") ;
}
--- a/include/db/servicealert-dao.inc.php
+++ b/include/db/servicealert-dao.inc.php
@@ -17,7 +17,7 @@
function getServiceAlert($alertID)
{
global $conn;
- $query = 'SELECT * from servicealerts_alerts where id = :servicealert_id';
+ $query = "SELECT id,extract('epoch', start) as start, extract('epoch', end) as end,cause,effect,header,description,url from servicealerts_alerts where id = :servicealert_id";
debug($query, "database");
$query = $conn -> prepare($query);
$query -> bindParam(":servicealert_id", $alertID);
@@ -30,15 +30,16 @@
}
-function updateServiceAlert($alertID, $start, $end, $description, $url)
+function updateServiceAlert($alertID, $start, $end, $header, $description, $url)
{
global $conn;
- $query = 'update servicealerts_alerts set start=:start, "end"=:end, description=:description, url=:url where id = :servicealert_id';
+ $query = 'update servicealerts_alerts set start=:start, "end"=:end, header=:header, description=:description, url=:url where id = :servicealert_id';
debug($query, "database");
$query = $conn -> prepare($query);
$query -> bindParam(":servicealert_id", $alertID);
$query -> bindParam(":start", $start);
$query -> bindParam(":end", $end);
+ $query -> bindParam(":header", $header);
$query -> bindParam(":description", $description);
$query -> bindParam(":url", $url);
$query -> execute();
@@ -51,14 +52,15 @@
return $query -> fetch(PDO :: FETCH_ASSOC);
}
- function addServiceAlert($start, $end, $description, $url)
+ function addServiceAlert($start, $end, $header, $description, $url)
{
global $conn;
- $query = 'INSERT INTO servicealerts_alerts (start, "end", description, url) VALUES (:start, :end, :description, :url) ';
+ $query = 'INSERT INTO servicealerts_alerts (start, "end", header, description, url) VALUES (:start, :end, :header, :description, :url) ';
debug($query, "database");
$query = $conn -> prepare($query);
$query -> bindParam(":start", $start);
$query -> bindParam(":end", $end);
+ $query -> bindParam(":header", $header);
$query -> bindParam(":description", $description);
$query -> bindParam(":url", $url);
$query -> execute();
@@ -74,7 +76,7 @@
function getCurrentAlerts()
{
global $conn;
- $query = 'SELECT * from servicealerts_alerts where NOW() > start and NOW() < "end"';
+ $query = "SELECT id,extract('epoch', start) as start, extract('epoch', end) as end,cause,effect,header,description,url from servicealerts_alerts where NOW() > start and NOW() < \"end\"";
// debug($query, "database");
$query = $conn -> prepare($query);
$query -> execute();
@@ -88,7 +90,7 @@
function getFutureAlerts()
{
global $conn;
- $query = 'SELECT * from servicealerts_alerts where NOW() > start or NOW() < "end"';
+ $query = "SELECT id,extract('epoch', start) as start, extract('epoch', end) as end,cause,effect,header,description,url from servicealerts_alerts where NOW() > start or NOW() < \"end\"";
// debug($query, "database");
$query = $conn -> prepare($query);
$query -> execute();
--- a/labs/servicealert_editor.php
+++ b/labs/servicealert_editor.php
@@ -5,16 +5,14 @@
/**
* Currently support:
* network inform
- * stop remove: trip patch, route inform
+ * stop remove: route patch, stop remove
* - stop search
- * street inform: route inform, trip inform, stop inform
+ * street inform: route inform, stop inform
* - street search
- * trip remove: route patch, stop inform
- * - trip search by route
*/
if (isset($_REQUEST['saveedit'])) {
- if ($_REQUEST['saveedit'] != "") updateServiceAlert($_REQUEST['saveedit'], $_REQUEST['startdate'], $_REQUEST['enddate'], $_REQUEST['description'], $_REQUEST['url']);
+ if ($_REQUEST['saveedit'] != "") updateServiceAlert($_REQUEST['saveedit'], $_REQUEST['startdate'], $_REQUEST['enddate'], $_REQUEST['header'], $_REQUEST['description'], $_REQUEST['url']);
else addServiceAlert($_REQUEST['startdate'], $_REQUEST['enddate'], $_REQUEST['description'], $_REQUEST['url']);
echo "Saved " . $_REQUEST['saveedit'];
die();
@@ -26,7 +24,7 @@
die();
}
if ($_REQUEST['networkinform']) {
- addInformedAlert($_REQUEST['networkinform'], "network", "network", "inform");
+ addInformedAlert($_REQUEST['networkinform'], "agency", "0", "inform");
echo "Added network inform for" . $_REQUEST['networkinform'];
die();
}
@@ -34,58 +32,27 @@
addInformedAlert($_REQUEST['stopsearch'], "stop", $_REQUEST['stopid'], "remove");
echo "Added stop remove for" . $_REQUEST['stopsearch'] . ", stop" . $_REQUEST['stopid'] . "<br>\n";
- foreach ($service_periods as $sp) {
- echo "Patching $sp trips<br>\n";
- foreach (getStopTrips($_REQUEST['stopid'], $sp) as $trip) {
- addInformedAlert($_REQUEST['stopsearch'], "trip", $trip['trip_id'], "patch");
- echo "Added trip patch for" . $_REQUEST['stopsearch'] . ", trip" . $trip['trip_id'] . "<br>\n";
-
- }
- echo "Informing $sp routes<br>\n";
+ foreach ($service_periods as $sp) {
+ echo "Remove from $sp routes<br>\n";
foreach (getStopRoutes($_REQUEST['stopid'], $sp) as $route) {
- addInformedAlert($_REQUEST['stopsearch'], "route", $route['route_id'], "inform");
- echo "Added route inform for" . $_REQUEST['stopsearch'] . ", route" . $route['route_id'] . "<br>\n";
+ addInformedAlert($_REQUEST['stopsearch'], "route", $route['route_id'], "patch");
+ echo "Added route patch for" . $_REQUEST['stopsearch'] . ", route" . $route['route_id'] . "<br>\n";
}
}
die();
}
-if ($_REQUEST['routesearch']) {
- echo "Informing route<br>\n";
- $stops = Array();
- echo "Informing trips<br>\n";
- foreach(getRouteTrips() as $trip) {
- addInformedAlert($_REQUEST['stopsearch'], "trip", $trip['trip_id'], "patch");
- echo "Added trip patch for" . $_REQUEST['stopsearch'] . ", trip" . $trip['trip_id'] . "<br>\n";
- viaPoints($tripID, "", false);
- }
-
- echo "Informing stops<br>\n";
- foreach($stops as $stop) {
- addInformedAlert($_REQUEST['stopsearch'], "stop", $_REQUEST['stopid'], "remove");
- echo "Added stop remove for" . $_REQUEST['stopsearch'] . ", stop" . $_REQUEST['stopid'] . "<br>\n";
- }
- die();
- }
if ($_REQUEST['streetsearch']) {
- echo "Informing stops<br>\n";
+ echo "Informing stops of street<br>\n";
foreach(getStopByName() as $stop) {
- addInformedAlert($_REQUEST['stopsearch'], "stop", $_REQUEST['stopid'], "remove");
+ addInformedAlert($_REQUEST['stopsearch'], "stop", $_REQUEST['stopid'], "inform");
echo "Added stop inform for" . $_REQUEST['stopsearch'] . ", stop" . $_REQUEST['stopid'] . "<br>\n";
foreach ($service_periods as $sp) {
- echo "Patching $sp trips<br>\n";
- foreach (getStopTrips($_REQUEST['stopid'], $sp) as $trip) {
- addInformedAlert($_REQUEST['stopsearch'], "trip", $trip['trip_id'], "patch");
- echo "Added trip inform for" . $_REQUEST['stopsearch'] . ", trip" . $trip['trip_id'] . "<br>\n";
-
- }
echo "Informing $sp routes<br>\n";
foreach (getStopRoutes($_REQUEST['stopid'], $sp) as $route) {
addInformedAlert($_REQUEST['stopsearch'], "route", $route['route_id'], "inform");
- echo "Added route inform for" . $_REQUEST['stopsearch'] . ", route" . $route['route_id'] . "<br>\n";
-
-
+ echo "Added route inform for stop" . $_REQUEST['stopsearch'] . ", route" . $route['route_id'] . "<br>\n";
}
}
die();
@@ -122,6 +89,11 @@
else echo date("c", strtotime("23:59"));
?>" />
</div>
+ <div data-role="fieldcontain">
+ <label for="header">Header</label>
+ <input type="text" name="header" id="header" value="<?php echo $alert['header'];
+?>" />
+ </div>
<div data-role="fieldcontain">
<label for="description">Description</label>
<textarea name="description">
@@ -156,7 +128,7 @@
<form action="<?php echo basename(__FILE__) ;
?>" method="get">
<div data-role="fieldcontain">
- <label for="stopid">StopID</label>
+ <label for="stopid">StopID to remove</label>
<input type="text" name="stopid" />
</div>
<input type="hidden" name="stopsearch" value="<?php echo $_REQUEST['edit'];
@@ -166,24 +138,14 @@
<form action="<?php echo basename(__FILE__) ;
?>" method="get">
<div data-role="fieldcontain">
- <label for="street">Street</label>
+ <label for="street">Street to inform</label>
<input type="text" name="street" />
</div>
<input type="hidden" name="streetsearch" value="<?php echo $_REQUEST['edit'];
?>"/>
<input type="submit" value="Street Search"/>
</form>
- <form action="<?php echo basename(__FILE__) ;
- ?>" method="get">
- <div data-role="fieldcontain">
- <label for="routeid">routeID</label>
- <input type="text" name="routeid" />
- </div>
- <input type="hidden" name="routesearch" value="<?php echo $_REQUEST['edit'];
- ?>"/>
- <input type="submit" value="Route Search"/>
- </form>
-<?php
+ <?php
}
include_footer();
--- /dev/null
+++ b/labs/servicealerts_twitter/NameFinder.java
@@ -1,1 +1,56 @@
+InputStream modelIn = new FileInputStream("en-ner-person.bin");
+try {
+ TokenNameFinder model = new TokenNameFinderModel(modelIn);
+}
+catch (IOException e) {
+ e.printStackTrace();
+}
+finally {
+ if (modelIn != null) {
+ try {
+ modelIn.close();
+ }
+ catch (IOException e) {
+ }
+ }
+}
+
+NameFinderME nameFinder = new NameFinderME(model);
+
+for (String document[][] : documents) {
+
+ for (String[] sentence : document) {
+ Span nameSpans[] = find(sentence);
+ // do something with the names
+ }
+
+ nameFinder.clearAdaptiveData()
+}
+
+
+ InputStream in = getClass()
+ .getClassLoader()
+ .getResourceAsStream(
+ "opennlp/tools/namefind/AnnotatedSentences.txt");
+
+ String encoding = "ISO-8859-1";
+
+ ObjectStream<NameSample> sampleStream = new NameSampleDataStream(
+ new PlainTextByLineStream(new InputStreamReader(in,
+ encoding)));
+
+ TokenNameFinderModel nameFinderModel = NameFinderME.train("en",
+ "default", sampleStream, Collections
+ .<String, Object> emptyMap(), 70, 1);
+
+ TokenNameFinder nameFinder = new NameFinderME(nameFinderModel);
+
+ // now test if it can detect the sample sentences
+
+ String sentence[] = { "Alisa", "appreciated", "the", "hint",
+ "and", "enjoyed", "a", "delicious", "traditional",
+ "meal." };
+
+ Span names[] = nameFinder.find(sentence);
+
--- /dev/null
+++ b/labs/servicealerts_twitter/pom.xml
@@ -1,1 +1,19 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.lambdacomplex.bus</groupId>
+ <artifactId>servicealerts_twitter</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <dependencies>
+<dependency>
+ <groupId>org.apache.opennlp</groupId>
+ <artifactId>opennlp</artifactId>
+ <version>1.5.1-incubating</version>
+</dependency>
+<dependency>
+ <groupId>org.apache.opennlp</groupId>
+ <artifactId>opennlp-tools</artifactId>
+ <version>1.5.1-incubating</version>
+</dependency>
+ </dependencies>
+</project>
--- /dev/null
+++ b/lib/Protobuf-PHP/test-alert.php
@@ -1,1 +1,69 @@
+<?php
+include_once("library/DrSlump/Protobuf.php");
+include_once("library/DrSlump/Protobuf/Message.php");
+include_once("library/DrSlump/Protobuf/Registry.php");
+include_once("library/DrSlump/Protobuf/Descriptor.php");
+include_once("library/DrSlump/Protobuf/Field.php");
+include_once("gtfs-realtime.php");
+include_once("library/DrSlump/Protobuf/CodecInterface.php");
+include_once("library/DrSlump/Protobuf/Codec/PhpArray.php");
+include_once("library/DrSlump/Protobuf/Codec/Binary.php");
+include_once("library/DrSlump/Protobuf/Codec/Binary/Writer.php");
+include_once("library/DrSlump/Protobuf/Codec/Json.php");
+//print_r(get_declared_classes());
+$fm = new transit_realtime\FeedMessage();
+$fh = new transit_realtime\FeedHeader();
+$fh->setGtfsRealtimeVersion(1);
+$fh->setTimestamp(time());
+$fm->setHeader($fh);
+$fe = new transit_realtime\FeedEntity();
+ $fe->setId("1234");
+ $fe->setIsDeleted(false);
+ $alert = new transit_realtime\Alert();
+ $tr = new transit_realtime\TimeRange();
+ $tr->setStart(000);
+ $tr->setEnd(001);
+ $alert-> addActivePeriod($tr);
+ $es = new transit_realtime\EntitySelector();
+ $es->setAgencyId("0");
+ $es->setStopId("0");
+ $es->setRouteId("0");
+ $td = new transit_realtime\TripDescriptor();
+ $td->setTripId("0");
+ $es->setTrip($td);
+ $alert-> addInformedEntity($es);
+ $alert->setCause(constant("transit_realtime\Alert\Cause::"."UNKNOWN_CAUSE"));
+ $alert->setEffect(constant("transit_realtime\Alert\Effect::"."UNKNOWN_EFFECT"));
+ $tsUrl = new transit_realtime\TranslatedString();
+ $tUrl = new transit_realtime\TranslatedString\Translation();
+ $tUrl->setText("http");
+ $tUrl->setLanguage("en");
+ $tsUrl->addTranslation($tUrl);
+ $alert->setUrl($tsUrl);
+ $tsHeaderText= new transit_realtime\TranslatedString();
+ $tHeaderText = new transit_realtime\TranslatedString\Translation();
+ $tHeaderText->setText("http");
+ $tHeaderText->setLanguage("en");
+ $tsHeaderText->addTranslation($tHeaderText);
+ $alert->setHeaderText($tsHeaderText);
+ $tsDescriptionText= new transit_realtime\TranslatedString();
+ $tDescriptionText = new transit_realtime\TranslatedString\Translation();
+ $tDescriptionText->setText("http");
+ $tDescriptionText->setLanguage("en");
+ $tsDescriptionText->addTranslation($tDescriptionText);
+ $alert->setDescriptionText($tsDescriptionText);
+ $fe->setAlert($alert);
+$fm->addEntity($fe);
+//var_dump($fm);
+
+//$codec = new DrSlump\Protobuf\Codec\Binary();
+//echo $codec->encode($fm);
+
+//$codec = new DrSlump\Protobuf\Codec\Json();
+//echo $codec->encode($fm);
+
+$codec = new DrSlump\Protobuf\Codec\PhpArray();
+print_r($codec->encode($fm));
+
+?>
--- /dev/null
+++ b/lib/Protobuf-PHP/test-tripupdates.php
@@ -1,1 +1,44 @@
+ <?php
+include_once("library/DrSlump/Protobuf.php");
+include_once("library/DrSlump/Protobuf/Message.php");
+include_once("library/DrSlump/Protobuf/Registry.php");
+include_once("library/DrSlump/Protobuf/Descriptor.php");
+include_once("library/DrSlump/Protobuf/Field.php");
+include_once("gtfs-realtime.php");
+include_once("library/DrSlump/Protobuf/CodecInterface.php");
+include_once("library/DrSlump/Protobuf/Codec/PhpArray.php");
+include_once("library/DrSlump/Protobuf/Codec/Binary.php");
+include_once("library/DrSlump/Protobuf/Codec/Binary/Writer.php");
+include_once("library/DrSlump/Protobuf/Codec/Json.php");
+//print_r(get_declared_classes());
+$fm = new transit_realtime\FeedMessage();
+$fh = new transit_realtime\FeedHeader();
+$fh->setGtfsRealtimeVersion(1);
+$fh->setTimestamp(time());
+$fm->setHeader($fh);
+$fe = new transit_realtime\FeedEntity();
+ $fe->setId("1234");
+ $fe->setIsDeleted(false);
+ $tu = new transit_realtime\TripUpdate();
+ $td = new transit_realtime\TripDescriptor();
+ $td->setRouteId("0");
+ $tu->setTrip($td);
+ $stu = new transit_realtime\TripUpdate\StopTimeUpdate();
+ $stu->setStopId("1");
+ $stu->setScheduleRelationship(transit_realtime\TripUpdate\StopTimeUpdate\ScheduleRelationship::SKIPPED);
+ $tu->addStopTimeUpdate($stu);
+ $fe->setTripUpdate($tu);
+$fm->addEntity($fe);
+//var_dump($fm);
+
+//$codec = new DrSlump\Protobuf\Codec\Binary();
+//echo $codec->encode($fm);
+
+//$codec = new DrSlump\Protobuf\Codec\Json();
+//echo $codec->encode($fm);
+
+$codec = new DrSlump\Protobuf\Codec\PhpArray();
+print_r($codec->encode($fm));
+
+?>
--- a/lib/Protobuf-PHP/test.php
+++ /dev/null
@@ -1,65 +1,1 @@
-<?php
-include_once("library/DrSlump/Protobuf.php");
-include_once("library/DrSlump/Protobuf/Message.php");
-include_once("library/DrSlump/Protobuf/Registry.php");
-include_once("library/DrSlump/Protobuf/Descriptor.php");
-include_once("library/DrSlump/Protobuf/Field.php");
-include_once("gtfs-realtime.php");
-include_once("library/DrSlump/Protobuf/CodecInterface.php");
-include_once("library/DrSlump/Protobuf/Codec/PhpArray.php");
-include_once("library/DrSlu