public void setBuffer(double buffer) { this.buffer = buffer; this.buf = Math.max(buffer, Math.max(bounds.getWidth() * buffer, bounds.getHeight() * buffer)); }
public boolean canSimplify(Envelope envelope) { return envelope.getWidth() < spanX && envelope.getHeight() < spanY; }
/** * Creates a new transform. * * @param env the envelope defining one coordinate system * @param xSize the number of cells along the X axis of the grid * @param ySize the number of cells along the Y axis of the grid */ public GridTransform(Envelope env, int xSize, int ySize) { this.env = env; this.xSize = xSize; this.ySize = ySize; dx = env.getWidth() / (xSize - 1); dy = env.getHeight() / (ySize - 1); }
private Envelope intersection(Envelope e1, Envelope e2) { Envelope r = e1.intersection(e2); if (r.getWidth() < 0) return null; if (r.getHeight() < 0) return null; return r; }
double calcPolygonAlignOrthoAngle(Geometry geometry) { Envelope envelope = geometry.getEnvelopeInternal(); if (envelope.getHeight() > envelope.getWidth()) { return -(Math.PI / 2); } else { return 0; } }
/** * TODO summary sentence for worldToScreenTransform ... * * @param bounds * @param rectangle * @return */ public static AffineTransform worldToScreenTransform(Envelope mapExtent, Rectangle screenSize) { double scaleX = screenSize.getWidth() / mapExtent.getWidth(); double scaleY = screenSize.getHeight() / mapExtent.getHeight(); double tx = -mapExtent.getMinX() * scaleX; double ty = (mapExtent.getMinY() * scaleY) + screenSize.getHeight(); AffineTransform at = new AffineTransform(scaleX, 0.0d, 0.0d, -scaleY, tx, ty); return at; } /**
/** * Sets up the affine transform * * <p>((Taken from the old LiteRenderer)) * * @param mapExtent the map extent * @param paintArea the size of the rendering output area * @return a transform that maps from real world coordinates to the screen * @deprecated Uses the alternative based on <code>ReferencedEnvelope</code> that doe not assume * anything on axes order. */ public static AffineTransform worldToScreenTransform(Envelope mapExtent, Rectangle paintArea) { double scaleX = paintArea.getWidth() / mapExtent.getWidth(); double scaleY = paintArea.getHeight() / mapExtent.getHeight(); double tx = -mapExtent.getMinX() * scaleX; double ty = (mapExtent.getMinY() * scaleY) + paintArea.getHeight(); AffineTransform at = new AffineTransform(scaleX, 0.0d, 0.0d, -scaleY, tx, ty); AffineTransform originTranslation = AffineTransform.getTranslateInstance(paintArea.x, paintArea.y); originTranslation.concatenate(at); return originTranslation != null ? originTranslation : at; }
/** * Converts a JTS Envelope into an equivalent {@link Rectangle2D} * * @param envelope The source envelope */ public static Rectangle2D toRectangle2D(Envelope envelope) { if (envelope == null) { return null; } return new Rectangle2D.Double( envelope.getMinX(), envelope.getMinY(), envelope.getWidth(), envelope.getHeight()); }
private int getNumSides(Envelope env) { return (int) (10 * (env.getWidth() + env.getHeight())); }
/** * Returns a high precision and more accurate bounding box of the <code>Shape</code> than the * <code>getBounds</code> method. Note that there is no guarantee that the returned {@link * Rectangle2D} is the smallest bounding box that encloses the <code>Shape</code>, only that the * <code>Shape</code> lies entirely within the indicated <code>Rectangle2D</code>. The bounding * box returned by this method is usually tighter than that returned by the <code>getBounds * </code> method and never fails due to overflow problems since the return value can be an * instance of the <code>Rectangle2D</code> that uses double precision values to store the * dimensions. * * @return an instance of <code>Rectangle2D</code> that is a high-precision bounding box of the * <code>Shape</code>. * @see #getBounds */ public Rectangle2D getBounds2D() { Envelope env = geometry.getEnvelopeInternal(); return new Rectangle2D.Double( env.getMinX(), env.getMinY(), env.getWidth(), env.getHeight()); }
private Rectangle2D getCurvedLabelBounds( LineStringCursor cursor, double startOrdinate, double endOrdinate, double bufferSize) { LineString cut = cursor.getSubLineString(startOrdinate, endOrdinate); Envelope e = cut.getEnvelopeInternal(); e.expandBy(bufferSize); return new Rectangle2D.Double(e.getMinX(), e.getMinY(), e.getWidth(), e.getHeight()); }
new double[] { env.getWidth() / buffImage.getWidth(), env.getHeight() / buffImage.getHeight() };
private double[] getTranslationFactors(Polygon reference, Polygon displaced) { // compare the two envelopes Envelope re = reference.getEnvelopeInternal(); Envelope de = displaced.getEnvelopeInternal(); double dw = Math.abs(re.getWidth() - de.getWidth()); double dh = Math.abs(re.getHeight() - de.getHeight()); if (dw > EPS * re.getWidth() || dh > EPS * re.getWidth()) { // this was not just a translation return null; } // compute the translation double dx = de.getMinX() - re.getMinX(); double dy = de.getMinY() - re.getMinY(); Polygon cloned = (Polygon) displaced.copy(); cloned.apply(AffineTransformation.translationInstance(-dx, -dy)); if (1 - new HausdorffSimilarityMeasure().measure(cloned, reference) > EPS) { return null; } else { return new double[] {dx, dy}; } }
/** * @param geom * @param seq */ private boolean decimateOnEnvelope(Geometry geom, LiteCoordinateSequence seq) { Envelope env = geom.getEnvelopeInternal(); if (env.getWidth() <= spanx && env.getHeight() <= spany) { if (geom instanceof LinearRing) { decimateRingFully(seq); return true; } else { double[] coords = seq.getArray(); int dim = seq.getDimension(); double[] newcoords = new double[dim * 2]; for (int i = 0; i < dim; i++) { newcoords[i] = coords[i]; newcoords[dim + i] = coords[coords.length - dim + i]; } seq.setArray(newcoords); return true; } } return false; }
public Geometry get() throws IOException { if (header == null) { header = readHeader(); } if (geometry == null) { Envelope envelope = header.getEnvelope(); if (simplificationDistance != null && geometryType != null && header.getFlags().getEnvelopeIndicator() != EnvelopeType.NONE && envelope.getWidth() < simplificationDistance.doubleValue() && envelope.getHeight() < simplificationDistance.doubleValue()) { Geometry simplified = getSimplifiedShape( geometryType, envelope.getMinX(), envelope.getMinY(), envelope.getMaxX(), envelope.getMaxY()); if (simplified != null) { geometry = simplified; } } if (geometry == null) { geometry = read(); } } return geometry; }
&& !envelope.isNull() && !Double.isInfinite(envelope.getWidth()) && !Double.isInfinite(envelope.getHeight())) {
&& envelope.getHeight() < simplificationDistance) { try {
envelope.getMinY(), envelope.getWidth(), envelope.getHeight());