From 093b0571c79425fc06ce340c5f058c373aef8074 Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Fri, 6 Nov 2020 18:02:29 +0200 Subject: [PATCH 1/3] Fix #10021 Favorite size should not be arbitrary --- OsmAnd/src/net/osmand/plus/audionotes/AudioNotesLayer.java | 2 +- OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java | 2 +- OsmAnd/src/net/osmand/plus/views/layers/FavouritesLayer.java | 2 +- OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java | 2 +- OsmAnd/src/net/osmand/plus/views/layers/POIMapLayer.java | 2 +- .../src/net/osmand/plus/views/layers/TransportStopsLayer.java | 4 ++-- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/audionotes/AudioNotesLayer.java b/OsmAnd/src/net/osmand/plus/audionotes/AudioNotesLayer.java index 20b9ac2d93..7a454f3a56 100644 --- a/OsmAnd/src/net/osmand/plus/audionotes/AudioNotesLayer.java +++ b/OsmAnd/src/net/osmand/plus/audionotes/AudioNotesLayer.java @@ -70,7 +70,7 @@ public class AudioNotesLayer extends OsmandMapLayer implements public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) { if (tileBox.getZoom() >= startZoom) { float textScale = activity.getMyApplication().getSettings().TEXT_SCALE.get(); - float iconSize = getIconSize(activity) * 3 / 2.5f * textScale; + float iconSize = getIconSize(activity) * 0.45f * textScale; QuadTree boundIntersections = initBoundIntersections(tileBox); DataTileManager recs = plugin.getRecordings(); diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java index da6dd2bdd3..840a5c53f5 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java @@ -112,7 +112,7 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider if (objects != null) { float textScale = activity.getMyApplication().getSettings().TEXT_SCALE.get(); - float iconSize = getIconSize(activity) * 3 / 2.5f * textScale; + float iconSize = getIconSize(activity) * 0.45f * textScale; QuadTree boundIntersections = initBoundIntersections(tileBox); List fullObjects = new ArrayList<>(); List fullObjectsLatLon = new ArrayList<>(); diff --git a/OsmAnd/src/net/osmand/plus/views/layers/FavouritesLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/FavouritesLayer.java index d0a1b91d8b..32e578cb21 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/FavouritesLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/FavouritesLayer.java @@ -95,7 +95,7 @@ public class FavouritesLayer extends OsmandMapLayer implements ContextMenuLayer. if (this.settings.SHOW_FAVORITES.get() && favorites.isFavoritesLoaded()) { if (tileBox.getZoom() >= startZoom) { float textScale = this.settings.TEXT_SCALE.get(); - float iconSize = getIconSize(view.getContext()) * 3 / 2.5f * textScale; + float iconSize = getIconSize(view.getContext()) * 0.45f * textScale; QuadTree boundIntersections = initBoundIntersections(tileBox); // request to load diff --git a/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java index 46d51bca33..5646b02e85 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java @@ -494,7 +494,7 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM private void drawSelectedFilesPoints(Canvas canvas, RotatedTileBox tileBox, List selectedGPXFiles) { if (tileBox.getZoom() >= START_ZOOM) { float textScale = view.getSettings().TEXT_SCALE.get(); - float iconSize = getIconSize(view.getContext()) * 3 / 2.5f * textScale; + float iconSize = getIconSize(view.getContext()) * 0.45f * textScale; QuadTree boundIntersections = initBoundIntersections(tileBox); List fullObjectsLatLon = new ArrayList<>(); diff --git a/OsmAnd/src/net/osmand/plus/views/layers/POIMapLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/POIMapLayer.java index ed0f2cc45d..8bdc6a610f 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/POIMapLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/POIMapLayer.java @@ -200,7 +200,7 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon objects = data.getResults(); if (objects != null) { float textScale = app.getSettings().TEXT_SCALE.get(); - float iconSize = getIconSize(app) * 1.5f * textScale; + float iconSize = getIconSize(app) * 0.45f * textScale; QuadTree boundIntersections = initBoundIntersections(tileBox); WaypointHelper wph = app.getWaypointHelper(); PointImageDrawable pointImageDrawable = PointImageDrawable.getOrCreate(view.getContext(), diff --git a/OsmAnd/src/net/osmand/plus/views/layers/TransportStopsLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/TransportStopsLayer.java index 2eb4f27956..356013c01c 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/TransportStopsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/TransportStopsLayer.java @@ -218,7 +218,7 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa if (objects != null) { float textScale = mapActivity.getMyApplication().getSettings().TEXT_SCALE.get(); - float iconSize = getIconSize(mapActivity) * 3 / 2.5f * textScale; + float iconSize = getIconSize(mapActivity) * 0.45f * textScale; QuadTree boundIntersections = initBoundIntersections(tb); List fullObjects = new ArrayList<>(); for (TransportStop o : objects) { @@ -228,7 +228,7 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa if (intersects(boundIntersections, x, y, iconSize, iconSize)) { PointImageDrawable pointImageDrawable = PointImageDrawable.getOrCreate(mapActivity, ContextCompat.getColor(mapActivity, R.color.transport_stop_icon_background), - true,false ,0, BackgroundType.SQUARE); + true, false, 0, BackgroundType.SQUARE); pointImageDrawable.setAlpha(0.9f); pointImageDrawable.drawSmallPoint(canvas, x, y, textScale); } else { From 41a96bcce075b242810e18b3825299e457d3ccba Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Fri, 6 Nov 2020 19:30:36 +0200 Subject: [PATCH 2/3] Fix review --- .../src/net/osmand/plus/audionotes/AudioNotesLayer.java | 6 ++++-- OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java | 9 +++++---- OsmAnd/src/net/osmand/plus/views/OsmandMapLayer.java | 6 +++--- .../net/osmand/plus/views/layers/FavouritesLayer.java | 2 +- OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java | 2 +- OsmAnd/src/net/osmand/plus/views/layers/POIMapLayer.java | 5 +++-- .../osmand/plus/views/layers/TransportStopsLayer.java | 8 +++++--- 7 files changed, 22 insertions(+), 16 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/audionotes/AudioNotesLayer.java b/OsmAnd/src/net/osmand/plus/audionotes/AudioNotesLayer.java index 7a454f3a56..ea0694aa8d 100644 --- a/OsmAnd/src/net/osmand/plus/audionotes/AudioNotesLayer.java +++ b/OsmAnd/src/net/osmand/plus/audionotes/AudioNotesLayer.java @@ -13,6 +13,7 @@ import net.osmand.data.PointDescription; import net.osmand.data.QuadRect; import net.osmand.data.QuadTree; import net.osmand.data.RotatedTileBox; +import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.audionotes.AudioVideoNotesPlugin.Recording; @@ -69,8 +70,9 @@ public class AudioNotesLayer extends OsmandMapLayer implements @Override public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) { if (tileBox.getZoom() >= startZoom) { - float textScale = activity.getMyApplication().getSettings().TEXT_SCALE.get(); - float iconSize = getIconSize(activity) * 0.45f * textScale; + OsmandApplication app = activity.getMyApplication(); + float textScale = app.getSettings().TEXT_SCALE.get(); + float iconSize = getIconSize(app); QuadTree boundIntersections = initBoundIntersections(tileBox); DataTileManager recs = plugin.getRecordings(); diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java index 840a5c53f5..ff2554dfe6 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java @@ -104,20 +104,21 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider @Override public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) { - startZoom = activity.getMyApplication().getSettings().SHOW_OSM_BUGS_MIN_ZOOM.get(); + OsmandApplication app = activity.getMyApplication(); + startZoom = app.getSettings().SHOW_OSM_BUGS_MIN_ZOOM.get(); if (tileBox.getZoom() >= startZoom) { // request to load data.queryNewData(tileBox); List objects = data.getResults(); if (objects != null) { - float textScale = activity.getMyApplication().getSettings().TEXT_SCALE.get(); - float iconSize = getIconSize(activity) * 0.45f * textScale; + float textScale = app.getSettings().TEXT_SCALE.get(); + float iconSize = getIconSize(app); QuadTree boundIntersections = initBoundIntersections(tileBox); List fullObjects = new ArrayList<>(); List fullObjectsLatLon = new ArrayList<>(); List smallObjectsLatLon = new ArrayList<>(); - boolean showClosed = activity.getMyApplication().getSettings().SHOW_CLOSED_OSM_BUGS.get(); + boolean showClosed = app.getSettings().SHOW_CLOSED_OSM_BUGS.get(); for (OpenStreetNote o : objects) { if (!o.isOpened() && !showClosed) { continue; diff --git a/OsmAnd/src/net/osmand/plus/views/OsmandMapLayer.java b/OsmAnd/src/net/osmand/plus/views/OsmandMapLayer.java index 2b00b9f498..67e046c1de 100644 --- a/OsmAnd/src/net/osmand/plus/views/OsmandMapLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/OsmandMapLayer.java @@ -1,6 +1,5 @@ package net.osmand.plus.views; -import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.ColorFilter; @@ -44,6 +43,7 @@ import java.util.Map; public abstract class OsmandMapLayer { + public static final float ICON_VISIBLE_PART_RATIO = 0.45f; protected List fullObjectsLatLon; protected List smallObjectsLatLon; @@ -235,8 +235,8 @@ public abstract class OsmandMapLayer { return (int) (r * tb.getDensity()); } - protected int getIconSize(Context ctx) { - return ctx.getResources().getDimensionPixelSize(R.dimen.favorites_icon_outline_size); + protected float getIconSize(OsmandApplication app) { + return app.getResources().getDimensionPixelSize(R.dimen.favorites_icon_outline_size) * ICON_VISIBLE_PART_RATIO * app.getSettings().TEXT_SCALE.get(); } public Rect getIconDestinationRect(float x, float y, int width, int height, float scale) { diff --git a/OsmAnd/src/net/osmand/plus/views/layers/FavouritesLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/FavouritesLayer.java index 32e578cb21..8cfc3025dd 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/FavouritesLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/FavouritesLayer.java @@ -95,7 +95,7 @@ public class FavouritesLayer extends OsmandMapLayer implements ContextMenuLayer. if (this.settings.SHOW_FAVORITES.get() && favorites.isFavoritesLoaded()) { if (tileBox.getZoom() >= startZoom) { float textScale = this.settings.TEXT_SCALE.get(); - float iconSize = getIconSize(view.getContext()) * 0.45f * textScale; + float iconSize = getIconSize(view.getApplication()); QuadTree boundIntersections = initBoundIntersections(tileBox); // request to load diff --git a/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java index 5646b02e85..b960b643bf 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java @@ -494,7 +494,7 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM private void drawSelectedFilesPoints(Canvas canvas, RotatedTileBox tileBox, List selectedGPXFiles) { if (tileBox.getZoom() >= START_ZOOM) { float textScale = view.getSettings().TEXT_SCALE.get(); - float iconSize = getIconSize(view.getContext()) * 0.45f * textScale; + float iconSize = getIconSize(view.getApplication()); QuadTree boundIntersections = initBoundIntersections(tileBox); List fullObjectsLatLon = new ArrayList<>(); diff --git a/OsmAnd/src/net/osmand/plus/views/layers/POIMapLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/POIMapLayer.java index 8bdc6a610f..13352a81ee 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/POIMapLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/POIMapLayer.java @@ -200,7 +200,7 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon objects = data.getResults(); if (objects != null) { float textScale = app.getSettings().TEXT_SCALE.get(); - float iconSize = getIconSize(app) * 0.45f * textScale; + float iconSize = getIconSize(app); QuadTree boundIntersections = initBoundIntersections(tileBox); WaypointHelper wph = app.getWaypointHelper(); PointImageDrawable pointImageDrawable = PointImageDrawable.getOrCreate(view.getContext(), @@ -394,7 +394,8 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon public int getTextShift(Amenity amenity, RotatedTileBox rb) { int radiusPoi = getRadiusPoi(rb); if (isPresentInFullObjects(amenity.getLocation())) { - radiusPoi += (getIconSize(app) - app.getResources().getDimensionPixelSize(R.dimen.favorites_icon_size_small)) / 2; + radiusPoi += (app.getResources().getDimensionPixelSize(R.dimen.favorites_icon_outline_size) + - app.getResources().getDimensionPixelSize(R.dimen.favorites_icon_size_small)) / 2; } return radiusPoi; } diff --git a/OsmAnd/src/net/osmand/plus/views/layers/TransportStopsLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/TransportStopsLayer.java index 356013c01c..ba219f26b6 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/TransportStopsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/TransportStopsLayer.java @@ -20,6 +20,7 @@ import net.osmand.data.RotatedTileBox; import net.osmand.data.TransportStop; import net.osmand.osm.edit.Node; import net.osmand.osm.edit.Way; +import net.osmand.plus.OsmandApplication; import net.osmand.plus.base.PointImageDrawable; import net.osmand.plus.settings.backend.CommonPreference; import net.osmand.plus.settings.backend.OsmandSettings; @@ -181,10 +182,11 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tb, DrawSettings settings) { List objects = null; boolean nightMode = settings.isNightMode(); + OsmandApplication app = mapActivity.getMyApplication(); if (tb.getZoom() >= startZoomRoute) { if (stopRoute != null) { objects = stopRoute.route.getForwardStops(); - int color = stopRoute.getColor(mapActivity.getMyApplication(), nightMode); + int color = stopRoute.getColor(app, nightMode); attrs.paint.setColor(color); attrs.updatePaints(view.getApplication(), settings, tb); try { @@ -217,8 +219,8 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa } if (objects != null) { - float textScale = mapActivity.getMyApplication().getSettings().TEXT_SCALE.get(); - float iconSize = getIconSize(mapActivity) * 0.45f * textScale; + float textScale = app.getSettings().TEXT_SCALE.get(); + float iconSize = getIconSize(app); QuadTree boundIntersections = initBoundIntersections(tb); List fullObjects = new ArrayList<>(); for (TransportStop o : objects) { From 5c34327559971eda9531d6aef8efe0b1e46dc437 Mon Sep 17 00:00:00 2001 From: alex-osm <74016125+alex-osm@users.noreply.github.com> Date: Sun, 8 Nov 2020 14:16:14 +0300 Subject: [PATCH 3/3] Create GPX.md --- GPX.md | 158 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 158 insertions(+) create mode 100644 GPX.md diff --git a/GPX.md b/GPX.md new file mode 100644 index 0000000000..8ab3640620 --- /dev/null +++ b/GPX.md @@ -0,0 +1,158 @@ +The OsmAnd's GPX file format conforms to GPX 1.1 specification with additional data written as extensions. There are few sections of such data: + +## Track appearance +These parameters are used to customize the appearance of a track on the map. Used inside "gpx" tag and applies to all tracks inside gpx. +#### Parameters +* **show_arrows** [*true, false*] - show / hide arrows along the path line. +* **width** [*thin, medium, bold, 1-24*] - width of a track line on the map. The thin, medium and bold are style depended values (should be defined as currentTrackWidth attribute). +* **color** [*#AARRGGBB, #RRGGBB*] - color of a track line on the map. Hex values. +* **split_type** [*no_split, distance, time*] - split type for a track. +* **split_interval** [*double*] - split interval for a track. Distance (meters), time (seconds). + +#### Example: +```xml + +... + + true + #4e4eff + distance + 2000.0 + bold + + +``` +## Details of a track point (trkpt) +Written to a gpx file while recording a track. +* **speed** (meters per second) +* **heading** (0-359 degrees) + +#### Example: +```xml + + 203 + + 3 + + 273 + 5.02 + + +``` + +## Calculated route(s) +This data contains information about a route built with **OsmAnd** (route segments, turns, road names and types, restrictions, etc.). With their help, route can be restored completely as if it had just been built even without the currently installed offline maps. + +There can be several routes in one gpx file. Each of them is contained in a specific segment (**trkseg** / **extensions**). In this form, a gpx file is saved when exporting a constructed route or when saving a track that consists of several separate segments via the **Plan route**. +When using the **Plan route** tool, route key points (**rtept**) are additionally written to the gpx file. There can also be several **rte** blocks (according to a number of separate segments / tracks in a gpx file). + +#### Gpx structure: +```xml + + + + + + + + + + + + + + + + + + + + + + + + + + ... + + ... + + + +``` + +#### Example: +```xml + + + Fri 06 Nov 2020 + + + Fri 06 Nov 2020 + + + 0.801 + + + 0.998 + + + 1 + + + 0.963 + + + 0.899 + + + .... + + + + + + + + ... + + + + + + + + ... + + + + + + + + + pedestrian + 0 + + + + + pedestrian + 24 + + + + + pedestrian + 89 + + + + + pedestrian + 121 + + + + +```