Skip Menu |

This queue is for tickets about the Map-Tube CPAN distribution.

Report information
The Basics
Id: 107745
Status: resolved
Priority: 0/
Queue: Map-Tube

People
Owner: MANWAR [...] cpan.org
Requestors: GWS [...] cpan.org
SKIM [...] cpan.org
SREZIC [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 3.02
Fixed in: 3.11



Subject: Improvements to get_stations() method
Hi, Is it possible improve get_stations() method to return list of stations in real station order? I think, that is right way. In actual situation this returns random list and it isn't useful. I am thinking about it and it has two problems: - Where is a begin on line. We can tell in XML file where is the begin. - I think, that is possible line with tree. But... I don't see it now. Regards, M.
Hi, Yes it is possible to get stations in ordered list as long as the map (xml data) has this information in a sensible format. I will see what I can do without breaking any existing functionalities. Best Regards, Mohammad S Anwar
Dne St 14.říj.2015 05:36:36, MANWAR napsal(a): Hi, Show quoted text
> Yes it is possible to get stations in ordered list as long as the map > (xml data) has this information in a sensible format. > > I will see what I can do without breaking any existing > functionalities.
Ok, thanks. M.
Hi Michael, I have pushed proposed solution to the feature you requested. https://github.com/Manwar/Map-Tube https://metacpan.org/release/MANWAR/Map-Tube-3.09 Please bear in mind, the change is backward compatible. I have tested the above changes against Delhi map as it is not huge as London map. Please find attached the changed code, not yet published. In order to get the above change incorporated, you would need to make slight change to the map xml data as shown below: Old way: <station id="KIRTI-NAGAR" name="Kirti Nagar" line="Blue,Green" link="B23,B21,G14"/> New way: <station id="KIRTI-NAGAR" name="Kirti Nagar" line="Blue:22,Green:15" link="B23,B21,G14"/> The 'line' attribute of the 'station' node expect to have station index for the corresponding line. So the above line says that the station "Kirti Nagar" index is 22 on Blue Line but 15 on Green Line. Here is the code to test the change: use strict; use warnings; use Map::Tube::Delhi; my $map = Map::Tube::Delhi->new; print join("\n", @{$map->get_stations('Red')}), "\n"; As always, please do share your views. Many Thanks. Best Regards, Mohammad S Anwar
Subject: Map-Tube-Delhi-0.35.tar.gz
Download Map-Tube-Delhi-0.35.tar.gz
application/x-gzip 18.4k

Message body not shown because it is not plain text.

Dne Út 20.říj.2015 06:54:38, MANWAR napsal(a): Hi Mohammad, Show quoted text
> I have pushed proposed solution to the feature you requested. > > https://github.com/Manwar/Map-Tube > https://metacpan.org/release/MANWAR/Map-Tube-3.09
[SNIP] Show quoted text
> As always, please do share your views.
I think, that's ok. I have two things: 1) When you added colon to 'line' attribute, you must rewrite code to accept "Line ID" as 'line' attribute. a) that's right way b) it is not clean, when you have colon in line name. 2) I rewrite Bucharest metro to this way. It's ok. I rewrite Bucharest metro to situation with explicit line changes. There are two types: - "Station" as platform or bridge change. - "Tunnel" as some tunnel change. Then i have problem with implicit station name - New is "Piața Victoriei (Linia M1, Station)" - Old was "Piața Victoriei (Linia M1, Linia M2)". I think, that right way is name of other line, no change name. See https://github.com/tupinek/Map-Tube-Bucharest and t/Map-Tube-Bucharest/10-get_stations.t test. Many thanks. Kind regards, Michal
Hi Michal, I have incorporated your first point in the attached code (not yet published). Please give it a go. I need more clarification regarding your second point, please. Here is the report that shows expected state with the proposed changes: Gisbert W. Selke [FAIL] Map-Tube-Beijing v0.01 [PASS] Map-Tube-Glasgow v0.07 [PASS] Map-Tube-KoelnBonn v0.09 [PASS] Map-Tube-Lyon v0.06 Slaven Rezic [PASS] Map::Tube::Berlin v0.11 Michal Spacek [FAIL] Map-Tube-Bucharest v0.07 [FAIL] Map-Tube-Budapest v0.04 [FAIL] Map-Tube-Dnipropetrovsk v0.05 [FAIL] Map-Tube-Kazan v0.04 [FAIL] Map-Tube-Kharkiv v0.05 [FAIL] Map-Tube-Kiev v0.05 [FAIL] Map-Tube-KualaLumpur v0.05 [FAIL] Map-Tube-Malaga v0.15 [FAIL] Map-Tube-Minsk v0.05 [FAIL] Map-Tube-Moscow v0.07 [FAIL] Map-Tube-Nanjing v0.04 [FAIL] Map-Tube-NizhnyNovgorod v0.03 [FAIL] Map-Tube-Novosibirsk v0.03 [FAIL] Map-Tube-Prague v0.13 [FAIL] Map-Tube-SaintPetersburg v0.05 [FAIL] Map-Tube-Samara v0.05 [FAIL] Map-Tube-Singapore v0.02 [FAIL] Map-Tube-Sofia v0.07 [FAIL] Map-Tube-Tbilisi v0.04 [FAIL] Map-Tube-Vienna v0.06 [FAIL] Map-Tube-Warsaw v0.06 [FAIL] Map-Tube-Yekaterinburg v0.05 Best Regards, Mohammad S Anwar
Subject: Map-Tube-3.10.tar.gz
Download Map-Tube-3.10.tar.gz
application/x-gzip 21.9k

