From 9a61ddac93c342d1e3c8f185644d8eaacf123f7e Mon Sep 17 00:00:00 2001 From: afischerdev Date: Mon, 17 Apr 2023 10:00:40 +0200 Subject: [PATCH 1/5] clean up log --- .../src/main/java/btools/routingapp/BRouterService.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/brouter-routing-app/src/main/java/btools/routingapp/BRouterService.java b/brouter-routing-app/src/main/java/btools/routingapp/BRouterService.java index 2abbb7d..668b0a9 100644 --- a/brouter-routing-app/src/main/java/btools/routingapp/BRouterService.java +++ b/brouter-routing-app/src/main/java/btools/routingapp/BRouterService.java @@ -29,7 +29,6 @@ public class BRouterService extends Service { @Override public IBinder onBind(Intent arg0) { - Log.d(getClass().getSimpleName(), "onBind()"); return myBRouterServiceStub; } @@ -277,13 +276,11 @@ public class BRouterService extends Service { @Override public void onCreate() { super.onCreate(); - Log.d(getClass().getSimpleName(), "onCreate()"); } @Override public void onDestroy() { super.onDestroy(); - Log.d(getClass().getSimpleName(), "onDestroy()"); } // This is the old onStart method that will be called on the pre-2.0 From 3675a2c9dd2ee5b7767ad4a1c479655cc67e266d Mon Sep 17 00:00:00 2001 From: afischerdev Date: Mon, 17 Apr 2023 10:02:07 +0200 Subject: [PATCH 2/5] more heap to avoid OOM --- brouter-routing-app/src/main/AndroidManifest.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/brouter-routing-app/src/main/AndroidManifest.xml b/brouter-routing-app/src/main/AndroidManifest.xml index dc4a3fd..842b8d9 100644 --- a/brouter-routing-app/src/main/AndroidManifest.xml +++ b/brouter-routing-app/src/main/AndroidManifest.xml @@ -18,6 +18,7 @@ android:label="@string/app_name" android:preserveLegacyExternalStorage="true" android:hasFragileUserData="true" + android:largeHeap="true" android:roundIcon="@mipmap/ic_launcher_round" android:theme="@style/Theme.App"> Date: Mon, 17 Apr 2023 10:03:32 +0200 Subject: [PATCH 3/5] more checks for online problems --- .../btools/routingapp/BInstallerActivity.java | 19 +++++--- .../btools/routingapp/DownloadWorker.java | 46 +++++++++++-------- 2 files changed, 38 insertions(+), 27 deletions(-) diff --git a/brouter-routing-app/src/main/java/btools/routingapp/BInstallerActivity.java b/brouter-routing-app/src/main/java/btools/routingapp/BInstallerActivity.java index 6370b02..31e597e 100644 --- a/brouter-routing-app/src/main/java/btools/routingapp/BInstallerActivity.java +++ b/brouter-routing-app/src/main/java/btools/routingapp/BInstallerActivity.java @@ -33,7 +33,6 @@ import androidx.work.NetworkType; import androidx.work.OneTimeWorkRequest; import androidx.work.WorkInfo; import androidx.work.WorkManager; -import androidx.work.WorkRequest; import com.google.android.material.progressindicator.LinearProgressIndicator; import com.google.common.util.concurrent.ListenableFuture; @@ -92,8 +91,7 @@ public class BInstallerActivity extends AppCompatActivity { if (ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.POST_NOTIFICATIONS) == PackageManager.PERMISSION_GRANTED) { // nothing to do - } - if (shouldShowRequestPermissionRationale(Manifest.permission.POST_NOTIFICATIONS)) { + } else if (shouldShowRequestPermissionRationale(Manifest.permission.POST_NOTIFICATIONS)) { // } else { // You can directly ask for the permission. @@ -222,14 +220,14 @@ public class BInstallerActivity extends AppCompatActivity { .setRequiredNetworkType(NetworkType.CONNECTED) .build(); - WorkRequest downloadWorkRequest = + OneTimeWorkRequest downloadWorkRequest = new OneTimeWorkRequest.Builder(DownloadWorker.class) .setInputData(inputData) .setConstraints(constraints) .build(); WorkManager workManager = WorkManager.getInstance(getApplicationContext()); - workManager.enqueueUniqueWork(DownloadWorker.WORKER_NAME, ExistingWorkPolicy.KEEP, (OneTimeWorkRequest) downloadWorkRequest); + workManager.enqueueUniqueWork(DownloadWorker.WORKER_NAME, ExistingWorkPolicy.KEEP, downloadWorkRequest); try { WorkInfo wi = WorkManager.getInstance(getApplicationContext()).getWorkInfoById(downloadWorkRequest.getId()).get(); @@ -256,7 +254,6 @@ public class BInstallerActivity extends AppCompatActivity { private void startObserver(WorkInfo workInfo) { if (workInfo != null) { if (workInfo.getState() == WorkInfo.State.ENQUEUED || workInfo.getState() == WorkInfo.State.BLOCKED) { - Log.d("worker", "cancel " + workInfo.getState()); //WorkManager.getInstance(getApplicationContext()).cancelWorkById(downloadWorkRequest.getId()); } @@ -265,6 +262,9 @@ public class BInstallerActivity extends AppCompatActivity { mProgressIndicator.hide(); mProgressIndicator.setIndeterminate(true); mProgressIndicator.show(); + + mButtonDownload.setText(getString(R.string.action_cancel)); + mButtonDownload.setEnabled(true); } if (workInfo.getState() == WorkInfo.State.RUNNING) { @@ -310,12 +310,17 @@ public class BInstallerActivity extends AppCompatActivity { } } - if (error != null && error.startsWith("error new app")) { + if (error != null && error.startsWith("Version new app")) { showAppUpdate(); } else if (error != null && error.startsWith("Version error")) { showConfirmNextSteps(); } else if (error != null && error.startsWith("Version diffs")) { showConfirmGetDiffs(); + } else if (error != null) { + stopDownload(); + mBInstallerView.setOnSelectListener(onSelectListener); + mBInstallerView.clearAllTilesStatus(MASK_SELECTED_RD5); + scanExistingFiles(); } else { mBInstallerView.setOnSelectListener(onSelectListener); mBInstallerView.clearAllTilesStatus(MASK_SELECTED_RD5); diff --git a/brouter-routing-app/src/main/java/btools/routingapp/DownloadWorker.java b/brouter-routing-app/src/main/java/btools/routingapp/DownloadWorker.java index 2e239c1..d536ae6 100644 --- a/brouter-routing-app/src/main/java/btools/routingapp/DownloadWorker.java +++ b/brouter-routing-app/src/main/java/btools/routingapp/DownloadWorker.java @@ -266,7 +266,7 @@ public class DownloadWorker extends Worker { } if (newappversion != -1 && newappversion > appversion) { if (DEBUG) Log.d(LOG_TAG, "app version old " + appversion + " new " + newappversion); - errorCode = "error new app"; + errorCode = "Version new app"; return false; } if (changed && downloadAll == VALUE_SEGMENT_PARTS) { @@ -375,36 +375,42 @@ public class DownloadWorker extends Worker { connection.setConnectTimeout(5000); connection.setRequestMethod("HEAD"); connection.setDoInput(false); - connection.connect(); + try { + connection.connect(); + return connection.getResponseCode() == HttpURLConnection.HTTP_OK; + } finally { + connection.disconnect(); + } - return connection.getResponseCode() == HttpURLConnection.HTTP_OK; } private boolean downloadFile(URL downloadUrl, File outputFile, int fileSize, boolean limitDownloadSpeed, DownloadType type) throws IOException, InterruptedException { if (DEBUG) Log.d(LOG_TAG, "download " + outputFile.getAbsolutePath()); HttpURLConnection connection = (HttpURLConnection) downloadUrl.openConnection(); connection.setConnectTimeout(5000); - connection.connect(); + connection.setDefaultUseCaches(false); - if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) { - throw new IOException("HTTP Request failed: " + downloadUrl + " returned " + connection.getResponseCode()); - } - int dataLength = connection.getContentLength(); - // no need of download when size equal - // file size not the best coice but easy to handle, date is not available - switch (type) { - case LOOKUP: - if (fileSize == dataLength) return false; - break; - case PROFILE: - if (fileSize == dataLength) return false; - break; - default: - break; - } InputStream input = null; OutputStream output = null; try { + connection.connect(); + + if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) { + throw new IOException("HTTP Request failed: " + downloadUrl + " returned " + connection.getResponseCode()); + } + int dataLength = connection.getContentLength(); + // no need of download when size equal + // file size not the best coice but easy to handle, date is not available + switch (type) { + case LOOKUP: + if (fileSize == dataLength) return false; + break; + case PROFILE: + if (fileSize == dataLength) return false; + break; + default: + break; + } input = connection.getInputStream(); output = new FileOutputStream(outputFile); From 13aad459b7ef68ead032230254f118ceb35bc841 Mon Sep 17 00:00:00 2001 From: afischerdev Date: Mon, 17 Apr 2023 10:04:15 +0200 Subject: [PATCH 4/5] change foot default brf --- brouter-routing-app/src/main/assets/modes.zip | Bin 215 -> 221 bytes misc/profiles2/hiking-mountain.brf | 26 ++++++++++-------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/brouter-routing-app/src/main/assets/modes.zip b/brouter-routing-app/src/main/assets/modes.zip index 2a83bdd87c450373533c409fa76c66c8491ebf8a..15964dbbd8b554c6f1009bf5ba0941c293adba7b 100644 GIT binary patch literal 221 zcmWIWW@Zs#U|`^2I21J@%tQKiY$T934TuGSxHz?_EHgPZIX^EgGhHtwu_U$Ik?Vj0 z56k0G6;Ikyt#5ujAy{ZM?HTQ3AIjIbmh&PGkZ$n)@}LoN2nuegHKi=X9&+C z0mT`!<0r*WnG?Yh$dmG-Ny6ii0Ix#ll_xcEdJF;Hj7%a7xZMDB1_L950*C?v3>O7> Rv$BCC7=h3pNH>8v3;+${Lh1kj diff --git a/misc/profiles2/hiking-mountain.brf b/misc/profiles2/hiking-mountain.brf index 01d3584..8ed13d9 100644 --- a/misc/profiles2/hiking-mountain.brf +++ b/misc/profiles2/hiking-mountain.brf @@ -10,14 +10,12 @@ ---context:global -assign consider_elevation 1 # 0 as default, otherwise less interesting flat roads are chosen. +assign consider_elevation true # %consider_elevation% | Set to false, otherwise less interesting flat roads are chosen | boolean + assign shortest_way 0 # 0 as default, duplicate shortest standard profile, SAC access limit ignored for now -assign turnInstructionMode = 1 # %turnInstructionMode% | Mode for the generated turn instructions | [0=none, 1=auto-choose, 2=locus-style, 3=osmand-style, 4=comment-style, 5=gpsies-style, 6=orux-style, 7=locus-old-style] -assign turnInstructionCatchingRange 20 # V1.8.5 / default=40, but foot paths may be more distingushed, especially in cities. - -assign iswet 0 # 0 as default, 1 tries to prevent muddy boots and wet buttocks -assign hiking_routes_preference 0.20 # 0.10 as default, Increases cost of non hiking routes by multiplier 1 + hiking_routes_preference +assign iswet 0 # %iswet% | tries to prevent muddy boots and wet buttocks | boolean +assign hiking_routes_preference 0.20 # %hiking_routes_preference% | Increases cost of non hiking routes by multiplier 1 + hiking_routes_preference (0.10 to 2.0) | number assign Offroad_factor 0.0 # default 0.0, see ****), see also https://github.com/poutnikl/Brouter-profiles/wiki/Trekking-MTB-Profiles---legend @@ -25,9 +23,9 @@ assign path_preference 0.0 # 0.0 as default, try 20.0 to penalize non #SAC - mountain hiking - see http://wiki.openstreetmap.org/wiki/Key:sac_scale -assign SAC_scale_limit 3 # 0..6, 0 to avoid any SAC paths, 1 for T1 as maximum, 6 for T6 as maximum - # all paths with sac_scale higher than SAC_scale_limit are forbidden. -assign SAC_scale_preferred 1 # The same, but the preferred SAC scale level. Level below are slightly, above strongly penalized +assign SAC_scale_limit 3 # %SAC_scale_limit% | all paths with sac_scale higher than SAC_scale_limit are forbidden | [0=avoid any SAC paths, 1=SAC T1, 2=SAC T2, 3=SAC T3, 4=SAC T4, 5=SAC T5, 6=SAC T6] +assign SAC_scale_preferred 1 # %SAC_scale_preferred% | The same, but the preferred SAC scale level. Level below are slightly, above strongly penalized | [0=avoid any SAC paths, 1=SAC T1, 2=SAC T2, 3=SAC T3, 4=SAC T4, 5=SAC T5, 6=SAC T6] + assign SAC_access_penalty 9000 # costfactor 9999 means the most horrible but allowed road., # 100000=forbidden. This makes difference if forbidden way is the only option. assign SAC_K1 0.05 # Penalizing of SAC levels below preferred @@ -38,14 +36,20 @@ assign turncost_value 0 # not used now assign initialcost_value 0 # not used now #less frequently changed flags -assign allow_steps 1 # 1 as default -assign allow_ferries 1 # 1 as default +assign allow_steps true # %allow_steps% | Set to false to disallow steps | boolean +assign allow_ferries true # %allow_ferries% | set to false to disallow ferries | boolean + assign cost_of_unknown 2 # 2 as default + # assign elevationpenaltybuffer 5 # 5 as default assign elevationmaxbuffer 10 # 10 as default assign elevationbufferreduce 1.0 # 0.0 as default +assign turnInstructionMode = 1 # %turnInstructionMode% | Mode for the generated turn instructions | [0=none, 1=auto-choose, 2=locus-style, 3=osmand-style, 4=comment-style, 5=gpsies-style, 6=orux-style, 7=locus-old-style] +assign turnInstructionCatchingRange 20 # V1.8.5 / default=40, but foot paths may be more distingushed, especially in cities. + + # as initial point, considered flat speed 4 km/h, climbing speed 600 m /h assign uphillcostvalue 7 assign uphillcutoffvalue 3 From 4559f17d856b05445cd73a0d7be3189f18a4fd22 Mon Sep 17 00:00:00 2001 From: afischerdev Date: Mon, 17 Apr 2023 17:07:39 +0200 Subject: [PATCH 5/5] change url for elevation data #534 --- docs/features/elevation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/features/elevation.md b/docs/features/elevation.md index 4d401a7..4d9aa0f 100644 --- a/docs/features/elevation.md +++ b/docs/features/elevation.md @@ -21,7 +21,7 @@ elevation-enabled routing tools. However, the routing algorithm is able to extract the information on real ascends and descends and ignores the noise. For latitudes above 60 degree in northern Europe, BRouter uses Lidar data, that -were [compiled and resampled by Sonny](https://data.opendataportal.at/dataset/dtm-europe) +were [compiled and resampled by Sonny](https://sonny.4lima.de/) On the reporting side, BRouter uses a similar concept to compute the *filtered ascend*, which is the ascend without the noise and the small hills and which