Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
d720fab63f
7 changed files with 70 additions and 30 deletions
|
@ -147,7 +147,10 @@ public class GeneralRouter implements VehicleRouter {
|
|||
public GeneralRouterProfile getProfile() {
|
||||
return profile;
|
||||
}
|
||||
|
||||
|
||||
public boolean getHeightObstacles() {
|
||||
return heightObstacles;
|
||||
}
|
||||
|
||||
public Map<String, RoutingParameter> getParameters() {
|
||||
return parameters;
|
||||
|
|
|
@ -25,6 +25,7 @@ import net.osmand.osm.MapRenderingTypes;
|
|||
import net.osmand.router.BinaryRoutePlanner.FinalRouteSegment;
|
||||
import net.osmand.router.BinaryRoutePlanner.RouteSegment;
|
||||
import net.osmand.router.RoutePlannerFrontEnd.RouteCalculationMode;
|
||||
import net.osmand.router.GeneralRouter.GeneralRouterProfile;
|
||||
import net.osmand.util.Algorithms;
|
||||
import net.osmand.util.MapUtils;
|
||||
|
||||
|
@ -108,6 +109,9 @@ public class RouteResultPreparation {
|
|||
}
|
||||
|
||||
private void calculateTimeSpeed(RoutingContext ctx, List<RouteSegmentResult> result) throws IOException {
|
||||
//for Naismith
|
||||
boolean usePedestrianHeight = ((((GeneralRouter) ctx.getRouter()).getProfile() == GeneralRouterProfile.PEDESTRIAN) && ((GeneralRouter) ctx.getRouter()).getHeightObstacles());
|
||||
|
||||
for (int i = 0; i < result.size(); i++) {
|
||||
RouteSegmentResult rr = result.get(i);
|
||||
RouteDataObject road = rr.getObject();
|
||||
|
@ -125,6 +129,15 @@ public class RouteResultPreparation {
|
|||
boolean plus = rr.getStartPointIndex() < rr.getEndPointIndex();
|
||||
int next;
|
||||
double distance = 0;
|
||||
|
||||
//for Naismith
|
||||
float prevHeight = -99999.0f;
|
||||
float[] heightDistanceArray = null;
|
||||
if (usePedestrianHeight) {
|
||||
road.calculateHeightArray();
|
||||
heightDistanceArray = road.heightDistanceArray;
|
||||
}
|
||||
|
||||
for (int j = rr.getStartPointIndex(); j != rr.getEndPointIndex(); j = next) {
|
||||
next = plus ? j + 1 : j - 1;
|
||||
double d = measuredDist(road.getPoint31XTile(j), road.getPoint31YTile(j), road.getPoint31XTile(next),
|
||||
|
@ -134,9 +147,24 @@ public class RouteResultPreparation {
|
|||
if (obstacle < 0) {
|
||||
obstacle = 0;
|
||||
}
|
||||
distOnRoadToPass += d / speed + obstacle;
|
||||
distOnRoadToPass += d / speed + obstacle; //this is time in seconds
|
||||
|
||||
//for Naismith
|
||||
if (usePedestrianHeight) {
|
||||
int heightIndex = 2 * j + 1;
|
||||
if (heightDistanceArray != null && heightIndex < heightDistanceArray.length) {
|
||||
float height = heightDistanceArray[heightIndex];
|
||||
if (prevHeight != -99999.0f) {
|
||||
float heightDiff = height - prevHeight;
|
||||
if (heightDiff > 0) { //ascent only
|
||||
distOnRoadToPass += heightDiff * 6.0f; //Naismith's rule: add 1 hour per every 600m of ascent
|
||||
}
|
||||
}
|
||||
prevHeight = height;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// last point turn time can be added
|
||||
// if(i + 1 < result.size()) { distOnRoadToPass += ctx.getRouter().calculateTurnTime(); }
|
||||
rr.setSegmentTime((float) distOnRoadToPass);
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
osmand:typeface="@string/font_roboto_medium"/>
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/empty_search_description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="4dp"
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
||||
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
||||
-->
|
||||
<string name="modify_the_search_query">Modify the search query.</string>
|
||||
<string name="empty_state_osm_edits">Create or modify OSM objects</string>
|
||||
<string name="empty_state_osm_edits_descr">Create or modify OSM POI, open or comment OSM Notes, and contribute recorded GPX files.</string>
|
||||
<string name="shared_string_deleted">Deleted</string>
|
||||
|
|
|
@ -761,7 +761,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
paused = false;
|
||||
hidden = false;
|
||||
if (interruptedSearch) {
|
||||
addMoreButton();
|
||||
addMoreButton(true);
|
||||
interruptedSearch = false;
|
||||
}
|
||||
}
|
||||
|
@ -1066,9 +1066,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
}
|
||||
if (getResultCollection() != null) {
|
||||
updateSearchResult(getResultCollection(), false);
|
||||
if (interruptedSearch || searchUICore.isSearchMoreAvailable(searchUICore.getPhrase())) {
|
||||
addMoreButton();
|
||||
}
|
||||
addMoreButton(searchUICore.isSearchMoreAvailable(searchUICore.getPhrase()));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1537,9 +1535,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
searching = false;
|
||||
if (resultListener == null || resultListener.searchFinished(object.requiredSearchPhrase)) {
|
||||
hideProgressBar();
|
||||
if (searchUICore.isSearchMoreAvailable(object.requiredSearchPhrase)) {
|
||||
addMoreButton();
|
||||
}
|
||||
addMoreButton(searchUICore.isSearchMoreAvailable(object.requiredSearchPhrase));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -1741,7 +1737,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
}
|
||||
}
|
||||
|
||||
private void addMoreButton() {
|
||||
private void addMoreButton(boolean searchMoreAvailable) {
|
||||
if (!paused && !cancelPrev && mainSearchFragment != null && !isTextEmpty()) {
|
||||
QuickSearchMoreListItem moreListItem =
|
||||
new QuickSearchMoreListItem(app, null, new SearchMoreItemOnClickListener() {
|
||||
|
@ -1765,6 +1761,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
moreListItem.setInterruptedSearch(interruptedSearch);
|
||||
moreListItem.setEmptySearch(isResultEmpty());
|
||||
moreListItem.setOnlineSearch(isOnlineSearch());
|
||||
moreListItem.setSearchMoreAvailable(searchMoreAvailable);
|
||||
mainSearchFragment.addListItem(moreListItem);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,16 +20,13 @@ import net.osmand.access.AccessibilityAssistant;
|
|||
import net.osmand.data.Amenity;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.dashboard.DashLocationFragment;
|
||||
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
|
||||
import net.osmand.plus.search.listitems.QuickSearchHeaderListItem;
|
||||
import net.osmand.plus.search.listitems.QuickSearchListItem;
|
||||
import net.osmand.plus.search.listitems.QuickSearchListItemType;
|
||||
import net.osmand.plus.search.listitems.QuickSearchMoreListItem;
|
||||
import net.osmand.plus.search.listitems.QuickSearchSelectAllListItem;
|
||||
import net.osmand.search.core.ObjectType;
|
||||
import net.osmand.search.core.SearchPhrase;
|
||||
import net.osmand.util.Algorithms;
|
||||
import net.osmand.util.OpeningHoursParser;
|
||||
|
@ -215,10 +212,8 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
|
|||
LinearLayout view;
|
||||
if (type == QuickSearchListItemType.SEARCH_MORE) {
|
||||
if (convertView == null) {
|
||||
LayoutInflater inflater = (LayoutInflater) app
|
||||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
view = (LinearLayout) inflater.inflate(
|
||||
R.layout.search_more_list_item, null);
|
||||
LayoutInflater inflater = (LayoutInflater) app.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
view = (LinearLayout) inflater.inflate(R.layout.search_more_list_item, null);
|
||||
} else {
|
||||
view = (LinearLayout) convertView;
|
||||
}
|
||||
|
@ -228,26 +223,32 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
|
|||
} else {
|
||||
((TextView) view.findViewById(R.id.title)).setText(listItem.getName());
|
||||
}
|
||||
QuickSearchMoreListItem searchMoreListItem = (QuickSearchMoreListItem) listItem;
|
||||
if (searchMoreListItem.isEmptySearch() && !searchMoreListItem.isInterruptedSearch()) {
|
||||
view.findViewById(R.id.empty_search).setVisibility(View.VISIBLE);
|
||||
view.findViewById(R.id.more_divider).setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
view.findViewById(R.id.empty_search).setVisibility(View.GONE);
|
||||
view.findViewById(R.id.more_divider).setVisibility(View.GONE);
|
||||
}
|
||||
view.findViewById(R.id.increase_radius_row).setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
final QuickSearchMoreListItem searchMoreItem = (QuickSearchMoreListItem) listItem;
|
||||
int emptyDescId = searchMoreItem.isSearchMoreAvailable() ? R.string.nothing_found_descr : R.string.modify_the_search_query;
|
||||
((TextView) view.findViewById(R.id.empty_search_description)).setText(emptyDescId);
|
||||
|
||||
boolean emptySearchVisible = searchMoreItem.isEmptySearch() && !searchMoreItem.isInterruptedSearch();
|
||||
boolean moreDividerVisible = emptySearchVisible && searchMoreItem.isSearchMoreAvailable();
|
||||
view.findViewById(R.id.empty_search).setVisibility(emptySearchVisible ? View.VISIBLE : View.GONE);
|
||||
view.findViewById(R.id.more_divider).setVisibility(moreDividerVisible ? View.VISIBLE : View.GONE);
|
||||
|
||||
View increaseRadiusRow = view.findViewById(R.id.increase_radius_row);
|
||||
increaseRadiusRow.setVisibility(searchMoreItem.isSearchMoreAvailable() ? View.VISIBLE : View.GONE);
|
||||
increaseRadiusRow.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
((QuickSearchMoreListItem) listItem).increaseRadiusOnClick();
|
||||
}
|
||||
});
|
||||
if (!searchMoreListItem.isOnlineSearch()) {
|
||||
view.findViewById(R.id.online_search_row).setVisibility(View.VISIBLE);
|
||||
view.findViewById(R.id.online_search_row).setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
if (!searchMoreItem.isOnlineSearch()) {
|
||||
View onlineSearchRow = view.findViewById(R.id.online_search_row);
|
||||
onlineSearchRow.setVisibility(View.VISIBLE);
|
||||
onlineSearchRow.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
((QuickSearchMoreListItem) listItem).onlineSearchOnClick();
|
||||
searchMoreItem.onlineSearchOnClick();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ public class QuickSearchMoreListItem extends QuickSearchListItem {
|
|||
private SearchMoreItemOnClickListener onClickListener;
|
||||
private boolean emptySearch;
|
||||
private boolean onlineSearch;
|
||||
private boolean searchMoreAvailable;
|
||||
private boolean interruptedSearch;
|
||||
private String findMore;
|
||||
private String restartSearch;
|
||||
|
@ -68,6 +69,14 @@ public class QuickSearchMoreListItem extends QuickSearchListItem {
|
|||
this.onlineSearch = onlineSearch;
|
||||
}
|
||||
|
||||
public boolean isSearchMoreAvailable() {
|
||||
return searchMoreAvailable;
|
||||
}
|
||||
|
||||
public void setSearchMoreAvailable(boolean searchMoreAvailable) {
|
||||
this.searchMoreAvailable = searchMoreAvailable;
|
||||
}
|
||||
|
||||
public void increaseRadiusOnClick() {
|
||||
if (onClickListener != null) {
|
||||
onClickListener.increaseRadiusOnClick();
|
||||
|
|
Loading…
Reference in a new issue