Comments (6)
I visualized it in a diagram:
from osm2gtfs.
Looks nice!
Where are the methods to refresh a route (and maybe even a stop)? Is this cache_refresh
? If so, maybe instead of passing a name, have dedicated methods for each type.
I was passing the routes into get_stops() and sometimes chaining these calls, because there's no point getting a stop if it is not part of a route relation, right? Also, you when you refresh a route, this might add new stops that you didn't have before.
The same applies when you refresh a route master, you might get a new route variant and new stops.
from osm2gtfs.
Refresh routes, stops and single route would happen through cache_refesh
with an argument stating what to refresh:
- cache_refresh('routes')
- cache_refresh('route', '255')
- cache_refresh('stops')
The function cache_refresh
contains a if/elseif statement select what functions to run for refresh. Personally I prefer to have one wrapper function than three single-line functions.
I think it's better to handle stops independently of routes. I can think about several reasons for this:
- We can optimize Overpass queries to not query again and again for each route's stops.
- We can do validation and e.g. print a warning, when stops are not part of any route, or likewise if a route has a stop that is not properly tagged.
- transitfeed handles stops independently from routes and we can also run logic better in encapsulated StopsCreators and RoutesCreators.
For the case when a route refresh comes up with new stops that are not cached already, I introduced the query_stop(osm_id)
function to lazy load these stops.
I generally would like to handle all OSM specific things inside OsmHelper. This means, applied to routes, that from outside (of OsmHelper) there only exist routes (like in GTFS). All RouteMaster and RouteVariant stuff is handled inside the helper. When you refresh a route OsmHelper checks the master relation and route variants for it to be refreshed.
from osm2gtfs.
Alright, sounds good. The cache refresh method is a matter of taste. If we might want to refresh different things in the future, I would agree with the parameter approach, but there will never be more than stops and routes. The arbitrary parameters you need to to error handling and offload to independent methods anyway. So I'd say using dedicated refresh methods is cleaner.
from osm2gtfs.
Yes, indeed, it's a matter of taste. I don't really care. Let's look how it looks like when we implement it. The only addition to refresh I can think of right now, is what you said above: refresh a single stop.
from osm2gtfs.
Refactored with the latest commit. Documenting here the changes and closing the issue.
- Renamed to
OsmConnector
- Moved all caching to a
Cache
class - Added comments to program code
Implemented the following structure:
OsmConnector
- config
- routes {route_id, RouteMaster}
- stops {osm_id, Stop}
-------
+ get_routes(): Dic of RouteMaster
+ get_stops(): Dic of Stop
- _build_route_master(): RouteMaster
- _build_route_variant(): Route
- _build_route_stop(): Stop
- _query_routes(): Dic of RouteMaster
- _query_stops(): List of Stop
from osm2gtfs.
Related Issues (20)
- Add city name to stop HOT 18
- Add city information to Line/Itinieray names HOT 3
- Support multiple values for the same OSM tag HOT 1
- Extend handling of `start_date`/`end_date` to support schedule as a source HOT 5
- Support all possible values of service periods and exceptions HOT 6
- Add alternative schedule source format with frequencies HOT 2
- Core tests HOT 2
- Implement included_lines and excluded_lines in standard trip creator or OsmConnector HOT 7
- Enabling a fast simple creator without timetable HOT 3
- Search for alternative stop name in the stop_area relation if exists before searching for other nodes close to the stop
- Default implementation for TripCreator with frequency support HOT 5
- Handle ref duplicates HOT 5
- Cache based on config file, not selector to support different agencies per city HOT 4
- Support hail_and_ride / GTFS Flex HOT 16
- [question] Potential stop is invalid and has been ignored / nodes of a platform way HOT 3
- Incomplete shapes because of roundabout HOT 1
- Issues loading bus stops HOT 2
- problem with package installation
- problem with package installation HOT 1
- "This feed has no effective service dates!" Error HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from osm2gtfs.