/** * Returns the rule used to handle geometry objects that have dateline (aka anti-meridian) crossing considerations. */ @Deprecated public DatelineRule getDatelineRule() { return getShapeFactory().getDatelineRule(); }
/** * INTERNAL: Returns a Rectangle of the JTS {@link Envelope} (bounding box) of the given {@code geom}. This asserts * that {@link Geometry#isRectangle()} is true. This method reacts to the {@link DatelineRule} setting. * @param geom non-null * @return the equivalent Rectangle. */ public Rectangle makeRectFromRectangularPoly(Geometry geom) { // TODO although, might want to never convert if there's a semantic difference (e.g. // geodetically)? Should have a setting for that. assert geom.isRectangle(); Envelope env = geom.getEnvelopeInternal(); boolean crossesDateline = false; if (ctx.isGeo() && getDatelineRule() != DatelineRule.none) { if (getDatelineRule() == DatelineRule.ccwRect) { // If JTS says it is clockwise, then it's actually a dateline crossing rectangle. crossesDateline = !CGAlgorithms.isCCW(geom.getCoordinates()); } else { crossesDateline = env.getWidth() > 180; } } if (crossesDateline) return rect(env.getMaxX(), env.getMinX(), env.getMinY(), env.getMaxY()); else return rect(env.getMinX(), env.getMaxX(), env.getMinY(), env.getMaxY()); }