From: Maxious Date: Tue, 23 Aug 2011 07:32:41 +0000 Subject: Add php protobuffer support for transition to GTFS-realtime X-Git-Url: https://maxious.lambdacomplex.org/git/?p=busui.git&a=commitdiff&h=f18f09fe95956498d8b75e51258b6400335d7894 --- Add php protobuffer support for transition to GTFS-realtime --- --- a/include/common-template.inc.php +++ b/include/common-template.inc.php @@ -159,8 +159,8 @@ if ($serviceAlertsEnabled) { $serviceAlerts = getServiceAlerts("network","network"); foreach ($serviceAlerts['entities'] as $entity) { - echo "
".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']))."
Warning: {$entity['alert']['description']['translation']} -
Source
"; + echo "
".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']}
Warning: {$entity['alert']['description_text']['translation']['text']} +
Source
"; } } } --- a/include/common-transit.inc.php +++ b/include/common-transit.inc.php @@ -45,6 +45,55 @@ return ""; } } + +$serviceAlertCause = Array( +UNKNOWN_CAUSE +OTHER_CAUSE +TECHNICAL_PROBLEM +STRIKE +DEMONSTRATION +ACCIDENT +HOLIDAY +WEATHER +MAINTENANCE +CONSTRUCTION +POLICE_ACTIVITY +MEDICAL_EMERGENCY + +Unknown cause +Other cause (not represented by any of these options) +Technical problem +Strike +Demonstration +Accident +Holiday +Weather +Maintenance +Construction +Police activity +Medical emergency +); +$serviceAlertEffect = Array( +NO_SERVICE +REDUCED_SERVICE +SIGNIFICANT_DELAYS +DETOUR +ADDITIONAL_SERVICE +MODIFIED_SERVICE +OTHER_EFFECT +UNKNOWN_EFFECT +STOP_MOVED + +No service +Reduced service +Significant delays (insignificant delays should only be provided through Trip updates). +Detour +Additional service +Modified service +Stop moved +Other effect (not represented by any of these options) +Unknown effect); + function getServiceAlerts($filter_class, $filter_id) { /* @@ -66,8 +115,9 @@ 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']); @@ -76,8 +126,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(); --- /dev/null +++ b/lib/Protobuf-PHP/LICENSE @@ -1,1 +1,21 @@ +The MIT License +Copyright (c) 2011 Iván -DrSlump- Montes + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. --- /dev/null +++ b/lib/Protobuf-PHP/README.md @@ -1,1 +1,198 @@ +Protobuf for PHP +================ +Protobuf for PHP is an implementation of Google's Protocol Buffers for the PHP +language, supporting its binary data serialization and including a `protoc` +plugin to generate PHP classes from .proto files. + +Great effort has been put into generating PHP files that include all sort of type +hints to aide IDE's with autocompletion. Therefore, it can not only be used to +communicate with Protocol Buffers services but also as a generation tool for +_data objects_ no matter what the final serialization is. + +For more information see the [included man pages](http://drslump.github.com/Protobuf-PHP/). + + +## Requirements + + - PHP 5.3 + - Pear's Console_CommandLine (for the protoc wrapper tool) + - Google's `protoc` compiler version 2.3 or above + - GMP or BC Math extensions ¹ + + ¹ Only needed for negative values in `int32`, `int64` or `fixed64` types. See + the _known issues_ section. + + +## Features + +### Working + + - Standard types (numbers, string, enums, messages, etc) + - Pluggable serialization backends (codecs) + - Standard Binary + - Standard TextFormat ¹ + - PhpArray + - JSON + - [ProtoJson](https://github.com/drslump/ProtoJson) (_TagMap_ and _Indexed_ variants) + - XML + - Protoc compiler plugin to generate the PHP classes + - Extensions + - Unknown fields + - Packed fields + - Reflection + - Dynamic messages with annotations support + - Generates service interfaces + - Includes comments from .proto files in the generated files + - Pear package for easy installation + +¹ Only serialization is supported + +### Future + + - Speed optimized code generation mode + - Support numbers beyond PHP's native limits + + + +## Example usage + + $person = new Tutorial\Person(); + $person->name = 'DrSlump'; + $person->setId(12); + + $book = new Tutorial\AddressBook(); + $book->addPerson($person); + + // Use default codec + $data = $book->serialize(); + + // Use custom codec + $codec = new \DrSlump\Protobuf\Codec\Binary(); + $data = $codec->encode($book); + // ... or ... + $data = $book->serialize($codec); + + +## Installation + +Install with Pear + + pear channel-discover pear.pollinimini.net + pear install drslump/Protobuf-beta + +You can also get the latest version by checking out a copy of the +repository in your computer. + + + +## Known issues + + +### Types + +PHP is very weak when dealing with numbers processing. Several work arounds have been applied +to the standard binary codec to reduce incompatibilities between Protobuf types and PHP ones. + + - Protobuf stores floating point values using the [IEEE 754](http://en.wikipedia.org/wiki/IEEE_754) standard + with 64bit words for the `double` and 32bit for the `float` types. PHP supports IEEE 754 natively although + the precission is platform dependant, however it typically supports 64bit doubles. It means that + if your PHP was compiled with 64bit sized doubles (or greater) you shouldn't have any problem encoding + and decoded float and double typed values with Protobuf. + + - Integer values are also [platform dependant in PHP](http://www.php.net/manual/en/language.types.integer.php). + The library has been developed and tested against PHP binaries compiled with 64bit integers. The encoding and + decoding algorithm should in theory work no matter if PHP uses 32bit or 64bit integers internally, just take + into account that with 32bit integers the numbers cannot exceed in any case the `PHP_INT_MAX` value (2147483647). + + While Protobuf supports unsigned integers PHP does not. In fact, numbers above the compiled PHP maximum + integer (`PHP_INT_MAX`, 0x7FFFFFFFFFFFFFFF for 64bits) will be automatically casted to doubles, which + typically will offer 53bits of decimal precission, allowing to safely work with numbers upto + 0x20000000000000 (2^53), even if they are represented in PHP as floats instead of integers. Higher numbers + will loose precission or might even return an _infinity_ value, note that the library does not include + any checking for these numbers and using them might provoke unexpected behaviour. + + Negative values when encoded as `int32`, `int64` or `fixed64` types require the big integer extensions + [GMP](http://www.php.net/gmp) or [BC Math](http://www.php.net/bc) (the later only for 64bit architectures) + to be available in your PHP environment. The reason is that when encoding these negative numbers without + using _zigzag_ the binary representation uses the most significant bit for the sign, thus the numbers become + above the maximum supported values in PHP. The library will check for these conditions and will automatically + try to use GMP or BC to process the value. + + +### Strings + +The binary codec expects strings to be encoded using UTF-8. PHP does not natively support string encodings, +PHP's string data type is basically a length delimited stream of bytes, so it's not trivial to include +automatic encoding conversion into the library encoding and decoding routines. Instead of trying to guess +or offer a configuration interface for the encoding, the binary codec will process the `string` type just as +it would process `byte` one, delegating on your application the task of encoding or decoding in the desired +character set. + +### Memory usage + +Large messages might be troublesome since the way the library is modelled does not allow to parse or +serialize messages as a streams, instead the whole operation is performed in memory, which allows for faster +processing but could consume too much RAM if messages are too large. + + +### Unknown fields + +Since wire types are different across different codec's formats, it's not possible to transcode unkwnon +fields consumed in one codec to another. This means, for example, that when consuming a message using the +binary codec, if it contains unknown fields, they won't be included when serializing the message using the +Json codec. + + +## Generating PHP classes + +The generation tool is designed to be run as a `protoc` plugin, thus it should +work with any proto file supported by the official compiler. + + protoc --plugin=protoc-gen-php --php_out=./build tutorial.proto + +To make use of non-standard options in your proto files (like `php.namespace`) you'll +have to import the `php.proto` file included with the library. It's location will +depend on where you've installed this library. + + protoc -I=./Protobuf-PHP/library/DrSlump/Protobuf/Compiler/protos \ + --plugin=protoc-gen-php --php_out=./build tutorial.proto + +In order to make your life easier, the supplied protoc plugin offers an additional +execution mode, where it acts as a wrapper for the `protoc` invocation. It will +automatically include the `php.proto` path so that you don't need to worry about it. + + protoc-gen-php -o ./build tutorial.proto + + +## LICENSE: + + The MIT License + + Copyright (c) 2011 Iván -DrSlump- Montes + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + 'Software'), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + + + + + + --- /dev/null +++ b/lib/Protobuf-PHP/Rakefile @@ -1,1 +1,120 @@ +# encoding: utf-8 +namespace :pear do + support_files = ['README.md', 'LICENSE', 'protoc-gen-php.php', 'protoc-gen-php.bat'] + tpl_file = 'package.pear' + xml_file = 'library/package.xml' + + desc "Generate package.xml" + task :xml => [:clean] do |t, args| + unless ENV['version'] then + puts 'Version number not given. Use "pear:xml version=1.0"' + exit 1 + end + + # Get template contents + text = File.read(tpl_file, :encoding => "UTF-8") + # Replace the version, date and time + text = text.gsub("{VERSION}", ENV['version']) + text = text.gsub('{DATE}', Time.now.strftime('%Y-%m-%d')) + text = text.gsub('{TIME}', Time.now.strftime('%H:%M:%S')) + + # Include source files + dirs = [] + Dir.glob('library/**/*.*') do |file| + file[0, 'library/'.length] = '' + dirs << '' + dirs << '' + dirs << '' + end + + text = text.gsub('{DIRS}', dirs.join("\n")) + + # Generate a new pear package.xml + xml = File.new(xml_file, 'w') + xml.syswrite(text); + xml.close(); + end + + desc "Build a release" + task :package => ['doc:build', :xml] do + + # Copy supporting files to the package root + + support_files.each do |file| + cp file, "library/#{file}" + end + + begin + sh "pear package -n #{xml_file}" + rescue Exception => e + puts "Rolling back..." + Rake::Task['pear:clean'].execute + raise + end + + Rake::Task['pear:clean'].execute + end + + desc "Clean up" + task :clean do + puts "Cleaning up..." + + # Remove package.xml + rm_f xml_file + + # Remove supporting files + support_files.each { |file| rm_f "library/#{file}" } + end + +end + +namespace :doc do + + desc "Generate manual" + task :build do + version = ENV['version'] + ENV['RONN_MANUAL'] = "Protobuf-PHP #{version}" + ENV['RONN_ORGANIZATION'] = "Ivan -DrSlump- Montes" + sh "ronn -w -s toc -r5 --markdown man/*.ronn" + end + + desc 'Publish to github pages' + task :github => 'doc:build' do + require 'git' + require 'logger' + + remote = `git remote show origin` + .split(%r{\n}) # Ruby 1.9 only has grep() on Array + .grep(/Push.*URL/) + .first[/git@.*/] + + files = [ + 'protoc-gen-php.1.html', + 'protobuf-php.3.html', + 'protobuf-php.5.html', + ] + + root = "/tmp/checkout-#{Time.now.to_i}" + g = Git.clone(remote, root, :log => Logger.new(STDOUT)) + + # Make sure this actually switches branches. + g.checkout(g.branch('gh-pages')) + + files.each {|file| + cp "man/#{file}", "#{root}/." + g.add(file) + } + + g.commit('Regenerating Github Pages.') + + # PUSH! + g.push(g.remote('origin'), g.branch('gh-pages')) + + puts '--> GitHub Pages Commit and Push successful.' + end + +end + + + --- /dev/null +++ b/lib/Protobuf-PHP/gtfs-realtime.php @@ -1,1 +1,3673 @@ - +number = 1; + $f->name = "header"; + $f->type = 11; + $f->rule = 2; + $f->reference = '\transit_realtime\FeedHeader'; + // @@protoc_insertion_point(scope_field) + // @@protoc_insertion_point(field_transit_realtime.FeedMessage:header) + $descriptor->addField($f); + + // repeated .transit_realtime.FeedEntity entity = 2 + $f = new \DrSlump\Protobuf\Field(); + $f->number = 2; + $f->name = "entity"; + $f->type = 11; + $f->rule = 3; + $f->reference = '\transit_realtime\FeedEntity'; + // @@protoc_insertion_point(scope_field) + // @@protoc_insertion_point(field_transit_realtime.FeedMessage:entity) + $descriptor->addField($f); + + foreach (self::$__extensions as $cb) { + $descriptor->addField($cb(), true); + } + + // @@protoc_insertion_point(scope_descriptor) + // @@protoc_insertion_point(descriptor_transit_realtime.FeedMessage) + + return $descriptor; + } + + /** @var \transit_realtime\FeedHeader */ + public $header = null; + + /** @var \transit_realtime\FeedEntity[] */ + public $entity = array(); + + + /** + * Check if
has a value + * + * @return boolean + */ + public function hasHeader(){ + return $this->_has(1); + } + + /** + * Clear
value + * + * @return \transit_realtime\FeedMessage + */ + public function clearHeader(){ + return $this->_clear(1); + } + + /** + * Get
value + * + * @return \transit_realtime\FeedHeader + */ + public function getHeader(){ + return $this->_get(1); + } + + /** + * Set
value + * + * @param \transit_realtime\FeedHeader $value + * @return \transit_realtime\FeedMessage + */ + public function setHeader(\transit_realtime\FeedHeader $value){ + return $this->_set(1, $value); + } + + /** + * Check if has a value + * + * @return boolean + */ + public function hasEntity(){ + return $this->_has(2); + } + + /** + * Clear value + * + * @return \transit_realtime\FeedMessage + */ + public function clearEntity(){ + return $this->_clear(2); + } + + /** + * Get value + * + * @param int $idx + * @return \transit_realtime\FeedEntity + */ + public function getEntity($idx = NULL){ + return $this->_get(2, $idx); + } + + /** + * Set value + * + * @param \transit_realtime\FeedEntity $value + * @return \transit_realtime\FeedMessage + */ + public function setEntity(\transit_realtime\FeedEntity $value, $idx = NULL){ + return $this->_set(2, $value, $idx); + } + + /** + * Get all elements of + * + * @return \transit_realtime\FeedEntity[] + */ + public function getEntityList(){ + return $this->_get(2); + } + + /** + * Add a new element to + * + * @param \transit_realtime\FeedEntity $value + * @return \transit_realtime\FeedMessage + */ + public function addEntity(\transit_realtime\FeedEntity $value){ + return $this->_add(2, $value); + } + + + // @@protoc_insertion_point(scope_class) + // @@protoc_insertion_point(class_transit_realtime.FeedMessage) + } +} + +namespace transit_realtime\FeedHeader { + + // @@protoc_insertion_point(scope_namespace) + // @@protoc_insertion_point(namespace_transit_realtime.FeedHeader) + + class Incrementality { + const FULL_DATASET = 0; + const DIFFERENTIAL = 1; + + // @@protoc_insertion_point(scope_class) + // @@protoc_insertion_point(class_transit_realtime.FeedHeader.Incrementality) + } +} +namespace transit_realtime { + + // @@protoc_insertion_point(scope_namespace) + // @@protoc_insertion_point(namespace_transit_realtime) + + class FeedHeader extends \DrSlump\Protobuf\Message { + + /** @var \Closure[] */ + protected static $__extensions = array(); + + public static function descriptor() + { + $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'transit_realtime.FeedHeader'); + + // required gtfs_realtime_version = 1 + $f = new \DrSlump\Protobuf\Field(); + $f->number = 1; + $f->name = "gtfs_realtime_version"; + $f->type = 9; + $f->rule = 2; + // @@protoc_insertion_point(scope_field) + // @@protoc_insertion_point(field_transit_realtime.FeedHeader:gtfs_realtime_version) + $descriptor->addField($f); + + // optional .transit_realtime.FeedHeader.Incrementality incrementality = 2 + $f = new \DrSlump\Protobuf\Field(); + $f->number = 2; + $f->name = "incrementality"; + $f->type = 14; + $f->rule = 1; + $f->reference = '\transit_realtime\FeedHeader\Incrementality'; + $f->default = \transit_realtime\FeedHeader\Incrementality::FULL_DATASET; + // @@protoc_insertion_point(scope_field) + // @@protoc_insertion_point(field_transit_realtime.FeedHeader:incrementality) + $descriptor->addField($f); + + // optional timestamp = 3 + $f = new \DrSlump\Protobuf\Field(); + $f->number = 3; + $f->name = "timestamp"; + $f->type = 4; + $f->rule = 1; + // @@protoc_insertion_point(scope_field) + // @@protoc_insertion_point(field_transit_realtime.FeedHeader:timestamp) + $descriptor->addField($f); + + foreach (self::$__extensions as $cb) { + $descriptor->addField($cb(), true); + } + + // @@protoc_insertion_point(scope_descriptor) + // @@protoc_insertion_point(descriptor_transit_realtime.FeedHeader) + + return $descriptor; + } + + /** @var string */ + public $gtfs_realtime_version = null; + + /** @var int - \transit_realtime\FeedHeader\Incrementality */ + public $incrementality = \transit_realtime\FeedHeader\Incrementality::FULL_DATASET; + + /** @var int */ + public $timestamp = null; + + + /** + * Check if has a value + * + * @return boolean + */ + public function hasGtfsRealtimeVersion(){ + return $this->_has(1); + } + + /** + * Clear value + * + * @return \transit_realtime\FeedHeader + */ + public function clearGtfsRealtimeVersion(){ + return $this->_clear(1); + } + + /** + * Get value + * + * @return string + */ + public function getGtfsRealtimeVersion(){ + return $this->_get(1); + } + + /** + * Set value + * + * @param string $value + * @return \transit_realtime\FeedHeader + */ + public function setGtfsRealtimeVersion( $value){ + return $this->_set(1, $value); + } + + /** + * Check if has a value + * + * @return boolean + */ + public function hasIncrementality(){ + return $this->_has(2); + } + + /** + * Clear value + * + * @return \transit_realtime\FeedHeader + */ + public function clearIncrementality(){ + return $this->_clear(2); + } + + /** + * Get value + * + * @return int - \transit_realtime\FeedHeader\Incrementality + */ + public function getIncrementality(){ + return $this->_get(2); + } + + /** + * Set value + * + * @param int - \transit_realtime\FeedHeader\Incrementality $value + * @return \transit_realtime\FeedHeader + */ + public function setIncrementality( $value){ + return $this->_set(2, $value); + } + + /** + * Check if has a value + * + * @return boolean + */ + public function hasTimestamp(){ + return $this->_has(3); + } + + /** + * Clear value + * + * @return \transit_realtime\FeedHeader + */ + public function clearTimestamp(){ + return $this->_clear(3); + } + + /** + * Get value + * + * @return int + */ + public function getTimestamp(){ + return $this->_get(3); + } + + /** + * Set value + * + * @param int $value + * @return \transit_realtime\FeedHeader + */ + public function setTimestamp( $value){ + return $this->_set(3, $value); + } + + + // @@protoc_insertion_point(scope_class) + // @@protoc_insertion_point(class_transit_realtime.FeedHeader) + } +} + +namespace transit_realtime { + + // @@protoc_insertion_point(scope_namespace) + // @@protoc_insertion_point(namespace_transit_realtime) + + class FeedEntity extends \DrSlump\Protobuf\Message { + + /** @var \Closure[] */ + protected static $__extensions = array(); + + public static function descriptor() + { + $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'transit_realtime.FeedEntity'); + + // required id = 1 + $f = new \DrSlump\Protobuf\Field(); + $f->number = 1; + $f->name = "id"; + $f->type = 9; + $f->rule = 2; + // @@protoc_insertion_point(scope_field) + // @@protoc_insertion_point(field_transit_realtime.FeedEntity:id) + $descriptor->addField($f); + + // optional is_deleted = 2 + $f = new \DrSlump\Protobuf\Field(); + $f->number = 2; + $f->name = "is_deleted"; + $f->type = 8; + $f->rule = 1; + $f->default = false; + // @@protoc_insertion_point(scope_field) + // @@protoc_insertion_point(field_transit_realtime.FeedEntity:is_deleted) + $descriptor->addField($f); + + // optional .transit_realtime.TripUpdate trip_update = 3 + $f = new \DrSlump\Protobuf\Field(); + $f->number = 3; + $f->name = "trip_update"; + $f->type = 11; + $f->rule = 1; + $f->reference = '\transit_realtime\TripUpdate'; + // @@protoc_insertion_point(scope_field) + // @@protoc_insertion_point(field_transit_realtime.FeedEntity:trip_update) + $descriptor->addField($f); + + // optional .transit_realtime.VehiclePosition vehicle = 4 + $f = new \DrSlump\Protobuf\Field(); + $f->number = 4; + $f->name = "vehicle"; + $f->type = 11; + $f->rule = 1; + $f->reference = '\transit_realtime\VehiclePosition'; + // @@protoc_insertion_point(scope_field) + // @@protoc_insertion_point(field_transit_realtime.FeedEntity:vehicle) + $descriptor->addField($f); + + // optional .transit_realtime.Alert alert = 5 + $f = new \DrSlump\Protobuf\Field(); + $f->number = 5; + $f->name = "alert"; + $f->type = 11; + $f->rule = 1; + $f->reference = '\transit_realtime\Alert'; + // @@protoc_insertion_point(scope_field) + // @@protoc_insertion_point(field_transit_realtime.FeedEntity:alert) + $descriptor->addField($f); + + foreach (self::$__extensions as $cb) { + $descriptor->addField($cb(), true); + } + + // @@protoc_insertion_point(scope_descriptor) + // @@protoc_insertion_point(descriptor_transit_realtime.FeedEntity) + + return $descriptor; + } + + /** @var string */ + public $id = null; + + /** @var boolean */ + public $is_deleted = true; + + /** @var \transit_realtime\TripUpdate */ + public $trip_update = null; + + /** @var \transit_realtime\VehiclePosition */ + public $vehicle = null; + + /** @var \transit_realtime\Alert */ + public $alert = null; + + + /** + * Check if has a value + * + * @return boolean + */ + public function hasId(){ + return $this->_has(1); + } + + /** + * Clear value + * + * @return \transit_realtime\FeedEntity + */ + public function clearId(){ + return $this->_clear(1); + } + + /** + * Get value + * + * @return string + */ + public function getId(){ + return $this->_get(1); + } + + /** + * Set value + * + * @param string $value + * @return \transit_realtime\FeedEntity + */ + public function setId( $value){ + return $this->_set(1, $value); + } + + /** + * Check if has a value + * + * @return boolean + */ + public function hasIsDeleted(){ + return $this->_has(2); + } + + /** + * Clear value + * + * @return \transit_realtime\FeedEntity + */ + public function clearIsDeleted(){ + return $this->_clear(2); + } + + /** + * Get value + * + * @return boolean + */ + public function getIsDeleted(){ + return $this->_get(2); + } + + /** + * Set value + * + * @param boolean $value + * @return \transit_realtime\FeedEntity + */ + public function setIsDeleted( $value){ + return $this->_set(2, $value); + } + + /** + * Check if has a value + * + * @return boolean + */ + public function hasTripUpdate(){ + return $this->_has(3); + } + + /** + * Clear value + * + * @return \transit_realtime\FeedEntity + */ + public function clearTripUpdate(){ + return $this->_clear(3); + } + + /** + * Get value + * + * @return \transit_realtime\TripUpdate + */ + public function getTripUpdate(){ + return $this->_get(3); + } + + /** + * Set value + * + * @param \transit_realtime\TripUpdate $value + * @return \transit_realtime\FeedEntity + */ + public function setTripUpdate(\transit_realtime\TripUpdate $value){ + return $this->_set(3, $value); + } + + /** + * Check if has a value + * + * @return boolean + */ + public function hasVehicle(){ + return $this->_has(4); + } + + /** + * Clear value + * + * @return \transit_realtime\FeedEntity + */ + public function clearVehicle(){ + return $this->_clear(4); + } + + /** + * Get value + * + * @return \transit_realtime\VehiclePosition + */ + public function getVehicle(){ + return $this->_get(4); + } + + /** + * Set value + * + * @param \transit_realtime\VehiclePosition $value + * @return \transit_realtime\FeedEntity + */ + public function setVehicle(\transit_realtime\VehiclePosition $value){ + return $this->_set(4, $value); + } + + /** + * Check if has a value + * + * @return boolean + */ + public function hasAlert(){ + return $this->_has(5); + } + + /** + * Clear value + * + * @return \transit_realtime\FeedEntity + */ + public function clearAlert(){ + return $this->_clear(5); + } + + /** + * Get value + * + * @return \transit_realtime\Alert + */ + public function getAlert(){ + return $this->_get(5); + } + + /** + * Set value + * + * @param \transit_realtime\Alert $value + * @return \transit_realtime\FeedEntity + */ + public function setAlert(\transit_realtime\Alert $value){ + return $this->_set(5, $value); + } + + + // @@protoc_insertion_point(scope_class) + // @@protoc_insertion_point(class_transit_realtime.FeedEntity) + } +} + +namespace transit_realtime\TripUpdate { + + // @@protoc_insertion_point(scope_namespace) + // @@protoc_insertion_point(namespace_transit_realtime.TripUpdate) + + class StopTimeEvent extends \DrSlump\Protobuf\Message { + + /** @var \Closure[] */ + protected static $__extensions = array(); + + public static function descriptor() + { + $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'transit_realtime.TripUpdate.StopTimeEvent'); + + // optional delay = 1 + $f = new \DrSlump\Protobuf\Field(); + $f->number = 1; + $f->name = "delay"; + $f->type = 5; + $f->rule = 1; + // @@protoc_insertion_point(scope_field) + // @@protoc_insertion_point(field_transit_realtime.TripUpdate.StopTimeEvent:delay) + $descriptor->addField($f); + + // optional time = 2 + $f = new \DrSlump\Protobuf\Field(); + $f->number = 2; + $f->name = "time"; + $f->type = 3; + $f->rule = 1; + // @@protoc_insertion_point(scope_field) + // @@protoc_insertion_point(field_transit_realtime.TripUpdate.StopTimeEvent:time) + $descriptor->addField($f); + + // optional uncertainty = 3 + $f = new \DrSlump\Protobuf\Field(); + $f->number = 3; + $f->name = "uncertainty"; + $f->type = 5; + $f->rule = 1; + // @@protoc_insertion_point(scope_field) + // @@protoc_insertion_point(field_transit_realtime.TripUpdate.StopTimeEvent:uncertainty) + $descriptor->addField($f); + + foreach (self::$__extensions as $cb) { + $descriptor->addField($cb(), true); + } + + // @@protoc_insertion_point(scope_descriptor) + // @@protoc_insertion_point(descriptor_transit_realtime.TripUpdate.StopTimeEvent) + + return $descriptor; + } + + /** @var int */ + public $delay = null; + + /** @var int */ + public $time = null; + + /** @var int */ + public $uncertainty = null; + + + /** + * Check if has a value + * + * @return boolean + */ + public function hasDelay(){ + return $this->_has(1); + } + + /** + * Clear value + * + * @return \transit_realtime\TripUpdate\StopTimeEvent + */ + public function clearDelay(){ + return $this->_clear(1); + } + + /** + * Get value + * + * @return int + */ + public function getDelay(){ + return $this->_get(1); + } + + /** + * Set value + * + * @param int $value + * @return \transit_realtime\TripUpdate\StopTimeEvent + */ + public function setDelay( $value){ + return $this->_set(1, $value); + } + + /** + * Check if