@Override public boolean evaluateInternal(Geometry left, Geometry right) { switch (literals) { case BOTH: return cacheValue; case RIGHT: { return rightPreppedGeom.intersects(left); } case LEFT: { return leftPreppedGeom.intersects(right); } default: { return basicEvaluate(left, right); } } }
private boolean preppedEvaluate(PreparedGeometry prepped, Geometry other) { Envelope envLeft = prepped.getGeometry().getEnvelopeInternal(); Envelope envRight = other.getEnvelopeInternal(); if (envRight.intersects(envLeft)) { return prepped.intersects(other); } else { return false; } // Note that this is a pretty permissive logic // if the type has somehow been mis-set (can't happen externally) // then true is returned in all cases }
Envelope geometryEnvelope = geometry.getEnvelopeInternal(); if (geometryEnvelope.intersects(tileBBox.getEnvelopeInternal()) && pg.intersects(tileBBox)) // geometry partially covers the tile: draw it
protected SpatialRelation relate(Geometry oGeom) { //see http://docs.geotools.org/latest/userguide/library/jts/dim9.html#preparedgeometry if (oGeom instanceof org.locationtech.jts.geom.Point) { if (preparedGeometry != null) return preparedGeometry.disjoint(oGeom) ? SpatialRelation.DISJOINT : SpatialRelation.CONTAINS; return geom.disjoint(oGeom) ? SpatialRelation.DISJOINT : SpatialRelation.CONTAINS; } if (preparedGeometry == null) return intersectionMatrixToSpatialRelation(geom.relate(oGeom)); else if (preparedGeometry.covers(oGeom)) return SpatialRelation.CONTAINS; else if (preparedGeometry.coveredBy(oGeom)) return SpatialRelation.WITHIN; else if (preparedGeometry.intersects(oGeom)) return SpatialRelation.INTERSECTS; return SpatialRelation.DISJOINT; }
@Override public boolean compare( final Geometry dataGeometry, final PreparedGeometry constraintGeometry) { return constraintGeometry.intersects(dataGeometry); }
public static boolean intersects(Geometry g1, Geometry g2) { PreparedGeometry prepGeom = PreparedGeometryFactory.prepare(g1); return prepGeom.intersects(g2); } public static boolean contains(Geometry g1, Geometry g2)
/** * Tests if the given rectangle intersects with this ROI. * * @param rect the rectangle * @return {@code true} if there is an intersection; {@code false} otherwise */ @Override public boolean intersects(Rectangle2D rect) { setTestRect(rect.getMinX(), rect.getMinY(), rect.getWidth(), rect.getHeight()); return theGeom.intersects(testRect); }
public static boolean preparedIntersects(Geometry g1, Geometry g2) { return createPG(g1).intersects(g2); }
/** * Tests if the given rectangle intersects with this ROI. * * @param rect the rectangle * @return {@code true} if there is an intersection; {@code false} otherwise */ @Override public boolean intersects(Rectangle rect) { setTestRect(rect.x, rect.y, rect.width, rect.height); return theGeom.intersects(testRect); }
/** * Tests if the given rectangle intersects with this ROI. * * @param rect the rectangle * @return {@code true} if there is an intersection; {@code false} otherwise */ @Override public boolean intersects(Rectangle rect) { setTestRect(rect.x, rect.y, rect.width, rect.height); return theGeom.intersects(testRect); }
/** * Tests if the given rectangle intersects with this ROI. * * @param rect the rectangle * @return {@code true} if there is an intersection; {@code false} otherwise */ @Override public boolean intersects(Rectangle2D rect) { setTestRect(rect.getMinX(), rect.getMinY(), rect.getWidth(), rect.getHeight()); return theGeom.intersects(testRect); }
/** * Tests if the given rectangle intersects with this ROI. * * @param rect the rectangle * @return {@code true} if there is an intersection; {@code false} otherwise */ @Override public boolean intersects(Rectangle rect) { setTestRect(rect.x, rect.y, rect.width, rect.height); return theGeom.intersects(testRect); }
/** * Tests if the given rectangle intersects with this ROI. * * @param rect the rectangle * @return {@code true} if there is an intersection; {@code false} otherwise */ @Override public boolean intersects(Rectangle2D rect) { setTestRect(rect.getMinX(), rect.getMinY(), rect.getWidth(), rect.getHeight()); return theGeom.intersects(testRect); }
public void run() { while (true) { System.out.println(threadIndex); pg.intersects(g); } }
private void checkIntersects(PreparedGeometry pg, Geometry g2) { boolean pgResult = pg.intersects(g2); boolean expected = pg.getGeometry().intersects(g2); if (pgResult != expected) { // pg.intersects(g2); throw new IllegalStateException("PreparedGeometry.intersects result does not match expected"); } // System.out.println("Results match!"); }
public static boolean intersects(Geometry g1, Geometry g2) { PreparedGeometryFactory pgFact = new PreparedGeometryFactory(); PreparedGeometry prepGeom = pgFact.create(g1); return prepGeom.intersects(g2); } public static boolean contains(Geometry g1, Geometry g2)
public int testPrepGeomCached(Geometry g, List lines) { System.out.println("Using cached Prepared Geometry"); PreparedGeometryFactory pgFact = new PreparedGeometryFactory(); PreparedGeometry prepGeom = pgFact.create(g); int count = 0; for (Iterator i = lines.iterator(); i.hasNext(); ) { LineString line = (LineString) i.next(); if (prepGeom.intersects(line)) count++; } return count; }
public int testPrepGeomCached(int iter, Geometry g, List lines) { if (iter == 0) System.out.println("Using cached Prepared Geometry"); PreparedGeometryFactory pgFact = new PreparedGeometryFactory(); PreparedGeometry prepGeom = pgFact.create(g); int count = 0; for (Iterator i = lines.iterator(); i.hasNext(); ) { LineString line = (LineString) i.next(); if (prepGeom.intersects(line)) count++; } return count; }
public void testResultsEqual(Geometry g, LineString line) { boolean slowIntersects = g.intersects(line); PreparedGeometryFactory pgFact = new PreparedGeometryFactory(); PreparedGeometry prepGeom = pgFact.create(g); boolean fastIntersects = prepGeom.intersects(line); if (slowIntersects != fastIntersects) { System.out.println(line); System.out.println("Slow = " + slowIntersects + ", Fast = " + fastIntersects); throw new RuntimeException("Different results found for intersects() !"); } } }
public boolean checkIntersects(Geometry target, Geometry test) { boolean expectedResult = target.intersects(test); PreparedGeometryFactory pgFact = new PreparedGeometryFactory(); PreparedGeometry prepGeom = pgFact.create(target); boolean prepResult = prepGeom.intersects(test); if (prepResult != expectedResult) { return false; } return true; }