diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..64e7cf6 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,3 @@ +github: dacoto +buy_me_a_coffee: dacoto +custom: ["https://www.paypal.com/donate/?hosted_button_id=SGZ2VZ52ZD378"] diff --git a/.github/workflows/generate.yml b/.github/workflows/generate.yml new file mode 100644 index 0000000..f21d559 --- /dev/null +++ b/.github/workflows/generate.yml @@ -0,0 +1,68 @@ +name: Regenerate PHP Classes + +on: + # Run manually from the Actions tab + workflow_dispatch: + inputs: + protoc_version: + description: 'Override protoc version (e.g. 34.1). Leave empty to derive from composer.json.' + required: false + default: '' + + # Run automatically when the google/protobuf version in composer.json changes + push: + branches: + - main + paths: + - 'composer.json' + - 'gtfs-realtime.proto' + +jobs: + generate: + name: Generate PHP classes from proto + runs-on: ubuntu-latest + + permissions: + contents: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.4' + tools: composer + + - name: Install Composer dependencies + run: composer install --no-interaction --prefer-dist + + - name: Run generation script + run: | + chmod +x bin/generate.sh + if [[ -n "${{ github.event.inputs.protoc_version }}" ]]; then + bash bin/generate.sh --protoc-version "${{ github.event.inputs.protoc_version }}" + else + bash bin/generate.sh + fi + + - name: Check for changes + id: changes + run: | + if git diff --quiet && git diff --cached --quiet; then + echo "changed=false" >> "$GITHUB_OUTPUT" + else + echo "changed=true" >> "$GITHUB_OUTPUT" + fi + + - name: Commit and push regenerated files + if: steps.changes.outputs.changed == 'true' + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git add src/ + # Include the version of protoc used in the commit message + PROTOC_VERSION=$(grep -oP '"google/protobuf":\s*"\K[^"]+' composer.json || echo "unknown") + git commit -m "chore: regenerate PHP classes (google/protobuf ${PROTOC_VERSION})" + git push diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..d664331 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,42 @@ +name: Tests + +on: + push: + branches: + - master + - main + pull_request: + branches: + - master + - main + +jobs: + tests: + name: PHPUnit (PHP ${{ matrix.php }}) + runs-on: ubuntu-latest + + permissions: + contents: read + + strategy: + fail-fast: false + matrix: + php: + - '8.4' + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up PHP ${{ matrix.php }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + tools: composer + coverage: none + + - name: Install Composer dependencies + run: composer install --no-interaction --prefer-dist --no-progress + + - name: Run PHPUnit tests + run: vendor/bin/phpunit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9673080 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +vendor/ +composer.lock +examples/feed.pb +.phpunit.result.cache diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..7011cb1 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 dacoto + +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. diff --git a/README.md b/README.md index c889c8c..d52fe62 100644 --- a/README.md +++ b/README.md @@ -1 +1,147 @@ -# gtfs-rt-php \ No newline at end of file +# gtfs-rt-php + +GTFS-Realtime library for PHP 8.4+ based on Google's [Protocol Buffers](https://github.com/protocolbuffers/protobuf) v5. + +A modern PHP implementation of the [GTFS Realtime](https://gtfs.org/documentation/realtime/reference/) specification. +The proto definition was downloaded from [gtfs.org](https://gtfs.org/documentation/realtime/gtfs-realtime.proto) and converted to proto3 syntax for compatibility with the latest `google/protobuf` PHP library. + +## Requirements + +- PHP >= 8.4 +- [google/protobuf](https://packagist.org/packages/google/protobuf) ^5.34 + +## Installation + +```bash +composer require dacoto/gtfs-rt-php +``` + +## Usage + +### Creating a Feed Message + +```php +use Google\Transit\Realtime\FeedMessage; +use Google\Transit\Realtime\FeedHeader; +use Google\Transit\Realtime\FeedHeader\Incrementality; +use Google\Transit\Realtime\FeedEntity; +use Google\Transit\Realtime\TripUpdate; +use Google\Transit\Realtime\TripUpdate\StopTimeUpdate; +use Google\Transit\Realtime\TripUpdate\StopTimeEvent; +use Google\Transit\Realtime\TripDescriptor; + +$feedMessage = new FeedMessage(); + +$header = new FeedHeader(); +$header->setGtfsRealtimeVersion('2.0'); +$header->setIncrementality(Incrementality::FULL_DATASET); +$header->setTimestamp(time()); +$feedMessage->setHeader($header); + +$entity = new FeedEntity(); +$entity->setId('entity-1'); + +$tripDescriptor = new TripDescriptor(); +$tripDescriptor->setTripId('trip-123'); +$tripDescriptor->setRouteId('route-42'); + +$arrivalEvent = new StopTimeEvent(); +$arrivalEvent->setDelay(120); // 2 minutes late + +$stopTimeUpdate = new StopTimeUpdate(); +$stopTimeUpdate->setStopSequence(1); +$stopTimeUpdate->setStopId('stop-A'); +$stopTimeUpdate->setArrival($arrivalEvent); + +$tripUpdate = new TripUpdate(); +$tripUpdate->setTrip($tripDescriptor); +$tripUpdate->setStopTimeUpdate([$stopTimeUpdate]); + +$entity->setTripUpdate($tripUpdate); +$feedMessage->setEntity([$entity]); + +// Serialize to binary protobuf +$binaryData = $feedMessage->serializeToString(); +``` + +### Parsing a Feed Message + +```php +use Google\Transit\Realtime\FeedMessage; + +$binaryData = file_get_contents('https://your-agency.com/gtfs-rt/tripupdates.pb'); + +$feedMessage = new FeedMessage(); +$feedMessage->mergeFromString($binaryData); + +echo "GTFS-RT version: " . $feedMessage->getHeader()->getGtfsRealtimeVersion() . PHP_EOL; + +foreach ($feedMessage->getEntity() as $entity) { + if ($entity->hasTripUpdate()) { + $tripUpdate = $entity->getTripUpdate(); + echo "Trip ID: " . $tripUpdate->getTrip()->getTripId() . PHP_EOL; + + foreach ($tripUpdate->getStopTimeUpdate() as $stu) { + if ($stu->hasArrival()) { + echo " Stop " . $stu->getStopId() . " delay: " . $stu->getArrival()->getDelay() . "s" . PHP_EOL; + } + } + } +} +``` + +See full examples in the [examples/](examples/) directory. + +## Proto3 Conversion Notes + +The official GTFS Realtime proto uses `proto2` syntax. This library converts it to `proto3` to be compatible with the latest `google/protobuf` PHP library. The key changes are: + +1. Changed `syntax = "proto2"` to `syntax = "proto3"` +2. Removed all `optional` and `required` field labels (all fields are optional in proto3) +3. Removed all `extensions` ranges (not supported in proto3) +4. Removed all explicit `[default = ...]` values +5. Added `UNKNOWN_CAUSE = 0`, `NO_SERVICE = 0`, and `UNKNOWN_SEVERITY = 0` as first enum values (proto3 requires first value to be 0) +6. Added PHP namespace options: `php_namespace` and `php_metadata_namespace` + +## Running Tests + +```bash +composer install +vendor/bin/phpunit +``` + +## Regenerating PHP Classes + +The PHP classes in `src/` are generated automatically from `gtfs-realtime.proto` using `protoc`. + +### Automatic (GitHub Actions) + +Every time `composer.json` or `gtfs-realtime.proto` is changed on `main`, the +[Regenerate PHP Classes](.github/workflows/generate.yml) workflow runs automatically, +downloads the correct `protoc` binary, regenerates all PHP classes, and commits the result. + +You can also trigger it manually from the **Actions** tab, optionally overriding the `protoc` version. + +### Manual (local) + +Run the generation script — it resolves the `protoc` version from `composer.json` (or `composer.lock`) automatically: + +```bash +bash bin/generate.sh +``` + +Or override the protoc version explicitly: + +```bash +bash bin/generate.sh --protoc-version 34.1 +``` + +The script: +1. Reads the `google/protobuf` version from `composer.lock` (or `composer.json`) +2. Derives the matching `protoc` release (e.g. PHP `v5.34.1` → `protoc v34.1`) +3. Downloads the `protoc` binary from [github.com/protocolbuffers/protobuf](https://github.com/protocolbuffers/protobuf/releases) +4. Regenerates all PHP classes in `src/` from `gtfs-realtime.proto` + +## License + +MIT — See [LICENSE](LICENSE) \ No newline at end of file diff --git a/bin/generate.sh b/bin/generate.sh new file mode 100755 index 0000000..e4ca4f7 --- /dev/null +++ b/bin/generate.sh @@ -0,0 +1,171 @@ +#!/usr/bin/env bash +# generate.sh — Regenerate PHP classes from gtfs-realtime.proto +# +# This script: +# 1. Reads the google/protobuf version from composer.lock (or composer.json) +# 2. Derives the matching protoc version using the unified versioning scheme: +# PHP v{ERA}.{PROTOC_MAJOR}.{PROTOC_MINOR} → protoc v{PROTOC_MAJOR}.{PROTOC_MINOR} +# e.g. google/protobuf v5.34.1 → protoc v34.1 +# 3. Downloads the protoc binary from the protocolbuffers/protobuf GitHub releases +# 4. Regenerates all PHP classes in src/ from gtfs-realtime.proto +# +# Usage: +# ./bin/generate.sh [--protoc-version ] +# +# Options: +# --protoc-version Override the protoc version to use (e.g. 34.1) + +set -euo pipefail + +REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" + +# ────────────────────────────────────────────────────────────────────────────── +# 1. Resolve the protoc version +# ────────────────────────────────────────────────────────────────────────────── +PROTOC_VERSION_OVERRIDE="" + +while [[ $# -gt 0 ]]; do + case "$1" in + --protoc-version) + PROTOC_VERSION_OVERRIDE="$2" + shift 2 + ;; + *) + echo "Unknown argument: $1" >&2 + exit 1 + ;; + esac +done + +if [[ -n "$PROTOC_VERSION_OVERRIDE" ]]; then + PROTOC_VERSION="$PROTOC_VERSION_OVERRIDE" +else + # Determine the exact google/protobuf version: + # 1. Read from composer.lock (most accurate — uses the installed version) + # 2. Fall back to the constraint in composer.json + PHP_PROTOBUF_VERSION="" + + if [[ -f "${REPO_ROOT}/composer.lock" ]]; then + PHP_PROTOBUF_VERSION="$( + python3 -c " +import json +with open('${REPO_ROOT}/composer.lock') as f: + lock = json.load(f) +for pkg in lock.get('packages', []) + lock.get('packages-dev', []): + if pkg['name'] == 'google/protobuf': + print(pkg['version'].lstrip('v')) + break +" 2>/dev/null + )" + fi + + if [[ -z "$PHP_PROTOBUF_VERSION" ]]; then + PHP_PROTOBUF_VERSION="$( + python3 -c " +import json, re +with open('${REPO_ROOT}/composer.json') as f: + data = json.load(f) +constraint = data['require']['google/protobuf'] +# Strip leading ^ ~ >= < v and whitespace, take first segment +version = re.sub(r'^[\^~>=&2 + exit 1 + ;; + esac + ;; + Darwin) + case "$ARCH" in + x86_64) PROTOC_OS_ARCH="osx-x86_64" ;; + arm64) PROTOC_OS_ARCH="osx-aarch_64" ;; + *) PROTOC_OS_ARCH="osx-universal_binary" ;; + esac + ;; + *) + echo "Unsupported OS: $OS" >&2 + exit 1 + ;; +esac + +PROTOC_ZIP="protoc-${PROTOC_VERSION}-${PROTOC_OS_ARCH}.zip" +PROTOC_URL="https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/${PROTOC_ZIP}" + +# ────────────────────────────────────────────────────────────────────────────── +# 3. Download and extract protoc +# ────────────────────────────────────────────────────────────────────────────── +WORK_DIR="$(mktemp -d)" +trap 'rm -rf "$WORK_DIR"' EXIT + +echo "→ Downloading ${PROTOC_URL}" +curl -sL -o "${WORK_DIR}/${PROTOC_ZIP}" "$PROTOC_URL" + +unzip -q "${WORK_DIR}/${PROTOC_ZIP}" -d "${WORK_DIR}/protoc" +PROTOC="${WORK_DIR}/protoc/bin/protoc" +chmod +x "$PROTOC" + +echo "→ protoc $("$PROTOC" --version)" + +# ────────────────────────────────────────────────────────────────────────────── +# 4. Generate PHP classes +# ────────────────────────────────────────────────────────────────────────────── +PROTO_FILE="${REPO_ROOT}/gtfs-realtime.proto" +OUT_DIR="${WORK_DIR}/php-out" +mkdir -p "$OUT_DIR" + +echo "→ Generating PHP classes from $(basename "$PROTO_FILE")" +"$PROTOC" \ + --php_out="$OUT_DIR" \ + -I "$(dirname "$PROTO_FILE")" \ + "$PROTO_FILE" + +# ────────────────────────────────────────────────────────────────────────────── +# 5. Replace the generated files in src/ +# ────────────────────────────────────────────────────────────────────────────── +SRC_DIR="${REPO_ROOT}/src" + +echo "→ Replacing generated files in ${SRC_DIR}" + +# Remove old generated files +rm -rf "${SRC_DIR:?}/GPBMetadata" "${SRC_DIR:?}/Google" + +# Copy new generated files +cp -r "${OUT_DIR}/." "${SRC_DIR}/" + +echo "✓ PHP classes successfully regenerated in src/" +echo " Generated files:" +find "${SRC_DIR}" -name "*.php" | sort | sed "s|${REPO_ROOT}/||" diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..860a153 --- /dev/null +++ b/composer.json @@ -0,0 +1,25 @@ +{ + "name": "dacoto/gtfs-rt-php", + "type": "library", + "description": "GTFS-Realtime library for PHP 8.4+ based on Google Protocol Buffers v5", + "keywords": ["gtfs", "gtfs-realtime", "protobuf", "transit"], + "license": "MIT", + "require": { + "php": ">=8.4", + "google/protobuf": "^5.34" + }, + "require-dev": { + "phpunit/phpunit": "^11.0" + }, + "autoload": { + "psr-4": { + "Google\\Transit\\Realtime\\": "src/Google/Transit/Realtime", + "GPBMetadata\\": "src/GPBMetadata" + } + }, + "autoload-dev": { + "psr-4": { + "Tests\\": "tests/" + } + } +} diff --git a/examples/create_message.php b/examples/create_message.php new file mode 100644 index 0000000..067faff --- /dev/null +++ b/examples/create_message.php @@ -0,0 +1,76 @@ +setGtfsRealtimeVersion('2.0'); +$header->setIncrementality(Incrementality::FULL_DATASET); +$header->setTimestamp(time()); +$feedMessage->setHeader($header); + +// Create a feed entity with a trip update +$entity = new FeedEntity(); +$entity->setId('entity-1'); + +// Create a trip descriptor +$tripDescriptor = new TripDescriptor(); +$tripDescriptor->setTripId('trip-123'); +$tripDescriptor->setRouteId('route-42'); +$tripDescriptor->setStartDate('20260328'); + +// Create a trip update +$tripUpdate = new TripUpdate(); +$tripUpdate->setTrip($tripDescriptor); +$tripUpdate->setTimestamp(time()); + +// Add stop time updates +$arrivalEvent = new StopTimeEvent(); +$arrivalEvent->setDelay(120); // 2 minutes late + +$departureEvent = new StopTimeEvent(); +$departureEvent->setDelay(120); + +$stopTimeUpdate = new StopTimeUpdate(); +$stopTimeUpdate->setStopSequence(1); +$stopTimeUpdate->setStopId('stop-A'); +$stopTimeUpdate->setArrival($arrivalEvent); +$stopTimeUpdate->setDeparture($departureEvent); + +$tripUpdate->setStopTimeUpdate([$stopTimeUpdate]); +$entity->setTripUpdate($tripUpdate); + +// Add entity to the feed message +$feedMessage->setEntity([$entity]); + +// Serialize to binary protobuf +$binaryData = $feedMessage->serializeToString(); + +echo "Feed message created successfully." . PHP_EOL; +echo "Binary size: " . strlen($binaryData) . " bytes" . PHP_EOL; +echo "Number of entities: " . count($feedMessage->getEntity()) . PHP_EOL; +echo "GTFS-RT version: " . $feedMessage->getHeader()->getGtfsRealtimeVersion() . PHP_EOL; +echo "Trip ID: " . $feedMessage->getEntity()[0]->getTripUpdate()->getTrip()->getTripId() . PHP_EOL; +echo "Arrival delay: " . $feedMessage->getEntity()[0]->getTripUpdate()->getStopTimeUpdate()[0]->getArrival()->getDelay() . " seconds" . PHP_EOL; + +// Save to file for use in parse_message.php example +file_put_contents(__DIR__ . '/feed.pb', $binaryData); +echo "Binary feed saved to examples/feed.pb" . PHP_EOL; diff --git a/examples/parse_message.php b/examples/parse_message.php new file mode 100644 index 0000000..6860220 --- /dev/null +++ b/examples/parse_message.php @@ -0,0 +1,70 @@ +mergeFromString($binaryData); + +echo "Feed message parsed successfully." . PHP_EOL; +echo "GTFS-RT version: " . $feedMessage->getHeader()->getGtfsRealtimeVersion() . PHP_EOL; +echo "Timestamp: " . $feedMessage->getHeader()->getTimestamp() . PHP_EOL; +echo "Number of entities: " . count($feedMessage->getEntity()) . PHP_EOL; + +foreach ($feedMessage->getEntity() as $entity) { + echo PHP_EOL . "Entity ID: " . $entity->getId() . PHP_EOL; + + if ($entity->hasTripUpdate()) { + $tripUpdate = $entity->getTripUpdate(); + echo " Trip ID: " . $tripUpdate->getTrip()->getTripId() . PHP_EOL; + echo " Route ID: " . $tripUpdate->getTrip()->getRouteId() . PHP_EOL; + + foreach ($tripUpdate->getStopTimeUpdate() as $stu) { + echo " Stop: " . $stu->getStopId() . " (seq " . $stu->getStopSequence() . ")" . PHP_EOL; + if ($stu->hasArrival()) { + echo " Arrival delay: " . $stu->getArrival()->getDelay() . "s" . PHP_EOL; + } + if ($stu->hasDeparture()) { + echo " Departure delay: " . $stu->getDeparture()->getDelay() . "s" . PHP_EOL; + } + } + } + + if ($entity->hasVehicle()) { + $vehicle = $entity->getVehicle(); + echo " Vehicle ID: " . $vehicle->getVehicle()->getId() . PHP_EOL; + if ($vehicle->hasPosition()) { + echo " Position: lat=" . $vehicle->getPosition()->getLatitude() + . " lon=" . $vehicle->getPosition()->getLongitude() . PHP_EOL; + } + } + + if ($entity->hasAlert()) { + $alert = $entity->getAlert(); + if ($alert->hasHeaderText()) { + foreach ($alert->getHeaderText()->getTranslation() as $translation) { + echo " Alert header [" . $translation->getLanguage() . "]: " . $translation->getText() . PHP_EOL; + } + } + } +} diff --git a/gtfs-realtime.proto b/gtfs-realtime.proto new file mode 100644 index 0000000..f7a6881 --- /dev/null +++ b/gtfs-realtime.proto @@ -0,0 +1,403 @@ +// Copyright 2015 The GTFS Specifications Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Protocol definition file for GTFS Realtime (converted to proto3). +// Source: https://gtfs.org/documentation/realtime/gtfs-realtime.proto + +syntax = "proto3"; +option java_package = "com.google.transit.realtime"; +option php_namespace = "Google\\Transit\\Realtime"; +option php_metadata_namespace = "GPBMetadata"; +package transit_realtime; + +// The contents of a feed message. +message FeedMessage { + FeedHeader header = 1; + repeated FeedEntity entity = 2; +} + +// Metadata about a feed, included in feed messages. +message FeedHeader { + string gtfs_realtime_version = 1; + + enum Incrementality { + FULL_DATASET = 0; + DIFFERENTIAL = 1; + } + Incrementality incrementality = 2; + + uint64 timestamp = 3; + string feed_version = 4; +} + +// A definition (or update) of an entity in the transit feed. +message FeedEntity { + string id = 1; + bool is_deleted = 2; + TripUpdate trip_update = 3; + VehiclePosition vehicle = 4; + Alert alert = 5; + // NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + Shape shape = 6; + Stop stop = 7; + TripModifications trip_modifications = 8; +} + +// Realtime update of the progress of a vehicle along a trip. +message TripUpdate { + TripDescriptor trip = 1; + VehicleDescriptor vehicle = 3; + + message StopTimeEvent { + int32 delay = 1; + int64 time = 2; + int32 uncertainty = 3; + // NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + int64 scheduled_time = 4; + } + + message StopTimeUpdate { + uint32 stop_sequence = 1; + string stop_id = 4; + StopTimeEvent arrival = 2; + StopTimeEvent departure = 3; + VehiclePosition.OccupancyStatus departure_occupancy_status = 7; + + enum ScheduleRelationship { + SCHEDULED = 0; + SKIPPED = 1; + NO_DATA = 2; + // NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + UNSCHEDULED = 3; + } + ScheduleRelationship schedule_relationship = 5; + + // NOTE: This message is still experimental, and subject to change. It may be formally adopted in the future. + message StopTimeProperties { + string assigned_stop_id = 1; + // NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + string stop_headsign = 2; + + enum DropOffPickupType { + REGULAR = 0; + NONE = 1; + PHONE_AGENCY = 2; + COORDINATE_WITH_DRIVER = 3; + } + + // NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + DropOffPickupType pickup_type = 3; + // NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + DropOffPickupType drop_off_type = 4; + } + + // NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + StopTimeProperties stop_time_properties = 6; + } + + repeated StopTimeUpdate stop_time_update = 2; + uint64 timestamp = 4; + // NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + int32 delay = 5; + + // NOTE: This message is still experimental, and subject to change. It may be formally adopted in the future. + message TripProperties { + string trip_id = 1; + string start_date = 2; + string start_time = 3; + string shape_id = 4; + // NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + string trip_headsign = 5; + // NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + string trip_short_name = 6; + } + TripProperties trip_properties = 6; +} + +// Realtime positioning information for a given vehicle. +message VehiclePosition { + TripDescriptor trip = 1; + VehicleDescriptor vehicle = 8; + Position position = 2; + uint32 current_stop_sequence = 3; + string stop_id = 7; + + enum VehicleStopStatus { + INCOMING_AT = 0; + STOPPED_AT = 1; + IN_TRANSIT_TO = 2; + } + VehicleStopStatus current_status = 4; + + uint64 timestamp = 5; + + enum CongestionLevel { + UNKNOWN_CONGESTION_LEVEL = 0; + RUNNING_SMOOTHLY = 1; + STOP_AND_GO = 2; + CONGESTION = 3; + SEVERE_CONGESTION = 4; + } + CongestionLevel congestion_level = 6; + + enum OccupancyStatus { + EMPTY = 0; + MANY_SEATS_AVAILABLE = 1; + FEW_SEATS_AVAILABLE = 2; + STANDING_ROOM_ONLY = 3; + CRUSHED_STANDING_ROOM_ONLY = 4; + FULL = 5; + NOT_ACCEPTING_PASSENGERS = 6; + NO_DATA_AVAILABLE = 7; + NOT_BOARDABLE = 8; + } + OccupancyStatus occupancy_status = 9; + + // NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + uint32 occupancy_percentage = 10; + + // NOTE: This message/field is still experimental, and subject to change. It may be formally adopted in the future. + message CarriageDetails { + string id = 1; + string label = 2; + OccupancyStatus occupancy_status = 3; + int32 occupancy_percentage = 4; + uint32 carriage_sequence = 5; + } + + // NOTE: This message/field is still experimental, and subject to change. It may be formally adopted in the future. + repeated CarriageDetails multi_carriage_details = 11; +} + +// An alert, indicating some sort of incident in the public transit network. +message Alert { + repeated TimeRange active_period = 1; + repeated EntitySelector informed_entity = 5; + + enum Cause { + UNKNOWN_CAUSE = 0; + OTHER_CAUSE = 2; + TECHNICAL_PROBLEM = 3; + STRIKE = 4; + DEMONSTRATION = 5; + ACCIDENT = 6; + HOLIDAY = 7; + WEATHER = 8; + MAINTENANCE = 9; + CONSTRUCTION = 10; + POLICE_ACTIVITY = 11; + MEDICAL_EMERGENCY = 12; + } + Cause cause = 6; + + enum Effect { + NO_SERVICE = 0; + REDUCED_SERVICE = 2; + SIGNIFICANT_DELAYS = 3; + DETOUR = 4; + ADDITIONAL_SERVICE = 5; + MODIFIED_SERVICE = 6; + OTHER_EFFECT = 7; + UNKNOWN_EFFECT = 8; + STOP_MOVED = 9; + NO_EFFECT = 10; + ACCESSIBILITY_ISSUE = 11; + } + Effect effect = 7; + + TranslatedString url = 8; + TranslatedString header_text = 10; + TranslatedString description_text = 11; + TranslatedString tts_header_text = 12; + TranslatedString tts_description_text = 13; + + enum SeverityLevel { + UNKNOWN_SEVERITY = 0; + INFO = 2; + WARNING = 3; + SEVERE = 4; + } + SeverityLevel severity_level = 14; + + // NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + TranslatedImage image = 15; + // NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + TranslatedString image_alternative_text = 16; + // NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + TranslatedString cause_detail = 17; + // NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + TranslatedString effect_detail = 18; +} + +// A time interval. +message TimeRange { + uint64 start = 1; + uint64 end = 2; +} + +// A position. +message Position { + float latitude = 1; + float longitude = 2; + float bearing = 3; + double odometer = 4; + float speed = 5; +} + +// A descriptor that identifies an instance of a GTFS trip. +message TripDescriptor { + string trip_id = 1; + string route_id = 5; + uint32 direction_id = 6; + string start_time = 2; + string start_date = 3; + + enum ScheduleRelationship { + SCHEDULED = 0; + ADDED = 1 [deprecated = true]; + UNSCHEDULED = 2; + CANCELED = 3; + // NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + REPLACEMENT = 5; + // NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + DUPLICATED = 6; + // NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + DELETED = 7; + // NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + NEW = 8; + } + ScheduleRelationship schedule_relationship = 4; + + message ModifiedTripSelector { + string modifications_id = 1; + string affected_trip_id = 2; + string start_time = 3; + string start_date = 4; + } + + // NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + ModifiedTripSelector modified_trip = 7; +} + +// Identification information for the vehicle performing the trip. +message VehicleDescriptor { + string id = 1; + string label = 2; + string license_plate = 3; + + enum WheelchairAccessible { + NO_VALUE = 0; + UNKNOWN = 1; + WHEELCHAIR_ACCESSIBLE = 2; + WHEELCHAIR_INACCESSIBLE = 3; + } + WheelchairAccessible wheelchair_accessible = 4; +} + +// A selector for an entity in a GTFS feed. +message EntitySelector { + string agency_id = 1; + string route_id = 2; + int32 route_type = 3; + TripDescriptor trip = 4; + string stop_id = 5; + uint32 direction_id = 6; +} + +// An internationalized message containing per-language versions of a snippet of text or a URL. +message TranslatedString { + message Translation { + string text = 1; + string language = 2; + } + repeated Translation translation = 1; +} + +// An internationalized image containing per-language versions of a URL linking to an image. +// NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. +message TranslatedImage { + message LocalizedImage { + string url = 1; + string media_type = 2; + string language = 3; + } + repeated LocalizedImage localized_image = 1; +} + +// Describes the physical path that a vehicle takes when it's not part of the (CSV) GTFS. +// NOTE: This message is still experimental, and subject to change. It may be formally adopted in the future. +message Shape { + string shape_id = 1; + string encoded_polyline = 2; +} + +// Describes a stop which is served by trips. +// NOTE: This message is still experimental, and subject to change. It may be formally adopted in the future. +message Stop { + enum WheelchairBoarding { + UNKNOWN = 0; + AVAILABLE = 1; + NOT_AVAILABLE = 2; + } + + string stop_id = 1; + TranslatedString stop_code = 2; + TranslatedString stop_name = 3; + TranslatedString tts_stop_name = 4; + TranslatedString stop_desc = 5; + float stop_lat = 6; + float stop_lon = 7; + string zone_id = 8; + TranslatedString stop_url = 9; + string parent_station = 11; + string stop_timezone = 12; + WheelchairBoarding wheelchair_boarding = 13; + string level_id = 14; + TranslatedString platform_code = 15; +} + +// NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. +message TripModifications { + message Modification { + StopSelector start_stop_selector = 1; + StopSelector end_stop_selector = 2; + int32 propagated_modification_delay = 3; + repeated ReplacementStop replacement_stops = 4; + string service_alert_id = 5; + uint64 last_modified_time = 6; + } + + message SelectedTrips { + repeated string trip_ids = 1; + string shape_id = 2; + } + + repeated SelectedTrips selected_trips = 1; + repeated string start_times = 2; + repeated string service_dates = 3; + repeated Modification modifications = 4; +} + +// Select a stop by stop sequence or by stop_id. +// NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. +message StopSelector { + uint32 stop_sequence = 1; + string stop_id = 2; +} + +// NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. +message ReplacementStop { + int32 travel_time_to_stop = 1; + string stop_id = 2; +} diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..54ae624 --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,17 @@ + + + + + tests + + + + + src + + + diff --git a/src/GPBMetadata/GtfsRealtime.php b/src/GPBMetadata/GtfsRealtime.php new file mode 100644 index 0000000..da7e259 --- /dev/null +++ b/src/GPBMetadata/GtfsRealtime.php @@ -0,0 +1,25 @@ +internalAddGeneratedFile( + "\x0A\xB3:\x0A\x13gtfs-realtime.proto\x12\x10transit_realtime\"i\x0A\x0BFeedMessage\x12,\x0A\x06header\x18\x01 \x01(\x0B2\x1C.transit_realtime.FeedHeader\x12,\x0A\x06entity\x18\x02 \x03(\x0B2\x1C.transit_realtime.FeedEntity\"\xCF\x01\x0A\x0AFeedHeader\x12\x1D\x0A\x15gtfs_realtime_version\x18\x01 \x01(\x09\x12C\x0A\x0Eincrementality\x18\x02 \x01(\x0E2+.transit_realtime.FeedHeader.Incrementality\x12\x11\x0A\x09timestamp\x18\x03 \x01(\x04\x12\x14\x0A\x0Cfeed_version\x18\x04 \x01(\x09\"4\x0A\x0EIncrementality\x12\x10\x0A\x0CFULL_DATASET\x10\x00\x12\x10\x0A\x0CDIFFERENTIAL\x10\x01\"\xCA\x02\x0A\x0AFeedEntity\x12\x0A\x0A\x02id\x18\x01 \x01(\x09\x12\x12\x0A\x0Ais_deleted\x18\x02 \x01(\x08\x121\x0A\x0Btrip_update\x18\x03 \x01(\x0B2\x1C.transit_realtime.TripUpdate\x122\x0A\x07vehicle\x18\x04 \x01(\x0B2!.transit_realtime.VehiclePosition\x12&\x0A\x05alert\x18\x05 \x01(\x0B2\x17.transit_realtime.Alert\x12&\x0A\x05shape\x18\x06 \x01(\x0B2\x17.transit_realtime.Shape\x12\$\x0A\x04stop\x18\x07 \x01(\x0B2\x16.transit_realtime.Stop\x12?\x0A\x12trip_modifications\x18\x08 \x01(\x0B2#.transit_realtime.TripModifications\"\x9B\x0B\x0A\x0ATripUpdate\x12.\x0A\x04trip\x18\x01 \x01(\x0B2 .transit_realtime.TripDescriptor\x124\x0A\x07vehicle\x18\x03 \x01(\x0B2#.transit_realtime.VehicleDescriptor\x12E\x0A\x10stop_time_update\x18\x02 \x03(\x0B2+.transit_realtime.TripUpdate.StopTimeUpdate\x12\x11\x0A\x09timestamp\x18\x04 \x01(\x04\x12\x0D\x0A\x05delay\x18\x05 \x01(\x05\x12D\x0A\x0Ftrip_properties\x18\x06 \x01(\x0B2+.transit_realtime.TripUpdate.TripProperties\x1AY\x0A\x0DStopTimeEvent\x12\x0D\x0A\x05delay\x18\x01 \x01(\x05\x12\x0C\x0A\x04time\x18\x02 \x01(\x03\x12\x13\x0A\x0Buncertainty\x18\x03 \x01(\x05\x12\x16\x0A\x0Escheduled_time\x18\x04 \x01(\x03\x1A\x8E\x07\x0A\x0EStopTimeUpdate\x12\x15\x0A\x0Dstop_sequence\x18\x01 \x01(\x0D\x12\x0F\x0A\x07stop_id\x18\x04 \x01(\x09\x12;\x0A\x07arrival\x18\x02 \x01(\x0B2*.transit_realtime.TripUpdate.StopTimeEvent\x12=\x0A\x09departure\x18\x03 \x01(\x0B2*.transit_realtime.TripUpdate.StopTimeEvent\x12U\x0A\x1Adeparture_occupancy_status\x18\x07 \x01(\x0E21.transit_realtime.VehiclePosition.OccupancyStatus\x12_\x0A\x15schedule_relationship\x18\x05 \x01(\x0E2@.transit_realtime.TripUpdate.StopTimeUpdate.ScheduleRelationship\x12\\\x0A\x14stop_time_properties\x18\x06 \x01(\x0B2>.transit_realtime.TripUpdate.StopTimeUpdate.StopTimeProperties\x1A\xEF\x02\x0A\x12StopTimeProperties\x12\x18\x0A\x10assigned_stop_id\x18\x01 \x01(\x09\x12\x15\x0A\x0Dstop_headsign\x18\x02 \x01(\x09\x12e\x0A\x0Bpickup_type\x18\x03 \x01(\x0E2P.transit_realtime.TripUpdate.StopTimeUpdate.StopTimeProperties.DropOffPickupType\x12g\x0A\x0Ddrop_off_type\x18\x04 \x01(\x0E2P.transit_realtime.TripUpdate.StopTimeUpdate.StopTimeProperties.DropOffPickupType\"X\x0A\x11DropOffPickupType\x12\x0B\x0A\x07REGULAR\x10\x00\x12\x08\x0A\x04NONE\x10\x01\x12\x10\x0A\x0CPHONE_AGENCY\x10\x02\x12\x1A\x0A\x16COORDINATE_WITH_DRIVER\x10\x03\"P\x0A\x14ScheduleRelationship\x12\x0D\x0A\x09SCHEDULED\x10\x00\x12\x0B\x0A\x07SKIPPED\x10\x01\x12\x0B\x0A\x07NO_DATA\x10\x02\x12\x0F\x0A\x0BUNSCHEDULED\x10\x03\x1A\x8B\x01\x0A\x0ETripProperties\x12\x0F\x0A\x07trip_id\x18\x01 \x01(\x09\x12\x12\x0A\x0Astart_date\x18\x02 \x01(\x09\x12\x12\x0A\x0Astart_time\x18\x03 \x01(\x09\x12\x10\x0A\x08shape_id\x18\x04 \x01(\x09\x12\x15\x0A\x0Dtrip_headsign\x18\x05 \x01(\x09\x12\x17\x0A\x0Ftrip_short_name\x18\x06 \x01(\x09\"\x99\x09\x0A\x0FVehiclePosition\x12.\x0A\x04trip\x18\x01 \x01(\x0B2 .transit_realtime.TripDescriptor\x124\x0A\x07vehicle\x18\x08 \x01(\x0B2#.transit_realtime.VehicleDescriptor\x12,\x0A\x08position\x18\x02 \x01(\x0B2\x1A.transit_realtime.Position\x12\x1D\x0A\x15current_stop_sequence\x18\x03 \x01(\x0D\x12\x0F\x0A\x07stop_id\x18\x07 \x01(\x09\x12K\x0A\x0Ecurrent_status\x18\x04 \x01(\x0E23.transit_realtime.VehiclePosition.VehicleStopStatus\x12\x11\x0A\x09timestamp\x18\x05 \x01(\x04\x12K\x0A\x10congestion_level\x18\x06 \x01(\x0E21.transit_realtime.VehiclePosition.CongestionLevel\x12K\x0A\x10occupancy_status\x18\x09 \x01(\x0E21.transit_realtime.VehiclePosition.OccupancyStatus\x12\x1C\x0A\x14occupancy_percentage\x18\x0A \x01(\x0D\x12Q\x0A\x16multi_carriage_details\x18\x0B \x03(\x0B21.transit_realtime.VehiclePosition.CarriageDetails\x1A\xB2\x01\x0A\x0FCarriageDetails\x12\x0A\x0A\x02id\x18\x01 \x01(\x09\x12\x0D\x0A\x05label\x18\x02 \x01(\x09\x12K\x0A\x10occupancy_status\x18\x03 \x01(\x0E21.transit_realtime.VehiclePosition.OccupancyStatus\x12\x1C\x0A\x14occupancy_percentage\x18\x04 \x01(\x05\x12\x19\x0A\x11carriage_sequence\x18\x05 \x01(\x0D\"G\x0A\x11VehicleStopStatus\x12\x0F\x0A\x0BINCOMING_AT\x10\x00\x12\x0E\x0A\x0ASTOPPED_AT\x10\x01\x12\x11\x0A\x0DIN_TRANSIT_TO\x10\x02\"}\x0A\x0FCongestionLevel\x12\x1C\x0A\x18UNKNOWN_CONGESTION_LEVEL\x10\x00\x12\x14\x0A\x10RUNNING_SMOOTHLY\x10\x01\x12\x0F\x0A\x0BSTOP_AND_GO\x10\x02\x12\x0E\x0A\x0ACONGESTION\x10\x03\x12\x15\x0A\x11SEVERE_CONGESTION\x10\x04\"\xD9\x01\x0A\x0FOccupancyStatus\x12\x09\x0A\x05EMPTY\x10\x00\x12\x18\x0A\x14MANY_SEATS_AVAILABLE\x10\x01\x12\x17\x0A\x13FEW_SEATS_AVAILABLE\x10\x02\x12\x16\x0A\x12STANDING_ROOM_ONLY\x10\x03\x12\x1E\x0A\x1ACRUSHED_STANDING_ROOM_ONLY\x10\x04\x12\x08\x0A\x04FULL\x10\x05\x12\x1C\x0A\x18NOT_ACCEPTING_PASSENGERS\x10\x06\x12\x15\x0A\x11NO_DATA_AVAILABLE\x10\x07\x12\x11\x0A\x0DNOT_BOARDABLE\x10\x08\"\xAA\x0A\x0A\x05Alert\x122\x0A\x0Dactive_period\x18\x01 \x03(\x0B2\x1B.transit_realtime.TimeRange\x129\x0A\x0Finformed_entity\x18\x05 \x03(\x0B2 .transit_realtime.EntitySelector\x12,\x0A\x05cause\x18\x06 \x01(\x0E2\x1D.transit_realtime.Alert.Cause\x12.\x0A\x06effect\x18\x07 \x01(\x0E2\x1E.transit_realtime.Alert.Effect\x12/\x0A\x03url\x18\x08 \x01(\x0B2\".transit_realtime.TranslatedString\x127\x0A\x0Bheader_text\x18\x0A \x01(\x0B2\".transit_realtime.TranslatedString\x12<\x0A\x10description_text\x18\x0B \x01(\x0B2\".transit_realtime.TranslatedString\x12;\x0A\x0Ftts_header_text\x18\x0C \x01(\x0B2\".transit_realtime.TranslatedString\x12@\x0A\x14tts_description_text\x18\x0D \x01(\x0B2\".transit_realtime.TranslatedString\x12=\x0A\x0Eseverity_level\x18\x0E \x01(\x0E2%.transit_realtime.Alert.SeverityLevel\x120\x0A\x05image\x18\x0F \x01(\x0B2!.transit_realtime.TranslatedImage\x12B\x0A\x16image_alternative_text\x18\x10 \x01(\x0B2\".transit_realtime.TranslatedString\x128\x0A\x0Ccause_detail\x18\x11 \x01(\x0B2\".transit_realtime.TranslatedString\x129\x0A\x0Deffect_detail\x18\x12 \x01(\x0B2\".transit_realtime.TranslatedString\"\xD8\x01\x0A\x05Cause\x12\x11\x0A\x0DUNKNOWN_CAUSE\x10\x00\x12\x0F\x0A\x0BOTHER_CAUSE\x10\x02\x12\x15\x0A\x11TECHNICAL_PROBLEM\x10\x03\x12\x0A\x0A\x06STRIKE\x10\x04\x12\x11\x0A\x0DDEMONSTRATION\x10\x05\x12\x0C\x0A\x08ACCIDENT\x10\x06\x12\x0B\x0A\x07HOLIDAY\x10\x07\x12\x0B\x0A\x07WEATHER\x10\x08\x12\x0F\x0A\x0BMAINTENANCE\x10\x09\x12\x10\x0A\x0CCONSTRUCTION\x10\x0A\x12\x13\x0A\x0FPOLICE_ACTIVITY\x10\x0B\x12\x15\x0A\x11MEDICAL_EMERGENCY\x10\x0C\"\xDD\x01\x0A\x06Effect\x12\x0E\x0A\x0ANO_SERVICE\x10\x00\x12\x13\x0A\x0FREDUCED_SERVICE\x10\x02\x12\x16\x0A\x12SIGNIFICANT_DELAYS\x10\x03\x12\x0A\x0A\x06DETOUR\x10\x04\x12\x16\x0A\x12ADDITIONAL_SERVICE\x10\x05\x12\x14\x0A\x10MODIFIED_SERVICE\x10\x06\x12\x10\x0A\x0COTHER_EFFECT\x10\x07\x12\x12\x0A\x0EUNKNOWN_EFFECT\x10\x08\x12\x0E\x0A\x0ASTOP_MOVED\x10\x09\x12\x0D\x0A\x09NO_EFFECT\x10\x0A\x12\x17\x0A\x13ACCESSIBILITY_ISSUE\x10\x0B\"H\x0A\x0DSeverityLevel\x12\x14\x0A\x10UNKNOWN_SEVERITY\x10\x00\x12\x08\x0A\x04INFO\x10\x02\x12\x0B\x0A\x07WARNING\x10\x03\x12\x0A\x0A\x06SEVERE\x10\x04\"'\x0A\x09TimeRange\x12\x0D\x0A\x05start\x18\x01 \x01(\x04\x12\x0B\x0A\x03end\x18\x02 \x01(\x04\"a\x0A\x08Position\x12\x10\x0A\x08latitude\x18\x01 \x01(\x02\x12\x11\x0A\x09longitude\x18\x02 \x01(\x02\x12\x0F\x0A\x07bearing\x18\x03 \x01(\x02\x12\x10\x0A\x08odometer\x18\x04 \x01(\x01\x12\x0D\x0A\x05speed\x18\x05 \x01(\x02\"\x96\x04\x0A\x0ETripDescriptor\x12\x0F\x0A\x07trip_id\x18\x01 \x01(\x09\x12\x10\x0A\x08route_id\x18\x05 \x01(\x09\x12\x14\x0A\x0Cdirection_id\x18\x06 \x01(\x0D\x12\x12\x0A\x0Astart_time\x18\x02 \x01(\x09\x12\x12\x0A\x0Astart_date\x18\x03 \x01(\x09\x12T\x0A\x15schedule_relationship\x18\x04 \x01(\x0E25.transit_realtime.TripDescriptor.ScheduleRelationship\x12L\x0A\x0Dmodified_trip\x18\x07 \x01(\x0B25.transit_realtime.TripDescriptor.ModifiedTripSelector\x1Ar\x0A\x14ModifiedTripSelector\x12\x18\x0A\x10modifications_id\x18\x01 \x01(\x09\x12\x18\x0A\x10affected_trip_id\x18\x02 \x01(\x09\x12\x12\x0A\x0Astart_time\x18\x03 \x01(\x09\x12\x12\x0A\x0Astart_date\x18\x04 \x01(\x09\"\x8A\x01\x0A\x14ScheduleRelationship\x12\x0D\x0A\x09SCHEDULED\x10\x00\x12\x0D\x0A\x05ADDED\x10\x01\x1A\x02\x08\x01\x12\x0F\x0A\x0BUNSCHEDULED\x10\x02\x12\x0C\x0A\x08CANCELED\x10\x03\x12\x0F\x0A\x0BREPLACEMENT\x10\x05\x12\x0E\x0A\x0ADUPLICATED\x10\x06\x12\x0B\x0A\x07DELETED\x10\x07\x12\x07\x0A\x03NEW\x10\x08\"\x89\x02\x0A\x11VehicleDescriptor\x12\x0A\x0A\x02id\x18\x01 \x01(\x09\x12\x0D\x0A\x05label\x18\x02 \x01(\x09\x12\x15\x0A\x0Dlicense_plate\x18\x03 \x01(\x09\x12W\x0A\x15wheelchair_accessible\x18\x04 \x01(\x0E28.transit_realtime.VehicleDescriptor.WheelchairAccessible\"i\x0A\x14WheelchairAccessible\x12\x0C\x0A\x08NO_VALUE\x10\x00\x12\x0B\x0A\x07UNKNOWN\x10\x01\x12\x19\x0A\x15WHEELCHAIR_ACCESSIBLE\x10\x02\x12\x1B\x0A\x17WHEELCHAIR_INACCESSIBLE\x10\x03\"\xA0\x01\x0A\x0EEntitySelector\x12\x11\x0A\x09agency_id\x18\x01 \x01(\x09\x12\x10\x0A\x08route_id\x18\x02 \x01(\x09\x12\x12\x0A\x0Aroute_type\x18\x03 \x01(\x05\x12.\x0A\x04trip\x18\x04 \x01(\x0B2 .transit_realtime.TripDescriptor\x12\x0F\x0A\x07stop_id\x18\x05 \x01(\x09\x12\x14\x0A\x0Cdirection_id\x18\x06 \x01(\x0D\"\x86\x01\x0A\x10TranslatedString\x12C\x0A\x0Btranslation\x18\x01 \x03(\x0B2..transit_realtime.TranslatedString.Translation\x1A-\x0A\x0BTranslation\x12\x0C\x0A\x04text\x18\x01 \x01(\x09\x12\x10\x0A\x08language\x18\x02 \x01(\x09\"\xA1\x01\x0A\x0FTranslatedImage\x12I\x0A\x0Flocalized_image\x18\x01 \x03(\x0B20.transit_realtime.TranslatedImage.LocalizedImage\x1AC\x0A\x0ELocalizedImage\x12\x0B\x0A\x03url\x18\x01 \x01(\x09\x12\x12\x0A\x0Amedia_type\x18\x02 \x01(\x09\x12\x10\x0A\x08language\x18\x03 \x01(\x09\"3\x0A\x05Shape\x12\x10\x0A\x08shape_id\x18\x01 \x01(\x09\x12\x18\x0A\x10encoded_polyline\x18\x02 \x01(\x09\"\xEB\x04\x0A\x04Stop\x12\x0F\x0A\x07stop_id\x18\x01 \x01(\x09\x125\x0A\x09stop_code\x18\x02 \x01(\x0B2\".transit_realtime.TranslatedString\x125\x0A\x09stop_name\x18\x03 \x01(\x0B2\".transit_realtime.TranslatedString\x129\x0A\x0Dtts_stop_name\x18\x04 \x01(\x0B2\".transit_realtime.TranslatedString\x125\x0A\x09stop_desc\x18\x05 \x01(\x0B2\".transit_realtime.TranslatedString\x12\x10\x0A\x08stop_lat\x18\x06 \x01(\x02\x12\x10\x0A\x08stop_lon\x18\x07 \x01(\x02\x12\x0F\x0A\x07zone_id\x18\x08 \x01(\x09\x124\x0A\x08stop_url\x18\x09 \x01(\x0B2\".transit_realtime.TranslatedString\x12\x16\x0A\x0Eparent_station\x18\x0B \x01(\x09\x12\x15\x0A\x0Dstop_timezone\x18\x0C \x01(\x09\x12F\x0A\x13wheelchair_boarding\x18\x0D \x01(\x0E2).transit_realtime.Stop.WheelchairBoarding\x12\x10\x0A\x08level_id\x18\x0E \x01(\x09\x129\x0A\x0Dplatform_code\x18\x0F \x01(\x0B2\".transit_realtime.TranslatedString\"C\x0A\x12WheelchairBoarding\x12\x0B\x0A\x07UNKNOWN\x10\x00\x12\x0D\x0A\x09AVAILABLE\x10\x01\x12\x11\x0A\x0DNOT_AVAILABLE\x10\x02\"\xAC\x04\x0A\x11TripModifications\x12I\x0A\x0Eselected_trips\x18\x01 \x03(\x0B21.transit_realtime.TripModifications.SelectedTrips\x12\x13\x0A\x0Bstart_times\x18\x02 \x03(\x09\x12\x15\x0A\x0Dservice_dates\x18\x03 \x03(\x09\x12G\x0A\x0Dmodifications\x18\x04 \x03(\x0B20.transit_realtime.TripModifications.Modification\x1A\xA1\x02\x0A\x0CModification\x12;\x0A\x13start_stop_selector\x18\x01 \x01(\x0B2\x1E.transit_realtime.StopSelector\x129\x0A\x11end_stop_selector\x18\x02 \x01(\x0B2\x1E.transit_realtime.StopSelector\x12%\x0A\x1Dpropagated_modification_delay\x18\x03 \x01(\x05\x12<\x0A\x11replacement_stops\x18\x04 \x03(\x0B2!.transit_realtime.ReplacementStop\x12\x18\x0A\x10service_alert_id\x18\x05 \x01(\x09\x12\x1A\x0A\x12last_modified_time\x18\x06 \x01(\x04\x1A3\x0A\x0DSelectedTrips\x12\x10\x0A\x08trip_ids\x18\x01 \x03(\x09\x12\x10\x0A\x08shape_id\x18\x02 \x01(\x09\"6\x0A\x0CStopSelector\x12\x15\x0A\x0Dstop_sequence\x18\x01 \x01(\x0D\x12\x0F\x0A\x07stop_id\x18\x02 \x01(\x09\"?\x0A\x0FReplacementStop\x12\x1B\x0A\x13travel_time_to_stop\x18\x01 \x01(\x05\x12\x0F\x0A\x07stop_id\x18\x02 \x01(\x09BE\x0A\x1Bcom.google.transit.realtime\xCA\x02\x17Google\\Transit\\Realtime\xE2\x02\x0BGPBMetadatab\x06proto3" + , true); + + static::$is_initialized = true; + } +} + diff --git a/src/Google/Transit/Realtime/Alert.php b/src/Google/Transit/Realtime/Alert.php new file mode 100644 index 0000000..ce15ba9 --- /dev/null +++ b/src/Google/Transit/Realtime/Alert.php @@ -0,0 +1,521 @@ +transit_realtime.Alert + */ +class Alert extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field repeated .transit_realtime.TimeRange active_period = 1; + */ + private $active_period; + /** + * Generated from protobuf field repeated .transit_realtime.EntitySelector informed_entity = 5; + */ + private $informed_entity; + /** + * Generated from protobuf field .transit_realtime.Alert.Cause cause = 6; + */ + protected $cause = 0; + /** + * Generated from protobuf field .transit_realtime.Alert.Effect effect = 7; + */ + protected $effect = 0; + /** + * Generated from protobuf field .transit_realtime.TranslatedString url = 8; + */ + protected $url = null; + /** + * Generated from protobuf field .transit_realtime.TranslatedString header_text = 10; + */ + protected $header_text = null; + /** + * Generated from protobuf field .transit_realtime.TranslatedString description_text = 11; + */ + protected $description_text = null; + /** + * Generated from protobuf field .transit_realtime.TranslatedString tts_header_text = 12; + */ + protected $tts_header_text = null; + /** + * Generated from protobuf field .transit_realtime.TranslatedString tts_description_text = 13; + */ + protected $tts_description_text = null; + /** + * Generated from protobuf field .transit_realtime.Alert.SeverityLevel severity_level = 14; + */ + protected $severity_level = 0; + /** + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * + * Generated from protobuf field .transit_realtime.TranslatedImage image = 15; + */ + protected $image = null; + /** + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * + * Generated from protobuf field .transit_realtime.TranslatedString image_alternative_text = 16; + */ + protected $image_alternative_text = null; + /** + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * + * Generated from protobuf field .transit_realtime.TranslatedString cause_detail = 17; + */ + protected $cause_detail = null; + /** + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * + * Generated from protobuf field .transit_realtime.TranslatedString effect_detail = 18; + */ + protected $effect_detail = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Transit\Realtime\TimeRange[] $active_period + * @type \Google\Transit\Realtime\EntitySelector[] $informed_entity + * @type int $cause + * @type int $effect + * @type \Google\Transit\Realtime\TranslatedString $url + * @type \Google\Transit\Realtime\TranslatedString $header_text + * @type \Google\Transit\Realtime\TranslatedString $description_text + * @type \Google\Transit\Realtime\TranslatedString $tts_header_text + * @type \Google\Transit\Realtime\TranslatedString $tts_description_text + * @type int $severity_level + * @type \Google\Transit\Realtime\TranslatedImage $image + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * @type \Google\Transit\Realtime\TranslatedString $image_alternative_text + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * @type \Google\Transit\Realtime\TranslatedString $cause_detail + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * @type \Google\Transit\Realtime\TranslatedString $effect_detail + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\GtfsRealtime::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field repeated .transit_realtime.TimeRange active_period = 1; + * @return RepeatedField<\Google\Transit\Realtime\TimeRange> + */ + public function getActivePeriod() + { + return $this->active_period; + } + + /** + * Generated from protobuf field repeated .transit_realtime.TimeRange active_period = 1; + * @param \Google\Transit\Realtime\TimeRange[] $var + * @return $this + */ + public function setActivePeriod(array|RepeatedField $var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Transit\Realtime\TimeRange::class); + $this->active_period = $arr; + + return $this; + } + + /** + * Generated from protobuf field repeated .transit_realtime.EntitySelector informed_entity = 5; + * @return RepeatedField<\Google\Transit\Realtime\EntitySelector> + */ + public function getInformedEntity() + { + return $this->informed_entity; + } + + /** + * Generated from protobuf field repeated .transit_realtime.EntitySelector informed_entity = 5; + * @param \Google\Transit\Realtime\EntitySelector[] $var + * @return $this + */ + public function setInformedEntity(array|RepeatedField $var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Transit\Realtime\EntitySelector::class); + $this->informed_entity = $arr; + + return $this; + } + + /** + * Generated from protobuf field .transit_realtime.Alert.Cause cause = 6; + * @return int one of the values in {@see \Google\Transit\Realtime\Alert\Cause} + */ + public function getCause() + { + return $this->cause; + } + + /** + * Generated from protobuf field .transit_realtime.Alert.Cause cause = 6; + * @param int $var one of the values in {@see \Google\Transit\Realtime\Alert\Cause} + * @return $this + */ + public function setCause(int $var) + { + GPBUtil::checkEnum($var, \Google\Transit\Realtime\Alert\Cause::class); + $this->cause = $var; + + return $this; + } + + /** + * Generated from protobuf field .transit_realtime.Alert.Effect effect = 7; + * @return int one of the values in {@see \Google\Transit\Realtime\Alert\Effect} + */ + public function getEffect() + { + return $this->effect; + } + + /** + * Generated from protobuf field .transit_realtime.Alert.Effect effect = 7; + * @param int $var one of the values in {@see \Google\Transit\Realtime\Alert\Effect} + * @return $this + */ + public function setEffect(int $var) + { + GPBUtil::checkEnum($var, \Google\Transit\Realtime\Alert\Effect::class); + $this->effect = $var; + + return $this; + } + + /** + * Generated from protobuf field .transit_realtime.TranslatedString url = 8; + * @return \Google\Transit\Realtime\TranslatedString|null + */ + public function getUrl() + { + return $this->url; + } + + public function hasUrl() + { + return isset($this->url); + } + + public function clearUrl() + { + unset($this->url); + } + + /** + * Generated from protobuf field .transit_realtime.TranslatedString url = 8; + * @param \Google\Transit\Realtime\TranslatedString $var + * @return $this + */ + public function setUrl(\Google\Transit\Realtime\TranslatedString|null $var) + { + $this->url = $var; + + return $this; + } + + /** + * Generated from protobuf field .transit_realtime.TranslatedString header_text = 10; + * @return \Google\Transit\Realtime\TranslatedString|null + */ + public function getHeaderText() + { + return $this->header_text; + } + + public function hasHeaderText() + { + return isset($this->header_text); + } + + public function clearHeaderText() + { + unset($this->header_text); + } + + /** + * Generated from protobuf field .transit_realtime.TranslatedString header_text = 10; + * @param \Google\Transit\Realtime\TranslatedString $var + * @return $this + */ + public function setHeaderText(\Google\Transit\Realtime\TranslatedString|null $var) + { + $this->header_text = $var; + + return $this; + } + + /** + * Generated from protobuf field .transit_realtime.TranslatedString description_text = 11; + * @return \Google\Transit\Realtime\TranslatedString|null + */ + public function getDescriptionText() + { + return $this->description_text; + } + + public function hasDescriptionText() + { + return isset($this->description_text); + } + + public function clearDescriptionText() + { + unset($this->description_text); + } + + /** + * Generated from protobuf field .transit_realtime.TranslatedString description_text = 11; + * @param \Google\Transit\Realtime\TranslatedString $var + * @return $this + */ + public function setDescriptionText(\Google\Transit\Realtime\TranslatedString|null $var) + { + $this->description_text = $var; + + return $this; + } + + /** + * Generated from protobuf field .transit_realtime.TranslatedString tts_header_text = 12; + * @return \Google\Transit\Realtime\TranslatedString|null + */ + public function getTtsHeaderText() + { + return $this->tts_header_text; + } + + public function hasTtsHeaderText() + { + return isset($this->tts_header_text); + } + + public function clearTtsHeaderText() + { + unset($this->tts_header_text); + } + + /** + * Generated from protobuf field .transit_realtime.TranslatedString tts_header_text = 12; + * @param \Google\Transit\Realtime\TranslatedString $var + * @return $this + */ + public function setTtsHeaderText(\Google\Transit\Realtime\TranslatedString|null $var) + { + $this->tts_header_text = $var; + + return $this; + } + + /** + * Generated from protobuf field .transit_realtime.TranslatedString tts_description_text = 13; + * @return \Google\Transit\Realtime\TranslatedString|null + */ + public function getTtsDescriptionText() + { + return $this->tts_description_text; + } + + public function hasTtsDescriptionText() + { + return isset($this->tts_description_text); + } + + public function clearTtsDescriptionText() + { + unset($this->tts_description_text); + } + + /** + * Generated from protobuf field .transit_realtime.TranslatedString tts_description_text = 13; + * @param \Google\Transit\Realtime\TranslatedString $var + * @return $this + */ + public function setTtsDescriptionText(\Google\Transit\Realtime\TranslatedString|null $var) + { + $this->tts_description_text = $var; + + return $this; + } + + /** + * Generated from protobuf field .transit_realtime.Alert.SeverityLevel severity_level = 14; + * @return int one of the values in {@see \Google\Transit\Realtime\Alert\SeverityLevel} + */ + public function getSeverityLevel() + { + return $this->severity_level; + } + + /** + * Generated from protobuf field .transit_realtime.Alert.SeverityLevel severity_level = 14; + * @param int $var one of the values in {@see \Google\Transit\Realtime\Alert\SeverityLevel} + * @return $this + */ + public function setSeverityLevel(int $var) + { + GPBUtil::checkEnum($var, \Google\Transit\Realtime\Alert\SeverityLevel::class); + $this->severity_level = $var; + + return $this; + } + + /** + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * + * Generated from protobuf field .transit_realtime.TranslatedImage image = 15; + * @return \Google\Transit\Realtime\TranslatedImage|null + */ + public function getImage() + { + return $this->image; + } + + public function hasImage() + { + return isset($this->image); + } + + public function clearImage() + { + unset($this->image); + } + + /** + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * + * Generated from protobuf field .transit_realtime.TranslatedImage image = 15; + * @param \Google\Transit\Realtime\TranslatedImage $var + * @return $this + */ + public function setImage(\Google\Transit\Realtime\TranslatedImage|null $var) + { + $this->image = $var; + + return $this; + } + + /** + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * + * Generated from protobuf field .transit_realtime.TranslatedString image_alternative_text = 16; + * @return \Google\Transit\Realtime\TranslatedString|null + */ + public function getImageAlternativeText() + { + return $this->image_alternative_text; + } + + public function hasImageAlternativeText() + { + return isset($this->image_alternative_text); + } + + public function clearImageAlternativeText() + { + unset($this->image_alternative_text); + } + + /** + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * + * Generated from protobuf field .transit_realtime.TranslatedString image_alternative_text = 16; + * @param \Google\Transit\Realtime\TranslatedString $var + * @return $this + */ + public function setImageAlternativeText(\Google\Transit\Realtime\TranslatedString|null $var) + { + $this->image_alternative_text = $var; + + return $this; + } + + /** + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * + * Generated from protobuf field .transit_realtime.TranslatedString cause_detail = 17; + * @return \Google\Transit\Realtime\TranslatedString|null + */ + public function getCauseDetail() + { + return $this->cause_detail; + } + + public function hasCauseDetail() + { + return isset($this->cause_detail); + } + + public function clearCauseDetail() + { + unset($this->cause_detail); + } + + /** + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * + * Generated from protobuf field .transit_realtime.TranslatedString cause_detail = 17; + * @param \Google\Transit\Realtime\TranslatedString $var + * @return $this + */ + public function setCauseDetail(\Google\Transit\Realtime\TranslatedString|null $var) + { + $this->cause_detail = $var; + + return $this; + } + + /** + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * + * Generated from protobuf field .transit_realtime.TranslatedString effect_detail = 18; + * @return \Google\Transit\Realtime\TranslatedString|null + */ + public function getEffectDetail() + { + return $this->effect_detail; + } + + public function hasEffectDetail() + { + return isset($this->effect_detail); + } + + public function clearEffectDetail() + { + unset($this->effect_detail); + } + + /** + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * + * Generated from protobuf field .transit_realtime.TranslatedString effect_detail = 18; + * @param \Google\Transit\Realtime\TranslatedString $var + * @return $this + */ + public function setEffectDetail(\Google\Transit\Realtime\TranslatedString|null $var) + { + $this->effect_detail = $var; + + return $this; + } + +} + diff --git a/src/Google/Transit/Realtime/Alert/Cause.php b/src/Google/Transit/Realtime/Alert/Cause.php new file mode 100644 index 0000000..2ecdf8a --- /dev/null +++ b/src/Google/Transit/Realtime/Alert/Cause.php @@ -0,0 +1,99 @@ +transit_realtime.Alert.Cause + */ +class Cause +{ + /** + * Generated from protobuf enum UNKNOWN_CAUSE = 0; + */ + const UNKNOWN_CAUSE = 0; + /** + * Generated from protobuf enum OTHER_CAUSE = 2; + */ + const OTHER_CAUSE = 2; + /** + * Generated from protobuf enum TECHNICAL_PROBLEM = 3; + */ + const TECHNICAL_PROBLEM = 3; + /** + * Generated from protobuf enum STRIKE = 4; + */ + const STRIKE = 4; + /** + * Generated from protobuf enum DEMONSTRATION = 5; + */ + const DEMONSTRATION = 5; + /** + * Generated from protobuf enum ACCIDENT = 6; + */ + const ACCIDENT = 6; + /** + * Generated from protobuf enum HOLIDAY = 7; + */ + const HOLIDAY = 7; + /** + * Generated from protobuf enum WEATHER = 8; + */ + const WEATHER = 8; + /** + * Generated from protobuf enum MAINTENANCE = 9; + */ + const MAINTENANCE = 9; + /** + * Generated from protobuf enum CONSTRUCTION = 10; + */ + const CONSTRUCTION = 10; + /** + * Generated from protobuf enum POLICE_ACTIVITY = 11; + */ + const POLICE_ACTIVITY = 11; + /** + * Generated from protobuf enum MEDICAL_EMERGENCY = 12; + */ + const MEDICAL_EMERGENCY = 12; + + private static $valueToName = [ + self::UNKNOWN_CAUSE => 'UNKNOWN_CAUSE', + self::OTHER_CAUSE => 'OTHER_CAUSE', + self::TECHNICAL_PROBLEM => 'TECHNICAL_PROBLEM', + self::STRIKE => 'STRIKE', + self::DEMONSTRATION => 'DEMONSTRATION', + self::ACCIDENT => 'ACCIDENT', + self::HOLIDAY => 'HOLIDAY', + self::WEATHER => 'WEATHER', + self::MAINTENANCE => 'MAINTENANCE', + self::CONSTRUCTION => 'CONSTRUCTION', + self::POLICE_ACTIVITY => 'POLICE_ACTIVITY', + self::MEDICAL_EMERGENCY => 'MEDICAL_EMERGENCY', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + diff --git a/src/Google/Transit/Realtime/Alert/Effect.php b/src/Google/Transit/Realtime/Alert/Effect.php new file mode 100644 index 0000000..bf09ffc --- /dev/null +++ b/src/Google/Transit/Realtime/Alert/Effect.php @@ -0,0 +1,94 @@ +transit_realtime.Alert.Effect + */ +class Effect +{ + /** + * Generated from protobuf enum NO_SERVICE = 0; + */ + const NO_SERVICE = 0; + /** + * Generated from protobuf enum REDUCED_SERVICE = 2; + */ + const REDUCED_SERVICE = 2; + /** + * Generated from protobuf enum SIGNIFICANT_DELAYS = 3; + */ + const SIGNIFICANT_DELAYS = 3; + /** + * Generated from protobuf enum DETOUR = 4; + */ + const DETOUR = 4; + /** + * Generated from protobuf enum ADDITIONAL_SERVICE = 5; + */ + const ADDITIONAL_SERVICE = 5; + /** + * Generated from protobuf enum MODIFIED_SERVICE = 6; + */ + const MODIFIED_SERVICE = 6; + /** + * Generated from protobuf enum OTHER_EFFECT = 7; + */ + const OTHER_EFFECT = 7; + /** + * Generated from protobuf enum UNKNOWN_EFFECT = 8; + */ + const UNKNOWN_EFFECT = 8; + /** + * Generated from protobuf enum STOP_MOVED = 9; + */ + const STOP_MOVED = 9; + /** + * Generated from protobuf enum NO_EFFECT = 10; + */ + const NO_EFFECT = 10; + /** + * Generated from protobuf enum ACCESSIBILITY_ISSUE = 11; + */ + const ACCESSIBILITY_ISSUE = 11; + + private static $valueToName = [ + self::NO_SERVICE => 'NO_SERVICE', + self::REDUCED_SERVICE => 'REDUCED_SERVICE', + self::SIGNIFICANT_DELAYS => 'SIGNIFICANT_DELAYS', + self::DETOUR => 'DETOUR', + self::ADDITIONAL_SERVICE => 'ADDITIONAL_SERVICE', + self::MODIFIED_SERVICE => 'MODIFIED_SERVICE', + self::OTHER_EFFECT => 'OTHER_EFFECT', + self::UNKNOWN_EFFECT => 'UNKNOWN_EFFECT', + self::STOP_MOVED => 'STOP_MOVED', + self::NO_EFFECT => 'NO_EFFECT', + self::ACCESSIBILITY_ISSUE => 'ACCESSIBILITY_ISSUE', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + diff --git a/src/Google/Transit/Realtime/Alert/SeverityLevel.php b/src/Google/Transit/Realtime/Alert/SeverityLevel.php new file mode 100644 index 0000000..72dc092 --- /dev/null +++ b/src/Google/Transit/Realtime/Alert/SeverityLevel.php @@ -0,0 +1,59 @@ +transit_realtime.Alert.SeverityLevel + */ +class SeverityLevel +{ + /** + * Generated from protobuf enum UNKNOWN_SEVERITY = 0; + */ + const UNKNOWN_SEVERITY = 0; + /** + * Generated from protobuf enum INFO = 2; + */ + const INFO = 2; + /** + * Generated from protobuf enum WARNING = 3; + */ + const WARNING = 3; + /** + * Generated from protobuf enum SEVERE = 4; + */ + const SEVERE = 4; + + private static $valueToName = [ + self::UNKNOWN_SEVERITY => 'UNKNOWN_SEVERITY', + self::INFO => 'INFO', + self::WARNING => 'WARNING', + self::SEVERE => 'SEVERE', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + diff --git a/src/Google/Transit/Realtime/EntitySelector.php b/src/Google/Transit/Realtime/EntitySelector.php new file mode 100644 index 0000000..9e3dcf6 --- /dev/null +++ b/src/Google/Transit/Realtime/EntitySelector.php @@ -0,0 +1,205 @@ +transit_realtime.EntitySelector + */ +class EntitySelector extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field string agency_id = 1; + */ + protected $agency_id = ''; + /** + * Generated from protobuf field string route_id = 2; + */ + protected $route_id = ''; + /** + * Generated from protobuf field int32 route_type = 3; + */ + protected $route_type = 0; + /** + * Generated from protobuf field .transit_realtime.TripDescriptor trip = 4; + */ + protected $trip = null; + /** + * Generated from protobuf field string stop_id = 5; + */ + protected $stop_id = ''; + /** + * Generated from protobuf field uint32 direction_id = 6; + */ + protected $direction_id = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $agency_id + * @type string $route_id + * @type int $route_type + * @type \Google\Transit\Realtime\TripDescriptor $trip + * @type string $stop_id + * @type int $direction_id + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\GtfsRealtime::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field string agency_id = 1; + * @return string + */ + public function getAgencyId() + { + return $this->agency_id; + } + + /** + * Generated from protobuf field string agency_id = 1; + * @param string $var + * @return $this + */ + public function setAgencyId(string $var) + { + GPBUtil::checkString($var, true); + $this->agency_id = $var; + + return $this; + } + + /** + * Generated from protobuf field string route_id = 2; + * @return string + */ + public function getRouteId() + { + return $this->route_id; + } + + /** + * Generated from protobuf field string route_id = 2; + * @param string $var + * @return $this + */ + public function setRouteId(string $var) + { + GPBUtil::checkString($var, true); + $this->route_id = $var; + + return $this; + } + + /** + * Generated from protobuf field int32 route_type = 3; + * @return int + */ + public function getRouteType() + { + return $this->route_type; + } + + /** + * Generated from protobuf field int32 route_type = 3; + * @param int $var + * @return $this + */ + public function setRouteType(int $var) + { + GPBUtil::checkInt32($var); + $this->route_type = $var; + + return $this; + } + + /** + * Generated from protobuf field .transit_realtime.TripDescriptor trip = 4; + * @return \Google\Transit\Realtime\TripDescriptor|null + */ + public function getTrip() + { + return $this->trip; + } + + public function hasTrip() + { + return isset($this->trip); + } + + public function clearTrip() + { + unset($this->trip); + } + + /** + * Generated from protobuf field .transit_realtime.TripDescriptor trip = 4; + * @param \Google\Transit\Realtime\TripDescriptor $var + * @return $this + */ + public function setTrip(\Google\Transit\Realtime\TripDescriptor|null $var) + { + $this->trip = $var; + + return $this; + } + + /** + * Generated from protobuf field string stop_id = 5; + * @return string + */ + public function getStopId() + { + return $this->stop_id; + } + + /** + * Generated from protobuf field string stop_id = 5; + * @param string $var + * @return $this + */ + public function setStopId(string $var) + { + GPBUtil::checkString($var, true); + $this->stop_id = $var; + + return $this; + } + + /** + * Generated from protobuf field uint32 direction_id = 6; + * @return int + */ + public function getDirectionId() + { + return $this->direction_id; + } + + /** + * Generated from protobuf field uint32 direction_id = 6; + * @param int $var + * @return $this + */ + public function setDirectionId(int $var) + { + GPBUtil::checkUint32($var); + $this->direction_id = $var; + + return $this; + } + +} + diff --git a/src/Google/Transit/Realtime/FeedEntity.php b/src/Google/Transit/Realtime/FeedEntity.php new file mode 100644 index 0000000..6088805 --- /dev/null +++ b/src/Google/Transit/Realtime/FeedEntity.php @@ -0,0 +1,310 @@ +transit_realtime.FeedEntity + */ +class FeedEntity extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field string id = 1; + */ + protected $id = ''; + /** + * Generated from protobuf field bool is_deleted = 2; + */ + protected $is_deleted = false; + /** + * Generated from protobuf field .transit_realtime.TripUpdate trip_update = 3; + */ + protected $trip_update = null; + /** + * Generated from protobuf field .transit_realtime.VehiclePosition vehicle = 4; + */ + protected $vehicle = null; + /** + * Generated from protobuf field .transit_realtime.Alert alert = 5; + */ + protected $alert = null; + /** + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * + * Generated from protobuf field .transit_realtime.Shape shape = 6; + */ + protected $shape = null; + /** + * Generated from protobuf field .transit_realtime.Stop stop = 7; + */ + protected $stop = null; + /** + * Generated from protobuf field .transit_realtime.TripModifications trip_modifications = 8; + */ + protected $trip_modifications = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $id + * @type bool $is_deleted + * @type \Google\Transit\Realtime\TripUpdate $trip_update + * @type \Google\Transit\Realtime\VehiclePosition $vehicle + * @type \Google\Transit\Realtime\Alert $alert + * @type \Google\Transit\Realtime\Shape $shape + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * @type \Google\Transit\Realtime\Stop $stop + * @type \Google\Transit\Realtime\TripModifications $trip_modifications + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\GtfsRealtime::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field string id = 1; + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * Generated from protobuf field string id = 1; + * @param string $var + * @return $this + */ + public function setId(string $var) + { + GPBUtil::checkString($var, true); + $this->id = $var; + + return $this; + } + + /** + * Generated from protobuf field bool is_deleted = 2; + * @return bool + */ + public function getIsDeleted() + { + return $this->is_deleted; + } + + /** + * Generated from protobuf field bool is_deleted = 2; + * @param bool $var + * @return $this + */ + public function setIsDeleted(bool $var) + { + $this->is_deleted = $var; + + return $this; + } + + /** + * Generated from protobuf field .transit_realtime.TripUpdate trip_update = 3; + * @return \Google\Transit\Realtime\TripUpdate|null + */ + public function getTripUpdate() + { + return $this->trip_update; + } + + public function hasTripUpdate() + { + return isset($this->trip_update); + } + + public function clearTripUpdate() + { + unset($this->trip_update); + } + + /** + * Generated from protobuf field .transit_realtime.TripUpdate trip_update = 3; + * @param \Google\Transit\Realtime\TripUpdate $var + * @return $this + */ + public function setTripUpdate(\Google\Transit\Realtime\TripUpdate|null $var) + { + $this->trip_update = $var; + + return $this; + } + + /** + * Generated from protobuf field .transit_realtime.VehiclePosition vehicle = 4; + * @return \Google\Transit\Realtime\VehiclePosition|null + */ + public function getVehicle() + { + return $this->vehicle; + } + + public function hasVehicle() + { + return isset($this->vehicle); + } + + public function clearVehicle() + { + unset($this->vehicle); + } + + /** + * Generated from protobuf field .transit_realtime.VehiclePosition vehicle = 4; + * @param \Google\Transit\Realtime\VehiclePosition $var + * @return $this + */ + public function setVehicle(\Google\Transit\Realtime\VehiclePosition|null $var) + { + $this->vehicle = $var; + + return $this; + } + + /** + * Generated from protobuf field .transit_realtime.Alert alert = 5; + * @return \Google\Transit\Realtime\Alert|null + */ + public function getAlert() + { + return $this->alert; + } + + public function hasAlert() + { + return isset($this->alert); + } + + public function clearAlert() + { + unset($this->alert); + } + + /** + * Generated from protobuf field .transit_realtime.Alert alert = 5; + * @param \Google\Transit\Realtime\Alert $var + * @return $this + */ + public function setAlert(\Google\Transit\Realtime\Alert|null $var) + { + $this->alert = $var; + + return $this; + } + + /** + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * + * Generated from protobuf field .transit_realtime.Shape shape = 6; + * @return \Google\Transit\Realtime\Shape|null + */ + public function getShape() + { + return $this->shape; + } + + public function hasShape() + { + return isset($this->shape); + } + + public function clearShape() + { + unset($this->shape); + } + + /** + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * + * Generated from protobuf field .transit_realtime.Shape shape = 6; + * @param \Google\Transit\Realtime\Shape $var + * @return $this + */ + public function setShape(\Google\Transit\Realtime\Shape|null $var) + { + $this->shape = $var; + + return $this; + } + + /** + * Generated from protobuf field .transit_realtime.Stop stop = 7; + * @return \Google\Transit\Realtime\Stop|null + */ + public function getStop() + { + return $this->stop; + } + + public function hasStop() + { + return isset($this->stop); + } + + public function clearStop() + { + unset($this->stop); + } + + /** + * Generated from protobuf field .transit_realtime.Stop stop = 7; + * @param \Google\Transit\Realtime\Stop $var + * @return $this + */ + public function setStop(\Google\Transit\Realtime\Stop|null $var) + { + $this->stop = $var; + + return $this; + } + + /** + * Generated from protobuf field .transit_realtime.TripModifications trip_modifications = 8; + * @return \Google\Transit\Realtime\TripModifications|null + */ + public function getTripModifications() + { + return $this->trip_modifications; + } + + public function hasTripModifications() + { + return isset($this->trip_modifications); + } + + public function clearTripModifications() + { + unset($this->trip_modifications); + } + + /** + * Generated from protobuf field .transit_realtime.TripModifications trip_modifications = 8; + * @param \Google\Transit\Realtime\TripModifications $var + * @return $this + */ + public function setTripModifications(\Google\Transit\Realtime\TripModifications|null $var) + { + $this->trip_modifications = $var; + + return $this; + } + +} + diff --git a/src/Google/Transit/Realtime/FeedHeader.php b/src/Google/Transit/Realtime/FeedHeader.php new file mode 100644 index 0000000..4d7b4cc --- /dev/null +++ b/src/Google/Transit/Realtime/FeedHeader.php @@ -0,0 +1,142 @@ +transit_realtime.FeedHeader + */ +class FeedHeader extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field string gtfs_realtime_version = 1; + */ + protected $gtfs_realtime_version = ''; + /** + * Generated from protobuf field .transit_realtime.FeedHeader.Incrementality incrementality = 2; + */ + protected $incrementality = 0; + /** + * Generated from protobuf field uint64 timestamp = 3; + */ + protected $timestamp = 0; + /** + * Generated from protobuf field string feed_version = 4; + */ + protected $feed_version = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $gtfs_realtime_version + * @type int $incrementality + * @type int|string $timestamp + * @type string $feed_version + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\GtfsRealtime::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field string gtfs_realtime_version = 1; + * @return string + */ + public function getGtfsRealtimeVersion() + { + return $this->gtfs_realtime_version; + } + + /** + * Generated from protobuf field string gtfs_realtime_version = 1; + * @param string $var + * @return $this + */ + public function setGtfsRealtimeVersion(string $var) + { + GPBUtil::checkString($var, true); + $this->gtfs_realtime_version = $var; + + return $this; + } + + /** + * Generated from protobuf field .transit_realtime.FeedHeader.Incrementality incrementality = 2; + * @return int one of the values in {@see \Google\Transit\Realtime\FeedHeader\Incrementality} + */ + public function getIncrementality() + { + return $this->incrementality; + } + + /** + * Generated from protobuf field .transit_realtime.FeedHeader.Incrementality incrementality = 2; + * @param int $var one of the values in {@see \Google\Transit\Realtime\FeedHeader\Incrementality} + * @return $this + */ + public function setIncrementality(int $var) + { + GPBUtil::checkEnum($var, \Google\Transit\Realtime\FeedHeader\Incrementality::class); + $this->incrementality = $var; + + return $this; + } + + /** + * Generated from protobuf field uint64 timestamp = 3; + * @return int|string + */ + public function getTimestamp() + { + return $this->timestamp; + } + + /** + * Generated from protobuf field uint64 timestamp = 3; + * @param int|string $var + * @return $this + */ + public function setTimestamp(int|string $var) + { + GPBUtil::checkUint64($var); + $this->timestamp = $var; + + return $this; + } + + /** + * Generated from protobuf field string feed_version = 4; + * @return string + */ + public function getFeedVersion() + { + return $this->feed_version; + } + + /** + * Generated from protobuf field string feed_version = 4; + * @param string $var + * @return $this + */ + public function setFeedVersion(string $var) + { + GPBUtil::checkString($var, true); + $this->feed_version = $var; + + return $this; + } + +} + diff --git a/src/Google/Transit/Realtime/FeedHeader/Incrementality.php b/src/Google/Transit/Realtime/FeedHeader/Incrementality.php new file mode 100644 index 0000000..d4c423f --- /dev/null +++ b/src/Google/Transit/Realtime/FeedHeader/Incrementality.php @@ -0,0 +1,49 @@ +transit_realtime.FeedHeader.Incrementality + */ +class Incrementality +{ + /** + * Generated from protobuf enum FULL_DATASET = 0; + */ + const FULL_DATASET = 0; + /** + * Generated from protobuf enum DIFFERENTIAL = 1; + */ + const DIFFERENTIAL = 1; + + private static $valueToName = [ + self::FULL_DATASET => 'FULL_DATASET', + self::DIFFERENTIAL => 'DIFFERENTIAL', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + diff --git a/src/Google/Transit/Realtime/FeedMessage.php b/src/Google/Transit/Realtime/FeedMessage.php new file mode 100644 index 0000000..a4893f4 --- /dev/null +++ b/src/Google/Transit/Realtime/FeedMessage.php @@ -0,0 +1,97 @@ +transit_realtime.FeedMessage + */ +class FeedMessage extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field .transit_realtime.FeedHeader header = 1; + */ + protected $header = null; + /** + * Generated from protobuf field repeated .transit_realtime.FeedEntity entity = 2; + */ + private $entity; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Transit\Realtime\FeedHeader $header + * @type \Google\Transit\Realtime\FeedEntity[] $entity + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\GtfsRealtime::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field .transit_realtime.FeedHeader header = 1; + * @return \Google\Transit\Realtime\FeedHeader|null + */ + public function getHeader() + { + return $this->header; + } + + public function hasHeader() + { + return isset($this->header); + } + + public function clearHeader() + { + unset($this->header); + } + + /** + * Generated from protobuf field .transit_realtime.FeedHeader header = 1; + * @param \Google\Transit\Realtime\FeedHeader $var + * @return $this + */ + public function setHeader(\Google\Transit\Realtime\FeedHeader|null $var) + { + $this->header = $var; + + return $this; + } + + /** + * Generated from protobuf field repeated .transit_realtime.FeedEntity entity = 2; + * @return RepeatedField<\Google\Transit\Realtime\FeedEntity> + */ + public function getEntity() + { + return $this->entity; + } + + /** + * Generated from protobuf field repeated .transit_realtime.FeedEntity entity = 2; + * @param \Google\Transit\Realtime\FeedEntity[] $var + * @return $this + */ + public function setEntity(array|RepeatedField $var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Transit\Realtime\FeedEntity::class); + $this->entity = $arr; + + return $this; + } + +} + diff --git a/src/Google/Transit/Realtime/Position.php b/src/Google/Transit/Realtime/Position.php new file mode 100644 index 0000000..3515a14 --- /dev/null +++ b/src/Google/Transit/Realtime/Position.php @@ -0,0 +1,164 @@ +transit_realtime.Position + */ +class Position extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field float latitude = 1; + */ + protected $latitude = 0.0; + /** + * Generated from protobuf field float longitude = 2; + */ + protected $longitude = 0.0; + /** + * Generated from protobuf field float bearing = 3; + */ + protected $bearing = 0.0; + /** + * Generated from protobuf field double odometer = 4; + */ + protected $odometer = 0.0; + /** + * Generated from protobuf field float speed = 5; + */ + protected $speed = 0.0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type float $latitude + * @type float $longitude + * @type float $bearing + * @type float $odometer + * @type float $speed + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\GtfsRealtime::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field float latitude = 1; + * @return float + */ + public function getLatitude() + { + return $this->latitude; + } + + /** + * Generated from protobuf field float latitude = 1; + * @param float $var + * @return $this + */ + public function setLatitude(float $var) + { + $this->latitude = $var; + + return $this; + } + + /** + * Generated from protobuf field float longitude = 2; + * @return float + */ + public function getLongitude() + { + return $this->longitude; + } + + /** + * Generated from protobuf field float longitude = 2; + * @param float $var + * @return $this + */ + public function setLongitude(float $var) + { + $this->longitude = $var; + + return $this; + } + + /** + * Generated from protobuf field float bearing = 3; + * @return float + */ + public function getBearing() + { + return $this->bearing; + } + + /** + * Generated from protobuf field float bearing = 3; + * @param float $var + * @return $this + */ + public function setBearing(float $var) + { + $this->bearing = $var; + + return $this; + } + + /** + * Generated from protobuf field double odometer = 4; + * @return float + */ + public function getOdometer() + { + return $this->odometer; + } + + /** + * Generated from protobuf field double odometer = 4; + * @param float $var + * @return $this + */ + public function setOdometer(float $var) + { + $this->odometer = $var; + + return $this; + } + + /** + * Generated from protobuf field float speed = 5; + * @return float + */ + public function getSpeed() + { + return $this->speed; + } + + /** + * Generated from protobuf field float speed = 5; + * @param float $var + * @return $this + */ + public function setSpeed(float $var) + { + $this->speed = $var; + + return $this; + } + +} + diff --git a/src/Google/Transit/Realtime/ReplacementStop.php b/src/Google/Transit/Realtime/ReplacementStop.php new file mode 100644 index 0000000..d5628d9 --- /dev/null +++ b/src/Google/Transit/Realtime/ReplacementStop.php @@ -0,0 +1,88 @@ +transit_realtime.ReplacementStop + */ +class ReplacementStop extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field int32 travel_time_to_stop = 1; + */ + protected $travel_time_to_stop = 0; + /** + * Generated from protobuf field string stop_id = 2; + */ + protected $stop_id = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int $travel_time_to_stop + * @type string $stop_id + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\GtfsRealtime::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field int32 travel_time_to_stop = 1; + * @return int + */ + public function getTravelTimeToStop() + { + return $this->travel_time_to_stop; + } + + /** + * Generated from protobuf field int32 travel_time_to_stop = 1; + * @param int $var + * @return $this + */ + public function setTravelTimeToStop(int $var) + { + GPBUtil::checkInt32($var); + $this->travel_time_to_stop = $var; + + return $this; + } + + /** + * Generated from protobuf field string stop_id = 2; + * @return string + */ + public function getStopId() + { + return $this->stop_id; + } + + /** + * Generated from protobuf field string stop_id = 2; + * @param string $var + * @return $this + */ + public function setStopId(string $var) + { + GPBUtil::checkString($var, true); + $this->stop_id = $var; + + return $this; + } + +} + diff --git a/src/Google/Transit/Realtime/Shape.php b/src/Google/Transit/Realtime/Shape.php new file mode 100644 index 0000000..249aaf8 --- /dev/null +++ b/src/Google/Transit/Realtime/Shape.php @@ -0,0 +1,89 @@ +transit_realtime.Shape + */ +class Shape extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field string shape_id = 1; + */ + protected $shape_id = ''; + /** + * Generated from protobuf field string encoded_polyline = 2; + */ + protected $encoded_polyline = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $shape_id + * @type string $encoded_polyline + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\GtfsRealtime::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field string shape_id = 1; + * @return string + */ + public function getShapeId() + { + return $this->shape_id; + } + + /** + * Generated from protobuf field string shape_id = 1; + * @param string $var + * @return $this + */ + public function setShapeId(string $var) + { + GPBUtil::checkString($var, true); + $this->shape_id = $var; + + return $this; + } + + /** + * Generated from protobuf field string encoded_polyline = 2; + * @return string + */ + public function getEncodedPolyline() + { + return $this->encoded_polyline; + } + + /** + * Generated from protobuf field string encoded_polyline = 2; + * @param string $var + * @return $this + */ + public function setEncodedPolyline(string $var) + { + GPBUtil::checkString($var, true); + $this->encoded_polyline = $var; + + return $this; + } + +} + diff --git a/src/Google/Transit/Realtime/Stop.php b/src/Google/Transit/Realtime/Stop.php new file mode 100644 index 0000000..3e5bb14 --- /dev/null +++ b/src/Google/Transit/Realtime/Stop.php @@ -0,0 +1,465 @@ +transit_realtime.Stop + */ +class Stop extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field string stop_id = 1; + */ + protected $stop_id = ''; + /** + * Generated from protobuf field .transit_realtime.TranslatedString stop_code = 2; + */ + protected $stop_code = null; + /** + * Generated from protobuf field .transit_realtime.TranslatedString stop_name = 3; + */ + protected $stop_name = null; + /** + * Generated from protobuf field .transit_realtime.TranslatedString tts_stop_name = 4; + */ + protected $tts_stop_name = null; + /** + * Generated from protobuf field .transit_realtime.TranslatedString stop_desc = 5; + */ + protected $stop_desc = null; + /** + * Generated from protobuf field float stop_lat = 6; + */ + protected $stop_lat = 0.0; + /** + * Generated from protobuf field float stop_lon = 7; + */ + protected $stop_lon = 0.0; + /** + * Generated from protobuf field string zone_id = 8; + */ + protected $zone_id = ''; + /** + * Generated from protobuf field .transit_realtime.TranslatedString stop_url = 9; + */ + protected $stop_url = null; + /** + * Generated from protobuf field string parent_station = 11; + */ + protected $parent_station = ''; + /** + * Generated from protobuf field string stop_timezone = 12; + */ + protected $stop_timezone = ''; + /** + * Generated from protobuf field .transit_realtime.Stop.WheelchairBoarding wheelchair_boarding = 13; + */ + protected $wheelchair_boarding = 0; + /** + * Generated from protobuf field string level_id = 14; + */ + protected $level_id = ''; + /** + * Generated from protobuf field .transit_realtime.TranslatedString platform_code = 15; + */ + protected $platform_code = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $stop_id + * @type \Google\Transit\Realtime\TranslatedString $stop_code + * @type \Google\Transit\Realtime\TranslatedString $stop_name + * @type \Google\Transit\Realtime\TranslatedString $tts_stop_name + * @type \Google\Transit\Realtime\TranslatedString $stop_desc + * @type float $stop_lat + * @type float $stop_lon + * @type string $zone_id + * @type \Google\Transit\Realtime\TranslatedString $stop_url + * @type string $parent_station + * @type string $stop_timezone + * @type int $wheelchair_boarding + * @type string $level_id + * @type \Google\Transit\Realtime\TranslatedString $platform_code + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\GtfsRealtime::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field string stop_id = 1; + * @return string + */ + public function getStopId() + { + return $this->stop_id; + } + + /** + * Generated from protobuf field string stop_id = 1; + * @param string $var + * @return $this + */ + public function setStopId(string $var) + { + GPBUtil::checkString($var, true); + $this->stop_id = $var; + + return $this; + } + + /** + * Generated from protobuf field .transit_realtime.TranslatedString stop_code = 2; + * @return \Google\Transit\Realtime\TranslatedString|null + */ + public function getStopCode() + { + return $this->stop_code; + } + + public function hasStopCode() + { + return isset($this->stop_code); + } + + public function clearStopCode() + { + unset($this->stop_code); + } + + /** + * Generated from protobuf field .transit_realtime.TranslatedString stop_code = 2; + * @param \Google\Transit\Realtime\TranslatedString $var + * @return $this + */ + public function setStopCode(\Google\Transit\Realtime\TranslatedString|null $var) + { + $this->stop_code = $var; + + return $this; + } + + /** + * Generated from protobuf field .transit_realtime.TranslatedString stop_name = 3; + * @return \Google\Transit\Realtime\TranslatedString|null + */ + public function getStopName() + { + return $this->stop_name; + } + + public function hasStopName() + { + return isset($this->stop_name); + } + + public function clearStopName() + { + unset($this->stop_name); + } + + /** + * Generated from protobuf field .transit_realtime.TranslatedString stop_name = 3; + * @param \Google\Transit\Realtime\TranslatedString $var + * @return $this + */ + public function setStopName(\Google\Transit\Realtime\TranslatedString|null $var) + { + $this->stop_name = $var; + + return $this; + } + + /** + * Generated from protobuf field .transit_realtime.TranslatedString tts_stop_name = 4; + * @return \Google\Transit\Realtime\TranslatedString|null + */ + public function getTtsStopName() + { + return $this->tts_stop_name; + } + + public function hasTtsStopName() + { + return isset($this->tts_stop_name); + } + + public function clearTtsStopName() + { + unset($this->tts_stop_name); + } + + /** + * Generated from protobuf field .transit_realtime.TranslatedString tts_stop_name = 4; + * @param \Google\Transit\Realtime\TranslatedString $var + * @return $this + */ + public function setTtsStopName(\Google\Transit\Realtime\TranslatedString|null $var) + { + $this->tts_stop_name = $var; + + return $this; + } + + /** + * Generated from protobuf field .transit_realtime.TranslatedString stop_desc = 5; + * @return \Google\Transit\Realtime\TranslatedString|null + */ + public function getStopDesc() + { + return $this->stop_desc; + } + + public function hasStopDesc() + { + return isset($this->stop_desc); + } + + public function clearStopDesc() + { + unset($this->stop_desc); + } + + /** + * Generated from protobuf field .transit_realtime.TranslatedString stop_desc = 5; + * @param \Google\Transit\Realtime\TranslatedString $var + * @return $this + */ + public function setStopDesc(\Google\Transit\Realtime\TranslatedString|null $var) + { + $this->stop_desc = $var; + + return $this; + } + + /** + * Generated from protobuf field float stop_lat = 6; + * @return float + */ + public function getStopLat() + { + return $this->stop_lat; + } + + /** + * Generated from protobuf field float stop_lat = 6; + * @param float $var + * @return $this + */ + public function setStopLat(float $var) + { + $this->stop_lat = $var; + + return $this; + } + + /** + * Generated from protobuf field float stop_lon = 7; + * @return float + */ + public function getStopLon() + { + return $this->stop_lon; + } + + /** + * Generated from protobuf field float stop_lon = 7; + * @param float $var + * @return $this + */ + public function setStopLon(float $var) + { + $this->stop_lon = $var; + + return $this; + } + + /** + * Generated from protobuf field string zone_id = 8; + * @return string + */ + public function getZoneId() + { + return $this->zone_id; + } + + /** + * Generated from protobuf field string zone_id = 8; + * @param string $var + * @return $this + */ + public function setZoneId(string $var) + { + GPBUtil::checkString($var, true); + $this->zone_id = $var; + + return $this; + } + + /** + * Generated from protobuf field .transit_realtime.TranslatedString stop_url = 9; + * @return \Google\Transit\Realtime\TranslatedString|null + */ + public function getStopUrl() + { + return $this->stop_url; + } + + public function hasStopUrl() + { + return isset($this->stop_url); + } + + public function clearStopUrl() + { + unset($this->stop_url); + } + + /** + * Generated from protobuf field .transit_realtime.TranslatedString stop_url = 9; + * @param \Google\Transit\Realtime\TranslatedString $var + * @return $this + */ + public function setStopUrl(\Google\Transit\Realtime\TranslatedString|null $var) + { + $this->stop_url = $var; + + return $this; + } + + /** + * Generated from protobuf field string parent_station = 11; + * @return string + */ + public function getParentStation() + { + return $this->parent_station; + } + + /** + * Generated from protobuf field string parent_station = 11; + * @param string $var + * @return $this + */ + public function setParentStation(string $var) + { + GPBUtil::checkString($var, true); + $this->parent_station = $var; + + return $this; + } + + /** + * Generated from protobuf field string stop_timezone = 12; + * @return string + */ + public function getStopTimezone() + { + return $this->stop_timezone; + } + + /** + * Generated from protobuf field string stop_timezone = 12; + * @param string $var + * @return $this + */ + public function setStopTimezone(string $var) + { + GPBUtil::checkString($var, true); + $this->stop_timezone = $var; + + return $this; + } + + /** + * Generated from protobuf field .transit_realtime.Stop.WheelchairBoarding wheelchair_boarding = 13; + * @return int one of the values in {@see \Google\Transit\Realtime\Stop\WheelchairBoarding} + */ + public function getWheelchairBoarding() + { + return $this->wheelchair_boarding; + } + + /** + * Generated from protobuf field .transit_realtime.Stop.WheelchairBoarding wheelchair_boarding = 13; + * @param int $var one of the values in {@see \Google\Transit\Realtime\Stop\WheelchairBoarding} + * @return $this + */ + public function setWheelchairBoarding(int $var) + { + GPBUtil::checkEnum($var, \Google\Transit\Realtime\Stop\WheelchairBoarding::class); + $this->wheelchair_boarding = $var; + + return $this; + } + + /** + * Generated from protobuf field string level_id = 14; + * @return string + */ + public function getLevelId() + { + return $this->level_id; + } + + /** + * Generated from protobuf field string level_id = 14; + * @param string $var + * @return $this + */ + public function setLevelId(string $var) + { + GPBUtil::checkString($var, true); + $this->level_id = $var; + + return $this; + } + + /** + * Generated from protobuf field .transit_realtime.TranslatedString platform_code = 15; + * @return \Google\Transit\Realtime\TranslatedString|null + */ + public function getPlatformCode() + { + return $this->platform_code; + } + + public function hasPlatformCode() + { + return isset($this->platform_code); + } + + public function clearPlatformCode() + { + unset($this->platform_code); + } + + /** + * Generated from protobuf field .transit_realtime.TranslatedString platform_code = 15; + * @param \Google\Transit\Realtime\TranslatedString $var + * @return $this + */ + public function setPlatformCode(\Google\Transit\Realtime\TranslatedString|null $var) + { + $this->platform_code = $var; + + return $this; + } + +} + diff --git a/src/Google/Transit/Realtime/Stop/WheelchairBoarding.php b/src/Google/Transit/Realtime/Stop/WheelchairBoarding.php new file mode 100644 index 0000000..ee78230 --- /dev/null +++ b/src/Google/Transit/Realtime/Stop/WheelchairBoarding.php @@ -0,0 +1,54 @@ +transit_realtime.Stop.WheelchairBoarding + */ +class WheelchairBoarding +{ + /** + * Generated from protobuf enum UNKNOWN = 0; + */ + const UNKNOWN = 0; + /** + * Generated from protobuf enum AVAILABLE = 1; + */ + const AVAILABLE = 1; + /** + * Generated from protobuf enum NOT_AVAILABLE = 2; + */ + const NOT_AVAILABLE = 2; + + private static $valueToName = [ + self::UNKNOWN => 'UNKNOWN', + self::AVAILABLE => 'AVAILABLE', + self::NOT_AVAILABLE => 'NOT_AVAILABLE', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + diff --git a/src/Google/Transit/Realtime/StopSelector.php b/src/Google/Transit/Realtime/StopSelector.php new file mode 100644 index 0000000..ff040fa --- /dev/null +++ b/src/Google/Transit/Realtime/StopSelector.php @@ -0,0 +1,89 @@ +transit_realtime.StopSelector + */ +class StopSelector extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field uint32 stop_sequence = 1; + */ + protected $stop_sequence = 0; + /** + * Generated from protobuf field string stop_id = 2; + */ + protected $stop_id = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int $stop_sequence + * @type string $stop_id + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\GtfsRealtime::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field uint32 stop_sequence = 1; + * @return int + */ + public function getStopSequence() + { + return $this->stop_sequence; + } + + /** + * Generated from protobuf field uint32 stop_sequence = 1; + * @param int $var + * @return $this + */ + public function setStopSequence(int $var) + { + GPBUtil::checkUint32($var); + $this->stop_sequence = $var; + + return $this; + } + + /** + * Generated from protobuf field string stop_id = 2; + * @return string + */ + public function getStopId() + { + return $this->stop_id; + } + + /** + * Generated from protobuf field string stop_id = 2; + * @param string $var + * @return $this + */ + public function setStopId(string $var) + { + GPBUtil::checkString($var, true); + $this->stop_id = $var; + + return $this; + } + +} + diff --git a/src/Google/Transit/Realtime/TimeRange.php b/src/Google/Transit/Realtime/TimeRange.php new file mode 100644 index 0000000..9cc62d2 --- /dev/null +++ b/src/Google/Transit/Realtime/TimeRange.php @@ -0,0 +1,88 @@ +transit_realtime.TimeRange + */ +class TimeRange extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field uint64 start = 1; + */ + protected $start = 0; + /** + * Generated from protobuf field uint64 end = 2; + */ + protected $end = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int|string $start + * @type int|string $end + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\GtfsRealtime::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field uint64 start = 1; + * @return int|string + */ + public function getStart() + { + return $this->start; + } + + /** + * Generated from protobuf field uint64 start = 1; + * @param int|string $var + * @return $this + */ + public function setStart(int|string $var) + { + GPBUtil::checkUint64($var); + $this->start = $var; + + return $this; + } + + /** + * Generated from protobuf field uint64 end = 2; + * @return int|string + */ + public function getEnd() + { + return $this->end; + } + + /** + * Generated from protobuf field uint64 end = 2; + * @param int|string $var + * @return $this + */ + public function setEnd(int|string $var) + { + GPBUtil::checkUint64($var); + $this->end = $var; + + return $this; + } + +} + diff --git a/src/Google/Transit/Realtime/TranslatedImage.php b/src/Google/Transit/Realtime/TranslatedImage.php new file mode 100644 index 0000000..a9c436a --- /dev/null +++ b/src/Google/Transit/Realtime/TranslatedImage.php @@ -0,0 +1,62 @@ +transit_realtime.TranslatedImage + */ +class TranslatedImage extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field repeated .transit_realtime.TranslatedImage.LocalizedImage localized_image = 1; + */ + private $localized_image; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Transit\Realtime\TranslatedImage\LocalizedImage[] $localized_image + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\GtfsRealtime::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field repeated .transit_realtime.TranslatedImage.LocalizedImage localized_image = 1; + * @return RepeatedField<\Google\Transit\Realtime\TranslatedImage\LocalizedImage> + */ + public function getLocalizedImage() + { + return $this->localized_image; + } + + /** + * Generated from protobuf field repeated .transit_realtime.TranslatedImage.LocalizedImage localized_image = 1; + * @param \Google\Transit\Realtime\TranslatedImage\LocalizedImage[] $var + * @return $this + */ + public function setLocalizedImage(array|RepeatedField $var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Transit\Realtime\TranslatedImage\LocalizedImage::class); + $this->localized_image = $arr; + + return $this; + } + +} + diff --git a/src/Google/Transit/Realtime/TranslatedImage/LocalizedImage.php b/src/Google/Transit/Realtime/TranslatedImage/LocalizedImage.php new file mode 100644 index 0000000..f7287d7 --- /dev/null +++ b/src/Google/Transit/Realtime/TranslatedImage/LocalizedImage.php @@ -0,0 +1,113 @@ +transit_realtime.TranslatedImage.LocalizedImage + */ +class LocalizedImage extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field string url = 1; + */ + protected $url = ''; + /** + * Generated from protobuf field string media_type = 2; + */ + protected $media_type = ''; + /** + * Generated from protobuf field string language = 3; + */ + protected $language = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $url + * @type string $media_type + * @type string $language + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\GtfsRealtime::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field string url = 1; + * @return string + */ + public function getUrl() + { + return $this->url; + } + + /** + * Generated from protobuf field string url = 1; + * @param string $var + * @return $this + */ + public function setUrl(string $var) + { + GPBUtil::checkString($var, true); + $this->url = $var; + + return $this; + } + + /** + * Generated from protobuf field string media_type = 2; + * @return string + */ + public function getMediaType() + { + return $this->media_type; + } + + /** + * Generated from protobuf field string media_type = 2; + * @param string $var + * @return $this + */ + public function setMediaType(string $var) + { + GPBUtil::checkString($var, true); + $this->media_type = $var; + + return $this; + } + + /** + * Generated from protobuf field string language = 3; + * @return string + */ + public function getLanguage() + { + return $this->language; + } + + /** + * Generated from protobuf field string language = 3; + * @param string $var + * @return $this + */ + public function setLanguage(string $var) + { + GPBUtil::checkString($var, true); + $this->language = $var; + + return $this; + } + +} + diff --git a/src/Google/Transit/Realtime/TranslatedString.php b/src/Google/Transit/Realtime/TranslatedString.php new file mode 100644 index 0000000..e3ddb02 --- /dev/null +++ b/src/Google/Transit/Realtime/TranslatedString.php @@ -0,0 +1,61 @@ +transit_realtime.TranslatedString + */ +class TranslatedString extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field repeated .transit_realtime.TranslatedString.Translation translation = 1; + */ + private $translation; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Transit\Realtime\TranslatedString\Translation[] $translation + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\GtfsRealtime::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field repeated .transit_realtime.TranslatedString.Translation translation = 1; + * @return RepeatedField<\Google\Transit\Realtime\TranslatedString\Translation> + */ + public function getTranslation() + { + return $this->translation; + } + + /** + * Generated from protobuf field repeated .transit_realtime.TranslatedString.Translation translation = 1; + * @param \Google\Transit\Realtime\TranslatedString\Translation[] $var + * @return $this + */ + public function setTranslation(array|RepeatedField $var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Transit\Realtime\TranslatedString\Translation::class); + $this->translation = $arr; + + return $this; + } + +} + diff --git a/src/Google/Transit/Realtime/TranslatedString/Translation.php b/src/Google/Transit/Realtime/TranslatedString/Translation.php new file mode 100644 index 0000000..eeedb30 --- /dev/null +++ b/src/Google/Transit/Realtime/TranslatedString/Translation.php @@ -0,0 +1,86 @@ +transit_realtime.TranslatedString.Translation + */ +class Translation extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field string text = 1; + */ + protected $text = ''; + /** + * Generated from protobuf field string language = 2; + */ + protected $language = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $text + * @type string $language + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\GtfsRealtime::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field string text = 1; + * @return string + */ + public function getText() + { + return $this->text; + } + + /** + * Generated from protobuf field string text = 1; + * @param string $var + * @return $this + */ + public function setText(string $var) + { + GPBUtil::checkString($var, true); + $this->text = $var; + + return $this; + } + + /** + * Generated from protobuf field string language = 2; + * @return string + */ + public function getLanguage() + { + return $this->language; + } + + /** + * Generated from protobuf field string language = 2; + * @param string $var + * @return $this + */ + public function setLanguage(string $var) + { + GPBUtil::checkString($var, true); + $this->language = $var; + + return $this; + } + +} + diff --git a/src/Google/Transit/Realtime/TripDescriptor.php b/src/Google/Transit/Realtime/TripDescriptor.php new file mode 100644 index 0000000..a887dca --- /dev/null +++ b/src/Google/Transit/Realtime/TripDescriptor.php @@ -0,0 +1,239 @@ +transit_realtime.TripDescriptor + */ +class TripDescriptor extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field string trip_id = 1; + */ + protected $trip_id = ''; + /** + * Generated from protobuf field string route_id = 5; + */ + protected $route_id = ''; + /** + * Generated from protobuf field uint32 direction_id = 6; + */ + protected $direction_id = 0; + /** + * Generated from protobuf field string start_time = 2; + */ + protected $start_time = ''; + /** + * Generated from protobuf field string start_date = 3; + */ + protected $start_date = ''; + /** + * Generated from protobuf field .transit_realtime.TripDescriptor.ScheduleRelationship schedule_relationship = 4; + */ + protected $schedule_relationship = 0; + /** + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * + * Generated from protobuf field .transit_realtime.TripDescriptor.ModifiedTripSelector modified_trip = 7; + */ + protected $modified_trip = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $trip_id + * @type string $route_id + * @type int $direction_id + * @type string $start_time + * @type string $start_date + * @type int $schedule_relationship + * @type \Google\Transit\Realtime\TripDescriptor\ModifiedTripSelector $modified_trip + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\GtfsRealtime::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field string trip_id = 1; + * @return string + */ + public function getTripId() + { + return $this->trip_id; + } + + /** + * Generated from protobuf field string trip_id = 1; + * @param string $var + * @return $this + */ + public function setTripId(string $var) + { + GPBUtil::checkString($var, true); + $this->trip_id = $var; + + return $this; + } + + /** + * Generated from protobuf field string route_id = 5; + * @return string + */ + public function getRouteId() + { + return $this->route_id; + } + + /** + * Generated from protobuf field string route_id = 5; + * @param string $var + * @return $this + */ + public function setRouteId(string $var) + { + GPBUtil::checkString($var, true); + $this->route_id = $var; + + return $this; + } + + /** + * Generated from protobuf field uint32 direction_id = 6; + * @return int + */ + public function getDirectionId() + { + return $this->direction_id; + } + + /** + * Generated from protobuf field uint32 direction_id = 6; + * @param int $var + * @return $this + */ + public function setDirectionId(int $var) + { + GPBUtil::checkUint32($var); + $this->direction_id = $var; + + return $this; + } + + /** + * Generated from protobuf field string start_time = 2; + * @return string + */ + public function getStartTime() + { + return $this->start_time; + } + + /** + * Generated from protobuf field string start_time = 2; + * @param string $var + * @return $this + */ + public function setStartTime(string $var) + { + GPBUtil::checkString($var, true); + $this->start_time = $var; + + return $this; + } + + /** + * Generated from protobuf field string start_date = 3; + * @return string + */ + public function getStartDate() + { + return $this->start_date; + } + + /** + * Generated from protobuf field string start_date = 3; + * @param string $var + * @return $this + */ + public function setStartDate(string $var) + { + GPBUtil::checkString($var, true); + $this->start_date = $var; + + return $this; + } + + /** + * Generated from protobuf field .transit_realtime.TripDescriptor.ScheduleRelationship schedule_relationship = 4; + * @return int one of the values in {@see \Google\Transit\Realtime\TripDescriptor\ScheduleRelationship} + */ + public function getScheduleRelationship() + { + return $this->schedule_relationship; + } + + /** + * Generated from protobuf field .transit_realtime.TripDescriptor.ScheduleRelationship schedule_relationship = 4; + * @param int $var one of the values in {@see \Google\Transit\Realtime\TripDescriptor\ScheduleRelationship} + * @return $this + */ + public function setScheduleRelationship(int $var) + { + GPBUtil::checkEnum($var, \Google\Transit\Realtime\TripDescriptor\ScheduleRelationship::class); + $this->schedule_relationship = $var; + + return $this; + } + + /** + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * + * Generated from protobuf field .transit_realtime.TripDescriptor.ModifiedTripSelector modified_trip = 7; + * @return \Google\Transit\Realtime\TripDescriptor\ModifiedTripSelector|null + */ + public function getModifiedTrip() + { + return $this->modified_trip; + } + + public function hasModifiedTrip() + { + return isset($this->modified_trip); + } + + public function clearModifiedTrip() + { + unset($this->modified_trip); + } + + /** + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * + * Generated from protobuf field .transit_realtime.TripDescriptor.ModifiedTripSelector modified_trip = 7; + * @param \Google\Transit\Realtime\TripDescriptor\ModifiedTripSelector $var + * @return $this + */ + public function setModifiedTrip(\Google\Transit\Realtime\TripDescriptor\ModifiedTripSelector|null $var) + { + $this->modified_trip = $var; + + return $this; + } + +} + diff --git a/src/Google/Transit/Realtime/TripDescriptor/ModifiedTripSelector.php b/src/Google/Transit/Realtime/TripDescriptor/ModifiedTripSelector.php new file mode 100644 index 0000000..32e36c8 --- /dev/null +++ b/src/Google/Transit/Realtime/TripDescriptor/ModifiedTripSelector.php @@ -0,0 +1,140 @@ +transit_realtime.TripDescriptor.ModifiedTripSelector + */ +class ModifiedTripSelector extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field string modifications_id = 1; + */ + protected $modifications_id = ''; + /** + * Generated from protobuf field string affected_trip_id = 2; + */ + protected $affected_trip_id = ''; + /** + * Generated from protobuf field string start_time = 3; + */ + protected $start_time = ''; + /** + * Generated from protobuf field string start_date = 4; + */ + protected $start_date = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $modifications_id + * @type string $affected_trip_id + * @type string $start_time + * @type string $start_date + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\GtfsRealtime::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field string modifications_id = 1; + * @return string + */ + public function getModificationsId() + { + return $this->modifications_id; + } + + /** + * Generated from protobuf field string modifications_id = 1; + * @param string $var + * @return $this + */ + public function setModificationsId(string $var) + { + GPBUtil::checkString($var, true); + $this->modifications_id = $var; + + return $this; + } + + /** + * Generated from protobuf field string affected_trip_id = 2; + * @return string + */ + public function getAffectedTripId() + { + return $this->affected_trip_id; + } + + /** + * Generated from protobuf field string affected_trip_id = 2; + * @param string $var + * @return $this + */ + public function setAffectedTripId(string $var) + { + GPBUtil::checkString($var, true); + $this->affected_trip_id = $var; + + return $this; + } + + /** + * Generated from protobuf field string start_time = 3; + * @return string + */ + public function getStartTime() + { + return $this->start_time; + } + + /** + * Generated from protobuf field string start_time = 3; + * @param string $var + * @return $this + */ + public function setStartTime(string $var) + { + GPBUtil::checkString($var, true); + $this->start_time = $var; + + return $this; + } + + /** + * Generated from protobuf field string start_date = 4; + * @return string + */ + public function getStartDate() + { + return $this->start_date; + } + + /** + * Generated from protobuf field string start_date = 4; + * @param string $var + * @return $this + */ + public function setStartDate(string $var) + { + GPBUtil::checkString($var, true); + $this->start_date = $var; + + return $this; + } + +} + diff --git a/src/Google/Transit/Realtime/TripDescriptor/ScheduleRelationship.php b/src/Google/Transit/Realtime/TripDescriptor/ScheduleRelationship.php new file mode 100644 index 0000000..bcfd552 --- /dev/null +++ b/src/Google/Transit/Realtime/TripDescriptor/ScheduleRelationship.php @@ -0,0 +1,91 @@ +transit_realtime.TripDescriptor.ScheduleRelationship + */ +class ScheduleRelationship +{ + /** + * Generated from protobuf enum SCHEDULED = 0; + */ + const SCHEDULED = 0; + /** + * Generated from protobuf enum ADDED = 1 [deprecated = true]; + */ + const ADDED = 1; + /** + * Generated from protobuf enum UNSCHEDULED = 2; + */ + const UNSCHEDULED = 2; + /** + * Generated from protobuf enum CANCELED = 3; + */ + const CANCELED = 3; + /** + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * + * Generated from protobuf enum REPLACEMENT = 5; + */ + const REPLACEMENT = 5; + /** + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * + * Generated from protobuf enum DUPLICATED = 6; + */ + const DUPLICATED = 6; + /** + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * + * Generated from protobuf enum DELETED = 7; + */ + const DELETED = 7; + /** + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * + * Generated from protobuf enum NEW = 8; + */ + const PBNEW = 8; + + private static $valueToName = [ + self::SCHEDULED => 'SCHEDULED', + self::ADDED => 'ADDED', + self::UNSCHEDULED => 'UNSCHEDULED', + self::CANCELED => 'CANCELED', + self::REPLACEMENT => 'REPLACEMENT', + self::DUPLICATED => 'DUPLICATED', + self::DELETED => 'DELETED', + self::PBNEW => 'NEW', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + $pbconst = __CLASS__. '::PB' . strtoupper($name); + if (!defined($pbconst)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($pbconst); + } + return constant($const); + } +} + diff --git a/src/Google/Transit/Realtime/TripModifications.php b/src/Google/Transit/Realtime/TripModifications.php new file mode 100644 index 0000000..3a2a49e --- /dev/null +++ b/src/Google/Transit/Realtime/TripModifications.php @@ -0,0 +1,142 @@ +transit_realtime.TripModifications + */ +class TripModifications extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field repeated .transit_realtime.TripModifications.SelectedTrips selected_trips = 1; + */ + private $selected_trips; + /** + * Generated from protobuf field repeated string start_times = 2; + */ + private $start_times; + /** + * Generated from protobuf field repeated string service_dates = 3; + */ + private $service_dates; + /** + * Generated from protobuf field repeated .transit_realtime.TripModifications.Modification modifications = 4; + */ + private $modifications; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Transit\Realtime\TripModifications\SelectedTrips[] $selected_trips + * @type string[] $start_times + * @type string[] $service_dates + * @type \Google\Transit\Realtime\TripModifications\Modification[] $modifications + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\GtfsRealtime::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field repeated .transit_realtime.TripModifications.SelectedTrips selected_trips = 1; + * @return RepeatedField<\Google\Transit\Realtime\TripModifications\SelectedTrips> + */ + public function getSelectedTrips() + { + return $this->selected_trips; + } + + /** + * Generated from protobuf field repeated .transit_realtime.TripModifications.SelectedTrips selected_trips = 1; + * @param \Google\Transit\Realtime\TripModifications\SelectedTrips[] $var + * @return $this + */ + public function setSelectedTrips(array|RepeatedField $var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Transit\Realtime\TripModifications\SelectedTrips::class); + $this->selected_trips = $arr; + + return $this; + } + + /** + * Generated from protobuf field repeated string start_times = 2; + * @return RepeatedField + */ + public function getStartTimes() + { + return $this->start_times; + } + + /** + * Generated from protobuf field repeated string start_times = 2; + * @param string[] $var + * @return $this + */ + public function setStartTimes(array|RepeatedField $var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->start_times = $arr; + + return $this; + } + + /** + * Generated from protobuf field repeated string service_dates = 3; + * @return RepeatedField + */ + public function getServiceDates() + { + return $this->service_dates; + } + + /** + * Generated from protobuf field repeated string service_dates = 3; + * @param string[] $var + * @return $this + */ + public function setServiceDates(array|RepeatedField $var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->service_dates = $arr; + + return $this; + } + + /** + * Generated from protobuf field repeated .transit_realtime.TripModifications.Modification modifications = 4; + * @return RepeatedField<\Google\Transit\Realtime\TripModifications\Modification> + */ + public function getModifications() + { + return $this->modifications; + } + + /** + * Generated from protobuf field repeated .transit_realtime.TripModifications.Modification modifications = 4; + * @param \Google\Transit\Realtime\TripModifications\Modification[] $var + * @return $this + */ + public function setModifications(array|RepeatedField $var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Transit\Realtime\TripModifications\Modification::class); + $this->modifications = $arr; + + return $this; + } + +} + diff --git a/src/Google/Transit/Realtime/TripModifications/Modification.php b/src/Google/Transit/Realtime/TripModifications/Modification.php new file mode 100644 index 0000000..2edb8b2 --- /dev/null +++ b/src/Google/Transit/Realtime/TripModifications/Modification.php @@ -0,0 +1,212 @@ +transit_realtime.TripModifications.Modification + */ +class Modification extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field .transit_realtime.StopSelector start_stop_selector = 1; + */ + protected $start_stop_selector = null; + /** + * Generated from protobuf field .transit_realtime.StopSelector end_stop_selector = 2; + */ + protected $end_stop_selector = null; + /** + * Generated from protobuf field int32 propagated_modification_delay = 3; + */ + protected $propagated_modification_delay = 0; + /** + * Generated from protobuf field repeated .transit_realtime.ReplacementStop replacement_stops = 4; + */ + private $replacement_stops; + /** + * Generated from protobuf field string service_alert_id = 5; + */ + protected $service_alert_id = ''; + /** + * Generated from protobuf field uint64 last_modified_time = 6; + */ + protected $last_modified_time = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Transit\Realtime\StopSelector $start_stop_selector + * @type \Google\Transit\Realtime\StopSelector $end_stop_selector + * @type int $propagated_modification_delay + * @type \Google\Transit\Realtime\ReplacementStop[] $replacement_stops + * @type string $service_alert_id + * @type int|string $last_modified_time + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\GtfsRealtime::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field .transit_realtime.StopSelector start_stop_selector = 1; + * @return \Google\Transit\Realtime\StopSelector|null + */ + public function getStartStopSelector() + { + return $this->start_stop_selector; + } + + public function hasStartStopSelector() + { + return isset($this->start_stop_selector); + } + + public function clearStartStopSelector() + { + unset($this->start_stop_selector); + } + + /** + * Generated from protobuf field .transit_realtime.StopSelector start_stop_selector = 1; + * @param \Google\Transit\Realtime\StopSelector $var + * @return $this + */ + public function setStartStopSelector(\Google\Transit\Realtime\StopSelector|null $var) + { + $this->start_stop_selector = $var; + + return $this; + } + + /** + * Generated from protobuf field .transit_realtime.StopSelector end_stop_selector = 2; + * @return \Google\Transit\Realtime\StopSelector|null + */ + public function getEndStopSelector() + { + return $this->end_stop_selector; + } + + public function hasEndStopSelector() + { + return isset($this->end_stop_selector); + } + + public function clearEndStopSelector() + { + unset($this->end_stop_selector); + } + + /** + * Generated from protobuf field .transit_realtime.StopSelector end_stop_selector = 2; + * @param \Google\Transit\Realtime\StopSelector $var + * @return $this + */ + public function setEndStopSelector(\Google\Transit\Realtime\StopSelector|null $var) + { + $this->end_stop_selector = $var; + + return $this; + } + + /** + * Generated from protobuf field int32 propagated_modification_delay = 3; + * @return int + */ + public function getPropagatedModificationDelay() + { + return $this->propagated_modification_delay; + } + + /** + * Generated from protobuf field int32 propagated_modification_delay = 3; + * @param int $var + * @return $this + */ + public function setPropagatedModificationDelay(int $var) + { + GPBUtil::checkInt32($var); + $this->propagated_modification_delay = $var; + + return $this; + } + + /** + * Generated from protobuf field repeated .transit_realtime.ReplacementStop replacement_stops = 4; + * @return RepeatedField<\Google\Transit\Realtime\ReplacementStop> + */ + public function getReplacementStops() + { + return $this->replacement_stops; + } + + /** + * Generated from protobuf field repeated .transit_realtime.ReplacementStop replacement_stops = 4; + * @param \Google\Transit\Realtime\ReplacementStop[] $var + * @return $this + */ + public function setReplacementStops(array|RepeatedField $var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Transit\Realtime\ReplacementStop::class); + $this->replacement_stops = $arr; + + return $this; + } + + /** + * Generated from protobuf field string service_alert_id = 5; + * @return string + */ + public function getServiceAlertId() + { + return $this->service_alert_id; + } + + /** + * Generated from protobuf field string service_alert_id = 5; + * @param string $var + * @return $this + */ + public function setServiceAlertId(string $var) + { + GPBUtil::checkString($var, true); + $this->service_alert_id = $var; + + return $this; + } + + /** + * Generated from protobuf field uint64 last_modified_time = 6; + * @return int|string + */ + public function getLastModifiedTime() + { + return $this->last_modified_time; + } + + /** + * Generated from protobuf field uint64 last_modified_time = 6; + * @param int|string $var + * @return $this + */ + public function setLastModifiedTime(int|string $var) + { + GPBUtil::checkUint64($var); + $this->last_modified_time = $var; + + return $this; + } + +} + diff --git a/src/Google/Transit/Realtime/TripModifications/SelectedTrips.php b/src/Google/Transit/Realtime/TripModifications/SelectedTrips.php new file mode 100644 index 0000000..9cc50d2 --- /dev/null +++ b/src/Google/Transit/Realtime/TripModifications/SelectedTrips.php @@ -0,0 +1,86 @@ +transit_realtime.TripModifications.SelectedTrips + */ +class SelectedTrips extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field repeated string trip_ids = 1; + */ + private $trip_ids; + /** + * Generated from protobuf field string shape_id = 2; + */ + protected $shape_id = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string[] $trip_ids + * @type string $shape_id + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\GtfsRealtime::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field repeated string trip_ids = 1; + * @return RepeatedField + */ + public function getTripIds() + { + return $this->trip_ids; + } + + /** + * Generated from protobuf field repeated string trip_ids = 1; + * @param string[] $var + * @return $this + */ + public function setTripIds(array|RepeatedField $var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->trip_ids = $arr; + + return $this; + } + + /** + * Generated from protobuf field string shape_id = 2; + * @return string + */ + public function getShapeId() + { + return $this->shape_id; + } + + /** + * Generated from protobuf field string shape_id = 2; + * @param string $var + * @return $this + */ + public function setShapeId(string $var) + { + GPBUtil::checkString($var, true); + $this->shape_id = $var; + + return $this; + } + +} + diff --git a/src/Google/Transit/Realtime/TripUpdate.php b/src/Google/Transit/Realtime/TripUpdate.php new file mode 100644 index 0000000..59ce4a2 --- /dev/null +++ b/src/Google/Transit/Realtime/TripUpdate.php @@ -0,0 +1,230 @@ +transit_realtime.TripUpdate + */ +class TripUpdate extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field .transit_realtime.TripDescriptor trip = 1; + */ + protected $trip = null; + /** + * Generated from protobuf field .transit_realtime.VehicleDescriptor vehicle = 3; + */ + protected $vehicle = null; + /** + * Generated from protobuf field repeated .transit_realtime.TripUpdate.StopTimeUpdate stop_time_update = 2; + */ + private $stop_time_update; + /** + * Generated from protobuf field uint64 timestamp = 4; + */ + protected $timestamp = 0; + /** + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * + * Generated from protobuf field int32 delay = 5; + */ + protected $delay = 0; + /** + * Generated from protobuf field .transit_realtime.TripUpdate.TripProperties trip_properties = 6; + */ + protected $trip_properties = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Transit\Realtime\TripDescriptor $trip + * @type \Google\Transit\Realtime\VehicleDescriptor $vehicle + * @type \Google\Transit\Realtime\TripUpdate\StopTimeUpdate[] $stop_time_update + * @type int|string $timestamp + * @type int $delay + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * @type \Google\Transit\Realtime\TripUpdate\TripProperties $trip_properties + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\GtfsRealtime::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field .transit_realtime.TripDescriptor trip = 1; + * @return \Google\Transit\Realtime\TripDescriptor|null + */ + public function getTrip() + { + return $this->trip; + } + + public function hasTrip() + { + return isset($this->trip); + } + + public function clearTrip() + { + unset($this->trip); + } + + /** + * Generated from protobuf field .transit_realtime.TripDescriptor trip = 1; + * @param \Google\Transit\Realtime\TripDescriptor $var + * @return $this + */ + public function setTrip(\Google\Transit\Realtime\TripDescriptor|null $var) + { + $this->trip = $var; + + return $this; + } + + /** + * Generated from protobuf field .transit_realtime.VehicleDescriptor vehicle = 3; + * @return \Google\Transit\Realtime\VehicleDescriptor|null + */ + public function getVehicle() + { + return $this->vehicle; + } + + public function hasVehicle() + { + return isset($this->vehicle); + } + + public function clearVehicle() + { + unset($this->vehicle); + } + + /** + * Generated from protobuf field .transit_realtime.VehicleDescriptor vehicle = 3; + * @param \Google\Transit\Realtime\VehicleDescriptor $var + * @return $this + */ + public function setVehicle(\Google\Transit\Realtime\VehicleDescriptor|null $var) + { + $this->vehicle = $var; + + return $this; + } + + /** + * Generated from protobuf field repeated .transit_realtime.TripUpdate.StopTimeUpdate stop_time_update = 2; + * @return RepeatedField<\Google\Transit\Realtime\TripUpdate\StopTimeUpdate> + */ + public function getStopTimeUpdate() + { + return $this->stop_time_update; + } + + /** + * Generated from protobuf field repeated .transit_realtime.TripUpdate.StopTimeUpdate stop_time_update = 2; + * @param \Google\Transit\Realtime\TripUpdate\StopTimeUpdate[] $var + * @return $this + */ + public function setStopTimeUpdate(array|RepeatedField $var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Transit\Realtime\TripUpdate\StopTimeUpdate::class); + $this->stop_time_update = $arr; + + return $this; + } + + /** + * Generated from protobuf field uint64 timestamp = 4; + * @return int|string + */ + public function getTimestamp() + { + return $this->timestamp; + } + + /** + * Generated from protobuf field uint64 timestamp = 4; + * @param int|string $var + * @return $this + */ + public function setTimestamp(int|string $var) + { + GPBUtil::checkUint64($var); + $this->timestamp = $var; + + return $this; + } + + /** + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * + * Generated from protobuf field int32 delay = 5; + * @return int + */ + public function getDelay() + { + return $this->delay; + } + + /** + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * + * Generated from protobuf field int32 delay = 5; + * @param int $var + * @return $this + */ + public function setDelay(int $var) + { + GPBUtil::checkInt32($var); + $this->delay = $var; + + return $this; + } + + /** + * Generated from protobuf field .transit_realtime.TripUpdate.TripProperties trip_properties = 6; + * @return \Google\Transit\Realtime\TripUpdate\TripProperties|null + */ + public function getTripProperties() + { + return $this->trip_properties; + } + + public function hasTripProperties() + { + return isset($this->trip_properties); + } + + public function clearTripProperties() + { + unset($this->trip_properties); + } + + /** + * Generated from protobuf field .transit_realtime.TripUpdate.TripProperties trip_properties = 6; + * @param \Google\Transit\Realtime\TripUpdate\TripProperties $var + * @return $this + */ + public function setTripProperties(\Google\Transit\Realtime\TripUpdate\TripProperties|null $var) + { + $this->trip_properties = $var; + + return $this; + } + +} + diff --git a/src/Google/Transit/Realtime/TripUpdate/StopTimeEvent.php b/src/Google/Transit/Realtime/TripUpdate/StopTimeEvent.php new file mode 100644 index 0000000..973dae3 --- /dev/null +++ b/src/Google/Transit/Realtime/TripUpdate/StopTimeEvent.php @@ -0,0 +1,147 @@ +transit_realtime.TripUpdate.StopTimeEvent + */ +class StopTimeEvent extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field int32 delay = 1; + */ + protected $delay = 0; + /** + * Generated from protobuf field int64 time = 2; + */ + protected $time = 0; + /** + * Generated from protobuf field int32 uncertainty = 3; + */ + protected $uncertainty = 0; + /** + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * + * Generated from protobuf field int64 scheduled_time = 4; + */ + protected $scheduled_time = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int $delay + * @type int|string $time + * @type int $uncertainty + * @type int|string $scheduled_time + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\GtfsRealtime::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field int32 delay = 1; + * @return int + */ + public function getDelay() + { + return $this->delay; + } + + /** + * Generated from protobuf field int32 delay = 1; + * @param int $var + * @return $this + */ + public function setDelay(int $var) + { + GPBUtil::checkInt32($var); + $this->delay = $var; + + return $this; + } + + /** + * Generated from protobuf field int64 time = 2; + * @return int|string + */ + public function getTime() + { + return $this->time; + } + + /** + * Generated from protobuf field int64 time = 2; + * @param int|string $var + * @return $this + */ + public function setTime(int|string $var) + { + GPBUtil::checkInt64($var); + $this->time = $var; + + return $this; + } + + /** + * Generated from protobuf field int32 uncertainty = 3; + * @return int + */ + public function getUncertainty() + { + return $this->uncertainty; + } + + /** + * Generated from protobuf field int32 uncertainty = 3; + * @param int $var + * @return $this + */ + public function setUncertainty(int $var) + { + GPBUtil::checkInt32($var); + $this->uncertainty = $var; + + return $this; + } + + /** + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * + * Generated from protobuf field int64 scheduled_time = 4; + * @return int|string + */ + public function getScheduledTime() + { + return $this->scheduled_time; + } + + /** + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * + * Generated from protobuf field int64 scheduled_time = 4; + * @param int|string $var + * @return $this + */ + public function setScheduledTime(int|string $var) + { + GPBUtil::checkInt64($var); + $this->scheduled_time = $var; + + return $this; + } + +} + diff --git a/src/Google/Transit/Realtime/TripUpdate/StopTimeUpdate.php b/src/Google/Transit/Realtime/TripUpdate/StopTimeUpdate.php new file mode 100644 index 0000000..6648238 --- /dev/null +++ b/src/Google/Transit/Realtime/TripUpdate/StopTimeUpdate.php @@ -0,0 +1,255 @@ +transit_realtime.TripUpdate.StopTimeUpdate + */ +class StopTimeUpdate extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field uint32 stop_sequence = 1; + */ + protected $stop_sequence = 0; + /** + * Generated from protobuf field string stop_id = 4; + */ + protected $stop_id = ''; + /** + * Generated from protobuf field .transit_realtime.TripUpdate.StopTimeEvent arrival = 2; + */ + protected $arrival = null; + /** + * Generated from protobuf field .transit_realtime.TripUpdate.StopTimeEvent departure = 3; + */ + protected $departure = null; + /** + * Generated from protobuf field .transit_realtime.VehiclePosition.OccupancyStatus departure_occupancy_status = 7; + */ + protected $departure_occupancy_status = 0; + /** + * Generated from protobuf field .transit_realtime.TripUpdate.StopTimeUpdate.ScheduleRelationship schedule_relationship = 5; + */ + protected $schedule_relationship = 0; + /** + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * + * Generated from protobuf field .transit_realtime.TripUpdate.StopTimeUpdate.StopTimeProperties stop_time_properties = 6; + */ + protected $stop_time_properties = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int $stop_sequence + * @type string $stop_id + * @type \Google\Transit\Realtime\TripUpdate\StopTimeEvent $arrival + * @type \Google\Transit\Realtime\TripUpdate\StopTimeEvent $departure + * @type int $departure_occupancy_status + * @type int $schedule_relationship + * @type \Google\Transit\Realtime\TripUpdate\StopTimeUpdate\StopTimeProperties $stop_time_properties + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\GtfsRealtime::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field uint32 stop_sequence = 1; + * @return int + */ + public function getStopSequence() + { + return $this->stop_sequence; + } + + /** + * Generated from protobuf field uint32 stop_sequence = 1; + * @param int $var + * @return $this + */ + public function setStopSequence(int $var) + { + GPBUtil::checkUint32($var); + $this->stop_sequence = $var; + + return $this; + } + + /** + * Generated from protobuf field string stop_id = 4; + * @return string + */ + public function getStopId() + { + return $this->stop_id; + } + + /** + * Generated from protobuf field string stop_id = 4; + * @param string $var + * @return $this + */ + public function setStopId(string $var) + { + GPBUtil::checkString($var, true); + $this->stop_id = $var; + + return $this; + } + + /** + * Generated from protobuf field .transit_realtime.TripUpdate.StopTimeEvent arrival = 2; + * @return \Google\Transit\Realtime\TripUpdate\StopTimeEvent|null + */ + public function getArrival() + { + return $this->arrival; + } + + public function hasArrival() + { + return isset($this->arrival); + } + + public function clearArrival() + { + unset($this->arrival); + } + + /** + * Generated from protobuf field .transit_realtime.TripUpdate.StopTimeEvent arrival = 2; + * @param \Google\Transit\Realtime\TripUpdate\StopTimeEvent $var + * @return $this + */ + public function setArrival(\Google\Transit\Realtime\TripUpdate\StopTimeEvent|null $var) + { + $this->arrival = $var; + + return $this; + } + + /** + * Generated from protobuf field .transit_realtime.TripUpdate.StopTimeEvent departure = 3; + * @return \Google\Transit\Realtime\TripUpdate\StopTimeEvent|null + */ + public function getDeparture() + { + return $this->departure; + } + + public function hasDeparture() + { + return isset($this->departure); + } + + public function clearDeparture() + { + unset($this->departure); + } + + /** + * Generated from protobuf field .transit_realtime.TripUpdate.StopTimeEvent departure = 3; + * @param \Google\Transit\Realtime\TripUpdate\StopTimeEvent $var + * @return $this + */ + public function setDeparture(\Google\Transit\Realtime\TripUpdate\StopTimeEvent|null $var) + { + $this->departure = $var; + + return $this; + } + + /** + * Generated from protobuf field .transit_realtime.VehiclePosition.OccupancyStatus departure_occupancy_status = 7; + * @return int one of the values in {@see \Google\Transit\Realtime\VehiclePosition\OccupancyStatus} + */ + public function getDepartureOccupancyStatus() + { + return $this->departure_occupancy_status; + } + + /** + * Generated from protobuf field .transit_realtime.VehiclePosition.OccupancyStatus departure_occupancy_status = 7; + * @param int $var one of the values in {@see \Google\Transit\Realtime\VehiclePosition\OccupancyStatus} + * @return $this + */ + public function setDepartureOccupancyStatus(int $var) + { + GPBUtil::checkEnum($var, \Google\Transit\Realtime\VehiclePosition\OccupancyStatus::class); + $this->departure_occupancy_status = $var; + + return $this; + } + + /** + * Generated from protobuf field .transit_realtime.TripUpdate.StopTimeUpdate.ScheduleRelationship schedule_relationship = 5; + * @return int one of the values in {@see \Google\Transit\Realtime\TripUpdate\StopTimeUpdate\ScheduleRelationship} + */ + public function getScheduleRelationship() + { + return $this->schedule_relationship; + } + + /** + * Generated from protobuf field .transit_realtime.TripUpdate.StopTimeUpdate.ScheduleRelationship schedule_relationship = 5; + * @param int $var one of the values in {@see \Google\Transit\Realtime\TripUpdate\StopTimeUpdate\ScheduleRelationship} + * @return $this + */ + public function setScheduleRelationship(int $var) + { + GPBUtil::checkEnum($var, \Google\Transit\Realtime\TripUpdate\StopTimeUpdate\ScheduleRelationship::class); + $this->schedule_relationship = $var; + + return $this; + } + + /** + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * + * Generated from protobuf field .transit_realtime.TripUpdate.StopTimeUpdate.StopTimeProperties stop_time_properties = 6; + * @return \Google\Transit\Realtime\TripUpdate\StopTimeUpdate\StopTimeProperties|null + */ + public function getStopTimeProperties() + { + return $this->stop_time_properties; + } + + public function hasStopTimeProperties() + { + return isset($this->stop_time_properties); + } + + public function clearStopTimeProperties() + { + unset($this->stop_time_properties); + } + + /** + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * + * Generated from protobuf field .transit_realtime.TripUpdate.StopTimeUpdate.StopTimeProperties stop_time_properties = 6; + * @param \Google\Transit\Realtime\TripUpdate\StopTimeUpdate\StopTimeProperties $var + * @return $this + */ + public function setStopTimeProperties(\Google\Transit\Realtime\TripUpdate\StopTimeUpdate\StopTimeProperties|null $var) + { + $this->stop_time_properties = $var; + + return $this; + } + +} + diff --git a/src/Google/Transit/Realtime/TripUpdate/StopTimeUpdate/ScheduleRelationship.php b/src/Google/Transit/Realtime/TripUpdate/StopTimeUpdate/ScheduleRelationship.php new file mode 100644 index 0000000..4c79ecd --- /dev/null +++ b/src/Google/Transit/Realtime/TripUpdate/StopTimeUpdate/ScheduleRelationship.php @@ -0,0 +1,61 @@ +transit_realtime.TripUpdate.StopTimeUpdate.ScheduleRelationship + */ +class ScheduleRelationship +{ + /** + * Generated from protobuf enum SCHEDULED = 0; + */ + const SCHEDULED = 0; + /** + * Generated from protobuf enum SKIPPED = 1; + */ + const SKIPPED = 1; + /** + * Generated from protobuf enum NO_DATA = 2; + */ + const NO_DATA = 2; + /** + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * + * Generated from protobuf enum UNSCHEDULED = 3; + */ + const UNSCHEDULED = 3; + + private static $valueToName = [ + self::SCHEDULED => 'SCHEDULED', + self::SKIPPED => 'SKIPPED', + self::NO_DATA => 'NO_DATA', + self::UNSCHEDULED => 'UNSCHEDULED', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + diff --git a/src/Google/Transit/Realtime/TripUpdate/StopTimeUpdate/StopTimeProperties.php b/src/Google/Transit/Realtime/TripUpdate/StopTimeUpdate/StopTimeProperties.php new file mode 100644 index 0000000..e7fc07c --- /dev/null +++ b/src/Google/Transit/Realtime/TripUpdate/StopTimeUpdate/StopTimeProperties.php @@ -0,0 +1,163 @@ +transit_realtime.TripUpdate.StopTimeUpdate.StopTimeProperties + */ +class StopTimeProperties extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field string assigned_stop_id = 1; + */ + protected $assigned_stop_id = ''; + /** + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * + * Generated from protobuf field string stop_headsign = 2; + */ + protected $stop_headsign = ''; + /** + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * + * Generated from protobuf field .transit_realtime.TripUpdate.StopTimeUpdate.StopTimeProperties.DropOffPickupType pickup_type = 3; + */ + protected $pickup_type = 0; + /** + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * + * Generated from protobuf field .transit_realtime.TripUpdate.StopTimeUpdate.StopTimeProperties.DropOffPickupType drop_off_type = 4; + */ + protected $drop_off_type = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $assigned_stop_id + * @type string $stop_headsign + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * @type int $pickup_type + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * @type int $drop_off_type + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\GtfsRealtime::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field string assigned_stop_id = 1; + * @return string + */ + public function getAssignedStopId() + { + return $this->assigned_stop_id; + } + + /** + * Generated from protobuf field string assigned_stop_id = 1; + * @param string $var + * @return $this + */ + public function setAssignedStopId(string $var) + { + GPBUtil::checkString($var, true); + $this->assigned_stop_id = $var; + + return $this; + } + + /** + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * + * Generated from protobuf field string stop_headsign = 2; + * @return string + */ + public function getStopHeadsign() + { + return $this->stop_headsign; + } + + /** + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * + * Generated from protobuf field string stop_headsign = 2; + * @param string $var + * @return $this + */ + public function setStopHeadsign(string $var) + { + GPBUtil::checkString($var, true); + $this->stop_headsign = $var; + + return $this; + } + + /** + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * + * Generated from protobuf field .transit_realtime.TripUpdate.StopTimeUpdate.StopTimeProperties.DropOffPickupType pickup_type = 3; + * @return int one of the values in {@see \Google\Transit\Realtime\TripUpdate\StopTimeUpdate\StopTimeProperties\DropOffPickupType} + */ + public function getPickupType() + { + return $this->pickup_type; + } + + /** + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * + * Generated from protobuf field .transit_realtime.TripUpdate.StopTimeUpdate.StopTimeProperties.DropOffPickupType pickup_type = 3; + * @param int $var one of the values in {@see \Google\Transit\Realtime\TripUpdate\StopTimeUpdate\StopTimeProperties\DropOffPickupType} + * @return $this + */ + public function setPickupType(int $var) + { + GPBUtil::checkEnum($var, \Google\Transit\Realtime\TripUpdate\StopTimeUpdate\StopTimeProperties\DropOffPickupType::class); + $this->pickup_type = $var; + + return $this; + } + + /** + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * + * Generated from protobuf field .transit_realtime.TripUpdate.StopTimeUpdate.StopTimeProperties.DropOffPickupType drop_off_type = 4; + * @return int one of the values in {@see \Google\Transit\Realtime\TripUpdate\StopTimeUpdate\StopTimeProperties\DropOffPickupType} + */ + public function getDropOffType() + { + return $this->drop_off_type; + } + + /** + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * + * Generated from protobuf field .transit_realtime.TripUpdate.StopTimeUpdate.StopTimeProperties.DropOffPickupType drop_off_type = 4; + * @param int $var one of the values in {@see \Google\Transit\Realtime\TripUpdate\StopTimeUpdate\StopTimeProperties\DropOffPickupType} + * @return $this + */ + public function setDropOffType(int $var) + { + GPBUtil::checkEnum($var, \Google\Transit\Realtime\TripUpdate\StopTimeUpdate\StopTimeProperties\DropOffPickupType::class); + $this->drop_off_type = $var; + + return $this; + } + +} + diff --git a/src/Google/Transit/Realtime/TripUpdate/StopTimeUpdate/StopTimeProperties/DropOffPickupType.php b/src/Google/Transit/Realtime/TripUpdate/StopTimeUpdate/StopTimeProperties/DropOffPickupType.php new file mode 100644 index 0000000..5a8a9f9 --- /dev/null +++ b/src/Google/Transit/Realtime/TripUpdate/StopTimeUpdate/StopTimeProperties/DropOffPickupType.php @@ -0,0 +1,59 @@ +transit_realtime.TripUpdate.StopTimeUpdate.StopTimeProperties.DropOffPickupType + */ +class DropOffPickupType +{ + /** + * Generated from protobuf enum REGULAR = 0; + */ + const REGULAR = 0; + /** + * Generated from protobuf enum NONE = 1; + */ + const NONE = 1; + /** + * Generated from protobuf enum PHONE_AGENCY = 2; + */ + const PHONE_AGENCY = 2; + /** + * Generated from protobuf enum COORDINATE_WITH_DRIVER = 3; + */ + const COORDINATE_WITH_DRIVER = 3; + + private static $valueToName = [ + self::REGULAR => 'REGULAR', + self::NONE => 'NONE', + self::PHONE_AGENCY => 'PHONE_AGENCY', + self::COORDINATE_WITH_DRIVER => 'COORDINATE_WITH_DRIVER', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + diff --git a/src/Google/Transit/Realtime/TripUpdate/TripProperties.php b/src/Google/Transit/Realtime/TripUpdate/TripProperties.php new file mode 100644 index 0000000..cd3b1fd --- /dev/null +++ b/src/Google/Transit/Realtime/TripUpdate/TripProperties.php @@ -0,0 +1,210 @@ +transit_realtime.TripUpdate.TripProperties + */ +class TripProperties extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field string trip_id = 1; + */ + protected $trip_id = ''; + /** + * Generated from protobuf field string start_date = 2; + */ + protected $start_date = ''; + /** + * Generated from protobuf field string start_time = 3; + */ + protected $start_time = ''; + /** + * Generated from protobuf field string shape_id = 4; + */ + protected $shape_id = ''; + /** + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * + * Generated from protobuf field string trip_headsign = 5; + */ + protected $trip_headsign = ''; + /** + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * + * Generated from protobuf field string trip_short_name = 6; + */ + protected $trip_short_name = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $trip_id + * @type string $start_date + * @type string $start_time + * @type string $shape_id + * @type string $trip_headsign + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * @type string $trip_short_name + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\GtfsRealtime::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field string trip_id = 1; + * @return string + */ + public function getTripId() + { + return $this->trip_id; + } + + /** + * Generated from protobuf field string trip_id = 1; + * @param string $var + * @return $this + */ + public function setTripId(string $var) + { + GPBUtil::checkString($var, true); + $this->trip_id = $var; + + return $this; + } + + /** + * Generated from protobuf field string start_date = 2; + * @return string + */ + public function getStartDate() + { + return $this->start_date; + } + + /** + * Generated from protobuf field string start_date = 2; + * @param string $var + * @return $this + */ + public function setStartDate(string $var) + { + GPBUtil::checkString($var, true); + $this->start_date = $var; + + return $this; + } + + /** + * Generated from protobuf field string start_time = 3; + * @return string + */ + public function getStartTime() + { + return $this->start_time; + } + + /** + * Generated from protobuf field string start_time = 3; + * @param string $var + * @return $this + */ + public function setStartTime(string $var) + { + GPBUtil::checkString($var, true); + $this->start_time = $var; + + return $this; + } + + /** + * Generated from protobuf field string shape_id = 4; + * @return string + */ + public function getShapeId() + { + return $this->shape_id; + } + + /** + * Generated from protobuf field string shape_id = 4; + * @param string $var + * @return $this + */ + public function setShapeId(string $var) + { + GPBUtil::checkString($var, true); + $this->shape_id = $var; + + return $this; + } + + /** + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * + * Generated from protobuf field string trip_headsign = 5; + * @return string + */ + public function getTripHeadsign() + { + return $this->trip_headsign; + } + + /** + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * + * Generated from protobuf field string trip_headsign = 5; + * @param string $var + * @return $this + */ + public function setTripHeadsign(string $var) + { + GPBUtil::checkString($var, true); + $this->trip_headsign = $var; + + return $this; + } + + /** + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * + * Generated from protobuf field string trip_short_name = 6; + * @return string + */ + public function getTripShortName() + { + return $this->trip_short_name; + } + + /** + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * + * Generated from protobuf field string trip_short_name = 6; + * @param string $var + * @return $this + */ + public function setTripShortName(string $var) + { + GPBUtil::checkString($var, true); + $this->trip_short_name = $var; + + return $this; + } + +} + diff --git a/src/Google/Transit/Realtime/VehicleDescriptor.php b/src/Google/Transit/Realtime/VehicleDescriptor.php new file mode 100644 index 0000000..e73270c --- /dev/null +++ b/src/Google/Transit/Realtime/VehicleDescriptor.php @@ -0,0 +1,142 @@ +transit_realtime.VehicleDescriptor + */ +class VehicleDescriptor extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field string id = 1; + */ + protected $id = ''; + /** + * Generated from protobuf field string label = 2; + */ + protected $label = ''; + /** + * Generated from protobuf field string license_plate = 3; + */ + protected $license_plate = ''; + /** + * Generated from protobuf field .transit_realtime.VehicleDescriptor.WheelchairAccessible wheelchair_accessible = 4; + */ + protected $wheelchair_accessible = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $id + * @type string $label + * @type string $license_plate + * @type int $wheelchair_accessible + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\GtfsRealtime::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field string id = 1; + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * Generated from protobuf field string id = 1; + * @param string $var + * @return $this + */ + public function setId(string $var) + { + GPBUtil::checkString($var, true); + $this->id = $var; + + return $this; + } + + /** + * Generated from protobuf field string label = 2; + * @return string + */ + public function getLabel() + { + return $this->label; + } + + /** + * Generated from protobuf field string label = 2; + * @param string $var + * @return $this + */ + public function setLabel(string $var) + { + GPBUtil::checkString($var, true); + $this->label = $var; + + return $this; + } + + /** + * Generated from protobuf field string license_plate = 3; + * @return string + */ + public function getLicensePlate() + { + return $this->license_plate; + } + + /** + * Generated from protobuf field string license_plate = 3; + * @param string $var + * @return $this + */ + public function setLicensePlate(string $var) + { + GPBUtil::checkString($var, true); + $this->license_plate = $var; + + return $this; + } + + /** + * Generated from protobuf field .transit_realtime.VehicleDescriptor.WheelchairAccessible wheelchair_accessible = 4; + * @return int one of the values in {@see \Google\Transit\Realtime\VehicleDescriptor\WheelchairAccessible} + */ + public function getWheelchairAccessible() + { + return $this->wheelchair_accessible; + } + + /** + * Generated from protobuf field .transit_realtime.VehicleDescriptor.WheelchairAccessible wheelchair_accessible = 4; + * @param int $var one of the values in {@see \Google\Transit\Realtime\VehicleDescriptor\WheelchairAccessible} + * @return $this + */ + public function setWheelchairAccessible(int $var) + { + GPBUtil::checkEnum($var, \Google\Transit\Realtime\VehicleDescriptor\WheelchairAccessible::class); + $this->wheelchair_accessible = $var; + + return $this; + } + +} + diff --git a/src/Google/Transit/Realtime/VehicleDescriptor/WheelchairAccessible.php b/src/Google/Transit/Realtime/VehicleDescriptor/WheelchairAccessible.php new file mode 100644 index 0000000..142fd80 --- /dev/null +++ b/src/Google/Transit/Realtime/VehicleDescriptor/WheelchairAccessible.php @@ -0,0 +1,59 @@ +transit_realtime.VehicleDescriptor.WheelchairAccessible + */ +class WheelchairAccessible +{ + /** + * Generated from protobuf enum NO_VALUE = 0; + */ + const NO_VALUE = 0; + /** + * Generated from protobuf enum UNKNOWN = 1; + */ + const UNKNOWN = 1; + /** + * Generated from protobuf enum WHEELCHAIR_ACCESSIBLE = 2; + */ + const WHEELCHAIR_ACCESSIBLE = 2; + /** + * Generated from protobuf enum WHEELCHAIR_INACCESSIBLE = 3; + */ + const WHEELCHAIR_INACCESSIBLE = 3; + + private static $valueToName = [ + self::NO_VALUE => 'NO_VALUE', + self::UNKNOWN => 'UNKNOWN', + self::WHEELCHAIR_ACCESSIBLE => 'WHEELCHAIR_ACCESSIBLE', + self::WHEELCHAIR_INACCESSIBLE => 'WHEELCHAIR_INACCESSIBLE', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + diff --git a/src/Google/Transit/Realtime/VehiclePosition.php b/src/Google/Transit/Realtime/VehiclePosition.php new file mode 100644 index 0000000..365f830 --- /dev/null +++ b/src/Google/Transit/Realtime/VehiclePosition.php @@ -0,0 +1,372 @@ +transit_realtime.VehiclePosition + */ +class VehiclePosition extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field .transit_realtime.TripDescriptor trip = 1; + */ + protected $trip = null; + /** + * Generated from protobuf field .transit_realtime.VehicleDescriptor vehicle = 8; + */ + protected $vehicle = null; + /** + * Generated from protobuf field .transit_realtime.Position position = 2; + */ + protected $position = null; + /** + * Generated from protobuf field uint32 current_stop_sequence = 3; + */ + protected $current_stop_sequence = 0; + /** + * Generated from protobuf field string stop_id = 7; + */ + protected $stop_id = ''; + /** + * Generated from protobuf field .transit_realtime.VehiclePosition.VehicleStopStatus current_status = 4; + */ + protected $current_status = 0; + /** + * Generated from protobuf field uint64 timestamp = 5; + */ + protected $timestamp = 0; + /** + * Generated from protobuf field .transit_realtime.VehiclePosition.CongestionLevel congestion_level = 6; + */ + protected $congestion_level = 0; + /** + * Generated from protobuf field .transit_realtime.VehiclePosition.OccupancyStatus occupancy_status = 9; + */ + protected $occupancy_status = 0; + /** + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * + * Generated from protobuf field uint32 occupancy_percentage = 10; + */ + protected $occupancy_percentage = 0; + /** + * NOTE: This message/field is still experimental, and subject to change. It may be formally adopted in the future. + * + * Generated from protobuf field repeated .transit_realtime.VehiclePosition.CarriageDetails multi_carriage_details = 11; + */ + private $multi_carriage_details; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Transit\Realtime\TripDescriptor $trip + * @type \Google\Transit\Realtime\VehicleDescriptor $vehicle + * @type \Google\Transit\Realtime\Position $position + * @type int $current_stop_sequence + * @type string $stop_id + * @type int $current_status + * @type int|string $timestamp + * @type int $congestion_level + * @type int $occupancy_status + * @type int $occupancy_percentage + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * @type \Google\Transit\Realtime\VehiclePosition\CarriageDetails[] $multi_carriage_details + * NOTE: This message/field is still experimental, and subject to change. It may be formally adopted in the future. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\GtfsRealtime::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field .transit_realtime.TripDescriptor trip = 1; + * @return \Google\Transit\Realtime\TripDescriptor|null + */ + public function getTrip() + { + return $this->trip; + } + + public function hasTrip() + { + return isset($this->trip); + } + + public function clearTrip() + { + unset($this->trip); + } + + /** + * Generated from protobuf field .transit_realtime.TripDescriptor trip = 1; + * @param \Google\Transit\Realtime\TripDescriptor $var + * @return $this + */ + public function setTrip(\Google\Transit\Realtime\TripDescriptor|null $var) + { + $this->trip = $var; + + return $this; + } + + /** + * Generated from protobuf field .transit_realtime.VehicleDescriptor vehicle = 8; + * @return \Google\Transit\Realtime\VehicleDescriptor|null + */ + public function getVehicle() + { + return $this->vehicle; + } + + public function hasVehicle() + { + return isset($this->vehicle); + } + + public function clearVehicle() + { + unset($this->vehicle); + } + + /** + * Generated from protobuf field .transit_realtime.VehicleDescriptor vehicle = 8; + * @param \Google\Transit\Realtime\VehicleDescriptor $var + * @return $this + */ + public function setVehicle(\Google\Transit\Realtime\VehicleDescriptor|null $var) + { + $this->vehicle = $var; + + return $this; + } + + /** + * Generated from protobuf field .transit_realtime.Position position = 2; + * @return \Google\Transit\Realtime\Position|null + */ + public function getPosition() + { + return $this->position; + } + + public function hasPosition() + { + return isset($this->position); + } + + public function clearPosition() + { + unset($this->position); + } + + /** + * Generated from protobuf field .transit_realtime.Position position = 2; + * @param \Google\Transit\Realtime\Position $var + * @return $this + */ + public function setPosition(\Google\Transit\Realtime\Position|null $var) + { + $this->position = $var; + + return $this; + } + + /** + * Generated from protobuf field uint32 current_stop_sequence = 3; + * @return int + */ + public function getCurrentStopSequence() + { + return $this->current_stop_sequence; + } + + /** + * Generated from protobuf field uint32 current_stop_sequence = 3; + * @param int $var + * @return $this + */ + public function setCurrentStopSequence(int $var) + { + GPBUtil::checkUint32($var); + $this->current_stop_sequence = $var; + + return $this; + } + + /** + * Generated from protobuf field string stop_id = 7; + * @return string + */ + public function getStopId() + { + return $this->stop_id; + } + + /** + * Generated from protobuf field string stop_id = 7; + * @param string $var + * @return $this + */ + public function setStopId(string $var) + { + GPBUtil::checkString($var, true); + $this->stop_id = $var; + + return $this; + } + + /** + * Generated from protobuf field .transit_realtime.VehiclePosition.VehicleStopStatus current_status = 4; + * @return int one of the values in {@see \Google\Transit\Realtime\VehiclePosition\VehicleStopStatus} + */ + public function getCurrentStatus() + { + return $this->current_status; + } + + /** + * Generated from protobuf field .transit_realtime.VehiclePosition.VehicleStopStatus current_status = 4; + * @param int $var one of the values in {@see \Google\Transit\Realtime\VehiclePosition\VehicleStopStatus} + * @return $this + */ + public function setCurrentStatus(int $var) + { + GPBUtil::checkEnum($var, \Google\Transit\Realtime\VehiclePosition\VehicleStopStatus::class); + $this->current_status = $var; + + return $this; + } + + /** + * Generated from protobuf field uint64 timestamp = 5; + * @return int|string + */ + public function getTimestamp() + { + return $this->timestamp; + } + + /** + * Generated from protobuf field uint64 timestamp = 5; + * @param int|string $var + * @return $this + */ + public function setTimestamp(int|string $var) + { + GPBUtil::checkUint64($var); + $this->timestamp = $var; + + return $this; + } + + /** + * Generated from protobuf field .transit_realtime.VehiclePosition.CongestionLevel congestion_level = 6; + * @return int one of the values in {@see \Google\Transit\Realtime\VehiclePosition\CongestionLevel} + */ + public function getCongestionLevel() + { + return $this->congestion_level; + } + + /** + * Generated from protobuf field .transit_realtime.VehiclePosition.CongestionLevel congestion_level = 6; + * @param int $var one of the values in {@see \Google\Transit\Realtime\VehiclePosition\CongestionLevel} + * @return $this + */ + public function setCongestionLevel(int $var) + { + GPBUtil::checkEnum($var, \Google\Transit\Realtime\VehiclePosition\CongestionLevel::class); + $this->congestion_level = $var; + + return $this; + } + + /** + * Generated from protobuf field .transit_realtime.VehiclePosition.OccupancyStatus occupancy_status = 9; + * @return int one of the values in {@see \Google\Transit\Realtime\VehiclePosition\OccupancyStatus} + */ + public function getOccupancyStatus() + { + return $this->occupancy_status; + } + + /** + * Generated from protobuf field .transit_realtime.VehiclePosition.OccupancyStatus occupancy_status = 9; + * @param int $var one of the values in {@see \Google\Transit\Realtime\VehiclePosition\OccupancyStatus} + * @return $this + */ + public function setOccupancyStatus(int $var) + { + GPBUtil::checkEnum($var, \Google\Transit\Realtime\VehiclePosition\OccupancyStatus::class); + $this->occupancy_status = $var; + + return $this; + } + + /** + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * + * Generated from protobuf field uint32 occupancy_percentage = 10; + * @return int + */ + public function getOccupancyPercentage() + { + return $this->occupancy_percentage; + } + + /** + * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. + * + * Generated from protobuf field uint32 occupancy_percentage = 10; + * @param int $var + * @return $this + */ + public function setOccupancyPercentage(int $var) + { + GPBUtil::checkUint32($var); + $this->occupancy_percentage = $var; + + return $this; + } + + /** + * NOTE: This message/field is still experimental, and subject to change. It may be formally adopted in the future. + * + * Generated from protobuf field repeated .transit_realtime.VehiclePosition.CarriageDetails multi_carriage_details = 11; + * @return RepeatedField<\Google\Transit\Realtime\VehiclePosition\CarriageDetails> + */ + public function getMultiCarriageDetails() + { + return $this->multi_carriage_details; + } + + /** + * NOTE: This message/field is still experimental, and subject to change. It may be formally adopted in the future. + * + * Generated from protobuf field repeated .transit_realtime.VehiclePosition.CarriageDetails multi_carriage_details = 11; + * @param \Google\Transit\Realtime\VehiclePosition\CarriageDetails[] $var + * @return $this + */ + public function setMultiCarriageDetails(array|RepeatedField $var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Transit\Realtime\VehiclePosition\CarriageDetails::class); + $this->multi_carriage_details = $arr; + + return $this; + } + +} + diff --git a/src/Google/Transit/Realtime/VehiclePosition/CarriageDetails.php b/src/Google/Transit/Realtime/VehiclePosition/CarriageDetails.php new file mode 100644 index 0000000..675ec81 --- /dev/null +++ b/src/Google/Transit/Realtime/VehiclePosition/CarriageDetails.php @@ -0,0 +1,169 @@ +transit_realtime.VehiclePosition.CarriageDetails + */ +class CarriageDetails extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field string id = 1; + */ + protected $id = ''; + /** + * Generated from protobuf field string label = 2; + */ + protected $label = ''; + /** + * Generated from protobuf field .transit_realtime.VehiclePosition.OccupancyStatus occupancy_status = 3; + */ + protected $occupancy_status = 0; + /** + * Generated from protobuf field int32 occupancy_percentage = 4; + */ + protected $occupancy_percentage = 0; + /** + * Generated from protobuf field uint32 carriage_sequence = 5; + */ + protected $carriage_sequence = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $id + * @type string $label + * @type int $occupancy_status + * @type int $occupancy_percentage + * @type int $carriage_sequence + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\GtfsRealtime::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field string id = 1; + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * Generated from protobuf field string id = 1; + * @param string $var + * @return $this + */ + public function setId(string $var) + { + GPBUtil::checkString($var, true); + $this->id = $var; + + return $this; + } + + /** + * Generated from protobuf field string label = 2; + * @return string + */ + public function getLabel() + { + return $this->label; + } + + /** + * Generated from protobuf field string label = 2; + * @param string $var + * @return $this + */ + public function setLabel(string $var) + { + GPBUtil::checkString($var, true); + $this->label = $var; + + return $this; + } + + /** + * Generated from protobuf field .transit_realtime.VehiclePosition.OccupancyStatus occupancy_status = 3; + * @return int one of the values in {@see \Google\Transit\Realtime\VehiclePosition\OccupancyStatus} + */ + public function getOccupancyStatus() + { + return $this->occupancy_status; + } + + /** + * Generated from protobuf field .transit_realtime.VehiclePosition.OccupancyStatus occupancy_status = 3; + * @param int $var one of the values in {@see \Google\Transit\Realtime\VehiclePosition\OccupancyStatus} + * @return $this + */ + public function setOccupancyStatus(int $var) + { + GPBUtil::checkEnum($var, \Google\Transit\Realtime\VehiclePosition\OccupancyStatus::class); + $this->occupancy_status = $var; + + return $this; + } + + /** + * Generated from protobuf field int32 occupancy_percentage = 4; + * @return int + */ + public function getOccupancyPercentage() + { + return $this->occupancy_percentage; + } + + /** + * Generated from protobuf field int32 occupancy_percentage = 4; + * @param int $var + * @return $this + */ + public function setOccupancyPercentage(int $var) + { + GPBUtil::checkInt32($var); + $this->occupancy_percentage = $var; + + return $this; + } + + /** + * Generated from protobuf field uint32 carriage_sequence = 5; + * @return int + */ + public function getCarriageSequence() + { + return $this->carriage_sequence; + } + + /** + * Generated from protobuf field uint32 carriage_sequence = 5; + * @param int $var + * @return $this + */ + public function setCarriageSequence(int $var) + { + GPBUtil::checkUint32($var); + $this->carriage_sequence = $var; + + return $this; + } + +} + diff --git a/src/Google/Transit/Realtime/VehiclePosition/CongestionLevel.php b/src/Google/Transit/Realtime/VehiclePosition/CongestionLevel.php new file mode 100644 index 0000000..db16770 --- /dev/null +++ b/src/Google/Transit/Realtime/VehiclePosition/CongestionLevel.php @@ -0,0 +1,64 @@ +transit_realtime.VehiclePosition.CongestionLevel + */ +class CongestionLevel +{ + /** + * Generated from protobuf enum UNKNOWN_CONGESTION_LEVEL = 0; + */ + const UNKNOWN_CONGESTION_LEVEL = 0; + /** + * Generated from protobuf enum RUNNING_SMOOTHLY = 1; + */ + const RUNNING_SMOOTHLY = 1; + /** + * Generated from protobuf enum STOP_AND_GO = 2; + */ + const STOP_AND_GO = 2; + /** + * Generated from protobuf enum CONGESTION = 3; + */ + const CONGESTION = 3; + /** + * Generated from protobuf enum SEVERE_CONGESTION = 4; + */ + const SEVERE_CONGESTION = 4; + + private static $valueToName = [ + self::UNKNOWN_CONGESTION_LEVEL => 'UNKNOWN_CONGESTION_LEVEL', + self::RUNNING_SMOOTHLY => 'RUNNING_SMOOTHLY', + self::STOP_AND_GO => 'STOP_AND_GO', + self::CONGESTION => 'CONGESTION', + self::SEVERE_CONGESTION => 'SEVERE_CONGESTION', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + diff --git a/src/Google/Transit/Realtime/VehiclePosition/OccupancyStatus.php b/src/Google/Transit/Realtime/VehiclePosition/OccupancyStatus.php new file mode 100644 index 0000000..5f31905 --- /dev/null +++ b/src/Google/Transit/Realtime/VehiclePosition/OccupancyStatus.php @@ -0,0 +1,88 @@ +transit_realtime.VehiclePosition.OccupancyStatus + */ +class OccupancyStatus +{ + /** + * Generated from protobuf enum EMPTY = 0; + */ + const PBEMPTY = 0; + /** + * Generated from protobuf enum MANY_SEATS_AVAILABLE = 1; + */ + const MANY_SEATS_AVAILABLE = 1; + /** + * Generated from protobuf enum FEW_SEATS_AVAILABLE = 2; + */ + const FEW_SEATS_AVAILABLE = 2; + /** + * Generated from protobuf enum STANDING_ROOM_ONLY = 3; + */ + const STANDING_ROOM_ONLY = 3; + /** + * Generated from protobuf enum CRUSHED_STANDING_ROOM_ONLY = 4; + */ + const CRUSHED_STANDING_ROOM_ONLY = 4; + /** + * Generated from protobuf enum FULL = 5; + */ + const FULL = 5; + /** + * Generated from protobuf enum NOT_ACCEPTING_PASSENGERS = 6; + */ + const NOT_ACCEPTING_PASSENGERS = 6; + /** + * Generated from protobuf enum NO_DATA_AVAILABLE = 7; + */ + const NO_DATA_AVAILABLE = 7; + /** + * Generated from protobuf enum NOT_BOARDABLE = 8; + */ + const NOT_BOARDABLE = 8; + + private static $valueToName = [ + self::PBEMPTY => 'EMPTY', + self::MANY_SEATS_AVAILABLE => 'MANY_SEATS_AVAILABLE', + self::FEW_SEATS_AVAILABLE => 'FEW_SEATS_AVAILABLE', + self::STANDING_ROOM_ONLY => 'STANDING_ROOM_ONLY', + self::CRUSHED_STANDING_ROOM_ONLY => 'CRUSHED_STANDING_ROOM_ONLY', + self::FULL => 'FULL', + self::NOT_ACCEPTING_PASSENGERS => 'NOT_ACCEPTING_PASSENGERS', + self::NO_DATA_AVAILABLE => 'NO_DATA_AVAILABLE', + self::NOT_BOARDABLE => 'NOT_BOARDABLE', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + $pbconst = __CLASS__. '::PB' . strtoupper($name); + if (!defined($pbconst)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($pbconst); + } + return constant($const); + } +} + diff --git a/src/Google/Transit/Realtime/VehiclePosition/VehicleStopStatus.php b/src/Google/Transit/Realtime/VehiclePosition/VehicleStopStatus.php new file mode 100644 index 0000000..4ea7cce --- /dev/null +++ b/src/Google/Transit/Realtime/VehiclePosition/VehicleStopStatus.php @@ -0,0 +1,54 @@ +transit_realtime.VehiclePosition.VehicleStopStatus + */ +class VehicleStopStatus +{ + /** + * Generated from protobuf enum INCOMING_AT = 0; + */ + const INCOMING_AT = 0; + /** + * Generated from protobuf enum STOPPED_AT = 1; + */ + const STOPPED_AT = 1; + /** + * Generated from protobuf enum IN_TRANSIT_TO = 2; + */ + const IN_TRANSIT_TO = 2; + + private static $valueToName = [ + self::INCOMING_AT => 'INCOMING_AT', + self::STOPPED_AT => 'STOPPED_AT', + self::IN_TRANSIT_TO => 'IN_TRANSIT_TO', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + diff --git a/tests/GtfsRealtimeTest.php b/tests/GtfsRealtimeTest.php new file mode 100644 index 0000000..d019392 --- /dev/null +++ b/tests/GtfsRealtimeTest.php @@ -0,0 +1,277 @@ +assertInstanceOf(FeedMessage::class, $feedMessage); + } + + public function testFeedHeaderSetAndGet(): void + { + $header = new FeedHeader(); + $header->setGtfsRealtimeVersion('2.0'); + $header->setIncrementality(Incrementality::FULL_DATASET); + $header->setTimestamp(1000000); + + $this->assertSame('2.0', $header->getGtfsRealtimeVersion()); + $this->assertSame(Incrementality::FULL_DATASET, $header->getIncrementality()); + $this->assertSame(1000000, $header->getTimestamp()); + } + + public function testFeedEntityWithTripUpdate(): void + { + $tripDescriptor = new TripDescriptor(); + $tripDescriptor->setTripId('trip-1'); + $tripDescriptor->setRouteId('route-1'); + $tripDescriptor->setStartDate('20260101'); + $tripDescriptor->setScheduleRelationship(ScheduleRelationship::SCHEDULED); + + $arrivalEvent = new StopTimeEvent(); + $arrivalEvent->setDelay(60); + $arrivalEvent->setTime(1000000); + $arrivalEvent->setUncertainty(30); + + $departureEvent = new StopTimeEvent(); + $departureEvent->setDelay(90); + + $stopTimeUpdate = new StopTimeUpdate(); + $stopTimeUpdate->setStopSequence(1); + $stopTimeUpdate->setStopId('stop-1'); + $stopTimeUpdate->setArrival($arrivalEvent); + $stopTimeUpdate->setDeparture($departureEvent); + + $tripUpdate = new TripUpdate(); + $tripUpdate->setTrip($tripDescriptor); + $tripUpdate->setTimestamp(1000000); + $tripUpdate->setStopTimeUpdate([$stopTimeUpdate]); + + $entity = new FeedEntity(); + $entity->setId('entity-1'); + $entity->setTripUpdate($tripUpdate); + + $this->assertSame('entity-1', $entity->getId()); + $this->assertTrue($entity->hasTripUpdate()); + $this->assertSame('trip-1', $entity->getTripUpdate()->getTrip()->getTripId()); + $this->assertSame('route-1', $entity->getTripUpdate()->getTrip()->getRouteId()); + $this->assertSame(1, count($entity->getTripUpdate()->getStopTimeUpdate())); + $this->assertSame(60, $entity->getTripUpdate()->getStopTimeUpdate()[0]->getArrival()->getDelay()); + $this->assertSame(90, $entity->getTripUpdate()->getStopTimeUpdate()[0]->getDeparture()->getDelay()); + } + + public function testFeedEntityWithVehiclePosition(): void + { + $position = new Position(); + $position->setLatitude(48.8566); + $position->setLongitude(2.3522); + $position->setBearing(90.0); + $position->setSpeed(15.0); + + $tripDescriptor = new TripDescriptor(); + $tripDescriptor->setTripId('trip-2'); + + $vehicleDescriptor = new VehicleDescriptor(); + $vehicleDescriptor->setId('vehicle-1'); + $vehicleDescriptor->setLabel('Bus 42'); + + $vehiclePosition = new VehiclePosition(); + $vehiclePosition->setTrip($tripDescriptor); + $vehiclePosition->setVehicle($vehicleDescriptor); + $vehiclePosition->setPosition($position); + $vehiclePosition->setCurrentStatus(VehiclePosition\VehicleStopStatus::IN_TRANSIT_TO); + $vehiclePosition->setTimestamp(1000000); + $vehiclePosition->setCongestionLevel(VehiclePosition\CongestionLevel::RUNNING_SMOOTHLY); + $vehiclePosition->setOccupancyStatus(VehiclePosition\OccupancyStatus::MANY_SEATS_AVAILABLE); + + $entity = new FeedEntity(); + $entity->setId('entity-2'); + $entity->setVehicle($vehiclePosition); + + $this->assertTrue($entity->hasVehicle()); + $this->assertSame('vehicle-1', $entity->getVehicle()->getVehicle()->getId()); + $this->assertEqualsWithDelta(48.8566, $entity->getVehicle()->getPosition()->getLatitude(), 0.001); + $this->assertEqualsWithDelta(2.3522, $entity->getVehicle()->getPosition()->getLongitude(), 0.001); + $this->assertSame(VehiclePosition\OccupancyStatus::MANY_SEATS_AVAILABLE, $entity->getVehicle()->getOccupancyStatus()); + } + + public function testFeedEntityWithAlert(): void + { + $translation = new Translation(); + $translation->setText('Service disruption on line 1'); + $translation->setLanguage('en'); + + $translatedString = new TranslatedString(); + $translatedString->setTranslation([$translation]); + + $timeRange = new TimeRange(); + $timeRange->setStart(1000000); + $timeRange->setEnd(1100000); + + $entitySelector = new EntitySelector(); + $entitySelector->setRouteId('route-1'); + + $alert = new Alert(); + $alert->setActivePeriod([$timeRange]); + $alert->setInformedEntity([$entitySelector]); + $alert->setCause(Cause::TECHNICAL_PROBLEM); + $alert->setEffect(Effect::SIGNIFICANT_DELAYS); + $alert->setSeverityLevel(SeverityLevel::WARNING); + $alert->setHeaderText($translatedString); + + $entity = new FeedEntity(); + $entity->setId('entity-3'); + $entity->setAlert($alert); + + $this->assertTrue($entity->hasAlert()); + $this->assertSame(Cause::TECHNICAL_PROBLEM, $entity->getAlert()->getCause()); + $this->assertSame(Effect::SIGNIFICANT_DELAYS, $entity->getAlert()->getEffect()); + $this->assertSame(SeverityLevel::WARNING, $entity->getAlert()->getSeverityLevel()); + $this->assertSame( + 'Service disruption on line 1', + $entity->getAlert()->getHeaderText()->getTranslation()[0]->getText() + ); + } + + public function testSerializeAndDeserializeFeedMessage(): void + { + // Create a feed message + $header = new FeedHeader(); + $header->setGtfsRealtimeVersion('2.0'); + $header->setIncrementality(Incrementality::FULL_DATASET); + $header->setTimestamp(1774000000); + + $tripDescriptor = new TripDescriptor(); + $tripDescriptor->setTripId('trip-serialize-test'); + + $arrivalEvent = new StopTimeEvent(); + $arrivalEvent->setDelay(300); + + $stopTimeUpdate = new StopTimeUpdate(); + $stopTimeUpdate->setStopSequence(5); + $stopTimeUpdate->setStopId('stop-X'); + $stopTimeUpdate->setArrival($arrivalEvent); + + $tripUpdate = new TripUpdate(); + $tripUpdate->setTrip($tripDescriptor); + $tripUpdate->setStopTimeUpdate([$stopTimeUpdate]); + + $entity = new FeedEntity(); + $entity->setId('serialize-entity-1'); + $entity->setTripUpdate($tripUpdate); + + $feedMessage = new FeedMessage(); + $feedMessage->setHeader($header); + $feedMessage->setEntity([$entity]); + + // Serialize + $binaryData = $feedMessage->serializeToString(); + $this->assertNotEmpty($binaryData); + + // Deserialize + $parsedFeed = new FeedMessage(); + $parsedFeed->mergeFromString($binaryData); + + $this->assertSame('2.0', $parsedFeed->getHeader()->getGtfsRealtimeVersion()); + $this->assertSame(1774000000, $parsedFeed->getHeader()->getTimestamp()); + $this->assertSame(1, count($parsedFeed->getEntity())); + $this->assertSame('serialize-entity-1', $parsedFeed->getEntity()[0]->getId()); + $this->assertSame('trip-serialize-test', $parsedFeed->getEntity()[0]->getTripUpdate()->getTrip()->getTripId()); + $this->assertSame(300, $parsedFeed->getEntity()[0]->getTripUpdate()->getStopTimeUpdate()[0]->getArrival()->getDelay()); + $this->assertSame('stop-X', $parsedFeed->getEntity()[0]->getTripUpdate()->getStopTimeUpdate()[0]->getStopId()); + } + + public function testMultipleEntitiesInFeed(): void + { + $feedMessage = new FeedMessage(); + + $header = new FeedHeader(); + $header->setGtfsRealtimeVersion('2.0'); + $header->setTimestamp(1774000000); + $feedMessage->setHeader($header); + + $entities = []; + for ($i = 1; $i <= 3; $i++) { + $entity = new FeedEntity(); + $entity->setId("entity-{$i}"); + + $tripDescriptor = new TripDescriptor(); + $tripDescriptor->setTripId("trip-{$i}"); + + $tripUpdate = new TripUpdate(); + $tripUpdate->setTrip($tripDescriptor); + + $entity->setTripUpdate($tripUpdate); + $entities[] = $entity; + } + + $feedMessage->setEntity($entities); + + $this->assertSame(3, count($feedMessage->getEntity())); + $this->assertSame('entity-2', $feedMessage->getEntity()[1]->getId()); + } + + public function testIsDeletedFeedEntity(): void + { + $entity = new FeedEntity(); + $entity->setId('deleted-entity-1'); + $entity->setIsDeleted(true); + + $this->assertTrue($entity->getIsDeleted()); + } + + public function testEnumDefaultValues(): void + { + $header = new FeedHeader(); + $this->assertSame(Incrementality::FULL_DATASET, $header->getIncrementality()); + + $vehiclePosition = new VehiclePosition(); + $this->assertSame(VehiclePosition\VehicleStopStatus::INCOMING_AT, $vehiclePosition->getCurrentStatus()); + + $tripDescriptor = new TripDescriptor(); + $this->assertSame(ScheduleRelationship::SCHEDULED, $tripDescriptor->getScheduleRelationship()); + } + + public function testJsonSerialization(): void + { + $header = new FeedHeader(); + $header->setGtfsRealtimeVersion('2.0'); + $header->setTimestamp(1774000000); + + $feedMessage = new FeedMessage(); + $feedMessage->setHeader($header); + + $json = $feedMessage->serializeToJsonString(); + $this->assertJson($json); + + $decoded = json_decode($json, true); + $this->assertArrayHasKey('header', $decoded); + $this->assertSame('2.0', $decoded['header']['gtfsRealtimeVersion']); + } +}