Open agstephens opened 7 years ago
I had some thoughts about how to do this... ...firstly, there might be a library out there that already does it.
If not, here are some (maybe wrong) thoughts:
You would need to wrap the array (i.e. append a copy of the array to the end) to ensure that you got through all the points (regardless of where you found the highest x).
If the conditions were not satisfied we assume it is clockwise, we reverse the array and do the same tests. And hopefully it is found to be counterclockwise.
Added a function to remove any consecutive duplicates in the display coordinates. 682a1eccf6d7163968d92afd65ac3175853147cf
We have discovered an issue with the "display" polygons that are being captured in Elasticsearch by the
ceda-di
code. The issue is as follows:We capture the bounding box polygon and label it as the "search" polygon. It is 5 points as a closed rectangle. We make sure of this by finding each extreme and then packaging up a new polygon (and ensuring we close it). We also specify the "orientation" as "counterclockwise" which is in-keeping with the standard (see: https://tools.ietf.org/html/rfc7946#section-3.1.6). The relevant code is: https://github.com/cedadev/ceda-di/blob/master/python/src/ceda_di/metadata/product.py#L255
We also capture the full polygon provided in the source data and we label it as the "display" polygon. This can have any number of points and might not be a closed polygon.
We need to fix the "display" polygon so that it:
The code that generates the "display" polygon is here:
https://github.com/cedadev/ceda-di/blob/master/python/src/ceda_di/metadata/product.py#L164
We need to fix the code so that the conditions in (3) are always met.
The code will therefore need to: