def add_properties_almuerzo(features, df): coordinate_filter = (df["LATITUD"].notnull()) & (df["LONGITUD"].notnull()) seen = set() for row in df[coordinate_filter].itertuples(): lat = lat_lon_parser.parse(row.LATITUD) lng = lat_lon_parser.parse(row.LONGITUD) if row._4 not in seen: feature = coordinates_to_feature(lat, lng, features) feature["properties"].setdefault("almuerzo", 0) feature["properties"]["almuerzo"] += 1 seen.add(row._4) return features
def nav(parsed, resp): start = parsed.group("start") destination = parsed.group("destination") saved_locations_dict = session.get("saved_locations", {}) if start in saved_locations_dict: start = saved_locations_dict[start] if destination in saved_locations_dict: destination = saved_locations_dict[destination] if "°" in start and '″ ' in start: if "″ S" in start: start = "-" + start lat = re.split('n |s ', start)[0] lon = re.split('n |s ', start)[1] if "″ W" in lon: lon = "-" + lon lat = str(parse(lat)) lon = str(parse(lon)) try: start = gmaps.reverse_geocode((lat,lon), "street_address")[0]["formatted_address"] print("START: " + start) except: resp.message("Google Maps couldn't find anything at those coordinates :/") return str(resp) if parsed.group("mode"): mode = parsed.group("mode") else: mode ="driving" try: directions_result = gmaps.directions(start, destination, mode=mode, departure_time=datetime.now())[0] session["steps_data"] = directions_result['legs'][0]['steps'] except (IndexError, googlemaps.exceptions.ApiError): resp.message("Location/Route not found -- try being more specific") return str(resp) msg = "Trip Duration: {}\n".format(directions_result['legs'][0]['duration']['text']) for index,step in enumerate(directions_result['legs'][0]['steps'], start=1): if len(msg) > 1500: send_message(msg + " ...") msg = '...' if 'html_instructions' in step: msg += "\n{}. {}".format(index, cleanhtml(step['html_instructions'])) if 'distance' in step: msg += " ({})".format(step['distance']['text']) if 'transit_details' in step: if 'name' in step['transit_details']['line']: transit_name = step['transit_details']['line']['name'] else: transit_name = step['transit_details']['line']['short_name'] msg += "\n Take {} toward {} {} stop(s) to {}".format(transit_name, step['transit_details']['headsign'], step['transit_details']['num_stops'], step['transit_details']['arrival_stop']['name']) if 'steps' in step: msg += " -- type 'expand {}' to see more details for this step".format(index) msg += "\n" print(msg) resp.message(msg) return str(resp)
def test_parse(string, value): tol = 12 assert round(parse(string), tol) == round(value, tol)
def test_parse_invalid(string): with pytest.raises(ValueError): parse(string)
temp = abs(p1.latitude) * 60 sec = temp % 60 min = sec % 60 print(temp,sec,min) #%% # %% print(temp) print(temp % 60) print(temp // 60) print(temp / 60) #%% from lat_lon_parser import parse a = parse('-24 50.20') print(a) help(parse) parse('24 40.753691 S') parse('042 9.720168 W') #%% p1 = Point('25.2,43.25') dd2dm(p1)