def setUp(self): # Ferry Building, San Francisco. self.ferry_building_coordinates = point.Coordinates(37.7955, -122.3937) # Pier 39, San Francisco. self.pier_39_coordinates = point.Coordinates(37.8100, -122.4104) # Place near Pier 39, San Francisco. self.near_pier_39_coordinates = point.Coordinates(37.8097, -122.4104) self.walking_speed = 2. # Walking speed in mph. self.driving_speed = 20. # Speed of car in traffic jams in mph. # 10 minutes to find and than park a car and 10 minutes to find a parking # spot when arrived. self.pause_before_driving = 0.30 self.ptt_speed = 15. # Speed of Public Transportation or Taxi in mph. # 15 minutes to buy a ticket and wait in case of public transportation or # call a taxi. self.pause_before_ptt = 0.25 self.fb_to_p39_walking = 1.916 / self.walking_speed self.fb_to_np39_walking = 1.894 / self.walking_speed self.p39_to_np39_walking = 0.029 / self.walking_speed self.fb_to_p39_driving = 1.916 / self.driving_speed self.fb_to_np39_driving = 1.894 / self.driving_speed self.p39_to_np39_driving = 0.029 / self.driving_speed self.fb_to_p39_ptt = 1.916 / self.ptt_speed self.fb_to_np39_ptt = 1.894 / self.ptt_speed self.p39_to_np39_ptt = 0.029 / self.ptt_speed self.fb_to_p39_pause_and_driving = (self.fb_to_p39_driving + self.pause_before_driving) self.fb_to_np39_pause_and_driving = (self.fb_to_np39_driving + self.pause_before_driving) self.p39_to_np39_pause_and_driving = (self.p39_to_np39_driving + self.pause_before_driving) self.fb_to_p39_pause_and_ptt = self.fb_to_p39_ptt + self.pause_before_ptt self.fb_to_np39_pause_and_ptt = self.fb_to_np39_ptt + self.pause_before_ptt self.p39_to_np39_pause_and_ptt = (self.p39_to_np39_ptt + self.pause_before_ptt) super(MoveCalculatorTest, self).setUp()
def main(): points_input = list(point_test_util.GetPointsInput('data', 'test_nyc_1.csv').values()) city_visit_finder_runner = finder_runner.CityVisitFinderRunner() visit_location = city_visit.VisitLocation('New York City') # 746 Ninth Ave, New York, NY 10019. start_end_coordinates = point.Coordinates(40.763582, -73.988470) first_day, last_day = 13, 16 day_visit_parameterss = runner_util.GetDayVisitParameterss(start_end_coordinates, first_day, last_day) city_visit_parameters = runner_util.GetCityVisitParameters(visit_location, day_visit_parameterss) city_visit_finder_runner.Run(points_input, city_visit_parameters)
def main(): points_dict = test_util.GetPointsInput('data', 'test_nyc_1.csv') points_keys = test_util.GetPointsKeys('router', 'test_points_nyc.txt') points_input = test_util.FilterAndSortByKeys(points_dict, points_keys) # 746 Ninth Ave, New York, NY 10019. start_end_coordinates = point.Coordinates(40.763582, -73.988470) first_day, last_day = 13, 16 day_visit_parameterss = runner_util.GetDayVisitParameterss( start_end_coordinates, first_day, last_day) city_visit_router_runner = router_runner.CityVisitRouterRunner() city_visit_router_runner.Run(points_input, day_visit_parameterss)
def ExtractCoordinates(coordinates_str): coordinates_str = ExtractString(coordinates_str) if __IsNone(coordinates_str): return None latitude_str, longitude_str = coordinates_str.split(lat_long_delimeter) latitude_str = ExtractString(latitude_str) longitude_str = ExtractString(longitude_str) if __IsNone(latitude_str) or __IsNone(longitude_str): return None latitude = __CoordinateStrToFloat(latitude_str, 'N', 'S') longitude = __CoordinateStrToFloat(longitude_str, 'E', 'W') return point_.Coordinates(latitude, longitude)
def testReadCSVGeneral(self): s = str() s += 'ID,Name,CoordinatesStarts,CoordinatesEnds,OperatingHoursOpens,OperatingHoursCloses,Duration,Popularity,City Tours,Landmarks,Nature,Museums,Shopping,Dining,Senior,Adult,Junior,Child,Toddlers,Price,Parking,Eating\n' s += '1,Ferry Building,"37.7955N, 122.3937W",,09:00:00,18:00:00,1,80,,100,,,,,90,90,40,70,,,,100\n' s += '2,Pier 39,"37.8100N, 122.4104W",,10:00:00,22:00:00,3,80,,100,,,30,60,70,70,70,90,,,,100\n' csv_filepath = tempfile.mktemp() with open(csv_filepath, 'w') as csv_file: csv_file.write(s) pier_39 = point.Point( name='Pier 39', coordinates_starts=point.Coordinates(37.8100, -122.4104), coordinates_ends=None, operating_hours=point.OperatingHours(datetime.time(10, 0, 0), datetime.time(22, 0, 0)), duration=3., popularity=80, point_type=point.PointType( city_tours=None, landmarks=100, nature=None, museums=None, shopping=30, dining=60), age_group=point.AgeGroup( senior=70, adult=70, junior=70, child=90, toddlers=None), price=None, parking=None, eating=100) points = read_csv.ReadCSV(csv_filepath) self.assertEqual(2, len(points)) self.assertEqual(pier_39, points[1]) points = read_csv.ReadCSVToDict(csv_filepath) self.assertEqual(2, len(points)) self.assertEqual(set(['Ferry Building', 'Pier 39']), set(points.keys())) self.assertEqual(pier_39, points['Pier 39'])
def testExtractCoordinatesGeneral(self): ferry_building_coordinates = read_csv.ExtractCoordinates('37.7955N, 122.3937W') self.assertEqual(point.Coordinates(37.7955, -122.3937), ferry_building_coordinates) ferry_building_coordinates = read_csv.ExtractCoordinates('37.7955, -122.3937') self.assertEqual(point.Coordinates(37.7955, -122.3937), ferry_building_coordinates) kremlin_coordinates = read_csv.ExtractCoordinates('55.7517N, 37.6178E') self.assertEqual(point.Coordinates(55.7517, 37.6178), kremlin_coordinates) kremlin_coordinates = read_csv.ExtractCoordinates('55.7517, 37.6178') self.assertEqual(point.Coordinates(55.7517, 37.6178), kremlin_coordinates) christ_the_redeemer_coordinates = read_csv.ExtractCoordinates('22.9519S, 43.2106W') self.assertEqual(point.Coordinates(-22.9519, -43.2106), christ_the_redeemer_coordinates) christ_the_redeemer_coordinates = read_csv.ExtractCoordinates('-22.9519, -43.2106') self.assertEqual(point.Coordinates(-22.9519, -43.2106), christ_the_redeemer_coordinates) self.assertEqual(None, read_csv.ExtractCoordinates(''))
import os from config import config as config_ config = config_.GetConfig(os.path.join('config', 'runner.config')) import datetime from data import city_visit from data import point start_end_coordinates = point.Coordinates(40.763582, -73.988470) day1 = city_visit.DayVisitParameters( start_datetime=datetime.datetime(2019, 7, 1, 10, 0, 0), end_datetime=datetime.datetime(2019, 7, 1, 19, 0, 0), lunch_start_datetime=datetime.datetime(2019, 7, 1, 14, 0, 0), lunch_hours=1., start_coordinates=start_end_coordinates, end_coordinates=start_end_coordinates) day2 = city_visit.DayVisitParameters( start_datetime=datetime.datetime(2019, 7, 2, 10, 0, 0), end_datetime=datetime.datetime(2019, 7, 2, 17, 0, 0), lunch_start_datetime=datetime.datetime(2019, 7, 1, 14, 0, 0), lunch_hours=1., start_coordinates=start_end_coordinates, end_coordinates=start_end_coordinates) from data import city_visit from data import point visit_location = city_visit.VisitLocation('New York City')
def setUp(self): self.san_francisco_coordinates = point.Coordinates(37.7833, -122.4167) self.points = read_csv.ReadCSVToDict(os.path.join('data', 'test_sf_1.csv')) super(FactorCostAccumulatorTest, self).setUp()
def GetHotelCoordinates(): # San Francisco coordinates. return point.Coordinates(37.7833, -122.4167)