diff --git a/core/src/main/java/org/tinfour/common/NearestEdgeResult.java b/core/src/main/java/org/tinfour/common/NearestEdgeResult.java index 81796b66..30aa0357 100644 --- a/core/src/main/java/org/tinfour/common/NearestEdgeResult.java +++ b/core/src/main/java/org/tinfour/common/NearestEdgeResult.java @@ -76,8 +76,8 @@ private void prepareNearestVertex() { for (IQuadEdge e : edge.pinwheel()) { Vertex v = e.getB(); if (v != null) { - dX = vMin.getX() - x; - dY = vMin.getY() - y; + dX = v.getX() - x; + dY = v.getY() - y; double d2 = dX * dX + dY * dY; if (d2 < d2Min) { d2Min = d2; diff --git a/core/src/main/java/org/tinfour/interpolation/NaturalNeighborInterpolator.java b/core/src/main/java/org/tinfour/interpolation/NaturalNeighborInterpolator.java index 3189fe77..90cac50a 100644 --- a/core/src/main/java/org/tinfour/interpolation/NaturalNeighborInterpolator.java +++ b/core/src/main/java/org/tinfour/interpolation/NaturalNeighborInterpolator.java @@ -48,7 +48,7 @@ import org.tinfour.common.Circumcircle; import org.tinfour.common.GeometricOperations; import org.tinfour.common.IIncrementalTin; -import org.tinfour.common.INeighborEdgeLocator; +import org.tinfour.common.IIncrementalTinNavigator; import org.tinfour.common.IQuadEdge; import org.tinfour.common.Thresholds; import org.tinfour.common.Vertex; @@ -70,7 +70,7 @@ public class NaturalNeighborInterpolator implements IInterpolatorOverTin { final IIncrementalTin tin; final GeometricOperations geoOp; - INeighborEdgeLocator locator; + IIncrementalTinNavigator navigator; private final VertexValuatorDefault defaultValuator = new VertexValuatorDefault(); @@ -109,7 +109,7 @@ public NaturalNeighborInterpolator(IIncrementalTin tin) { halfPlaneThreshold = thresholds.getHalfPlaneThreshold(); this.tin = tin; - locator = tin.getNeighborEdgeLocator(); + navigator = tin.getNavigator(); } /** @@ -120,7 +120,7 @@ public NaturalNeighborInterpolator(IIncrementalTin tin) { */ @Override public void resetForChangeToTin() { - locator.resetForChangeToTin(); + navigator.resetForChangeToTin(); } /** @@ -379,7 +379,7 @@ public List getBowyerWatsonPolygon(double x, double y) { ArrayList eList = new ArrayList<>(); - IQuadEdge locatorEdge = locator.getNeigborEdge(x, y); + IQuadEdge locatorEdge = navigator.getNeighborEdge(x, y); if (locatorEdge == null) { // this would happen only if the TIN were not bootstrapped return eList; diff --git a/core/src/main/java/org/tinfour/interpolation/TriangularFacetInterpolator.java b/core/src/main/java/org/tinfour/interpolation/TriangularFacetInterpolator.java index df827fe5..779e1a38 100644 --- a/core/src/main/java/org/tinfour/interpolation/TriangularFacetInterpolator.java +++ b/core/src/main/java/org/tinfour/interpolation/TriangularFacetInterpolator.java @@ -31,7 +31,7 @@ package org.tinfour.interpolation; import org.tinfour.common.IIncrementalTin; -import org.tinfour.common.INeighborEdgeLocator; +import org.tinfour.common.IIncrementalTinNavigator; import org.tinfour.common.IQuadEdge; import org.tinfour.common.Thresholds; import org.tinfour.common.Vertex; @@ -48,7 +48,7 @@ public class TriangularFacetInterpolator implements IInterpolatorOverTin { final private double precisionThreshold; final IIncrementalTin tin; - final INeighborEdgeLocator locator; + final IIncrementalTinNavigator navigator; private final VertexValuatorDefault defaultValuator = new VertexValuatorDefault(); @@ -83,7 +83,7 @@ public TriangularFacetInterpolator(IIncrementalTin tin) { precisionThreshold = thresholds.getPrecisionThreshold(); this.tin = tin; - locator = tin.getNeighborEdgeLocator(); + navigator = tin.getNavigator(); } /** @@ -94,7 +94,7 @@ public TriangularFacetInterpolator(IIncrementalTin tin) { */ @Override public void resetForChangeToTin() { - locator.resetForChangeToTin(); + navigator.resetForChangeToTin(); } /** @@ -125,7 +125,7 @@ public double interpolate(double x, double y, IVertexValuator valuator) { vq = defaultValuator; } - IQuadEdge e= locator.getNeigborEdge(x, y); + IQuadEdge e= navigator.getNeighborEdge(x, y); if (e == null) { // this should happen only when TIN is not bootstrapped diff --git a/core/src/main/java/org/tinfour/utils/VertexColorizerKempe6.java b/core/src/main/java/org/tinfour/utils/VertexColorizerKempe6.java index 1663997f..0f61b597 100644 --- a/core/src/main/java/org/tinfour/utils/VertexColorizerKempe6.java +++ b/core/src/main/java/org/tinfour/utils/VertexColorizerKempe6.java @@ -35,7 +35,7 @@ import java.util.Arrays; import java.util.List; import org.tinfour.common.IIncrementalTin; -import org.tinfour.common.INeighborEdgeLocator; +import org.tinfour.common.IIncrementalTinNavigator; import org.tinfour.common.IQuadEdge; import org.tinfour.common.Vertex; @@ -99,7 +99,7 @@ public void assignColorsToVertices(IIncrementalTin tin) { // The minimum number of connections is two. For a sufficiently large // population, the average number of connections is 6. ArrayDeque stack = new ArrayDeque<>(); - INeighborEdgeLocator locator = tin.getNeighborEdgeLocator(); + IIncrementalTinNavigator navigator = tin.getNavigator(); while (!vertexList.isEmpty()) { Vertex vRemove = null; for (Vertex v : vertexList) { @@ -110,7 +110,7 @@ public void assignColorsToVertices(IIncrementalTin tin) { } vertexList.remove(vRemove); stack.push(vRemove); - IQuadEdge eRemove = locateEdge(locator, vRemove); + IQuadEdge eRemove = locateEdge(navigator, vRemove); if(eRemove==null){ throw new IllegalStateException("Internal error, unable to locate edge"); } @@ -130,7 +130,7 @@ public void assignColorsToVertices(IIncrementalTin tin) { int iStart = 0; while (!stack.isEmpty()) { Vertex v = stack.pop(); - IQuadEdge e = locateEdge(locator, v); + IQuadEdge e = locateEdge(navigator, v); Arrays.fill(flag, true); for (IQuadEdge p : e.pinwheel()) { Vertex B = p.getB(); @@ -254,11 +254,11 @@ private void setDegree(IQuadEdge e, boolean[] visited, List vertexList) /** * Locate an edge which begins with the specified vertex. - * @param locator the edge locator associated with the tin + * @param navigator the edge locator associated with the tin * @param v a valid vertex * @return a valid edge */ - private IQuadEdge locateEdge(INeighborEdgeLocator locator, Vertex v) { + private IQuadEdge locateEdge(IIncrementalTinNavigator navigator, Vertex v) { // The Tinfour edge locator identifies an edge belonging to a // Triangle in which vertex V lies. The locator is a general-purpose // utility that does not assume that the input coordinates necessarily @@ -266,7 +266,7 @@ private IQuadEdge locateEdge(INeighborEdgeLocator locator, Vertex v) { // will include the input vertex. Since the colorization logic // requires a vertex that begins with input vertex v, a bit more // work is required to select the correct edge. - IQuadEdge e = locator.getNeigborEdge(v.getX(), v.getY()); + IQuadEdge e = navigator.getNeighborEdge(v.getX(), v.getY()); if(e == null){ // won't happen except when the TIN is not bootstraped return null; diff --git a/demo/src/main/java/org/tinfour/demo/viewer/backplane/MvComposite.java b/demo/src/main/java/org/tinfour/demo/viewer/backplane/MvComposite.java index bd1b6e4a..7140d458 100644 --- a/demo/src/main/java/org/tinfour/demo/viewer/backplane/MvComposite.java +++ b/demo/src/main/java/org/tinfour/demo/viewer/backplane/MvComposite.java @@ -51,9 +51,9 @@ import org.apache.commons.math3.linear.SingularMatrixException; import org.tinfour.common.IConstraint; import org.tinfour.common.IIncrementalTin; -import org.tinfour.common.INeighborEdgeLocator; +import org.tinfour.common.IIncrementalTinNavigator; import org.tinfour.common.IQuadEdge; -import org.tinfour.common.NeighborEdgeVertex; +import org.tinfour.common.NearestEdgeResult; import org.tinfour.common.PolygonConstraint; import org.tinfour.common.Vertex; import org.tinfour.gwr.BandwidthSelectionMethod; @@ -110,7 +110,7 @@ public class MvComposite { private List constraintsForRender; GwrTinInterpolator interpolator; - INeighborEdgeLocator edgeLocator; + IIncrementalTinNavigator navigator; double vx0, vy0, vx1, vy1; @@ -210,7 +210,7 @@ public MvComposite( interpolatingTin = model.getReferenceTin(); reductionForInterpolatingTin = model.getReferenceReductionFactor(); interpolator = new GwrTinInterpolator(interpolatingTin); - edgeLocator = interpolatingTin.getNeighborEdgeLocator(); + navigator = interpolatingTin.getNavigator(); applyRangeOfVisibleSamples(model.getVertexList()); } @@ -250,7 +250,7 @@ public MvComposite( this.interpolator = mvComposite.interpolator; this.timeForBuildRaster0 = mvComposite.timeForBuildRaster0; this.timeForBuildRaster1 = mvComposite.timeForBuildRaster1; - this.edgeLocator = mvComposite.edgeLocator; + this.navigator = mvComposite.navigator; this.constraintsForRender = mvComposite.constraintsForRender; } } @@ -262,7 +262,7 @@ public MvComposite( interpolatingTin = mvComposite.interpolatingTin; reductionForInterpolatingTin = mvComposite.reductionForInterpolatingTin; interpolator = new GwrTinInterpolator(interpolatingTin); - edgeLocator = interpolatingTin.getNeighborEdgeLocator(); + navigator = interpolatingTin.getNavigator(); zVisMin = mvComposite.zVisMin; zVisMax = mvComposite.zVisMax; } @@ -289,9 +289,9 @@ public MvComposite( if (model.isLoaded()) { IIncrementalTin ref = model.getReferenceTin(); - ref.getNeighborEdgeLocator(); + ref.getNavigator(); interpolator = new GwrTinInterpolator(ref); - edgeLocator = ref.getNeighborEdgeLocator(); + navigator = ref.getNavigator(); } } @@ -442,7 +442,7 @@ void submitCandidateTinForInterpolation(IIncrementalTin tin, double reductionFac interpolatingTin = tin; reductionForInterpolatingTin = reductionFactor; interpolator = new GwrTinInterpolator(interpolatingTin); - edgeLocator = interpolatingTin.getNeighborEdgeLocator(); + navigator = interpolatingTin.getNavigator(); } } } @@ -924,10 +924,10 @@ public MvQueryResult performQuery(double x, double y) { units = "units"; break; } - NeighborEdgeVertex nev = edgeLocator.getEdgeWithNearestVertex(mx, my); - boolean queryIsOutside = !nev.isInterior(); - Vertex vNear = nev.getNearestVertex(); - double dNear = nev.getDistance(); + NearestEdgeResult result = navigator.getNearestEdge(mx, my); + boolean queryIsOutside = !result.isInterior(); + Vertex vNear = result.getNearestVertex(); + double dNear = result.getDistanceToNearestVertex(); // the following is a debugging aid when trying to deal with vertex // insertion versus TIN extension. diff --git a/demo/src/main/java/org/tinfour/demo/viewer/backplane/MvTaskBuildTinAndRender.java b/demo/src/main/java/org/tinfour/demo/viewer/backplane/MvTaskBuildTinAndRender.java index 062e2609..aa078515 100644 --- a/demo/src/main/java/org/tinfour/demo/viewer/backplane/MvTaskBuildTinAndRender.java +++ b/demo/src/main/java/org/tinfour/demo/viewer/backplane/MvTaskBuildTinAndRender.java @@ -37,10 +37,9 @@ import java.util.concurrent.atomic.AtomicInteger; import org.tinfour.common.IConstraint; import org.tinfour.common.IIncrementalTin; +import org.tinfour.common.IIncrementalTinNavigator; import org.tinfour.common.IMonitorWithCancellation; -import org.tinfour.common.INeighborEdgeLocator; import org.tinfour.common.IPolyline; -import org.tinfour.common.NeighborEdgeVertex; import org.tinfour.common.PolygonConstraint; import org.tinfour.common.Vertex; import org.tinfour.utils.PolylineThinner; @@ -399,10 +398,8 @@ void launchRasterProcessing(double nominalPointSpacing, IIncrementalTin wirefram private Vertex getNearbyVertex(double x, double y) { IIncrementalTin referenceTin = model.getReferenceTin(); - referenceTin.getNeighborEdgeLocator(); - INeighborEdgeLocator locator = referenceTin.getNeighborEdgeLocator(); - NeighborEdgeVertex nev = locator.getEdgeWithNearestVertex(x, y); - return nev.getNearestVertex(); + IIncrementalTinNavigator navigator = referenceTin.getNavigator(); + return navigator.getNearestVertex(x, y); } /** diff --git a/svm/src/main/java/org/tinfour/svm/SvmContourGraph.java b/svm/src/main/java/org/tinfour/svm/SvmContourGraph.java index 28f63b95..1a813a98 100644 --- a/svm/src/main/java/org/tinfour/svm/SvmContourGraph.java +++ b/svm/src/main/java/org/tinfour/svm/SvmContourGraph.java @@ -49,7 +49,7 @@ import javax.imageio.ImageIO; import org.tinfour.common.IConstraint; import org.tinfour.common.IIncrementalTin; -import org.tinfour.common.INeighborEdgeLocator; +import org.tinfour.common.IIncrementalTinNavigator; import org.tinfour.common.IQuadEdge; import org.tinfour.common.PolygonConstraint; import org.tinfour.common.Vertex; @@ -203,7 +203,7 @@ static void write( // it is necessary to force outside values to be at least the // shoreline reference elevation. ps.println("\nChecking for vertices lying outside of constraints"); - INeighborEdgeLocator locator = tin.getNeighborEdgeLocator(); + IIncrementalTinNavigator navigator = tin.getNavigator(); long time0 = System.currentTimeMillis(); int nOutsiders = 0; @@ -213,7 +213,7 @@ static void write( int index = v.getIndex(); double x = v.getX(); double y = v.getY(); - IQuadEdge test = locator.getNeigborEdge(x, y); + IQuadEdge test = navigator.getNeighborEdge(x, y); IConstraint con = tin.getRegionConstraint(test); if (con == null || !water[con.getConstraintIndex()]) { nOutsiders++; diff --git a/svm/src/main/java/org/tinfour/svm/SvmRaster.java b/svm/src/main/java/org/tinfour/svm/SvmRaster.java index 60d37c40..e47c0f58 100644 --- a/svm/src/main/java/org/tinfour/svm/SvmRaster.java +++ b/svm/src/main/java/org/tinfour/svm/SvmRaster.java @@ -34,7 +34,7 @@ import java.io.IOException; import java.io.PrintStream; import org.tinfour.common.IIncrementalTin; -import org.tinfour.common.INeighborEdgeLocator; +import org.tinfour.common.IIncrementalTinNavigator; import org.tinfour.common.IQuadEdge; import org.tinfour.interpolation.NaturalNeighborInterpolator; import org.tinfour.svm.properties.SvmProperties; @@ -112,7 +112,7 @@ void buildAndWriteRaster( long reportBlockSize = nRows / 10; long priorReportBlock = 0; int nCovered = 0; - INeighborEdgeLocator locator = tin.getNeighborEdgeLocator(); + IIncrementalTinNavigator navigator = tin.getNavigator(); NaturalNeighborInterpolator nni = new NaturalNeighborInterpolator(tin); long time0 = System.nanoTime(); for (long i = iMin; i < iMax; i++) { @@ -121,7 +121,7 @@ void buildAndWriteRaster( int jCol = (int) (j - jMin); double x = j * s; double y = i * s; - IQuadEdge edge = locator.getNeigborEdge(x, y); + IQuadEdge edge = navigator.getNeighborEdge(x, y); double z = -1; if (testWater(edge, water)) { z = nni.interpolate(x, y, null);