comaps/subways
17
7
Fork
You've already forked subways
6

WIP: Fix support of tram #70

Closed
jeanbaptisteC wants to merge 1 commit from jb_tram into master
pull from: jb_tram
merge into: comaps:master
comaps:master
comaps:jb_test
comaps:jb_lt
comaps:pastk-TEST-pr-62
comaps:pastk-TEST-pr-61
comaps:pastk-TEST-pr-54
comaps:pastk-TEST-pr-39
comaps:pastk-TEST-pr-41-and-39
comaps:pastk-TEST-pr-48
comaps:pastk-TEST-pr-41
comaps:pastk-TEST-pr-43
comaps:upstream
comaps:fixes-from-alexey2
comaps:fixes
Contributor
Copy link

The tram transport has been added in the past by Zverik but after a refactor of the project structure the tram validator has been broken

This PR try to fix the support of tram transport, any help is appreciated
I'm not able to test these changes, but that could be test with these command python "./scripts/process_subways.py" --cities-info-file "./source_data/Overground.csv" -t

Todo:

  • Update CI
  • Check if changes are required to be integrated in the maps data

Signed-off-by: Jean-Baptiste jeanbaptiste.charron@outlook.fr

The tram transport has been added in the past by [Zverik](https://github.com/mapsme/subways/commit/a39cf3232d94f7d9383d0c84348d05b24464ffef) but after a [refactor of the project structure](https://github.com/Zverik/subways-az/commit/60821b60d67727e4887a9341e89d16f760fc1c9b) the tram validator has been broken This PR try to fix the support of tram transport, any help is appreciated I'm not able to test these changes, but that could be test with these command python "./scripts/process_subways.py" --cities-info-file "./source_data/Overground.csv" -t Todo: - Update CI - Check if changes are required to be integrated in the maps data Signed-off-by: Jean-Baptiste <jeanbaptiste.charron@outlook.fr>
Signed-off-by: Jean-Baptiste <jeanbaptiste.charron@outlook.fr>
Author
Contributor
Copy link

Maybe check in first, if that break our actual process

Maybe check in first, if that break our actual process
@ -237,2 +237,2 @@
QRELATIONS="r/route,route_master=subway,light_rail,monorail,train r/public_transport=stop_area,stop_area_group"
QNODES="n/railway=station,subway_entrance,train_station_entrance n/station=subway,light_rail,monorail n/subway=yes n/light_rail=yes n/monorail=yes n/train=yes"
QRELATIONS="r/route,route_master=subway,light_rail,monorail,train,tram r/public_transport=stop_area,stop_area_group"
QNODES="n/railway=station,subway_entrance,train_station_entrance,tram_stop n/station=subway,light_rail,monorail n/subway=yes n/light_rail=yes n/monorail=yes n/train=yes n/tram=yes"
Member
Copy link

Should we use the existing queries for rapid transit or should we create seperate queries only querying tram related items for overground processing? At least for QRELATIONS I don't think subway route relations are needed, while for the rapid file tram routes are not needed.

I have no real experience with this part of the code, so not sure what would be best.

Should we use the existing queries for rapid transit or should we create seperate queries only querying tram related items for overground processing? At least for QRELATIONS I don't think subway route relations are needed, while for the rapid file tram routes are not needed. I have no real experience with this part of the code, so not sure what would be best.
Author
Contributor
Copy link

This script doesn't know if we have selected rapid or overground mode but I guess it's better to extract data from osmium only once time

This script doesn't know if we have selected rapid or overground mode but I guess it's better to extract data from osmium only once time
Member
Copy link

Okay, makes sense.

At line 260, however, we don't set the overground flag for process_subways.py, so it will only process in rapid mode.

As far as I can see this sh script needs to be run once for every file right now, so maybe it is easiest to add an overground flag there that we can pass through to the process_subways.py script. In that case we could also ajust the queries to the mode.

Alternatively we could try to change the script to process multiple input files with multiple modes at once, just a little more complicated I think.

Okay, makes sense. At line 260, however, we don't set the overground flag for `process_subways.py`, so it will only process in rapid mode. As far as I can see this sh script needs to be run once for every file right now, so maybe it is easiest to add an overground flag there that we can pass through to the `process_subways.py` script. In that case we could also ajust the queries to the mode. Alternatively we could try to change the script to process multiple input files with multiple modes at once, just a little more complicated I think.
Author
Contributor
Copy link

I don't know how to proceeed to integrate to the actual workflow:

  • Run overground process each time we generate subway after execute the rapid part
  • Run only when we want with a parameter on the codeberg workflow, to wait we integrate more tram and fix issues before integrate first networks in the app.

Also, I don't know if it's better to merge this part now and merge CI in a seperate PR?

I don't know how to proceeed to integrate to the actual workflow: - Run overground process each time we generate subway after execute the rapid part - Run only when we want with a parameter on the codeberg workflow, to wait we integrate more tram and fix issues before integrate first networks in the app. Also, I don't know if it's better to merge this part now and merge CI in a seperate PR?
Member
Copy link

I don't know either, so i'll leave commenting on that for the CI people here.

I don't know either, so i'll leave commenting on that for the CI people here.
Author
Contributor
Copy link

To build website validator, I guess we need to execute both process in the same pipeline if we don't want to overwrite website validator for rapid with overground validator

To build website validator, I guess we need to execute both process in the same pipeline if we don't want to overwrite website validator for rapid with overground validator
Member
Copy link

If we have two seperate input files, wouldn't it make more sense to also have two output files and html validation files to keep it simple? Or do you think it is better to have it all in one place? I would like to preserve the format and the statistics of the current html subways page if possible to keep side by side comparison with VK easy.

If we have two seperate input files, wouldn't it make more sense to also have two output files and html validation files to keep it simple? Or do you think it is better to have it all in one place? I would like to preserve the format and the statistics of the current html subways page if possible to keep side by side comparison with VK easy.
Author
Contributor
Copy link

Actual UI support rapid and overground transport on the same page with new columns for trams and bus

Actual UI support rapid and overground transport on the same page with new columns for trams and bus
Member
Copy link

Right now it is set up to show either rapid or overground lines by setting the boolean overground variable as far as I can see, not both. We could of course change this. I just like the idea of keeping rapid and overground/tram a bit seperate, also with potential different rendering in mind (one input -> one output). A seperate validation html feels most logical to me, as it would be following this pattern.

Right now it is set up to show either rapid or overground lines by setting the boolean overground variable as far as I can see, not both. We could of course change this. I just like the idea of keeping rapid and overground/tram a bit seperate, also with potential different rendering in mind (one input -> one output). A seperate validation html feels most logical to me, as it would be following this pattern.
Author
Contributor
Copy link

Feel free to update this PR, If you know how to improve html generator part

Feel free to update this PR, If you know how to improve html generator part
@ -23,6 +23,8 @@ class StopArea:
return False
if el["tags"].get("railway") == "stop":
return True
if el["tags"].get("railway") == "tram_stop":
Member
Copy link

Can be combined in one if by using

if el["tags"].get("railway") in ["stop", "tram_stop"]:

I also made this change in my partial tram PR, so depending on which PR gets merged first it can be removed from the other to prevent merge conflicts.

Can be combined in one if by using ```python if el["tags"].get("railway") in ["stop", "tram_stop"]: ``` I also made this change in my partial tram PR, so depending on which PR gets merged first it can be removed from the other to prevent merge conflicts.
Member
Copy link

Sorry, wrong brackets (i'm used to PHP arrays). Should be

if el["tags"].get("railway") in ("stop", "tram_stop"):
Sorry, wrong brackets (i'm used to PHP arrays). Should be ```python if el["tags"].get("railway") in ("stop", "tram_stop"): ```
Author
Contributor
Copy link

Fixed

Fixed
jeanbaptisteC marked this conversation as resolved
@ -205,2 +204,2 @@
data.splitlines(),
fieldnames=(
if not overground:
Member
Copy link

Indentation of the if section looks wrong here. I think it should go outside of the with ... as f:, so one level back while the strings inside of the tuple should be indented.

The whole thing could even be inlined:

reader = csv.DictReader(
 data.splitlines(),
 fieldnames=(
 "id",
 "name",
 "country",
 "continent",
 "num_lines",
 "num_light_lines",
 "bbox",
 "networks",
 ) if not overground else (
 "id",
 "name",
 "country",
 "continent",
 "num_tram_lines",
 "num_trolleybus_lines",
 "num_bus_lines",
 "num_other_lines",
 "bbox",
 "networks",
 ),
)
Indentation of the if section looks wrong here. I think it should go outside of the `with ... as f:`, so one level back while the strings inside of the tuple should be indented. The whole thing could even be inlined: ```python reader = csv.DictReader( data.splitlines(), fieldnames=( "id", "name", "country", "continent", "num_lines", "num_light_lines", "bbox", "networks", ) if not overground else ( "id", "name", "country", "continent", "num_tram_lines", "num_trolleybus_lines", "num_bus_lines", "num_other_lines", "bbox", "networks", ), ) ```
Author
Contributor
Copy link

Fixed

Fixed
jeanbaptisteC marked this conversation as resolved
@ -215,2 +226,4 @@
"networks",
),
)
)
Member
Copy link

One closing bracket too many (last one should be removed) 😉

One closing bracket too many (last one should be removed) 😉
jeanbaptisteC marked this conversation as resolved

Pull request closed

Please reopen this pull request to perform a merge.
Sign in to join this conversation.
No reviewers
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
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
comaps/subways!70
Reference in a new issue
comaps/subways
No description provided.
Delete branch "jb_tram"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?