draw lines between location and base
This commit is contained in:
parent
8aa59ef749
commit
efce68ba1f
|
|
@ -24,6 +24,7 @@ To use Mappersons, follow these steps:
|
|||
This YAML file has a structure that includes the following fields:
|
||||
- `name`: The name of the person or entity.
|
||||
- `image`: The image associated with the person or entity.
|
||||
- `base`: The location where person is based. Identically to locations.yml
|
||||
- `weeks`: A list of weeks, each containing:
|
||||
- `location`: The location where tasks were performed. Identically to locations.yml
|
||||
- `tasks`: A list of tasks performed during that week at that location.
|
||||
|
|
@ -34,6 +35,7 @@ This YAML file has a structure that includes the following fields:
|
|||
---
|
||||
- name: Lisa Lurch
|
||||
image: lurch_l.jpg
|
||||
base: Hamburg
|
||||
weeks:
|
||||
21/2023:
|
||||
- location: Hamburg
|
||||
|
|
@ -45,6 +47,7 @@ This YAML file has a structure that includes the following fields:
|
|||
- Maintenance NSP
|
||||
- name: Walter Wiesel
|
||||
image: wiesel_w.jpg
|
||||
base: Hamburg
|
||||
weeks:
|
||||
21/2023:
|
||||
- location: Teisnach
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@
|
|||
|
||||
function loadWeek(locations) {
|
||||
locations.map(location => {
|
||||
return L.marker([location.lat, location.lng], {
|
||||
L.marker([location.lat, location.lng], {
|
||||
icon: L.icon({
|
||||
iconUrl: location.icon,
|
||||
iconAnchor: location.anchor
|
||||
|
|
@ -60,8 +60,12 @@
|
|||
})
|
||||
.bindPopup(location.popup)
|
||||
.addTo(markerLayer);
|
||||
location.bases.map(base => {
|
||||
return L.polyline([[location.lat, location.lng],[base.lat,base.lng]],{color: 'red', weight: 1}).addTo(markerLayer);
|
||||
});
|
||||
return;
|
||||
});
|
||||
map.addLayer(markerLayer)
|
||||
map.addLayer(markerLayer);
|
||||
}
|
||||
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -59,8 +59,7 @@ def create_circle(image_paths):
|
|||
# Cut out a circle from each image
|
||||
circular_images = [circular_mask(img) for img in shrunk_images]
|
||||
if len(circular_images) == 1:
|
||||
circular_images[0].save(output_path)
|
||||
return
|
||||
return circular_images[0]
|
||||
|
||||
if len(circular_images) < 7:
|
||||
output_img = arrange_images_in_circle(circular_images)
|
||||
|
|
@ -85,6 +84,7 @@ def generateWeek(week, persons, locations, output_path=Path('.')):
|
|||
if week in person['weeks'].keys():
|
||||
cur_name = person['name']
|
||||
cur_image = person['image']
|
||||
cur_base = person['base']
|
||||
for task in person['weeks'][week]:
|
||||
cur_loc = task['location']
|
||||
cur_tasks = task['tasks']
|
||||
|
|
@ -93,6 +93,7 @@ def generateWeek(week, persons, locations, output_path=Path('.')):
|
|||
if cur_name not in loc[cur_loc].keys():
|
||||
loc[cur_loc][cur_name] = {
|
||||
'image': cur_image,
|
||||
'base': cur_base,
|
||||
'tasks': []
|
||||
}
|
||||
loc[cur_loc][cur_name]['tasks'] += cur_tasks
|
||||
|
|
@ -100,14 +101,22 @@ def generateWeek(week, persons, locations, output_path=Path('.')):
|
|||
w,y = week.split('/')
|
||||
json_file = "cw_%s_%s.json" % (w,y)
|
||||
for cur_loc, cur_persons in loc.items():
|
||||
png_file = "%s_%s_%s.png" % (cur_loc.lower(),w,y)
|
||||
png_file = "%s_%s_%s.png" % (cur_loc.lower().replace(' ','_'),w,y)
|
||||
image_paths = [("persons/%s" % x['image']) for n,x in cur_persons.items()]
|
||||
img = create_circle(image_paths)
|
||||
img.save(output_path / Path(png_file))
|
||||
bases = []
|
||||
popup = "<h2>%s</h2>" % cur_loc
|
||||
for cur_per, cur_info in cur_persons.items():
|
||||
popup += "<h3>%s</h3>" % cur_per
|
||||
popup += "</br>".join(cur_info['tasks'])
|
||||
if cur_info['base'] != cur_loc:
|
||||
l = [x for x in locations if x['name'] == cur_info['base']][0]
|
||||
bases.append({
|
||||
"city": cur_info['base'],
|
||||
"lat": l['lat'],
|
||||
"lng": l['lng'],
|
||||
})
|
||||
l = [x for x in locations if x['name'] == cur_loc][0]
|
||||
week_json.append({
|
||||
"city": cur_loc,
|
||||
|
|
@ -115,7 +124,8 @@ def generateWeek(week, persons, locations, output_path=Path('.')):
|
|||
"lng": l['lng'],
|
||||
"icon": png_file,
|
||||
"anchor": [x//2 for x in img.size],
|
||||
"popup": popup
|
||||
"popup": popup,
|
||||
"bases": bases
|
||||
})
|
||||
with open(output_path / Path(json_file),"w") as j:
|
||||
json.dump(week_json, j)
|
||||
|
|
|
|||
BIN
screenshot.png
BIN
screenshot.png
Binary file not shown.
|
Before Width: | Height: | Size: 421 KiB After Width: | Height: | Size: 511 KiB |
Loading…
Reference in a new issue