Skip to content

incorrect measurement due to swap of lat/long #105

@our30K

Description

@our30K

Hi, thanks for all the work, I've been using this for a while, and recently I discover an issue about the points measurement

in the measure function, the comments shows that points should be defined as (lat, long)
but in the calculation below, it is expecting (long, lat). which leads distance calculation error.
this is an easy fix, but I am not sure, if this also leads to calculation error in point to line, point to polygon etc.

dlat = radians((coordinates2[1] - coordinates1[1]))
dlon = radians((coordinates2[0] - coordinates1[0]))

"
:param point1: first point; tuple of (latitude, longitude) in decimal degrees.
:param point2: second point; tuple of (latitude, longitude) in decimal degrees.
:param units: A string containing unit, E.g. kilometers = 'km', miles = 'mi',
meters = 'm', feet = 'ft', inches = 'in'.
:return: The distance between the two points in the requested unit, as a float.
Example:
>>> from turfpy import measurement
>>> from geojson import Point, Feature
>>> start = Feature(geometry=Point((-75.343, 39.984)))
>>> end = Feature(geometry=Point((-75.534, 39.123)))
>>> measurement.distance(start,end)
"""
coordinates1 = get_coord(point1)
coordinates2 = get_coord(point2)

dlat = radians((coordinates2[1] - coordinates1[1]))

dlon = radians((coordinates2[0] - coordinates1[0]))

lat1 = radians(coordinates1[1])

lat2 = radians(coordinates2[1])"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions