Skip to content

Commit

Permalink
Remove unused parameters
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Zilske <michael.zilske@tu-berlin.de>
  • Loading branch information
michaz committed Apr 23, 2018
1 parent ba2dc34 commit 2456732
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 38 deletions.
Expand Up @@ -41,13 +41,10 @@ public ContourBuilder(QuadEdgeSubdivision triangulation) {
}

public Geometry computeIsoline(double z0) {
Set<QuadEdge> processed = new HashSet<QuadEdge>();
Queue<QuadEdge> processQ = new ArrayDeque<QuadEdge>();
List<LinearRing> rings = new ArrayList<LinearRing>();
Set<QuadEdge> processed = new HashSet<>();
List<LinearRing> rings = new ArrayList<>();

for (QuadEdge e : ((Collection<QuadEdge>) triangulation.getPrimaryEdges(true))) {
processQ.add(e);
}
Queue<QuadEdge> processQ = new ArrayDeque<>(getPrimaryEdges());
while (!processQ.isEmpty()) {
QuadEdge e = processQ.remove();
if (processed.contains(e))
Expand All @@ -57,7 +54,7 @@ public Geometry computeIsoline(double z0) {
if (cut == 0) {
continue; // While, next edge
}
List<Coordinate> polyPoints = new ArrayList<Coordinate>();
List<Coordinate> polyPoints = new ArrayList<>();
boolean ccw = cut > 0;
while (true) {
// Add a point to polyline
Expand Down Expand Up @@ -96,8 +93,13 @@ public Geometry computeIsoline(double z0) {
rings.add(ring);
}
}
List<Polygon> retval = punchHoles(rings);
return geometryFactory.createMultiPolygon(retval.toArray(new Polygon[retval.size()]));
List<Polygon> isolinePolygons = punchHoles(rings);
return geometryFactory.createMultiPolygon(isolinePolygons.toArray(new Polygon[isolinePolygons.size()]));
}

@SuppressWarnings("unchecked") // JTS is not generified
private Collection<QuadEdge> getPrimaryEdges() {
return (Collection<QuadEdge>) triangulation.getPrimaryEdges(true);
}

private Coordinate moveEpsilonTowards(Coordinate coordinate, Coordinate distantFrameCoordinate) {
Expand All @@ -112,8 +114,8 @@ private int cut(double za, double zb, double z0) {

@SuppressWarnings("unchecked")
private List<Polygon> punchHoles(List<LinearRing> rings) {
List<Polygon> shells = new ArrayList<Polygon>(rings.size());
List<LinearRing> holes = new ArrayList<LinearRing>(rings.size() / 2);
List<Polygon> shells = new ArrayList<>(rings.size());
List<LinearRing> holes = new ArrayList<>(rings.size() / 2);
// 1. Split the polygon list in two: shells and holes (CCW and CW)
for (LinearRing ring : rings) {
if (CGAlgorithms.signedArea(ring.getCoordinateSequence()) > 0.0)
Expand All @@ -132,7 +134,6 @@ public int compare(Polygon o1, Polygon o2) {
shell.setUserData(new ArrayList<LinearRing>());
}
// 3. For each hole, determine which shell it fits in.
int nHolesFailed = 0;
for (LinearRing hole : holes) {
outer: {
// Probably most of the time, the first shell will be the one
Expand All @@ -146,7 +147,7 @@ public int compare(Polygon o1, Polygon o2) {
}
}
// 4. Build the list of punched polygons
List<Polygon> punched = new ArrayList<Polygon>(shells.size());
List<Polygon> punched = new ArrayList<>(shells.size());
for (Polygon shell : shells) {
List<LinearRing> shellHoles = ((List<LinearRing>) shell.getUserData());
punched.add(geometryFactory.createPolygon((LinearRing) (shell.getExteriorRing()),
Expand Down
Expand Up @@ -45,7 +45,7 @@ enum ExploreType {TIME, DISTANCE}
// TODO use same class as used in GTFS module?
class IsoLabel extends SPTEntry {

public IsoLabel(int edgeId, int adjNode, double weight, long time, double distance) {
IsoLabel(int edgeId, int adjNode, double weight, long time, double distance) {
super(edgeId, adjNode, weight);
this.time = time;
this.distance = distance;
Expand All @@ -71,15 +71,11 @@ public String toString() {

public Isochrone(Graph g, Weighting weighting, boolean reverseFlow) {
super(g, weighting, TraversalMode.NODE_BASED);
initCollections(1000);
fromHeap = new PriorityQueue<>(1000);
fromMap = new GHIntObjectHashMap<>(1000);
this.reverseFlow = reverseFlow;
}

protected void initCollections(int size) {
fromHeap = new PriorityQueue<>(size);
fromMap = new GHIntObjectHashMap<>(size);
}

@Override
public Path calcPath(int from, int to) {
throw new IllegalStateException("call search instead");
Expand Down Expand Up @@ -138,8 +134,6 @@ public void apply(int nodeId, IsoLabel label) {
double lon2 = na.getLongitude(nodeId);
buckets.get(bucketIndex).add(new Double[]{(lon + lon2) / 2, (lat + lat2) / 2});
}

return;
}
});
return buckets;
Expand Down Expand Up @@ -173,13 +167,12 @@ public void apply(int nodeId, IsoLabel label) {
}

list.get(bucketIndex).add(nodeId);
return;
}
});
return list;
}

public void searchInternal(int from) {
private void searchInternal(int from) {
checkAlreadyRun();
currEdge = new IsoLabel(-1, from, 0, 0, 0);
fromMap.put(from, currEdge);
Expand Down Expand Up @@ -236,7 +229,7 @@ public void searchInternal(int from) {
}
}

final double getExploreValue(IsoLabel label) {
private double getExploreValue(IsoLabel label) {
if (exploreType == TIME)
return label.time;
// if(exploreType == DISTANCE)
Expand Down
Expand Up @@ -42,8 +42,7 @@ public class RasterHullBuilder {
* @return a list of polygons wrapping the specified points
*/
@SuppressWarnings("unchecked")
public List<List<Double[]>> calcList(List<List<Double[]>> pointsList, int maxIsolines,
double rasterDistance, double bufferDistance, int quadrantSegments) {
public List<List<Double[]>> calcList(List<List<Double[]>> pointsList, int maxIsolines) {

if (maxIsolines > pointsList.size()) {
throw new IllegalStateException("maxIsolines can only be smaller or equals to pointsList");
Expand Down Expand Up @@ -102,7 +101,7 @@ public List<List<Double[]>> calcList(List<List<Double[]>> pointsList, int maxIso
return polygons;
}

void fillExteriorRing(List<Double[]> coords, Geometry geo) {
private void fillExteriorRing(List<Double[]> coords, Geometry geo) {
if (geo instanceof Polygon) {
// normally this will be picked
Polygon poly = (Polygon) geo;
Expand Down
Expand Up @@ -45,7 +45,7 @@ public void tearDown() {
// 4-5-- |
// |/ \--7
// 6----/
void initDirectedAndDiffSpeed(Graph graph) {
private void initDirectedAndDiffSpeed(Graph graph) {
graph.edge(0, 1).setDistance(70).setFlags(carEncoder.setProperties(10, true, false));
graph.edge(0, 4).setDistance(50).setFlags(carEncoder.setProperties(20, true, false));

Expand Down
Expand Up @@ -24,7 +24,7 @@ public void testCalc() {
list.add(new Double[]{0.001, 0.002});
list.add(new Double[]{0.000, 0.002});

List<List<Double[]>> res = instance.calcList(listOfList, listOfList.size(), 3, 0.007, 2);
List<List<Double[]>> res = instance.calcList(listOfList, listOfList.size());
List<Double[]> geometry = res.get(0);
Assert.assertEquals(9, geometry.size());
}
Expand Down
Expand Up @@ -124,14 +124,7 @@ public Response doGet(
calcRes = list;

} else if ("polygon".equalsIgnoreCase(resultStr)) {
// bigger raster distance => bigger raster => less points => stranger buffer results, but faster
double rasterDistance = 0.75; // cmdArgs.getDouble("isochrone.raster_distance", 0.75);
// bigger buffer distance => less holes, lower means less points!
double bufferDistance = 0.003; // cmdArgs.getDouble("isochrone.buffer_distance", 0.003);
// precision of the 'circles'
int quadrantSegments = 3; // cmdArgs.getInt("isochrone.quadrant_segments", 3);

list = rasterHullBuilder.calcList(list, list.size() - 1, rasterDistance, bufferDistance, quadrantSegments);
list = rasterHullBuilder.calcList(list, list.size() - 1);

ArrayList polyList = new ArrayList();
int index = 0;
Expand Down

0 comments on commit 2456732

Please sign in to comment.