moved angle calc to util
This commit is contained in:
parent
9e64eb39c4
commit
68b7ddff5c
5 changed files with 71 additions and 61 deletions
|
|
@ -51,7 +51,7 @@ final class KinematicPrePath extends OsmPrePath
|
|||
|
||||
int dist = rc.calcDistance( lon1, lat1, lon2, lat2 );
|
||||
|
||||
angle = rc.calcAngle( lon0, lat0, lon1, lat1, lon2, lat2 );
|
||||
angle = rc.anglemeter.calcAngle( lon0, lat0, lon1, lat1, lon2, lat2 );
|
||||
priorityclassifier = (int)rc.expctxWay.getPriorityClassifier();
|
||||
classifiermask = (int)rc.expctxWay.getClassifierMask();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -323,8 +323,8 @@ abstract class OsmPath implements OsmLinkHolder
|
|||
lat0 = lat1 - (lat2-lat1);
|
||||
}
|
||||
}
|
||||
double angle = rc.calcAngle( lon0, lat0, lon1, lat1, lon2, lat2 );
|
||||
double cosangle = rc.getCosAngle();
|
||||
double angle = rc.anglemeter.calcAngle( lon0, lat0, lon1, lat1, lon2, lat2 );
|
||||
double cosangle = rc.anglemeter.getCosAngle();
|
||||
|
||||
// *** elevation stuff
|
||||
double delta_h = 0.;
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import btools.expressions.BExpressionContextNode;
|
|||
import btools.expressions.BExpressionContextWay;
|
||||
import btools.mapaccess.GeometryDecoder;
|
||||
import btools.mapaccess.OsmLink;
|
||||
import btools.util.CheapAngleMeter;
|
||||
import btools.util.CheapRuler;
|
||||
|
||||
public final class RoutingContext
|
||||
|
|
@ -194,7 +195,8 @@ public final class RoutingContext
|
|||
public boolean startDirectionValid;
|
||||
public boolean forceUseStartDirection;
|
||||
|
||||
private double cosangle;
|
||||
public CheapAngleMeter anglemeter = new CheapAngleMeter();
|
||||
|
||||
public double nogoCost = 0.;
|
||||
public boolean isEndpoint = false;
|
||||
|
||||
|
|
@ -412,51 +414,6 @@ public final class RoutingContext
|
|||
return (int)(d + 1.0 );
|
||||
}
|
||||
|
||||
public double getCosAngle()
|
||||
{
|
||||
return cosangle;
|
||||
}
|
||||
|
||||
public double calcAngle( int lon0, int lat0, int lon1, int lat1, int lon2, int lat2 )
|
||||
{
|
||||
double[] lonlat2m = CheapRuler.getLonLatToMeterScales( lat1 );
|
||||
double lon2m = lonlat2m[0];
|
||||
double lat2m = lonlat2m[1];
|
||||
double dx10 = (lon1 - lon0) * lon2m;
|
||||
double dy10 = (lat1 - lat0) * lat2m;
|
||||
double dx21 = (lon2 - lon1) * lon2m;
|
||||
double dy21 = (lat2 - lat1) * lat2m;
|
||||
|
||||
double dd = Math.sqrt( (dx10*dx10 + dy10*dy10)*(dx21*dx21 + dy21*dy21) );
|
||||
if ( dd == 0. ) { cosangle = 1.; return 0.; }
|
||||
double sinp = (dy10*dx21 - dx10*dy21)/dd;
|
||||
double cosp = (dy10*dy21 + dx10*dx21)/dd;
|
||||
cosangle = cosp;
|
||||
|
||||
double offset = 0.;
|
||||
double s2 = sinp*sinp;
|
||||
if ( s2 > 0.5 )
|
||||
{
|
||||
if ( sinp > 0. )
|
||||
{
|
||||
offset = 90.;
|
||||
sinp = -cosp;
|
||||
}
|
||||
else
|
||||
{
|
||||
offset = -90.;
|
||||
sinp = cosp;
|
||||
}
|
||||
s2 = cosp*cosp;
|
||||
}
|
||||
else if ( cosp < 0. )
|
||||
{
|
||||
sinp = -sinp;
|
||||
offset = sinp > 0. ? -180. : 180.;
|
||||
}
|
||||
return offset + sinp * ( 57.4539 + s2 * ( 9.57565 + s2 * ( 4.30904 + s2 * 2.56491 ) ) );
|
||||
}
|
||||
|
||||
public OsmPathModel pm;
|
||||
|
||||
public OsmPrePath createPrePath( OsmPath origin, OsmLink link )
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue