A
A
Alexey Gus2021-12-09 17:10:41
PHP
Alexey Gus, 2021-12-09 17:10:41

How to get geo-points from the visible area on the map when changing the map angle?

ES works on the back, from which I get points to display on the Yandex map.
When the map moves, I get the Map Visibility in the form:

topLeftLat, topLeftLng, bottomRightLat , bottomRightLng

and at zero azimuth, such a query in ES works fine:
[
                    "exists" => [
                        "field" => "location"
                    ]
                ],
                [
                    "geo_bounding_box" => [
                        "location" => [
                            "top_left" => $topLeftLat.','.$topLeftLng,
                            "bottom_right" => $bottomRightLat.','.$bottomRightLng
                        ]
                    ]
                ]


but when you change the angle of the map (view azimuth), it naturally ceases to produce points (because the points of the top and bottom are no longer there relative to the north).
I did not find in the docks how to get around this, maybe someone knows?
Or maybe how can I move the points that I pass to ES to the right place according to the azimuth?
You can in any language)
Thank you all in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Gus, 2021-12-10
@Holyboom

Long story short, how did I resolve this issue?
because I do not need super accuracy, I used the following formula:

//dist расстояние , в моем случает от центра карты до лев верх угла карты в метрах.
// те это то расстояние от центра на котором мы поставим наши точки 
// a  = угол на который наклонить точки относительно нулевого азимута.
// lat и  long координаты точки в центре экрана 
var p180= 180/pi;
      var dx =  p180 * ((cos(a / 180 * pi) * dist) / 6378137) ;
      var dy =  p180 * ((sin(a / 180 * pi) * dist) / 6378137) ;
      var toplat = latitude + dy;
      var toplng = longitude + dx / cos(latitude);
      var bottomlat = latitude - dy;
      var bottomlng = longitude - dx / cos(latitude);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question