-
Notifications
You must be signed in to change notification settings - Fork 0
Directional Filter and Unnamed Fallback Refinements #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
| Point furthestPointOfSecondPath = getTerminalPoint(lineStrings.get(lineStrings.size() - 1), buildUpstream); | ||
|
|
||
| boolean selectFirstPath = true; | ||
| boolean isNonCardinal = !CARDINAL_DIRECTIONS.contains(direction); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
halfThresholdDistanceInDegrees is an unclear name since we have two different kinds of degrees at play here: lat/long degrees (which are the degrees being used) and bearing degrees (which are not the degrees being used).
Also, that value will be fine for latitude but isn't great for longitude inside the United States. At the southern tip of Texas, you get 100,000 meters per degree longitude but at northern tip of Maine it is only 75,000. This may or may not be that important to what you are doing but a better 'general' number of meters per degree might be 95,000 or 93,000 or something. But, 111,200 might be close enough for what you are doing here.
| switch (direction) { | ||
| case NORTH: | ||
| case SOUTH: | ||
| // Default to the first path if Y difference < threshold (paths too horizontal for N/S determination) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this comment means to say, 'difference < halfThresholdInDegrees'
| break; | ||
| case EAST: | ||
| case WEST: | ||
| // Default to the first path if X difference < threshold (paths too vertical for E/W determination) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this comment means to say, 'difference < halfThresholdInDegrees'
| break; | ||
| } | ||
|
|
||
| if (isNonCardinal) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless I am wrong, (and I might be wrong), the angle at which yDiff or xDiff will be < halfThresholdInDegrees is about 60 degrees off of the true cardinal direction. So a road that is at angle 59 (which is 59 degrees off of exact north since 'straight north' is zero) would be successfully determined to be 'North' and a road at 61 degrees would default to first path.
In that case, it is easy to adjust the non-cardinal directions to have this same amount of leniency.
(Double check that I haven't made any boneheaded mistakes) the following should work:
if (isNonCardinal) {
// For non-cardinal directions: Calculate bearing between terminal points for better direction accuracy.
// Splits the circle into two halves and checks if the angle is within the specified half.
int bearing = (int) Math.round(AngleCalc.ANGLE_CALC.calcAzimuth(
furthestPointOfFirstPath.getY(), furthestPointOfFirstPath.getX(),
furthestPointOfSecondPath.getY(),furthestPointOfSecondPath.getX()));
switch (direction) {
case NORTHEAST:
selectFirstPath = bearing >= BEARING_DUE_NORTHWEST + 30 || bearing <= BEARING_DUE_SOUTHEAST - 30;
break;
case SOUTHWEST:
selectFirstPath = bearing > BEARING_DUE_SOUTHEAST + 30 && bearing < BEARING_DUE_NORTHWEST - 30;
break;
case NORTHWEST:
selectFirstPath = bearing >= BEARING_DUE_SOUTHWEST + 30 || bearing <= BEARING_DUE_NORTHEAST - 30;
break;
case SOUTHEAST:
selectFirstPath = bearing > BEARING_DUE_NORTHEAST + 30 && bearing < BEARING_DUE_SOUTHWEST - 30;
break;
default:
break;
}
}
|
|
||
| boolean selectFirstPath = true; | ||
| boolean isNonCardinal = !CARDINAL_DIRECTIONS.contains(direction); | ||
| double halfThresholdInDegrees = thresholdDistance / 2 / DistanceCalcEarth.METERS_PER_DEGREE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A better 'cheap' solution for the difference between meters in lat and long would be to use this value (111,194) for north-south, and either:
- use 87,500 for east-west or
- have a small lookup table with maybe five values in it so that you were using 75,000 for the xDiff if the lat was around 54, 80,000 for xDiff if the lat was around (something-or-other> all the way down to 100,000 if the lat was around 26 (Brownsville, Texas).
Summary
Solution