chore(pbf): add gtfs-r js sources

This commit is contained in:
dancingCycle 2022-09-13 15:30:00 +02:00
parent e26a9c3342
commit 575461e037
7 changed files with 2428 additions and 0 deletions

3
pbf/.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "proto2js"]
path = proto2js
url = git@github.com:dancesWithCycles/proto2js.git

View File

@ -6,6 +6,28 @@
# General
* check out project and change into the project root folder
```
git clone --recurse-submodules dancesWithCycles/sandbox-react.git
cd sandbox-react/pbf
```
* if not already done, submodules can be pulled like this from the project root folder\
```
git submodule init
git submodule update
```
* run the following instruction to install dependenies
```
npm i
```
* run the following instrction to start the service
```
npm run start
```
# Links
* [React setup with webpack for beginners](https://dev.to/deepanjangh/react-setup-with-webpack-for-beginners-2a8k)

674
pbf/proto2js/LICENSE Normal file
View File

@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.

26
pbf/proto2js/README.md Normal file
View File

@ -0,0 +1,26 @@
# proto2js
Compile *.proto file to JavaScript module
## Table of Contents
0. [General](#General)
1. [GTFS Realtime](#gtfs-realtime)
# General
This repository provides three folders for each compilation.
1. ```doc```: Documentation
2. ```proto```: Source file
3. ```js```: Result file
The tool used for compilation is called
[pbf](https://github.com/mapbox/pbf)
and installed in a global fashion like this.
```
$ npm install -g pbf
```
A compilation is done by calling the following instruction.
```
pbf ./proto/<file.proto> > ./js/<file.js>
```
# [GTFS Realtime](./doc/gtfs-rt.md)

View File

@ -0,0 +1,20 @@
# gtfs-rt
* further description for gtfs-rt is available on the [gtfs.org](https://gtfs.org/realtime/proto/) website
* clone [repository](git@github.com:google/transit.git)
```
cd /tmp
git clone git@github.com:google/transit.git
```
* copy proto file into this repository
```
cd /tmp/transit/gtfs-realtime/proto
cp gtfs-realtime.proto ~/<path>/proto2js/proto/gtfs-rt.proto
```
* compile proto file into js file
```
pbf ./proto/gtfs-rt.proto > ./js/gtfs-rt.js
```

688
pbf/proto2js/js/gtfs-rt.js Normal file
View File

@ -0,0 +1,688 @@
'use strict'; // code generated by pbf v3.2.1
// FeedMessage ========================================
var FeedMessage = exports.FeedMessage = {};
FeedMessage.read = function (pbf, end) {
return pbf.readFields(FeedMessage._readField, {header: null, entity: []}, end);
};
FeedMessage._readField = function (tag, obj, pbf) {
if (tag === 1) obj.header = FeedHeader.read(pbf, pbf.readVarint() + pbf.pos);
else if (tag === 2) obj.entity.push(FeedEntity.read(pbf, pbf.readVarint() + pbf.pos));
};
FeedMessage.write = function (obj, pbf) {
if (obj.header) pbf.writeMessage(1, FeedHeader.write, obj.header);
if (obj.entity) for (var i = 0; i < obj.entity.length; i++) pbf.writeMessage(2, FeedEntity.write, obj.entity[i]);
};
// FeedHeader ========================================
var FeedHeader = exports.FeedHeader = {};
FeedHeader.read = function (pbf, end) {
return pbf.readFields(FeedHeader._readField, {gtfs_realtime_version: "", incrementality: {"value":0,"options":{}}, timestamp: 0}, end);
};
FeedHeader._readField = function (tag, obj, pbf) {
if (tag === 1) obj.gtfs_realtime_version = pbf.readString();
else if (tag === 2) obj.incrementality = pbf.readVarint();
else if (tag === 3) obj.timestamp = pbf.readVarint();
};
FeedHeader.write = function (obj, pbf) {
if (obj.gtfs_realtime_version) pbf.writeStringField(1, obj.gtfs_realtime_version);
if (obj.incrementality != undefined && obj.incrementality !== {"value":0,"options":{}}) pbf.writeVarintField(2, obj.incrementality);
if (obj.timestamp) pbf.writeVarintField(3, obj.timestamp);
};
FeedHeader.Incrementality = {
"FULL_DATASET": {
"value": 0,
"options": {}
},
"DIFFERENTIAL": {
"value": 1,
"options": {}
}
};
// FeedEntity ========================================
var FeedEntity = exports.FeedEntity = {};
FeedEntity.read = function (pbf, end) {
return pbf.readFields(FeedEntity._readField, {id: "", is_deleted: false, trip_update: null, vehicle: null, alert: null, shape: null}, end);
};
FeedEntity._readField = function (tag, obj, pbf) {
if (tag === 1) obj.id = pbf.readString();
else if (tag === 2) obj.is_deleted = pbf.readBoolean();
else if (tag === 3) obj.trip_update = TripUpdate.read(pbf, pbf.readVarint() + pbf.pos);
else if (tag === 4) obj.vehicle = VehiclePosition.read(pbf, pbf.readVarint() + pbf.pos);
else if (tag === 5) obj.alert = Alert.read(pbf, pbf.readVarint() + pbf.pos);
else if (tag === 6) obj.shape = Shape.read(pbf, pbf.readVarint() + pbf.pos);
};
FeedEntity.write = function (obj, pbf) {
if (obj.id) pbf.writeStringField(1, obj.id);
if (obj.is_deleted) pbf.writeBooleanField(2, obj.is_deleted);
if (obj.trip_update) pbf.writeMessage(3, TripUpdate.write, obj.trip_update);
if (obj.vehicle) pbf.writeMessage(4, VehiclePosition.write, obj.vehicle);
if (obj.alert) pbf.writeMessage(5, Alert.write, obj.alert);
if (obj.shape) pbf.writeMessage(6, Shape.write, obj.shape);
};
// TripUpdate ========================================
var TripUpdate = exports.TripUpdate = {};
TripUpdate.read = function (pbf, end) {
return pbf.readFields(TripUpdate._readField, {trip: null, vehicle: null, stop_time_update: [], timestamp: 0, delay: 0, trip_properties: null}, end);
};
TripUpdate._readField = function (tag, obj, pbf) {
if (tag === 1) obj.trip = TripDescriptor.read(pbf, pbf.readVarint() + pbf.pos);
else if (tag === 3) obj.vehicle = VehicleDescriptor.read(pbf, pbf.readVarint() + pbf.pos);
else if (tag === 2) obj.stop_time_update.push(TripUpdate.StopTimeUpdate.read(pbf, pbf.readVarint() + pbf.pos));
else if (tag === 4) obj.timestamp = pbf.readVarint();
else if (tag === 5) obj.delay = pbf.readVarint(true);
else if (tag === 6) obj.trip_properties = TripUpdate.TripProperties.read(pbf, pbf.readVarint() + pbf.pos);
};
TripUpdate.write = function (obj, pbf) {
if (obj.trip) pbf.writeMessage(1, TripDescriptor.write, obj.trip);
if (obj.vehicle) pbf.writeMessage(3, VehicleDescriptor.write, obj.vehicle);
if (obj.stop_time_update) for (var i = 0; i < obj.stop_time_update.length; i++) pbf.writeMessage(2, TripUpdate.StopTimeUpdate.write, obj.stop_time_update[i]);
if (obj.timestamp) pbf.writeVarintField(4, obj.timestamp);
if (obj.delay) pbf.writeVarintField(5, obj.delay);
if (obj.trip_properties) pbf.writeMessage(6, TripUpdate.TripProperties.write, obj.trip_properties);
};
// TripUpdate.StopTimeEvent ========================================
TripUpdate.StopTimeEvent = {};
TripUpdate.StopTimeEvent.read = function (pbf, end) {
return pbf.readFields(TripUpdate.StopTimeEvent._readField, {delay: 0, time: 0, uncertainty: 0}, end);
};
TripUpdate.StopTimeEvent._readField = function (tag, obj, pbf) {
if (tag === 1) obj.delay = pbf.readVarint(true);
else if (tag === 2) obj.time = pbf.readVarint(true);
else if (tag === 3) obj.uncertainty = pbf.readVarint(true);
};
TripUpdate.StopTimeEvent.write = function (obj, pbf) {
if (obj.delay) pbf.writeVarintField(1, obj.delay);
if (obj.time) pbf.writeVarintField(2, obj.time);
if (obj.uncertainty) pbf.writeVarintField(3, obj.uncertainty);
};
// TripUpdate.StopTimeUpdate ========================================
TripUpdate.StopTimeUpdate = {};
TripUpdate.StopTimeUpdate.read = function (pbf, end) {
return pbf.readFields(TripUpdate.StopTimeUpdate._readField, {stop_sequence: 0, stop_id: "", arrival: null, departure: null, departure_occupancy_status: 0, schedule_relationship: {"value":0,"options":{}}, stop_time_properties: null}, end);
};
TripUpdate.StopTimeUpdate._readField = function (tag, obj, pbf) {
if (tag === 1) obj.stop_sequence = pbf.readVarint();
else if (tag === 4) obj.stop_id = pbf.readString();
else if (tag === 2) obj.arrival = TripUpdate.StopTimeEvent.read(pbf, pbf.readVarint() + pbf.pos);
else if (tag === 3) obj.departure = TripUpdate.StopTimeEvent.read(pbf, pbf.readVarint() + pbf.pos);
else if (tag === 7) obj.departure_occupancy_status = pbf.readVarint();
else if (tag === 5) obj.schedule_relationship = pbf.readVarint();
else if (tag === 6) obj.stop_time_properties = TripUpdate.StopTimeUpdate.StopTimeProperties.read(pbf, pbf.readVarint() + pbf.pos);
};
TripUpdate.StopTimeUpdate.write = function (obj, pbf) {
if (obj.stop_sequence) pbf.writeVarintField(1, obj.stop_sequence);
if (obj.stop_id) pbf.writeStringField(4, obj.stop_id);
if (obj.arrival) pbf.writeMessage(2, TripUpdate.StopTimeEvent.write, obj.arrival);
if (obj.departure) pbf.writeMessage(3, TripUpdate.StopTimeEvent.write, obj.departure);
if (obj.departure_occupancy_status) pbf.writeVarintField(7, obj.departure_occupancy_status);
if (obj.schedule_relationship != undefined && obj.schedule_relationship !== {"value":0,"options":{}}) pbf.writeVarintField(5, obj.schedule_relationship);
if (obj.stop_time_properties) pbf.writeMessage(6, TripUpdate.StopTimeUpdate.StopTimeProperties.write, obj.stop_time_properties);
};
TripUpdate.StopTimeUpdate.ScheduleRelationship = {
"SCHEDULED": {
"value": 0,
"options": {}
},
"SKIPPED": {
"value": 1,
"options": {}
},
"NO_DATA": {
"value": 2,
"options": {}
},
"UNSCHEDULED": {
"value": 3,
"options": {}
}
};
// TripUpdate.StopTimeUpdate.StopTimeProperties ========================================
TripUpdate.StopTimeUpdate.StopTimeProperties = {};
TripUpdate.StopTimeUpdate.StopTimeProperties.read = function (pbf, end) {
return pbf.readFields(TripUpdate.StopTimeUpdate.StopTimeProperties._readField, {assigned_stop_id: ""}, end);
};
TripUpdate.StopTimeUpdate.StopTimeProperties._readField = function (tag, obj, pbf) {
if (tag === 1) obj.assigned_stop_id = pbf.readString();
};
TripUpdate.StopTimeUpdate.StopTimeProperties.write = function (obj, pbf) {
if (obj.assigned_stop_id) pbf.writeStringField(1, obj.assigned_stop_id);
};
// TripUpdate.TripProperties ========================================
TripUpdate.TripProperties = {};
TripUpdate.TripProperties.read = function (pbf, end) {
return pbf.readFields(TripUpdate.TripProperties._readField, {trip_id: "", start_date: "", start_time: "", shape_id: ""}, end);
};
TripUpdate.TripProperties._readField = function (tag, obj, pbf) {
if (tag === 1) obj.trip_id = pbf.readString();
else if (tag === 2) obj.start_date = pbf.readString();
else if (tag === 3) obj.start_time = pbf.readString();
else if (tag === 4) obj.shape_id = pbf.readString();
};
TripUpdate.TripProperties.write = function (obj, pbf) {
if (obj.trip_id) pbf.writeStringField(1, obj.trip_id);
if (obj.start_date) pbf.writeStringField(2, obj.start_date);
if (obj.start_time) pbf.writeStringField(3, obj.start_time);
if (obj.shape_id) pbf.writeStringField(4, obj.shape_id);
};
// VehiclePosition ========================================
var VehiclePosition = exports.VehiclePosition = {};
VehiclePosition.read = function (pbf, end) {
return pbf.readFields(VehiclePosition._readField, {trip: null, vehicle: null, position: null, current_stop_sequence: 0, stop_id: "", current_status: {"value":2,"options":{}}, timestamp: 0, congestion_level: 0, occupancy_status: 0, occupancy_percentage: 0, multi_carriage_details: []}, end);
};
VehiclePosition._readField = function (tag, obj, pbf) {
if (tag === 1) obj.trip = TripDescriptor.read(pbf, pbf.readVarint() + pbf.pos);
else if (tag === 8) obj.vehicle = VehicleDescriptor.read(pbf, pbf.readVarint() + pbf.pos);
else if (tag === 2) obj.position = Position.read(pbf, pbf.readVarint() + pbf.pos);
else if (tag === 3) obj.current_stop_sequence = pbf.readVarint();
else if (tag === 7) obj.stop_id = pbf.readString();
else if (tag === 4) obj.current_status = pbf.readVarint();
else if (tag === 5) obj.timestamp = pbf.readVarint();
else if (tag === 6) obj.congestion_level = pbf.readVarint();
else if (tag === 9) obj.occupancy_status = pbf.readVarint();
else if (tag === 10) obj.occupancy_percentage = pbf.readVarint();
else if (tag === 11) obj.multi_carriage_details.push(VehiclePosition.CarriageDetails.read(pbf, pbf.readVarint() + pbf.pos));
};
VehiclePosition.write = function (obj, pbf) {
if (obj.trip) pbf.writeMessage(1, TripDescriptor.write, obj.trip);
if (obj.vehicle) pbf.writeMessage(8, VehicleDescriptor.write, obj.vehicle);
if (obj.position) pbf.writeMessage(2, Position.write, obj.position);
if (obj.current_stop_sequence) pbf.writeVarintField(3, obj.current_stop_sequence);
if (obj.stop_id) pbf.writeStringField(7, obj.stop_id);
if (obj.current_status != undefined && obj.current_status !== {"value":2,"options":{}}) pbf.writeVarintField(4, obj.current_status);
if (obj.timestamp) pbf.writeVarintField(5, obj.timestamp);
if (obj.congestion_level) pbf.writeVarintField(6, obj.congestion_level);
if (obj.occupancy_status) pbf.writeVarintField(9, obj.occupancy_status);
if (obj.occupancy_percentage) pbf.writeVarintField(10, obj.occupancy_percentage);
if (obj.multi_carriage_details) for (var i = 0; i < obj.multi_carriage_details.length; i++) pbf.writeMessage(11, VehiclePosition.CarriageDetails.write, obj.multi_carriage_details[i]);
};
VehiclePosition.VehicleStopStatus = {
"INCOMING_AT": {
"value": 0,
"options": {}
},
"STOPPED_AT": {
"value": 1,
"options": {}
},
"IN_TRANSIT_TO": {
"value": 2,
"options": {}
}
};
VehiclePosition.CongestionLevel = {
"UNKNOWN_CONGESTION_LEVEL": {
"value": 0,
"options": {}
},
"RUNNING_SMOOTHLY": {
"value": 1,
"options": {}
},
"STOP_AND_GO": {
"value": 2,
"options": {}
},
"CONGESTION": {
"value": 3,
"options": {}
},
"SEVERE_CONGESTION": {
"value": 4,
"options": {}
}
};
VehiclePosition.OccupancyStatus = {
"EMPTY": {
"value": 0,
"options": {}
},
"MANY_SEATS_AVAILABLE": {
"value": 1,
"options": {}
},
"FEW_SEATS_AVAILABLE": {
"value": 2,
"options": {}
},
"STANDING_ROOM_ONLY": {
"value": 3,
"options": {}
},
"CRUSHED_STANDING_ROOM_ONLY": {
"value": 4,
"options": {}
},
"FULL": {
"value": 5,
"options": {}
},
"NOT_ACCEPTING_PASSENGERS": {
"value": 6,
"options": {}
},
"NO_DATA_AVAILABLE": {
"value": 7,
"options": {}
},
"NOT_BOARDABLE": {
"value": 8,
"options": {}
}
};
// VehiclePosition.CarriageDetails ========================================
VehiclePosition.CarriageDetails = {};
VehiclePosition.CarriageDetails.read = function (pbf, end) {
return pbf.readFields(VehiclePosition.CarriageDetails._readField, {id: "", label: "", occupancy_status: {"value":7,"options":{}}, occupancy_percentage: -1, carriage_sequence: 0}, end);
};
VehiclePosition.CarriageDetails._readField = function (tag, obj, pbf) {
if (tag === 1) obj.id = pbf.readString();
else if (tag === 2) obj.label = pbf.readString();
else if (tag === 3) obj.occupancy_status = pbf.readVarint();
else if (tag === 4) obj.occupancy_percentage = pbf.readVarint(true);
else if (tag === 5) obj.carriage_sequence = pbf.readVarint();
};
VehiclePosition.CarriageDetails.write = function (obj, pbf) {
if (obj.id) pbf.writeStringField(1, obj.id);
if (obj.label) pbf.writeStringField(2, obj.label);
if (obj.occupancy_status != undefined && obj.occupancy_status !== {"value":7,"options":{}}) pbf.writeVarintField(3, obj.occupancy_status);
if (obj.occupancy_percentage != undefined && obj.occupancy_percentage !== -1) pbf.writeVarintField(4, obj.occupancy_percentage);
if (obj.carriage_sequence) pbf.writeVarintField(5, obj.carriage_sequence);
};
// Alert ========================================
var Alert = exports.Alert = {};
Alert.read = function (pbf, end) {
return pbf.readFields(Alert._readField, {active_period: [], informed_entity: [], cause: {"value":1,"options":{}}, effect: {"value":8,"options":{}}, url: null, header_text: null, description_text: null, tts_header_text: null, tts_description_text: null, severity_level: {"value":1,"options":{}}, image: null, image_alternative_text: null}, end);
};
Alert._readField = function (tag, obj, pbf) {
if (tag === 1) obj.active_period.push(TimeRange.read(pbf, pbf.readVarint() + pbf.pos));
else if (tag === 5) obj.informed_entity.push(EntitySelector.read(pbf, pbf.readVarint() + pbf.pos));
else if (tag === 6) obj.cause = pbf.readVarint();
else if (tag === 7) obj.effect = pbf.readVarint();
else if (tag === 8) obj.url = TranslatedString.read(pbf, pbf.readVarint() + pbf.pos);
else if (tag === 10) obj.header_text = TranslatedString.read(pbf, pbf.readVarint() + pbf.pos);
else if (tag === 11) obj.description_text = TranslatedString.read(pbf, pbf.readVarint() + pbf.pos);
else if (tag === 12) obj.tts_header_text = TranslatedString.read(pbf, pbf.readVarint() + pbf.pos);
else if (tag === 13) obj.tts_description_text = TranslatedString.read(pbf, pbf.readVarint() + pbf.pos);
else if (tag === 14) obj.severity_level = pbf.readVarint();
else if (tag === 15) obj.image = TranslatedImage.read(pbf, pbf.readVarint() + pbf.pos);
else if (tag === 16) obj.image_alternative_text = TranslatedString.read(pbf, pbf.readVarint() + pbf.pos);
};
Alert.write = function (obj, pbf) {
if (obj.active_period) for (var i = 0; i < obj.active_period.length; i++) pbf.writeMessage(1, TimeRange.write, obj.active_period[i]);
if (obj.informed_entity) for (i = 0; i < obj.informed_entity.length; i++) pbf.writeMessage(5, EntitySelector.write, obj.informed_entity[i]);
if (obj.cause != undefined && obj.cause !== {"value":1,"options":{}}) pbf.writeVarintField(6, obj.cause);
if (obj.effect != undefined && obj.effect !== {"value":8,"options":{}}) pbf.writeVarintField(7, obj.effect);
if (obj.url) pbf.writeMessage(8, TranslatedString.write, obj.url);
if (obj.header_text) pbf.writeMessage(10, TranslatedString.write, obj.header_text);
if (obj.description_text) pbf.writeMessage(11, TranslatedString.write, obj.description_text);
if (obj.tts_header_text) pbf.writeMessage(12, TranslatedString.write, obj.tts_header_text);
if (obj.tts_description_text) pbf.writeMessage(13, TranslatedString.write, obj.tts_description_text);
if (obj.severity_level != undefined && obj.severity_level !== {"value":1,"options":{}}) pbf.writeVarintField(14, obj.severity_level);
if (obj.image) pbf.writeMessage(15, TranslatedImage.write, obj.image);
if (obj.image_alternative_text) pbf.writeMessage(16, TranslatedString.write, obj.image_alternative_text);
};
Alert.Cause = {
"UNKNOWN_CAUSE": {
"value": 1,
"options": {}
},
"OTHER_CAUSE": {
"value": 2,
"options": {}
},
"TECHNICAL_PROBLEM": {
"value": 3,
"options": {}
},
"STRIKE": {
"value": 4,
"options": {}
},
"DEMONSTRATION": {
"value": 5,
"options": {}
},
"ACCIDENT": {
"value": 6,
"options": {}
},
"HOLIDAY": {
"value": 7,
"options": {}
},
"WEATHER": {
"value": 8,
"options": {}
},
"MAINTENANCE": {
"value": 9,
"options": {}
},
"CONSTRUCTION": {
"value": 10,
"options": {}
},
"POLICE_ACTIVITY": {
"value": 11,
"options": {}
},
"MEDICAL_EMERGENCY": {
"value": 12,
"options": {}
}
};
Alert.Effect = {
"NO_SERVICE": {
"value": 1,
"options": {}
},
"REDUCED_SERVICE": {
"value": 2,
"options": {}
},
"SIGNIFICANT_DELAYS": {
"value": 3,
"options": {}
},
"DETOUR": {
"value": 4,
"options": {}
},
"ADDITIONAL_SERVICE": {
"value": 5,
"options": {}
},
"MODIFIED_SERVICE": {
"value": 6,
"options": {}
},
"OTHER_EFFECT": {
"value": 7,
"options": {}
},
"UNKNOWN_EFFECT": {
"value": 8,
"options": {}
},
"STOP_MOVED": {
"value": 9,
"options": {}
},
"NO_EFFECT": {
"value": 10,
"options": {}
},
"ACCESSIBILITY_ISSUE": {
"value": 11,
"options": {}
}
};
Alert.SeverityLevel = {
"UNKNOWN_SEVERITY": {
"value": 1,
"options": {}
},
"INFO": {
"value": 2,
"options": {}
},
"WARNING": {
"value": 3,
"options": {}
},
"SEVERE": {
"value": 4,
"options": {}
}
};
// TimeRange ========================================
var TimeRange = exports.TimeRange = {};
TimeRange.read = function (pbf, end) {
return pbf.readFields(TimeRange._readField, {start: 0, end: 0}, end);
};
TimeRange._readField = function (tag, obj, pbf) {
if (tag === 1) obj.start = pbf.readVarint();
else if (tag === 2) obj.end = pbf.readVarint();
};
TimeRange.write = function (obj, pbf) {
if (obj.start) pbf.writeVarintField(1, obj.start);
if (obj.end) pbf.writeVarintField(2, obj.end);
};
// Position ========================================
var Position = exports.Position = {};
Position.read = function (pbf, end) {
return pbf.readFields(Position._readField, {latitude: 0, longitude: 0, bearing: 0, odometer: 0, speed: 0}, end);
};
Position._readField = function (tag, obj, pbf) {
if (tag === 1) obj.latitude = pbf.readFloat();
else if (tag === 2) obj.longitude = pbf.readFloat();
else if (tag === 3) obj.bearing = pbf.readFloat();
else if (tag === 4) obj.odometer = pbf.readDouble();
else if (tag === 5) obj.speed = pbf.readFloat();
};
Position.write = function (obj, pbf) {
if (obj.latitude) pbf.writeFloatField(1, obj.latitude);
if (obj.longitude) pbf.writeFloatField(2, obj.longitude);
if (obj.bearing) pbf.writeFloatField(3, obj.bearing);
if (obj.odometer) pbf.writeDoubleField(4, obj.odometer);
if (obj.speed) pbf.writeFloatField(5, obj.speed);
};
// TripDescriptor ========================================
var TripDescriptor = exports.TripDescriptor = {};
TripDescriptor.read = function (pbf, end) {
return pbf.readFields(TripDescriptor._readField, {trip_id: "", route_id: "", direction_id: 0, start_time: "", start_date: "", schedule_relationship: 0}, end);
};
TripDescriptor._readField = function (tag, obj, pbf) {
if (tag === 1) obj.trip_id = pbf.readString();
else if (tag === 5) obj.route_id = pbf.readString();
else if (tag === 6) obj.direction_id = pbf.readVarint();
else if (tag === 2) obj.start_time = pbf.readString();
else if (tag === 3) obj.start_date = pbf.readString();
else if (tag === 4) obj.schedule_relationship = pbf.readVarint();
};
TripDescriptor.write = function (obj, pbf) {
if (obj.trip_id) pbf.writeStringField(1, obj.trip_id);
if (obj.route_id) pbf.writeStringField(5, obj.route_id);
if (obj.direction_id) pbf.writeVarintField(6, obj.direction_id);
if (obj.start_time) pbf.writeStringField(2, obj.start_time);
if (obj.start_date) pbf.writeStringField(3, obj.start_date);
if (obj.schedule_relationship) pbf.writeVarintField(4, obj.schedule_relationship);
};
TripDescriptor.ScheduleRelationship = {
"SCHEDULED": {
"value": 0,
"options": {}
},
"ADDED": {
"value": 1,
"options": {}
},
"UNSCHEDULED": {
"value": 2,
"options": {}
},
"CANCELED": {
"value": 3,
"options": {}
},
"REPLACEMENT": {
"value": 5,
"options": {
"deprecated": "true"
}
},
"DUPLICATED": {
"value": 6,
"options": {}
}
};
// VehicleDescriptor ========================================
var VehicleDescriptor = exports.VehicleDescriptor = {};
VehicleDescriptor.read = function (pbf, end) {
return pbf.readFields(VehicleDescriptor._readField, {id: "", label: "", license_plate: ""}, end);
};
VehicleDescriptor._readField = function (tag, obj, pbf) {
if (tag === 1) obj.id = pbf.readString();
else if (tag === 2) obj.label = pbf.readString();
else if (tag === 3) obj.license_plate = pbf.readString();
};
VehicleDescriptor.write = function (obj, pbf) {
if (obj.id) pbf.writeStringField(1, obj.id);
if (obj.label) pbf.writeStringField(2, obj.label);
if (obj.license_plate) pbf.writeStringField(3, obj.license_plate);
};
// EntitySelector ========================================
var EntitySelector = exports.EntitySelector = {};
EntitySelector.read = function (pbf, end) {
return pbf.readFields(EntitySelector._readField, {agency_id: "", route_id: "", route_type: 0, trip: null, stop_id: "", direction_id: 0}, end);
};
EntitySelector._readField = function (tag, obj, pbf) {
if (tag === 1) obj.agency_id = pbf.readString();
else if (tag === 2) obj.route_id = pbf.readString();
else if (tag === 3) obj.route_type = pbf.readVarint(true);
else if (tag === 4) obj.trip = TripDescriptor.read(pbf, pbf.readVarint() + pbf.pos);
else if (tag === 5) obj.stop_id = pbf.readString();
else if (tag === 6) obj.direction_id = pbf.readVarint();
};
EntitySelector.write = function (obj, pbf) {
if (obj.agency_id) pbf.writeStringField(1, obj.agency_id);
if (obj.route_id) pbf.writeStringField(2, obj.route_id);
if (obj.route_type) pbf.writeVarintField(3, obj.route_type);
if (obj.trip) pbf.writeMessage(4, TripDescriptor.write, obj.trip);
if (obj.stop_id) pbf.writeStringField(5, obj.stop_id);
if (obj.direction_id) pbf.writeVarintField(6, obj.direction_id);
};
// TranslatedString ========================================
var TranslatedString = exports.TranslatedString = {};
TranslatedString.read = function (pbf, end) {
return pbf.readFields(TranslatedString._readField, {translation: []}, end);
};
TranslatedString._readField = function (tag, obj, pbf) {
if (tag === 1) obj.translation.push(TranslatedString.Translation.read(pbf, pbf.readVarint() + pbf.pos));
};
TranslatedString.write = function (obj, pbf) {
if (obj.translation) for (var i = 0; i < obj.translation.length; i++) pbf.writeMessage(1, TranslatedString.Translation.write, obj.translation[i]);
};
// TranslatedString.Translation ========================================
TranslatedString.Translation = {};
TranslatedString.Translation.read = function (pbf, end) {
return pbf.readFields(TranslatedString.Translation._readField, {text: "", language: ""}, end);
};
TranslatedString.Translation._readField = function (tag, obj, pbf) {
if (tag === 1) obj.text = pbf.readString();
else if (tag === 2) obj.language = pbf.readString();
};
TranslatedString.Translation.write = function (obj, pbf) {
if (obj.text) pbf.writeStringField(1, obj.text);
if (obj.language) pbf.writeStringField(2, obj.language);
};
// TranslatedImage ========================================
var TranslatedImage = exports.TranslatedImage = {};
TranslatedImage.read = function (pbf, end) {
return pbf.readFields(TranslatedImage._readField, {localized_image: []}, end);
};
TranslatedImage._readField = function (tag, obj, pbf) {
if (tag === 1) obj.localized_image.push(TranslatedImage.LocalizedImage.read(pbf, pbf.readVarint() + pbf.pos));
};
TranslatedImage.write = function (obj, pbf) {
if (obj.localized_image) for (var i = 0; i < obj.localized_image.length; i++) pbf.writeMessage(1, TranslatedImage.LocalizedImage.write, obj.localized_image[i]);
};
// TranslatedImage.LocalizedImage ========================================
TranslatedImage.LocalizedImage = {};
TranslatedImage.LocalizedImage.read = function (pbf, end) {
return pbf.readFields(TranslatedImage.LocalizedImage._readField, {url: "", media_type: "", language: ""}, end);
};
TranslatedImage.LocalizedImage._readField = function (tag, obj, pbf) {
if (tag === 1) obj.url = pbf.readString();
else if (tag === 2) obj.media_type = pbf.readString();
else if (tag === 3) obj.language = pbf.readString();
};
TranslatedImage.LocalizedImage.write = function (obj, pbf) {
if (obj.url) pbf.writeStringField(1, obj.url);
if (obj.media_type) pbf.writeStringField(2, obj.media_type);
if (obj.language) pbf.writeStringField(3, obj.language);
};
// Shape ========================================
var Shape = exports.Shape = {};
Shape.read = function (pbf, end) {
return pbf.readFields(Shape._readField, {shape_id: "", encoded_polyline: ""}, end);
};
Shape._readField = function (tag, obj, pbf) {
if (tag === 1) obj.shape_id = pbf.readString();
else if (tag === 2) obj.encoded_polyline = pbf.readString();
};
Shape.write = function (obj, pbf) {
if (obj.shape_id) pbf.writeStringField(1, obj.shape_id);
if (obj.encoded_polyline) pbf.writeStringField(2, obj.encoded_polyline);
};

View File

@ -0,0 +1,995 @@
// 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.
//
// GTFS Realtime lets transit agencies provide consumers with realtime
// information about disruptions to their service (stations closed, lines not
// operating, important delays etc), location of their vehicles and expected
// arrival times.
//
// This protocol is published at:
// https://github.com/google/transit/tree/master/gtfs-realtime
syntax = "proto2";
option java_package = "com.google.transit.realtime";
package transit_realtime;
// The contents of a feed message.
// A feed is a continuous stream of feed messages. Each message in the stream is
// obtained as a response to an appropriate HTTP GET request.
// A realtime feed is always defined with relation to an existing GTFS feed.
// All the entity ids are resolved with respect to the GTFS feed.
// Note that "required" and "optional" as stated in this file refer to Protocol
// Buffer cardinality, not semantic cardinality. See reference.md at
// https://github.com/google/transit/tree/master/gtfs-realtime for field
// semantic cardinality.
message FeedMessage {
// Metadata about this feed and feed message.
required FeedHeader header = 1;
// Contents of the feed.
repeated FeedEntity entity = 2;
// The extensions namespace allows 3rd-party developers to extend the
// GTFS Realtime specification in order to add and evaluate new features and
// modifications to the spec.
extensions 1000 to 1999;
// The following extension IDs are reserved for private use by any organization.
extensions 9000 to 9999;
}
// Metadata about a feed, included in feed messages.
message FeedHeader {
// Version of the feed specification.
// The current version is 2.0. Valid versions are "2.0", "1.0".
required string gtfs_realtime_version = 1;
// Determines whether the current fetch is incremental. Currently,
// DIFFERENTIAL mode is unsupported and behavior is unspecified for feeds
// that use this mode. There are discussions on the GTFS Realtime mailing
// list around fully specifying the behavior of DIFFERENTIAL mode and the
// documentation will be updated when those discussions are finalized.
enum Incrementality {
FULL_DATASET = 0;
DIFFERENTIAL = 1;
}
optional Incrementality incrementality = 2 [default = FULL_DATASET];
// This timestamp identifies the moment when the content of this feed has been
// created (in server time). In POSIX time (i.e., number of seconds since
// January 1st 1970 00:00:00 UTC).
optional uint64 timestamp = 3;
// The extensions namespace allows 3rd-party developers to extend the
// GTFS Realtime specification in order to add and evaluate new features and
// modifications to the spec.
extensions 1000 to 1999;
// The following extension IDs are reserved for private use by any organization.
extensions 9000 to 9999;
}
// A definition (or update) of an entity in the transit feed.
message FeedEntity {
// The ids are used only to provide incrementality support. The id should be
// unique within a FeedMessage. Consequent FeedMessages may contain
// FeedEntities with the same id. In case of a DIFFERENTIAL update the new
// FeedEntity with some id will replace the old FeedEntity with the same id
// (or delete it - see is_deleted below).
// The actual GTFS entities (e.g. stations, routes, trips) referenced by the
// feed must be specified by explicit selectors (see EntitySelector below for
// more info).
required string id = 1;
// Whether this entity is to be deleted. Relevant only for incremental
// fetches.
optional bool is_deleted = 2 [default = false];
// Data about the entity itself. Exactly one of the following fields must be
// present (unless the entity is being deleted).
optional TripUpdate trip_update = 3;
optional VehiclePosition vehicle = 4;
optional Alert alert = 5;
// NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future.
optional Shape shape = 6;
// The extensions namespace allows 3rd-party developers to extend the
// GTFS Realtime Specification in order to add and evaluate new features and
// modifications to the spec.
extensions 1000 to 1999;
// The following extension IDs are reserved for private use by any organization.
extensions 9000 to 9999;
}
//
// Entities used in the feed.
//
// Realtime update of the progress of a vehicle along a trip.
// Depending on the value of ScheduleRelationship, a TripUpdate can specify:
// - A trip that proceeds along the schedule.
// - A trip that proceeds along a route but has no fixed schedule.
// - A trip that have been added or removed with regard to schedule.
//
// The updates can be for future, predicted arrival/departure events, or for
// past events that already occurred.
// Normally, updates should get more precise and more certain (see
// uncertainty below) as the events gets closer to current time.
// Even if that is not possible, the information for past events should be
// precise and certain. In particular, if an update points to time in the past
// but its update's uncertainty is not 0, the client should conclude that the
// update is a (wrong) prediction and that the trip has not completed yet.
//
// Note that the update can describe a trip that is already completed.
// To this end, it is enough to provide an update for the last stop of the trip.
// If the time of that is in the past, the client will conclude from that that
// the whole trip is in the past (it is possible, although inconsequential, to
// also provide updates for preceding stops).
// This option is most relevant for a trip that has completed ahead of schedule,
// but according to the schedule, the trip is still proceeding at the current
// time. Removing the updates for this trip could make the client assume
// that the trip is still proceeding.
// Note that the feed provider is allowed, but not required, to purge past
// updates - this is one case where this would be practically useful.
message TripUpdate {
// The Trip that this message applies to. There can be at most one
// TripUpdate entity for each actual trip instance.
// If there is none, that means there is no prediction information available.
// It does *not* mean that the trip is progressing according to schedule.
required TripDescriptor trip = 1;
// Additional information on the vehicle that is serving this trip.
optional VehicleDescriptor vehicle = 3;
// Timing information for a single predicted event (either arrival or
// departure).
// Timing consists of delay and/or estimated time, and uncertainty.
// - delay should be used when the prediction is given relative to some
// existing schedule in GTFS.
// - time should be given whether there is a predicted schedule or not. If
// both time and delay are specified, time will take precedence
// (although normally, time, if given for a scheduled trip, should be
// equal to scheduled time in GTFS + delay).
//
// Uncertainty applies equally to both time and delay.
// The uncertainty roughly specifies the expected error in true delay (but
// note, we don't yet define its precise statistical meaning). It's possible
// for the uncertainty to be 0, for example for trains that are driven under
// computer timing control.
message StopTimeEvent {
// Delay (in seconds) can be positive (meaning that the vehicle is late) or
// negative (meaning that the vehicle is ahead of schedule). Delay of 0
// means that the vehicle is exactly on time.
optional int32 delay = 1;
// Event as absolute time.
// In Unix time (i.e., number of seconds since January 1st 1970 00:00:00
// UTC).
optional int64 time = 2;
// If uncertainty is omitted, it is interpreted as unknown.
// If the prediction is unknown or too uncertain, the delay (or time) field
// should be empty. In such case, the uncertainty field is ignored.
// To specify a completely certain prediction, set its uncertainty to 0.
optional int32 uncertainty = 3;
// The extensions namespace allows 3rd-party developers to extend the
// GTFS Realtime Specification in order to add and evaluate new features
// and modifications to the spec.
extensions 1000 to 1999;
// The following extension IDs are reserved for private use by any organization.
extensions 9000 to 9999;
}
// Realtime update for arrival and/or departure events for a given stop on a
// trip. Updates can be supplied for both past and future events.
// The producer is allowed, although not required, to drop past events.
message StopTimeUpdate {
// The update is linked to a specific stop either through stop_sequence or
// stop_id, so one of the fields below must necessarily be set.
// See the documentation in TripDescriptor for more information.
// Must be the same as in stop_times.txt in the corresponding GTFS feed.
optional uint32 stop_sequence = 1;
// Must be the same as in stops.txt in the corresponding GTFS feed.
optional string stop_id = 4;
optional StopTimeEvent arrival = 2;
optional StopTimeEvent departure = 3;
// Expected occupancy after departure from the given stop.
// Should be provided only for future stops.
// In order to provide departure_occupancy_status without either arrival or
// departure StopTimeEvents, ScheduleRelationship should be set to NO_DATA.
optional VehiclePosition.OccupancyStatus departure_occupancy_status = 7;
// The relation between the StopTimeEvents and the static schedule.
enum ScheduleRelationship {
// The vehicle is proceeding in accordance with its static schedule of
// stops, although not necessarily according to the times of the schedule.
// At least one of arrival and departure must be provided. If the schedule
// for this stop contains both arrival and departure times then so must
// this update. Frequency-based trips (GTFS frequencies.txt with exact_times = 0)
// should not have a SCHEDULED value and should use UNSCHEDULED instead.
SCHEDULED = 0;
// The stop is skipped, i.e., the vehicle will not stop at this stop.
// Arrival and departure are optional.
SKIPPED = 1;
// No StopTimeEvents are given for this stop.
// The main intention for this value is to give time predictions only for
// part of a trip, i.e., if the last update for a trip has a NO_DATA
// specifier, then StopTimeEvents for the rest of the stops in the trip
// are considered to be unspecified as well.
// Neither arrival nor departure should be supplied.
NO_DATA = 2;
// The vehicle is operating a trip defined in GTFS frequencies.txt with exact_times = 0.
// This value should not be used for trips that are not defined in GTFS frequencies.txt,
// or trips in GTFS frequencies.txt with exact_times = 1. Trips containing StopTimeUpdates
// with ScheduleRelationship=UNSCHEDULED must also set TripDescriptor.ScheduleRelationship=UNSCHEDULED.
// NOTE: This field is still experimental, and subject to change. It may be
// formally adopted in the future.
UNSCHEDULED = 3;
}
optional ScheduleRelationship schedule_relationship = 5
[default = SCHEDULED];
// Provides the updated values for the stop time.
// NOTE: This message is still experimental, and subject to change. It may be formally adopted in the future.
message StopTimeProperties {
// Supports real-time stop assignments. Refers to a stop_id defined in the GTFS stops.txt.
// The new assigned_stop_id should not result in a significantly different trip experience for the end user than
// the stop_id defined in GTFS stop_times.txt. In other words, the end user should not view this new stop_id as an
// "unusual change" if the new stop was presented within an app without any additional context.
// For example, this field is intended to be used for platform assignments by using a stop_id that belongs to the
// same station as the stop originally defined in GTFS stop_times.txt.
// To assign a stop without providing any real-time arrival or departure predictions, populate this field and set
// StopTimeUpdate.schedule_relationship = NO_DATA.
// If this field is populated, it is preferred to omit `StopTimeUpdate.stop_id` and use only `StopTimeUpdate.stop_sequence`. If
// `StopTimeProperties.assigned_stop_id` and `StopTimeUpdate.stop_id` are populated, `StopTimeUpdate.stop_id` must match `assigned_stop_id`.
// Platform assignments should be reflected in other GTFS-realtime fields as well
// (e.g., `VehiclePosition.stop_id`).
// NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future.
optional string assigned_stop_id = 1;
// The extensions namespace allows 3rd-party developers to extend the
// GTFS Realtime Specification in order to add and evaluate new features
// and modifications to the spec.
extensions 1000 to 1999;
// The following extension IDs are reserved for private use by any organization.
extensions 9000 to 9999;
}
// Realtime updates for certain properties defined within GTFS stop_times.txt
// NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future.
optional StopTimeProperties stop_time_properties = 6;
// The extensions namespace allows 3rd-party developers to extend the
// GTFS Realtime Specification in order to add and evaluate new features
// and modifications to the spec.
extensions 1000 to 1999;
// The following extension IDs are reserved for private use by any organization.
extensions 9000 to 9999;
}
// Updates to StopTimes for the trip (both future, i.e., predictions, and in
// some cases, past ones, i.e., those that already happened).
// The updates must be sorted by stop_sequence, and apply for all the
// following stops of the trip up to the next specified one.
//
// Example 1:
// For a trip with 20 stops, a StopTimeUpdate with arrival delay and departure
// delay of 0 for stop_sequence of the current stop means that the trip is
// exactly on time.
//
// Example 2:
// For the same trip instance, 3 StopTimeUpdates are provided:
// - delay of 5 min for stop_sequence 3
// - delay of 1 min for stop_sequence 8
// - delay of unspecified duration for stop_sequence 10
// This will be interpreted as:
// - stop_sequences 3,4,5,6,7 have delay of 5 min.
// - stop_sequences 8,9 have delay of 1 min.
// - stop_sequences 10,... have unknown delay.
repeated StopTimeUpdate stop_time_update = 2;
// The most recent moment at which the vehicle's real-time progress was measured
// to estimate StopTimes in the future. When StopTimes in the past are provided,
// arrival/departure times may be earlier than this value. In POSIX
// time (i.e., the number of seconds since January 1st 1970 00:00:00 UTC).
optional uint64 timestamp = 4;
// The current schedule deviation for the trip. Delay should only be
// specified when the prediction is given relative to some existing schedule
// in GTFS.
//
// Delay (in seconds) can be positive (meaning that the vehicle is late) or
// negative (meaning that the vehicle is ahead of schedule). Delay of 0
// means that the vehicle is exactly on time.
//
// Delay information in StopTimeUpdates take precedent of trip-level delay
// information, such that trip-level delay is only propagated until the next
// stop along the trip with a StopTimeUpdate delay value specified.
//
// Feed providers are strongly encouraged to provide a TripUpdate.timestamp
// value indicating when the delay value was last updated, in order to
// evaluate the freshness of the data.
//
// NOTE: This field is still experimental, and subject to change. It may be
// formally adopted in the future.
optional int32 delay = 5;
// Defines updated properties of the trip, such as a new shape_id when there is a detour. Or defines the
// trip_id, start_date, and start_time of a DUPLICATED trip.
// NOTE: This message is still experimental, and subject to change. It may be formally adopted in the future.
message TripProperties {
// Defines the identifier of a new trip that is a duplicate of an existing trip defined in (CSV) GTFS trips.txt
// but will start at a different service date and/or time (defined using the TripProperties.start_date and
// TripProperties.start_time fields). See definition of trips.trip_id in (CSV) GTFS. Its value must be different
// than the ones used in the (CSV) GTFS. Required if schedule_relationship=DUPLICATED, otherwise this field must not
// be populated and will be ignored by consumers.
// NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future.
optional string trip_id = 1;
// Service date on which the DUPLICATED trip will be run, in YYYYMMDD format. Required if
// schedule_relationship=DUPLICATED, otherwise this field must not be populated and will be ignored by consumers.
// NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future.
optional string start_date = 2;
// Defines the departure start time of the trip when its duplicated. See definition of stop_times.departure_time
// in (CSV) GTFS. Scheduled arrival and departure times for the duplicated trip are calculated based on the offset
// between the original trip departure_time and this field. For example, if a GTFS trip has stop A with a
// departure_time of 10:00:00 and stop B with departure_time of 10:01:00, and this field is populated with the value
// of 10:30:00, stop B on the duplicated trip will have a scheduled departure_time of 10:31:00. Real-time prediction
// delay values are applied to this calculated schedule time to determine the predicted time. For example, if a
// departure delay of 30 is provided for stop B, then the predicted departure time is 10:31:30. Real-time
// prediction time values do not have any offset applied to them and indicate the predicted time as provided.
// For example, if a departure time representing 10:31:30 is provided for stop B, then the predicted departure time
// is 10:31:30. This field is required if schedule_relationship is DUPLICATED, otherwise this field must not be
// populated and will be ignored by consumers.
// NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future.
optional string start_time = 3;
// Specifies the shape of the vehicle travel path when the trip shape differs from the shape specified in
// (CSV) GTFS or to specify it in real-time when it's not provided by (CSV) GTFS, such as a vehicle that takes differing
// paths based on rider demand. See definition of trips.shape_id in (CSV) GTFS. If a shape is neither defined in (CSV) GTFS
// nor in real-time, the shape is considered unknown. This field can refer to a shape defined in the (CSV) GTFS in shapes.txt
// or a Shape in the (protobuf) real-time feed. The order of stops (stop sequences) for this trip must remain the same as
// (CSV) GTFS. Stops that are a part of the original trip but will no longer be made, such as when a detour occurs, should
// be marked as schedule_relationship=SKIPPED.
// NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future.
optional string shape_id = 4;
// The extensions namespace allows 3rd-party developers to extend the
// GTFS Realtime Specification in order to add and evaluate new features
// and modifications to the spec.
extensions 1000 to 1999;
// The following extension IDs are reserved for private use by any organization.
extensions 9000 to 9999;
}
optional TripProperties trip_properties = 6;
// The extensions namespace allows 3rd-party developers to extend the
// GTFS Realtime Specification in order to add and evaluate new features and
// modifications to the spec.
extensions 1000 to 1999;
// The following extension IDs are reserved for private use by any organization.
extensions 9000 to 9999;
}
// Realtime positioning information for a given vehicle.
message VehiclePosition {
// The Trip that this vehicle is serving.
// Can be empty or partial if the vehicle can not be identified with a given
// trip instance.
optional TripDescriptor trip = 1;
// Additional information on the vehicle that is serving this trip.
optional VehicleDescriptor vehicle = 8;
// Current position of this vehicle.
optional Position position = 2;
// The stop sequence index of the current stop. The meaning of
// current_stop_sequence (i.e., the stop that it refers to) is determined by
// current_status.
// If current_status is missing IN_TRANSIT_TO is assumed.
optional uint32 current_stop_sequence = 3;
// Identifies the current stop. The value must be the same as in stops.txt in
// the corresponding GTFS feed.
optional string stop_id = 7;
enum VehicleStopStatus {
// The vehicle is just about to arrive at the stop (on a stop
// display, the vehicle symbol typically flashes).
INCOMING_AT = 0;
// The vehicle is standing at the stop.
STOPPED_AT = 1;
// The vehicle has departed and is in transit to the next stop.
IN_TRANSIT_TO = 2;
}
// The exact status of the vehicle with respect to the current stop.
// Ignored if current_stop_sequence is missing.
optional VehicleStopStatus current_status = 4 [default = IN_TRANSIT_TO];
// Moment at which the vehicle's position was measured. In POSIX time
// (i.e., number of seconds since January 1st 1970 00:00:00 UTC).
optional uint64 timestamp = 5;
// Congestion level that is affecting this vehicle.
enum CongestionLevel {
UNKNOWN_CONGESTION_LEVEL = 0;
RUNNING_SMOOTHLY = 1;
STOP_AND_GO = 2;
CONGESTION = 3;
SEVERE_CONGESTION = 4; // People leaving their cars.
}
optional CongestionLevel congestion_level = 6;
// The state of passenger occupancy for the vehicle or carriage.
// Individual producers may not publish all OccupancyStatus values. Therefore, consumers
// must not assume that the OccupancyStatus values follow a linear scale.
// Consumers should represent OccupancyStatus values as the state indicated
// and intended by the producer. Likewise, producers must use OccupancyStatus values that
// correspond to actual vehicle occupancy states.
// For describing passenger occupancy levels on a linear scale, see `occupancy_percentage`.
// This field is still experimental, and subject to change. It may be formally adopted in the future.
enum OccupancyStatus {
// The vehicle or carriage is considered empty by most measures, and has few or no
// passengers onboard, but is still accepting passengers.
EMPTY = 0;
// The vehicle or carriage has a large number of seats available.
// The amount of free seats out of the total seats available to be
// considered large enough to fall into this category is determined at the
// discretion of the producer.
MANY_SEATS_AVAILABLE = 1;
// The vehicle or carriage has a relatively small number of seats available.
// The amount of free seats out of the total seats available to be
// considered small enough to fall into this category is determined at the
// discretion of the feed producer.
FEW_SEATS_AVAILABLE = 2;
// The vehicle or carriage can currently accommodate only standing passengers.
STANDING_ROOM_ONLY = 3;
// The vehicle or carriage can currently accommodate only standing passengers
// and has limited space for them.
CRUSHED_STANDING_ROOM_ONLY = 4;
// The vehicle or carriage is considered full by most measures, but may still be
// allowing passengers to board.
FULL = 5;
// The vehicle or carriage is not accepting passengers, but usually accepts passengers for boarding.
NOT_ACCEPTING_PASSENGERS = 6;
// The vehicle or carriage doesn't have any occupancy data available at that time.
NO_DATA_AVAILABLE = 7;
// The vehicle or carriage is not boardable and never accepts passengers.
// Useful for special vehicles or carriages (engine, maintenance carriage, etc).
NOT_BOARDABLE = 8;
}
// If multi_carriage_status is populated with per-carriage OccupancyStatus,
// then this field should describe the entire vehicle with all carriages accepting passengers considered.
optional OccupancyStatus occupancy_status = 9;
// A percentage value indicating the degree of passenger occupancy in the vehicle.
// The values are represented as an integer without decimals. 0 means 0% and 100 means 100%.
// The value 100 should represent the total maximum occupancy the vehicle was designed for,
// including both seated and standing capacity, and current operating regulations allow.
// The value may exceed 100 if there are more passengers than the maximum designed capacity.
// The precision of occupancy_percentage should be low enough that individual passengers cannot be tracked boarding or alighting the vehicle.
// If multi_carriage_status is populated with per-carriage occupancy_percentage,
// then this field should describe the entire vehicle with all carriages accepting passengers considered.
// This field is still experimental, and subject to change. It may be formally adopted in the future.
optional uint32 occupancy_percentage = 10;
// Carriage specific details, used for vehicles composed of several carriages
// This message/field is still experimental, and subject to change. It may be formally adopted in the future.
message CarriageDetails {
// Identification of the carriage. Should be unique per vehicle.
optional string id = 1;
// User visible label that may be shown to the passenger to help identify
// the carriage. Example: "7712", "Car ABC-32", etc...
// This message/field is still experimental, and subject to change. It may be formally adopted in the future.
optional string label = 2;
// Occupancy status for this given carriage, in this vehicle
// This message/field is still experimental, and subject to change. It may be formally adopted in the future.
optional OccupancyStatus occupancy_status = 3 [default = NO_DATA_AVAILABLE];
// Occupancy percentage for this given carriage, in this vehicle.
// Follows the same rules as "VehiclePosition.occupancy_percentage"
// -1 in case data is not available for this given carriage (as protobuf defaults to 0 otherwise)
// This message/field is still experimental, and subject to change. It may be formally adopted in the future.
optional int32 occupancy_percentage = 4 [default = -1];
// Identifies the order of this carriage with respect to the other
// carriages in the vehicle's list of CarriageDetails.
// The first carriage in the direction of travel must have a value of 1.
// The second value corresponds to the second carriage in the direction
// of travel and must have a value of 2, and so forth.
// For example, the first carriage in the direction of travel has a value of 1.
// If the second carriage in the direction of travel has a value of 3,
// consumers will discard data for all carriages (i.e., the multi_carriage_details field).
// Carriages without data must be represented with a valid carriage_sequence number and the fields
// without data should be omitted (alternately, those fields could also be included and set to the "no data" values).
// This message/field is still experimental, and subject to change. It may be formally adopted in the future.
optional uint32 carriage_sequence = 5;
// The extensions namespace allows 3rd-party developers to extend the
// GTFS Realtime Specification in order to add and evaluate new features and
// modifications to the spec.
extensions 1000 to 1999;
// The following extension IDs are reserved for private use by any organization.
extensions 9000 to 9999;
}
// Details of the multiple carriages of this given vehicle.
// The first occurrence represents the first carriage of the vehicle,
// given the current direction of travel.
// The number of occurrences of the multi_carriage_details
// field represents the number of carriages of the vehicle.
// It also includes non boardable carriages,
// like engines, maintenance carriages, etc as they provide valuable
// information to passengers about where to stand on a platform.
// This message/field is still experimental, and subject to change. It may be formally adopted in the future.
repeated CarriageDetails multi_carriage_details = 11;
// The extensions namespace allows 3rd-party developers to extend the
// GTFS Realtime Specification in order to add and evaluate new features and
// modifications to the spec.
extensions 1000 to 1999;
// The following extension IDs are reserved for private use by any organization.
extensions 9000 to 9999;
}
// An alert, indicating some sort of incident in the public transit network.
message Alert {
// Time when the alert should be shown to the user. If missing, the
// alert will be shown as long as it appears in the feed.
// If multiple ranges are given, the alert will be shown during all of them.
repeated TimeRange active_period = 1;
// Entities whose users we should notify of this alert.
repeated EntitySelector informed_entity = 5;
// Cause of this alert.
enum Cause {
UNKNOWN_CAUSE = 1;
OTHER_CAUSE = 2; // Not machine-representable.
TECHNICAL_PROBLEM = 3;
STRIKE = 4; // Public transit agency employees stopped working.
DEMONSTRATION = 5; // People are blocking the streets.
ACCIDENT = 6;
HOLIDAY = 7;
WEATHER = 8;
MAINTENANCE = 9;
CONSTRUCTION = 10;
POLICE_ACTIVITY = 11;
MEDICAL_EMERGENCY = 12;
}
optional Cause cause = 6 [default = UNKNOWN_CAUSE];
// What is the effect of this problem on the affected entity.
enum Effect {
NO_SERVICE = 1;
REDUCED_SERVICE = 2;
// We don't care about INsignificant delays: they are hard to detect, have
// little impact on the user, and would clutter the results as they are too
// frequent.
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;
}
optional Effect effect = 7 [default = UNKNOWN_EFFECT];
// The URL which provides additional information about the alert.
optional TranslatedString url = 8;
// Alert header. Contains a short summary of the alert text as plain-text.
optional TranslatedString header_text = 10;
// Full description for the alert as plain-text. The information in the
// description should add to the information of the header.
optional TranslatedString description_text = 11;
// Text for alert header to be used in text-to-speech implementations. This field is the text-to-speech version of header_text.
optional TranslatedString tts_header_text = 12;
// Text for full description for the alert to be used in text-to-speech implementations. This field is the text-to-speech version of description_text.
optional TranslatedString tts_description_text = 13;
// Severity of this alert.
enum SeverityLevel {
UNKNOWN_SEVERITY = 1;
INFO = 2;
WARNING = 3;
SEVERE = 4;
}
optional SeverityLevel severity_level = 14 [default = UNKNOWN_SEVERITY];
// TranslatedImage to be displayed along the alert text. Used to explain visually the alert effect of a detour, station closure, etc. The image must enhance the understanding of the alert. Any essential information communicated within the image must also be contained in the alert text.
// The following types of images are discouraged : image containing mainly text, marketing or branded images that add no additional information.
// NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future.
optional TranslatedImage image = 15;
// Text describing the appearance of the linked image in the `image` field (e.g., in case the image can't be displayed
// or the user can't see the image for accessibility reasons). See the HTML spec for alt image text - https://html.spec.whatwg.org/#alt.
// NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future.
optional TranslatedString image_alternative_text = 16;
// The extensions namespace allows 3rd-party developers to extend the
// GTFS Realtime Specification in order to add and evaluate new features
// and modifications to the spec.
extensions 1000 to 1999;
// The following extension IDs are reserved for private use by any organization.
extensions 9000 to 9999;
}
//
// Low level data structures used above.
//
// A time interval. The interval is considered active at time 't' if 't' is
// greater than or equal to the start time and less than the end time.
message TimeRange {
// Start time, in POSIX time (i.e., number of seconds since January 1st 1970
// 00:00:00 UTC).
// If missing, the interval starts at minus infinity.
optional uint64 start = 1;
// End time, in POSIX time (i.e., number of seconds since January 1st 1970
// 00:00:00 UTC).
// If missing, the interval ends at plus infinity.
optional uint64 end = 2;
// The extensions namespace allows 3rd-party developers to extend the
// GTFS Realtime Specification in order to add and evaluate new features and
// modifications to the spec.
extensions 1000 to 1999;
// The following extension IDs are reserved for private use by any organization.
extensions 9000 to 9999;
}
// A position.
message Position {
// Degrees North, in the WGS-84 coordinate system.
required float latitude = 1;
// Degrees East, in the WGS-84 coordinate system.
required float longitude = 2;
// Bearing, in degrees, clockwise from North, i.e., 0 is North and 90 is East.
// This can be the compass bearing, or the direction towards the next stop
// or intermediate location.
// This should not be direction deduced from the sequence of previous
// positions, which can be computed from previous data.
optional float bearing = 3;
// Odometer value, in meters.
optional double odometer = 4;
// Momentary speed measured by the vehicle, in meters per second.
optional float speed = 5;
// The extensions namespace allows 3rd-party developers to extend the
// GTFS Realtime Specification in order to add and evaluate new features and
// modifications to the spec.
extensions 1000 to 1999;
// The following extension IDs are reserved for private use by any organization.
extensions 9000 to 9999;
}
// A descriptor that identifies an instance of a GTFS trip, or all instances of
// a trip along a route.
// - To specify a single trip instance, the trip_id (and if necessary,
// start_time) is set. If route_id is also set, then it should be same as one
// that the given trip corresponds to.
// - To specify all the trips along a given route, only the route_id should be
// set. Note that if the trip_id is not known, then stop sequence ids in
// TripUpdate are not sufficient, and stop_ids must be provided as well. In
// addition, absolute arrival/departure times must be provided.
message TripDescriptor {
// The trip_id from the GTFS feed that this selector refers to.
// For non frequency-based trips, this field is enough to uniquely identify
// the trip. For frequency-based trip, start_time and start_date might also be
// necessary. When schedule_relationship is DUPLICATED within a TripUpdate, the trip_id identifies the trip from
// static GTFS to be duplicated. When schedule_relationship is DUPLICATED within a VehiclePosition, the trip_id
// identifies the new duplicate trip and must contain the value for the corresponding TripUpdate.TripProperties.trip_id.
optional string trip_id = 1;
// The route_id from the GTFS that this selector refers to.
optional string route_id = 5;
// The direction_id from the GTFS feed trips.txt file, indicating the
// direction of travel for trips this selector refers to.
optional uint32 direction_id = 6;
// The initially scheduled start time of this trip instance.
// When the trip_id corresponds to a non-frequency-based trip, this field
// should either be omitted or be equal to the value in the GTFS feed. When
// the trip_id correponds to a frequency-based trip, the start_time must be
// specified for trip updates and vehicle positions. If the trip corresponds
// to exact_times=1 GTFS record, then start_time must be some multiple
// (including zero) of headway_secs later than frequencies.txt start_time for
// the corresponding time period. If the trip corresponds to exact_times=0,
// then its start_time may be arbitrary, and is initially expected to be the
// first departure of the trip. Once established, the start_time of this
// frequency-based trip should be considered immutable, even if the first
// departure time changes -- that time change may instead be reflected in a
// StopTimeUpdate.
// Format and semantics of the field is same as that of
// GTFS/frequencies.txt/start_time, e.g., 11:15:35 or 25:15:35.
optional string start_time = 2;
// The scheduled start date of this trip instance.
// Must be provided to disambiguate trips that are so late as to collide with
// a scheduled trip on a next day. For example, for a train that departs 8:00
// and 20:00 every day, and is 12 hours late, there would be two distinct
// trips on the same time.
// This field can be provided but is not mandatory for schedules in which such
// collisions are impossible - for example, a service running on hourly
// schedule where a vehicle that is one hour late is not considered to be
// related to schedule anymore.
// In YYYYMMDD format.
optional string start_date = 3;
// The relation between this trip and the static schedule. If a trip is done
// in accordance with temporary schedule, not reflected in GTFS, then it
// shouldn't be marked as SCHEDULED, but likely as ADDED.
enum ScheduleRelationship {
// Trip that is running in accordance with its GTFS schedule, or is close
// enough to the scheduled trip to be associated with it.
SCHEDULED = 0;
// An extra trip that was added in addition to a running schedule, for
// example, to replace a broken vehicle or to respond to sudden passenger
// load.
// NOTE: Currently, behavior is unspecified for feeds that use this mode. There are discussions on the GTFS GitHub
// [(1)](https://github.com/google/transit/issues/106) [(2)](https://github.com/google/transit/pull/221)
// [(3)](https://github.com/google/transit/pull/219) around fully specifying or deprecating ADDED trips and the
// documentation will be updated when those discussions are finalized.
ADDED = 1;
// A trip that is running with no schedule associated to it (GTFS frequencies.txt exact_times=0).
// Trips with ScheduleRelationship=UNSCHEDULED must also set all StopTimeUpdates.ScheduleRelationship=UNSCHEDULED.
UNSCHEDULED = 2;
// A trip that existed in the schedule but was removed.
CANCELED = 3;
// Should not be used - for backwards-compatibility only.
REPLACEMENT = 5 [deprecated=true];
// An extra trip that was added in addition to a running schedule, for example, to replace a broken vehicle or to
// respond to sudden passenger load. Used with TripUpdate.TripProperties.trip_id, TripUpdate.TripProperties.start_date,
// and TripUpdate.TripProperties.start_time to copy an existing trip from static GTFS but start at a different service
// date and/or time. Duplicating a trip is allowed if the service related to the original trip in (CSV) GTFS
// (in calendar.txt or calendar_dates.txt) is operating within the next 30 days. The trip to be duplicated is
// identified via TripUpdate.TripDescriptor.trip_id. This enumeration does not modify the existing trip referenced by
// TripUpdate.TripDescriptor.trip_id - if a producer wants to cancel the original trip, it must publish a separate
// TripUpdate with the value of CANCELED. Trips defined in GTFS frequencies.txt with exact_times that is empty or
// equal to 0 cannot be duplicated. The VehiclePosition.TripDescriptor.trip_id for the new trip must contain
// the matching value from TripUpdate.TripProperties.trip_id and VehiclePosition.TripDescriptor.ScheduleRelationship
// must also be set to DUPLICATED.
// Existing producers and consumers that were using the ADDED enumeration to represent duplicated trips must follow
// the migration guide (https://github.com/google/transit/tree/master/gtfs-realtime/spec/en/examples/migration-duplicated.md)
// to transition to the DUPLICATED enumeration.
// NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future.
DUPLICATED = 6;
}
optional ScheduleRelationship schedule_relationship = 4;
// The extensions namespace allows 3rd-party developers to extend the
// GTFS Realtime Specification in order to add and evaluate new features and
// modifications to the spec.
extensions 1000 to 1999;
// The following extension IDs are reserved for private use by any organization.
extensions 9000 to 9999;
}
// Identification information for the vehicle performing the trip.
message VehicleDescriptor {
// Internal system identification of the vehicle. Should be unique per
// vehicle, and can be used for tracking the vehicle as it proceeds through
// the system.
optional string id = 1;
// User visible label, i.e., something that must be shown to the passenger to
// help identify the correct vehicle.
optional string label = 2;
// The license plate of the vehicle.
optional string license_plate = 3;
// The extensions namespace allows 3rd-party developers to extend the
// GTFS Realtime Specification in order to add and evaluate new features and
// modifications to the spec.
extensions 1000 to 1999;
// The following extension IDs are reserved for private use by any organization.
extensions 9000 to 9999;
}
// A selector for an entity in a GTFS feed.
message EntitySelector {
// The values of the fields should correspond to the appropriate fields in the
// GTFS feed.
// At least one specifier must be given. If several are given, then the
// matching has to apply to all the given specifiers.
optional string agency_id = 1;
optional string route_id = 2;
// corresponds to route_type in GTFS.
optional int32 route_type = 3;
optional TripDescriptor trip = 4;
optional string stop_id = 5;
// Corresponds to trip direction_id in GTFS trips.txt. If provided the
// route_id must also be provided.
optional uint32 direction_id = 6;
// The extensions namespace allows 3rd-party developers to extend the
// GTFS Realtime Specification in order to add and evaluate new features and
// modifications to the spec.
extensions 1000 to 1999;
// The following extension IDs are reserved for private use by any organization.
extensions 9000 to 9999;
}
// An internationalized message containing per-language versions of a snippet of
// text or a URL.
// One of the strings from a message will be picked up. The resolution proceeds
// as follows:
// 1. If the UI language matches the language code of a translation,
// the first matching translation is picked.
// 2. If a default UI language (e.g., English) matches the language code of a
// translation, the first matching translation is picked.
// 3. If some translation has an unspecified language code, that translation is
// picked.
message TranslatedString {
message Translation {
// A UTF-8 string containing the message.
required string text = 1;
// BCP-47 language code. Can be omitted if the language is unknown or if
// no i18n is done at all for the feed. At most one translation is
// allowed to have an unspecified language tag.
optional string language = 2;
// The extensions namespace allows 3rd-party developers to extend the
// GTFS Realtime Specification in order to add and evaluate new features and
// modifications to the spec.
extensions 1000 to 1999;
// The following extension IDs are reserved for private use by any organization.
extensions 9000 to 9999;
}
// At least one translation must be provided.
repeated Translation translation = 1;
// The extensions namespace allows 3rd-party developers to extend the
// GTFS Realtime Specification in order to add and evaluate new features and
// modifications to the spec.
extensions 1000 to 1999;
// The following extension IDs are reserved for private use by any organization.
extensions 9000 to 9999;
}
// An internationalized image containing per-language versions of a URL linking to an image
// along with meta information
// Only one of the images from a message will be retained by consumers. The resolution proceeds
// as follows:
// 1. If the UI language matches the language code of a translation,
// the first matching translation is picked.
// 2. If a default UI language (e.g., English) matches the language code of a
// translation, the first matching translation is picked.
// 3. If some translation has an unspecified language code, that translation is
// picked.
// NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future.
message TranslatedImage {
message LocalizedImage {
// String containing an URL linking to an image
// The image linked must be less than 2MB.
// If an image changes in a significant enough way that an update is required on the consumer side, the producer must update the URL to a new one.
// The URL should be a fully qualified URL that includes http:// or https://, and any special characters in the URL must be correctly escaped. See the following http://www.w3.org/Addressing/URL/4_URI_Recommentations.html for a description of how to create fully qualified URL values.
required string url = 1;
// IANA media type as to specify the type of image to be displayed.
// The type must start with "image/"
required string media_type = 2;
// BCP-47 language code. Can be omitted if the language is unknown or if
// no i18n is done at all for the feed. At most one translation is
// allowed to have an unspecified language tag.
optional string language = 3;
// The extensions namespace allows 3rd-party developers to extend the
// GTFS Realtime Specification in order to add and evaluate new features and
// modifications to the spec.
extensions 1000 to 1999;
// The following extension IDs are reserved for private use by any organization.
extensions 9000 to 9999;
}
// At least one localized image must be provided.
repeated LocalizedImage localized_image = 1;
// The extensions namespace allows 3rd-party developers to extend the
// GTFS Realtime Specification in order to add and evaluate new features and
// modifications to the spec.
extensions 1000 to 1999;
// The following extension IDs are reserved for private use by any organization.
extensions 9000 to 9999;
}
// Describes the physical path that a vehicle takes when it's not part of the (CSV) GTFS,
// such as for a detour. Shapes belong to Trips, and consist of a sequence of shape points.
// Tracing the points in order provides the path of the vehicle. Shapes do not need to intercept
// the location of Stops exactly, but all Stops on a trip should lie within a small distance of
// the shape for that trip, i.e. close to straight line segments connecting the shape points
// NOTE: This message is still experimental, and subject to change. It may be formally adopted in the future.
message Shape {
// Identifier of the shape. Must be different than any shape_id defined in the (CSV) GTFS.
// This field is required as per reference.md, but needs to be specified here optional because "Required is Forever"
// See https://developers.google.com/protocol-buffers/docs/proto#specifying_field_rules
// NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future.
optional string shape_id = 1;
// Encoded polyline representation of the shape. This polyline must contain at least two points.
// For more information about encoded polylines, see https://developers.google.com/maps/documentation/utilities/polylinealgorithm
// This field is required as per reference.md, but needs to be specified here optional because "Required is Forever"
// See https://developers.google.com/protocol-buffers/docs/proto#specifying_field_rules
// NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future.
optional string encoded_polyline = 2;
// The extensions namespace allows 3rd-party developers to extend the
// GTFS Realtime Specification in order to add and evaluate new features and
// modifications to the spec.
extensions 1000 to 1999;
// The following extension IDs are reserved for private use by any organization.
extensions 9000 to 9999;
}