Currently I have a problem while developing an app - I use OpenStreetMap and draw a Circle and pass it to a Python back-end, 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.
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 Euclidean 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 coordinate system? But as I have read OpenStreetMap (and Leaflet) are using "flat" EPSG:3857 system.
Can somebody explain what is going on?