Skip to content

Commit

Permalink
use SpatialIndex generics in MCIndexNoder
Browse files Browse the repository at this point in the history
Signed-off-by: Mike Barry <[email protected]>
  • Loading branch information
msbarry committed Nov 5, 2023
1 parent bbd687b commit 45a64fb
Showing 1 changed file with 23 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
public class MCIndexNoder
extends SinglePassNoder
{
private List monoChains = new ArrayList();
private SpatialIndex index= new HPRtree();
private final List<MonotoneChain> monoChains = new ArrayList<>();
private final SpatialIndex<MonotoneChain> index = new HPRtree<>();
private int idCounter = 0;
private Collection nodedSegStrings;
// statistics
Expand Down Expand Up @@ -69,9 +69,9 @@ public MCIndexNoder(SegmentIntersector si, double overlapTolerance)
this.overlapTolerance = overlapTolerance;
}

public List getMonotoneChains() { return monoChains; }
public List<MonotoneChain> getMonotoneChains() { return monoChains; }

public SpatialIndex getIndex() { return index; }
public SpatialIndex<MonotoneChain> getIndex() { return index; }

public Collection getNodedSubstrings()
{
Expand All @@ -92,25 +92,26 @@ private void intersectChains()
{
MonotoneChainOverlapAction overlapAction = new SegmentOverlapAction(segInt);

for (Iterator i = monoChains.iterator(); i.hasNext(); ) {
MonotoneChain queryChain = (MonotoneChain) i.next();
Envelope queryEnv = queryChain.getEnvelope(overlapTolerance);
List overlapChains = index.query(queryEnv);
for (Iterator j = overlapChains.iterator(); j.hasNext(); ) {
MonotoneChain testChain = (MonotoneChain) j.next();
/**
* following test makes sure we only compare each pair of chains once
* and that we don't compare a chain to itself
*/
if (testChain.getId() > queryChain.getId()) {
queryChain.computeOverlaps(testChain, overlapTolerance, overlapAction);
nOverlaps++;
}
// short-circuit if possible
if (segInt.isDone())
return;
/**
* following test makes sure we only compare each pair of chains once
* and that we don't compare a chain to itself
*/
for (MonotoneChain queryChain : monoChains) {
Envelope queryEnv = queryChain.getEnvelope(overlapTolerance);
for (MonotoneChain testChain : index.query(queryEnv)) {
/**
* following test makes sure we only compare each pair of chains once
* and that we don't compare a chain to itself
*/
if (testChain.getId() > queryChain.getId()) {
queryChain.computeOverlaps(testChain, overlapTolerance, overlapAction);
nOverlaps++;
}
// short-circuit if possible
if (segInt.isDone())
return;
}
}
}
}

private void add(SegmentString segStr)
Expand Down

0 comments on commit 45a64fb

Please sign in to comment.