Esempio n. 1
0
 def test_back_to_coordinates(self):
     a = 0.5089428571428637
     b = 0.28768181818181293
     self.assertEqual(tr.back_to_coordinates(a, b), (59.851252, 17.59329))
     print "Test - OK ... Back to coordinates"
Esempio n. 2
0
 def test_back_to_coordinates(self):
     a = 0.5089428571428637
     b = 0.28768181818181293
     self.assertEqual(tr.back_to_coordinates(a,b), (59.851252, 17.59329))
     print "Test - OK ... Back to coordinates"
Esempio n. 3
0
 def test_calculate_distance_arrival(self):
     tr.nearest_stops_dep = []
     tr.nearest_stops_arr = []
     tr.selected_centroids = [
         array([
             0.45161914, 0.52874184, 0.55135584, 0.50578817, 0.172007,
             0.0162836, 0.18377792, 0.0129053
         ]),
         array([
             0.43406424, 0.53152554, 0.23595767, 0.61999794, 0.04638085,
             0.17973951, 0.05322643, 0.16249825
         ]),
         array([
             0.5511221, 0.51158863, 0.44533246, 0.52734338, 0.11118081,
             0.44409996, 0.10121861, 0.4370837
         ]),
         array([
             0.56304867, 0.50875958, 0.49079012, 0.51340253, 0.38025537,
             0.03755701, 0.38917885, 0.04317823
         ])
     ]
     for i in range(len(tr.selected_centroids)):
         cent_lat, cent_long = tr.back_to_coordinates(
             tr.selected_centroids[i][0], tr.selected_centroids[i][1])
         tr.nearest_stops_dep.append(
             tr.nearest_stops(cent_lat, cent_long, 200))
         cent_lat, cent_long = tr.back_to_coordinates(
             tr.selected_centroids[i][2], tr.selected_centroids[i][3])
         tr.nearest_stops_arr.append(
             tr.nearest_stops(cent_lat, cent_long, 200))
     x = [(0.236022142857145, 0.6218945454545409, 0.40896343421923104,
           0.44295239459832625, u'Arrheniusplan'),
          (0.238678571428556, 0.5870136363636353, 0.40812001002704273,
           0.44364416445906113, u'Djursjukhuset'),
          (0.2546271428571387, 0.5872218181818116, 0.40727357545778864,
           0.4443322476140367, u'Campus Ultuna'),
          (0.2753349999999992, 0.5840540909090949, 0.4064241466263627,
           0.44501663096314165, u'Veterin\xe4rv\xe4gen'),
          (0.3359407142856987, 0.5639872727272691, 0.4047163709212964,
           0.4463742461957367, u'Ekudden'),
          (0.34959714285715, 0.5507245454545474, 0.4038580565612437,
           0.4470474522321898, u'Kronparksg\xe5rden'),
          (0.36905928571425406, 0.5455418181818119, 0.40299681296557566,
           0.4477169067691902, u'Gustaf Kjellbergs v\xe4g'),
          (0.3865264285714416, 0.5455240909090874, 0.4012656037101964,
           0.449044510434701, u'Emmy Rappes v\xe4g'),
          (0.39794999999997865, 0.543904545454542, 0.40039567101021384,
           0.4497026342875515, u'Uppsala Folkh\xf6gskola'),
          (0.4188514285714396, 0.5506949999999958, 0.39864723227667076,
           0.4510074633850332, u'Lundellska skolan'),
          (0.43012357142855484, 0.5347072727272748, 0.3977687595308634,
           0.45165414378759955, u'Polacksbacken'),
          (0.42828428571429433, 0.49847272727272374, 0.3968874734808786,
           0.4522969849859463, u'Grindstugan'),
          (0.45128642857140344, 0.49310363636362675, 0.395116528635283,
           0.453571100888228, u'Uppsala Science Park'),
          (0.5006285714285578, 0.5147454545454487, 0.3942269035559092,
           0.4542023513348327, u'Akademiska sjukhuset s\xf6dra'),
          (0.4981964285714144, 0.5162363636363563, 0.3933345326041903,
           0.4548297140630195, u'Akademiska sjukhuset'),
          (0.5175778571428252, 0.5021068181818119, 0.3924394327695829,
           0.4554531771287061, u'Svandammen'),
          (0.5421178571428472, 0.5200304545454572, 0.39154162109349755,
           0.45607272866205456, u'B\xe4verns gr\xe4nd'),
          (0.5531264285714069, 0.5268077272727204, 0.3906411146689745,
           0.45668835686769677, u'Centralstationen')]
     result = tr.calculate_distance_arrival(
         x,
         tr.calculate_distance_departure(x)["pos_departure"])
     result['dist_arrival'][0] = round(result['dist_arrival'][0], 4)
     result['dist_arrival'][1] = round(result['dist_arrival'][1], 4)
     result['dist_arrival'][2] = round(result['dist_arrival'][2], 4)
     result['dist_arrival'][3] = round(result['dist_arrival'][3], 4)
     self.assertEqual(
         result, {
             'dist_arrival': [1000.0, 1000.0, 0.2384, 1000.0],
             'pos_arrival': [0, 0, 10, 0]
         })
     print "Test - OK ... Distance arrival function"
