2022-05-26 01:30:51 -04:00
|
|
|
import staticmaps
|
|
|
|
from iplocate import selfpath
|
|
|
|
|
2023-12-26 02:11:15 -03:00
|
|
|
# context.set_tile_provider(staticmaps.tile_provider_ArcGISWorldImagery)
|
|
|
|
# context.set_tile_provider(staticmaps.tile_provider_CartoDarkNoLabels)
|
2022-05-26 01:30:51 -04:00
|
|
|
cntxt200 = staticmaps.Context()
|
|
|
|
cntxt200.set_tile_provider(staticmaps.tile_provider_OSM)
|
|
|
|
cntxt300 = staticmaps.Context()
|
|
|
|
cntxt300.set_tile_provider(staticmaps.tile_provider_OSM)
|
|
|
|
cntxtAll = staticmaps.Context()
|
|
|
|
cntxtAll.set_tile_provider(staticmaps.tile_provider_OSM)
|
|
|
|
|
2023-12-26 02:11:15 -03:00
|
|
|
|
2022-05-26 01:30:51 -04:00
|
|
|
def map200(geolocs):
|
|
|
|
for loc in geolocs:
|
|
|
|
lat = float(loc[0].split(',')[0])
|
|
|
|
lon = float(loc[0].split(',')[1])
|
2024-01-21 01:26:36 -03:00
|
|
|
marca200 = staticmaps.create_latlng(lat, lon)
|
2024-03-05 00:53:17 -03:00
|
|
|
cntxt200.add_object(
|
|
|
|
staticmaps.Marker(
|
|
|
|
marca200,
|
|
|
|
color=staticmaps.parse_color('#00ff29'),
|
|
|
|
size=7
|
|
|
|
)
|
|
|
|
)
|
2022-05-26 01:30:51 -04:00
|
|
|
|
|
|
|
svg_image = cntxt200.render_svg(1920, 1080)
|
2023-12-26 02:11:15 -03:00
|
|
|
with open(f"{selfpath}/maps/map_200.svg", "w", encoding="utf-8") as f:
|
2022-05-26 01:30:51 -04:00
|
|
|
svg_image.write(f, pretty=True)
|
2023-12-26 02:11:15 -03:00
|
|
|
|
2022-05-26 01:30:51 -04:00
|
|
|
image = cntxt200.render_cairo(1920, 1080)
|
|
|
|
image.write_to_png(f"{selfpath}/maps/map_200.png")
|
|
|
|
|
|
|
|
|
|
|
|
def map300(geolocs):
|
|
|
|
for loc in geolocs:
|
|
|
|
lat = float(loc[0].split(',')[0])
|
|
|
|
lon = float(loc[0].split(',')[1])
|
2024-01-21 01:26:36 -03:00
|
|
|
marca300 = staticmaps.create_latlng(lat, lon)
|
|
|
|
cntxt300.add_object(staticmaps.Marker(
|
|
|
|
marca300, color=staticmaps.parse_color('#b20101'), size=5))
|
2022-05-26 01:30:51 -04:00
|
|
|
|
|
|
|
svg_image = cntxt300.render_svg(1920, 1080)
|
2023-12-26 02:11:15 -03:00
|
|
|
with open(f"{selfpath}/maps/map_300.svg", "w", encoding="utf-8") as f:
|
2022-05-26 01:30:51 -04:00
|
|
|
svg_image.write(f, pretty=True)
|
2023-12-26 02:11:15 -03:00
|
|
|
|
2022-05-26 01:30:51 -04:00
|
|
|
image = cntxt300.render_cairo(1920, 1080)
|
|
|
|
image.write_to_png(f"{selfpath}/maps/map_300.png")
|
|
|
|
|
|
|
|
|
|
|
|
def maps_gen(locs_200, locs_300):
|
2023-06-06 04:48:14 -04:00
|
|
|
maps_thumbs(locs_200, locs_300)
|
2022-05-26 01:30:51 -04:00
|
|
|
map200(locs_200)
|
|
|
|
map300(locs_300)
|
|
|
|
for loc in locs_300:
|
|
|
|
lat = float(loc[0].split(',')[0])
|
|
|
|
lon = float(loc[0].split(',')[1])
|
2023-12-26 02:11:15 -03:00
|
|
|
marca3 = staticmaps.create_latlng(lat, lon)
|
2024-03-05 00:53:17 -03:00
|
|
|
cntxtAll.add_object(
|
|
|
|
staticmaps.Marker(
|
|
|
|
marca3,
|
|
|
|
color=staticmaps.parse_color('#b20101'),
|
|
|
|
size=5
|
|
|
|
)
|
|
|
|
)
|
2023-12-26 02:11:15 -03:00
|
|
|
|
2022-05-26 01:30:51 -04:00
|
|
|
for loc in locs_200:
|
|
|
|
lat = float(loc[0].split(',')[0])
|
|
|
|
lon = float(loc[0].split(',')[1])
|
2024-01-21 01:26:36 -03:00
|
|
|
marca3 = staticmaps.create_latlng(lat, lon)
|
2024-03-05 00:53:17 -03:00
|
|
|
cntxtAll.add_object(
|
|
|
|
staticmaps.Marker(
|
|
|
|
marca3,
|
|
|
|
color=staticmaps.parse_color('#00ff29'),
|
|
|
|
size=6
|
|
|
|
)
|
|
|
|
)
|
2022-05-26 01:30:51 -04:00
|
|
|
|
|
|
|
svg_image = cntxtAll.render_svg(1920, 1080)
|
2023-12-26 02:11:15 -03:00
|
|
|
with open(f"{selfpath}/maps/map_all.svg", "w", encoding="utf-8") as f:
|
2022-05-26 01:30:51 -04:00
|
|
|
svg_image.write(f, pretty=True)
|
2023-12-26 02:11:15 -03:00
|
|
|
|
2022-05-26 01:30:51 -04:00
|
|
|
image = cntxtAll.render_cairo(1920, 1080)
|
|
|
|
image.write_to_png(f"{selfpath}/maps/map_all.png")
|
|
|
|
maps_thumbs(locs_200, locs_300)
|
|
|
|
|
|
|
|
|
|
|
|
def maps_thumbs(locs_200, locs_300):
|
|
|
|
cntxtdemo = staticmaps.Context()
|
|
|
|
cntxtdemo.set_tile_provider(staticmaps.tile_provider_OSM)
|
|
|
|
|
|
|
|
for loc in locs_300:
|
|
|
|
lat = float(loc[0].split(',')[0])
|
|
|
|
lon = float(loc[0].split(',')[1])
|
2023-12-26 02:11:15 -03:00
|
|
|
demo300 = staticmaps.create_latlng(lat, lon)
|
2024-03-05 00:53:17 -03:00
|
|
|
cntxtdemo.add_object(
|
|
|
|
staticmaps.Marker(
|
|
|
|
demo300,
|
|
|
|
color=staticmaps.parse_color('#b20101'),
|
|
|
|
size=4
|
|
|
|
)
|
|
|
|
)
|
2023-06-06 04:48:14 -04:00
|
|
|
|
2022-05-26 01:30:51 -04:00
|
|
|
for loc in locs_200:
|
|
|
|
lat = float(loc[0].split(',')[0])
|
|
|
|
lon = float(loc[0].split(',')[1])
|
2024-01-21 01:26:36 -03:00
|
|
|
demo200 = staticmaps.create_latlng(lat, lon)
|
2024-03-05 00:53:17 -03:00
|
|
|
cntxtdemo.add_object(
|
|
|
|
staticmaps.Marker(
|
|
|
|
demo200,
|
|
|
|
color=staticmaps.parse_color('#00ff29'),
|
|
|
|
size=5
|
|
|
|
)
|
|
|
|
)
|
2022-05-26 01:30:51 -04:00
|
|
|
|
|
|
|
svg_thumb = cntxtdemo.render_svg(1024, 768)
|
2023-12-26 02:11:15 -03:00
|
|
|
with open(f"{selfpath}/maps/map_thumb.svg", "w", encoding="utf-8") as f:
|
2022-05-26 01:30:51 -04:00
|
|
|
svg_thumb.write(f, pretty=True)
|
2023-12-26 02:11:15 -03:00
|
|
|
|
2022-05-26 01:30:51 -04:00
|
|
|
image = cntxtdemo.render_cairo(1024, 768)
|
|
|
|
image.write_to_png(f"{selfpath}/maps/map_thumb.png")
|