[ 
https://issues.apache.org/jira/browse/LUCENE-7154?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15219897#comment-15219897
 ] 

Robert Muir commented on LUCENE-7154:
-------------------------------------

{quote}
Wouldn't "contains" have a different result if the sense of the polygon were 
different?
{quote}

I don't think so. Note that our "contains" and "crosses" behave like java's 
Shape contains/intersects apis: where they can conservatively return false, and 
true respectively (its safe, just means things are potentially slower/less 
efficient). So e.g. for our crosses we don't try to optimize rects fully within 
holes (someone could add that later). For the contains, see the logic below. 
The only part i added was the stuff within the "game over" block, essentially i 
did the "minimal effort needed to correctly support holes":

{code}
  /**
   * Computes whether a rectangle is within a polygon (shared boundaries not 
allowed)
   */
  public boolean contains(double minLat, double maxLat, double minLon, double 
maxLon) {
    // check if rectangle crosses poly (to handle concave/pacman polys), then 
check that all 4 corners
    // are contained
    boolean contains = crosses(minLat, maxLat, minLon, maxLon) == false &&
                       contains(minLat, minLon) &&
                       contains(minLat, maxLon) &&
                       contains(maxLat, maxLon) && 
                       contains(maxLat, minLon);
    
    if (contains) {
      // if we cross any hole, game over
      for (Polygon hole : holes) {
        if (hole.crosses(minLat, maxLat, minLon, maxLon)) {
          return false;
        }
      }
      return true;
    } else {
      return false;
    }
  }
{code}

> Add support for polygon holes to Geo3D
> --------------------------------------
>
>                 Key: LUCENE-7154
>                 URL: https://issues.apache.org/jira/browse/LUCENE-7154
>             Project: Lucene - Core
>          Issue Type: New Feature
>            Reporter: Karl Wright
>         Attachments: LUCENE-7154.diff
>
>
> Real-world polygons (e.g. from ESRI) have holes in them.  We need polygon 
> support in geo3D that works in the same way.
> The proposal would be to change the GeoConvexPolygon constructor to include a 
> number of GeoPolygon inputs, each of which would specify a hole.  Then, the 
> GeoPolygonFactory.makeGeoPolygon() method would also need to accept a similar 
> list of GeoPolygon hole descriptions.
> This change is likely to be fairly complex because of the already tricky 
> algorithm used to create convex polygons from non-convex ones, implemented in 
> GeoPolygonFactory.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to