Skip to content

Commit

Permalink
clean up for release 2.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
gwlucastrig committed Sep 11, 2019
1 parent f831808 commit 656ef18
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 44 deletions.
4 changes: 2 additions & 2 deletions core/src/main/java/org/tinfour/common/NearestEdgeResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();

Expand Down Expand Up @@ -109,7 +109,7 @@ public NaturalNeighborInterpolator(IIncrementalTin tin) {
halfPlaneThreshold = thresholds.getHalfPlaneThreshold();

this.tin = tin;
locator = tin.getNeighborEdgeLocator();
navigator = tin.getNavigator();
}

/**
Expand All @@ -120,7 +120,7 @@ public NaturalNeighborInterpolator(IIncrementalTin tin) {
*/
@Override
public void resetForChangeToTin() {
locator.resetForChangeToTin();
navigator.resetForChangeToTin();
}

/**
Expand Down Expand Up @@ -379,7 +379,7 @@ public List<IQuadEdge> getBowyerWatsonPolygon(double x, double y) {

ArrayList<IQuadEdge> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();

Expand Down Expand Up @@ -83,7 +83,7 @@ public TriangularFacetInterpolator(IIncrementalTin tin) {
precisionThreshold = thresholds.getPrecisionThreshold();

this.tin = tin;
locator = tin.getNeighborEdgeLocator();
navigator = tin.getNavigator();
}

/**
Expand All @@ -94,7 +94,7 @@ public TriangularFacetInterpolator(IIncrementalTin tin) {
*/
@Override
public void resetForChangeToTin() {
locator.resetForChangeToTin();
navigator.resetForChangeToTin();
}

/**
Expand Down Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions core/src/main/java/org/tinfour/utils/VertexColorizerKempe6.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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<Vertex> stack = new ArrayDeque<>();
INeighborEdgeLocator locator = tin.getNeighborEdgeLocator();
IIncrementalTinNavigator navigator = tin.getNavigator();
while (!vertexList.isEmpty()) {
Vertex vRemove = null;
for (Vertex v : vertexList) {
Expand All @@ -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");
}
Expand All @@ -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();
Expand Down Expand Up @@ -254,19 +254,19 @@ private void setDegree(IQuadEdge e, boolean[] visited, List<Vertex> 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
// belong to a vertex. Thus it does not guarantee that the edge
// 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -110,7 +110,7 @@ public class MvComposite {
private List<IConstraint> constraintsForRender;

GwrTinInterpolator interpolator;
INeighborEdgeLocator edgeLocator;
IIncrementalTinNavigator navigator;

double vx0, vy0, vx1, vy1;

Expand Down Expand Up @@ -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());
}

Expand Down Expand Up @@ -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;
}
}
Expand All @@ -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;
}
Expand All @@ -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();
}
}

Expand Down Expand Up @@ -442,7 +442,7 @@ void submitCandidateTinForInterpolation(IIncrementalTin tin, double reductionFac
interpolatingTin = tin;
reductionForInterpolatingTin = reductionFactor;
interpolator = new GwrTinInterpolator(interpolatingTin);
edgeLocator = interpolatingTin.getNeighborEdgeLocator();
navigator = interpolatingTin.getNavigator();
}
}
}
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions svm/src/main/java/org/tinfour/svm/SvmContourGraph.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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++;
Expand Down
6 changes: 3 additions & 3 deletions svm/src/main/java/org/tinfour/svm/SvmRaster.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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++) {
Expand All @@ -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);
Expand Down

0 comments on commit 656ef18

Please sign in to comment.