Skip to content
/ atm Public
forked from pitfallharry/atm

ATM (Azienda Trasporti Milanesi) Python Library

Notifications You must be signed in to change notification settings

arseniov/atm

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

atm

ATM (Azienda Trasporti Milanesi) Python Library

This Library is intended for educational purpose.

  • Free to use.
  • No API Key needed.
  • Daily useful.
  • Functionality tested in real time.

Initial Version - 0.1

In [1]: from atm import Stop

In [2]: s = Stop(11161)

In [3]: s.description()
Fermata 11161 (Alzaia Nav. Pavese, 60) | 2020-02-10 23:04:32.617598

In [4]: s.waitmessage('grid')

11161 - Alzaia Nav. Pavese, 60
+---------+------------------------------+----------+
|   Linea | Descrizione                  | Attesa   |
+=========+==============================+==========+
|      59 | P.ta Lodovica - Famagosta M2 | no serv. |
+---------+------------------------------+----------+
|      71 | Famagosta M2 - Romolo M2     | 5 min    |
+---------+------------------------------+----------+
 - 2020-02-10 23:04:32.617598 - 

In [5]: s.position()
Out[5]: (9.176054951924698, 45.44497959284472)

In [6]: s.lines()
Out[6]: ['59', '71']

In [7]: s.update()

In [8]: s.waitmessage('html')

11161 - Alzaia Nav. Pavese, 60
LineaDescrizione Attesa
59P.ta Lodovica - Famagosta M2no serv.
71Famagosta M2 - Romolo M2 14 min
- 2020-02-10 23:16:08.537093 -

In [9]: from atm import distance

In [10]: s1 = Stop(12402)

In [11]: s2 = Stop(12400)

In [12]: distance(s1,s2)
Out[12]: 0.1354349258943788

In [13]: from atm import Line

In [14]: l = Line(73)

In [15]: l.description()
Linea Bus 73 Aeroporto Linate - Duomo M1 M3

In [16]: l.stops()
Out[16]: ['12926', '12921', '12854', '12852', '18119', '12647', '12405', '12400', '12391', '12127', '12125', '12111', '12098', '12095', '11820', '17854', '18155', '17769', '17855', '16929']

In [17]: l.path('html')

Bus 73 Aeroporto Linate - Duomo M1 M3
FermataDescrizione
12926Aeroporto di Linate Segrate
12921V.le Forlanini Via Circonvallazione Segrate
12854V.le Forlanini Aeronautica Militare
12852V.le Forlanini Tangenziale Est
18119V.le Forlanini P.za Artigianato
12647Forlanini
12405V.le Corsica Via Lomellina
12400V.le Corsica Via Battistotti Sassi
12391V.le Campania V.le Corsica
12127P.za Grandi
12125P.za Emilia
12111Via Cadore C.so Ventidue Marzo
12098P.za S.Maria del Suffragio
12095P.za 5 Giornate
11820C.so P.ta Vittoria Camera del Lavoro
17854Via Battisti
18155L.go Augusto
17769Via Larga
17855P.za Velasca
16929Duomo M1 M3

In [18]: l.reverse()

In [19]: l.path()

Bus 73 Duomo M1 M3 - Aeroporto Linate
+-----------+----------------------------------------------+
|   Fermata | Descrizione                                  |
+===========+==============================================+
|     16929 | Duomo M1 M3                                  |
+-----------+----------------------------------------------+
|     11794 | Via Larga                                    |
+-----------+----------------------------------------------+
|     11798 | L.go Augusto                                 |
+-----------+----------------------------------------------+
|     11816 | Palazzo di Giustizia                         |
+-----------+----------------------------------------------+
|     11823 | C.so P.ta Vittoria  Camera del Lavoro        |
+-----------+----------------------------------------------+
|     12094 | P.za 5 Giornate                              |
+-----------+----------------------------------------------+
|     12099 | P.za S.Maria del Suffragio                   |
+-----------+----------------------------------------------+
|     12108 | Via Cadore C.so Ventidue Marzo               |
+-----------+----------------------------------------------+
|     12126 | P.za Emilia                                  |
+-----------+----------------------------------------------+
|     12390 | P.za Grandi                                  |
+-----------+----------------------------------------------+
|     12392 | V.le Campania V.le Corsica                   |
+-----------+----------------------------------------------+
|     12402 | V.le Corsica Via Lomellina                   |
+-----------+----------------------------------------------+
|     12407 | V.le Corsica Via Negroli                     |
+-----------+----------------------------------------------+
|     12646 | Forlanini                                    |
+-----------+----------------------------------------------+
|     12662 | V.le Forlanini P.za Artigianato              |
+-----------+----------------------------------------------+
|     12851 | V.le Forlanini  Tangenziale Est              |
+-----------+----------------------------------------------+
|     12853 | V.le Forlanini  Aeronautica Militare         |
+-----------+----------------------------------------------+
|     12922 | V.le Forlanini Via Circonvallazione  Segrate |
+-----------+----------------------------------------------+
|     12926 | Aeroporto di Linate  Segrate                 |
+-----------+----------------------------------------------+

About

ATM (Azienda Trasporti Milanesi) Python Library

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 52.1%
  • Jupyter Notebook 47.9%