Deprecated OpenMobility Replaced With Mobility Database #2631

Merged
fardeenfs merged 6 commits from gtfs-source-fix into master 2022-05-30 07:44:31 +00:00
fardeenfs commented 2022-05-27 06:30:52 +00:00 (Migrated from github.com)

Open Mobility Data is no longer regularly updated/maintained and its API will soon be depreciated. It is the perfect time to replace it with its modified GTFS-feeds aggregator, Mobility Database. Updated the current code to support Mobility Database.

Signed-off-by: Fardeen Faisal fardeenfaisal.fs@gmail.com

Open Mobility Data is no longer regularly updated/maintained and its API will soon be depreciated. It is the perfect time to replace it with its modified GTFS-feeds aggregator, Mobility Database. Updated the current code to support Mobility Database. Signed-off-by: Fardeen Faisal <fardeenfaisal.fs@gmail.com>
pastk reviewed 2022-05-27 06:30:52 +00:00
strump reviewed 2022-05-27 07:58:55 +00:00
@ -4,3 +4,4 @@
- Mobility Database (https://mobilitydata.org/)
Crawls all the urls, loads feed zips and extracts to the specified directory."""
import argparse

You use Pandas lib to parse CSV file. It adds extra dependency. While there is default Python 3 library csv.

You use Pandas lib to parse CSV file. It adds extra dependency. While there is default Python 3 library [csv](https://docs.python.org/3.8/library/csv.html).
@ -12,3 +13,4 @@
import csv
import time
import zipfile

Why do you use short URL instead of a full URL https://storage.googleapis.com/storage/v1/b/mdb-csv/o/sources.csv?alt=media ?

Why do you use short URL instead of a full URL `https://storage.googleapis.com/storage/v1/b/mdb-csv/o/sources.csv?alt=media` ?
biodranik commented 2022-05-27 08:28:08 +00:00 (Migrated from github.com)

@pastk can you please also take a look, as a python-expert? :)

@pastk can you please also take a look, as a python-expert? :)
fardeenfs (Migrated from github.com) reviewed 2022-05-27 18:21:20 +00:00
@ -12,3 +13,4 @@
import csv
import time
import zipfile
fardeenfs (Migrated from github.com) commented 2022-05-27 18:21:20 +00:00

The link to the CSV file on their website used a link shortener.

The link target could potentially change when they go from v1 to say v2. The link shortener's target URL will probably be updated and feels like a better option. I can change it if there is an issue with it.

The link to the CSV file on their website used a link shortener. The link target could potentially change when they go from v1 to say v2. The link shortener's target URL will probably be updated and feels like a better option. I can change it if there is an issue with it.
fardeenfs (Migrated from github.com) reviewed 2022-05-27 18:37:44 +00:00
@ -4,3 +4,4 @@
- Mobility Database (https://mobilitydata.org/)
Crawls all the urls, loads feed zips and extracts to the specified directory."""
import argparse
fardeenfs (Migrated from github.com) commented 2022-05-27 18:37:44 +00:00

Pandas is currently being used by another file in the project (/search/search_quality/scoring_model.py), so I was of the opinion that the module will already be installed to run the project, i.e. not an extra dependency.
I will look into a csv module alternative.

Pandas is currently being used by another file in the project (/search/search_quality/scoring_model.py), so I was of the opinion that the module will already be installed to run the project, i.e. not an extra dependency. I will look into a csv module alternative.
biodranik (Migrated from github.com) reviewed 2022-05-28 10:23:51 +00:00
@ -4,3 +4,4 @@
- Mobility Database (https://mobilitydata.org/)
Crawls all the urls, loads feed zips and extracts to the specified directory."""
import argparse
biodranik (Migrated from github.com) commented 2022-05-28 10:23:51 +00:00

Our general rule: fewer dependencies are better than more. We introduce new 3party dependencies ONLY if there is no other comparable way to solve the problem.

Our general rule: fewer dependencies are better than more. We introduce new 3party dependencies ONLY if there is no other comparable way to solve the problem.
biodranik (Migrated from github.com) reviewed 2022-05-28 10:37:54 +00:00
@ -12,3 +13,4 @@
import csv
import time
import zipfile
biodranik (Migrated from github.com) commented 2022-05-28 10:27:08 +00:00

It creates an additional HTTP round-trip to resolve the shortener. I would document in the comment the original web page where you get that shortener, and use the resolved URL. If the scheme changes, we'll need to update the parser too.

It creates an additional HTTP round-trip to resolve the shortener. I would document in the comment the original web page where you get that shortener, and use the resolved URL. If the scheme changes, we'll need to update the parser too.
biodranik (Migrated from github.com) commented 2022-05-28 10:28:22 +00:00
    file = open(RAW_FILE_MOBILITYDB, encoding="UTF-8")

Please use consistent code formatting everywhere.

```suggestion file = open(RAW_FILE_MOBILITYDB, encoding="UTF-8") ``` Please use consistent code formatting everywhere.
biodranik (Migrated from github.com) commented 2022-05-28 10:31:03 +00:00
  1. Will it close the file properly if write() above throws an exception?
  2. After running this function, there will be a file somewhere in the file system. Is that place predictable and always the same? When should this file be deleted? Or it shouldn't? Does it make sense to reuse it if the HTTP connection fails?
1. Will it close the file properly if write() above throws an exception? 2. After running this function, there will be a file somewhere in the file system. Is that place predictable and always the same? When should this file be deleted? Or it shouldn't? Does it make sense to reuse it if the HTTP connection fails?
fardeenfs (Migrated from github.com) reviewed 2022-05-28 19:45:33 +00:00
@ -12,3 +13,4 @@
import csv
import time
import zipfile
fardeenfs (Migrated from github.com) commented 2022-05-28 19:45:33 +00:00
  1. I have improved it. It should close now even if the write() fails.
  2. The file can be reused even if the HTTP connection fails. The file is stored in the same location where the existing Transit Land URLs file is stored. It can be deleted but if it exists it will overwrite its content, so it will not cause any issues either way.
1. I have improved it. It should close now even if the write() fails. 2. The file can be reused even if the HTTP connection fails. The file is stored in the same location where the existing Transit Land URLs file is stored. It can be deleted but if it exists it will overwrite its content, so it will not cause any issues either way.
fardeenfs (Migrated from github.com) reviewed 2022-05-29 06:21:11 +00:00
@ -4,3 +4,4 @@
- Mobility Database (https://mobilitydata.org/)
Crawls all the urls, loads feed zips and extracts to the specified directory."""
import argparse
fardeenfs (Migrated from github.com) commented 2022-05-29 06:21:10 +00:00

I have changed the code to work with the default csv module :)

I have changed the code to work with the default csv module :)
biodranik (Migrated from github.com) approved these changes 2022-05-29 21:23:19 +00:00
biodranik (Migrated from github.com) commented 2022-05-29 21:15:32 +00:00

