Skip to content

Commit

Permalink
Merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanPyrohivskyi committed Dec 2, 2024
2 parents b866de3 + 409e76c commit 31f92a3
Show file tree
Hide file tree
Showing 676 changed files with 27,975 additions and 16,536 deletions.
10 changes: 0 additions & 10 deletions .github/ISSUE_TEMPLATE/1-support-request.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,4 @@ name: "❓ Support request"
about: Questions and requests for support
---

🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑

Please do not file questions or support requests on the GitHub issues tracker.

In case you aren't sure whether to open an issue or not, please send your request to [email protected].

You can get your questions answered using the [Google group](https://groups.google.com/forum/#!forum/osmand) or chat in real-time via our Telegram instances: [English](https://t.me/OsmAndMaps), [German](https://t.me/deosmand), [French](https://t.me/frosmand), [Ukrainian](https://t.me/uaosmand), [Italian](https://t.me/itosmand), [Russian](https://t.me/ruosmand).

Thank you!

🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public interface OsmAndCustomizationConstants {
String DRAWER_BUILDS_ID = DRAWER_ITEM_ID_SCHEME + "builds";
String DRAWER_DIVIDER_ID = DRAWER_ITEM_ID_SCHEME + "divider";
String DRAWER_OSMAND_VERSION_ID = DRAWER_ITEM_ID_SCHEME + "osmand_version";
String DRAWER_VEHICLE_METRICS_ID = DRAWER_ITEM_ID_SCHEME + "vehicle_metrics";

// Configure Map:
String CONFIGURE_MAP_ITEM_ID_SCHEME = "map.configure.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class NavigateGpxParams extends AidlParams {
private String fileName;
private boolean force;
private boolean needLocationPermission;
private boolean passWholeRoute;
private Boolean passWholeRoute;
private boolean snapToRoad;
private String snapToRoadMode;
private int snapToRoadThreshold;
Expand Down Expand Up @@ -66,11 +66,11 @@ public boolean isForce() {
return force;
}

public boolean isPassWholeRoute() {
public Boolean isPassWholeRoute() {
return passWholeRoute;
}

public void setPassWholeRoute(boolean passWholeRoute) {
public void setPassWholeRoute(Boolean passWholeRoute) {
this.passWholeRoute = passWholeRoute;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ private static String alignChars(String fullText) {
return fullText;
}

private static boolean isSpace(char c){
public static boolean isSpace(char c){
return !Character.isLetter(c) && !Character.isDigit(c);
}

Expand Down
16 changes: 12 additions & 4 deletions OsmAnd-java/src/main/java/net/osmand/NativeLibrary.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import java.util.Map;
import java.util.TreeMap;

import net.osmand.router.*;
import org.apache.commons.logging.Log;

import com.google.gson.JsonObject;
Expand All @@ -27,17 +26,26 @@
import net.osmand.binary.BinaryMapIndexReader;
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteRegion;
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteSubregion;
import net.osmand.binary.ObfConstants;
import net.osmand.binary.RouteDataObject;
import net.osmand.data.LatLon;
import net.osmand.data.MapObject;
import net.osmand.data.QuadRect;
import net.osmand.render.RenderingRuleSearchRequest;
import net.osmand.render.RenderingRulesStorage;
import net.osmand.router.GeneralRouter;
import net.osmand.router.GpxRouteApproximation;
import net.osmand.router.HHRouteDataStructure.HHRoutingConfig;
import net.osmand.router.HHRoutePlanner;
import net.osmand.router.NativeTransportRoutingResult;
import net.osmand.router.RouteCalculationProgress;
import net.osmand.router.RoutePlannerFrontEnd.GpxPoint;
import net.osmand.router.RouteResultPreparation;
import net.osmand.router.RouteSegmentResult;
import net.osmand.router.RoutingContext;
import net.osmand.router.TransportRoutingConfiguration;
import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils;
import net.osmand.util.OsmUtils;

public class NativeLibrary {

Expand Down Expand Up @@ -707,8 +715,8 @@ public String getGpxFileName() {
@Override
public String toString() {
String s = getClass().getSimpleName() + " " + name;
String link = OsmUtils.getOsmUrlForId(this);
String tags = OsmUtils.getPrintTags(this);
String link = ObfConstants.getOsmUrlForId(this);
String tags = ObfConstants.getPrintTags(this);
s += s.contains(link) ? "" : " " + link;
s += s.contains(tags) ? "" : " " + tags;
return s;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2275,10 +2275,12 @@ public String toString() {
private static boolean testAddressSearch = false;
private static boolean testAddressSearchName = false;
private static boolean testAddressJustifySearch = false;
private static boolean testPoiSearch = true;
private static boolean testPoiSearch = false;
private static boolean testPoiSearchOnPath = false;
private static boolean testTransportSearch = false;

private static boolean testPoiRouteByName = true;
private static boolean testPoiRouteByType = true;

private static int sleft = MapUtils.get31TileNumberX(27.55079);
private static int sright = MapUtils.get31TileNumberX(27.55317);
private static int stop = MapUtils.get31TileNumberY(53.89378);
Expand Down Expand Up @@ -2319,13 +2321,25 @@ public static void main(String[] args) throws IOException {
PoiRegion poiRegion = reader.getPoiIndexes().get(0);
if (testPoiSearch) {
testPoiSearch(reader, poiRegion);
testPoiSearchByName(reader);
testPoiSearchByName(reader, "central ukraine", 0, 0);
}
if (testPoiSearchOnPath) {
testSearchOnthePath(reader);
}
}

if (testPoiRouteByName || testPoiRouteByType) {
int y = MapUtils.get31TileNumberY(36.023431);
int x = MapUtils.get31TileNumberX(14.298406);
if (testPoiRouteByName) {
testPoiSearchByName(reader, "Gozo Coastal Walk", x, y); // Malta - Gozo Island - osm_hiking track
}
if (testPoiRouteByType) {
testPoiSearchByType(reader, "routes", "osm_hiking", x, y);
// testPoiSearchByType(reader, "routes", null, x, y);
}
}

println("MEMORY " + (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory())); //$NON-NLS-1$
println("Time " + (System.currentTimeMillis() - time)); //$NON-NLS-1$
}
Expand Down Expand Up @@ -2436,16 +2450,49 @@ private static List<Location> readGPX(File f) {
}
return res;
}
private static void testPoiSearchByType(BinaryMapIndexReader reader, String askType, String askSubType, int x, int y) throws IOException {
println("Searching by type/subtype...");

SearchRequest<Amenity> req = buildSearchPoiRequest(x, y, "", 0, Integer.MAX_VALUE, 0, Integer.MAX_VALUE,
new SearchPoiTypeFilter() {
@Override
public boolean accept(PoiCategory type, String subcategory) {
return type.getKeyName().equals(askType) && (askSubType == null || subcategory.equals(askSubType));
}
@Override
public boolean isEmpty() {
return false;
}
}, null, null);

reader.searchPoi(req);
for (Amenity a : req.getSearchResults()) {
int distance = 0;
if (x > 0 && y > 0) {
distance = (int)MapUtils.getDistance(a.getLocation(),
MapUtils.get31LatitudeY(y), MapUtils.get31LongitudeX(x));
}
println(a.getType().getTranslation() +
" " + a.getSubType() + " " + a.getName() + " " + a.getLocation() +
(distance > 0 ? (" Dist " + distance + " m") : ""));
}
}

private static void testPoiSearchByName(BinaryMapIndexReader reader) throws IOException {
private static void testPoiSearchByName(BinaryMapIndexReader reader, String query, int x, int y) throws IOException {
println("Searching by name...");
SearchRequest<Amenity> req = buildSearchPoiRequest(0, 0, "central ukraine",
SearchRequest<Amenity> req = buildSearchPoiRequest(x, y, query,
0, Integer.MAX_VALUE, 0, Integer.MAX_VALUE, null);

reader.searchPoiByName(req);
for (Amenity a : req.getSearchResults()) {
int distance = 0;
if (x > 0 && y > 0) {
distance = (int)MapUtils.getDistance(a.getLocation(),
MapUtils.get31LatitudeY(y), MapUtils.get31LongitudeX(x));
}
println(a.getType().getTranslation() +
" " + a.getSubType() + " " + a.getName() + " " + a.getLocation());
" " + a.getSubType() + " " + a.getName() + " " + a.getLocation() +
(distance > 0 ? (" Dist " + distance + " m") : ""));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static class PoiRegion extends BinaryIndexPart {
int right31;
int top31;
int bottom31;

public int getLeft31() {
return left31;
}
Expand Down Expand Up @@ -818,6 +818,7 @@ private Amenity readPoiPoint(int left31, int right31, int top31, int bottom31,
}
}
}
am.setRegionName(region.getName());
return am;
case OsmandOdb.OsmAndPoiBoxDataAtom.DX_FIELD_NUMBER:
x = (codedIS.readSInt32() + (px << (BASE_POI_ZOOM - zoom))) << BASE_POI_SHIFT;
Expand Down Expand Up @@ -972,7 +973,7 @@ private boolean checkCategories(SearchRequest<Amenity> req, PoiRegion region) th
}
}
subtype = poiTypes.replaceDeprecatedSubtype(type, subtype);
if (req.poiTypeFilter.accept(type, subtype)) {
if (req.poiTypeFilter != null && req.poiTypeFilter.accept(type, subtype)) {
codedIS.skipRawBytes(codedIS.getBytesUntilLimit());
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,30 @@ public int conditionalValue(long time) {
return 0;
}

public Integer getMaxIntegerConditionalValue() {
if (conditional()) {
int maxValue = Integer.MIN_VALUE;
for (RouteTypeCondition c : conditions) {
try {
int value = Integer.parseInt(c.value);
if (value > maxValue) {
maxValue = value;
}
} catch(NumberFormatException e) {
continue;
}
}
return maxValue > Integer.MIN_VALUE ? maxValue : null;
}
return null;
}

public float maxSpeed(int profile) {
if (type == (MAXSPEED + profile)) {
return floatValue;
}
return -1;
}


public int lanes() {
if (type == LANES) {
Expand Down
37 changes: 24 additions & 13 deletions OsmAnd-java/src/main/java/net/osmand/binary/GeocodingUtilities.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package net.osmand.binary;

import net.osmand.CollatorStringMatcher;
import net.osmand.CollatorStringMatcher.StringMatcherMode;
import net.osmand.PlatformUtil;
import net.osmand.ResultMatcher;
import net.osmand.CollatorStringMatcher.StringMatcherMode;
import net.osmand.binary.BinaryMapIndexReader.SearchRequest;
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteRegion;
import net.osmand.binary.GeocodingUtilities.GeocodingResult;
import net.osmand.data.Building;
import net.osmand.data.City;
import net.osmand.data.LatLon;
Expand All @@ -17,7 +17,6 @@
import net.osmand.router.RoutingContext;
import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils;

import org.apache.commons.logging.Log;

import java.io.IOException;
Expand Down Expand Up @@ -51,6 +50,9 @@ public class GeocodingUtilities {

@Override
public int compare(GeocodingResult o1, GeocodingResult o2) {
if ((int) o1.getDistance() == (int) o2.getDistance()) {
return Double.compare(o1.getCityDistance(), o2.getCityDistance());
}
return Double.compare(o1.getDistance(), o2.getDistance());
}
};
Expand Down Expand Up @@ -85,6 +87,7 @@ public GeocodingResult(GeocodingResult r) {
public Street street;
public City city;
private double dist = -1;
private double cityDist = -1;

public LatLon getLocation() {
return connectionPoint;
Expand All @@ -110,6 +113,18 @@ public double getDistance() {
return dist;
}

public void resetDistance() {
dist = -1;
getDistance();
}

public double getCityDistance() {
if (cityDist == -1 && city != null && searchPoint != null) {
cityDist = MapUtils.getDistance(city.getLocation(), searchPoint);
}
return cityDist;
}

@Override
public String toString() {
StringBuilder bld = new StringBuilder();
Expand Down Expand Up @@ -185,9 +200,9 @@ public List<String> prepareStreetName(String s, boolean addCommonWords) {
List<String> ls = new ArrayList<String>();
int beginning = 0;
for (int i = 1; i < s.length(); i++) {
if (s.charAt(i) == ' ') {
if (CollatorStringMatcher.isSpace(s.charAt(i))) {
addWord(ls, s.substring(beginning, i), addCommonWords);
beginning = i;
beginning = i + 1;
} else if (s.charAt(i) == '(') {
addWord(ls, s.substring(beginning, i), addCommonWords);
while (i < s.length()) {
Expand Down Expand Up @@ -254,6 +269,7 @@ && prepareStreetName(object.getName(), addCommonWordsFinal).equals(streetNamesUs
// set connection point to sort
rs.connectionPoint = rs.street.getLocation();
rs.city = rs.street.getCity();
rs.dist = d;
streetsList.add(rs);
return true;
}
Expand Down Expand Up @@ -281,10 +297,10 @@ public boolean isCancelled() {
for (GeocodingResult street : streetsList) {
if (streetDistance == 0) {
streetDistance = street.getDistance();
} else if (streetDistance > 0 && street.getDistance() > streetDistance + DISTANCE_STREET_FROM_CLOSEST_WITH_SAME_NAME &&
isBuildingFound) {
} else if (isBuildingFound && street.getDistance() > streetDistance + DISTANCE_STREET_FROM_CLOSEST_WITH_SAME_NAME) {
continue;
}
street.resetDistance();//reset to road projection
street.connectionPoint = road.connectionPoint;
final List<GeocodingResult> streetBuildings = loadStreetBuildings(road, reader, street);
Collections.sort(streetBuildings, DISTANCE_COMPARATOR);
Expand Down Expand Up @@ -435,12 +451,7 @@ public List<GeocodingResult> sortGeocodingResults(List<BinaryMapIndexReader> lis
it.remove();
}
}
Collections.sort(complete, new Comparator<GeocodingResult>() {
@Override
public int compare(GeocodingResult o1, GeocodingResult o2) {
return Double.compare(o1.getDistance(), o2.getDistance());
}
});
Collections.sort(complete, DISTANCE_COMPARATOR);
return complete;

}
Expand Down
Loading

0 comments on commit 31f92a3

Please sign in to comment.