How to query a JTS QuadTree using a query envelope with holes

المشرف العام

Administrator
طاقم الإدارة
Hi I have a Java Topology Suite QuadTree containing Points, now I'm trying to query the QuadTree with a polygon that contains a hole. Here's how I create the polygon.

//Method will create a searchable Polygon in the shape of a donut.public Polygon searchAreaPoly(double outterBoundry, double innerBoundry) { Coordinate center = MyIndex.getWGSCoord(longitude, latitude); GeometricShapeFactory gsf = new GeometricShapeFactory(); gsf.setCentre(center); gsf.setNumPoints(20); LinearRing[] holes = null; GeometryFactory fact = new GeometryFactory(); //create the hole in the shape if innerBoundry is > 0 if (innerBoundry > 0) { gsf.setSize(innerBoundry); Polygon innerPoly = gsf.createCircle(); Coordinate[] innerCoords = innerPoly.getCoordinates(); LinearRing hole = fact.createLinearRing(innerCoords); holes = new LinearRing[]{hole}; } //create the outter boundry gsf.setSize(outterBoundry); Polygon outterPoly = gsf.createCircle(); Coordinate[] outterCoords = outterPoly.getCoordinates(); LinearRing shell = fact.createLinearRing(outterCoords); Polygon searchPoly = fact.createPolygon(shell, holes); return searchPoly;}Here's how I am querying the QuadTree;

//create polygon to search for points the intersect with itPolygon polygon = data_bounds.searchAreaPoly(shell, hole);List items = quadTree.query(polygon.getEnvelopeInternal());However the QuadTree returns a list that doesn't remove the Points the fall within the hole, no matter how big the hole. Does anyone know how to do this, or even if it is possible? Thanks for your time.



أكثر...
 
أعلى