Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2012-09-06 12:00:18 +02:00
commit 99d8c2ebf8
3 changed files with 67 additions and 33 deletions

View file

@ -229,8 +229,19 @@ public class RouteDataObject {
}
px = getPoint31XTile(nx);
py = getPoint31YTile(nx);
total += Math.abs(px - x) + Math.abs(py - y);
} while (total < 100);
// translate into meters
total += Math.abs(px - x) * 0.011d + Math.abs(py - y) * 0.01863d;
// Victor : the problem to put more than 5 meters that BinaryRoutePlanner will treat
// 2 consequent Turn Right as UT and here 2 points will have same turn angle
// So it should be fix in both places
} while (total < 5);
return -Math.atan2( x - px, y - py );
}
@Override
public String toString() {
String name = getName();
String rf = getRef();
return String.format("Road id %s name %s ref %s", getId()+"", name == null ? "" : name, rf == null ? "" : rf);
}
}

View file

@ -41,6 +41,7 @@ public class BinaryRoutePlanner {
protected static final Log log = LogUtil.getLog(BinaryRoutePlanner.class);
private static final int ROUTE_POINTS = 11;
private static final float TURN_DEGREE_MIN = 45;
public BinaryRoutePlanner(NativeLibrary nativeLib, BinaryMapIndexReader... map) {
@ -776,7 +777,6 @@ public class BinaryRoutePlanner {
return false;
}
private static final float TURN_DEGREE_MIN = 45;
/**
* Helper method to prepare final result
@ -982,12 +982,16 @@ public class BinaryRoutePlanner {
}
}
private boolean highwayLowEnd(String highway) {
if (highway == null || highway.endsWith("_link") || highway.endsWith("services") || highway.endsWith("service")
|| highway.endsWith("unclassified") || highway.endsWith("road")) {
return true;
private static final int MAX_SPEAK_PRIORITY = 5;
private int highwaySpeakPriority(String highway) {
if(highway == null || highway.endsWith("track") || highway.endsWith("services") || highway.endsWith("service")
|| highway.endsWith("path")) {
return MAX_SPEAK_PRIORITY;
}
return false;
if (highway.endsWith("_link") || highway.endsWith("unclassified") || highway.endsWith("road") ) {
return 1;
}
return 0;
}
@ -1078,25 +1082,29 @@ public class BinaryRoutePlanner {
int ls = prev.getObject().getLanes();
int left = 0;
int right = 0;
boolean speak = highwayLowEnd(prev.getObject().getHighway()) || highwayLowEnd(rr.getObject().getHighway());
if(attachedRoutes != null){
for(RouteSegmentResult rs : attachedRoutes){
boolean speak = false;
int speakPriority = Math.max(highwaySpeakPriority(prev.getObject().getHighway()), highwaySpeakPriority(rr.getObject().getHighway()));
if (attachedRoutes != null) {
for (RouteSegmentResult rs : attachedRoutes) {
double ex = MapUtils.degreesDiff(rs.getBearingBegin(), rr.getBearingBegin());
double mpi = Math.abs(MapUtils.degreesDiff(prev.getBearingEnd(), rs.getBearingBegin())) ;
if((ex < TURN_DEGREE_MIN || mpi < TURN_DEGREE_MIN) && ex >= 0) {
kl = true;
int lns = rs.getObject().getLanes();
if (lns > 0) {
right += lns;
double mpi = Math.abs(MapUtils.degreesDiff(prev.getBearingEnd(), rs.getBearingBegin()));
int rsSpeakPriority = highwaySpeakPriority(rs.getObject().getHighway());
if (rsSpeakPriority != MAX_SPEAK_PRIORITY || speakPriority == MAX_SPEAK_PRIORITY) {
if ((ex < TURN_DEGREE_MIN || mpi < TURN_DEGREE_MIN) && ex >= 0) {
kl = true;
int lns = rs.getObject().getLanes();
if (lns > 0) {
right += lns;
}
speak = speak || rsSpeakPriority <= speakPriority;
} else if ((ex > -TURN_DEGREE_MIN || mpi < TURN_DEGREE_MIN) && ex <= 0) {
kr = true;
int lns = rs.getObject().getLanes();
if (lns > 0) {
left += lns;
}
speak = speak || rsSpeakPriority <= speakPriority;
}
speak = speak || !highwayLowEnd(rs.getObject().getHighway());
} else if((ex > -TURN_DEGREE_MIN || mpi < TURN_DEGREE_MIN) && ex <= 0) {
kr = true;
int lns = rs.getObject().getLanes();
if (lns > 0) {
left += lns;
}
speak = speak || !highwayLowEnd(rs.getObject().getHighway());
}
}
}
@ -1128,18 +1136,24 @@ public class BinaryRoutePlanner {
t = TurnType.valueOf(TurnType.KR, leftSide);
t.setSkipToSpeak(!speak);
}
if (t!= null && lanes != null) {
if (t != null && lanes != null) {
t.setLanes(lanes);
}
return t;
}
private long getPoint(RouteDataObject road, int pointInd) {
return (((long) road.getPoint31XTile(pointInd)) << 31) + (long) road.getPoint31YTile(pointInd);
}
private void attachRoadSegments(RoutingContext ctx, List<RouteSegmentResult> result, int routeInd, int pointInd, boolean plus) {
RouteSegmentResult rr = result.get(routeInd);
RouteDataObject road = rr.getObject();
RoutingTile tl = loadRoutes(ctx, road.getPoint31XTile(pointInd), road.getPoint31YTile(pointInd));
long l = (((long) road.getPoint31XTile(pointInd)) << 31) + (long) road.getPoint31YTile(pointInd);
long l = getPoint(road, pointInd);
long nextL = pointInd < road.getPointsLength() - 1 ? getPoint(road, pointInd + 1) : 0;
long prevL = pointInd > 0 ? getPoint(road, pointInd - 1) : 0;
// attach additional roads to represent more information about the route
RouteSegmentResult previousResult = null;
@ -1165,13 +1179,22 @@ public class BinaryRoutePlanner {
while (routeSegment != null) {
if (routeSegment.road.getId() != road.getId() && routeSegment.road.getId() != previousRoadId) {
RouteDataObject addRoad = routeSegment.road;
// TODO restrictions can be considered as well
int oneWay = ctx.getRouter().isOneWay(addRoad);
if (oneWay >= 0 && routeSegment.segmentStart < addRoad.getPointsLength() - 1) {
rr.attachRoute(pointInd, new RouteSegmentResult(addRoad, routeSegment.segmentStart, addRoad.getPointsLength() - 1));
long pointL = getPoint(addRoad, routeSegment.segmentStart + 1);
if(pointL != nextL && pointL != prevL) {
// if way contains same segment (nodes) as different way (do not attach it)
rr.attachRoute(pointInd, new RouteSegmentResult(addRoad, routeSegment.segmentStart, addRoad.getPointsLength() - 1));
}
}
if (oneWay <= 0 && routeSegment.segmentStart > 0) {
rr.attachRoute(pointInd, new RouteSegmentResult(addRoad, routeSegment.segmentStart, 0));
long pointL = getPoint(addRoad, routeSegment.segmentStart - 1);
// if way contains same segment (nodes) as different way (do not attach it)
if(pointL != nextL && pointL != prevL) {
rr.attachRoute(pointInd, new RouteSegmentResult(addRoad, routeSegment.segmentStart, 0));
}
}
}
routeSegment = routeSegment.next;

View file

@ -658,7 +658,7 @@
<string name="invalid_locations">Les coordenades no son valides!</string>
<string name="saving_gpx_tracks">Guardant seguiments GPX a la SD…</string>
<string name="download_indexes">Baixar informació fora de linía</string>
<string name="osm_settings">Edició d'OSM</string>
<string name="osm_settings">Edició d\'OSM</string>
<string name="save_track_interval">Interval de mostreig</string>
<string name="additional_settings">Preferències adiccionals</string>
<string name="data_settings_descr">Especifica llengua,baixa/recarrega dades</string>
@ -678,16 +678,16 @@
<string name="choose_available_region">Escull regió de la llista</string>
<string name="search_POI_level_btn">Cercar més</string>
<string name="map_source">Font de mapes</string>
<string name="show_poi_over_map_description">Mostrar PDI sobre el mapa(usa l'ultim filtre escollit)</string>
<string name="show_poi_over_map_description">Mostrar PDI sobre el mapa(usa l\'ultim filtre escollit)</string>
<string name="use_internet">Usa Internet</string>
<string name="favorites_Button">Preferit</string>
<string name="search_address_top_text">Escull adreça</string>
<string name="context_menu_item_add_favorite">Afegir a preferits</string>
<string name="favourites_context_menu_edit">Editar preferit</string>
<string name="favourites_context_menu_delete">Eliminar preferit</string>
<string name="osb_add_dialog_title">Entrar text d'error</string>
<string name="osb_add_dialog_title">Entrar text d\'error</string>
<string name="osb_close_dialog_success">Error tancat correctement</string>
<string name="osb_comment_dialog_title">Afegint comentari a l'error</string>
<string name="osb_comment_dialog_title">Afegint comentari a l\'error</string>
<string name="poi_edit_title">Editar PDI</string>
<string name="poi_remove_title">Eliminar PDI</string>
<string name="poi_create_title">Crear PDI</string>