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);
}
}
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();
}
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;
}
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);
}
}
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;
}
}
}
Aggregations