diff --git a/NooTous/build.gradle b/NooTous/build.gradle index 08a6398a..5f6080d5 100644 --- a/NooTous/build.gradle +++ b/NooTous/build.gradle @@ -32,13 +32,10 @@ android { dependencies { - implementation 'androidx.appcompat:appcompat:1.2.0' - implementation 'com.google.android.material:material:1.2.1' - implementation 'androidx.constraintlayout:constraintlayout:2.0.1' - implementation 'androidx.navigation:navigation-fragment:2.3.0' - implementation 'androidx.navigation:navigation-ui:2.3.0' + implementation 'androidx.appcompat:appcompat:1.3.1' + implementation 'com.google.android.material:material:1.4.0' + implementation 'androidx.constraintlayout:constraintlayout:2.1.0' + implementation 'androidx.navigation:navigation-fragment:2.3.5' + implementation 'androidx.navigation:navigation-ui:2.3.5' implementation project(path: ':OSMBonusPack') - testImplementation 'junit:junit:4.+' - androidTestImplementation 'androidx.test.ext:junit:1.1.2' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' } \ No newline at end of file diff --git a/OSMBonusPack/build.gradle b/OSMBonusPack/build.gradle index 7d02b0cc..36e60247 100644 --- a/OSMBonusPack/build.gradle +++ b/OSMBonusPack/build.gradle @@ -1,13 +1,13 @@ apply plugin: 'com.android.library' android { - compileSdkVersion 28 + compileSdkVersion 30 defaultConfig { minSdkVersion 16 - targetSdkVersion 28 - versionCode 67 - versionName "6.7-SNAPSHOT" + targetSdkVersion 30 + versionCode 68 + versionName "6.8-SNAPSHOT" } buildTypes { release { @@ -23,9 +23,9 @@ android { } dependencies { - api 'org.osmdroid:osmdroid-android:6.1.10' + api 'org.osmdroid:osmdroid-android:6.1.11' implementation 'org.apache.commons:commons-lang3:3.8.1' api 'com.google.code.gson:gson:2.8.6' implementation 'com.squareup.okhttp3:okhttp:4.7.2' - implementation 'androidx.core:core:1.2.0' + implementation 'androidx.core:core:1.5.0' } diff --git a/OSMBonusPack/src/main/java/org/osmdroid/bonuspack/clustering/GridMarkerClusterer.java b/OSMBonusPack/src/main/java/org/osmdroid/bonuspack/clustering/GridMarkerClusterer.java deleted file mode 100644 index e75df235..00000000 --- a/OSMBonusPack/src/main/java/org/osmdroid/bonuspack/clustering/GridMarkerClusterer.java +++ /dev/null @@ -1,137 +0,0 @@ -package org.osmdroid.bonuspack.clustering; - -import android.graphics.Bitmap; -import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.Paint; -import android.graphics.Rect; -import android.graphics.drawable.BitmapDrawable; -import android.util.LongSparseArray; -import org.osmdroid.util.BoundingBox; -import org.osmdroid.views.MapView; -import org.osmdroid.views.overlay.Marker; - -import java.util.ArrayList; - -/** - * Grid-based Clustering algorithm: all markers inside the same cell belong to the same cluster. - * The grid size is specified in screen pixels.
- * - * TODO: check what happens with map rotation.
- * TODO: clustering is not perfectly stable: if you zoom in then out, the mapview lat/lon span may change a little bit, - * potentially changing the grid positioning - * => Considering this issue, this class is deprecated. Use RadiusMarkerClusterer instead.
- * - * Largely inspired from (open source) Google Maps Android utility library. - * - * @see android-maps-utils - * @author M.Kergall - * - */ -@Deprecated public class GridMarkerClusterer extends MarkerClusterer { - - protected int mGridSize = 50; //in pixels - protected Paint mTextPaint; - - /** cluster icon anchor */ - public float mAnchorU = Marker.ANCHOR_CENTER, mAnchorV = Marker.ANCHOR_CENTER; - /** anchor point to draw the number of markers inside the cluster icon */ - public float mTextAnchorU = Marker.ANCHOR_CENTER, mTextAnchorV = Marker.ANCHOR_CENTER; - - public GridMarkerClusterer() { - super(); - mTextPaint = new Paint(); - mTextPaint.setColor(Color.WHITE); - mTextPaint.setTextSize(15.0f); - mTextPaint.setFakeBoldText(true); - mTextPaint.setTextAlign(Paint.Align.CENTER); - mTextPaint.setAntiAlias(true); - } - - /** If you want to change the default text paint (color, size, font) */ - public Paint getTextPaint(){ - return mTextPaint; - } - - /** Change the size of the clustering grid, in pixels. Default is 50px. */ - public void setGridSize(int gridSize){ - mGridSize = gridSize; - } - - /** Grid-based clustering algorithm */ - @Override public ArrayList clusterer(MapView mapView){ - Rect mScreenRect = mapView.getIntrinsicScreenRect(null); - - BoundingBox bb = mapView.getBoundingBox(); - double latSpan = bb.getLatitudeSpan(); - double lonSpan = bb.getLongitudeSpan(); - //Log.d("ZOOM", "latSpan="+latSpan+" lonSpan="+lonSpan); - - //convert grid size from pixels to degrees: - double gridSizeX, gridSizeY; - gridSizeX = lonSpan * (double)mGridSize / (double)(mScreenRect.right - mScreenRect.left); - gridSizeY = latSpan * (double)mGridSize / (double)(mScreenRect.bottom - mScreenRect.top); - - int numCellsW = (int)(360.0f/gridSizeX); - //Log.d("ZOOM", "zoomlevel="+mapView.getZoomLevel()+" cells="+numCellsW); - //Log.d("ZOOM", "gridSizeX="+gridSizeX+" gridSizeY="+gridSizeY); - - ArrayList clusters = new ArrayList(); - LongSparseArray sparseArray = new LongSparseArray(); - for (Marker item:mItems){ - //TODO - add 180° to prevent negative values - long gridX = (long)(item.getPosition().getLongitude() / gridSizeX); - long gridY = (long)(item.getPosition().getLatitude() / gridSizeY); - long coord = numCellsW * gridX + gridY; - StaticCluster cluster = sparseArray.get(coord); - //Log.d("ZOOM", "coord="+coord+" =>cluster:"+(cluster==null?"new":"add")); - if (cluster == null) { - //GeoPoint clusterCorner = new GeoPoint(gridSizeY*(double)gridY, gridSizeX*(double)gridX); - cluster = new StaticCluster(item.getPosition() /*clusterCorner*/); - sparseArray.put(coord, cluster); - clusters.add(cluster); - } - cluster.add(item); - } - return clusters; - } - - /** Build the marker for a cluster. - * Uses the cluster icon, and displays inside the number of markers it contains.
- * In the standard Google coordinate system for Marker icons:
- * - The cluster icon is anchored at mAnchorU, mAnchorV.
- * - The text showing the number of markers is anchored at mTextAnchorU, mTextAnchorV. - * This text is centered horizontally and vertically. */ - @Override public Marker buildClusterMarker(StaticCluster cluster, MapView mapView){ - Marker m = new Marker(mapView); - m.setPosition(cluster.getPosition()); - m.setInfoWindow(null); - m.setAnchor(mAnchorU, mAnchorV); - Bitmap finalIcon = Bitmap.createBitmap(mClusterIcon.getWidth(), mClusterIcon.getHeight(), mClusterIcon.getConfig()); - Canvas iconCanvas = new Canvas(finalIcon); - iconCanvas.drawBitmap(mClusterIcon, 0, 0, null); - String text = ""+cluster.getSize(); - int textHeight = (int) (mTextPaint.descent() + mTextPaint.ascent()); - iconCanvas.drawText(text, - mTextAnchorU*finalIcon.getWidth(), - mTextAnchorV*finalIcon.getHeight() - textHeight/2, - mTextPaint); - m.setIcon(new BitmapDrawable(mapView.getContext().getResources(), finalIcon)); - return m; - } - - /** Build clusters markers to be used at next draw */ - @Override public void renderer(ArrayList clusters, Canvas canvas, MapView mapView){ - for (StaticCluster cluster:clusters){ - if (cluster.getSize()==1){ - //cluster has only 1 marker => use it as it is: - cluster.setMarker(cluster.getItem(0)); - } else { - //only draw 1 Marker at Cluster center, displaying number of Markers contained - Marker m = buildClusterMarker(cluster, mapView); - cluster.setMarker(m); - } - } - } - -} diff --git a/OSMBonusPack/src/main/java/org/osmdroid/bonuspack/routing/Road.java b/OSMBonusPack/src/main/java/org/osmdroid/bonuspack/routing/Road.java index b9b8c714..2965421e 100644 --- a/OSMBonusPack/src/main/java/org/osmdroid/bonuspack/routing/Road.java +++ b/OSMBonusPack/src/main/java/org/osmdroid/bonuspack/routing/Road.java @@ -7,9 +7,9 @@ import org.osmdroid.bonuspack.R; import org.osmdroid.bonuspack.utils.BonusPackHelper; -import org.osmdroid.bonuspack.utils.DouglasPeuckerReducer; import org.osmdroid.util.BoundingBox; import org.osmdroid.util.GeoPoint; +import org.osmdroid.util.PointReducer; import java.util.ArrayList; @@ -91,7 +91,7 @@ public ArrayList getRouteLow(){ if (mRouteLow == null){ //Simplify the route (divide number of points by around 10): int n = mRouteHigh.size(); - mRouteLow = DouglasPeuckerReducer.reduceWithTolerance(mRouteHigh, 1500.0); + mRouteLow = PointReducer.reduceWithTolerance(mRouteHigh, 1500.0); Log.d(BonusPackHelper.LOG_TAG, "Road reduced from "+n+" to "+mRouteLow.size()+ " points"); } return mRouteLow; diff --git a/OSMBonusPack/src/main/java/org/osmdroid/bonuspack/utils/DouglasPeuckerReducer.java b/OSMBonusPack/src/main/java/org/osmdroid/bonuspack/utils/DouglasPeuckerReducer.java deleted file mode 100644 index 68860e2c..00000000 --- a/OSMBonusPack/src/main/java/org/osmdroid/bonuspack/utils/DouglasPeuckerReducer.java +++ /dev/null @@ -1,140 +0,0 @@ -package org.osmdroid.bonuspack.utils; - -import org.osmdroid.util.GeoPoint; - -import java.util.ArrayList; - -/** Reduces the number of points in a shape using the Douglas-Peucker algorithm.
- * - * From: http://www.phpriot.com/articles/reducing-map-path-douglas-peucker-algorithm/4
- * Ported from PHP to Java. "marked" array added to optimize. - * @author M.Kergall - * @deprecated as the whole class has been moved in osmdroid (renamed PointReducer). - */ -@Deprecated public class DouglasPeuckerReducer { - - /** - * Reduce the number of points in a shape using the Douglas-Peucker algorithm - * - * @param shape The shape to reduce - * @param tolerance The tolerance to decide whether or not - * to keep a point, in the coordinate system - * of the points (micro-degrees here) - * @return the reduced shape - */ - public static ArrayList reduceWithTolerance(ArrayList shape, double tolerance) - { - int n = shape.size(); - // if a shape has 2 or less points it cannot be reduced - if (tolerance <= 0 || n < 3) { - return shape; - } - - boolean [] marked = new boolean[n]; //vertex indexes to keep will be marked as "true" - for (int i=1; i newShape = new ArrayList(n); // the new shape to return - for (int i=0; i shape, boolean[] marked, double tolerance, int firstIdx, int lastIdx) - { - if (lastIdx <= firstIdx + 1) { - // overlapping indexes, just return - return; - } - - // loop over the points between the first and last points - // and find the point that is the farthest away - - double maxDistance = 0.0; - int indexFarthest = 0; - - GeoPoint firstPoint = shape.get(firstIdx); - GeoPoint lastPoint = shape.get(lastIdx); - - for (int idx = firstIdx + 1; idx < lastIdx; idx++) { - GeoPoint point = shape.get(idx); - - double distance = orthogonalDistance(point, firstPoint, lastPoint); - - // keep the point with the greatest distance - if (distance > maxDistance) { - maxDistance = distance; - indexFarthest = idx; - } - } - - if (maxDistance > tolerance) { - //The farthest point is outside the tolerance: it is marked and the algorithm continues. - marked[indexFarthest] = true; - - // reduce the shape between the starting point to newly found point - douglasPeuckerReduction(shape, marked, tolerance, firstIdx, indexFarthest); - - // reduce the shape between the newly found point and the finishing point - douglasPeuckerReduction(shape, marked, tolerance, indexFarthest, lastIdx); - } - //else: the farthest point is within the tolerance, the whole segment is discarded. - } - - /** - * Calculate the orthogonal distance from the line joining the - * lineStart and lineEnd points to point - * - * @param point The point the distance is being calculated for - * @param lineStart The point that starts the line - * @param lineEnd The point that ends the line - * @return The distance in points coordinate system - */ - public static double orthogonalDistance(GeoPoint point, GeoPoint lineStart, GeoPoint lineEnd) - { - double area = Math.abs( - ( - lineStart.getLatitude() * lineEnd.getLongitude() - + lineEnd.getLatitude() * point.getLongitude() - + point.getLatitude() * lineStart.getLongitude() - - lineEnd.getLatitude() * lineStart.getLongitude() - - point.getLatitude() * lineEnd.getLongitude() - - lineStart.getLatitude() * point.getLongitude() - ) / 2.0 - ); - - double bottom = Math.hypot( - lineStart.getLatitude() - lineEnd.getLatitude(), - lineStart.getLongitude() - lineEnd.getLongitude() - ); - - return(area / bottom * 2.0); - } -} diff --git a/OSMBonusPackTuto/build.gradle b/OSMBonusPackTuto/build.gradle index a39bcb76..d562c9a9 100644 --- a/OSMBonusPackTuto/build.gradle +++ b/OSMBonusPackTuto/build.gradle @@ -1,12 +1,12 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 28 + compileSdkVersion 30 defaultConfig { applicationId "com.example.osmbonuspacktuto" minSdkVersion 16 - targetSdkVersion 28 + targetSdkVersion 30 versionCode 1 versionName "1.0" } @@ -35,7 +35,7 @@ dependencies { // including as local lib /* compile(name: 'osmbonuspack_v6.7.0', ext: 'aar') - implementation 'org.osmdroid:osmdroid-android:6.1.10' + implementation 'org.osmdroid:osmdroid-android:6.1.11' implementation 'org.apache.commons:commons-lang3:3.8.1' implementation 'com.google.code.gson:gson:2.8.6' implementation 'com.squareup.okhttp3:okhttp:4.7.2' diff --git a/OSMNavigator/build.gradle b/OSMNavigator/build.gradle index c5e7750e..75cbdebf 100644 --- a/OSMNavigator/build.gradle +++ b/OSMNavigator/build.gradle @@ -1,12 +1,12 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 29 + compileSdkVersion 30 defaultConfig { applicationId "com.osmnavigator" minSdkVersion 16 - targetSdkVersion 29 + targetSdkVersion 30 versionCode 25 versionName "2.5" } diff --git a/OSMNavigator/src/main/java/com/osmnavigator/MapActivity.java b/OSMNavigator/src/main/java/com/osmnavigator/MapActivity.java index c9e8aca7..fa85d101 100644 --- a/OSMNavigator/src/main/java/com/osmnavigator/MapActivity.java +++ b/OSMNavigator/src/main/java/com/osmnavigator/MapActivity.java @@ -179,7 +179,7 @@ public class MapActivity extends Activity implements MapEventsReceiver, Location OnlineTileSourceBase MAPBOXSATELLITELABELLED; boolean mNightMode; - static final String userAgent = "OsmNavigator/2.4"; + static final String userAgent = BuildConfig.APPLICATION_ID+"/"+BuildConfig.VERSION_NAME; static String graphHopperApiKey; static String flickrApiKey;