Message body not shown because it is not plain text.

Dne St 21.říj.2015 12:12:22, MANWAR napsal(a): Hi Mohammad, Show quoted text
> I have incorporated your first point in the attached code (not yet > published). Please give it a go. I need more clarification regarding > your second point, please.
Problems: 1) No returned $line on get_line_by_id() method. 2) On get_line_by_name() method, you use _get_line_object(). In _get_line_object() is undefined $self->{_lines}->{$line_id}->name on other_links lines, because this "lines" haven't name. This cause problem with Test::Map::Tube::ok_map() in _validate_multi_lined_nodes() method too. Kind regards, Michal
Hi Michal, I noticed that when I tested against my map. Thanks for pointing out the issues. I have attached updated code. Please give it a try. Best Regards, Mohammad S Anwar
Subject: Map-Tube-3.10.tar.gz
Download Map-Tube-3.10.tar.gz
application/x-gzip 21.9k

Message body not shown because it is not plain text.

Dne Čt 22.říj.2015 06:13:26, MANWAR napsal(a): Hi Mohammad, Show quoted text
> I noticed that when I tested against my map. > Thanks for pointing out the issues. > > I have attached updated code. Please give it a try.
Change with Line IDs is ok. Thanks. And what about proposed change with lines in station? 'Piața Victoriei (Linia M1, Station)' vs 'Piața Victoriei (Linia M1, Linia M2)' Kind regards, M.
Hi Michal, Please find attached updated code to resolve the second point. Best Regards, Mohammad S Anwar
Subject: Map-Tube-3.10.tar.gz
Download Map-Tube-3.10.tar.gz
application/x-gzip 22.1k

Message body not shown because it is not plain text.

