Skip to content

Commit

Permalink
Merge branch 'osmandapp:master' into hardy_Afa
Browse files Browse the repository at this point in the history
  • Loading branch information
sonora authored Jul 19, 2024
2 parents 1277c07 + 74bc91e commit b426e58
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ FinalRouteSegment searchRouteInternal(final RoutingContext ctx, RouteSegmentPoin
println(" " + segment.segEnd + ">> Already visited by minimum");
}
skipSegment = true;
} else if (cst.cost + 0.1 < minCost[forwardSearch ? 1 : 0] && ASSERT_CHECKS && ctx.calculationMode != RouteCalculationMode.COMPLEX) {
} else if (cst.cost + 2.0 < minCost[forwardSearch ? 1 : 0] && ASSERT_CHECKS && ctx.calculationMode != RouteCalculationMode.COMPLEX) {
// squareRootDist is inaccurate by 0.0015%-0.0036% according to tests
// think about multiplier * 1.00004f instead of the const (2.0)
if (ctx.config.heuristicCoefficient <= 1) {
throw new IllegalStateException(cst.cost + " < ??? " + minCost[forwardSearch ? 1 : 0]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ public String getTag() {
return tag;
}

public String getFilterId() {
return MapPoiTypes.TOP_INDEX_ADDITIONAL_PREFIX + tag + "_" + getValueKey(value);
}

@Override
public String getName() {
// type of object: brand, operator
Expand All @@ -49,4 +53,8 @@ public String getIconResource() {
public static String getValueKey(String value) {
return value.toLowerCase().replace(':', '_').replaceAll("\'", "").replace(' ', '_').replaceAll("\"", "");
}

public String getValue() {
return value;
}
}
11 changes: 10 additions & 1 deletion OsmAnd/res/values-hu/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5830,7 +5830,16 @@
<string name="rendering_avg_info_details">FPS (utolsó 1000 képkocka): %1$s
\nCPU (csempék): %2$s
\nCPU (üresjárat): %3$s
\nCPU (CPU-ra várás): %4$s</string>
\nCPU (GPU-ra várás): %4$s</string>
<string name="resting_position">Állóhelyzet</string>
<string name="resting_navigation_position">Állóhelyzeti és navigálási pozíció</string>
<string name="auto_25_chars_route_tshr">Forduljon élesen jobbra</string>
<string name="auto_25_chars_route_kl">Tartson balra</string>
<string name="auto_25_chars_route_tl">Forduljon balra</string>
<string name="auto_25_chars_route_kr">Tartson jobbra</string>
<string name="auto_25_chars_route_tr">Forduljon jobbra</string>
<string name="auto_25_chars_route_tshl">Forduljon élesen balra</string>
<string name="auto_25_chars_route_tsll">Forduljon enyhén balra</string>
<string name="auto_25_chars_route_tslr">Forduljon enyhén jobbra</string>
<string name="auto_25_chars_route_tu">Forduljon meg</string>
</resources>
4 changes: 2 additions & 2 deletions OsmAnd/res/values-ro/phrases.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3215,14 +3215,14 @@
<string name="poi_cuisine_tea_shop">Magazin de ceai</string>
<string name="poi_cuisine_tea">Ceai</string>
<string name="poi_cuisine_fine_dining">Mâncare rafinată</string>
<string name="poi_cuisine_soba">Sobă</string>
<string name="poi_cuisine_soba">Soba</string>
<string name="poi_cuisine_juice">Suc de fructe</string>
<string name="poi_cuisine_fast_food">Fast food</string>
<string name="poi_cuisine_pasta">Paste</string>
<string name="poi_cuisine_pancake">Clătite</string>
<string name="poi_cuisine_cake">Tort</string>
<string name="poi_cuisine_sausage">Cârnați</string>
<string name="poi_cuisine_diner">Cina</string>
<string name="poi_cuisine_diner">Diner</string>
<string name="poi_cuisine_bagel">Covrigi</string>
<string name="poi_cuisine_grill">Grătar</string>
<string name="poi_cuisine_buschenschank">Lanț de autobuz</string>
Expand Down
2 changes: 1 addition & 1 deletion OsmAnd/src/net/osmand/plus/inapp/InAppPurchases.java
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ public Pair<Spannable, Spannable> getFormattedDescription(@NonNull Context ctx,
Period subscriptionPeriod = subscription.getSubscriptionPeriod();
long originalNumberOfUnits = subscriptionPeriod != null ? subscriptionPeriod.getNumberOfUnits() : 1;
String originalUnitsStr = getTotalUnitsString(ctx, true).toLowerCase();
String originalPriceStr = subscription.getPrice(ctx);
String originalPriceStr = subscription.getOriginalPrice(ctx);
String priceStr = introductoryPrice;

String pricePeriod;
Expand Down
7 changes: 7 additions & 0 deletions OsmAnd/src/net/osmand/plus/poi/PoiFiltersHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import net.osmand.plus.backup.BackupUtils;
import net.osmand.plus.plugins.PluginsHelper;
import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.search.core.TopIndexFilter;
import net.osmand.util.CollectionUtils;

import org.apache.commons.logging.Log;
Expand Down Expand Up @@ -213,6 +214,12 @@ public PoiUIFilter getFilterById(String filterId, boolean includeDeleted) {
return null;
}

@Nullable
public PoiUIFilter getFilter(TopIndexFilter topIndexFilter, Map<PoiCategory, LinkedHashSet<String>> acceptedTypes) {
PoiUIFilter poiUIFilter = new PoiUIFilter(topIndexFilter, acceptedTypes, application);
return addTopPoiFilter(poiUIFilter);
}

public void reloadAllPoiFilters() {
showAllPOIFilter = null;
getShowAllPOIFilter();
Expand Down
18 changes: 18 additions & 0 deletions OsmAnd/src/net/osmand/plus/poi/PoiUIFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.utils.OsmAndFormatter;
import net.osmand.search.core.CustomSearchPoiFilter;
import net.osmand.search.core.TopIndexFilter;
import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils;
import net.osmand.util.OpeningHoursParser;
Expand Down Expand Up @@ -102,6 +103,23 @@ public PoiUIFilter(@Nullable AbstractPoiType type, @NonNull OsmandApplication ap
}
}

public PoiUIFilter(TopIndexFilter topIndexFilter, @Nullable Map<PoiCategory, LinkedHashSet<String>> acceptedTypes, @NonNull OsmandApplication app) {
this.app = app;
isStandardFilter = true;
standardIconId = topIndexFilter.getIconResource();
filterId = topIndexFilter.getFilterId();
this.name = topIndexFilter.getName();
poiTypes = app.getPoiTypes();

if (acceptedTypes == null) {
initSearchAll();
} else {
this.acceptedTypes.putAll(acceptedTypes);
}
updatePoiAdditionals();
updateAcceptedTypeOrigins();
}

// search by name standard
protected PoiUIFilter(@NonNull OsmandApplication app) {
this.app = app;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import net.osmand.PlatformUtil;
import net.osmand.ResultMatcher;
import net.osmand.binary.BinaryMapIndexReader;
import net.osmand.data.Amenity;
import net.osmand.data.City;
import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon;
Expand Down Expand Up @@ -107,13 +108,17 @@
import net.osmand.search.core.SearchResult;
import net.osmand.search.core.SearchSettings;
import net.osmand.search.core.SearchWord;
import net.osmand.search.core.TopIndexFilter;
import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;

public class QuickSearchDialogFragment extends DialogFragment implements OsmAndCompassListener,
OsmAndLocationListener, DownloadEvents, OnPreferenceChanged {
Expand Down Expand Up @@ -204,6 +209,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
private static final int EXPIRATION_TIME_MIN = 10; // 10 minutes

private static boolean isDebugMode = SearchUICore.isDebugMode();
private boolean processTopIndexAfterLoad = false;

public enum QuickSearchTab {
HISTORY,
Expand Down Expand Up @@ -317,6 +323,15 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
custom.updateTypesToAccept(abstractPoiType);
filterId = custom.getFilterId();
}
} else if (object instanceof TopIndexFilter) {
TopIndexFilter topIndexFilter = (TopIndexFilter) object;
PoiUIFilter poiUIFilter = initPoiUIFilter(topIndexFilter);
if (poiUIFilter != null) {
filterId = poiUIFilter.getFilterId();
filterByName = topIndexFilter.getValue();
} else {
processTopIndexAfterLoad = true;
}
}
if (filterId != null) {
QuickSearchPoiFilterFragment.showDialog(QuickSearchDialogFragment.this, filterByName, filterId);
Expand Down Expand Up @@ -1550,6 +1565,12 @@ public boolean publish(SearchResult object) {
regionResultCollection = null;
results = new ArrayList<>();
showApiResults(searchApi, apiResults, phrase, hasRegionCollection, resultListener);
if (processTopIndexAfterLoad) {
app.runInUIThread(() -> {
buttonToolbarFilter.performClick();
});
processTopIndexAfterLoad = false;
}
break;
case SEARCH_API_REGION_FINISHED:
regionResultApi = (SearchCoreAPI) object.object;
Expand Down Expand Up @@ -2090,4 +2111,28 @@ public interface SearchResultListener {
// return true if search done, false if next search will be ran immediately
boolean searchFinished(SearchPhrase phrase);
}

private PoiUIFilter initPoiUIFilter(TopIndexFilter topIndexFilter) {
PoiUIFilter poiUIFilter = app.getPoiFilters().getFilterById(topIndexFilter.getFilterId());
if (poiUIFilter != null) {
// use saved filter
processTopIndexAfterLoad = false;
return poiUIFilter;
} else if (searchHelper != null && searchHelper.getResultCollection() != null) {
// collect poi categories and subtypes from searching result
List<SearchResult> searchResults = searchHelper.getResultCollection().getCurrentSearchResults();
Map<PoiCategory, LinkedHashSet<String>> acceptedTypes = new HashMap<>();
for (SearchResult res : searchResults) {
if (res.object instanceof Amenity) {
Amenity am = (Amenity) res.object;
LinkedHashSet<String> subtypes = acceptedTypes.computeIfAbsent(am.getType(), s -> new LinkedHashSet<>());
subtypes.add(am.getSubType());
}
}
poiUIFilter = app.getPoiFilters().getFilter(topIndexFilter, acceptedTypes);
processTopIndexAfterLoad = false;
return poiUIFilter;
}
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import static net.osmand.plus.routing.TransportRoutingHelper.PUBLIC_TRANSPORT_KEY;
import static net.osmand.plus.settings.backend.storages.IntermediatePointsStorage.INTERMEDIATE_POINTS;
import static net.osmand.plus.settings.backend.storages.IntermediatePointsStorage.INTERMEDIATE_POINTS_DESCRIPTION;
import static net.osmand.plus.settings.enums.ApproximationType.APPROX_GEO_CPP;
import static net.osmand.plus.settings.enums.ApproximationType.APPROX_CPP;
import static net.osmand.plus.settings.enums.LocationSource.ANDROID_API;
import static net.osmand.plus.settings.enums.LocationSource.GOOGLE_PLAY_SERVICES;
import static net.osmand.plus.settings.enums.RoutingType.HH_CPP;
Expand Down Expand Up @@ -1491,8 +1491,8 @@ public boolean isProxyEnabled() {
public final OsmandPreference<Boolean> FAST_ROUTE_MODE = new BooleanPreference(this, "fast_route_mode", true).makeProfile();

public static boolean IGNORE_MISSING_MAPS = false;
public final CommonPreference<RoutingType> ROUTING_TYPE = new EnumStringPreference<>(this, "routing_method", HH_CPP, RoutingType.values()).makeProfile().cache(); // previously routing_type
public final CommonPreference<ApproximationType> APPROXIMATION_TYPE = new EnumStringPreference<>(this, "approximator_type", APPROX_GEO_CPP, ApproximationType.values()).makeProfile().cache(); // previously approximation_type
public final CommonPreference<RoutingType> ROUTING_TYPE = new EnumStringPreference<>(this, "routing_method", HH_CPP, RoutingType.values()).makeProfile().cache();
public final CommonPreference<ApproximationType> APPROXIMATION_TYPE = new EnumStringPreference<>(this, "approximation_type_r48_fallback", APPROX_CPP, ApproximationType.values()).makeProfile().cache();

public final CommonPreference<Boolean> ENABLE_TIME_CONDITIONAL_ROUTING = new BooleanPreference(this, "enable_time_conditional_routing", true).makeProfile();

Expand Down

0 comments on commit b426e58

Please sign in to comment.