@Test public void testThatSnapSnapsCorrectlyToADiagonalLine() { SimpleWaySnap simpleWaySnap = new SimpleWaySnap(new XYPointFactory(), edges); NicGeoPoint geoPointIn1 = new XYPoint(50722200, 7061630); NicGeoPoint geoPointOut1 = simpleWaySnap.snap(geoPointIn1); assertEquals(50722199, geoPointOut1.getLatitudeE6()); assertEquals(7061635, geoPointOut1.getLongitudeE6()); }
public NicGeoPoint snap(NicGeoPoint point) { if (edges != null) { edgesByDistance = new TreeMap<Float, Edge>(); nearestPoints = new HashMap<Edge, NicGeoPoint>(); for (final Edge edge : edges) { final float distance = distance(edge, point); if ((!edgesByDistance.containsKey(distance)) || (edge == lastEdge)) { edgesByDistance.put(distance, edge); } } lastEdge = edgesByDistance.get(edgesByDistance.firstKey()); point = nearestPoints.get(lastEdge); } return point; }
SimpleWaySnap { public NicGeoPoint snap(NicGeoPoint point) { if (edges != null) { edgesByDistance = new TreeMap<Float, Edge>(); nearestPoints = new HashMap<Edge, NicGeoPoint>(); for (final Edge edge : edges) { final float distance = distance(edge, point); if ((!edgesByDistance.containsKey(distance)) || (edge == lastEdge)) { edgesByDistance.put(distance, edge); } } lastEdge = edgesByDistance.get(edgesByDistance.firstKey()); point = nearestPoints.get(lastEdge); } return point; } }
SimpleWaySnap { public NicGeoPoint snap(NicGeoPoint point) { if (edges != null) { edgesByDistance = new TreeMap<Float, Edge>(); nearestPoints = new HashMap<Edge, NicGeoPoint>(); for (final Edge edge : edges) { final float distance = distance(edge, point); if ((!edgesByDistance.containsKey(distance)) || (edge == lastEdge)) { edgesByDistance.put(distance, edge); } } lastEdge = edgesByDistance.get(edgesByDistance.firstKey()); point = nearestPoints.get(lastEdge); } return point; } SimpleWaySnap(PointFactory factory, final Collection<Edge> edges); }
SimpleWaySnap { public NicGeoPoint snap(NicGeoPoint point) { if (edges != null) { edgesByDistance = new TreeMap<Float, Edge>(); nearestPoints = new HashMap<Edge, NicGeoPoint>(); for (final Edge edge : edges) { final float distance = distance(edge, point); if ((!edgesByDistance.containsKey(distance)) || (edge == lastEdge)) { edgesByDistance.put(distance, edge); } } lastEdge = edgesByDistance.get(edgesByDistance.firstKey()); point = nearestPoints.get(lastEdge); } return point; } SimpleWaySnap(PointFactory factory, final Collection<Edge> edges); NicGeoPoint snap(NicGeoPoint point); }
SimpleWaySnap { public NicGeoPoint snap(NicGeoPoint point) { if (edges != null) { edgesByDistance = new TreeMap<Float, Edge>(); nearestPoints = new HashMap<Edge, NicGeoPoint>(); for (final Edge edge : edges) { final float distance = distance(edge, point); if ((!edgesByDistance.containsKey(distance)) || (edge == lastEdge)) { edgesByDistance.put(distance, edge); } } lastEdge = edgesByDistance.get(edgesByDistance.firstKey()); point = nearestPoints.get(lastEdge); } return point; } SimpleWaySnap(PointFactory factory, final Collection<Edge> edges); NicGeoPoint snap(NicGeoPoint point);  }