예제 #1
0
파일: Maps.py 프로젝트: ssk-98/V.I.E.W
 def __init__(self):
     self.modes = {'walk':[herepy.RouteMode.pedestrian,herepy.RouteMode.shortest],'bus':[herepy.RouteMode.publicTransport,herepy.RouteMode.fastest],'car':[herepy.RouteMode.car,herepy.RouteMode.fastest,herepy.RouteMode.traffic_enabled]}
     self.api_key = self.getconfig("maps_api")#"NuWLrM7oE23-PKjQWHD79izu0aFFvYdEu7wZV0SanSE"
     self.max_radius = self.getconfig("maxradius")*1000 #Enter in KM
     self.geocoderApi = herepy.GeocoderApi(self.api_key)
     self.geocoderAutoCompleteApi = herepy.GeocoderAutoCompleteApi(self.api_key)
     self.routingApi = herepy.RoutingApi(self.api_key)
     self.geocoderReverseApi = herepy.GeocoderReverseApi(self.api_key)
     self.placesApi = herepy.PlacesApi(self.api_key)
     self.current_coordinates = [0,0]
     self.loadconfig()
예제 #2
0
def places_init(filename):
    '''
    Initialize Here.com Places API with credentials from yaml file
    :param filename:  string for file containing credentials in yaml format
    :return:
    '''

    with open(filename, 'r') as f:
        credentials = yaml.safe_load(f)
        f.close()

    app_id = credentials['app_id']
    app_code = credentials['app_code']

    return(herepy.PlacesApi(app_id, app_code))
예제 #3
0
def get_here_restaurants(latitude, longitude):

    placesApi = herepy.PlacesApi('api_key')

    listofRestaurantsnearby = []
    api_key = '#use_key_from_bitwarden.com_or_generate_new_key'
    #&radius=500&sort=real_distance&order=asc&start=0
    getRestaurantsFromLatAndLon = 'https://reverse.geocoder.ls.hereapi.com/6.2/reversegeocode.json?mode=retrieveLandmarks&gen=9&prox=' + latitude + ',' + longitude + ',500&maxresults=20&apiKey=' + api_key
    header = {"User-agent": "curl/7.43.0", "Accept": "application/json"}
    response = requests.get(getRestaurantsFromLatAndLon, headers=header)
    restaurant_info = response.json()["Response"]

    for key, value in restaurant_info.items():
        if (key == 'View'):
            for item in restaurant_info[key][0]["Result"]:
                listofRestaurantsnearby.append(item["Location"]["Name"])
    listofRestaurantsnearbyjson = {
        "nearby": [x for x in listofRestaurantsnearby]
    }
    return jsonify(listofRestaurantsnearbyjson)
예제 #4
0
def nearbyPlaces_dataset(fpathNearby, column_name):

    try:
        excel = pd.read_excel(fpathNearby)

    except:

        try:
            excel = pd.read_csv(fpathNearby)

        except:
            "Input File Read Error!! Please check Format."

    for t in range(len(excel)):


        location= excel.loc[t, column_name]
        placesApi = herepy.PlacesApi(appID, appCode)
        lat, lng = map(float, location.strip('()').split(','))

        nearbyResponse = placesApi.places_with_language([lat, lng], 'ar')

        # try:

        data = nearbyResponse.as_dict()
        for i in range(0, (len(data['results']['items']))):
            title = 'title' + str(i)
            distance = 'distance' + str(i)
            position = 'position' + str(i)
            category = 'category' + str(i)

            excel.loc[t,title] = str(data['results']['items'][i]['title'])
            excel.loc[t, distance] =str(data['results']['items'][i]['distance'])
            excel.loc[t, position] = str(data['results']['items'][i]['position'])
            excel.loc[t, category] = str(data['results']['items'][i]['category']['title'])
            time.sleep(0.1)

    return excel
예제 #5
0
import numpy as np
import pandas as pd
import time
import herepy
from pandasql import sqldf


credentials = np.load(r"C:\Skyhook\HERE\HERE_API_credentials.npy")

# apiID = 'vQUXblWlsSzsBSJNRDax'
# apiCode = 'f4f3xSQqZX5l3m6ur86jAQ'

appID = credentials[1]
appCode = credentials[2]



placesApi = herepy.PlacesApi(appID, appCode)
lat, lng = map(float, location.strip('()').split(','))

nearbyResponse = placesApi.nearby_places([lat, lng])
try:
    data = nearbyResponse.as_dict()
    print(data)
예제 #6
0
 def setUp(self):
     api = herepy.PlacesApi('app_id', 'app_code')
     self._api = api
예제 #7
0
 def setUp(self):
     api = herepy.PlacesApi('api_key')
     self._api = api
예제 #8
0
 def setUp(self):
     api = herepy.PlacesApi("api_key")
     self._api = api
