Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save RodrigoCMoraes/baa658491ec10f2d8ded6b7e0b7e1476 to your computer and use it in GitHub Desktop.
Save RodrigoCMoraes/baa658491ec10f2d8ded6b7e0b7e1476 to your computer and use it in GitHub Desktop.
useful snippets to data related to maps visualization
def format_points_list_to_visualization(points, to_print=True):
"""
Format a list of Points of Django to able visualization on:
https://mobisoftinfotech.com/tools/plot-multiple-points-on-map/
Usage:
from django.contrib.gis.geos import Point
sample_lat_lng = [
(19.0760,72.8777),
(18.5204,73.8567),
(40.7128,-74.0060),
(-33.9249,18.4241),
(-22.9068,-43.1729),
]
sample_points = [Point(x=lng, y=lat) for (lat, lng) in sample_lat_lng]
format_points_list_to_visualization(sample_points)
Params:
to_print (bool) : print formatted string on terminal
Returns:
formatted_string (str) : points formatted as string
_________Just copy and paste ;) - START_________
def format_points_list_to_visualization(points, to_print=True):
formatted_string = ""
for pos in points:
lng, lat = pos.x, pos.y
formatted_string += f'{lat},{lng},blue,marker\n'
if to_print:
print("https://mobisoftinfotech.com/tools/plot-multiple-points-on-map/")
print(formatted_string)
return formatted_string
_________Just copy and paste ;) - END_________
"""
formatted_string = ""
for pos in points:
lng, lat = pos.x, pos.y
formatted_string += f'{lat},{lng},blue,marker\n'
if to_print:
print("https://mobisoftinfotech.com/tools/plot-multiple-points-on-map/")
print(formatted_string)
return formatted_string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment