@Test public void testNullGeometryPolygon() { Polygon p = FastPointInPolygonTest.createPolygon(); FastPolygonOperations pop = new FastPolygonOperations(p); assertNull(pop.intersection((Polygon) null)); }
public Geometry intersection(Geometry other) { if (other == null || other.isEmpty()) return other; Envelope otherEnv = other.getEnvelopeInternal(); int minBandX = Math.max(0, Math.min(numBands - 1, (int)Math.floor((otherEnv.getMinX() - env.getMinX())/envWidth * numBands))); int maxBandX = Math.max(0, Math.min(numBands - 1, (int)Math.floor((otherEnv.getMaxX() - env.getMinX())/envWidth * numBands))); int minBandY = Math.max(0, Math.min(numBands - 1, (int)Math.floor((otherEnv.getMinY() - env.getMinY())/envHeight * numBands))); int maxBandY = Math.max(0, Math.min(numBands - 1, (int)Math.floor((otherEnv.getMaxY() - env.getMinY())/envHeight * numBands))); Geometry intersector = null; for (int x = minBandX; x <= maxBandX; x++) { for (int y = minBandY; y <= maxBandY; y++) { Geometry block = blocks.get(y + x*numBands); if (intersector == null) { intersector = block; } else { intersector = intersector.union(block); } } } assert intersector != null; return other.intersection(intersector); }
FastPolygonOperations implements Serializable { public Geometry intersection(Geometry other) { if (other == null || other.isEmpty()) return other; Envelope otherEnv = other.getEnvelopeInternal(); int minBandX = Math.max(0, Math.min(numBands - 1, (int)Math.floor((otherEnv.getMinX() - env.getMinX())/envWidth * numBands))); int maxBandX = Math.max(0, Math.min(numBands - 1, (int)Math.floor((otherEnv.getMaxX() - env.getMinX())/envWidth * numBands))); int minBandY = Math.max(0, Math.min(numBands - 1, (int)Math.floor((otherEnv.getMinY() - env.getMinY())/envHeight * numBands))); int maxBandY = Math.max(0, Math.min(numBands - 1, (int)Math.floor((otherEnv.getMaxY() - env.getMinY())/envHeight * numBands))); Geometry intersector = null; for (int x = minBandX; x <= maxBandX; x++) { for (int y = minBandY; y <= maxBandY; y++) { Geometry block = blocks.get(y + x*numBands); if (intersector == null) { intersector = block; } else { intersector = intersector.union(block); } } } assert intersector != null; return other.intersection(intersector); } }
FastPolygonOperations implements Serializable { public Geometry intersection(Geometry other) { if (other == null || other.isEmpty()) return other; Envelope otherEnv = other.getEnvelopeInternal(); int minBandX = Math.max(0, Math.min(numBands - 1, (int)Math.floor((otherEnv.getMinX() - env.getMinX())/envWidth * numBands))); int maxBandX = Math.max(0, Math.min(numBands - 1, (int)Math.floor((otherEnv.getMaxX() - env.getMinX())/envWidth * numBands))); int minBandY = Math.max(0, Math.min(numBands - 1, (int)Math.floor((otherEnv.getMinY() - env.getMinY())/envHeight * numBands))); int maxBandY = Math.max(0, Math.min(numBands - 1, (int)Math.floor((otherEnv.getMaxY() - env.getMinY())/envHeight * numBands))); Geometry intersector = null; for (int x = minBandX; x <= maxBandX; x++) { for (int y = minBandY; y <= maxBandY; y++) { Geometry block = blocks.get(y + x*numBands); if (intersector == null) { intersector = block; } else { intersector = intersector.union(block); } } } assert intersector != null; return other.intersection(intersector); } <P extends Geometry & Polygonal> FastPolygonOperations(P geom); }
FastPolygonOperations implements Serializable { public Geometry intersection(Geometry other) { if (other == null || other.isEmpty()) return other; Envelope otherEnv = other.getEnvelopeInternal(); int minBandX = Math.max(0, Math.min(numBands - 1, (int)Math.floor((otherEnv.getMinX() - env.getMinX())/envWidth * numBands))); int maxBandX = Math.max(0, Math.min(numBands - 1, (int)Math.floor((otherEnv.getMaxX() - env.getMinX())/envWidth * numBands))); int minBandY = Math.max(0, Math.min(numBands - 1, (int)Math.floor((otherEnv.getMinY() - env.getMinY())/envHeight * numBands))); int maxBandY = Math.max(0, Math.min(numBands - 1, (int)Math.floor((otherEnv.getMaxY() - env.getMinY())/envHeight * numBands))); Geometry intersector = null; for (int x = minBandX; x <= maxBandX; x++) { for (int y = minBandY; y <= maxBandY; y++) { Geometry block = blocks.get(y + x*numBands); if (intersector == null) { intersector = block; } else { intersector = intersector.union(block); } } } assert intersector != null; return other.intersection(intersector); } <P extends Geometry & Polygonal> FastPolygonOperations(P geom); Geometry intersection(Geometry other); }
FastPolygonOperations implements Serializable { public Geometry intersection(Geometry other) { if (other == null || other.isEmpty()) return other; Envelope otherEnv = other.getEnvelopeInternal(); int minBandX = Math.max(0, Math.min(numBands - 1, (int)Math.floor((otherEnv.getMinX() - env.getMinX())/envWidth * numBands))); int maxBandX = Math.max(0, Math.min(numBands - 1, (int)Math.floor((otherEnv.getMaxX() - env.getMinX())/envWidth * numBands))); int minBandY = Math.max(0, Math.min(numBands - 1, (int)Math.floor((otherEnv.getMinY() - env.getMinY())/envHeight * numBands))); int maxBandY = Math.max(0, Math.min(numBands - 1, (int)Math.floor((otherEnv.getMaxY() - env.getMinY())/envHeight * numBands))); Geometry intersector = null; for (int x = minBandX; x <= maxBandX; x++) { for (int y = minBandY; y <= maxBandY; y++) { Geometry block = blocks.get(y + x*numBands); if (intersector == null) { intersector = block; } else { intersector = intersector.union(block); } } } assert intersector != null; return other.intersection(intersector); } <P extends Geometry & Polygonal> FastPolygonOperations(P geom); Geometry intersection(Geometry other);  }