apps-android-commons icon indicating copy to clipboard operation
apps-android-commons copied to clipboard

Nearby export: Pins not all around me

Open nicolas-raoul opened this issue 1 year ago • 8 comments

Ideally pins should form a square or circle around my position, rather than using my position as a corner:

Screenshot_20240325-231850.png

nicolas-raoul avatar Mar 25 '24 14:03 nicolas-raoul

@nicolas-raoul, What are your thoughts on circle around my location and Can you please suggest some radius (in kilometers) ?

kanahia1 avatar Mar 25 '24 14:03 kanahia1

Rectangle is probably easier to implement for now. How about 10 kilometers North/South/East/West? A few years ago I originally said 100 km but there are many more points now so it would take too long.

nicolas-raoul avatar Mar 25 '24 14:03 nicolas-raoul

Thanks for providing information. I will work on it!

kanahia1 avatar Mar 25 '24 14:03 kanahia1

Hey @nicolas-raoul, I have added to code to give coordinates for 10Km North-East and South-West. I have used 0.008 as it is approximately 1Km. Reference

    public static LatLng calculateNorthEast(double latitude, double longitude, double distance) {
        double lat1 = Math.toRadians(latitude);
        double deltaLat = distance * 0.008;
        double deltaLon = distance / Math.cos(lat1)*0.008;
        double lat2 = latitude + deltaLat;
        double lon2 = longitude + deltaLon;

        return new LatLng(lat2, lon2, 0);
    }

    public static LatLng calculateSouthWest(double latitude, double longitude, double distance) {
        double lat1 = Math.toRadians(latitude);
        double deltaLat = distance * 0.008;
        double deltaLon = distance / Math.cos(lat1)*0.008;
        double lat2 = latitude - deltaLat;
        double lon2 = longitude - deltaLon;

        return new LatLng(lat2, lon2, 0);
    }

WhatsApp Image 2024-03-26 at 14 18 04_8a25da51

Can you please have a look at PR https://github.com/commons-app/apps-android-commons/pull/5658, Since I am getting same problem.

kanahia1 avatar Mar 26 '24 14:03 kanahia1

Can you run in debug mode, note down the result of each function, and draw these two points on the map above?

nicolas-raoul avatar Mar 26 '24 14:03 nicolas-raoul

I have tested and these are the points (25.523992142085177,85.04935220271054) and (25.683992142085174,85.22677465886173)

I have plotted them on the map and are marked with (heart). WhatsApp Image 2024-03-26 at 20 00 21_a42f38e4

kanahia1 avatar Mar 26 '24 14:03 kanahia1

The points seem correctly positioned.

nicolas-raoul avatar Mar 27 '24 00:03 nicolas-raoul

I am looking into it and will share an update in 2 days (currently I am out of station)

kanahia1 avatar Mar 27 '24 01:03 kanahia1