There could be temporary network errors, so I would avoid recommending URL update.

There could be temporary network errors, so I would avoid recommending URL update.
biodranik (Migrated from github.com) commented 2022-05-29 21:15:55 +00:00
    file = open(RAW_FILE_MOBILITYDB, encoding='UTF-8')

One interesting practice is to use single quotes for verbatim strings, and double quotes for strings with variables inside. It helps to read the code.

```suggestion file = open(RAW_FILE_MOBILITYDB, encoding='UTF-8') ``` One interesting practice is to use single quotes for verbatim strings, and double quotes for strings with variables inside. It helps to read the code.
biodranik (Migrated from github.com) commented 2022-05-29 21:23:12 +00:00

Another possible option is to always use double quotes like it's done already in the file (except in 'wb' above).

Another possible option is to always use double quotes like it's done already in the file (except in 'wb' above).
biodranik (Migrated from github.com) reviewed 2022-05-30 06:15:35 +00:00
biodranik (Migrated from github.com) commented 2022-05-30 06:15:35 +00:00

Why it was required before? What happens now if it is specified or not specified?

Why it was required before? What happens now if it is specified or not specified?
fardeenfs (Migrated from github.com) reviewed 2022-05-30 06:46:21 +00:00
fardeenfs (Migrated from github.com) commented 2022-05-30 06:46:21 +00:00

