pastvu icon indicating copy to clipboard operation
pastvu copied to clipboard

api2 photo.getByBounds doesn't work correctly

Open 773517913 opened this issue 3 years ago • 5 comments

Hello,

When I try the example polygon request from the wiki, it works. But when I try it with my desired coordinates, I get no results.

Here are my polygon coordinates and my request: [[40.9731974,28.8936996],[41.0452914,28.8936996],[41.0452914,28.9948573],[40.9731974,28.9948573],[40.9731974,28.8936996]]

I can draw this with leaflet:

image

My request is: https://pastvu.com/api2?method=photo.getByBounds&params={%22z%22:11,%22geometry%22:{%22type%22:%22Polygon%22,%22coordinates%22:[[[40.9731974,28.8936996],[41.0452914,28.8936996],[41.0452914,28.9948573],[40.9731974,28.9948573],[40.9731974,28.8936996]]]}}

It's center of Istanbul and there are normally lot's of photos. But response JSON contains no photos:

{"result":{"z":11,"photos":[],"clusters":[]},"rid":"nxmguvjscj"}

I tried lots of different combinations like:

  • Switching [lat,lng] --> [lng,lat]
  • Changing parantesis counts etc.

Some of them yields some results but weirdly they don't belong to the coordinates I request for.

Could you please check this out? Thanks!

773517913 avatar Aug 25 '22 07:08 773517913

Correct request string for your case:

https://pastvu.com/api2?method=photo.getByBounds&params=%7B%22z%22:11,%22geometry%22:%7B%22type%22:%22Polygon%22,%22coordinates%22:[[[28.8936996,40.9731974],[28.8936996,41.0452914],[28.9948573,41.0452914],[28.9948573,40.9731974],[28.8936996,40.9731974]]]%7D%7D

Also worked:

https://pastvu.com/api2?method=photo.getByBounds&params={
"z":11,"geometry":{"type":"Polygon","coordinates":[[[28.8936996,40.9731974],[28.8936996,41.0452914],[28.9948573,41.0452914],[28.9948573,40.9731974],[28.8936996,40.9731974]]]}}

Paul K. (_p_k)

чт, 25 авг. 2022 г. в 10:53, 773517913 @.***>:

Hello,

When I try the example polygon request from the wiki, it works. But when I try it with my desired coordinates, I get no results.

Here are my polygon coordinates and my request:

[[40.9731974,28.8936996],[41.0452914,28.8936996],[41.0452914,28.9948573],[40.9731974,28.9948573],[40.9731974,28.8936996]]

I can draw this with leaflet:

[image: image] https://user-images.githubusercontent.com/30352099/186606761-a3b416af-3cfe-49a8-b6c1-efb3c4845fea.png

My request is:

https://pastvu.com/api2?method=photo.getByBounds&params={%22z%22:11,%22geometry%22:{%22type%22:%22Polygon%22,%22coordinates%22:[[[40.9731974,28.8936996],[41.0452914,28.8936996],[41.0452914,28.9948573],[40.9731974,28.9948573],[40.9731974,28.8936996]]]}} https://pastvu.com/api2?method=photo.getByBounds&params=%7B%22z%22:11,%22geometry%22:%7B%22type%22:%22Polygon%22,%22coordinates%22:[[[40.9731974,28.8936996],[41.0452914,28.8936996],[41.0452914,28.9948573],[40.9731974,28.9948573],[40.9731974,28.8936996]]]%7D%7D

It's center of Istanbul and there are normally lot's of photos. But response JSON contains no photos:

{"result":{"z":11,"photos":[],"clusters":[]},"rid":"nxmguvjscj"}

I tried lots of different combinations like:

  • Switching [lat,lng] --> [lng,lat]
  • Changing parantesis counts etc.

Some of them yields some results but weirdly they don't belong to the coordinates I request for.

Could you please check this out? Thanks!

— Reply to this email directly, view it on GitHub https://github.com/PastVu/pastvu/issues/494, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOLAIHG5IX2HPQJPLXLP7T3V24RAZANCNFSM57SBNYRQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

paul-k-pastvu avatar Aug 25 '22 10:08 paul-k-pastvu

Correct request string for your case

Hmm, does not support markdown when editing email response for some reason. Anyway, the correct order is lng, lat as @paul-k-pastvu suggested above.

kabalin avatar Aug 25 '22 11:08 kabalin

Hello,

Did you check out the result of the request you send in the reply? They don't belong to the location we made the request for. We ask for Istanbul (lat: 40.9731974 lng: 28.8936996) but the results are somewhere around US:

"geo":[35.686563,-121.17068]

773517913 avatar Aug 26 '22 08:08 773517913

Hi @773517913, sorry, I did not pay the attention to result. The order of coordinates in polygon is important, it needs to be counter-clockwise to query inclusive part or clockwise do query exclusive area. This is because we enforce "strict winding" in geospacial queres to avoid ambiguity and compliance with RFC7946. You can read more about it at https://www.mongodb.com/blog/post/mongodb-30-features-big-polygon (the statement in the post that GeoJSON does not address winding is obsolete, see RFC link above).

Back you your query, it needs to be as follows:

https://pastvu.com/api2?method=photo.getByBounds&params={%22z%22:11,%22geometry%22:{%22type%22:%22Polygon%22,%22coordinates%22:[[[28.8936996,40.9731974],[28.9948573,40.9731974],[28.9948573,41.0452914],[28.8936996,41.0452914],[28.8936996,40.9731974]]]}}

Notice at zoom level 11 you get clusters only, to get clusters and photos, you need increase zoom level (try 16 for example). And if you are interested in photos only in the specified geometry use localWork=1 (we use it when map zoom is 17 and above).

kabalin avatar Aug 26 '22 13:08 kabalin

Hi, thanks for the help. Now it works! I think this lng-lat notation and inclusive/exclusive selection stuff worth noting down to the wiki.

By the way, "year2" filtering seems not respected:

https://pastvu.com/api2?method=photo.getByBounds&params={%22z%22:17,%22localWork%22:1,%22year%22:1826,%22year2%22:1920,%22geometry%22:{%22type%22:%22Polygon%22,%22coordinates%22:[[[28.8936996,40.9731974],[28.9948573,40.9731974],[28.9948573,41.0452914],[28.8936996,41.0452914],[28.8936996,40.9731974]]]}}

image

Maybe because I'm using localWork flag? Anyways, this is easy to solve using local filtering.

773517913 avatar Sep 01 '22 05:09 773517913

Hi, thanks for the help. Now it works! I think this lng-lat notation and inclusive/exclusive selection stuff worth noting down to the wiki.

Great, added to wiki, thanks for suggestion.

By the way, "year2" filtering seems not respected:

It is respected in way that the lower year ("from") of photo is always within specified year conditions that you pass in the query. See issue #217 for explanation.

kabalin avatar Sep 13 '22 22:09 kabalin