-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtools.py
27 lines (23 loc) · 870 Bytes
/
tools.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from pyproj import Proj, transform
import unicodedata
import string
import random
def convert_coordinates(x,y):
inProj = Proj(init='epsg:3857')
outProj = Proj(init='epsg:4326')
x2,y2 = transform(inProj,outProj,x,y)
return(x2,y2)
def extract_point(response_json):
for alias in response_json['data']['value'][0]["fields"]["fields"]:
if 'POINT' in alias["value"]:
point_text = alias["value"]
point_text = point_text.replace("POINT(","")
point_text = point_text.replace(")","")
x, y = point_text.split(" ")
return float(x), float(y)
def normalize_data(s):
s = s.lower()
return ''.join(c for c in unicodedata.normalize('NFD', s)
if unicodedata.category(c) != 'Mn')
def id_generator(size=6, chars=string.ascii_uppercase + string.digits):
return ''.join(random.choice(chars) for _ in range(size))