diff --git a/OsmAnd-api/src/net/osmand/aidlapi/map/ALocation.java b/OsmAnd-api/src/net/osmand/aidlapi/map/ALocation.java index 03741138d5..0809944ba9 100644 --- a/OsmAnd-api/src/net/osmand/aidlapi/map/ALocation.java +++ b/OsmAnd-api/src/net/osmand/aidlapi/map/ALocation.java @@ -25,6 +25,24 @@ public class ALocation extends AidlParams { private ALocation() { } + public ALocation(double latitude, double longitude, long time, boolean hasAltitude, double altitude, + boolean hasSpeed, float speed, boolean hasBearing, float bearing, + boolean hasAccuracy, float accuracy, boolean hasVerticalAccuracy, float verticalAccuracy) { + this.latitude = latitude; + this.longitude = longitude; + this.time = time; + this.hasAltitude = hasAltitude; + this.altitude = altitude; + this.hasSpeed = hasSpeed; + this.speed = speed; + this.hasBearing = hasBearing; + this.bearing = bearing; + this.hasAccuracy = hasAccuracy; + this.accuracy = accuracy; + this.hasVerticalAccuracy = hasVerticalAccuracy; + this.verticalAccuracy = verticalAccuracy; + } + public ALocation(Parcel in) { readFromParcel(in); } diff --git a/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java b/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java index ed80b55b05..4db84c5c33 100644 --- a/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java +++ b/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java @@ -60,7 +60,8 @@ public class GPXUtilities { private final static NumberFormat latLonFormat = new DecimalFormat("0.00#####", new DecimalFormatSymbols( new Locale("EN", "US"))); - private final static NumberFormat decimalFormat = new DecimalFormat("#.###", new DecimalFormatSymbols( + // speed, ele, hdop + private final static NumberFormat decimalFormat = new DecimalFormat("#.#", new DecimalFormatSymbols( new Locale("EN", "US"))); public enum GPXColor { @@ -1255,6 +1256,10 @@ public class GPXUtilities { return g; } + public boolean containsRoutePoint(WptPt point) { + return getRoutePoints().contains(point); + } + public List getRoutePoints() { List points = new ArrayList<>(); for (int i = 0; i < routes.size(); i++) { @@ -2476,6 +2481,7 @@ public class GPXUtilities { firstSegment.routeSegments = routeSegments; firstSegment.routeTypes = routeTypes; } + gpxFile.addGeneralTrack(); } catch (Exception e) { gpxFile.error = e; log.error("Error reading gpx", e); //$NON-NLS-1$ @@ -2590,4 +2596,4 @@ public class GPXUtilities { to.error = from.error; } } -} \ No newline at end of file +} diff --git a/OsmAnd-java/src/main/java/net/osmand/binary/BinaryMapIndexReader.java b/OsmAnd-java/src/main/java/net/osmand/binary/BinaryMapIndexReader.java index dc16b89f30..34483b01b7 100644 --- a/OsmAnd-java/src/main/java/net/osmand/binary/BinaryMapIndexReader.java +++ b/OsmAnd-java/src/main/java/net/osmand/binary/BinaryMapIndexReader.java @@ -83,7 +83,7 @@ public class BinaryMapIndexReader { public final static int TRANSPORT_STOP_ZOOM = 24; public static final int SHIFT_COORDINATES = 5; - public static final int LABEL_ZOOM_ENCODE = 26; + public static final int LABEL_ZOOM_ENCODE = 31 - SHIFT_COORDINATES; private final static Log log = PlatformUtil.getLog(BinaryMapIndexReader.class); public static boolean READ_STATS = false; public static final SearchPoiTypeFilter ACCEPT_ALL_POI_TYPE_FILTER = new SearchPoiTypeFilter() { diff --git a/OsmAnd-java/src/main/java/net/osmand/binary/BinaryMapPoiReaderAdapter.java b/OsmAnd-java/src/main/java/net/osmand/binary/BinaryMapPoiReaderAdapter.java index fd6fe7bce9..742eae1f61 100644 --- a/OsmAnd-java/src/main/java/net/osmand/binary/BinaryMapPoiReaderAdapter.java +++ b/OsmAnd-java/src/main/java/net/osmand/binary/BinaryMapPoiReaderAdapter.java @@ -37,7 +37,12 @@ public class BinaryMapPoiReaderAdapter { private static final int CATEGORY_MASK = (1 << SHIFT_BITS_CATEGORY) - 1; private static final int ZOOM_TO_SKIP_FILTER_READ = 6; private static final int ZOOM_TO_SKIP_FILTER = 3; - private static final int BUCKET_SEARCH_BY_NAME = 15; // should be bigger 100? + private static final int BUCKET_SEARCH_BY_NAME = 15; // should be bigger 100? + private static final int BASE_POI_SHIFT = SHIFT_BITS_CATEGORY;// 7 + private static final int FINAL_POI_SHIFT = BinaryMapIndexReader.SHIFT_COORDINATES;// 5 + private static final int BASE_POI_ZOOM = 31 - BASE_POI_SHIFT;// 24 zoom + private static final int FINAL_POI_ZOOM = 31 - FINAL_POI_SHIFT;// 26 zoom + public static class PoiSubType { public boolean text; @@ -714,6 +719,8 @@ public class BinaryMapPoiReaderAdapter { Amenity am = null; int x = 0; int y = 0; + int precisionXY = 0; + boolean hasLocation = false; StringBuilder retValue = new StringBuilder(); PoiCategory amenityType = null; LinkedList textTags = null; @@ -740,12 +747,22 @@ public class BinaryMapPoiReaderAdapter { am.setRoutePoint(arp); } } + if (hasLocation) { + if (precisionXY != 0) { + int[] xy = MapUtils.calculateFinalXYFromBaseAndPrecisionXY(BASE_POI_ZOOM, FINAL_POI_ZOOM, precisionXY, x >> BASE_POI_SHIFT, y >> BASE_POI_SHIFT, true); + int x31 = xy[0] << FINAL_POI_SHIFT; + int y31 = xy[1] << FINAL_POI_SHIFT; + am.setLocation(MapUtils.get31LatitudeY(y31), MapUtils.get31LongitudeX(x31)); + } else { + am.setLocation(MapUtils.get31LatitudeY(y), MapUtils.get31LongitudeX(x)); + } + } return am; case OsmandOdb.OsmAndPoiBoxDataAtom.DX_FIELD_NUMBER: - x = (codedIS.readSInt32() + (px << (24 - zoom))) << 7; + x = (codedIS.readSInt32() + (px << (BASE_POI_ZOOM - zoom))) << BASE_POI_SHIFT; break; case OsmandOdb.OsmAndPoiBoxDataAtom.DY_FIELD_NUMBER: - y = (codedIS.readSInt32() + (py << (24 - zoom))) << 7; + y = (codedIS.readSInt32() + (py << (BASE_POI_ZOOM - zoom))) << BASE_POI_SHIFT; req.numberOfVisitedObjects++; if (checkBounds) { if (left31 > x || right31 < x || top31 > y || bottom31 < y) { @@ -754,7 +771,8 @@ public class BinaryMapPoiReaderAdapter { } } am = new Amenity(); - am.setLocation(MapUtils.get31LatitudeY(y), MapUtils.get31LongitudeX(x)); + hasLocation = true; + //am.setLocation(MapUtils.get31LatitudeY(y), MapUtils.get31LongitudeX(x)); // set precise coordinates break; case OsmandOdb.OsmAndPoiBoxDataAtom.SUBCATEGORIES_FIELD_NUMBER: int subtypev = codedIS.readUInt32(); @@ -827,6 +845,11 @@ public class BinaryMapPoiReaderAdapter { case OsmandOdb.OsmAndPoiBoxDataAtom.NOTE_FIELD_NUMBER: am.setDescription(codedIS.readString()); break; + case OsmandOdb.OsmAndPoiBoxDataAtom.PRECISIONXY_FIELD_NUMBER: + if (hasLocation) { + precisionXY = codedIS.readInt32(); + } + break; default: skipUnknownField(t); break; diff --git a/OsmAnd-java/src/main/java/net/osmand/binary/OsmandOdb.java b/OsmAnd-java/src/main/java/net/osmand/binary/OsmandOdb.java index 97a2abeb91..f531dfbfde 100644 --- a/OsmAnd-java/src/main/java/net/osmand/binary/OsmandOdb.java +++ b/OsmAnd-java/src/main/java/net/osmand/binary/OsmandOdb.java @@ -54371,6 +54371,24 @@ public final class OsmandOdb { */ com.google.protobuf.ByteString getTextValuesBytes(int index); + + // optional int32 precisionXY = 16; + /** + * optional int32 precisionXY = 16; + * + *
+     * precision in 1-xy-xy-xy binary format
+     * 
+ */ + boolean hasPrecisionXY(); + /** + * optional int32 precisionXY = 16; + * + *
+     * precision in 1-xy-xy-xy binary format
+     * 
+ */ + int getPrecisionXY(); } /** * Protobuf type {@code OsmAnd.OBF.OsmAndPoiBoxDataAtom} @@ -54539,6 +54557,11 @@ public final class OsmandOdb { textValues_.add(input.readBytes()); break; } + case 128: { + bitField0_ |= 0x00000200; + precisionXY_ = input.readInt32(); + break; + } } } } catch (com.google.protobuf.InvalidProtocolBufferException e) { @@ -55048,6 +55071,30 @@ public final class OsmandOdb { return textValues_.getByteString(index); } + // optional int32 precisionXY = 16; + public static final int PRECISIONXY_FIELD_NUMBER = 16; + private int precisionXY_; + /** + * optional int32 precisionXY = 16; + * + *
+     * precision in 1-xy-xy-xy binary format
+     * 
+ */ + public boolean hasPrecisionXY() { + return ((bitField0_ & 0x00000200) == 0x00000200); + } + /** + * optional int32 precisionXY = 16; + * + *
+     * precision in 1-xy-xy-xy binary format
+     * 
+ */ + public int getPrecisionXY() { + return precisionXY_; + } + private void initFields() { dx_ = 0; dy_ = 0; @@ -55062,6 +55109,7 @@ public final class OsmandOdb { note_ = ""; textCategories_ = java.util.Collections.emptyList(); textValues_ = com.google.protobuf.LazyStringArrayList.EMPTY; + precisionXY_ = 0; } private byte memoizedIsInitialized = -1; public final boolean isInitialized() { @@ -55122,6 +55170,9 @@ public final class OsmandOdb { for (int i = 0; i < textValues_.size(); i++) { output.writeBytes(15, textValues_.getByteString(i)); } + if (((bitField0_ & 0x00000200) == 0x00000200)) { + output.writeInt32(16, precisionXY_); + } getUnknownFields().writeTo(output); } @@ -55203,6 +55254,10 @@ public final class OsmandOdb { size += dataSize; size += 1 * getTextValuesList().size(); } + if (((bitField0_ & 0x00000200) == 0x00000200)) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(16, precisionXY_); + } size += getUnknownFields().getSerializedSize(); memoizedSerializedSize = size; return size; @@ -55345,6 +55400,8 @@ public final class OsmandOdb { bitField0_ = (bitField0_ & ~0x00000800); textValues_ = com.google.protobuf.LazyStringArrayList.EMPTY; bitField0_ = (bitField0_ & ~0x00001000); + precisionXY_ = 0; + bitField0_ = (bitField0_ & ~0x00002000); return this; } @@ -55430,6 +55487,10 @@ public final class OsmandOdb { bitField0_ = (bitField0_ & ~0x00001000); } result.textValues_ = textValues_; + if (((from_bitField0_ & 0x00002000) == 0x00002000)) { + to_bitField0_ |= 0x00000200; + } + result.precisionXY_ = precisionXY_; result.bitField0_ = to_bitField0_; onBuilt(); return result; @@ -55525,6 +55586,9 @@ public final class OsmandOdb { } onChanged(); } + if (other.hasPrecisionXY()) { + setPrecisionXY(other.getPrecisionXY()); + } this.mergeUnknownFields(other.getUnknownFields()); return this; } @@ -56506,6 +56570,55 @@ public final class OsmandOdb { return this; } + // optional int32 precisionXY = 16; + private int precisionXY_ ; + /** + * optional int32 precisionXY = 16; + * + *
+       * precision in 1-xy-xy-xy binary format
+       * 
+ */ + public boolean hasPrecisionXY() { + return ((bitField0_ & 0x00002000) == 0x00002000); + } + /** + * optional int32 precisionXY = 16; + * + *
+       * precision in 1-xy-xy-xy binary format
+       * 
+ */ + public int getPrecisionXY() { + return precisionXY_; + } + /** + * optional int32 precisionXY = 16; + * + *
+       * precision in 1-xy-xy-xy binary format
+       * 
+ */ + public Builder setPrecisionXY(int value) { + bitField0_ |= 0x00002000; + precisionXY_ = value; + onChanged(); + return this; + } + /** + * optional int32 precisionXY = 16; + * + *
+       * precision in 1-xy-xy-xy binary format
+       * 
+ */ + public Builder clearPrecisionXY() { + bitField0_ = (bitField0_ & ~0x00002000); + precisionXY_ = 0; + onChanged(); + return this; + } + // @@protoc_insertion_point(builder_scope:OsmAnd.OBF.OsmAndPoiBoxDataAtom) } @@ -65008,37 +65121,38 @@ public final class OsmandOdb { "tegories\030\003 \003(\r\022\025\n\rsubcategories\030\005 \003(\r\"i\n" + "\020OsmAndPoiBoxData\022\014\n\004zoom\030\001 \001(\r\022\t\n\001x\030\002 \001" + "(\r\022\t\n\001y\030\003 \001(\r\0221\n\007poiData\030\005 \003(\0132 .OsmAnd." + - "OBF.OsmAndPoiBoxDataAtom\"\360\001\n\024OsmAndPoiBo", + "OBF.OsmAndPoiBoxDataAtom\"\205\002\n\024OsmAndPoiBo", "xDataAtom\022\n\n\002dx\030\002 \002(\021\022\n\n\002dy\030\003 \002(\021\022\022\n\ncat" + "egories\030\004 \003(\r\022\025\n\rsubcategories\030\005 \003(\r\022\014\n\004" + "name\030\006 \001(\t\022\016\n\006nameEn\030\007 \001(\t\022\n\n\002id\030\010 \001(\004\022\024" + "\n\014openingHours\030\n \001(\t\022\014\n\004site\030\013 \001(\t\022\r\n\005ph" + "one\030\014 \001(\t\022\014\n\004note\030\r \001(\t\022\026\n\016textCategorie" + - "s\030\016 \003(\r\022\022\n\ntextValues\030\017 \003(\t\"\032\n\007IdTable\022\017" + - "\n\007routeId\030\001 \003(\022\"F\n\017RestrictionData\022\014\n\004ty" + - "pe\030\001 \002(\005\022\014\n\004from\030\002 \002(\005\022\n\n\002to\030\003 \002(\005\022\013\n\003vi" + - "a\030\004 \001(\005\"x\n\tRouteData\022\016\n\006points\030\001 \002(\014\022\022\n\n" + - "pointTypes\030\004 \001(\014\022\022\n\npointNames\030\005 \001(\014\022\r\n\005", - "types\030\007 \002(\014\022\017\n\007routeId\030\014 \002(\005\022\023\n\013stringNa" + - "mes\030\016 \001(\014\"\304\005\n\022OsmAndRoutingIndex\022\014\n\004name" + - "\030\001 \002(\t\022?\n\005rules\030\002 \003(\01320.OsmAnd.OBF.OsmAn" + - "dRoutingIndex.RouteEncodingRule\022>\n\trootB" + - "oxes\030\003 \003(\0132+.OsmAnd.OBF.OsmAndRoutingInd" + - "ex.RouteDataBox\022A\n\014basemapBoxes\030\004 \003(\0132+." + - "OsmAnd.OBF.OsmAndRoutingIndex.RouteDataB" + - "ox\022=\n\006blocks\030\005 \003(\0132-.OsmAnd.OBF.OsmAndRo" + - "utingIndex.RouteDataBlock\032;\n\021RouteEncodi" + - "ngRule\022\013\n\003tag\030\003 \002(\t\022\r\n\005value\030\005 \002(\t\022\n\n\002id", - "\030\007 \001(\r\032\231\001\n\014RouteDataBox\022\014\n\004left\030\001 \002(\021\022\r\n" + - "\005right\030\002 \002(\021\022\013\n\003top\030\003 \002(\021\022\016\n\006bottom\030\004 \002(" + - "\021\022\023\n\013shiftToData\030\005 \001(\007\022:\n\005boxes\030\007 \003(\0132+." + - "OsmAnd.OBF.OsmAndRoutingIndex.RouteDataB" + - "ox\032\303\001\n\016RouteDataBlock\022$\n\007idTable\030\005 \001(\0132\023" + - ".OsmAnd.OBF.IdTable\022*\n\013dataObjects\030\006 \003(\013" + - "2\025.OsmAnd.OBF.RouteData\0221\n\014restrictions\030" + - "\007 \003(\0132\033.OsmAnd.OBF.RestrictionData\022,\n\013st" + - "ringTable\030\010 \001(\0132\027.OsmAnd.OBF.StringTable" + - "B\036\n\021net.osmand.binaryB\tOsmandOdb" + "s\030\016 \003(\r\022\022\n\ntextValues\030\017 \003(\t\022\023\n\013precision" + + "XY\030\020 \001(\005\"\032\n\007IdTable\022\017\n\007routeId\030\001 \003(\022\"F\n\017" + + "RestrictionData\022\014\n\004type\030\001 \002(\005\022\014\n\004from\030\002 " + + "\002(\005\022\n\n\002to\030\003 \002(\005\022\013\n\003via\030\004 \001(\005\"x\n\tRouteDat" + + "a\022\016\n\006points\030\001 \002(\014\022\022\n\npointTypes\030\004 \001(\014\022\022\n", + "\npointNames\030\005 \001(\014\022\r\n\005types\030\007 \002(\014\022\017\n\007rout" + + "eId\030\014 \002(\005\022\023\n\013stringNames\030\016 \001(\014\"\304\005\n\022OsmAn" + + "dRoutingIndex\022\014\n\004name\030\001 \002(\t\022?\n\005rules\030\002 \003" + + "(\01320.OsmAnd.OBF.OsmAndRoutingIndex.Route" + + "EncodingRule\022>\n\trootBoxes\030\003 \003(\0132+.OsmAnd" + + ".OBF.OsmAndRoutingIndex.RouteDataBox\022A\n\014" + + "basemapBoxes\030\004 \003(\0132+.OsmAnd.OBF.OsmAndRo" + + "utingIndex.RouteDataBox\022=\n\006blocks\030\005 \003(\0132" + + "-.OsmAnd.OBF.OsmAndRoutingIndex.RouteDat" + + "aBlock\032;\n\021RouteEncodingRule\022\013\n\003tag\030\003 \002(\t", + "\022\r\n\005value\030\005 \002(\t\022\n\n\002id\030\007 \001(\r\032\231\001\n\014RouteDat" + + "aBox\022\014\n\004left\030\001 \002(\021\022\r\n\005right\030\002 \002(\021\022\013\n\003top" + + "\030\003 \002(\021\022\016\n\006bottom\030\004 \002(\021\022\023\n\013shiftToData\030\005 " + + "\001(\007\022:\n\005boxes\030\007 \003(\0132+.OsmAnd.OBF.OsmAndRo" + + "utingIndex.RouteDataBox\032\303\001\n\016RouteDataBlo" + + "ck\022$\n\007idTable\030\005 \001(\0132\023.OsmAnd.OBF.IdTable" + + "\022*\n\013dataObjects\030\006 \003(\0132\025.OsmAnd.OBF.Route" + + "Data\0221\n\014restrictions\030\007 \003(\0132\033.OsmAnd.OBF." + + "RestrictionData\022,\n\013stringTable\030\010 \001(\0132\027.O" + + "smAnd.OBF.StringTableB\036\n\021net.osmand.bina", + "ryB\tOsmandOdb" }; com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { @@ -65296,7 +65410,7 @@ public final class OsmandOdb { internal_static_OsmAnd_OBF_OsmAndPoiBoxDataAtom_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_OsmAnd_OBF_OsmAndPoiBoxDataAtom_descriptor, - new java.lang.String[] { "Dx", "Dy", "Categories", "Subcategories", "Name", "NameEn", "Id", "OpeningHours", "Site", "Phone", "Note", "TextCategories", "TextValues", }); + new java.lang.String[] { "Dx", "Dy", "Categories", "Subcategories", "Name", "NameEn", "Id", "OpeningHours", "Site", "Phone", "Note", "TextCategories", "TextValues", "PrecisionXY", }); internal_static_OsmAnd_OBF_IdTable_descriptor = getDescriptor().getMessageTypes().get(36); internal_static_OsmAnd_OBF_IdTable_fieldAccessorTable = new diff --git a/OsmAnd-java/src/main/java/net/osmand/osm/RouteActivityType.java b/OsmAnd-java/src/main/java/net/osmand/osm/RouteActivityType.java index 28c9b11551..7c54388f64 100644 --- a/OsmAnd-java/src/main/java/net/osmand/osm/RouteActivityType.java +++ b/OsmAnd-java/src/main/java/net/osmand/osm/RouteActivityType.java @@ -1,42 +1,76 @@ package net.osmand.osm; -public enum RouteActivityType { - WATER("Water", "yellow"), WINTER("Winter", "yellow"), SNOWMOBILE("Snowmobile", "yellow"), RIDING("Riding", "yellow"), RACING("Racing", "yellow"), - MOUNTAINBIKE("Mountainbike", "blue"), CYCLING("Cycling", "blue"), - HIKING("Hiking", "orange"), RUNNING("Running", "orange"), WALKING("Walking", "orange"), - OFFROAD("Off-road", "yellow"), - MOTORBIKE("Motorbike", "green"), CAR("Car", "green"); - // less specific bottom order +import java.util.ArrayList; +import java.util.List; +public class RouteActivityType { + private static final List values = new ArrayList<>(); + public static final String DEFAULT_ICON = "special_marker"; + public static final String DEFAULT_COLOR = "orange"; + + public static final RouteActivityType WATER = createType("water", "yellow").icon("special_kayak").reg(); + public static final RouteActivityType WINTER = createType("winter", "yellow").icon("special_skiing").reg(); + public static final RouteActivityType SNOWMOBILE = createType("snowmobile", "yellow").icon("special_snowmobile").reg(); + public static final RouteActivityType RIDING = createType("riding", "yellow").icon("special_horse").reg(); + public static final RouteActivityType RACING = createType("racing", "yellow").icon("raceway").reg(); + public static final RouteActivityType MOUNTAINBIKE = createType("mountainbike", "blue").icon("sport_cycling").reg(); + public static final RouteActivityType CYCLING = createType("cycling", "blue").icon("special_bicycle").reg(); + public static final RouteActivityType HIKING = createType("hiking", "orange").icon("special_trekking").reg(); + public static final RouteActivityType RUNNING = createType("running", "orange").icon("running").reg(); + public static final RouteActivityType WALKING = createType("walking", "orange").icon("special_walking").reg(); + public static final RouteActivityType OFFROAD = createType("offroad", "yellow").icon("special_offroad").reg(); + public static final RouteActivityType MOTORBIKE = createType("motorbike", "green").icon("special_motorcycle").reg(); + public static final RouteActivityType CAR = createType("car", "green").icon("shop_car").reg(); + // less specific bottom order String name; String color; + String icon; - private RouteActivityType(String nm, String clr) { + RouteActivityType(String nm, String clr) { this.name = nm; this.color = clr; } - + public String getName() { return name; } - + public String getColor() { return color; } - + + public String getIcon() { + return icon; + } + + public static RouteActivityType getOrCreateTypeFromName(String name) { + for (RouteActivityType rat : values) { + if (rat.name.equalsIgnoreCase(name)) { + return rat; + } + } + return createType(name.toLowerCase(), DEFAULT_COLOR).icon(DEFAULT_ICON).reg(); + } + + private static RouteActivityTypeBuilder createType(String name, String color) { + RouteActivityTypeBuilder builder = new RouteActivityTypeBuilder(); + builder.routeActivityType = new RouteActivityType(name, color); + return builder; + } + public static RouteActivityType getTypeFromTags(String[] tags) { RouteActivityType activityType = null; for (String tg : tags) { RouteActivityType rat = RouteActivityType.convertFromOsmGPXTag(tg); if (rat != null) { - if (activityType == null || activityType.ordinal() > rat.ordinal()) { + if (activityType == null || values.indexOf(activityType) > values.indexOf(rat)) { activityType = rat; } } } return activityType; } - + public static RouteActivityType convertFromOsmGPXTag(String tg) { String t = tg.toLowerCase(); if ("mountain hiking".equalsIgnoreCase(t)) { @@ -215,4 +249,18 @@ public enum RouteActivityType { return null; } + public static class RouteActivityTypeBuilder { + + private RouteActivityType routeActivityType; + + public RouteActivityTypeBuilder icon(String icon) { + routeActivityType.icon = icon; + return this; + } + + private RouteActivityType reg() { + values.add(routeActivityType); + return routeActivityType; + } + } } \ No newline at end of file diff --git a/OsmAnd-java/src/main/java/net/osmand/osm/edit/EntityParser.java b/OsmAnd-java/src/main/java/net/osmand/osm/edit/EntityParser.java index 9caa54b55c..bd37de6ba0 100644 --- a/OsmAnd-java/src/main/java/net/osmand/osm/edit/EntityParser.java +++ b/OsmAnd-java/src/main/java/net/osmand/osm/edit/EntityParser.java @@ -21,7 +21,7 @@ import net.osmand.osm.edit.Relation.RelationMember; import net.osmand.util.Algorithms; public class EntityParser { - + public static void parseMapObject(MapObject mo, Entity e, Map tags) { mo.setId(e.getId()); if(mo instanceof Amenity) { @@ -123,7 +123,7 @@ public class EntityParser { mo.setName(ref); } } - + private static void setNameFromBrand(MapObject mo, Map tags) { String ref = tags.get(OSMTagKey.BRAND.getValue()); if(ref != null){ @@ -140,7 +140,7 @@ public class EntityParser { op += " [" + ref + "]"; mo.setName(op); } - + private static String getWebSiteURL(Map tagValues, boolean checkWikipedia) { String siteUrl = null; @@ -170,14 +170,14 @@ public class EntityParser { } return siteUrl; } - - + + public static List parseAmenities(MapPoiTypes poiTypes, Entity entity, Map tags, List amenitiesList) { amenitiesList.clear(); // it could be collection of amenities boolean relation = entity instanceof Relation; - boolean purerelation = relation && + boolean purerelation = relation && !("multipolygon".equals(tags.get("type")) || "boundary".equals(tags.get("type"))); Collection> it = MapRenderingTypes.splitTagsIntoDifferentObjects(tags); for (Map ts : it) { @@ -201,9 +201,7 @@ public class EntityParser { } return amenitiesList; } - - - + private static boolean checkAmenitiesToAdd(Amenity a, List amenitiesList){ // check amenity for duplication for(Amenity b : amenitiesList){ @@ -212,9 +210,9 @@ public class EntityParser { } } return true; - + } - + public static Building parseBuilding(Entity e){ Building b = new Building(); parseMapObject(b, e, e.getTags()); @@ -228,7 +226,7 @@ public class EntityParser { List nodes = ((Way) e).getNodes(); for(int i = 0; i < nodes.size(); i++) { Node node = nodes.get(i); - if(node != null && "yes".equals(node.getTag(OSMTagKey.ENTRANCE)) && + if(node != null && "yes".equals(node.getTag(OSMTagKey.ENTRANCE)) && !Algorithms.isEmpty(node.getTag(OSMTagKey.REF))) { b.addEntrance(node.getTag(OSMTagKey.REF), node.getLatLon()); } @@ -236,11 +234,11 @@ public class EntityParser { } return b; } - + public static City parseCity(Node el) { return parseCity(el, CityType.valueFromString(el.getTag(OSMTagKey.PLACE.getValue()))); } - + public static City parseCity(Entity el, CityType t) { if(t == null) { return null; @@ -252,15 +250,15 @@ public class EntityParser { c.setIsin(isin); return c; } - - + + public static TransportRoute parserRoute(Relation r, String ref){ TransportRoute rt = new TransportRoute(); parseMapObject(rt, r, r.getTags()); rt.setRef(ref); return rt; } - + public static TransportStop parseTransportStop(Entity e){ TransportStop st = new TransportStop(); parseMapObject(st, e, e.getTags()); diff --git a/OsmAnd-java/src/main/java/net/osmand/router/BinaryRoutePlanner.java b/OsmAnd-java/src/main/java/net/osmand/router/BinaryRoutePlanner.java index dabefe81b3..0769e1390c 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/BinaryRoutePlanner.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/BinaryRoutePlanner.java @@ -658,7 +658,7 @@ public class BinaryRoutePlanner { break; } } - if (rv == viaId && rt == MapRenderingTypes.RESTRICTION_ONLY_STRAIGHT_ON) { + if (rv == viaId && via && rt == MapRenderingTypes.RESTRICTION_ONLY_STRAIGHT_ON) { type = MapRenderingTypes.RESTRICTION_NO_STRAIGHT_ON; break; } @@ -675,7 +675,7 @@ public class BinaryRoutePlanner { } } - if (rv == viaId && rt == MapRenderingTypes.RESTRICTION_ONLY_STRAIGHT_ON) { + if (rv == viaId && via && rt == MapRenderingTypes.RESTRICTION_ONLY_STRAIGHT_ON) { type = MapRenderingTypes.RESTRICTION_NO_STRAIGHT_ON; break; } diff --git a/OsmAnd-java/src/main/java/net/osmand/util/MapUtils.java b/OsmAnd-java/src/main/java/net/osmand/util/MapUtils.java index 7a37eee3aa..97e921a3d4 100644 --- a/OsmAnd-java/src/main/java/net/osmand/util/MapUtils.java +++ b/OsmAnd-java/src/main/java/net/osmand/util/MapUtils.java @@ -49,6 +49,47 @@ public class MapUtils { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '_', '~' }; + public static int calculateFromBaseZoomPrecisionXY(int baseZoom, int finalZoom, int xFinal, int yFinal) { + int px = xFinal; + int py = yFinal; + int precisionNumber = 1; + for (int zoom = finalZoom - 1; zoom >= baseZoom; zoom--) { + int x = px / 2; // (int) MapUtils.getTileNumberX(zoom, lon); + int y = py / 2; // (int) MapUtils.getTileNumberY(zoom, lat); + int deltax = px - x * 2; + int deltay = py - y * 2; + precisionNumber = (precisionNumber << 2) + (deltax << 1) + deltay; + // StringBuilder spaces = new StringBuilder(); + // for (int i = 0; i < 32 - zoom; i++) { + // spaces.append(' '); + // } + // System.out.println(String.format("%d %s + %d %s %s + %d", zoom, Integer.toBinaryString(x), deltax, spaces.toString(), Integer.toBinaryString(y), deltay)); + px = x; + py = y; + } + // System.out.println(String.format("Bits: %d %s (%d)", Integer.toBinaryString(precisionNumber).length(), Integer.toBinaryString(precisionNumber), precisionNumber)); + return precisionNumber; + } + + public static int[] calculateFinalXYFromBaseAndPrecisionXY(int bazeZoom, int finalZoom, + int precisionXY, int xBase, int yBase, boolean ignoreNotEnoughPrecision) { + // System.out.println(String.format("Base x, y at zoom %d: %d %d", zoomToStart, xBaseApproximation, yBaseApproximation)); + // calculate finish approximation using precisionNumber + int finalX = xBase; + int finalY = yBase; + int precisionCalc = precisionXY; + for (int zoom = bazeZoom; zoom < finalZoom; zoom++) { + if (precisionCalc <= 1 && precisionCalc > 0 && !ignoreNotEnoughPrecision) { + throw new IllegalArgumentException("Not enough bits to retrieve zoom approximation"); + } + finalY = finalY * 2 + (precisionXY & 1); + finalX = finalX * 2 + ((precisionXY & 2) >> 1); + precisionXY = precisionXY >> 2; + } + // System.out.println(String.format("Calc x, y at zoom %d: %d %d", finalZoom, finalX, finalY)); + return new int[] { finalX, finalY }; + } + public static double getDistance(LatLon l, double latitude, double longitude) { diff --git a/OsmAnd-telegram/res/values-uk/strings.xml b/OsmAnd-telegram/res/values-uk/strings.xml index 40c91d4ed3..1cf8bf63b6 100644 --- a/OsmAnd-telegram/res/values-uk/strings.xml +++ b/OsmAnd-telegram/res/values-uk/strings.xml @@ -135,10 +135,10 @@ мл км м - мор.м. + nmi хв/м хв/км - вузл + вузлів м/с км/г мл/г diff --git a/OsmAnd/.gitignore b/OsmAnd/.gitignore index b8c08a2225..3149fb4209 100644 --- a/OsmAnd/.gitignore +++ b/OsmAnd/.gitignore @@ -39,8 +39,6 @@ mx_* valgrind/ bin/ dist/ -res/values/no_translate.xml -res/values/skip_translate.xml assets/specialphrases/* assets/voice/* assets/fonts/* diff --git a/OsmAnd/AndroidManifest-gplayFree.xml b/OsmAnd/AndroidManifest-gplayFree.xml index 873848e1e9..eb06260f4e 100644 --- a/OsmAnd/AndroidManifest-gplayFree.xml +++ b/OsmAnd/AndroidManifest-gplayFree.xml @@ -4,7 +4,7 @@ - - diff --git a/OsmAnd/AndroidManifest-nightlyFree.xml b/OsmAnd/AndroidManifest-nightlyFree.xml index 6ec6d5a12e..d4e57e4b87 100644 --- a/OsmAnd/AndroidManifest-nightlyFree.xml +++ b/OsmAnd/AndroidManifest-nightlyFree.xml @@ -5,9 +5,6 @@ - replaceNoTranslate(line); - } - } - into 'res/values/' -} task validateTranslate { println "Validating translations" @@ -147,10 +138,6 @@ task collectVoiceAssets(type: Sync) { include "**/*.js" } -task cleanNoTranslate(type: Delete) { - delete('res/values/no_translate.xml') -} - task collectFonts(type: Copy) { from "../../resources/fonts" from "../../resources/rendering_styles/fonts" @@ -262,7 +249,6 @@ task collectExternalResources { copyMapShaderIcons, copyMapPOIIcons, copyLargePOIIcons, - updateNoTranslate, validateTranslate, copyWidgetIcons, copyWidgetIconsHdpi, diff --git a/OsmAnd/build-library.gradle b/OsmAnd/build-library.gradle index b8cf0a21a5..2c50079396 100644 --- a/OsmAnd/build-library.gradle +++ b/OsmAnd/build-library.gradle @@ -24,14 +24,11 @@ android { // Build that doesn't include 3D OpenGL legacy { dimension "coreversion" + resValue "string", "app_edition", "" } } } -def replaceNoTranslate(line) { - return line; -} - afterEvaluate { android.libraryVariants.all { variant -> variant.javaCompiler.dependsOn(collectExternalResources, buildOsmAndCore, cleanupDuplicatesInCore) diff --git a/OsmAnd/build.gradle b/OsmAnd/build.gradle index 436aa652dc..11c9388fa0 100644 --- a/OsmAnd/build.gradle +++ b/OsmAnd/build.gradle @@ -36,9 +36,9 @@ android { defaultConfig { minSdkVersion System.getenv("MIN_SDK_VERSION") ? System.getenv("MIN_SDK_VERSION").toInteger() : 15 - versionCode 390 + versionCode 400 versionCode System.getenv("APK_NUMBER_VERSION") ? System.getenv("APK_NUMBER_VERSION").toInteger() : versionCode - versionName "3.9.0" + versionName "4.0.0" versionName System.getenv("APK_VERSION")? System.getenv("APK_VERSION").toString(): versionName versionName System.getenv("APK_VERSION_SUFFIX")? versionName + System.getenv("APK_VERSION_SUFFIX").toString(): versionName } @@ -105,31 +105,45 @@ android { nightlyFree { dimension "version" applicationId "net.osmand.dev" + resValue "string", "app_name", "OsmAnd Nightly" + resValue "string", "app_edition", System.getenv("APP_EDITION") ? System.getenv("APP_EDITION") : "" // resConfig "en" } androidFull { dimension "version" applicationId "net.osmand.plus" + resValue "string", "app_name", "OsmAnd~" + resValue "string", "app_edition", System.getenv("APP_EDITION") ? System.getenv("APP_EDITION") : "" } gplayFree { dimension "version" applicationId "net.osmand" + resValue "string", "app_name", "OsmAnd" + resValue "string", "app_edition", System.getenv("APP_EDITION") ? System.getenv("APP_EDITION") : "" } gplayFull { dimension "version" applicationId "net.osmand.plus" + resValue "string", "app_name", "OsmAnd+" + resValue "string", "app_edition", System.getenv("APP_EDITION") ? System.getenv("APP_EDITION") : "" } amazonFree { dimension "version" applicationId "net.osmand" + resValue "string", "app_name", "OsmAnd" + resValue "string", "app_edition", "" } amazonFull { dimension "version" applicationId "net.osmand.plus" + resValue "string", "app_name", "OsmAnd+" + resValue "string", "app_edition", "" } huawei { dimension "version" applicationId "net.osmand.huawei" + resValue "string", "app_name", "OsmAnd" + resValue "string", "app_edition", "" } // Build that includes 3D OpenGL release @@ -153,19 +167,6 @@ android { } -def replaceNoTranslate(line) { - if (line.contains("\"app_name\"") && System.getenv("TARGET_APP_NAME")) { - return line.replaceAll(">[^<]*<", ">" + System.getenv("TARGET_APP_NAME") + "<") - } - if (line.contains("\"app_name_free\"") && System.getenv("TARGET_APP_NAME")) { - return line.replaceAll(">[^<]*<", ">" + System.getenv("TARGET_APP_NAME") + "<") - } - if (line.contains("\"app_edition\"") && System.getenv("APP_EDITION")) { - return line.replaceAll(">[^<]*<", ">" + System.getenv("APP_EDITION") + "<") - } - return line; -} - afterEvaluate { android.applicationVariants.all { variant -> variant.javaCompiler.dependsOn(collectExternalResources, buildOsmAndCore, cleanupDuplicatesInCore) diff --git a/OsmAnd/res/drawable/bottom_navigation_item_bg_dark.xml b/OsmAnd/res/drawable/bottom_navigation_item_bg_dark.xml new file mode 100644 index 0000000000..f0934052c1 --- /dev/null +++ b/OsmAnd/res/drawable/bottom_navigation_item_bg_dark.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/drawable/bottom_navigation_item_bg_light.xml b/OsmAnd/res/drawable/bottom_navigation_item_bg_light.xml new file mode 100644 index 0000000000..f410c7a1ff --- /dev/null +++ b/OsmAnd/res/drawable/bottom_navigation_item_bg_light.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/drawable/ic_action_ruler_line.xml b/OsmAnd/res/drawable/ic_action_ruler_line.xml new file mode 100644 index 0000000000..0fb6bfc5fa --- /dev/null +++ b/OsmAnd/res/drawable/ic_action_ruler_line.xml @@ -0,0 +1,23 @@ + + + + + + diff --git a/OsmAnd/res/drawable/navigation_item_active_bg_dark.xml b/OsmAnd/res/drawable/navigation_item_active_bg_dark.xml new file mode 100644 index 0000000000..de8b54eb6e --- /dev/null +++ b/OsmAnd/res/drawable/navigation_item_active_bg_dark.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/drawable/navigation_item_active_bg_light.xml b/OsmAnd/res/drawable/navigation_item_active_bg_light.xml new file mode 100644 index 0000000000..31d31f1c40 --- /dev/null +++ b/OsmAnd/res/drawable/navigation_item_active_bg_light.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/layout/favorite_category_dialog_item.xml b/OsmAnd/res/layout/favorite_category_dialog_item.xml index 92aa731363..c5e3e52d7a 100644 --- a/OsmAnd/res/layout/favorite_category_dialog_item.xml +++ b/OsmAnd/res/layout/favorite_category_dialog_item.xml @@ -1,25 +1,27 @@ -