n76 / DejaVu

Yet another network location backend for the UnifiedNLP/microG project
GNU General Public License v3.0
100 stars 18 forks source link

Bouding box uses wrong conversion between degrees and meters #43

Open Helium314 opened 2 years ago

Helium314 commented 2 years ago

in https://github.com/n76/DejaVu/blob/e54aae2d9f3d4619065a258b431ace1911d1e931/app/src/main/java/org/fitchfamily/android/dejavu/BoundingBox.java#L91-L92 east-west size of the bounding box is set by converting meters to degrees and multiplying with cosLat. This results in narrower bouding boxes (in degrees) for high latitude. But actually the bouding boxes with the same e-w width in metes should get wider if we go towards the poles.

Proposed solution: change to (radius_ew * BackendService.METER_TO_DEG) / cosLat; and change https://github.com/n76/DejaVu/blob/e54aae2d9f3d4619065a258b431ace1911d1e931/app/src/main/java/org/fitchfamily/android/dejavu/BoundingBox.java#L134 to ((east - center_lon) * BackendService.DEG_TO_METER) * cosLat