-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocess_indy.py
More file actions
40 lines (33 loc) · 4.61 KB
/
process_indy.py
File metadata and controls
40 lines (33 loc) · 4.61 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
import json
geojson_data = {
"type": "FeatureCollection",
"name": "us-1909",
"bbox": [ -86.238930, 39.788120, -86.230961, 39.801235 ],
"features": [
{ "type": "Feature", "properties": { "id": "us-1909", "Location": "Indianapolis", "Name": "Indianapolis Motor Speedway", "opened": 1909, "firstgp": 2000, "length": 4192, "altitude": 219 }, "bbox": [ -86.23893, 39.78812, -86.230961, 39.801235 ], "geometry": { "type": "LineString", "coordinates": [ [ -86.238851, 39.793155 ], [ -86.23893, 39.798968 ], [ -86.238899, 39.799057 ], [ -86.238842, 39.799102 ], [ -86.238748, 39.799124 ], [ -86.238529, 39.799128 ], [ -86.238191, 39.799127 ], [ -86.238058, 39.799141 ], [ -86.237936, 39.799177 ], [ -86.237837, 39.79922 ], [ -86.237736, 39.799308 ], [ -86.237671, 39.799418 ], [ -86.237655, 39.799522 ], [ -86.237663, 39.799634 ], [ -86.237701, 39.799953 ], [ -86.237701, 39.800064 ], [ -86.237685, 39.800171 ], [ -86.237619, 39.800362 ], [ -86.237487, 39.800574 ], [ -86.237333, 39.800734 ], [ -86.237216, 39.800821 ], [ -86.23703, 39.800928 ], [ -86.236679, 39.801064 ], [ -86.236255, 39.801213 ], [ -86.23615, 39.801235 ], [ -86.236015, 39.801229 ], [ -86.235911, 39.801199 ], [ -86.235716, 39.801097 ], [ -86.235573, 39.800961 ], [ -86.235528, 39.800897 ], [ -86.235476, 39.800788 ], [ -86.235461, 39.800691 ], [ -86.235451, 39.800412 ], [ -86.235449, 39.800001 ], [ -86.235438, 39.799689 ], [ -86.235449, 39.799606 ], [ -86.235491, 39.799497 ], [ -86.235568, 39.799381 ], [ -86.235684, 39.799285 ], [ -86.2371, 39.798503 ], [ -86.237241, 39.798384 ], [ -86.237323, 39.79823 ], [ -86.237331, 39.798148 ], [ -86.237307, 39.798012 ], [ -86.237267, 39.797919 ], [ -86.237144, 39.797795 ], [ -86.237032, 39.797715 ], [ -86.236915, 39.79766 ], [ -86.236759, 39.797615 ], [ -86.236608, 39.797602 ], [ -86.23645, 39.797607 ], [ -86.23625, 39.797651 ], [ -86.23577, 39.797904 ], [ -86.23566, 39.797948 ], [ -86.235555, 39.797963 ], [ -86.235451, 39.797958 ], [ -86.235295, 39.797901 ], [ -86.235162, 39.797802 ], [ -86.235037, 39.797629 ], [ -86.234994, 39.79753 ], [ -86.234981, 39.797435 ], [ -86.234915, 39.792755 ], [ -86.234894, 39.792641 ], [ -86.234878, 39.792614 ], [ -86.234827, 39.792527 ], [ -86.23473, 39.792429 ], [ -86.234593, 39.792336 ], [ -86.234521, 39.792304 ], [ -86.234352, 39.792253 ], [ -86.234222, 39.792233 ], [ -86.234115, 39.792223 ], [ -86.233696, 39.792242 ], [ -86.233509, 39.792247 ], [ -86.233369, 39.792232 ], [ -86.233213, 39.792179 ], [ -86.233126, 39.792134 ], [ -86.23304, 39.792066 ], [ -86.232991, 39.792005 ], [ -86.232945, 39.791915 ], [ -86.232912, 39.791821 ], [ -86.232859, 39.791732 ], [ -86.232802, 39.791666 ], [ -86.232716, 39.791612 ], [ -86.232616, 39.791574 ], [ -86.232519, 39.79155 ], [ -86.232425, 39.79154 ], [ -86.232264, 39.791538 ], [ -86.23141, 39.791583 ], [ -86.231298, 39.791559 ], [ -86.231193, 39.791502 ], [ -86.231142, 39.791444 ], [ -86.231096, 39.791374 ], [ -86.231005, 39.791139 ], [ -86.230961, 39.790914 ], [ -86.230963, 39.790786 ], [ -86.230976, 39.790668 ], [ -86.231078, 39.790152 ], [ -86.231208, 39.789479 ], [ -86.231267, 39.789332 ], [ -86.231341, 39.789169 ], [ -86.231518, 39.788955 ], [ -86.231712, 39.788759 ], [ -86.231903, 39.788619 ], [ -86.232232, 39.788451 ], [ -86.232596, 39.788328 ], [ -86.232866, 39.78827 ], [ -86.233211, 39.78823 ], [ -86.234138, 39.788174 ], [ -86.235328, 39.788133 ], [ -86.236023, 39.78812 ], [ -86.236291, 39.788143 ], [ -86.236572, 39.788188 ], [ -86.236772, 39.788235 ], [ -86.236896, 39.788274 ], [ -86.237234, 39.788398 ], [ -86.237446, 39.788496 ], [ -86.237796, 39.788701 ], [ -86.238002, 39.788874 ], [ -86.238115, 39.788965 ], [ -86.23827, 39.789118 ], [ -86.238523, 39.789436 ], [ -86.238685, 39.789757 ], [ -86.238769, 39.790084 ], [ -86.238794, 39.790268 ], [ -86.23882, 39.790546 ], [ -86.238851, 39.793155 ] ] } }
]
}
coords = geojson_data['features'][0]['geometry']['coordinates']
lons = [p[0] for p in coords]
lats = [p[1] for p in coords]
min_lon, max_lon = min(lons), max(lons)
min_lat, max_lat = min(lats), max(lats)
# Normalize to 0-1 range
# x = (lon - min_lon) / (max_lon - min_lon)
# y = (max_lat - lat) / (max_lat - min_lat) <-- Invert Y for canvas (top-left origin)
normalized_path = []
for lon, lat in coords:
norm_x = (lon - min_lon) / (max_lon - min_lon)
norm_y = (max_lat - lat) / (max_lat - min_lat)
normalized_path.append([norm_x, norm_y])
output = {
"path": normalized_path,
"startLine": normalized_path[0],
"bounds": {
"lat_min": min_lat,
"lat_max": max_lat,
"long_min": min_lon,
"long_max": max_lon
}
}
print(json.dumps(output, indent=2))