Repository navigation
Expand file tree
/
Copy pathutils.py
More file actions
64 lines (58 loc) · 2.03 KB
/
Copy pathutils.py
File metadata and controls
64 lines (58 loc) · 2.03 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import openeo
import shapely
from ipyleaflet import (
Map,
Marker,
TileLayer, ImageOverlay,
Polygon, Rectangle,
GeoJSON,
DrawControl,
LayersControl,
WidgetControl,
basemaps,
basemap_to_tiles,
WMSLayer,
FullScreenControl
)
class openeoMap:
def __init__(self,center,zoom):
self.map = Map(center=center, zoom=zoom, scroll_wheel_zoom=True, interpolation='nearest')
self.bbox = []
self.point_coords = []
self.figure = None
self.figure_widget = None
feature_collection = {
'type': 'FeatureCollection',
'features': []
}
draw = DrawControl(
circlemarker={}, polyline={}, polygon={},
marker= {"shapeOptions": {
"original": {},
"editing": {},
}},
rectangle = {"shapeOptions": {
"original": {},
"editing": {},
}})
self.map.add_control(draw)
def handle_draw(target, action, geo_json):
feature_collection['features'] = []
feature_collection['features'].append(geo_json)
if feature_collection['features'][0]['geometry']['type'] == 'Point':
self.point_coords = feature_collection['features'][0]['geometry']['coordinates']
else:
coords = feature_collection['features'][0]['geometry']['coordinates'][0]
polygon = shapely.geometry.Polygon(coords)
self.bbox = polygon.bounds
layers_control = LayersControl(position='topright')
self.map.add_control(layers_control)
self.map.add_control(FullScreenControl())
self.map.add_layer(basemap_to_tiles(basemaps.Esri.WorldImagery));
draw.on_draw(handle_draw)
def getBbox(self):
if(len(self.bbox) == 0):
mapBox = self.map.bounds
return [ mapBox[0][1],mapBox[0][0],mapBox[1][1],mapBox[1][0]]
else:
return self.bbox