@Override public boolean evaluateInternal(Geometry left, Geometry right) { switch (literals) { case BOTH: return cacheValue; case RIGHT: { // since it is left contains right there is no // benefit of having a prepared geometry for the right side return basicEvaluate(left, right); } case LEFT: { return leftPreppedGeom.contains(right); } default: { return basicEvaluate(left, right); } } }
@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); } } }
< painter.getLabel().getGoodnessOfFit()) { if (textStyle.flipRotation(pg.getGeometry())) { tempTransform.setTransform(original); setupPointTransform(tempTransform, centroid, textStyle, painter); || goodnessOfFit(painter, tempTransform, pg) < painter.getLabel().getGoodnessOfFit()) { textStyle.flipRotation(pg.getGeometry()); return false;
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; }
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 }
@Override public boolean evaluateInternal(Geometry left, Geometry right) { switch (literals) { case BOTH: return cacheValue; case RIGHT: { // if the right contains left then left is within right return rightPreppedGeom.contains(left); } case LEFT: { // since within does not have an optimization with prepared geometries // there is nothing to be gained in this case so use the normal check return basicEvaluate(leftPreppedGeom.getGeometry(), right); } default: { return basicEvaluate(left, right); } } }
/** * Gets the data for the requested tile. If the tile is either completely within or outside of the reference {@code PreparedGeometry} a cached * constant {@code Raster} with 1 or 0 values is returned. Otherwise tile pixels are checked for inclusion and set individually. * * @param minX origin X ordinate * @param minY origin Y ordinate * * @return the requested tile */ protected Raster getTileRaster(int minX, int minY) { // check relationship between geometry and the tile we're computing Polygon testRect = getTestRect(minX, minY); try { // RasterOp need to be thread safe synchronized (geom) { if (geom.contains(testRect)) { return getSolidTile(); } else if (geom.disjoint(testRect)) { return getBlankTile(); } } } catch (TopologyException tpe) { // In case a Topology Exception have been raised, // use the standard rasterization instead of leveraging // on the shared tiles } return drawGeometry(minX, minY); }
Envelope geometryEnvelope = geometry.getEnvelopeInternal(); if (geometryEnvelope.intersects(tileBBox.getEnvelopeInternal()) && pg.intersects(tileBBox)) // geometry partially covers the tile: draw it if (pg.contains(tileBBox)) // geometry fully covers the tile?
private void checkCovers(PreparedGeometry pg, Geometry g2) { boolean pgResult = pg.covers(g2); boolean expected = pg.getGeometry().covers(g2); if (pgResult != expected) throw new IllegalStateException("PreparedGeometry.covers result does not match expected"); // System.out.println("Results match!"); }
private void checkContainsProperly(PreparedGeometry pg, Geometry g2) { boolean pgResult = pg.containsProperly(g2); boolean expected = containsProperly(pg.getGeometry(), g2); if (pgResult != expected) throw new IllegalStateException("PreparedGeometry.containsProperly result does not match expected"); // System.out.println("Results match!"); }
public static boolean covers(Geometry g1, Geometry g2) { PreparedGeometry prepGeom = PreparedGeometryFactory.prepare(g1); return prepGeom.covers(g2); } }
public static boolean containsProperly(Geometry g1, Geometry g2) { PreparedGeometry prepGeom = PreparedGeometryFactory.prepare(g1); return prepGeom.containsProperly(g2); } public static boolean covers(Geometry g1, Geometry g2)
if (representativeGeom.getGeometry() instanceof Point) { return 1.0; if (representativeGeom.getGeometry() instanceof LineString) { return 1.0; if (representativeGeom.getGeometry() instanceof Polygon) { Rectangle2D glyphBounds = painter.getFullLabelBounds(); try { if (representativeGeom.contains(pp)) { count++; Geometry g = representativeGeom.getGeometry(); g.geometryChanged(); Envelope ePoly = g.getEnvelopeInternal();
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!"); }
@Override public boolean compare( final Geometry dataGeometry, final PreparedGeometry constraintGeometry) { return constraintGeometry.disjoint(dataGeometry); }
public static boolean preparedCovers(Geometry g1, Geometry g2) { return createPG(g1).covers(g2); }
public static boolean preparedContainsProperly(Geometry g1, Geometry g2) { return createPG(g1).containsProperly(g2); }
@Override public boolean compare( final Geometry dataGeometry, final PreparedGeometry constraintGeometry) { return constraintGeometry.intersects(dataGeometry); }