예제 #9
0
def makeWebhookResult(req):
    if req.get("queryResult").get("action") == "symptom":
        result = req.get("queryResult")
        parameters = result.get("parameters")
        symptom = parameters.get("symptom")
        disease = diseaseprediction.dosomething(symptom)
        print(disease)
        #speech = "you may have " + disease + ". Please, consult your doctor."
        #print(speech)
        if not disease:
            speech = "For further details Please click on the below link"
            disease = symptom[0]
        else:
            speech = "you may have " + disease + ". Please, consult your doctor."

        return {
            "fulfillmentText":
            speech,
            "fulfillmentMessages": [{
                "platform": "ACTIONS_ON_GOOGLE",
                "simpleResponses": {
                    "simpleResponses": [{
                        "textToSpeech": speech
                    }]
                }
            }, {
                "platform": "ACTIONS_ON_GOOGLE",
                "linkOutSuggestion": {
                    "destinationName":
                    "Details of disease",
                    "uri":
                    "https://www.webmd.com/search/search_results/default.aspx?query="
                    + disease
                }
            }, {
                "platform": "ACTIONS_ON_GOOGLE",
                "suggestions": {
                    "suggestions": [{
                        "title": "Predict disease"
                    }, {
                        "title": "Details about disease"
                    }, {
                        "title": "Know nearby hospitals"
                    }, {
                        "title": "Thank you"
                    }]
                }
            }]
        }
    if req.get("queryResult").get(
            "action") == "Detailsaboutsymptoms.Detailsaboutsymptoms-custom":
        result = req.get("queryResult")
        parameters = result.get("parameters")
        symptom = parameters.get("disease")
        speech = "For further details Please click on the below link"
        disease = symptom
        return {
            "fulfillmentText":
            speech,
            "fulfillmentMessages": [{
                "platform": "ACTIONS_ON_GOOGLE",
                "simpleResponses": {
                    "simpleResponses": [{
                        "textToSpeech": speech
                    }]
                }
            }, {
                "platform": "ACTIONS_ON_GOOGLE",
                "linkOutSuggestion": {
                    "destinationName":
                    "Details of disease",
                    "uri":
                    "https://www.webmd.com/search/search_results/default.aspx?query="
                    + disease
                }
            }, {
                "platform": "ACTIONS_ON_GOOGLE",
                "suggestions": {
                    "suggestions": [{
                        "title": "Predict disease"
                    }, {
                        "title": "Details about disease"
                    }, {
                        "title": "Know nearby hospitals"
                    }, {
                        "title": "Thank you"
                    }]
                }
            }]
        }
    if req.get("queryResult").get("action") == "google":
        result = req.get("queryResult")
        parameters = result.get("parameters")
        location = parameters.get("geo-city")
        hospital_name = []
        hospital_address = []
        speech = ""
        geocoderApi = herepy.GeocoderApi(
            'NYzvNeZQL5quJfEWEUccVGR-nXIIVt3PeFj1X11dWkw')
        placesApi = herepy.PlacesApi(
            'NYzvNeZQL5quJfEWEUccVGR-nXIIVt3PeFj1X11dWkw')

        response = geocoderApi.free_form(location)
        dict = response.as_dict()
        print(dict)
        position = dict['items'][0]['position']
        latitude = position['lat']
        longitude = position['lng']

        response = placesApi.category_places_at(
            [latitude, longitude],
            [herepy.PlacesCategory.hospital_health_care_facility])
        dict = response.as_dict()

        for i in range(0, 10):
            #print(places_result["results"])
            hospitalname = dict["results"]["items"][i]["title"]
            hospital_name.append(hospitalname)

            hospitaladdress = dict["results"]["items"][i]["vicinity"]
            hospital_address.append(hospitaladdress)

        for i in range(0, len(hospital_name)):
            speech += "<br/><br/>Hospital name: " + hospital_name[
                i] + "<br/>Hospital Address: " + hospital_address[i]
        return {
            "fulfillmentText":
            speech,
            "fulfillmentMessages": [{
                "platform": "ACTIONS_ON_GOOGLE",
                "simpleResponses": {
                    "simpleResponses": [{
                        "textToSpeech": speech
                    }]
                }
            }, {
                "platform": "ACTIONS_ON_GOOGLE",
                "suggestions": {
                    "suggestions": [{
                        "title": "Predict disease"
                    }, {
                        "title": "Details about disease"
                    }, {
                        "title": "Know nearby hospitals"
                    }, {
                        "title": "Thank you"
                    }]
                }
            }]
        }
예제 #10
0
 def __init__(self):
     self.__places_api = herepy.PlacesApi(HERE_APP_ID, HERE_APP_CODE)
예제 #11
0
</li>
</ul>
<p>
<button type="button" onclick="alert('You submitted!')">Submit!</button>
</p>"""

m = folium.Map(location=[45.372, -121.6972], zoom_start=12, tiles='Stamen Terrain')


app_id = 'kj5O3uIQcg0mzyy6Dyeb'

app_code = 'UYxM0q2BZXVoHqthopku6A'

geocoderApi = herepy.GeocoderApi(app_id, app_code)

placesApi = herepy.PlacesApi(app_id, app_code)

# response = placesApi.onebox_search([-25.2744,133.7751], 'pool')

m = folium.Map(location=[-25.2744,133.7751],
                zoom_start=4,
                tiles='Stamen Terrain')

def generate_layer(search_text,coords,colour):
    response = placesApi.onebox_search(coords, search_text)

    df = json_normalize(response.results,'items')

    layer = folium.FeatureGroup(name=search_text)

    for index,row in df.iterrows():