Issue 17824

Clarify types of polygons accepted

17824
Reporter: scott
Assignee: fmendez
Type: Feedback
Summary: Clarify types of polygons accepted
Priority: Minor
Resolution: Fixed
Status: Closed
Created: 2015-09-17 23:37:24.531
Updated: 2016-10-05 22:39:45.314
Resolved: 2016-09-05 15:24:05.985
        
Description: The docs for the geometry parameter on the /occurrence/search route specify that POLYGON WKT type is accepted.

However, it seems that only a subset of that type are accepted. For example, this query produces an error

http://api.gbif.org/v1/occurrence/search?geometry=POLYGON((-125 38.4, -121.8 38.4, -121.8 40.9, -125 40.9, -125 38.4), (-115 22.4, -111.8 22.4, -111.8 30.9, -115 30.9, -115 22.4))

Invalid polygon POLYGON((-125 38.4, -121.8 38.4, -121.8 40.9, -125 40.9, -125 38.4), (-115 22.4, -111.8 22.4, -111.8 30.9, -115 30.9, -115 22.4))

But AFAIK that WKT is valid. But maybe I am wrong?  I know you don't accept MULTIPOLYGON (or at least you didn't in the past), but i thought this might be a way to query multiple polygons at once, rather than making multiple API calls, which I imagine would be slower client side depending on connection speed, etc. ]]>
    


Author: scott
Comment: Just noticed that USGS BISON API also only accepts single polygons in WKT `POLYGON` 
Created: 2015-09-18 00:09:22.909
Updated: 2015-09-18 00:09:22.909


Author: trobertson@gbif.org
Comment: [~fmendez@gbif.org] - can you please provide advice on this?
Created: 2016-09-01 21:55:09.759
Updated: 2016-09-01 21:55:09.759


Author: fmendez@gbif.org
Created: 2016-09-02 11:44:12.222
Updated: 2016-09-02 11:44:12.222
        
[~scott] i'll be testing how multipolygons behave in the occurrence search API, if the preliminary tests work fine I'll let you know how and where you can test a beta version of that service, thanks for your feedback

https://github.com/gbif/gbif-api/commit/bbd29fe4c6fd506c839e872e994303755d1a71c8
    


Author: fmendez@gbif.org
Created: 2016-09-02 14:26:07.442
Updated: 2016-09-02 14:26:07.442
        
[~scott] I've tested your MULTIPOLYGON example and it seems that a couple parenthesis were missing, see the example below:
http://api.gbif-uat.org/v1/occurrence/search?GEOMETRY=MULTIPOLYGON(((-125%2038.4,%20-121.8%2038.4,%20-121.8%2040.9,%20-125%2040.9,%20-125%2038.4)),((-115%2022.4,%20-111.8%2022.4,%20-111.8%2030.9,%20-115%2030.9,%20-115%2022.4)))

vs

http://api.gbif-uat.org/v1/occurrence/search?GEOMETRY=MULTIPOLYGON(((-125%2038.4,%20-121.8%2038.4,%20-121.8%2040.9,%20-125%2040.9,%20-125%2038.4),(-115%2022.4,%20-111.8%2022.4,%20-111.8%2030.9,%20-115%2030.9,%20-115%2022.4)))

i'll promote this change to production in the soon
    


Author: scott
Created: 2016-09-02 16:38:41.8
Updated: 2016-09-02 16:38:41.8
        
Thanks for this. And here's one that works

http://api.gbif-uat.org/v1/occurrence/search?GEOMETRY=MULTIPOLYGON(((30%2020,%2045%2040,%2010%2040,%2030%2020)),((15%205,%2040%2010,%2010%2020,%205%2010,%2015%205)))
    


Author: fmendez@gbif.org
Comment: [~scott] I promoted this to production now: http://api.gbif-uat.org/v1/occurrence/search?GEOMETRY=MULTIPOLYGON(((30%2020,%2045%2040,%2010%2040,%2030%2020)),((15%205,%2040%2010,%2010%2020,%205%2010,%2015%205)))
Created: 2016-09-05 15:24:02.048
Updated: 2016-09-05 15:24:02.048


Author: scott
Comment: Thanks very much [~fmendez@gbif.org]  - I'll update the Python and R clients
Created: 2016-09-07 01:52:29.103
Updated: 2016-09-07 01:52:29.103


Author: scott
Created: 2016-10-05 21:30:13.649
Updated: 2016-10-05 21:30:13.649
        
[~fmendez@gbif.org] It appears that MULTIPOLYGON is rejected again now. E.g.,

http://api.gbif-uat.org/v1/occurrence/search?GEOMETRY=MULTIPOLYGON(((30%2020,%2045%2040,%2010%2040,%2030%2020)),((15%205,%2040%2010,%2010%2020,%205%2010,%2015%205

gives

Invalid simple WKT: MULTIPOLYGON(((30 20, 45 40, 10 40, 30 20)),((15 5, 40 10, 10 20, 5 10, 15 5

Same error when using api.gbif.org base URL

Did the change get reverted?
    


Author: scott
Comment: [~fmendez@gbif.org] Nevermind, it seems the http client library i'm using was hacking up the URL for some reason. Thank, S
Created: 2016-10-05 22:39:45.314
Updated: 2016-10-05 22:39:45.314