Beispiel #1
0
 def add_visit(self, location: Location, date_of_visit, staying_time,
               priority):
     """
     Adds a visit to a location specifying the details. If opening and closing are not specified, the location is open all the time
     :param location: Location to visit
     :param date_of_visit: Date of the visit (must be "YYYY-MM-DD" format)
     :param staying_time: Staying time of the visit (must be "hh:mm:ss" format)
     :param priority: A priority for scheduling this visit
     :param opening_time: Opening time of the location (must be "hh:mm:ss" format)
     :param closing_time: Closing time of the location (must be "hh:mm:ss" format)
     """
     visit = {
         "name":
         location.name,
         "OpeningTime":
         date_of_visit + 'T' + location.opening_time(date_of_visit),
         "ClosingTime":
         date_of_visit + 'T' + location.closing_time(date_of_visit),
         "DwellTime":
         staying_time,
         "Priority":
         int(priority),
         "Location": {
             "Latitude": location.latitude,
             "Longitude": location.longitude
         }
     }
     self.__to_visit.append(visit)
     self.__modified = True
 def getLocationFromCity(self, location_query):
     '''
     Usage: this is for when user is s
     :param location_query:
     :return:
     '''
     return Location.get_locations_by_query(location_query, self.__city)
Beispiel #3
0
 def __get_visits(self, instructions):
     return [
         Visit(
             Location(i['itineraryItem']['name'],
                      i['itineraryItem']['location']['latitude'],
                      i['itineraryItem']['location']['longitude']),
             i['startTime'], i['endTime']) for i in instructions
         if i['instructionType'] == 'VisitLocation'
     ]
    def __parseFilterFile(self, filter):
        objectives = []
        goodPath = str(pathlib.Path(__file__).parent.parent.absolute()
                       ) + "\\Scrapping\\obiectiveData\\" + filter + ".txt"

        with open(goodPath.replace('\\', '/'), encoding="utf-8") as file:
            for line in file:
                data = line.strip().split(";")
                if len(data[-2]) == 0 or len(data[-3]) == 0:
                    continue
                try:
                    schedule = eval(data[-5])
                    if len(schedule) % 2 == 1:
                        continue
                    if 'hour' not in data[-4]:
                        continue
                    schedule = self.__build_schedule(schedule)
                except Exception as e:
                    # print(e)
                    continue
                nrs = re.findall(r'\d+', data[-4])
                if len(nrs) > 3 or len(nrs) == 0:
                    continue
                s = 0
                for nr in nrs:
                    s += int(nr)
                location = Location(data[0],
                                    float(data[-3]),
                                    float(data[-2]),
                                    schedule=schedule)
                if location.is_closed(self.__start_date_time.split("T")[0]):
                    continue
                objectives.append(
                    ObjectiveVisit(location, self.__nr_to_hour(s / len(nr)),
                                   None, data[1], data[3], data[5]))
        return objectives
def showMeTheMap(param):
    lat=[]
    long=[]
    points=[]
    for p in param:
        coord=Location.get_locations_by_query(p)
        print(coord[0].latitude,coord[0].longitude)
        # lat.append(coord[0].latitude)
        # long.append(coord[0].longitude)

        points.append(tuple([coord[0].latitude, coord[0].longitude]))

    # centroid_lat = 16.7
    # centroid_lon = 81.095
    #
    # x = .1
    #
    # n = 10
    #
    # o_lats = np.asarray(lat[0:-2])
    # o_lons = np.asarray(long[0:-2])
    # d_lats = np.asarray(lat[1:-1])
    # d_lons = np.asarray(long[1:-1])
    #
    # df = pandas.DataFrame({'origin_lng': o_lons, 'origin_lat': o_lats,
    #                    'destination_lng': d_lons, 'destination_lat': d_lats})


    print(points)
    ave_lat = sum(p[0] for p in points) / len(points)
    ave_lon = sum(p[1] for p in points) / len(points)

    # Load map centred on average coordinates
    my_map = folium.Map(location=[ave_lat, ave_lon], zoom_start=14)

    # add a markers
    for each in points:
        folium.Marker(each).add_to(my_map)

    # fadd lines
    folium.PolyLine(points, color="red", weight=2.5, opacity=1).add_to(my_map)

    # Save map
    my_map.save("./gpx_berlin_withmarker.html")

    pass
 def getHardLocation(self):
     return Location("home", 48.220293, 16.3856423)
 def getCurrentLocation(self):
     g = geocoder.ip('me')
     print(str(g.latlng[0]) + "--" + str(g.latlng[1]))
     return Location('start', g.latlng[0], g.latlng[1])
Beispiel #8
0
from API.ItineraryAPI.Location import Location

add_loc = True
to_visit = []
while add_loc:
    add_loc = True if input("Add location? (Y|N)") == "Y" else False
    if not add_loc: break
    location_query = input("Give a location: ")
    locations = Location.get_locations_by_query(location_query)
    for l in locations:
        print(locations.index(l), " ", l)
    choice = int(input("Select one:"))
    to_visit.append(locations[choice])