{"id":19369213,"url":"https://github.com/mapsme/just_gtfs","last_synced_at":"2025-04-23T15:31:25.626Z","repository":{"id":53336506,"uuid":"250751634","full_name":"mapsme/just_gtfs","owner":"mapsme","description":"C++17 header-only library for reading and writing GTFS 🌍 ","archived":false,"fork":false,"pushed_at":"2024-07-05T07:38:22.000Z","size":137,"stargazers_count":22,"open_issues_count":6,"forks_count":18,"subscribers_count":21,"default_branch":"master","last_synced_at":"2025-04-02T16:53:47.084Z","etag":null,"topics":["cpp17","gtfs","gtfs-feed","gtfs-static","header-only","public-transport","tools","transit"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mapsme.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.MIT","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-03-28T08:58:37.000Z","updated_at":"2024-07-05T07:38:25.000Z","dependencies_parsed_at":"2024-05-02T01:34:42.033Z","dependency_job_id":"4ec80069-8f77-4a85-924a-92100e533ad1","html_url":"https://github.com/mapsme/just_gtfs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mapsme%2Fjust_gtfs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mapsme%2Fjust_gtfs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mapsme%2Fjust_gtfs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mapsme%2Fjust_gtfs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mapsme","download_url":"https://codeload.github.com/mapsme/just_gtfs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250460388,"owners_count":21434240,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp17","gtfs","gtfs-feed","gtfs-static","header-only","public-transport","tools","transit"],"created_at":"2024-11-10T08:10:05.240Z","updated_at":"2025-04-23T15:31:25.346Z","avatar_url":"https://github.com/mapsme.png","language":"C++","funding_links":[],"categories":["Uncategorized"],"sub_categories":["Uncategorized"],"readme":"# just_gtfs - header-only modern C++ library for reading and writing GTFS feeds\n\n[![GTFS reader and writer for C++](https://github.com/mapsme/just_gtfs/blob/add-the-most-important-readers/docs/logo.jpeg)](https://github.com/mapsme/just_gtfs)\n\n[![C++](https://img.shields.io/badge/c%2B%2B-17-informational.svg)](https://shields.io/)\n[![MIT license](https://img.shields.io/badge/License-MIT-blue.svg)](https://lbesson.mit-license.org/)\n![](https://github.com/mapsme/just_gtfs/workflows/C%2FC%2B%2B%20CI/badge.svg)\n[![](https://github.com/sindresorhus/awesome/blob/main/media/mentioned-badge.svg)](https://github.com/CUTR-at-USF/awesome-transit)\n[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/mapsme/just_gtfs/issues)\n\n\n## Table of Contents\n- [Description](#description)\n- [Reading and writing GTFS feeds](#reading-and-writing-gtfs-feeds)\n- [How to add library to your project](#how-to-add-library-to-your-project)\n- [Used third-party tools](#used-third-party-tools)\n- [Contributing](#contributing)\n- [Resources](#resources)\n\n## Description\nThe just_gtfs library implements reading and writing static transit data in GTFS - [General Transit Feed Specification](https://developers.google.com/transit/gtfs/reference).\n\nIts main features:\n - Fast reading and writing of GTFS feeds\n - Support for [extended GTFS route types](https://developers.google.com/transit/gtfs/reference/extended-route-types)\n - Simple working with GTFS `Date` and `Time` formats\n - Header-only\n - Written in C++17\n - Tested on GCC and Clang\n\n\n## Reading and writing GTFS feeds\nLibrary provides main class for working with GTFS feeds: `gtfs::Feed`. It also provides classes for each of the 17 GTFS entities: `Route`, `Stop`, `Pathway`, `Translation` and others.\nGTFS csv files are mapped to the corresponding C++ classes. Every GTFS entity can be accessed through `gtfs::Feed` corresponding getters \u0026 setters.\n\n:pushpin: All GTFS entities are managed in the same way. So here is the example for working with `agencies`.\n\nMethod of the `Feed` class for reading `agency.txt`:\n```c++\nResult read_agencies()\n```\n\nMethod for reading reading not only agencies but all GTFS entities. Path to the feed is specified in the `Feed` constructor:\n```c++\nResult read_feed()\n```\n\nMethod for getting reference to the `Agencies` - `std::vector` of all `Agency` objects of the feed:\n```c++\nconst Agencies \u0026 get_agencies()\n```\n\nMethod for finding agency by its id. Returns `std::optional` so you should check if the result is `std::nullopt`:\n```c++\nstd::optional\u003cAgency\u003e get_agency(const Id \u0026 agency_id)\n``` \n\nMethod for adding agency to the feed:\n```c++\nvoid add_agency(const Agency \u0026 agency)\n```\n\nMethod for writing agencies to the `agency.txt` file to `gtfs_path`.\n```c++\nResult write_agencies(const std::string \u0026 gtfs_path)\n```\n\nMethod for writing all GTFS entities (not only agencies, but stops, stop times, calendar etc):\n```c++\nResult write_feed(const std::string \u0026 gtfs_path)\n```\n\n:pushpin: **There are similar methods for all other GTFS entities** for getting the list of entities, finding and adding them.\nFor some of them additional methods are provided. \nFor example, you can find all the stop times for current stop by its id:\n```c++\nStopTimes get_stop_times_for_stop(const Id \u0026 stop_id)\n```\n\nOr you can find stop times for the particular trip:\n```c++\nStopTimes get_stop_times_for_trip(const Id \u0026 trip_id, bool sort_by_sequence = true)\n```\n\n### Example of reading GTFS feed and working with its stops and routes\n:pushpin: Provide `gtfs::Feed` the feed path, read it and work with GTFS entities such as stops and routes:\n```c++\nFeed feed(\"~/data/SFMTA/\");\nif (feed.read_feed() == ResultCode::OK)\n{\n  Stops stops = feed.get_stops();\n  std::cout \u003c\u003c \"Stops count in feed: \" \u003c\u003c stops.size() \u003c\u003c std::endl;\n\n  for (const Stop \u0026 stop: stops)\n  {\n    std::cout \u003c\u003c stop.stop_id \u003c\u003c std::endl;\n  }\n\n  Route route = feed.get_route(\"route_id_1009\");\n  if (route)\n  {\n    std::cout \u003c\u003c route-\u003eroute_long_name \u003c\u003c std::endl;\n  }\n}\n```\n\n### Example of parsing shapes.txt and working with its contents\nGTFS feed can be wholly read from directory as in the example above or you can read GTFS files separately. E.g., if you need only shapes data, you can avoid parsing all other files and just work with the shapes.\n\n:pushpin: Read only `shapes.txt` from the feed and work with shapes:\n```c++\nFeed feed(\"~/data/SFMTA/\");\nif (feed.read_shapes() == ResultCode::OK)\n{\n  Shapes all_shapes = feed.get_shapes();\n  Shape shape = feed.get_shape(\"9367\");\n\n  for (const ShapePoint \u0026 point: shape)\n  {\n    std::cout \u003c\u003c point.shape_pt_lat \u003c\u003c \" \" \u003c\u003c point.shape_pt_lon \u003c\u003c std::endl;\n  }\n}\n```\n\n### Example of writing GTFS:\n:pushpin: If you already filled the `feed` object with data that suits you, you can write it to the corresponding path:\n```c++\nFeed feed;\n\n// Fill feed with agencies, stops, routes and other required data:\n\nfeed.add_trip(some_trip);\nfeed.add_attribution(attr);\n\nfeed.write_feed(\"~/data/custom_feed/\");\n```\n\n## How to add library to your project\n- For including just_gtfs to your own project **as a submodule:** use branch \"for-usage-as-submodule\" which consists of a single header.\n- Another way of including just_gtfs to your project: just_gtfs is completely contained inside a single header and therefore it is sufficient to copy include/just_gtfs/just_gtfs.h to your **include paths.** The library does not have to be explicitly build.\n- For building library and **running tests:**\nClone just_gtfs with `git clone --recursive` or run `git submodule update --init --recursive --remote` after cloning.\nIn the just_gtfs project directory build the project and run unit tests: \n```\ncmake .\nmake\nctest --output-on-failure --verbose\n```\nThe library makes use of the C++17 features and therefore you have to use the appropriate compiler version.\n\n## Used third-party tools\n- [**doctest**](https://github.com/onqtam/doctest) for unit testing.\n\n## Contributing\nPlease open a [Github issue](https://github.com/mapsme/just_gtfs/issues/new) with as much of the information as you're able to specify, or create a [pull request](https://github.com/mapsme/just_gtfs/pulls) according to our [guidelines](https://github.com/mapsme/just_gtfs/blob/master/docs/CPP_STYLE.md).\n\n## Resources\n[GTFS reference in Google GitHub repository](https://github.com/google/transit/blob/master/gtfs/spec/en/reference.md)\n\n[GTFS reference on Google Transit API](https://developers.google.com/transit/gtfs/reference?csw=1)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmapsme%2Fjust_gtfs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmapsme%2Fjust_gtfs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmapsme%2Fjust_gtfs/lists"}