Search in sources :

Example 41 with BoundingBox

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

the class ProjectedCoordinateSystem method getAreaBoundingBox.

@Override
public BoundingBox getAreaBoundingBox() {
    if (this.areaBoundingBox == null) {
        final GeometryFactory geographicGeometryFactory = this.geographicCoordinateSystem.getGeometryFactory();
        BoundingBox boundingBox;
        if (this.area == null) {
            boundingBox = geographicGeometryFactory.newBoundingBox(-180, -90, 180, 90);
        } else {
            final BoundingBox latLonBounds = this.area.getLatLonBounds();
            boundingBox = latLonBounds.convert(geographicGeometryFactory);
        }
        final GeometryFactory geometryFactory = getGeometryFactory();
        this.areaBoundingBox = boundingBox.convert(geometryFactory);
    }
    return this.areaBoundingBox;
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) BoundingBox(com.revolsys.geometry.model.BoundingBox)

Example 42 with BoundingBox

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

the class MCPointInRing method isInside.

@Override
public boolean isInside(final Point pt) {
    this.crossings = 0;
    // test all segments intersected by ray from pt in positive x direction
    final double y = pt.getY();
    final BoundingBox rayEnv = new BoundingBoxDoubleXY(-Double.MAX_VALUE, y, Double.MAX_VALUE, y);
    this.interval.min = y;
    this.interval.max = y;
    final List segs = this.tree.query(this.interval);
    // System.out.println("query size = " + segs.size());
    final MCSelecter mcSelecter = new MCSelecter(pt);
    for (final Iterator i = segs.iterator(); i.hasNext(); ) {
        final MonotoneChain mc = (MonotoneChain) i.next();
        testMonotoneChain(rayEnv, mcSelecter, mc);
    }
    /*
     * p is inside if number of crossings is odd.
     */
    if (this.crossings % 2 == 1) {
        return true;
    }
    return false;
}
Also used : MonotoneChain(com.revolsys.geometry.index.chain.MonotoneChain) BoundingBox(com.revolsys.geometry.model.BoundingBox) Iterator(java.util.Iterator) List(java.util.List) BoundingBoxDoubleXY(com.revolsys.geometry.model.impl.BoundingBoxDoubleXY)

Example 43 with BoundingBox

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

the class BoundingBoxIntersectsEdgeVisitor method getEdges.

public static <T> List<Edge<T>> getEdges(final Graph<T> graph, final Edge<T> edge, final double maxDistance) {
    final CreateListVisitor<Edge<T>> results = new CreateListVisitor<>();
    final LineString line = edge.getLineString();
    BoundingBox boundingBox = line.getBoundingBox();
    boundingBox = boundingBox.expand(maxDistance);
    final BoundingBoxIntersectsEdgeVisitor<T> visitor = new BoundingBoxIntersectsEdgeVisitor<>(boundingBox, results);
    final IdObjectIndex<Edge<T>> index = graph.getEdgeIndex();
    index.forEach(boundingBox, visitor);
    final List<Edge<T>> list = results.getList();
    list.remove(edge);
    return list;
}
Also used : LineString(com.revolsys.geometry.model.LineString) BoundingBox(com.revolsys.geometry.model.BoundingBox) CreateListVisitor(com.revolsys.visitor.CreateListVisitor) Edge(com.revolsys.geometry.graph.Edge)

Example 44 with BoundingBox

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

the class EdgeIntersectsLinearlyEdgeVisitor method accept.

@Override
public void accept(final Edge<T> edge2) {
    if (edge2 != this.edge) {
        final LineString line1 = this.edge.getLineString();
        final LineString line2 = edge2.getLineString();
        final BoundingBox envelope1 = line1.getBoundingBox();
        final BoundingBox envelope2 = line2.getBoundingBox();
        if (envelope1.intersects(envelope2)) {
            final IntersectionMatrix relate = line1.relate(line2);
            if (relate.get(0, 0) == Dimension.L) {
                this.matchVisitor.accept(edge2);
            }
        }
    }
}
Also used : LineString(com.revolsys.geometry.model.LineString) BoundingBox(com.revolsys.geometry.model.BoundingBox) IntersectionMatrix(com.revolsys.geometry.model.IntersectionMatrix)

Example 45 with BoundingBox

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

the class EdgeIntersectsLinearlyEdgeVisitor method getEdges.

public static <T> List<Edge<T>> getEdges(final Graph<T> graph, final Edge<T> edge) {
    final CreateListVisitor<Edge<T>> results = new CreateListVisitor<>();
    final LineString line = edge.getLineString();
    final BoundingBox env = line.getBoundingBox();
    final IdObjectIndex<Edge<T>> index = graph.getEdgeIndex();
    index.forEach(env, new EdgeIntersectsLinearlyEdgeVisitor<>(edge, results));
    final List<Edge<T>> edges = results.getList();
    Collections.sort(edges);
    return edges;
}
Also used : LineString(com.revolsys.geometry.model.LineString) BoundingBox(com.revolsys.geometry.model.BoundingBox) CreateListVisitor(com.revolsys.visitor.CreateListVisitor) Edge(com.revolsys.geometry.graph.Edge)

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