public boolean contains(Circle c) { double res = radiusInMeter - c.radiusInMeter; if (res < 0) { return false; } return calc.calcDist(lat, lon, c.lat, c.lon) <= res; }
double fromDist = calc.calcDist(fromLat, fromLon, queryLat, queryLon); if (fromDist < 0) continue; double toLon = nodeAccess.getLongitude(toNode); if (calc.validEdgeDistance(queryLat, queryLon, fromLat, fromLon, toLat, toLon)) { double distEdge = calc.calcDenormalizedDist(calc.calcNormalizedEdgeDistance(queryLat, queryLon, fromLat, fromLon, toLat, toLon)); if (distEdge < foundDist) { res.setClosestNode(node); res.setClosestEdge(iter); if (fromDist > calc.calcDist(toLat, toLon, queryLat, queryLon)) res.setClosestNode(toNode);
void initAlgo(int lat, int lon) { this.latSize = lat; this.lonSize = lon; BBox b = graph.getBounds(); keyAlgo = new LinearKeyAlgo(lat, lon).setBounds(b); double max = Math.max(distCalc.calcDist(b.minLat, b.minLon, b.minLat, b.maxLon), distCalc.calcDist(b.minLat, b.minLon, b.maxLat, b.minLon)); maxRasterWidth2InMeterNormed = distCalc.calcNormalizedDist(max / Math.sqrt(getCapacity()) * 2); // as long as we have "dist < PI*R/2" it is save to compare the normalized distances instead of the real // distances. because sin(x) is only monotonic increasing for x <= PI/2 (and positive for x >= 0) }
public Circle(double lat, double lon, double radiusInMeter, DistanceCalc calc) { this.calc = calc; this.lat = lat; this.lon = lon; this.radiusInMeter = radiusInMeter; this.normedDist = calc.calcNormalizedDist(radiusInMeter); bbox = calc.createBBox(lat, lon, radiusInMeter); }
void prepareAlgo() { equalNormedDelta = distCalc.calcNormalizedDist(0.1); double maxDistInMeter = Math.max( (bounds.maxLat - bounds.minLat) / 360 * DistanceCalcEarth.C, (bounds.maxLon - bounds.minLon) / 360 * preciseDistCalc.calcCircumference(lat)); double tmp = maxDistInMeter / minResolutionInMeter; tmp = tmp * tmp;
double adjLat = nodeAccess.getLatitude(adjNode); double adjLon = nodeAccess.getLongitude(adjNode); double adjDist = distCalc.calcNormalizedDist(adjLat, adjLon, queryLat, queryLon); double wayLon = pointList.getLongitude(pointIndex); QueryResult.Position pos = QueryResult.Position.EDGE; if (distCalc.isCrossBoundary(tmpLon, wayLon)) { tmpLat = wayLat; tmpLon = wayLon; if (distCalc.validEdgeDistance(queryLat, queryLon, tmpLat, tmpLon, wayLat, wayLon)) { tmpNormedDist = distCalc.calcNormalizedEdgeDistance(queryLat, queryLon, tmpLat, tmpLon, wayLat, wayLon); check(tmpClosestNode, tmpNormedDist, pointIndex, currEdge, pos); pos = QueryResult.Position.TOWER; } else { tmpNormedDist = distCalc.calcNormalizedDist(queryLat, queryLon, wayLat, wayLon); pos = QueryResult.Position.PILLAR;
double prevLon = points.getLongitude(0); DistanceCalc distCalc = Helper.DIST_EARTH; double foundMinDistance = distCalc.calcNormalizedDist(lat, lon, prevLat, prevLon); int foundInstruction = 0; if (distCalc.validEdgeDistance(lat, lon, currLat, currLon, prevLat, prevLon)) { distance = distCalc.calcNormalizedEdgeDistance(lat, lon, currLat, currLon, prevLat, prevLon); if (pointIndex > 0) index++; } else { distance = distCalc.calcNormalizedDist(lat, lon, currLat, currLon); if (pointIndex > 0) index++; if (distCalc.calcDenormalizedDist(foundMinDistance) > maxDistance) return null;
if (pointList.is3D()) { ele = pointList.getElevation(i); if (!distCalc.isCrossBoundary(lon, prevLon)) towerNodeDistance += distCalc3D.calcDist(prevLat, prevLon, prevEle, lat, lon, ele); prevEle = ele; } else if (!distCalc.isCrossBoundary(lon, prevLon)) towerNodeDistance += distCalc.calcDist(prevLat, prevLon, lat, lon);
final QueryResult res = new QueryResult(queryLat, queryLon); res.setClosestNode(id); res.setQueryDistance(distCalc.calcNormalizedDist(queryLat, queryLon, mainLat, mainLon)); goFurtherHook(id); new BreadthFirstSearch() { res.setQueryDistance(distCalc.calcDenormalizedDist(res.getQueryDistance())); return res;
/** * maximum distance of discrepancy (from the normal way) in meter */ public DouglasPeucker setMaxDistance(double dist) { this.normedMaxDist = calc.calcNormalizedDist(dist); return this; }
protected double getMaxRasterWidthMeter() { return distCalc.calcDenormalizedDist(maxRasterWidth2InMeterNormed) / 2; }
/** * Calculates the closet point on the edge from the query point. */ public void calcSnappedPoint(DistanceCalc distCalc) { if (closestEdge == null) throw new IllegalStateException("No closest edge?"); if (snappedPoint != null) throw new IllegalStateException("Calculate snapped point only once"); PointList fullPL = getClosestEdge().fetchWayGeometry(3); double tmpLat = fullPL.getLatitude(wayIndex); double tmpLon = fullPL.getLongitude(wayIndex); double tmpEle = fullPL.getElevation(wayIndex); if (snappedPosition != Position.EDGE) { snappedPoint = new GHPoint3D(tmpLat, tmpLon, tmpEle); return; } double queryLat = getQueryPoint().lat, queryLon = getQueryPoint().lon; double adjLat = fullPL.getLatitude(wayIndex + 1), adjLon = fullPL.getLongitude(wayIndex + 1); if (distCalc.validEdgeDistance(queryLat, queryLon, tmpLat, tmpLon, adjLat, adjLon)) { GHPoint tmpPoint = distCalc.calcCrossingPointToEdge(queryLat, queryLon, tmpLat, tmpLon, adjLat, adjLon); double adjEle = fullPL.getElevation(wayIndex + 1); snappedPoint = new GHPoint3D(tmpPoint.lat, tmpPoint.lon, (tmpEle + adjEle) / 2); } else // outside of edge boundaries snappedPoint = new GHPoint3D(tmpLat, tmpLon, tmpEle); }
void addNode(final int nodeA, final int nodeB, final double lat1, final double lon1, final double lat2, final double lon2) { PointEmitter pointEmitter = new PointEmitter() { @Override public void set(double lat, double lon) { long key = keyAlgo.encode(lat, lon); long keyPart = createReverseKey(key); // no need to feed both nodes as we search neighbors in fillIDs addNode(root, nodeA, 0, keyPart, key); } }; if (!distCalc.isCrossBoundary(lon1, lon2)) { BresenhamLine.calcPoints(lat1, lon1, lat2, lon2, pointEmitter, graph.getBounds().minLat, graph.getBounds().minLon, deltaLat, deltaLon); } }
double dist = calc.calcNormalizedEdgeDistance(lat, lon, firstLat, firstLon, lastLat, lastLon); if (maxDist < dist) { indexWithMaxDist = i;
double adjLat = nodeAccess.getLatitude(adjNode); double adjLon = nodeAccess.getLongitude(adjNode); double adjDist = distCalc.calcNormalizedDist(adjLat, adjLon, queryLat, queryLon); double wayLon = pointList.getLongitude(pointIndex); QueryResult.Position pos = QueryResult.Position.EDGE; if (distCalc.isCrossBoundary(tmpLon, wayLon)) { tmpLat = wayLat; tmpLon = wayLon; if (distCalc.validEdgeDistance(queryLat, queryLon, tmpLat, tmpLon, wayLat, wayLon)) { tmpNormedDist = distCalc.calcNormalizedEdgeDistance(queryLat, queryLon, tmpLat, tmpLon, wayLat, wayLon); check(tmpClosestNode, tmpNormedDist, pointIndex, currEdge, pos); pos = QueryResult.Position.TOWER; } else { tmpNormedDist = distCalc.calcNormalizedDist(queryLat, queryLon, wayLat, wayLon); pos = QueryResult.Position.PILLAR;
double prevLon = points.getLongitude(0); DistanceCalc distCalc = Helper.DIST_EARTH; double foundMinDistance = distCalc.calcNormalizedDist(lat, lon, prevLat, prevLon); int foundInstruction = 0; if (distCalc.validEdgeDistance(lat, lon, currLat, currLon, prevLat, prevLon)) { distance = distCalc.calcNormalizedEdgeDistance(lat, lon, currLat, currLon, prevLat, prevLon); if (pointIndex > 0) index++; } else { distance = distCalc.calcNormalizedDist(lat, lon, currLat, currLon); if (pointIndex > 0) index++; if (distCalc.calcDenormalizedDist(foundMinDistance) > maxDistance) return null;
if (pointList.is3D()) { ele = pointList.getElevation(i); if (!distCalc.isCrossBoundary(lon, prevLon)) towerNodeDistance += distCalc3D.calcDist(prevLat, prevLon, prevEle, lat, lon, ele); prevEle = ele; } else if (!distCalc.isCrossBoundary(lon, prevLon)) towerNodeDistance += distCalc.calcDist(prevLat, prevLon, lat, lon);
final double returnAllResultsWithin = distCalc.calcNormalizedDist(radius); if (qr.isValid()) { qr.setQueryDistance(distCalc.calcDenormalizedDist(qr.getQueryDistance())); qr.calcSnappedPoint(distCalc); } else {
private double normDist(double lat1, double lon1) { return calc.calcNormalizedDist(lat, lon, lat1, lon1); }
public Circle( double lat, double lon, double radiusInMeter, DistanceCalc calc ) { this.calc = calc; this.lat = lat; this.lon = lon; this.radiusInKm = radiusInMeter; this.normedDist = calc.calcNormalizedDist(radiusInMeter); bbox = calc.createBBox(lat, lon, radiusInMeter); }