Esempio n. 4
0
 def test_calculate_distance_arrival(self):
     tr.nearest_stops_dep = []
     tr.nearest_stops_arr = []
     tr.selected_centroids = [array([ 0.45161914,  0.52874184,  0.55135584,
     0.50578817,  0.172007  ,  0.0162836 ,  0.18377792,  0.0129053 ]),
     array([ 0.43406424,  0.53152554,  0.23595767,  0.61999794,  0.04638085,
     0.17973951,  0.05322643,  0.16249825]),
     array([ 0.5511221 ,  0.51158863,  0.44533246,  0.52734338,  0.11118081,
     0.44409996,  0.10121861,  0.4370837 ]),
     array([ 0.56304867,  0.50875958,  0.49079012,  0.51340253,  0.38025537,
     0.03755701,  0.38917885,  0.04317823])]
     for i in range(len(tr.selected_centroids)):
         cent_lat, cent_long = tr.back_to_coordinates(
         tr.selected_centroids[i][0], tr.selected_centroids[i][1])
         tr.nearest_stops_dep.append(tr.nearest_stops(
         cent_lat, cent_long, 200))
         cent_lat, cent_long = tr.back_to_coordinates(
         tr.selected_centroids[i][2],tr.selected_centroids[i][3])
         tr.nearest_stops_arr.append(tr.nearest_stops(
         cent_lat, cent_long, 200))
     x = [(0.236022142857145, 0.6218945454545409, 0.40896343421923104,
     0.44295239459832625, u'Arrheniusplan'),
     (0.238678571428556, 0.5870136363636353, 0.40812001002704273,
     0.44364416445906113, u'Djursjukhuset'),
     (0.2546271428571387, 0.5872218181818116, 0.40727357545778864,
     0.4443322476140367, u'Campus Ultuna'),
     (0.2753349999999992, 0.5840540909090949, 0.4064241466263627,
     0.44501663096314165, u'Veterin\xe4rv\xe4gen'),
     (0.3359407142856987, 0.5639872727272691, 0.4047163709212964,
     0.4463742461957367, u'Ekudden'),
     (0.34959714285715, 0.5507245454545474, 0.4038580565612437,
     0.4470474522321898, u'Kronparksg\xe5rden'),
     (0.36905928571425406, 0.5455418181818119, 0.40299681296557566,
     0.4477169067691902, u'Gustaf Kjellbergs v\xe4g'),
     (0.3865264285714416, 0.5455240909090874, 0.4012656037101964,
     0.449044510434701, u'Emmy Rappes v\xe4g'),
     (0.39794999999997865, 0.543904545454542, 0.40039567101021384,
     0.4497026342875515, u'Uppsala Folkh\xf6gskola'),
     (0.4188514285714396, 0.5506949999999958, 0.39864723227667076,
     0.4510074633850332, u'Lundellska skolan'),
     (0.43012357142855484, 0.5347072727272748, 0.3977687595308634,
     0.45165414378759955, u'Polacksbacken'),
     (0.42828428571429433, 0.49847272727272374, 0.3968874734808786,
     0.4522969849859463, u'Grindstugan'),
     (0.45128642857140344, 0.49310363636362675, 0.395116528635283,
     0.453571100888228, u'Uppsala Science Park'),
     (0.5006285714285578, 0.5147454545454487, 0.3942269035559092,
     0.4542023513348327, u'Akademiska sjukhuset s\xf6dra'),
     (0.4981964285714144, 0.5162363636363563, 0.3933345326041903,
     0.4548297140630195, u'Akademiska sjukhuset'),
     (0.5175778571428252, 0.5021068181818119, 0.3924394327695829,
     0.4554531771287061, u'Svandammen'),
     (0.5421178571428472, 0.5200304545454572, 0.39154162109349755,
     0.45607272866205456, u'B\xe4verns gr\xe4nd'),
     (0.5531264285714069, 0.5268077272727204, 0.3906411146689745,
     0.45668835686769677, u'Centralstationen')]
     result = tr.calculate_distance_arrival(x,
     tr.calculate_distance_departure(x)["pos_departure"])
     result['dist_arrival'][0] = round(result['dist_arrival'][0],4)
     result['dist_arrival'][1] = round(result['dist_arrival'][1],4)
     result['dist_arrival'][2] = round(result['dist_arrival'][2],4)
     result['dist_arrival'][3] = round(result['dist_arrival'][3],4)
     self.assertEqual(result, {'dist_arrival':
     [1000.0, 1000.0, 0.2384, 1000.0], 'pos_arrival': [0, 0, 10, 0]})
     print "Test - OK ... Distance arrival function"