def sedan(): form = BookingForm2(request.form) try: if request.method == 'POST': start = form.start.data destination = form.destination.data start = request.form['start'] destination = request.form['destination'] gmaps = GoogleMaps('Your goolge key') start = start end = destination dirs = gmaps.distance(start, end) for step in dirs: x = str(float(step.distance.kilometers)) z = float(x) if z > 50.0: flash( "Distance is more than 50 km.Please change the credentials" ) else: y = str(z * float(4)) flash("Distance is:" + x) flash("Total fare is :" + y) except Exception as e: flash("Please enter the credentials or check your internet connecton") return render_template("sedan.html", form=form)
def geolocation(self): self.maplist = [] self.buttonHeightCounter = .05 API_KEY = 'AIzaSyBPGAbevdKkeXaZT0ZsR0qbO30Bpqqm0Mc' google_places = GooglePlaces(API_KEY) self.query_result = google_places.nearby_search( location=self.entry.get(), radius=700, types=[types.TYPE_RESTAURANT]) self.current_places = self.query_result if self.query_result.has_attributions: print(self.query_result.html_attributions) for place in self.query_result.places: place.get_details() markers = "&markers=size:big|label:S|color:red|" + str( place.details['geometry']['location']['lat']) + "," + str( place.details['geometry']['location']['lng']) + "|" self.maplist.append(markers) print(place.name) self.button_list.append( Button(self, text=place.name, command=lambda pname=place.name: self.on_click(pname), width=25)) self.button_list[-1].place(relx=.70, rely=self.buttonHeightCounter, anchor="c") self.buttonHeightCounter += .035 print(place.formatted_address + "\n") google_maps = GoogleMaps( api_key='AIzaSyDlJqxwlOWWAPwf54ivrpAZw4R1Yb5j6Yk') location = google_maps.search( location=self.entry.get()) # sends search to Google Maps. my_location = location.first() # returns only first location. #MARKER = '&markers=color:blue' + '%' + str(7) + 'Clabel:S%' + str(7) + 'C' + str(my_location.lat) + ',' + str(my_location.lng) #MARKER = "&markers=size:big|label:S|color:blue|" + str(my_location.lat) + "," + str(my_location.lng) + "|" + \ MARKER = self.maplist[1] + self.maplist[2] + self.maplist[3] self.zoomlevel = ZOOM maptype_index = 0 self.radiovar.set(maptype_index) self.goompy = GooMPy(WIDTH, HEIGHT, my_location.lat, my_location.lng, ZOOM, MAPTYPE, MARKER) self.restart() print(self.query_result) print(str(my_location.lat)) print(str(my_location.lng))
def return_latlng(enquiry): address = enquiry google_maps = GoogleMaps(api_key='AIzaSyCw6c6wq-VY06rOn401rwtv-Q7MU3-C89M') location = google_maps.search(location=address) # sends search to Google Maps. # print(location.all()) # returns all locations. my_location = location.first() # returns only first location. # route_name = my_location.route # st = my_location.street_number # place = my_location.formatted_address # print(route_name) # print(my_location.lng) # print(my_location.street_number) # print(my_location.formatted_address) # lat = 37.751502 # lng = -122.386707 # my_location = google_maps.search(lat=lat, lng=lng).first() # print (my_location.route) return [my_location.lat, my_location.lng]
def __init__(self): self.location_cache = {} self.geolocator = Nominatim() self.geolocation = None self.backup_geolocator = GoogleMaps(api_key=google_map_api_key) self.lat = None self.long = None
def __init__(self, **kwargs): super(ConferenceAlertsSpider, self).__init__(**kwargs) self.init_month() self.urls = self.get_dict('assets\conf_start_urls.json') for url in self.urls: self.start_urls = self.start_urls + [url['url']] self.google_maps = GoogleMaps(api_key='AIzaSyCaxLzZ2r7AbCJiIy5RtJ4jOQXcOlDbeV0')
def get_latlng(address): google_maps = GoogleMaps(api_key='AIzaSyCcuF3AbW0iS9QChjdMUsstXN7C5zOJ5gg') location = google_maps.search(location=address) my_location = location.first() return (str(my_location.lat), str(my_location.lng))
def show_dist_delivery_time(): origins = [user_reverse_geocode_result] destinations = [rest_reverse_geocode_result] google_maps = GoogleMaps(api_key=’API_KEY’) items = google_maps.distance(origins, destinations).all() # default mode parameter is DistanceMatrixApiClient.MODE_DRIVING. for item in items: print item.distance.kilometers print item.distance.meters print item.duration
def display_details(self): address = str(self.ui.lineEditLocation.text()) google_maps = GoogleMaps( api_key='AIzaSyCqZcxCYBoZ4ui8ihg02MmR0CLEWzGhZp0') location = google_maps.search(location=address) my_location = location.first() self.ui.labelCity.setText("City: " + str(my_location.city)) self.ui.labelPostalCode.setText("Postal Code: " + str(my_location.postal_code)) self.ui.labelLongitude.setText("Longitude: " + str(my_location.lng)) self.ui.labelLatitude.setText("Latitude: " + str(my_location.lat))
def displayDetails(self): address = str(self.ui.lineEditLocation.text()) google_maps = GoogleMaps(api_key='xxxxxxxxxxxxxxxxxxxxxxxxxxxx') location = google_maps.search(location=address) my_location = location.first() self.ui.labelCity.setText("City:" + str(my_location.city)) self.ui.labelPostalCode.setText("Postal Code: " + str(my_location.postal_code)) self.ui.labelLongitude.setText("Longitude:" + str(my_location.lng)) self.ui.labelLatitude.setText("Latitude:" + str(my_location.lat))
def get_geolocation(address): google_maps = GoogleMaps(api_key='your_geocoding_api_key') location = google_maps.search(location=address) my_location = location.first() if my_location is not None: coordinates = (my_location.lat, my_location.lng) return coordinates else: return 'Not Found'
def dist(): origin = ['Santa Cruz'] destination = ['Seaside'] duration = [] google_maps = GoogleMaps(api_key='AIzaSyBTfMBsYy9fFaJ-XVhoHIz-VnKiN2DZGpg') items = google_maps.distance(origin, destination).all() for item in items: duration.append('Start: ' + origin[0] + '\n' + 'Destination: ' + destination[0] + '\n' + 'Travel time: %s' % item.duration) return duration
def send_data(): #addr = Entry1.get() #print(addr) addr = 'MNNIT Allhabad, Uttar Pradesh' #quant = Scale1.get() #print(quant) ''' import urllib2 proxy = urllib2.ProxyHandler({'http':'edcguest:[email protected]:3128','https':'edcguest:[email protected]:3128'}) opener = urllib2.build_opener(proxy) urllib2.install_opener(opener) ''' address = addr print(address) google_maps = GoogleMaps( api_key=' AIzaSyD4QiVK9WflR5GCkzuks27x55V2_v5CX2k ') print(address) location = google_maps.search( location=address) # sends search to Google Maps. print(location.all()) # returns all locations. my_location = location.first() # returns only first location. print(my_location.city) print(my_location.route) print(my_location.street_number) print(my_location.postal_code) for administrative_area in my_location.administrative_area: print("{}: {} ({})".format(administrative_area.area_type, administrative_area.name, administrative_area.short_name)) print(my_location.country) print(my_location.country_shortcut) print(my_location.formatted_address) print(my_location.lat) print(my_location.lng) '''
def __init__(self): # Setup OSC self.maxServer = OSC.OSCServer(('127.0.0.1', 7000)) self.maxServerThread = threading.Thread(target=self.maxServer.serve_forever) self.maxServerThread.daemon = False self.maxServerThread.start() self.maxClient = OSC.OSCClient() self.maxClient.connect(('127.0.0.1', 57121)) self.maxServer.addMsgHandler("/saveTweetPhrase", self.saveTweetPhraseResponder) self.maxServer.addMsgHandler("/nextTweetPhrase", self.nextTweetPhraseResponder) self.nodeClient = OSC.OSCClient() self.nodeClient.connect(('127.0.0.1', 6000)) # Current tweets to be sonified self.tweets = [] self.tweetIndex = 0 # Instantiate a Google Maps client for geocoding self.maps = GoogleMaps(api_key=mapscredentials.api_key) # Instantiate a Twitter client self.twitterClient = twitter.Api(consumer_key=twittercredentials.consumer_key, consumer_secret=twittercredentials.consumer_secret, access_token_key=twittercredentials.access_token_key, access_token_secret=twittercredentials.access_token_secret, input_encoding=None, tweet_mode="extended") # Instantiate a Google NLP client cred = service_account.Credentials.from_service_account_file('TwittHear-a204ccf1b234.json') cred = cred.with_scopes( ['https://www.googleapis.com/auth/cloud-platform']) self.NLPClient = language.LanguageServiceClient(credentials=cred) # Instantiate CMU Pronunciation Dictionary try: self.dict = cmudict.dict() except: print "Downloading cmudict..." nltk.download('cmudict') print "Downloaded cmudict." self.dict = cmudict.dict() # Attempt to create databases self.setUpDatabase()
def inti(): try: origins = raw_input("[*] Route Dari : ") destinations = raw_input("[*] Route Tujuan : ") time.sleep(1) google_maps = GoogleMaps( api_key='AIzaSyDGJVf8GBXp0UvNcF2hG_eyaSfEsobzHrA') items = google_maps.distance(origins, destinations).all() time.sleep(1) print '[*] Searching location ...' time.sleep(3) for item in items: print print '[*] Route Dari : %s ' % item.origin time.sleep(1) print '[*] Route Tujuan : %s ' % item.destination time.sleep(1) print '[*] Jarak Kilometer : %s KM' % item.distance.kilometers print '[*] Jarak Meter : %s M' % item.distance.meters print '[*] Jarak Mil : %s Mil' % item.distance.miles print '[*] Durasi Perjalanan : %s ' % item.duration print '[*] Durasi Waktu : %s ' % item.duration.datetime print '[*] Durasi Hari : %s ' % item.duration.days print '[*] Durasi Jam : %s ' % item.duration.hours print '[*] Durasi menit : %s ' % item.duration.minutes print '[*] Durasi detik : %s \n' % item.duration.seconds next = raw_input('[*] Tunjukan Mode Lain nya (yes/no) : ') yes = "yes" if next == yes: time.sleep(2) print '[*] Mode Lainnya Diterima\n ' else: time.sleep(2) print '[*] Mode lainnya Ditolak ' sys.exit() except KeyboardInterrupt: print "\n[*] System Control + C" sys.exit() except TypeError: print "[*] System Error code: 0x6572726f722073797374656d" sys.exit()
def on_data(self, data): #Decode json data tweet = json.loads(data) username = tweet['user']['screen_name'] location_address = tweet['user']['location'] tweet_text = tweet['text'].encode('ascii', 'ignore') processed_tweet = preprocess(tweet_text) if processed_tweet != 1: try: if location_address and location_address is not None: location_address.replace(" ", "+") google_maps = GoogleMaps( api_key='AIzaSyCoMZR7wii10qjJarohY7Ru__9cxC8Ftgw') geo_location = google_maps.search( location=location_address) location = geo_location.first() if location and location is not None: latitude = location.lat longitude = location.lng print("Original token list:", tweet_text) print("Location: ", location_address) print("New token list:", processed_tweet) print "Latitude: {}, Longitude= {} ".format( latitude, longitude) #print("Sentiment: ", sentiment) tweet = " ".join(tweet_text.split()) processed_tweet = (processed_tweet + "\t" + str(latitude) + "\t" + str(longitude) + "\t" + tweet + "\n") conn.send(processed_tweet.encode('utf-8')) else: print("No location returned from the API!") else: print("No location data associated with the tweet!") except: print("Couldn't find location of the tweet!")
from geolocation.main import GoogleMaps address = 'São Luís Maranhão' google_maps = GoogleMaps(api_key='AIzaSyBCksh0B58c_C6k_Epm2k1ZQb-YF6kA6SE') location = google_maps.search(location=address) my_location = location.first() if my_location.city: print(my_location.city.decode('utf-8')) if my_location.route: print(my_location.route.decode('utf-8')) if my_location.street_number: print(my_location.street_number) if my_location.postal_code: print(my_location.postal_code) for administrative_area in my_location.administrative_area: print("%s: %s" % (administrative_area.area_type, administrative_area.name.decode('utf-8'))) if my_location.country: print(my_location.country.decode('utf-8')) print(my_location.country_shortcut) print(my_location.formatted_address) print(my_location.lat) print(my_location.lng)
from geolocation.main import GoogleMaps from geolocation.distance_matrix.client import DistanceMatrixApiClient import urllib2 import json google_maps = GoogleMaps(api_key="AIzaSyA2l1Dg7y6sUMl98CSDudcuC28VLLlXFTk") def getgeoinfo(): f = urllib2.urlopen('http://freegeoip.net/json/') json_string = f.read() f.close() location = json.loads(json_string) return location def getLat(addr): location=google_maps.search(location=addr) print("aaaa" + location.all()) myloc = location.first() return myloc.lat def getLng(addr): location=google_maps.search(location=addr) return location.first().lng
def __init__(self): self.gender_detector = GenderDetector() self.googlemaps_api = GoogleMaps( api_key=app_settings.SERVICES_CREDENTIALS['google_api_key'])
def send_data(): global m1,m2 addr = Entry1.get() print(addr) quant = Scale1.get() print(quant) #top.withdraw() #top1.deiconify() ''' import urllib2 proxy = urllib2.ProxyHandler({'http':'edcguest:[email protected]:3128','https':'edcguest:[email protected]:3128'}) opener = urllib2.build_opener(proxy) urllib2.install_opener(opener) ''' address = addr print(address) google_maps = GoogleMaps(api_key=' AIzaSyD4QiVK9WflR5GCkzuks27x55V2_v5CX2k ') print(address) location = google_maps.search(location=address) # sends search to Google Maps. print(location.all()) # returns all locations. my_location = location.first() # returns only first location. print(my_location.city) print(my_location.route) print(my_location.street_number) print(my_location.postal_code) for administrative_area in my_location.administrative_area: print("{}: {} ({})".format(administrative_area.area_type, administrative_area.name, administrative_area.short_name)) print(my_location.country) print(my_location.country_shortcut) print(my_location.formatted_address) print(my_location.lat) print(my_location.lng) #host1 = socket.gethostname() host1 = '172.20.53.93' port = 2004 BUFFER_SIZE = 2000 print(socket.gethostbyname(host1)) #host1 = '192.168.225.26' m1 = str(my_location.lat) + ' ' m2 = str(my_location.lng) MESSAGE = m1 + m2 + ' ' + str(quant) print(MESSAGE) tcpClientA = socket.socket(socket.AF_INET, socket.SOCK_STREAM) tcpClientA.connect((host1, port)) tcpClientA.send(MESSAGE) tcpClientA.close() top.withdraw() top1.deiconify()
from datetime import datetime, timedelta from pytz import timezone from geolocation.main import GoogleMaps from credentials import * import threading import time import random import requests import tweepy google_maps = GoogleMaps(api_key='') auth = tweepy.OAuthHandler(consumer_key, consumer_secret) auth.set_access_token(access_token, access_token_secret) api = tweepy.API(auth) agencyids = [""] TWEET_SLEEP_TIME = 10 PP_API_SLEEP = 5 MINUTES_REMOVE = 5 currtime = datetime.now() incidents = [] def grab_pulsepoint(agencyid): url = "https://api.pulsepoint.org/v1/incidents" pp_json = None while pp_json is None: try: pp_json = requests.get(url, headers=random_headers(), params=( ('apikey', ''),
# -*- coding: utf-8 -*- from geolocation.main import GoogleMaps if __name__ == "__main__": address = "New York City" google_maps = GoogleMaps(api_key='your_google_maps_key') location = google_maps.search(location=address) print(location.all()) my_location = location.first() print(my_location.city) print(my_location.route) print(my_location.street_number) print(my_location.postal_code) for administrative_area in my_location.administrative_area: print("%s: %s" % (administrative_area.area_type, administrative_area.name)) print(my_location.country) print(my_location.country_shortcut) print(my_location.formatted_address) print(my_location.lat) print(my_location.lng)
def testRequests(decrypt): address = decrypt google_maps = GoogleMaps(api_key="AIzaSyAEk_XVCNBK9RavS6KiXXfQW-fRvMzKt5o") location = google_maps.search(location=address) print(location.all())
import csv from operator import itemgetter from geolocation.main import GoogleMaps ifile = open('crash.csv', 'r') reader = csv.DictReader(ifile) default = 0 google_maps = GoogleMaps(api_key='AIzaSyARs71g1TIgn9VYqK4xmdLN64AbwZxBXn0') error = 0 breakvar = 0 total = 0 listLat = [] listLng = [] csvfile = open('sandend.csv', 'w') fieldnames = ['slatitude', 'slongitude', 'elatitude', 'elongitude'] writer = csv.DictWriter(csvfile, fieldnames=fieldnames) writer.writeheader() for row in reader: try: location1 = google_maps.search(location=((row['Route']).split('-'))[0]) my_location1 = location1.first() location2 = google_maps.search(location=((row['Route']).split('-'))[1]) my_location2 = location2.first() writer.writerow({ 'slatitude': my_location1.lat, 'slongitude': my_location1.lng, 'elatitude': my_location2.lat,
# -*- coding:utf-8 -*- from geolocation.main import GoogleMaps from geolocation.distance_matrix.client import DistanceMatrixApiClient key = 'AIzaSyAr1BDyauV-BQzwduA1kQBIghgeOABJs-g' maps = GoogleMaps(api_key=key) class Geolocalisation(object): def geolocalisationAdresse(self, adresse): localisation = maps.search(location=adresse) localisation.all() adresse_localisation = localisation.first() ville = adresse_localisation.city route = adresse_localisation.route numero_rue = adresse_localisation.street_number code_postal = adresse_localisation.postal_code pays = adresse_localisation.country liste = [ville, route, numero_rue, code_postal, pays] for administrative_area in adresse_localisation.administrative_area: liste.append(administrative_area.area_type) liste.append(administrative_area.name) latitude = adresse_localisation.lat longitude = adresse_localisation.lng liste.append(latitude)
from geolocation.main import GoogleMaps address = "Thane Wood Street Kenora " google_maps = GoogleMaps(api_key='AIzaSyCIIOxzvcIvagBNbLs7xN_WR3rYPnEf-0A') location = google_maps.search(location=address) # sends search to Google Maps. print(location.all()) # returns all locations. my_location = location.first() # returns only first location. print(my_location.city) print(my_location.route) print(my_location.street_number) print(my_location.postal_code) for administrative_area in my_location.administrative_area: print("{}: {} ({})".format(administrative_area.area_type, administrative_area.name, administrative_area.short_name)) print(my_location.country) print(my_location.country_shortcut) print(my_location.formatted_address) print(my_location.lat) print(my_location.lng) # reverse geocode
import os, sys, json, requests from flask import Flask, request import apiai from config import * from threadsettings import * from geolocation.main import GoogleMaps from transport import * from datetime import datetime app = Flask(__name__) # An endpoint to ApiAi, an object used for making requests to a particular agent. ai = apiai.ApiAI(CLIENT_ACCESS_TOKEN) google_maps = GoogleMaps(api_key=GOOGLE_MAPS_KEY) user_location = {} user_destination = {} user_name = "mate" @app.route('/', methods=['GET']) def print_signage(): return "Conversational Chatbot Webservice, send your data towards this/webhook!" # Handling HTTP GET when Facebook subscribes to our Webhook. @app.route('/webhook', methods=['GET']) def handle_verification(): print("Handling Verification.") # Checking if the GET was sent by Messenger by matching the configured secret token. if (request.args.get('hub.verify_token', '') == VERIFY_TOKEN):
import random import re import requests import sys auth_token = environ['EVENTBRITE_OAUTH_TOKEN'] pusher_app_id = environ['PUSHER_APP_ID'] pusher_key = environ['PUSHER_KEY'] pusher_secret = environ['PUSHER_SECRET'] mu_token = environ['MEETUP_API_KEY'] geo_code = environ['GEOCODE_API_KEY'] # Instantiate the Eventbrite and Meetup API clients. eventbrite = eventbrite.Eventbrite(auth_token) meetup = meetup.api.Client(mu_token) google_maps = GoogleMaps(api_key=geo_code) geo_api = geo_code compress = Compress() app = Flask(__name__) Compress(app) app.debug = False app.jinja_env.undefined = StrictUndefined app.secret_key = "leisure" MEETUP_IMG_URL = "static/assets/meetup_logo.png" EVBRTE_IMG_URL = "static/assets/eb_logo.jpg" # ----------------------------- ROUTES ---------------------------------- #
from webwhatsapi.objects.message import Message from bs4 import BeautifulSoup from geolocation.main import GoogleMaps from csv import DictReader # Create SQS client sqs = boto3.client('sqs') queue_url = 'https://us-west-2.queue.amazonaws.com/362759655961/sendQueue' s_queue_url = 'https://sqs.us-west-2.amazonaws.com/362759655961/sendMessage.fifo' r_queue_url = 'https://sqs.us-west-2.amazonaws.com/362759655961/recieveSQS.fifo' conn = psycopg2.connect(database="postgres", user = "******", password = "******", host = "127.0.0.1", port = "5432") print "Opened database successfully" cur = conn.cursor() google_maps = GoogleMaps(api_key='AIzaSyDNw4OLKRESwCrp1lLU6ojq9paZ85ZSqqs') driver = WhatsAPIDriver(client="chrome") print("Waiting for QR") driver.wait_for_login() print("Bot started") def send(): msg = [] #pdb.set_trace() try: while(True): pdb.set_trace() response = sqs.receive_message(QueueUrl=s_queue_url,AttributeNames=['All'],MessageAttributeNames=['All'],MaxNumberOfMessages=1,VisibilityTimeout=10)['Messages'] try:
https://console.cloud.google.com/google/maps-apis/new?project=upbeat-lexicon-223120 Geocoding maps-apis Distance Matrix maps-apis pip install geolocation-python # -- coding: utf-8 -- from geolocation.main import GoogleMaps from geolocation.distance_matrix.client import DistanceMatrixApiClient address = “New York City Wall Street 12” google_maps = GoogleMaps(api_key=’your_google_maps_key’) location = google_maps.search(location=address) # sends search to Google Maps. print(location.all()) # returns all locations. my_location = location.first() # returns only first location. print(my_location.city) print(my_location.route) print(my_location.street_number) print(my_location.postal_code) for administrative_area in my_location.administrative_area: print(“{}: {} ({})”.format(administrative_area.area_type, administrative_area.name, administrative_area.short_name)) print(my_location.country) print(my_location.country_shortcut) print(my_location.formatted_address) print(my_location.lat) print(my_location.lng)
def __init__(self, google_api_key): super().__init__() self.__solr = SolrClient(iu.solr_url) self.__core = iu.solr_core_tweets self.__google_maps = GoogleMaps(api_key=google_api_key)