@Override public void finish() { if (prevInRoundabout) { // calc angle between roundabout entrance and finish double orientation = Helper.ANGLE_CALC.calcOrientation(doublePrevLat, doublePrevLon, prevLat, prevLon); orientation = Helper.ANGLE_CALC.alignOrientation(prevOrientation, orientation); double delta = (orientation - prevOrientation); ((RoundaboutInstruction) prevInstruction).setRadian(delta); } Instruction finishInstruction = new FinishInstruction(nodeAccess, prevEdge.getAdjNode()); // This is the heading how the edge ended finishInstruction.setExtraInfo("last_heading", Helper.ANGLE_CALC.calcAzimuth(doublePrevLat, doublePrevLon, prevLat, prevLon)); ways.add(finishInstruction); }
/** * Return the direction like 'NE' based on the first tracksegment of the instruction. If * Instruction does not contain enough coordinate points, an empty string will be returned. */ String calcDirection(Instruction nextI) { double azimuth = calcAzimuth(nextI); if (Double.isNaN(azimuth)) return ""; return AC.azimuth2compassPoint(azimuth); }
favoredHeading = AC.convertAzimuth2xaxisAngle(favoredHeading); if (incoming) { int numWayPoints = wayGeo.getSize(); edgeOrientation = AC.calcOrientation(wayGeo.getLat(numWayPoints - 2), wayGeo.getLon(numWayPoints - 2), wayGeo.getLat(numWayPoints - 1), wayGeo.getLon(numWayPoints - 1)); } else { edgeOrientation = AC.calcOrientation(wayGeo.getLat(0), wayGeo.getLon(0), wayGeo.getLat(1), wayGeo.getLon(1)); edgeOrientation = AC.alignOrientation(favoredHeading, edgeOrientation); double delta = (edgeOrientation - favoredHeading);
static double calculateOrientationDelta(double prevLatitude, double prevLongitude, double latitude, double longitude, double prevOrientation) { double orientation = Helper.ANGLE_CALC.calcOrientation(prevLatitude, prevLongitude, latitude, longitude, false); orientation = Helper.ANGLE_CALC.alignOrientation(prevOrientation, orientation); return orientation - prevOrientation; }
public double calcOrientation(double lat1, double lon1, double lat2, double lon2) { return calcOrientation(lat1, lon1, lat2, lon2, true); }
/** * Return the azimuth in degree based on the first tracksegment of this instruction. If this * instruction contains less than 2 points then NaN will be returned or the specified * instruction will be used if that is the finish instruction. */ public double calcAzimuth(Instruction nextI) { double nextLat; double nextLon; if (points.getSize() >= 2) { nextLat = points.getLatitude(1); nextLon = points.getLongitude(1); } else if (nextI != null && points.getSize() == 1) { nextLat = nextI.points.getLatitude(0); nextLon = nextI.points.getLongitude(0); } else { return Double.NaN; } double lat = points.getLatitude(0); double lon = points.getLongitude(0); return AC.calcAzimuth(lat, lon, nextLat, nextLon); }
/** * Return orientation of line relative to east. * <p> * * @param exact If false the atan gets calculated faster, but it might contain small errors * @return Orientation in interval -pi to +pi where 0 is east */ public double calcOrientation(double lat1, double lon1, double lat2, double lon2, boolean exact) { double shrinkFactor = cos(toRadians((lat1 + lat2) / 2)); if (exact) return Math.atan2(lat2 - lat1, shrinkFactor * (lon2 - lon1)); else return atan2(lat2 - lat1, shrinkFactor * (lon2 - lon1)); }
private double getAngle(int n1, int n2, int n3, int n4) { double inOrientation = Helper.ANGLE_CALC.calcOrientation(na.getLat(n1), na.getLon(n1), na.getLat(n2), na.getLon(n2)); double outOrientation = Helper.ANGLE_CALC.calcOrientation(na.getLat(n3), na.getLon(n3), na.getLat(n4), na.getLon(n4)); outOrientation = Helper.ANGLE_CALC.alignOrientation(inOrientation, outOrientation); double delta = (inOrientation - outOrientation); delta = clockwise ? (Math.PI + delta) : -1 * (Math.PI - delta); return delta; } }
/** * Calculate the azimuth in degree for a line given by two coordinates. Direction in 'degree' * where 0 is north, 90 is east, 180 is south and 270 is west. */ public double calcAzimuth(double lat1, double lon1, double lat2, double lon2) { double orientation = Math.PI / 2 - calcOrientation(lat1, lon1, lat2, lon2); if (orientation < 0) orientation += 2 * Math.PI; return Math.toDegrees(Helper.round4(orientation)) % 360; }
/** * Return the azimuth in degree based on the first tracksegment of this instruction. If this * instruction contains less than 2 points then NaN will be returned or the specified * instruction will be used if that is the finish instruction. */ public double calcAzimuth(Instruction nextI) { double nextLat; double nextLon; if (points.getSize() >= 2) { nextLat = points.getLatitude(1); nextLon = points.getLongitude(1); } else if (nextI != null && points.getSize() == 1) { nextLat = nextI.points.getLatitude(0); nextLon = nextI.points.getLongitude(0); } else { return Double.NaN; } double lat = points.getLatitude(0); double lon = points.getLongitude(0); return AC.calcAzimuth(lat, lon, nextLat, nextLon); }
/** * Return orientation of line relative to east. * <p> * * @param exact If false the atan gets calculated faster, but it might contain small errors * @return Orientation in interval -pi to +pi where 0 is east */ public double calcOrientation(double lat1, double lon1, double lat2, double lon2, boolean exact) { double shrinkFactor = cos(toRadians((lat1 + lat2) / 2)); if (exact) return Math.atan2(lat2 - lat1, shrinkFactor * (lon2 - lon1)); else return atan2(lat2 - lat1, shrinkFactor * (lon2 - lon1)); }
double startLat = nodeAccess.getLat(baseNode); double startLon = nodeAccess.getLon(baseNode); double heading = Helper.ANGLE_CALC.calcAzimuth(startLat, startLon, latitude, longitude); prevInstruction.setExtraInfo("heading", Helper.round(heading, 2)); ways.add(prevInstruction); prevOrientation = Helper.ANGLE_CALC.calcOrientation(doublePrevLat, doublePrevLon, prevLat, prevLon); double orientation = Helper.ANGLE_CALC.calcOrientation(prevLat, prevLon, latitude, longitude); orientation = Helper.ANGLE_CALC.alignOrientation(prevOrientation, orientation); double delta = (orientation - prevOrientation); roundaboutInstruction.setDirOfRotation(delta); prevOrientation = Helper.ANGLE_CALC.calcOrientation(prevLat, prevLon, latitude, longitude); prevName = name; prevAnnotation = annotation; double orientation = Helper.ANGLE_CALC.calcOrientation(prevLat, prevLon, latitude, longitude); orientation = Helper.ANGLE_CALC.alignOrientation(prevOrientation, orientation); double deltaInOut = (orientation - prevOrientation); double recentOrientation = Helper.ANGLE_CALC.calcOrientation(doublePrevLat, doublePrevLon, prevLat, prevLon); orientation = Helper.ANGLE_CALC.alignOrientation(recentOrientation, orientation); double deltaOut = (orientation - recentOrientation); double lat = point.getLat(); double lon = point.getLon(); double currentOrientation = Helper.ANGLE_CALC.calcOrientation(prevLat, prevLon, lat, lon, false);
favoredHeading = AC.convertAzimuth2xaxisAngle(favoredHeading); if (incoming) { int numWayPoints = wayGeo.getSize(); edgeOrientation = AC.calcOrientation(wayGeo.getLat(numWayPoints - 2), wayGeo.getLon(numWayPoints - 2), wayGeo.getLat(numWayPoints - 1), wayGeo.getLon(numWayPoints - 1)); } else { edgeOrientation = AC.calcOrientation(wayGeo.getLat(0), wayGeo.getLon(0), wayGeo.getLat(1), wayGeo.getLon(1)); edgeOrientation = AC.alignOrientation(favoredHeading, edgeOrientation); double delta = (edgeOrientation - favoredHeading);
static double calculateOrientationDelta(double prevLatitude, double prevLongitude, double latitude, double longitude, double prevOrientation) { double orientation = Helper.ANGLE_CALC.calcOrientation(prevLatitude, prevLongitude, latitude, longitude, false); orientation = Helper.ANGLE_CALC.alignOrientation(prevOrientation, orientation); return orientation - prevOrientation; }
double lat = point.getLat(); double lon = point.getLon(); prevOrientation = Helper.ANGLE_CALC.calcOrientation(doublePrevLat, doublePrevLon, prevLat, prevLon); int sign = InstructionsHelper.calculateSign(prevLat, prevLon, lat, lon, prevOrientation);
/** * Return the azimuth in degree based on the first tracksegment of this instruction. If this * instruction contains less than 2 points then NaN will be returned or the specified * instruction will be used if that is the finish instruction. */ public double calcAzimuth(Instruction nextI) { double nextLat; double nextLon; if (points.getSize() >= 2) { nextLat = points.getLatitude(1); nextLon = points.getLongitude(1); } else if (nextI != null && points.getSize() == 1) { nextLat = nextI.points.getLatitude(0); nextLon = nextI.points.getLongitude(0); } else { return Double.NaN; } double lat = points.getLatitude(0); double lon = points.getLongitude(0); return AC.calcAzimuth(lat, lon, nextLat, nextLon); }
/** * Return the direction like 'NE' based on the first tracksegment of the instruction. If * Instruction does not contain enough coordinate points, an empty string will be returned. */ String calcDirection( Instruction nextI ) { double azimuth = calcAzimuth(nextI); if (Double.isNaN(azimuth)) return ""; return AC.azimuth2compassPoint(azimuth); }
@Override public void finish() { if (prevInRoundabout) { // calc angle between roundabout entrance and finish double orientation = Helper.ANGLE_CALC.calcOrientation(doublePrevLat, doublePrevLon, prevLat, prevLon); orientation = Helper.ANGLE_CALC.alignOrientation(prevOrientation, orientation); double delta = (orientation - prevOrientation); ((RoundaboutInstruction) prevInstruction).setRadian(delta); } Instruction finishInstruction = new FinishInstruction(nodeAccess, prevEdge.getAdjNode()); // This is the heading how the edge ended finishInstruction.setExtraInfo("last_heading", Helper.ANGLE_CALC.calcAzimuth(doublePrevLat, doublePrevLon, prevLat, prevLon)); ways.add(finishInstruction); }
favoredHeading = AC.convertAzimuth2xaxisAngle(favoredHeading); if (incoming) { int numWayPoints = wayGeo.getSize(); edgeOrientation = AC.calcOrientation(wayGeo.getLat(numWayPoints - 2), wayGeo.getLon(numWayPoints - 2), wayGeo.getLat(numWayPoints - 1), wayGeo.getLon(numWayPoints - 1)); } else { edgeOrientation = AC.calcOrientation(wayGeo.getLat(0), wayGeo.getLon(0), wayGeo.getLat(1), wayGeo.getLon(1)); edgeOrientation = AC.alignOrientation(favoredHeading, edgeOrientation); double delta = (edgeOrientation - favoredHeading);
prevOrientation = AC.calcOrientation(doublePrevLat, doublePrevLong, prevLat, prevLon); double orientation = AC.calcOrientation(prevLat, prevLon, latitude, longitude); orientation = AC.alignOrientation(prevOrientation, orientation); double delta = (orientation - prevOrientation); roundaboutInstruction.setDirOfRotation(delta); prevOrientation = AC.calcOrientation(prevLat, prevLon, latitude, longitude); prevName = name; prevAnnotation = annotation; double orientation = AC.calcOrientation(prevLat, prevLon, latitude, longitude); orientation = AC.alignOrientation(prevOrientation, orientation); double deltaInOut = (orientation - prevOrientation); double recentOrientation = AC.calcOrientation(doublePrevLat, doublePrevLong, prevLat, prevLon); orientation = AC.alignOrientation(recentOrientation, orientation); double deltaOut = (orientation - recentOrientation); prevOrientation = AC.calcOrientation(doublePrevLat, doublePrevLong, prevLat, prevLon); double orientation = AC.calcOrientation(prevLat, prevLon, latitude, longitude); orientation = AC.alignOrientation(prevOrientation, orientation); double delta = orientation - prevOrientation; double absDelta = Math.abs(delta); double orientation = AC.calcOrientation(doublePrevLat, doublePrevLong, prevLat, prevLon); orientation = AC.alignOrientation(prevOrientation, orientation); double delta = (orientation - prevOrientation); ((RoundaboutInstruction) prevInstruction).setRadian(delta);