As per the earlier implementation, Transit Land API key was always necessary. This gives the flexibility to just crawl Mobility without the hassle of generating a Transit Land API key.

If the --source is set to 'all' or 'transitland' : the key is required. If it is not specified, line 255 will return an error.

If the --source is set to 'mobilitydb' : the key is not required and it will crawl just Mobility DB. Specifying the Transit Land key wouldn't matter since it is not being used.

As per the earlier implementation, Transit Land API key was always necessary. This gives the flexibility to just crawl Mobility without the hassle of generating a Transit Land API key. If the --source is set to 'all' or 'transitland' : the key is required. If it is not specified, line 255 will return an error. If the --source is set to 'mobilitydb' : the key is not required and it will crawl just Mobility DB. Specifying the Transit Land key wouldn't matter since it is not being used.
biodranik (Migrated from github.com) approved these changes 2022-05-30 07:44:13 +00:00
biodranik (Migrated from github.com) left a comment

Good! Let's merge it.

Good! Let's merge it.
This repo is archived. You cannot comment on pull requests.
No reviewers
No labels
Accessibility
Accessibility
Address
Address
Android
Android
Android Auto
Android Auto
Android Automotive (AAOS)
Android Automotive (AAOS)
API
API
AppGallery
AppGallery
AppStore
AppStore
Battery and Performance
Battery and Performance
Blocker
Blocker
Bookmarks and Tracks
Bookmarks and Tracks
Borders
Borders
Bug
Bug
Build
Build
CarPlay
CarPlay
Classificator
Classificator
Community
Community
Core
Core
CrashReports
CrashReports
Cycling
Cycling
Desktop
Desktop
DevEx
DevEx
DevOps
DevOps
dev_sandbox
dev_sandbox
Directions
Directions
Documentation
Documentation
Downloader
Downloader
Drape
Drape
Driving
Driving
Duplicate
Duplicate
Editor
Editor
Elevation
Elevation
Enhancement
Enhancement
Epic
Epic
External Map Datasets
External Map Datasets
F-Droid
F-Droid
Fonts
Fonts
Frequently User Reported
Frequently User Reported
Fund
Fund
Generator
Generator
Good first issue
Good first issue
Google Play
Google Play
GPS
GPS
GSoC
GSoC
iCloud
iCloud
Icons
Icons
iOS
iOS
Legal
Legal
Linux Desktop
Linux Desktop
Linux packaging
Linux packaging
Linux Phone
Linux Phone
Mac OS
Mac OS
Map Data
Map Data
Metro
Metro
Navigation
Navigation
Need Feedback
Need Feedback
Night Mode
Night Mode
NLnet 2024-06-281
NLnet 2024-06-281
No Feature Parity
No Feature Parity
Opening Hours
Opening Hours
Outdoors
Outdoors
POI Info
POI Info
Privacy
Privacy
Public Transport
Public Transport
Raw Idea
Raw Idea
Refactoring
Refactoring
Regional
Regional
Regression
Regression
Releases
Releases
RoboTest
RoboTest
Route Planning
Route Planning
Routing
Routing
Ruler
Ruler
Search
Search
Security
Security
Styles
Styles
Tests
Tests
Track Recording
Track Recording
Translations
Translations
TTS
TTS
UI
UI
UX
UX
Walk Navigation
Walk Navigation
Watches
Watches
Web
Web
Wikipedia
Wikipedia
Windows
Windows
Won't fix
Won't fix
World Map
World Map
No milestone
No project
No assignees
3 participants
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: organicmaps/organicmaps-tmp#2631
No description provided.