Search in sources :

Example 66 with BoundingBox

use of com.revolsys.geometry.model.BoundingBox in project com.revolsys.open by revolsys.

the class IndexedNestedRingTester method buildIndex.

private void buildIndex() {
    this.index = new StrTree();
    for (int i = 0; i < this.rings.size(); i++) {
        final LinearRing ring = (LinearRing) this.rings.get(i);
        final BoundingBox env = ring.getBoundingBox();
        this.index.insertItem(env, ring);
    }
}
Also used : BoundingBox(com.revolsys.geometry.model.BoundingBox) StrTree(com.revolsys.geometry.index.strtree.StrTree) LinearRing(com.revolsys.geometry.model.LinearRing) Point(com.revolsys.geometry.model.Point)

Example 67 with BoundingBox

use of com.revolsys.geometry.model.BoundingBox in project com.revolsys.open by revolsys.

the class LineSegmentVisitor method query.

public List query(final LineSegment querySeg) {
    final BoundingBox env = querySeg.getBoundingBox();
    final LineSegmentVisitor visitor = new LineSegmentVisitor(querySeg);
    this.index.forEach(env, visitor);
    final List itemsFound = visitor.getItems();
    return itemsFound;
}
Also used : BoundingBox(com.revolsys.geometry.model.BoundingBox) List(java.util.List) ArrayList(java.util.ArrayList)

Example 68 with BoundingBox

use of com.revolsys.geometry.model.BoundingBox in project com.revolsys.open by revolsys.

the class GeometricShapeFactory method newEllipse.

/**
 * Creates an elliptical {@link Polygon}.
 * If the supplied envelope is square the
 * result will be a circle.
 *
 * @return an ellipse or circle
 */
public Polygon newEllipse() {
    final BoundingBox env = this.dim.getEnvelope();
    final double xRadius = env.getWidth() / 2.0;
    final double yRadius = env.getHeight() / 2.0;
    final double centreX = env.getMinX() + xRadius;
    final double centreY = env.getMinY() + yRadius;
    final double[] coordinates = new double[(this.vertexCount + 1) * 2];
    int coordinateIndex = 0;
    for (int i = 0; i < this.vertexCount; i++) {
        final double ang = i * (2 * Math.PI / this.vertexCount);
        final double x = xRadius * Math.cos(ang) + centreX;
        final double y = yRadius * Math.sin(ang) + centreY;
        coordinates[coordinateIndex++] = x;
        coordinates[coordinateIndex++] = y;
    }
    coordinates[coordinateIndex++] = 0;
    coordinates[coordinateIndex++] = 1;
    final Polygon poly = this.geomFact.polygon(2, coordinates);
    return poly;
}
Also used : BoundingBox(com.revolsys.geometry.model.BoundingBox) Polygon(com.revolsys.geometry.model.Polygon) Point(com.revolsys.geometry.model.Point)

Example 69 with BoundingBox

use of com.revolsys.geometry.model.BoundingBox in project com.revolsys.open by revolsys.

the class GeometricShapeFactory method newArc.

/**
 * Creates an elliptical arc, as a {@link LineString}.
 * The arc is always created in a counter-clockwise direction.
 * This can easily be reversed if required by using
 * {#link LineString.reverse()}
 *
 * @param startAng start angle in radians
 * @param angExtent size of angle in radians
 * @return an elliptical arc
 */
public LineString newArc(final double startAng, final double angExtent) {
    final BoundingBox env = this.dim.getEnvelope();
    final double xRadius = env.getWidth() / 2.0;
    final double yRadius = env.getHeight() / 2.0;
    final double centreX = env.getMinX() + xRadius;
    final double centreY = env.getMinY() + yRadius;
    double angSize = angExtent;
    if (angSize <= 0.0 || angSize > 2 * Math.PI) {
        angSize = 2 * Math.PI;
    }
    final double angInc = angSize / (this.vertexCount - 1);
    final Point[] pts = new Point[this.vertexCount];
    int iPt = 0;
    for (int i = 0; i < this.vertexCount; i++) {
        final double ang = startAng + i * angInc;
        final double x = xRadius * Math.cos(ang) + centreX;
        final double y = yRadius * Math.sin(ang) + centreY;
        pts[iPt++] = newPoint(x, y);
    }
    final LineString line = this.geomFact.lineString(pts);
    return line;
}
Also used : LineString(com.revolsys.geometry.model.LineString) BoundingBox(com.revolsys.geometry.model.BoundingBox) Point(com.revolsys.geometry.model.Point) Point(com.revolsys.geometry.model.Point)

Example 70 with BoundingBox

use of com.revolsys.geometry.model.BoundingBox in project com.revolsys.open by revolsys.

the class UtmRectangularMapGrid method getTileByLocation.

@Override
public RectangularMapTile getTileByLocation(final double x, final double y) {
    final String mapTileName = getMapTileName(x, y);
    final BoundingBox boundingBox = getBoundingBox(mapTileName);
    final String formattedMapTileName = getFormattedMapTileName(mapTileName);
    return new SimpleRectangularMapTile(this, formattedMapTileName, mapTileName, boundingBox);
}
Also used : BoundingBox(com.revolsys.geometry.model.BoundingBox)

Aggregations

BoundingBox (com.revolsys.geometry.model.BoundingBox)307 Point (com.revolsys.geometry.model.Point)83 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)76 ArrayList (java.util.ArrayList)45 Geometry (com.revolsys.geometry.model.Geometry)41 LineString (com.revolsys.geometry.model.LineString)26 List (java.util.List)26 BoundingBoxDoubleXY (com.revolsys.geometry.model.impl.BoundingBoxDoubleXY)19 Polygon (com.revolsys.geometry.model.Polygon)14 PointDoubleXY (com.revolsys.geometry.model.impl.PointDoubleXY)14 Project (com.revolsys.swing.map.layer.Project)14 CreateListVisitor (com.revolsys.visitor.CreateListVisitor)12 CoordinateSystem (com.revolsys.geometry.cs.CoordinateSystem)11 LayerRecord (com.revolsys.swing.map.layer.record.LayerRecord)11 Edge (com.revolsys.geometry.graph.Edge)10 HashMap (java.util.HashMap)10 Record (com.revolsys.record.Record)9 Graphics2D (java.awt.Graphics2D)9 MapEx (com.revolsys.collection.map.MapEx)8 LinearRing (com.revolsys.geometry.model.LinearRing)8