acikyazilimagi / deprem-yardim-backend

afetharita.com backend projesi
Apache License 2.0
383 stars 74 forks source link

what3words Entegrasyonu #93

Closed Doiwriteacode closed 1 year ago

Doiwriteacode commented 1 year ago

The what3words API is a fast, simple interface which allows you to convert 3 word addresses such as ///index.home.raft to latitude and longitude coordinates such as (-0.203586, 51.521251) and vice versa. It features a powerful autosuggest function, which can validate and autocorrect user input and limit it to certain geographic areas (this powers the search box on our map site). It allows you to request a section of the what3words grid (which can be requested as GeoJSON for easy display on online maps), and to request the list of all languages supported by what3words. For advanced users, autosuggest can be used to post-process voice output. See links on the left to navigate.

All coordinates are latitude,longitude pairs in standard WGS-84 (as commonly used worldwide in GPS systems). All latitudes must be in the range of -90 to 90 (inclusive).

https://developer.what3words.com/public-api

API Buradan ulaşılabilir, ///üç.kelime.gir şeklinde bir farkındalık yaratılabilirse bu aracı kullanarak nokta atışı adres alımı ve yönlendirme yapılabilir.

yemregundogmus commented 1 year ago

Aktif olarak google geocoder kullanarak halletik bu süreci, not alıyorum. Sorun yaşarsak deneyelim.

Doiwriteacode commented 1 year ago

İleride ekleme yapılırsa aşağıdaki kod parçasından yararlanılabilir belki. Sevgiler.

import folium import folium.plugins import pandas as pd import tweepy import requests

setup twitter API

consumer_key = "YOUR_CONSUMER_KEY" consumer_secret = "YOUR_CONSUMER_SECRET" access_token = "YOUR_ACCESS_TOKEN" access_token_secret = "YOUR_ACCESS_TOKEN_SECRET"

auth = tweepy.OAuthHandler(consumer_key, consumer_secret) auth.set_access_token(access_token, access_token_secret)

api = tweepy.API(auth)

setup w3w API

w3w_api_key = "YOUR_W3W_API_KEY"

search twitter for tweets containing specified hashtags

tweets = api.search(q="#deprem OR #kahramanmaras OR #hatay")

create a list to store the latitude, longitude, and what3words data

data = []

loop through the tweets and get the w3w for each tweet's location

for tweet in tweets: lat, lng = tweet.coordinates['coordinates'] response = requests.get(f"https://api.what3words.com/v3/forward?key={w3w_api_key}&coordinates={lat},{lng}&format=json") what3words = response.json()['words'] data.append([lat, lng, what3words])

create a dataframe from the latitude, longitude, and what3words data

df = pd.DataFrame(data, columns=['latitude', 'longitude', 'what3words'])

initialize a folium map centered at the average of the latitude and longitude values

m = folium.Map(location=[sum(df['latitude'])/len(df['latitude']), sum(df['longitude'])/len(df['longitude'])], zoom_start=7)

add markers for each point in the dataframe

for i, row in df.iterrows(): folium.Marker([row['latitude'], row['longitude']], popup=f"What3Words: <a href='https://map.what3words.com/{row['what3words']}' target='_blank'>{row['what3words']}", ).add_to(m)

add a layer control to the map to toggle the heatmap on and off

heatmap = folium.FeatureGroup(name="Heatmap") heatmap.add_child(folium.plugins.HeatMap(data=df[['latitude', 'longitude']].values.tolist(), radius=15)) m.add_child(heatmap)

add a layer control to the map to toggle the heatmap on and off

folium.plugins.MeasureControl().add_to(m)

save the map to an html file

m.save('map.html')