Dne Čt 22.říj.2015 07:50:07, MANWAR napsal(a): Hi Mohammad, Show quoted text
> Please find attached updated code to resolve the second point.
On my actual Bucharest repository (https://github.com/tupinek/Map-Tube-Bucharest/) has example script from attachment this output: Show quoted text
> ./get_stations.pl 'Linia M1'
Dristor 2 (Linia M1) Piața Muncii (Linia M1) Iancului (Linia M1) Obor (Linia M1) Ștefan cel Mare (Linia M1) Piața Victoriei (Linia M1, Station) Gara de Nord (Linia M1) Basarab (Linia M1, Station) Crângași (Linia M1) Petrache Poenaru (Linia M1) Grozăvești (Linia M1) Eroilor (Linia M1, Station) Izvor (Linia M1, Station) Piața Unirii 1 (Linia M1, Station, Tunnel) Timpuri Noi (Linia M1, Station) Mihai Bravu (Linia M1, Station) Dristor 1 (Linia M1, Station) Nicolae Grigorescu (Linia M1, Station) Titan (Linia M1) Costin Georgian (Linia M1) Republica (Linia M1) Pantelimon (Linia M1) This is not, what i want :-) BTW: Isn't better add your changes to repository step by step? I don't see changes between 1) and 2). Kind regards, M.
Subject: get_stations.pl
#!/usr/bin/env perl # Pragmas. use strict; use warnings; # Modules. use Encode qw(encode_utf8); use Map::Tube::Bucharest; # Arguments. if (@ARGV < 1) { print STDERR "Usage: $0 line\n"; exit 1; } my $line = $ARGV[0]; # Object. my $metro = Map::Tube::Bucharest->new; # Get tables. my $stations_ar = $metro->get_stations($line); # Print lines. foreach my $station (@{$stations_ar}) { print encode_utf8($station)."\n"; }
Hi Michal, Please try now, attached code. Best Regards, Mohammad S Anwar
Subject: Map-Tube-3.10.tar.gz
Download Map-Tube-3.10.tar.gz
application/x-gzip 22.2k

Message body not shown because it is not plain text.

Dne Čt 22.říj.2015 08:26:53, MANWAR napsal(a): Hi Mohammad, Show quoted text
> Please try now, attached code.
Station names are ok. But get_stations() returns unsorted stations. Kind regards, M.
Hi Michal, Please find attached the updated code. Best Regards, Mohammad S Anwar
Subject: Map-Tube-3.10.tar.gz
Download Map-Tube-3.10.tar.gz
application/x-gzip 22.2k

Message body not shown because it is not plain text.

Dne Čt 22.říj.2015 13:42:46, MANWAR napsal(a): Hi Mohammad, Show quoted text
> Please find attached the updated code.
So... last thing - lines in station string isn't sorted. Actually they returns random order of its. I think that sort is better. For test, for readability. Kind regards, M.
Hi Michal, Can this be close now? Best Regards, Mohammad S Anwar
Dne Čt 22.říj.2015 14:08:15, MANWAR napsal(a): Hi, Show quoted text
> Can this be close now?
Yes and what about my last message, which i send? Kind regards, M.
Do you mean, line names for a station should be alphabetically sorted?
Dne Čt 22.říj.2015 14:15:21, MANWAR napsal(a): Show quoted text
> Do you mean, line names for a station should be alphabetically sorted?
Yes. M.
On my Map::Tube::Sofia is regression in tests between Map::Tube 3.10 and 3.11. Example is in attachment. Output with Map::Tube 3.10: pepa:~/perl/MODULES/Map-Tube-Sofia> ./get_shortest_route.pl Люлин 'Ломско шосе' Route: Люлин (Първи метродиаметър), Сливница (Първи метродиаметър), Обеля (Първи метродиаметър, Втори метродиаметър), Ломско шосе (Втори метродиаметър) Output with Map::Tube 3.11: pepa:~/perl/MODULES/Map-Tube-Sofia> ./get_shortest_route.pl Люлин 'Ломско шосе' Route: Люлин (), Сливница (), Обеля (), Ломско шосе () Kind regards, M.
Subject: get_shortest_route.pl
#!/usr/bin/env perl # Pragmas. use strict; use warnings; # Modules. use Encode qw(decode_utf8 encode_utf8); use Map::Tube::Sofia; # Arguments. if (@ARGV < 2) { print STDERR "Usage: $0 from to\n"; exit 1; } my $from = decode_utf8($ARGV[0]); my $to = decode_utf8($ARGV[1]); # Object. my $metro = Map::Tube::Sofia->new; # Get route. my $route = $metro->get_shortest_route($from, $to); # Print route. print "Route: ".encode_utf8($route)."\n";
Dne So 24.říj.2015 11:32:19, SKIM napsal(a): Show quoted text
> On my Map::Tube::Sofia is regression in tests between Map::Tube 3.10 > and 3.11.
[SNIP] Ups.. This is regression on old XML schema with line name in station element. This means, that changes with line name vs line id are no backward compatible. I am rewriting all my modules to new XML version. Kind regards, M.
Closing the ticket now. Best Regards, Mohammad S Anwar