Currently I have a problem while developing an app - I use Open Street Map and draw a Circle and pass it to a Python backend, as central point and point on the perimeter on the Circle. Next I am describing that circle with 20-sided Polygon, and return both to the front and I see, that actually is no more circle-like, but it looks like an Ellipse.
More to that - I have written an algorithm which defines if my route crosses that zone - and it works on the data from Polygon, but not the Circle from the front (look picture)
The relevant code is: Getting Radius from central Circle point and point on the perimeter:
def edit_radius(point, radius): xc, yc = point, point rad_x, rad_y = radius, radius return math.sqrt((xc - rad_x) ** 2 + (yc - rad_y) ** 2)
The similar result I can reach with
mpu.haversine_distance(point, radius)/100 - which returns Haversine distance between that points (and it differs with Euqlidean distance).
Drawing polygon with 20 sides, and radius passed from previous function:
def polygon(sides, radius=1, rotation=0, translation=None): one_segment = math.pi * 2 / sides points = [ (math.sin(one_segment * i + rotation) * radius, math.cos(one_segment * i + rotation) * radius) for i in range(sides)] if translation: points = [[sum(pair) for pair in zip(point, translation)] for point in points] return points
I can't understand what I am missing. Should I convert to another coordinates system? But as I have read OpenStretMap (and Leaflet) are using "flat" EPSG:3857 system. Can somebody explain what is going on?