Search in sources :

Example 1 with MonotoneChain

use of com.revolsys.geometry.index.chain.MonotoneChain in project com.revolsys.open by revolsys.

the class MCIndexNoder method add.

private void add(final SegmentString segStr) {
    final List<MonotoneChain> segChains = MonotoneChainBuilder.getChains(segStr.getLineString(), segStr);
    for (final MonotoneChain chain : segChains) {
        chain.setId(this.idCounter++);
        this.index.insertItem(chain);
        this.monoChains.add(chain);
    }
}
Also used : MonotoneChain(com.revolsys.geometry.index.chain.MonotoneChain)

Example 2 with MonotoneChain

use of com.revolsys.geometry.index.chain.MonotoneChain in project com.revolsys.open by revolsys.

the class MCIndexPointSnapper method snap.

/**
 * Snaps (nodes) all interacting segments to this hot pixel.
 * The hot pixel may represent a vertex of an edge,
 * in which case this routine uses the optimization
 * of not noding the vertex itself
 *
 * @param hotPixel the hot pixel to snap to
 * @param parentEdge the edge containing the vertex, if applicable, or <code>null</code>
 * @param hotPixelVertexIndex the index of the hotPixel vertex, if applicable, or -1
 * @return <code>true</code> if a node was added for this pixel
 */
public boolean snap(final HotPixel hotPixel, final SegmentString parentEdge, final int hotPixelVertexIndex) {
    final BoundingBox pixelEnv = hotPixel.getSafeEnvelope();
    final HotPixelSnapAction hotPixelSnapAction = new HotPixelSnapAction(hotPixel, parentEdge, hotPixelVertexIndex);
    this.index.query(pixelEnv, (item) -> {
        final MonotoneChain testChain = (MonotoneChain) item;
        testChain.select(pixelEnv, hotPixelSnapAction);
    });
    return hotPixelSnapAction.isNodeAdded();
}
Also used : MonotoneChain(com.revolsys.geometry.index.chain.MonotoneChain) BoundingBox(com.revolsys.geometry.model.BoundingBox)

Example 3 with MonotoneChain

use of com.revolsys.geometry.index.chain.MonotoneChain 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 4 with MonotoneChain

use of com.revolsys.geometry.index.chain.MonotoneChain in project com.revolsys.open by revolsys.

the class MCPointInRing method buildIndex.

private void buildIndex() {
    // BoundingBox env = ring.getEnvelopeInternal();
    this.tree = new Bintree();
    final LineString points = this.ring.removeDuplicatePoints();
    final List<MonotoneChain> mcList = MonotoneChainBuilder.getChains(points);
    for (int i = 0; i < mcList.size(); i++) {
        final MonotoneChain mc = mcList.get(i);
        final BoundingBox mcEnv = mc.getEnvelope();
        this.interval.min = mcEnv.getMinY();
        this.interval.max = mcEnv.getMaxY();
        this.tree.insert(this.interval, mc);
    }
}
Also used : LineString(com.revolsys.geometry.model.LineString) MonotoneChain(com.revolsys.geometry.index.chain.MonotoneChain) BoundingBox(com.revolsys.geometry.model.BoundingBox) Bintree(com.revolsys.geometry.index.bintree.Bintree) Point(com.revolsys.geometry.model.Point)

Example 5 with MonotoneChain

use of com.revolsys.geometry.index.chain.MonotoneChain in project com.revolsys.open by revolsys.

the class MCIndexedPointInAreaLocator method countSegs.

private void countSegs(final RayCrossingCounter rcc, final BoundingBox rayEnv, final List monoChains, final MCSegmentCounter mcSegCounter) {
    for (final Iterator i = monoChains.iterator(); i.hasNext(); ) {
        final MonotoneChain mc = (MonotoneChain) i.next();
        mc.select(rayEnv, mcSegCounter);
        // short-circuit if possible
        if (rcc.isOnSegment()) {
            return;
        }
    }
}
Also used : MonotoneChain(com.revolsys.geometry.index.chain.MonotoneChain) Iterator(java.util.Iterator)

Aggregations

MonotoneChain (com.revolsys.geometry.index.chain.MonotoneChain)6 BoundingBox (com.revolsys.geometry.model.BoundingBox)3 Iterator (java.util.Iterator)2 Bintree (com.revolsys.geometry.index.bintree.Bintree)1 LineString (com.revolsys.geometry.model.LineString)1 Point (com.revolsys.geometry.model.Point)1 BoundingBoxDoubleXY (com.revolsys.geometry.model.impl.BoundingBoxDoubleXY)1 BasicSegmentString (com.revolsys.geometry.noding.BasicSegmentString)1 SegmentString (com.revolsys.geometry.noding.SegmentString)1 List (java.util.List)1