from math import radians, sin, cos, asin, sqrt, atan2, degrees, pi, pow
def calculate_distance(pointA, pointB):
- `pointA: The tuple representing the latitude/longitude for the
first point. Latitude and longitude must be in decimal degrees
- `pointB: The tuple representing the latitude/longitude for the
second point. Latitude and longitude must be in decimal degrees
The distance in km
# convert decimal degrees to radians
lat1 = radians(pointA)
lat2 = radians(pointB)
lon1 = radians(pointA)
lon2 = radians(pointB)
# haversine formula
dlon = lon2 - lon1
dlat = lat2 - lat1
a = sin(dlat/2)**2 + cos(lat1) * cos(lat2) * sin(dlon/2)**2
c = 2 * asin(sqrt(a))
r = 6371 # Radius of earth in kilometers. Use 3956 for miles
dist = c * r
lat_cen = 48.8582 # Tour Eiffel
lon_cen = 2.2945
w_m = 1000
h_m = 1000
img = location.render_map_snapshot(lat_cen, lon_cen, width=w_m, height=h_m, map_type='standard', show_poi=True, img_width=512, img_height=512, img_scale=0)
lat_pin = 48.8560793 # Bassins du Champ de Mars
lon_pin = 2.2979048
x = calculate_distance((lat_cen,lon_cen),(lat_cen,lon_pin))
y = calculate_distance((lat_cen,lon_cen),(lat_pin,lon_cen))
x = img.size.w/2 + x*img.size.w/(w_m/1000)
y = img.size.h/2 + y*img.size.h/(h_m/1000)
with ui.ImageContext(img.size.w, img.size.h) as ctx:
d = 8
path = ui.Path.oval(x-d,y-d,2*d,2*d)
result = ctx.get_image()
@dlow, I would recommend using boto3 as a library instead if fighting with awscli, as command-line usage of about anything is not one of Pythonista’s strengths – not even a feature of the core product, really.
(By library usage I mean creating small scripts for what you want to accomplish, by importing boto3 client classes and working with them.)
I'm not sure if I understand the problem correctly, and I think a solution has already have been suggested.
However, I would recommend using scene.run() for presenting, and then adding UI elements e.g. in setup(), like this:
from scene import *
A = Action
class MyScene (Scene):
button = ui.Button(title='Tap me')
# You may want to do layout here...
if __name__ == '__main__':
(Modified just slightly from the standard Game/Animation template)
Thanks, and I should have picked up on that even with my limited experience in Python, since all I've been working in is 3x Python.
This DID cause the code to print the set after "All scanned codes:' , but then as usual popped another 'No method found for stringValue' error with it. That likely is an issue nested in P2x v P3x code as this was.
For what I want to use this code for, it really doesn't matter at all, because what i want to do is build a function and nest it in the seeding of the found_codes to send off the data to a database, so this was more a frustration/curiosity that I really wanted to see resolved for my own benefit more than the project I'm working on.