Compare commits
10 commits
Author | SHA1 | Date | |
---|---|---|---|
|
21030cb58c | ||
|
7c81f72439 | ||
|
2d6bc33395 | ||
|
7d529dc42a | ||
|
f7790ef2c7 | ||
|
ed729cb018 | ||
|
1b53652adc | ||
|
da82ba519e | ||
|
2d2425c984 | ||
|
424c213a72 |
1708 changed files with 64546 additions and 123177 deletions
18
.github/ISSUE_TEMPLATE/2-bug-report.md
vendored
18
.github/ISSUE_TEMPLATE/2-bug-report.md
vendored
|
@ -1,18 +0,0 @@
|
||||||
---
|
|
||||||
name: "\U0001F41E Bug report"
|
|
||||||
about: Report a bug in OsmAnd
|
|
||||||
---
|
|
||||||
|
|
||||||
### Description
|
|
||||||
|
|
||||||
|
|
||||||
### How to reproduce?
|
|
||||||
|
|
||||||
|
|
||||||
### Your Environment
|
|
||||||
OsmAnd Version:
|
|
||||||
Android/iOS version:
|
|
||||||
Device model:
|
|
||||||
|
|
||||||
**Maps used (online or offline):**
|
|
||||||
If you have an issue related to offline maps, tell us the exact name of the map file where the issue occurs and its edition date.
|
|
12
.github/ISSUE_TEMPLATE/2-faq-report.md
vendored
Normal file
12
.github/ISSUE_TEMPLATE/2-faq-report.md
vendored
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
---
|
||||||
|
name: "📚 Outdated FAQ"
|
||||||
|
about: Report an issue in FAQ
|
||||||
|
---
|
||||||
|
|
||||||
|
🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑
|
||||||
|
|
||||||
|
Please do not file FAQ issues on the GitHub issues tracker.
|
||||||
|
|
||||||
|
Instead use the [Google group](https://groups.google.com/forum/#!forum/osmand) to fix wrong or outdated FAQ.
|
||||||
|
|
||||||
|
🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑
|
71
.github/ISSUE_TEMPLATE/3-bug-report.md
vendored
Normal file
71
.github/ISSUE_TEMPLATE/3-bug-report.md
vendored
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
---
|
||||||
|
name: "\U0001F41E Bug report"
|
||||||
|
about: Report a bug in OsmAnd
|
||||||
|
---
|
||||||
|
|
||||||
|
<!--🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅
|
||||||
|
|
||||||
|
Oh hi there! 😄
|
||||||
|
|
||||||
|
To expedite issue processing please search open and closed issues before submitting a new one.
|
||||||
|
Existing issues often contain information about workarounds, resolution, or progress updates.
|
||||||
|
|
||||||
|
GitHub is our main development tool for our developers. There are hundreds of requests a month and there are relatively few developers.
|
||||||
|
So by opening an issue, please know that your issue will be sent out to all developers and acknowledge that it could be closed without explanation or with just a brief message.
|
||||||
|
Comments on the closed issues are also sent to all developers, so you will definitely will be heard.
|
||||||
|
However, there is no guarantee that a developer will pick up the issue to work on it.
|
||||||
|
|
||||||
|
Please be sure to read our [FAQ](https://osmand.net/help-online) before creating an issue here.
|
||||||
|
|
||||||
|
The best way to get help about an OsmAnd issue is to create a valid and detailed issue.
|
||||||
|
Please give us the following information so that we can try to **reproduce** your issue:
|
||||||
|
|
||||||
|
🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅-->
|
||||||
|
|
||||||
|
# 🐞 bug report
|
||||||
|
|
||||||
|
### Is this a regression?
|
||||||
|
|
||||||
|
<!-- Did this behavior use to work in the previous version? -->
|
||||||
|
<!-- ✍️--> Yes, the previous version in which this bug was not present was: ....
|
||||||
|
|
||||||
|
### Description
|
||||||
|
|
||||||
|
<!-- A clear and concise description of the problem... -->
|
||||||
|
|
||||||
|
## 🔬 Minimal Reproduction
|
||||||
|
|
||||||
|
<!--
|
||||||
|
If the bug is reproducible, please describe steps below:
|
||||||
|
-->
|
||||||
|
<!-- ✍️--> 1. Open app, and click on ...
|
||||||
|
|
||||||
|
## 🔥 Exception or Error
|
||||||
|
|
||||||
|
<pre><code>
|
||||||
|
<!-- If the issue is accompanied by an exception or an error, please share it below: -->
|
||||||
|
<!-- ✍️-->
|
||||||
|
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
## 🌍 Your Environment
|
||||||
|
|
||||||
|
**OsmAnd Version:**
|
||||||
|
|
||||||
|
<pre><code>
|
||||||
|
<!-- paste version below -->
|
||||||
|
<!-- ✍️-->
|
||||||
|
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
**Device and Android/iOS version:**
|
||||||
|
|
||||||
|
**Maps used (online or offline):**
|
||||||
|
|
||||||
|
<!-- Please tick the correct box [x] (or both) -->
|
||||||
|
|
||||||
|
- [ ] Offline maps offered within the OsmAnd app for download.
|
||||||
|
<!-- If you have an issue related to offline maps, tell us the exact name of the map file where the issue occurs and its edition date. -->
|
||||||
|
- [ ] Online (tile / raster) maps <!-- Please name it -->
|
||||||
|
|
||||||
|
**Anything else relevant?**
|
|
@ -12,7 +12,7 @@ Existing issues often contain information about workarounds, resolution, or prog
|
||||||
|
|
||||||
GitHub is our main development tool for our developers. There are hundreds of requests a month and there are relatively few developers.
|
GitHub is our main development tool for our developers. There are hundreds of requests a month and there are relatively few developers.
|
||||||
So by opening an issue, please know that your issue will be sent out to all developers and acknowledge that it could be closed without explanation or with just a brief message.
|
So by opening an issue, please know that your issue will be sent out to all developers and acknowledge that it could be closed without explanation or with just a brief message.
|
||||||
Comments on the closed issues are also sent to all developers, so you definitely will be heard.
|
Comments on the closed issues are also sent to all developers, so you will definitely will be heard.
|
||||||
However, there is no guarantee that a developer will pick up the issue to work on it.
|
However, there is no guarantee that a developer will pick up the issue to work on it.
|
||||||
|
|
||||||
Please be sure to read our [FAQ](https://osmand.net/help-online) before creating an issue here.
|
Please be sure to read our [FAQ](https://osmand.net/help-online) before creating an issue here.
|
4
.github/ISSUE_TEMPLATE/config.yml
vendored
4
.github/ISSUE_TEMPLATE/config.yml
vendored
|
@ -1,4 +0,0 @@
|
||||||
contact_links:
|
|
||||||
- name: Outdated FAQ
|
|
||||||
url: https://groups.google.com/forum/#!forum/osmand
|
|
||||||
about: Fix wrong or outdated FAQ on the forum instead
|
|
7
.gitignore
vendored
7
.gitignore
vendored
|
@ -16,14 +16,9 @@ OsmAndCore_*.aar
|
||||||
*.iml
|
*.iml
|
||||||
.settings
|
.settings
|
||||||
.idea
|
.idea
|
||||||
**/.project
|
.project
|
||||||
**/.classpath
|
|
||||||
out/
|
out/
|
||||||
|
|
||||||
# Huawei
|
|
||||||
agconnect-services.json
|
|
||||||
OsmAndHms.jks
|
|
||||||
|
|
||||||
# Android Studio
|
# Android Studio
|
||||||
/.idea
|
/.idea
|
||||||
*.iml
|
*.iml
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
apply plugin: 'com.android.library'
|
apply plugin: 'com.android.library'
|
||||||
apply plugin: 'ivy-publish'
|
|
||||||
apply plugin: 'com.github.dcendents.android-maven'
|
apply plugin: 'com.github.dcendents.android-maven'
|
||||||
|
|
||||||
|
group = 'com.github.osmandapp.osmand'
|
||||||
|
version = '2.0.0'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 28
|
compileSdkVersion 28
|
||||||
|
@ -25,33 +26,6 @@ android {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
afterEvaluate {
|
|
||||||
publishing {
|
|
||||||
repositories {
|
|
||||||
ivy {
|
|
||||||
url = System.getenv("OSMAND_BINARIES_IVY_ROOT") ?: "./"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
publications {
|
|
||||||
release(IvyPublication) {
|
|
||||||
// Applies the component for the release build variant.
|
|
||||||
from components.release
|
|
||||||
organisation = 'net.osmand'
|
|
||||||
module = 'android-aidl-lib'
|
|
||||||
revision = 'master-snapshot'
|
|
||||||
}
|
|
||||||
debug(IvyPublication) {
|
|
||||||
// Applies the component for the release build variant.
|
|
||||||
from components.debug
|
|
||||||
organisation = 'net.osmand'
|
|
||||||
module = 'android-aidl-lib'
|
|
||||||
revision = 'master-snapshot'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
implementation 'com.android.support:support-annotations:28.0.0'
|
implementation 'com.android.support:support-annotations:28.0.0'
|
||||||
|
@ -64,4 +38,4 @@ task sourcesJar(type: Jar) {
|
||||||
|
|
||||||
artifacts {
|
artifacts {
|
||||||
archives sourcesJar
|
archives sourcesJar
|
||||||
}
|
}
|
|
@ -2,7 +2,6 @@ package net.osmand.aidlapi;
|
||||||
|
|
||||||
import net.osmand.aidlapi.map.ALatLon;
|
import net.osmand.aidlapi.map.ALatLon;
|
||||||
import net.osmand.aidlapi.map.SetMapLocationParams;
|
import net.osmand.aidlapi.map.SetMapLocationParams;
|
||||||
import net.osmand.aidlapi.map.SetLocationParams;
|
|
||||||
|
|
||||||
import net.osmand.aidlapi.favorite.group.AFavoriteGroup;
|
import net.osmand.aidlapi.favorite.group.AFavoriteGroup;
|
||||||
import net.osmand.aidlapi.favorite.group.AddFavoriteGroupParams;
|
import net.osmand.aidlapi.favorite.group.AddFavoriteGroupParams;
|
||||||
|
@ -21,8 +20,6 @@ import net.osmand.aidlapi.mapmarker.UpdateMapMarkerParams;
|
||||||
|
|
||||||
import net.osmand.aidlapi.calculateroute.CalculateRouteParams;
|
import net.osmand.aidlapi.calculateroute.CalculateRouteParams;
|
||||||
|
|
||||||
import net.osmand.aidlapi.profile.ExportProfileParams;
|
|
||||||
|
|
||||||
import net.osmand.aidlapi.gpx.ImportGpxParams;
|
import net.osmand.aidlapi.gpx.ImportGpxParams;
|
||||||
import net.osmand.aidlapi.gpx.ShowGpxParams;
|
import net.osmand.aidlapi.gpx.ShowGpxParams;
|
||||||
import net.osmand.aidlapi.gpx.StartGpxRecordingParams;
|
import net.osmand.aidlapi.gpx.StartGpxRecordingParams;
|
||||||
|
@ -78,9 +75,6 @@ import net.osmand.aidlapi.customization.OsmandSettingsInfoParams;
|
||||||
import net.osmand.aidlapi.customization.CustomizationInfoParams;
|
import net.osmand.aidlapi.customization.CustomizationInfoParams;
|
||||||
import net.osmand.aidlapi.customization.ProfileSettingsParams;
|
import net.osmand.aidlapi.customization.ProfileSettingsParams;
|
||||||
import net.osmand.aidlapi.customization.MapMarginsParams;
|
import net.osmand.aidlapi.customization.MapMarginsParams;
|
||||||
import net.osmand.aidlapi.customization.CustomPluginParams;
|
|
||||||
import net.osmand.aidlapi.customization.SelectProfileParams;
|
|
||||||
import net.osmand.aidlapi.customization.AProfile;
|
|
||||||
|
|
||||||
import net.osmand.aidlapi.gpx.AGpxFile;
|
import net.osmand.aidlapi.gpx.AGpxFile;
|
||||||
import net.osmand.aidlapi.gpx.AGpxFileDetails;
|
import net.osmand.aidlapi.gpx.AGpxFileDetails;
|
||||||
|
@ -93,9 +87,6 @@ import net.osmand.aidlapi.copyfile.CopyFileParams;
|
||||||
|
|
||||||
import net.osmand.aidlapi.navigation.ANavigationUpdateParams;
|
import net.osmand.aidlapi.navigation.ANavigationUpdateParams;
|
||||||
import net.osmand.aidlapi.navigation.ANavigationVoiceRouterMessageParams;
|
import net.osmand.aidlapi.navigation.ANavigationVoiceRouterMessageParams;
|
||||||
import net.osmand.aidlapi.navigation.ABlockedRoad;
|
|
||||||
import net.osmand.aidlapi.navigation.AddBlockedRoadParams;
|
|
||||||
import net.osmand.aidlapi.navigation.RemoveBlockedRoadParams;
|
|
||||||
|
|
||||||
import net.osmand.aidlapi.contextmenu.ContextMenuButtonsParams;
|
import net.osmand.aidlapi.contextmenu.ContextMenuButtonsParams;
|
||||||
import net.osmand.aidlapi.contextmenu.UpdateContextMenuButtonsParams;
|
import net.osmand.aidlapi.contextmenu.UpdateContextMenuButtonsParams;
|
||||||
|
@ -112,8 +103,6 @@ import net.osmand.aidlapi.events.AKeyEventsParams;
|
||||||
|
|
||||||
import net.osmand.aidlapi.info.AppInfoParams;
|
import net.osmand.aidlapi.info.AppInfoParams;
|
||||||
|
|
||||||
import net.osmand.aidlapi.profile.ExportProfileParams;
|
|
||||||
|
|
||||||
// NOTE: Add new methods at the end of file!!!
|
// NOTE: Add new methods at the end of file!!!
|
||||||
|
|
||||||
interface IOsmAndAidlInterface {
|
interface IOsmAndAidlInterface {
|
||||||
|
@ -878,30 +867,4 @@ interface IOsmAndAidlInterface {
|
||||||
AppInfoParams getAppInfo();
|
AppInfoParams getAppInfo();
|
||||||
|
|
||||||
boolean setMapMargins(in MapMarginsParams params);
|
boolean setMapMargins(in MapMarginsParams params);
|
||||||
|
|
||||||
boolean exportProfile(in ExportProfileParams params);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Is any fragment open.
|
|
||||||
*/
|
|
||||||
boolean isFragmentOpen();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Is contect menu open.
|
|
||||||
*/
|
|
||||||
boolean isMenuOpen();
|
|
||||||
|
|
||||||
int getPluginVersion(in CustomPluginParams params);
|
|
||||||
|
|
||||||
boolean selectProfile(in SelectProfileParams params);
|
|
||||||
|
|
||||||
boolean getProfiles(out List<AProfile> profiles);
|
|
||||||
|
|
||||||
boolean getBlockedRoads(out List<ABlockedRoad> blockedRoads);
|
|
||||||
|
|
||||||
boolean addRoadBlock(in AddBlockedRoadParams params);
|
|
||||||
|
|
||||||
boolean removeRoadBlock(in RemoveBlockedRoadParams params);
|
|
||||||
|
|
||||||
boolean setLocation(in SetLocationParams params);
|
|
||||||
}
|
}
|
|
@ -4,14 +4,11 @@ public interface OsmAndCustomizationConstants {
|
||||||
|
|
||||||
// Navigation Drawer:
|
// Navigation Drawer:
|
||||||
String DRAWER_ITEM_ID_SCHEME = "drawer.action.";
|
String DRAWER_ITEM_ID_SCHEME = "drawer.action.";
|
||||||
String DRAWER_SWITCH_PROFILE_ID = DRAWER_ITEM_ID_SCHEME + "switch_profile";
|
|
||||||
String DRAWER_CONFIGURE_PROFILE_ID = DRAWER_ITEM_ID_SCHEME + "configure_profile";
|
|
||||||
String DRAWER_DASHBOARD_ID = DRAWER_ITEM_ID_SCHEME + "dashboard";
|
String DRAWER_DASHBOARD_ID = DRAWER_ITEM_ID_SCHEME + "dashboard";
|
||||||
String DRAWER_MAP_MARKERS_ID = DRAWER_ITEM_ID_SCHEME + "map_markers";
|
String DRAWER_MAP_MARKERS_ID = DRAWER_ITEM_ID_SCHEME + "map_markers";
|
||||||
String DRAWER_MY_PLACES_ID = DRAWER_ITEM_ID_SCHEME + "my_places";
|
String DRAWER_MY_PLACES_ID = DRAWER_ITEM_ID_SCHEME + "my_places";
|
||||||
String DRAWER_SEARCH_ID = DRAWER_ITEM_ID_SCHEME + "search";
|
String DRAWER_SEARCH_ID = DRAWER_ITEM_ID_SCHEME + "search";
|
||||||
String DRAWER_DIRECTIONS_ID = DRAWER_ITEM_ID_SCHEME + "directions";
|
String DRAWER_DIRECTIONS_ID = DRAWER_ITEM_ID_SCHEME + "directions";
|
||||||
String DRAWER_TRIP_RECORDING_ID = DRAWER_ITEM_ID_SCHEME + "trip_recording";
|
|
||||||
String DRAWER_CONFIGURE_MAP_ID = DRAWER_ITEM_ID_SCHEME + "configure_map";
|
String DRAWER_CONFIGURE_MAP_ID = DRAWER_ITEM_ID_SCHEME + "configure_map";
|
||||||
String DRAWER_DOWNLOAD_MAPS_ID = DRAWER_ITEM_ID_SCHEME + "download_maps";
|
String DRAWER_DOWNLOAD_MAPS_ID = DRAWER_ITEM_ID_SCHEME + "download_maps";
|
||||||
String DRAWER_OSMAND_LIVE_ID = DRAWER_ITEM_ID_SCHEME + "osmand_live";
|
String DRAWER_OSMAND_LIVE_ID = DRAWER_ITEM_ID_SCHEME + "osmand_live";
|
||||||
|
|
|
@ -9,21 +9,12 @@ import net.osmand.aidlapi.AidlParams;
|
||||||
|
|
||||||
public class CopyFileParams extends AidlParams {
|
public class CopyFileParams extends AidlParams {
|
||||||
|
|
||||||
public static final String DESTINATION_DIR_KEY = "destinationDir";
|
|
||||||
public static final String FILE_NAME_KEY = "fileName";
|
|
||||||
public static final String FILE_PART_DATA_KEY = "filePartData";
|
|
||||||
public static final String START_TIME_KEY = "startTime";
|
|
||||||
public static final String DONE_KEY = "done";
|
|
||||||
private String destinationDir;
|
|
||||||
private String fileName;
|
private String fileName;
|
||||||
private byte[] filePartData;
|
private byte[] filePartData;
|
||||||
private long startTime;
|
private long startTime;
|
||||||
private boolean done;
|
private boolean done;
|
||||||
|
|
||||||
public CopyFileParams(@NonNull String destinationDir, @NonNull String fileName, @NonNull byte[] filePartData,
|
public CopyFileParams(@NonNull String fileName, @NonNull byte[] filePartData, long startTime, boolean done) {
|
||||||
long startTime, boolean done) {
|
|
||||||
|
|
||||||
this.destinationDir = destinationDir;
|
|
||||||
this.fileName = fileName;
|
this.fileName = fileName;
|
||||||
this.filePartData = filePartData;
|
this.filePartData = filePartData;
|
||||||
this.startTime = startTime;
|
this.startTime = startTime;
|
||||||
|
@ -46,10 +37,6 @@ public class CopyFileParams extends AidlParams {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public String getDestinationDir() {
|
|
||||||
return destinationDir;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFileName() {
|
public String getFileName() {
|
||||||
return fileName;
|
return fileName;
|
||||||
}
|
}
|
||||||
|
@ -68,26 +55,23 @@ public class CopyFileParams extends AidlParams {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToBundle(Bundle bundle) {
|
public void writeToBundle(Bundle bundle) {
|
||||||
bundle.putString(DESTINATION_DIR_KEY, destinationDir);
|
bundle.putString("fileName", fileName);
|
||||||
bundle.putString(FILE_NAME_KEY, fileName);
|
bundle.putByteArray("filePartData", filePartData);
|
||||||
bundle.putByteArray(FILE_PART_DATA_KEY, filePartData);
|
bundle.putLong("startTime", startTime);
|
||||||
bundle.putLong(START_TIME_KEY, startTime);
|
bundle.putBoolean("done", done);
|
||||||
bundle.putBoolean(DONE_KEY, done);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void readFromBundle(Bundle bundle) {
|
protected void readFromBundle(Bundle bundle) {
|
||||||
destinationDir = bundle.getString(DESTINATION_DIR_KEY);
|
fileName = bundle.getString("fileName");
|
||||||
fileName = bundle.getString(FILE_NAME_KEY);
|
filePartData = bundle.getByteArray("filePartData");
|
||||||
filePartData = bundle.getByteArray(FILE_PART_DATA_KEY);
|
startTime = bundle.getLong("startTime");
|
||||||
startTime = bundle.getLong(START_TIME_KEY);
|
done = bundle.getBoolean("done");
|
||||||
done = bundle.getBoolean(DONE_KEY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "CopyFileParams {" +
|
return "CopyFileParams {" +
|
||||||
" destinationDir=" + destinationDir +
|
|
||||||
" fileName=" + fileName +
|
" fileName=" + fileName +
|
||||||
", filePartData size=" + filePartData.length +
|
", filePartData size=" + filePartData.length +
|
||||||
", startTime=" + startTime +
|
", startTime=" + startTime +
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
package net.osmand.aidlapi.customization;
|
|
||||||
|
|
||||||
parcelable AProfile;
|
|
|
@ -1,129 +0,0 @@
|
||||||
package net.osmand.aidlapi.customization;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.Parcel;
|
|
||||||
|
|
||||||
import net.osmand.aidlapi.AidlParams;
|
|
||||||
|
|
||||||
public class AProfile extends AidlParams {
|
|
||||||
|
|
||||||
public static final String PROFILE_ID_KEY = "profile_id";
|
|
||||||
public static final String USER_PROFILE_NAME_KEY = "user_profile_name";
|
|
||||||
public static final String PARENT_KEY = "parent";
|
|
||||||
public static final String ICON_NAME_KEY = "icon_name";
|
|
||||||
public static final String ICON_COLOR_KEY = "icon_color";
|
|
||||||
public static final String ROUTING_PROFILE_KEY = "routing_profile";
|
|
||||||
public static final String ROUTE_SERVICE_KEY = "route_service";
|
|
||||||
public static final String LOC_ICON_KEY = "loc_icon";
|
|
||||||
public static final String NAV_ICON_KEY = "nav_icon";
|
|
||||||
public static final String ORDER_KEY = "order";
|
|
||||||
|
|
||||||
private String appModeKey;
|
|
||||||
private String userProfileName;
|
|
||||||
private String parent;
|
|
||||||
private String iconName;
|
|
||||||
private String iconColor;
|
|
||||||
private String routingProfile;
|
|
||||||
private String routeService;
|
|
||||||
private String locIcon;
|
|
||||||
private String navIcon;
|
|
||||||
private int order = -1;
|
|
||||||
|
|
||||||
public AProfile(String appModeKey, String userProfileName, String parent, String iconName, String iconColor,
|
|
||||||
String routingProfile, String routeService, String locIcon, String navIcon, int order) {
|
|
||||||
this.appModeKey = appModeKey;
|
|
||||||
this.userProfileName = userProfileName;
|
|
||||||
this.parent = parent;
|
|
||||||
this.iconName = iconName;
|
|
||||||
this.iconColor = iconColor;
|
|
||||||
this.routingProfile = routingProfile;
|
|
||||||
this.routeService = routeService;
|
|
||||||
this.locIcon = locIcon;
|
|
||||||
this.navIcon = navIcon;
|
|
||||||
this.order = order;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AProfile(Parcel in) {
|
|
||||||
readFromParcel(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final Creator<AProfile> CREATOR = new Creator<AProfile>() {
|
|
||||||
@Override
|
|
||||||
public AProfile createFromParcel(Parcel in) {
|
|
||||||
return new AProfile(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AProfile[] newArray(int size) {
|
|
||||||
return new AProfile[size];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public String getStringKey() {
|
|
||||||
return appModeKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUserProfileName() {
|
|
||||||
return userProfileName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getParent() {
|
|
||||||
return parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getIconName() {
|
|
||||||
return iconName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getIconColor() {
|
|
||||||
return iconColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRoutingProfile() {
|
|
||||||
return routingProfile;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRouteService() {
|
|
||||||
return routeService;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLocIcon() {
|
|
||||||
return locIcon;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getNavIcon() {
|
|
||||||
return navIcon;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getOrder() {
|
|
||||||
return order;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeToBundle(Bundle bundle) {
|
|
||||||
bundle.putString(PROFILE_ID_KEY, appModeKey);
|
|
||||||
bundle.putString(USER_PROFILE_NAME_KEY, userProfileName);
|
|
||||||
bundle.putString(PARENT_KEY, parent);
|
|
||||||
bundle.putString(ICON_NAME_KEY, iconName);
|
|
||||||
bundle.putString(ICON_COLOR_KEY, iconColor);
|
|
||||||
bundle.putString(ROUTING_PROFILE_KEY, routingProfile);
|
|
||||||
bundle.putString(ROUTE_SERVICE_KEY, routeService);
|
|
||||||
bundle.putString(LOC_ICON_KEY, locIcon);
|
|
||||||
bundle.putString(NAV_ICON_KEY, navIcon);
|
|
||||||
bundle.putInt(ORDER_KEY, order);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void readFromBundle(Bundle bundle) {
|
|
||||||
appModeKey = bundle.getString(PROFILE_ID_KEY);
|
|
||||||
userProfileName = bundle.getString(USER_PROFILE_NAME_KEY);
|
|
||||||
parent = bundle.getString(PARENT_KEY);
|
|
||||||
iconName = bundle.getString(ICON_NAME_KEY);
|
|
||||||
iconColor = bundle.getString(ICON_COLOR_KEY);
|
|
||||||
routingProfile = bundle.getString(ROUTING_PROFILE_KEY);
|
|
||||||
routeService = bundle.getString(ROUTE_SERVICE_KEY);
|
|
||||||
locIcon = bundle.getString(LOC_ICON_KEY);
|
|
||||||
navIcon = bundle.getString(NAV_ICON_KEY);
|
|
||||||
order = bundle.getInt(ORDER_KEY);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,3 +0,0 @@
|
||||||
package net.osmand.aidlapi.customization;
|
|
||||||
|
|
||||||
parcelable CustomPluginParams;
|
|
|
@ -1,48 +0,0 @@
|
||||||
package net.osmand.aidlapi.customization;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.Parcel;
|
|
||||||
|
|
||||||
import net.osmand.aidlapi.AidlParams;
|
|
||||||
|
|
||||||
|
|
||||||
public class CustomPluginParams extends AidlParams {
|
|
||||||
|
|
||||||
public static final String PLUGIN_ID_KEY = "plugin_id";
|
|
||||||
|
|
||||||
private String pluginId;
|
|
||||||
|
|
||||||
public CustomPluginParams(String pluginId) {
|
|
||||||
this.pluginId = pluginId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CustomPluginParams(Parcel in) {
|
|
||||||
readFromParcel(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final Creator<CustomPluginParams> CREATOR = new Creator<CustomPluginParams>() {
|
|
||||||
@Override
|
|
||||||
public CustomPluginParams createFromParcel(Parcel in) {
|
|
||||||
return new CustomPluginParams(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CustomPluginParams[] newArray(int size) {
|
|
||||||
return new CustomPluginParams[size];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public String getPluginId() {
|
|
||||||
return pluginId;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeToBundle(Bundle bundle) {
|
|
||||||
bundle.putString(PLUGIN_ID_KEY, pluginId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void readFromBundle(Bundle bundle) {
|
|
||||||
pluginId = bundle.getString(PLUGIN_ID_KEY);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -3,31 +3,18 @@ package net.osmand.aidlapi.customization;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
|
|
||||||
import net.osmand.aidlapi.AidlParams;
|
import net.osmand.aidlapi.AidlParams;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class MapMarginsParams extends AidlParams {
|
public class MapMarginsParams extends AidlParams {
|
||||||
|
|
||||||
public static final String LEFT_MARGIN_KEY = "leftMargin";
|
private String appModeKey;
|
||||||
public static final String TOP_MARGIN_KEY = "topMargin";
|
|
||||||
public static final String RIGHT_MARGIN_KEY = "rightMargin";
|
|
||||||
public static final String BOTTOM_MARGIN_KEY = "bottomMargin";
|
|
||||||
public static final String APP_MODES_KEYS_KEY = "appModesKeys";
|
|
||||||
private ArrayList<String> appModesKeys = new ArrayList<>();
|
|
||||||
private int leftMargin;
|
private int leftMargin;
|
||||||
private int topMargin;
|
private int topMargin;
|
||||||
private int rightMargin;
|
private int rightMargin;
|
||||||
private int bottomMargin;
|
private int bottomMargin;
|
||||||
|
|
||||||
public MapMarginsParams(int leftMargin, int topMargin, int rightMargin, int bottomMargin,
|
public MapMarginsParams(String appModeKey, int leftMargin, int topMargin, int rightMargin, int bottomMargin) {
|
||||||
@Nullable List<String> appModesKeys) {
|
this.appModeKey = appModeKey;
|
||||||
if (appModesKeys != null) {
|
|
||||||
this.appModesKeys.addAll(appModesKeys);
|
|
||||||
}
|
|
||||||
this.leftMargin = leftMargin;
|
this.leftMargin = leftMargin;
|
||||||
this.topMargin = topMargin;
|
this.topMargin = topMargin;
|
||||||
this.rightMargin = rightMargin;
|
this.rightMargin = rightMargin;
|
||||||
|
@ -50,8 +37,8 @@ public class MapMarginsParams extends AidlParams {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public List<String> getAppModesKeys() {
|
public String getAppModeKey() {
|
||||||
return appModesKeys;
|
return appModeKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getLeftMargin() {
|
public int getLeftMargin() {
|
||||||
|
@ -72,19 +59,19 @@ public class MapMarginsParams extends AidlParams {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToBundle(Bundle bundle) {
|
public void writeToBundle(Bundle bundle) {
|
||||||
bundle.putInt(LEFT_MARGIN_KEY, leftMargin);
|
bundle.putString("appModeKey", appModeKey);
|
||||||
bundle.putInt(TOP_MARGIN_KEY, topMargin);
|
bundle.putInt("leftMargin", leftMargin);
|
||||||
bundle.putInt(RIGHT_MARGIN_KEY, rightMargin);
|
bundle.putInt("topMargin", topMargin);
|
||||||
bundle.putInt(BOTTOM_MARGIN_KEY, bottomMargin);
|
bundle.putInt("rightMargin", rightMargin);
|
||||||
bundle.putStringArrayList(APP_MODES_KEYS_KEY, appModesKeys);
|
bundle.putInt("bottomMargin", bottomMargin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void readFromBundle(Bundle bundle) {
|
protected void readFromBundle(Bundle bundle) {
|
||||||
leftMargin = bundle.getInt(LEFT_MARGIN_KEY);
|
appModeKey = bundle.getString("appModeKey");
|
||||||
topMargin = bundle.getInt(TOP_MARGIN_KEY);
|
leftMargin = bundle.getInt("leftMargin");
|
||||||
rightMargin = bundle.getInt(RIGHT_MARGIN_KEY);
|
topMargin = bundle.getInt("topMargin");
|
||||||
bottomMargin = bundle.getInt(BOTTOM_MARGIN_KEY);
|
rightMargin = bundle.getInt("rightMargin");
|
||||||
appModesKeys = bundle.getStringArrayList(APP_MODES_KEYS_KEY);
|
bottomMargin = bundle.getInt("bottomMargin");
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -5,42 +5,17 @@ import android.os.Bundle;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
|
|
||||||
import net.osmand.aidlapi.AidlParams;
|
import net.osmand.aidlapi.AidlParams;
|
||||||
import net.osmand.aidlapi.profile.AExportSettingsType;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static net.osmand.aidlapi.profile.ExportProfileParams.SETTINGS_TYPE_KEY;
|
|
||||||
|
|
||||||
public class ProfileSettingsParams extends AidlParams {
|
public class ProfileSettingsParams extends AidlParams {
|
||||||
|
|
||||||
public static final String VERSION_KEY = "version";
|
|
||||||
public static final String REPLACE_KEY = "replace";
|
|
||||||
public static final String SILENT_IMPORT_KEY = "silentImport";
|
|
||||||
public static final String LATEST_CHANGES_KEY = "latestChanges";
|
|
||||||
public static final String PROFILE_SETTINGS_URI_KEY = "profileSettingsUri";
|
|
||||||
private Uri profileSettingsUri;
|
private Uri profileSettingsUri;
|
||||||
private String latestChanges;
|
private String latestChanges;
|
||||||
private int version;
|
private int version;
|
||||||
private List<String> settingsTypeKeyList = new ArrayList<>();
|
|
||||||
private boolean silent;
|
|
||||||
private boolean replace;
|
|
||||||
|
|
||||||
public ProfileSettingsParams(Uri profileSettingsUri, List<AExportSettingsType> settingsTypeList, boolean replace,
|
public ProfileSettingsParams(Uri profileSettingsUri, String latestChanges, int version) {
|
||||||
boolean silent, String latestChanges, int version) {
|
|
||||||
this.profileSettingsUri = profileSettingsUri;
|
this.profileSettingsUri = profileSettingsUri;
|
||||||
for (AExportSettingsType settingsType : settingsTypeList) {
|
|
||||||
settingsTypeKeyList.add(settingsType.name());
|
|
||||||
}
|
|
||||||
this.replace = replace;
|
|
||||||
this.latestChanges = latestChanges;
|
this.latestChanges = latestChanges;
|
||||||
this.version = version;
|
this.version = version;
|
||||||
this.silent = silent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ProfileSettingsParams(Uri profileSettingsUri, List<AExportSettingsType> settingsTypeList,
|
|
||||||
boolean replace, String latestChanges, int version) {
|
|
||||||
this(profileSettingsUri, settingsTypeList, replace, false, latestChanges, version);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProfileSettingsParams(Parcel in) {
|
public ProfileSettingsParams(Parcel in) {
|
||||||
|
@ -71,35 +46,17 @@ public class ProfileSettingsParams extends AidlParams {
|
||||||
return profileSettingsUri;
|
return profileSettingsUri;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getSettingsTypeKeys() {
|
|
||||||
return settingsTypeKeyList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isReplace() {
|
|
||||||
return replace;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSilent() {
|
|
||||||
return silent;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToBundle(Bundle bundle) {
|
public void writeToBundle(Bundle bundle) {
|
||||||
bundle.putInt(VERSION_KEY, version);
|
bundle.putInt("version", version);
|
||||||
bundle.putString(LATEST_CHANGES_KEY, latestChanges);
|
bundle.putString("latestChanges", latestChanges);
|
||||||
bundle.putParcelable(PROFILE_SETTINGS_URI_KEY, profileSettingsUri);
|
bundle.putParcelable("profileSettingsUri", profileSettingsUri);
|
||||||
bundle.putStringArrayList(SETTINGS_TYPE_KEY, new ArrayList<>(settingsTypeKeyList));
|
|
||||||
bundle.putBoolean(REPLACE_KEY, replace);
|
|
||||||
bundle.putBoolean(SILENT_IMPORT_KEY, silent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void readFromBundle(Bundle bundle) {
|
protected void readFromBundle(Bundle bundle) {
|
||||||
version = bundle.getInt(VERSION_KEY);
|
version = bundle.getInt("version");
|
||||||
latestChanges = bundle.getString(LATEST_CHANGES_KEY);
|
latestChanges = bundle.getString("latestChanges");
|
||||||
profileSettingsUri = bundle.getParcelable(PROFILE_SETTINGS_URI_KEY);
|
profileSettingsUri = bundle.getParcelable("profileSettingsUri");
|
||||||
settingsTypeKeyList = bundle.getStringArrayList(SETTINGS_TYPE_KEY);
|
|
||||||
replace = bundle.getBoolean(REPLACE_KEY);
|
|
||||||
silent = bundle.getBoolean(SILENT_IMPORT_KEY);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,3 +0,0 @@
|
||||||
package net.osmand.aidlapi.customization;
|
|
||||||
|
|
||||||
parcelable SelectProfileParams;
|
|
|
@ -1,47 +0,0 @@
|
||||||
package net.osmand.aidlapi.customization;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.Parcel;
|
|
||||||
|
|
||||||
import net.osmand.aidlapi.AidlParams;
|
|
||||||
|
|
||||||
public class SelectProfileParams extends AidlParams {
|
|
||||||
|
|
||||||
public static final String PROFILE_ID_KEY = "profile_id";
|
|
||||||
|
|
||||||
private String appModeKey;
|
|
||||||
|
|
||||||
public SelectProfileParams(String appModeKey) {
|
|
||||||
this.appModeKey = appModeKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SelectProfileParams(Parcel in) {
|
|
||||||
readFromParcel(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final Creator<SelectProfileParams> CREATOR = new Creator<SelectProfileParams>() {
|
|
||||||
@Override
|
|
||||||
public SelectProfileParams createFromParcel(Parcel in) {
|
|
||||||
return new SelectProfileParams(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public SelectProfileParams[] newArray(int size) {
|
|
||||||
return new SelectProfileParams[size];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public String getAppModeKey() {
|
|
||||||
return appModeKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeToBundle(Bundle bundle) {
|
|
||||||
bundle.putString(PROFILE_ID_KEY, appModeKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void readFromBundle(Bundle bundle) {
|
|
||||||
appModeKey = bundle.getString(PROFILE_ID_KEY);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,3 +0,0 @@
|
||||||
package net.osmand.aidlapi.map;
|
|
||||||
|
|
||||||
parcelable ALocation;
|
|
|
@ -1,226 +0,0 @@
|
||||||
package net.osmand.aidlapi.map;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.Parcel;
|
|
||||||
import android.os.Parcelable;
|
|
||||||
|
|
||||||
import net.osmand.aidlapi.AidlParams;
|
|
||||||
|
|
||||||
public class ALocation extends AidlParams {
|
|
||||||
|
|
||||||
private double latitude = 0.0;
|
|
||||||
private double longitude = 0.0;
|
|
||||||
private long time = 0;
|
|
||||||
private boolean hasAltitude = false;
|
|
||||||
private double altitude = 0.0f;
|
|
||||||
private boolean hasSpeed = false;
|
|
||||||
private float speed = 0.0f;
|
|
||||||
private boolean hasBearing = false;
|
|
||||||
private float bearing = 0.0f;
|
|
||||||
private boolean hasAccuracy = false;
|
|
||||||
private float accuracy = 0.0f;
|
|
||||||
private boolean hasVerticalAccuracy = false;
|
|
||||||
private float verticalAccuracy = 0.0f;
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final Parcelable.Creator<ALocation> CREATOR = new Parcelable.Creator<ALocation>() {
|
|
||||||
@Override
|
|
||||||
public ALocation createFromParcel(Parcel in) {
|
|
||||||
return new ALocation(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ALocation[] newArray(int size) {
|
|
||||||
return new ALocation[size];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public double getLatitude() {
|
|
||||||
return latitude;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getLongitude() {
|
|
||||||
return longitude;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getTime() {
|
|
||||||
return time;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasAltitude() {
|
|
||||||
return hasAltitude;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getAltitude() {
|
|
||||||
return altitude;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasSpeed() {
|
|
||||||
return hasSpeed;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getSpeed() {
|
|
||||||
return speed;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasBearing() {
|
|
||||||
return hasBearing;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getBearing() {
|
|
||||||
return bearing;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasAccuracy() {
|
|
||||||
return hasAccuracy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getAccuracy() {
|
|
||||||
return accuracy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasVerticalAccuracy() {
|
|
||||||
return hasVerticalAccuracy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getVerticalAccuracy() {
|
|
||||||
return verticalAccuracy;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void writeToBundle(Bundle bundle) {
|
|
||||||
bundle.putDouble("latitude", latitude);
|
|
||||||
bundle.putDouble("longitude", longitude);
|
|
||||||
bundle.putLong("time", time);
|
|
||||||
bundle.putBoolean("hasAltitude", hasAltitude);
|
|
||||||
bundle.putDouble("altitude", altitude);
|
|
||||||
bundle.putBoolean("hasSpeed", hasSpeed);
|
|
||||||
bundle.putFloat("speed", speed);
|
|
||||||
bundle.putBoolean("hasBearing", hasBearing);
|
|
||||||
bundle.putFloat("bearing", bearing);
|
|
||||||
bundle.putBoolean("hasAccuracy", hasAccuracy);
|
|
||||||
bundle.putFloat("accuracy", accuracy);
|
|
||||||
bundle.putBoolean("hasVerticalAccuracy", hasVerticalAccuracy);
|
|
||||||
bundle.putFloat("verticalAccuracy", verticalAccuracy);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void readFromBundle(Bundle bundle) {
|
|
||||||
latitude = bundle.getDouble("latitude");
|
|
||||||
longitude = bundle.getDouble("longitude");
|
|
||||||
time = bundle.getLong("time");
|
|
||||||
hasAltitude = bundle.getBoolean("hasAltitude");
|
|
||||||
altitude = bundle.getDouble("altitude");
|
|
||||||
hasSpeed = bundle.getBoolean("hasSpeed");
|
|
||||||
speed = bundle.getFloat("speed");
|
|
||||||
hasBearing = bundle.getBoolean("hasBearing");
|
|
||||||
bearing = bundle.getFloat("bearing");
|
|
||||||
hasAccuracy = bundle.getBoolean("hasAccuracy");
|
|
||||||
accuracy = bundle.getFloat("accuracy");
|
|
||||||
hasVerticalAccuracy = bundle.getBoolean("hasVerticalAccuracy");
|
|
||||||
verticalAccuracy = bundle.getFloat("verticalAccuracy");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Builder builder() {
|
|
||||||
return new ALocation().new Builder();
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Builder {
|
|
||||||
|
|
||||||
private Builder() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setLatitude(double latitude) {
|
|
||||||
ALocation.this.latitude = latitude;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setLongitude(double longitude) {
|
|
||||||
ALocation.this.longitude = longitude;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setTime(long time) {
|
|
||||||
ALocation.this.time = time;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder hasAltitude(boolean hasAltitude) {
|
|
||||||
ALocation.this.hasAltitude = hasAltitude;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setAltitude(float altitude) {
|
|
||||||
ALocation.this.altitude = altitude;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder hasSpeed(boolean hasSpeed) {
|
|
||||||
ALocation.this.hasSpeed = hasSpeed;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setSpeed(float speed) {
|
|
||||||
ALocation.this.speed = speed;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder hasBearing(boolean hasBearing) {
|
|
||||||
ALocation.this.hasBearing = hasBearing;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setBearing(float bearing) {
|
|
||||||
ALocation.this.bearing = bearing;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder hasAccuracy(boolean hasAccuracy) {
|
|
||||||
ALocation.this.hasAccuracy = hasAccuracy;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setAccuracy(float accuracy) {
|
|
||||||
ALocation.this.accuracy = accuracy;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder hasVerticalAccuracy(boolean hasVerticalAccuracy) {
|
|
||||||
ALocation.this.hasVerticalAccuracy = hasVerticalAccuracy;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setVerticalAccuracy(float verticalAccuracy) {
|
|
||||||
ALocation.this.verticalAccuracy = verticalAccuracy;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ALocation build() {
|
|
||||||
return ALocation.this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,3 +0,0 @@
|
||||||
package net.osmand.aidlapi.map;
|
|
||||||
|
|
||||||
parcelable SetLocationParams;
|
|
|
@ -1,54 +0,0 @@
|
||||||
package net.osmand.aidlapi.map;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.Parcel;
|
|
||||||
|
|
||||||
import net.osmand.aidlapi.AidlParams;
|
|
||||||
|
|
||||||
public class SetLocationParams extends AidlParams {
|
|
||||||
|
|
||||||
private ALocation location;
|
|
||||||
private long timeToNotUseOtherGPS;
|
|
||||||
|
|
||||||
public SetLocationParams(ALocation location, long timeToNotUseOtherGPS) {
|
|
||||||
this.location = location;
|
|
||||||
this.timeToNotUseOtherGPS = timeToNotUseOtherGPS;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SetLocationParams(Parcel in) {
|
|
||||||
readFromParcel(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final Creator<SetLocationParams> CREATOR = new Creator<SetLocationParams>() {
|
|
||||||
@Override
|
|
||||||
public SetLocationParams createFromParcel(Parcel in) {
|
|
||||||
return new SetLocationParams(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public SetLocationParams[] newArray(int size) {
|
|
||||||
return new SetLocationParams[size];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public ALocation getLocation() {
|
|
||||||
return location;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getTimeToNotUseOtherGPS() {
|
|
||||||
return timeToNotUseOtherGPS;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeToBundle(Bundle bundle) {
|
|
||||||
bundle.putParcelable("location", location);
|
|
||||||
bundle.putLong("timeToNotUseOtherGPS", timeToNotUseOtherGPS);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void readFromBundle(Bundle bundle) {
|
|
||||||
bundle.setClassLoader(ALocation.class.getClassLoader());
|
|
||||||
location = bundle.getParcelable("location");
|
|
||||||
timeToNotUseOtherGPS = bundle.getLong("timeToNotUseOtherGPS");
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,3 +0,0 @@
|
||||||
package net.osmand.aidlapi.navigation;
|
|
||||||
|
|
||||||
parcelable ABlockedRoad;
|
|
|
@ -1,85 +0,0 @@
|
||||||
package net.osmand.aidlapi.navigation;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.Parcel;
|
|
||||||
|
|
||||||
import net.osmand.aidlapi.AidlParams;
|
|
||||||
|
|
||||||
public class ABlockedRoad extends AidlParams {
|
|
||||||
|
|
||||||
private long roadId;
|
|
||||||
private double latitude;
|
|
||||||
private double longitude;
|
|
||||||
private double direction;
|
|
||||||
private String name;
|
|
||||||
private String appModeKey;
|
|
||||||
|
|
||||||
public ABlockedRoad(long roadId, double latitude, double longitude, double direction, String name, String appModeKey) {
|
|
||||||
this.roadId = roadId;
|
|
||||||
this.latitude = latitude;
|
|
||||||
this.longitude = longitude;
|
|
||||||
this.direction = direction;
|
|
||||||
this.name = name;
|
|
||||||
this.appModeKey = appModeKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected ABlockedRoad(Parcel in) {
|
|
||||||
readFromParcel(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final Creator<ABlockedRoad> CREATOR = new Creator<ABlockedRoad>() {
|
|
||||||
@Override
|
|
||||||
public ABlockedRoad createFromParcel(Parcel in) {
|
|
||||||
return new ABlockedRoad(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ABlockedRoad[] newArray(int size) {
|
|
||||||
return new ABlockedRoad[size];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public long getRoadId() {
|
|
||||||
return roadId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getLatitude() {
|
|
||||||
return latitude;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getLongitude() {
|
|
||||||
return longitude;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getDirection() {
|
|
||||||
return direction;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAppModeKey() {
|
|
||||||
return appModeKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void readFromBundle(Bundle bundle) {
|
|
||||||
roadId = bundle.getLong("roadId");
|
|
||||||
latitude = bundle.getDouble("latitude");
|
|
||||||
longitude = bundle.getDouble("longitude");
|
|
||||||
direction = bundle.getDouble("direction");
|
|
||||||
name = bundle.getString("name");
|
|
||||||
appModeKey = bundle.getString("appModeKey");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeToBundle(Bundle bundle) {
|
|
||||||
bundle.putLong("roadId", roadId);
|
|
||||||
bundle.putDouble("latitude", latitude);
|
|
||||||
bundle.putDouble("longitude", longitude);
|
|
||||||
bundle.putDouble("direction", direction);
|
|
||||||
bundle.putString("name", name);
|
|
||||||
bundle.putString("appModeKey", appModeKey);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,3 +0,0 @@
|
||||||
package net.osmand.aidlapi.navigation;
|
|
||||||
|
|
||||||
parcelable AddBlockedRoadParams;
|
|
|
@ -1,46 +0,0 @@
|
||||||
package net.osmand.aidlapi.navigation;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.Parcel;
|
|
||||||
|
|
||||||
import net.osmand.aidlapi.AidlParams;
|
|
||||||
|
|
||||||
public class AddBlockedRoadParams extends AidlParams {
|
|
||||||
|
|
||||||
private ABlockedRoad blockedRoad;
|
|
||||||
|
|
||||||
public AddBlockedRoadParams(ABlockedRoad blockedRoad) {
|
|
||||||
this.blockedRoad = blockedRoad;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AddBlockedRoadParams(Parcel in) {
|
|
||||||
readFromParcel(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final Creator<AddBlockedRoadParams> CREATOR = new Creator<AddBlockedRoadParams>() {
|
|
||||||
@Override
|
|
||||||
public AddBlockedRoadParams createFromParcel(Parcel in) {
|
|
||||||
return new AddBlockedRoadParams(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AddBlockedRoadParams[] newArray(int size) {
|
|
||||||
return new AddBlockedRoadParams[size];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public ABlockedRoad getBlockedRoad() {
|
|
||||||
return blockedRoad;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeToBundle(Bundle bundle) {
|
|
||||||
bundle.putParcelable("blockedRoad", blockedRoad);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void readFromBundle(Bundle bundle) {
|
|
||||||
bundle.setClassLoader(ABlockedRoad.class.getClassLoader());
|
|
||||||
blockedRoad = bundle.getParcelable("blockedRoad");
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -11,18 +11,15 @@ public class NavigateGpxParams extends AidlParams {
|
||||||
private String data;
|
private String data;
|
||||||
private Uri uri;
|
private Uri uri;
|
||||||
private boolean force;
|
private boolean force;
|
||||||
private boolean needLocationPermission;
|
|
||||||
|
|
||||||
public NavigateGpxParams(String data, boolean force, boolean needLocationPermission) {
|
public NavigateGpxParams(String data, boolean force) {
|
||||||
this.data = data;
|
this.data = data;
|
||||||
this.force = force;
|
this.force = force;
|
||||||
this.needLocationPermission = needLocationPermission;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public NavigateGpxParams(Uri uri, boolean force, boolean needLocationPermission) {
|
public NavigateGpxParams(Uri uri, boolean force) {
|
||||||
this.uri = uri;
|
this.uri = uri;
|
||||||
this.force = force;
|
this.force = force;
|
||||||
this.needLocationPermission = needLocationPermission;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public NavigateGpxParams(Parcel in) {
|
public NavigateGpxParams(Parcel in) {
|
||||||
|
@ -53,16 +50,11 @@ public class NavigateGpxParams extends AidlParams {
|
||||||
return force;
|
return force;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isNeedLocationPermission() {
|
|
||||||
return needLocationPermission;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToBundle(Bundle bundle) {
|
public void writeToBundle(Bundle bundle) {
|
||||||
bundle.putString("data", data);
|
bundle.putString("data", data);
|
||||||
bundle.putParcelable("uri", uri);
|
bundle.putParcelable("uri", uri);
|
||||||
bundle.putBoolean("force", force);
|
bundle.putBoolean("force", force);
|
||||||
bundle.putBoolean("needLocationPermission", needLocationPermission);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -70,6 +62,5 @@ public class NavigateGpxParams extends AidlParams {
|
||||||
data = bundle.getString("data");
|
data = bundle.getString("data");
|
||||||
uri = bundle.getParcelable("uri");
|
uri = bundle.getParcelable("uri");
|
||||||
force = bundle.getBoolean("force");
|
force = bundle.getBoolean("force");
|
||||||
needLocationPermission = bundle.getBoolean("needLocationPermission");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -17,10 +17,8 @@ public class NavigateParams extends AidlParams {
|
||||||
private double destLon;
|
private double destLon;
|
||||||
|
|
||||||
private boolean force;
|
private boolean force;
|
||||||
private boolean needLocationPermission;
|
|
||||||
|
|
||||||
public NavigateParams(String startName, double startLat, double startLon, String destName, double destLat,
|
public NavigateParams(String startName, double startLat, double startLon, String destName, double destLat, double destLon, String profile, boolean force) {
|
||||||
double destLon, String profile, boolean force, boolean needLocationPermission) {
|
|
||||||
this.startName = startName;
|
this.startName = startName;
|
||||||
this.startLat = startLat;
|
this.startLat = startLat;
|
||||||
this.startLon = startLon;
|
this.startLon = startLon;
|
||||||
|
@ -29,7 +27,6 @@ public class NavigateParams extends AidlParams {
|
||||||
this.destLon = destLon;
|
this.destLon = destLon;
|
||||||
this.profile = profile;
|
this.profile = profile;
|
||||||
this.force = force;
|
this.force = force;
|
||||||
this.needLocationPermission = needLocationPermission;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public NavigateParams(Parcel in) {
|
public NavigateParams(Parcel in) {
|
||||||
|
@ -80,10 +77,6 @@ public class NavigateParams extends AidlParams {
|
||||||
return force;
|
return force;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isNeedLocationPermission() {
|
|
||||||
return needLocationPermission;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToBundle(Bundle bundle) {
|
public void writeToBundle(Bundle bundle) {
|
||||||
bundle.putString("startName", startName);
|
bundle.putString("startName", startName);
|
||||||
|
@ -94,7 +87,6 @@ public class NavigateParams extends AidlParams {
|
||||||
bundle.putDouble("destLon", destLon);
|
bundle.putDouble("destLon", destLon);
|
||||||
bundle.putString("profile", profile);
|
bundle.putString("profile", profile);
|
||||||
bundle.putBoolean("force", force);
|
bundle.putBoolean("force", force);
|
||||||
bundle.putBoolean("needLocationPermission", needLocationPermission);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -107,6 +99,5 @@ public class NavigateParams extends AidlParams {
|
||||||
destLon = bundle.getDouble("destLon");
|
destLon = bundle.getDouble("destLon");
|
||||||
profile = bundle.getString("profile");
|
profile = bundle.getString("profile");
|
||||||
force = bundle.getBoolean("force");
|
force = bundle.getBoolean("force");
|
||||||
needLocationPermission = bundle.getBoolean("needLocationPermission");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -17,11 +17,10 @@ public class NavigateSearchParams extends AidlParams {
|
||||||
private double searchLon;
|
private double searchLon;
|
||||||
|
|
||||||
private boolean force;
|
private boolean force;
|
||||||
private boolean needLocationPermission;
|
|
||||||
|
|
||||||
public NavigateSearchParams(String startName, double startLat, double startLon,
|
public NavigateSearchParams(String startName, double startLat, double startLon,
|
||||||
String searchQuery, double searchLat, double searchLon,
|
String searchQuery, double searchLat, double searchLon,
|
||||||
String profile, boolean force, boolean needLocationPermission) {
|
String profile, boolean force) {
|
||||||
this.startName = startName;
|
this.startName = startName;
|
||||||
this.startLat = startLat;
|
this.startLat = startLat;
|
||||||
this.startLon = startLon;
|
this.startLon = startLon;
|
||||||
|
@ -30,7 +29,6 @@ public class NavigateSearchParams extends AidlParams {
|
||||||
this.searchLon = searchLon;
|
this.searchLon = searchLon;
|
||||||
this.profile = profile;
|
this.profile = profile;
|
||||||
this.force = force;
|
this.force = force;
|
||||||
this.needLocationPermission = needLocationPermission;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public NavigateSearchParams(Parcel in) {
|
public NavigateSearchParams(Parcel in) {
|
||||||
|
@ -81,10 +79,6 @@ public class NavigateSearchParams extends AidlParams {
|
||||||
return force;
|
return force;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isNeedLocationPermission() {
|
|
||||||
return needLocationPermission;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToBundle(Bundle bundle) {
|
public void writeToBundle(Bundle bundle) {
|
||||||
bundle.putString("startName", startName);
|
bundle.putString("startName", startName);
|
||||||
|
@ -95,7 +89,6 @@ public class NavigateSearchParams extends AidlParams {
|
||||||
bundle.putBoolean("force", force);
|
bundle.putBoolean("force", force);
|
||||||
bundle.putDouble("searchLat", searchLat);
|
bundle.putDouble("searchLat", searchLat);
|
||||||
bundle.putDouble("searchLon", searchLon);
|
bundle.putDouble("searchLon", searchLon);
|
||||||
bundle.putBoolean("needLocationPermission", needLocationPermission);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -108,6 +101,5 @@ public class NavigateSearchParams extends AidlParams {
|
||||||
force = bundle.getBoolean("force");
|
force = bundle.getBoolean("force");
|
||||||
searchLat = bundle.getDouble("searchLat");
|
searchLat = bundle.getDouble("searchLat");
|
||||||
searchLon = bundle.getDouble("searchLon");
|
searchLon = bundle.getDouble("searchLon");
|
||||||
needLocationPermission = bundle.getBoolean("needLocationPermission");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,3 +0,0 @@
|
||||||
package net.osmand.aidlapi.navigation;
|
|
||||||
|
|
||||||
parcelable RemoveBlockedRoadParams;
|
|
|
@ -1,46 +0,0 @@
|
||||||
package net.osmand.aidlapi.navigation;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.Parcel;
|
|
||||||
|
|
||||||
import net.osmand.aidlapi.AidlParams;
|
|
||||||
|
|
||||||
public class RemoveBlockedRoadParams extends AidlParams {
|
|
||||||
|
|
||||||
private ABlockedRoad blockedRoad;
|
|
||||||
|
|
||||||
public RemoveBlockedRoadParams(ABlockedRoad blockedRoad) {
|
|
||||||
this.blockedRoad = blockedRoad;
|
|
||||||
}
|
|
||||||
|
|
||||||
public RemoveBlockedRoadParams(Parcel in) {
|
|
||||||
readFromParcel(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final Creator<RemoveBlockedRoadParams> CREATOR = new Creator<RemoveBlockedRoadParams>() {
|
|
||||||
@Override
|
|
||||||
public RemoveBlockedRoadParams createFromParcel(Parcel in) {
|
|
||||||
return new RemoveBlockedRoadParams(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public RemoveBlockedRoadParams[] newArray(int size) {
|
|
||||||
return new RemoveBlockedRoadParams[size];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public ABlockedRoad getBlockedRoad() {
|
|
||||||
return blockedRoad;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeToBundle(Bundle bundle) {
|
|
||||||
bundle.putParcelable("blockedRoad", blockedRoad);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void readFromBundle(Bundle bundle) {
|
|
||||||
bundle.setClassLoader(ABlockedRoad.class.getClassLoader());
|
|
||||||
blockedRoad = bundle.getParcelable("blockedRoad");
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,3 +0,0 @@
|
||||||
package net.osmand.aidlapi.profile;
|
|
||||||
|
|
||||||
parcelable AExportSettingsType;
|
|
|
@ -1,11 +0,0 @@
|
||||||
package net.osmand.aidlapi.profile;
|
|
||||||
|
|
||||||
public enum AExportSettingsType {
|
|
||||||
PROFILE,
|
|
||||||
QUICK_ACTIONS,
|
|
||||||
POI_TYPES,
|
|
||||||
MAP_SOURCES,
|
|
||||||
CUSTOM_RENDER_STYLE,
|
|
||||||
CUSTOM_ROUTING,
|
|
||||||
AVOID_ROADS;
|
|
||||||
}
|
|
|
@ -1,3 +0,0 @@
|
||||||
package net.osmand.aidlapi.profile;
|
|
||||||
|
|
||||||
parcelable ExportProfileParams;
|
|
|
@ -1,61 +0,0 @@
|
||||||
package net.osmand.aidlapi.profile;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.Parcel;
|
|
||||||
|
|
||||||
import net.osmand.aidlapi.AidlParams;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class ExportProfileParams extends AidlParams {
|
|
||||||
|
|
||||||
public static final String PROFILE_KEY = "profile";
|
|
||||||
public static final String SETTINGS_TYPE_KEY = "settings_type";
|
|
||||||
private String profile;
|
|
||||||
private ArrayList<String> settingsTypeKeyList = new ArrayList<>();
|
|
||||||
|
|
||||||
public ExportProfileParams(String profile, ArrayList<AExportSettingsType> settingsTypeList) {
|
|
||||||
|
|
||||||
this.profile = profile;
|
|
||||||
for (AExportSettingsType settingsType : settingsTypeList) {
|
|
||||||
settingsTypeKeyList.add(settingsType.name());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public ExportProfileParams(Parcel in) {
|
|
||||||
readFromParcel(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final Creator<ExportProfileParams> CREATOR = new Creator<ExportProfileParams>() {
|
|
||||||
@Override
|
|
||||||
public ExportProfileParams createFromParcel(Parcel in) {
|
|
||||||
return new ExportProfileParams(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ExportProfileParams[] newArray(int size) {
|
|
||||||
return new ExportProfileParams[size];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public String getProfile() {
|
|
||||||
return profile;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> getSettingsTypeKeys() {
|
|
||||||
return settingsTypeKeyList;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeToBundle(Bundle bundle) {
|
|
||||||
bundle.putString(PROFILE_KEY, profile);
|
|
||||||
bundle.putStringArrayList(SETTINGS_TYPE_KEY, settingsTypeKeyList);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void readFromBundle(Bundle bundle) {
|
|
||||||
profile = bundle.getString(PROFILE_KEY);
|
|
||||||
settingsTypeKeyList = bundle.getStringArrayList(SETTINGS_TYPE_KEY);
|
|
||||||
}
|
|
||||||
}
|
|
BIN
OsmAnd-java/OsmAnd-core-android.jar
Normal file
BIN
OsmAnd-java/OsmAnd-core-android.jar
Normal file
Binary file not shown.
BIN
OsmAnd-java/OsmAnd-core.jar
Normal file
BIN
OsmAnd-java/OsmAnd-core.jar
Normal file
Binary file not shown.
|
@ -1,7 +1,6 @@
|
||||||
apply plugin: 'java'
|
apply plugin: 'java'
|
||||||
apply plugin: 'maven-publish'
|
apply plugin: 'maven-publish'
|
||||||
apply plugin: 'ivy-publish'
|
|
||||||
|
|
||||||
configurations {
|
configurations {
|
||||||
android
|
android
|
||||||
}
|
}
|
||||||
|
@ -86,22 +85,12 @@ artifacts {
|
||||||
}
|
}
|
||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
repositories {
|
|
||||||
ivy {
|
|
||||||
url = System.getenv("OSMAND_BINARIES_IVY_ROOT") ?: "./"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
publications {
|
publications {
|
||||||
maven(MavenPublication) {
|
maven(MavenPublication) {
|
||||||
artifactId "osmand-base"
|
artifactId "osmand-base"
|
||||||
from components.java
|
from components.java
|
||||||
}
|
}
|
||||||
ivyJava(IvyPublication) {
|
}
|
||||||
artifact androidJar {
|
|
||||||
classifier 'android'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
@ -115,9 +104,6 @@ dependencies {
|
||||||
implementation 'com.moparisthebest:junidecode:0.1.1'
|
implementation 'com.moparisthebest:junidecode:0.1.1'
|
||||||
implementation 'com.vividsolutions:jts-core:1.14.0'
|
implementation 'com.vividsolutions:jts-core:1.14.0'
|
||||||
implementation 'com.google.openlocationcode:openlocationcode:1.0.4'
|
implementation 'com.google.openlocationcode:openlocationcode:1.0.4'
|
||||||
implementation ('com.github.scribejava:scribejava-apis:7.1.1') {
|
|
||||||
exclude group: "com.fasterxml.jackson.core"
|
|
||||||
}
|
|
||||||
// turn off for now
|
// turn off for now
|
||||||
//implementation 'com.atilika.kuromoji:kuromoji-ipadic:0.9.0'
|
//implementation 'com.atilika.kuromoji:kuromoji-ipadic:0.9.0'
|
||||||
implementation 'net.sf.kxml:kxml2:2.1.8'
|
implementation 'net.sf.kxml:kxml2:2.1.8'
|
||||||
|
|
|
@ -800,7 +800,7 @@ public abstract class ByteString implements Iterable<Byte> {
|
||||||
// Copy the information we need into local variables so as to hold
|
// Copy the information we need into local variables so as to hold
|
||||||
// the lock for as short a time as possible.
|
// the lock for as short a time as possible.
|
||||||
cachedFlushBuffers =
|
cachedFlushBuffers =
|
||||||
flushedBuffers.toArray(new ByteString[0]);
|
flushedBuffers.toArray(new ByteString[flushedBuffers.size()]);
|
||||||
cachedBuffer = buffer;
|
cachedBuffer = buffer;
|
||||||
cachedBufferPos = bufferPos;
|
cachedBufferPos = bufferPos;
|
||||||
}
|
}
|
||||||
|
|
|
@ -242,7 +242,8 @@ final class FieldSet<FieldDescriptorType extends
|
||||||
|
|
||||||
// Wrap the contents in a new list so that the caller cannot change
|
// Wrap the contents in a new list so that the caller cannot change
|
||||||
// the list's contents after setting it.
|
// the list's contents after setting it.
|
||||||
final List newList = new ArrayList((List) value);
|
final List newList = new ArrayList();
|
||||||
|
newList.addAll((List) value);
|
||||||
for (final Object element : newList) {
|
for (final Object element : newList) {
|
||||||
verifyType(descriptor.getLiteType(), element);
|
verifyType(descriptor.getLiteType(), element);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,11 +14,6 @@
|
||||||
|
|
||||||
package com.jwetherell.openmap.common;
|
package com.jwetherell.openmap.common;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
public class MGRSPoint extends ZonedUTMPoint {
|
public class MGRSPoint extends ZonedUTMPoint {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -109,15 +104,6 @@ public class MGRSPoint extends ZonedUTMPoint {
|
||||||
* an UPPERCASE coordinate string is expected.
|
* an UPPERCASE coordinate string is expected.
|
||||||
*/
|
*/
|
||||||
protected void decode(String mgrsString) throws NumberFormatException {
|
protected void decode(String mgrsString) throws NumberFormatException {
|
||||||
if (mgrsString.contains(" ")) {
|
|
||||||
String[] parts = mgrsString.split(" ");
|
|
||||||
StringBuilder s = new StringBuilder();
|
|
||||||
for (String i : parts) {
|
|
||||||
s.append(i);
|
|
||||||
}
|
|
||||||
mgrsString = s.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mgrsString == null || mgrsString.length() == 0) {
|
if (mgrsString == null || mgrsString.length() == 0) {
|
||||||
throw new NumberFormatException("MGRSPoint coverting from nothing");
|
throw new NumberFormatException("MGRSPoint coverting from nothing");
|
||||||
}
|
}
|
||||||
|
@ -647,96 +633,6 @@ public class MGRSPoint extends ZonedUTMPoint {
|
||||||
return twoLetter;
|
return twoLetter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toFlavoredString() {
|
|
||||||
try {
|
|
||||||
List<String> all = new ArrayList<>();
|
|
||||||
for (int i = 0; i <= mgrs.length(); i++) {
|
|
||||||
if (Character.isAlphabetic(mgrs.charAt(i))){
|
|
||||||
all.add(mgrs.substring(0,i+1));
|
|
||||||
all.add(mgrs.substring(i+1,i+3));
|
|
||||||
String remains = mgrs.substring(i+3);
|
|
||||||
all.add(remains.substring(0,remains.length()/2));
|
|
||||||
all.add(remains.substring(remains.length()/2));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
StringBuilder os = new StringBuilder();
|
|
||||||
for(String part: all){
|
|
||||||
if (os.length() > 0) os.append(" ");
|
|
||||||
os.append(part);
|
|
||||||
}
|
|
||||||
return os.toString();
|
|
||||||
}catch (Exception e){
|
|
||||||
return mgrs;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toFlavoredString(int accuracy) {
|
|
||||||
try {
|
|
||||||
List<String> all = new ArrayList<>();
|
|
||||||
for (int i = 0; i <= mgrs.length(); i++) {
|
|
||||||
if (Character.isAlphabetic(mgrs.charAt(i))){
|
|
||||||
all.add(mgrs.substring(0,i+1));
|
|
||||||
all.add(mgrs.substring(i+1,i+3));
|
|
||||||
String remains = mgrs.substring(i+3);
|
|
||||||
int easting = Integer.parseInt(remains.substring(0,remains.length()/2));
|
|
||||||
int northing = Integer.parseInt(remains.substring(remains.length()/2));
|
|
||||||
double resolution = Math.pow(10, getAccuracy() - accuracy);
|
|
||||||
long roundedEasting = Math.round(easting/resolution);
|
|
||||||
long roundedNorthing = Math.round(northing/resolution);
|
|
||||||
int eastShift = 0;
|
|
||||||
int northShift = 0;
|
|
||||||
if (roundedEasting == resolution*10){
|
|
||||||
roundedEasting = 0L;
|
|
||||||
eastShift = 1;
|
|
||||||
}
|
|
||||||
if (roundedNorthing == resolution*10){
|
|
||||||
roundedNorthing = 0L;
|
|
||||||
northShift = 1;
|
|
||||||
}
|
|
||||||
if (eastShift != 0 || northShift != 0){
|
|
||||||
all.set(1, shiftChar(all.get(1), eastShift, northShift));
|
|
||||||
String zero = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
all.add(String.format(Locale.US,"%0" + accuracy + "d", roundedEasting));
|
|
||||||
all.add(String.format(Locale.US,"%0" + accuracy + "d", roundedNorthing));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
StringBuilder os = new StringBuilder();
|
|
||||||
for(String part: all){
|
|
||||||
if (os.length() > 0) os.append(" ");
|
|
||||||
os.append(part);
|
|
||||||
}
|
|
||||||
return os.toString();
|
|
||||||
}catch (Exception e){
|
|
||||||
return toFlavoredString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String shiftChar(String chars, int east, int north){
|
|
||||||
ArrayList<Character> keys = new ArrayList<Character>(
|
|
||||||
Arrays.asList('A','B','C','D','E','F','G','H','J','K','L','M','N','P','Q','R','S','T','U','V','W','X','Y','Z'));
|
|
||||||
StringBuilder s = new StringBuilder();
|
|
||||||
if (east != 0){
|
|
||||||
int idx = keys.indexOf(chars.charAt(0));
|
|
||||||
idx += east;
|
|
||||||
if (idx >= keys.size()) idx -= keys.size();
|
|
||||||
if (idx < 0) idx += keys.size();
|
|
||||||
s.append(keys.get(idx));
|
|
||||||
}else s.append(chars.charAt(0));
|
|
||||||
if (north != 0){
|
|
||||||
int idx = keys.indexOf(chars.charAt(1));
|
|
||||||
idx += north;
|
|
||||||
if (idx >= keys.size()) idx -= keys.size();
|
|
||||||
if (idx < 0) idx += keys.size();
|
|
||||||
s.append(keys.get(idx));
|
|
||||||
}else s.append(chars.charAt(1));
|
|
||||||
return s.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -345,6 +345,7 @@ public final class JtsAdapter {
|
||||||
for(int i = 0; i < geom.getNumGeometries(); ++i) {
|
for(int i = 0; i < geom.getNumGeometries(); ++i) {
|
||||||
|
|
||||||
final Polygon nextPoly = (Polygon) geom.getGeometryN(i);
|
final Polygon nextPoly = (Polygon) geom.getGeometryN(i);
|
||||||
|
final List<Integer> nextPolyGeom = new ArrayList<>();
|
||||||
boolean valid = true;
|
boolean valid = true;
|
||||||
|
|
||||||
// Add exterior ring
|
// Add exterior ring
|
||||||
|
@ -361,7 +362,7 @@ public final class JtsAdapter {
|
||||||
CoordinateArrays.reverse(exteriorRing.getCoordinates());
|
CoordinateArrays.reverse(exteriorRing.getCoordinates());
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<Integer> nextPolyGeom = new ArrayList<>(linesToGeomCmds(exteriorRing, mvtClosePath, cursor, 2));
|
nextPolyGeom.addAll(linesToGeomCmds(exteriorRing, mvtClosePath, cursor, 2));
|
||||||
|
|
||||||
|
|
||||||
// Add interior rings
|
// Add interior rings
|
||||||
|
|
|
@ -322,7 +322,7 @@ public final class MvtReader {
|
||||||
geoms.add(geomFactory.createLineString(nextCoordSeq));
|
geoms.add(geomFactory.createLineString(nextCoordSeq));
|
||||||
}
|
}
|
||||||
|
|
||||||
return geoms.size() == 1 ? geoms.get(0) : geomFactory.createMultiLineString(geoms.toArray(new LineString[0]));
|
return geoms.size() == 1 ? geoms.get(0) : geomFactory.createMultiLineString(geoms.toArray(new LineString[geoms.size()]));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -450,7 +450,7 @@ public final class MvtReader {
|
||||||
return polygons.get(0);
|
return polygons.get(0);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return geomFactory.createMultiPolygon(polygons.toArray(new Polygon[0]));
|
return geomFactory.createMultiPolygon(polygons.toArray(new Polygon[polygons.size()]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -512,7 +512,7 @@ public final class MvtReader {
|
||||||
|
|
||||||
if (area > 0d) {
|
if (area > 0d) {
|
||||||
if (outerPoly != null) {
|
if (outerPoly != null) {
|
||||||
polygons.add(geomFactory.createPolygon(outerPoly, holes.toArray(new LinearRing[0])));
|
polygons.add(geomFactory.createPolygon(outerPoly, holes.toArray(new LinearRing[holes.size()])));
|
||||||
holes.clear();
|
holes.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -533,7 +533,7 @@ public final class MvtReader {
|
||||||
|
|
||||||
if (outerPoly != null) {
|
if (outerPoly != null) {
|
||||||
holes.toArray();
|
holes.toArray();
|
||||||
polygons.add(geomFactory.createPolygon(outerPoly, holes.toArray(new LinearRing[0])));
|
polygons.add(geomFactory.createPolygon(outerPoly, holes.toArray(new LinearRing[holes.size()])));
|
||||||
}
|
}
|
||||||
|
|
||||||
return polygons;
|
return polygons;
|
||||||
|
@ -569,7 +569,7 @@ public final class MvtReader {
|
||||||
|
|
||||||
if (outerPoly == null || (outerArea < 0 == area < 0)) {
|
if (outerPoly == null || (outerArea < 0 == area < 0)) {
|
||||||
if (outerPoly != null) {
|
if (outerPoly != null) {
|
||||||
polygons.add(geomFactory.createPolygon(outerPoly, holes.toArray(new LinearRing[0])));
|
polygons.add(geomFactory.createPolygon(outerPoly, holes.toArray(new LinearRing[holes.size()])));
|
||||||
holes.clear();
|
holes.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -590,7 +590,7 @@ public final class MvtReader {
|
||||||
|
|
||||||
if (outerPoly != null) {
|
if (outerPoly != null) {
|
||||||
holes.toArray();
|
holes.toArray();
|
||||||
polygons.add(geomFactory.createPolygon(outerPoly, holes.toArray(new LinearRing[0])));
|
polygons.add(geomFactory.createPolygon(outerPoly, holes.toArray(new LinearRing[holes.size()])));
|
||||||
}
|
}
|
||||||
|
|
||||||
return polygons;
|
return polygons;
|
||||||
|
|
|
@ -6,7 +6,6 @@ import net.osmand.binary.StringBundle;
|
||||||
import net.osmand.binary.StringBundleWriter;
|
import net.osmand.binary.StringBundleWriter;
|
||||||
import net.osmand.binary.StringBundleXmlWriter;
|
import net.osmand.binary.StringBundleXmlWriter;
|
||||||
import net.osmand.data.QuadRect;
|
import net.osmand.data.QuadRect;
|
||||||
import net.osmand.router.RouteColorize.ColorizationType;
|
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
@ -53,16 +52,14 @@ public class GPXUtilities {
|
||||||
private static final String DEFAULT_ICON_NAME = "special_star";
|
private static final String DEFAULT_ICON_NAME = "special_star";
|
||||||
private static final String BACKGROUND_TYPE_EXTENSION = "background";
|
private static final String BACKGROUND_TYPE_EXTENSION = "background";
|
||||||
private static final String PROFILE_TYPE_EXTENSION = "profile";
|
private static final String PROFILE_TYPE_EXTENSION = "profile";
|
||||||
private static final String GAP_PROFILE_TYPE = "gap";
|
|
||||||
private static final String TRKPT_INDEX_EXTENSION = "trkpt_idx";
|
private static final String TRKPT_INDEX_EXTENSION = "trkpt_idx";
|
||||||
|
|
||||||
public final static String GPX_TIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'"; //$NON-NLS-1$
|
private final static String GPX_TIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'"; //$NON-NLS-1$
|
||||||
private final static String GPX_TIME_FORMAT_MILLIS = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"; //$NON-NLS-1$
|
private final static String GPX_TIME_FORMAT_MILLIS = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"; //$NON-NLS-1$
|
||||||
|
|
||||||
private final static NumberFormat latLonFormat = new DecimalFormat("0.00#####", new DecimalFormatSymbols(
|
private final static NumberFormat latLonFormat = new DecimalFormat("0.00#####", new DecimalFormatSymbols(
|
||||||
new Locale("EN", "US")));
|
new Locale("EN", "US")));
|
||||||
// speed, ele, hdop
|
private final static NumberFormat decimalFormat = new DecimalFormat("#.###", new DecimalFormatSymbols(
|
||||||
private final static NumberFormat decimalFormat = new DecimalFormat("#.#", new DecimalFormatSymbols(
|
|
||||||
new Locale("EN", "US")));
|
new Locale("EN", "US")));
|
||||||
|
|
||||||
public enum GPXColor {
|
public enum GPXColor {
|
||||||
|
@ -73,7 +70,6 @@ public class GPXUtilities {
|
||||||
WHITE(0xFFFFFFFF),
|
WHITE(0xFFFFFFFF),
|
||||||
RED(0xFFFF0000),
|
RED(0xFFFF0000),
|
||||||
GREEN(0xFF00FF00),
|
GREEN(0xFF00FF00),
|
||||||
DARKGREEN(0xFF006400),
|
|
||||||
BLUE(0xFF0000FF),
|
BLUE(0xFF0000FF),
|
||||||
YELLOW(0xFFFFFF00),
|
YELLOW(0xFFFFFF00),
|
||||||
CYAN(0xFF00FFFF),
|
CYAN(0xFF00FFFF),
|
||||||
|
@ -228,9 +224,6 @@ public class GPXUtilities {
|
||||||
public double hdop = Double.NaN;
|
public double hdop = Double.NaN;
|
||||||
public float heading = Float.NaN;
|
public float heading = Float.NaN;
|
||||||
public boolean deleted = false;
|
public boolean deleted = false;
|
||||||
public int speedColor = 0;
|
|
||||||
public int altitudeColor = 0;
|
|
||||||
public int slopeColor = 0;
|
|
||||||
public int colourARGB = 0; // point colour (used for altitude/speed colouring)
|
public int colourARGB = 0; // point colour (used for altitude/speed colouring)
|
||||||
public double distance = 0.0; // cumulative distance, if in a track
|
public double distance = 0.0; // cumulative distance, if in a track
|
||||||
|
|
||||||
|
@ -253,9 +246,6 @@ public class GPXUtilities {
|
||||||
this.hdop = wptPt.hdop;
|
this.hdop = wptPt.hdop;
|
||||||
this.heading = wptPt.heading;
|
this.heading = wptPt.heading;
|
||||||
this.deleted = wptPt.deleted;
|
this.deleted = wptPt.deleted;
|
||||||
this.speedColor = wptPt.speedColor;
|
|
||||||
this.altitudeColor = wptPt.altitudeColor;
|
|
||||||
this.slopeColor = wptPt.slopeColor;
|
|
||||||
this.colourARGB = wptPt.colourARGB;
|
this.colourARGB = wptPt.colourARGB;
|
||||||
this.distance = wptPt.distance;
|
this.distance = wptPt.distance;
|
||||||
}
|
}
|
||||||
|
@ -318,26 +308,6 @@ public class GPXUtilities {
|
||||||
getExtensionsToWrite().put(ICON_NAME_EXTENSION, iconName);
|
getExtensionsToWrite().put(ICON_NAME_EXTENSION, iconName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getColor(ColorizationType type) {
|
|
||||||
if (type == ColorizationType.SPEED) {
|
|
||||||
return speedColor;
|
|
||||||
} else if (type == ColorizationType.ELEVATION) {
|
|
||||||
return altitudeColor;
|
|
||||||
} else {
|
|
||||||
return slopeColor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setColor(ColorizationType type, int color) {
|
|
||||||
if (type == ColorizationType.SPEED) {
|
|
||||||
speedColor = color;
|
|
||||||
} else if (type == ColorizationType.ELEVATION) {
|
|
||||||
altitudeColor = color;
|
|
||||||
} else if (type == ColorizationType.SLOPE) {
|
|
||||||
slopeColor = color;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getBackgroundType() {
|
public String getBackgroundType() {
|
||||||
return getExtensionsToRead().get(BACKGROUND_TYPE_EXTENSION);
|
return getExtensionsToRead().get(BACKGROUND_TYPE_EXTENSION);
|
||||||
}
|
}
|
||||||
|
@ -354,20 +324,6 @@ public class GPXUtilities {
|
||||||
getExtensionsToWrite().put(PROFILE_TYPE_EXTENSION, profileType);
|
getExtensionsToWrite().put(PROFILE_TYPE_EXTENSION, profileType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasProfile() {
|
|
||||||
String profileType = getProfileType();
|
|
||||||
return profileType != null && !GAP_PROFILE_TYPE.equals(profileType);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isGap() {
|
|
||||||
String profileType = getProfileType();
|
|
||||||
return GAP_PROFILE_TYPE.equals(profileType);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setGap() {
|
|
||||||
setProfileType(GAP_PROFILE_TYPE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeProfileType() {
|
public void removeProfileType() {
|
||||||
getExtensionsToWrite().remove(PROFILE_TYPE_EXTENSION);
|
getExtensionsToWrite().remove(PROFILE_TYPE_EXTENSION);
|
||||||
}
|
}
|
||||||
|
@ -418,16 +374,11 @@ public class GPXUtilities {
|
||||||
|
|
||||||
public static class TrkSegment extends GPXExtensions {
|
public static class TrkSegment extends GPXExtensions {
|
||||||
public boolean generalSegment = false;
|
public boolean generalSegment = false;
|
||||||
|
|
||||||
public List<WptPt> points = new ArrayList<>();
|
public List<WptPt> points = new ArrayList<>();
|
||||||
|
|
||||||
public Object renderer;
|
public Object renderer;
|
||||||
|
|
||||||
public List<RouteSegment> routeSegments = new ArrayList<>();
|
|
||||||
public List<RouteType> routeTypes = new ArrayList<>();
|
|
||||||
|
|
||||||
public boolean hasRoute() {
|
|
||||||
return !routeSegments.isEmpty() && !routeTypes.isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<GPXTrackAnalysis> splitByDistance(double meters, boolean joinSegments) {
|
public List<GPXTrackAnalysis> splitByDistance(double meters, boolean joinSegments) {
|
||||||
return split(getDistanceMetric(), getTimeSplit(), meters, joinSegments);
|
return split(getDistanceMetric(), getTimeSplit(), meters, joinSegments);
|
||||||
|
@ -442,6 +393,7 @@ public class GPXUtilities {
|
||||||
splitSegment(metric, secondaryMetric, metricLimit, splitSegments, this, joinSegments);
|
splitSegment(metric, secondaryMetric, metricLimit, splitSegments, this, joinSegments);
|
||||||
return convert(splitSegments);
|
return convert(splitSegments);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Track extends GPXExtensions {
|
public static class Track extends GPXExtensions {
|
||||||
|
@ -477,10 +429,6 @@ public class GPXUtilities {
|
||||||
public String getArticleLang() {
|
public String getArticleLang() {
|
||||||
return getExtensionsToRead().get("article_lang");
|
return getExtensionsToRead().get("article_lang");
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription() {
|
|
||||||
return getExtensionsToRead().get("desc");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Author extends GPXExtensions {
|
public static class Author extends GPXExtensions {
|
||||||
|
@ -1113,15 +1061,6 @@ public class GPXUtilities {
|
||||||
return trackBounds;
|
return trackBounds;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static QuadRect calculateTrackBounds(List<TrkSegment> segments) {
|
|
||||||
QuadRect trackBounds = new QuadRect(Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY,
|
|
||||||
Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);
|
|
||||||
for (TrkSegment segment : segments) {
|
|
||||||
updateBounds(trackBounds, segment.points, 0);
|
|
||||||
}
|
|
||||||
return trackBounds;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void updateBounds(QuadRect trackBounds, List<WptPt> pts, int startIndex) {
|
public static void updateBounds(QuadRect trackBounds, List<WptPt> pts, int startIndex) {
|
||||||
for (int i = startIndex; i < pts.size(); i++) {
|
for (int i = startIndex; i < pts.size(); i++) {
|
||||||
WptPt pt = pts.get(i);
|
WptPt pt = pts.get(i);
|
||||||
|
@ -1139,6 +1078,9 @@ public class GPXUtilities {
|
||||||
private List<WptPt> points = new ArrayList<>();
|
private List<WptPt> points = new ArrayList<>();
|
||||||
public List<Route> routes = new ArrayList<>();
|
public List<Route> routes = new ArrayList<>();
|
||||||
|
|
||||||
|
public List<RouteSegment> routeSegments = new ArrayList<>();
|
||||||
|
public List<RouteType> routeTypes = new ArrayList<>();
|
||||||
|
|
||||||
public Exception error = null;
|
public Exception error = null;
|
||||||
public String path = "";
|
public String path = "";
|
||||||
public boolean showCurrentTrack;
|
public boolean showCurrentTrack;
|
||||||
|
@ -1166,7 +1108,7 @@ public class GPXUtilities {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasRoute() {
|
public boolean hasRoute() {
|
||||||
return getNonEmptyTrkSegments(true).size() > 0;
|
return !routeSegments.isEmpty() && !routeTypes.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<WptPt> getPoints() {
|
public List<WptPt> getPoints() {
|
||||||
|
@ -1276,7 +1218,7 @@ public class GPXUtilities {
|
||||||
GPXTrackAnalysis g = new GPXTrackAnalysis();
|
GPXTrackAnalysis g = new GPXTrackAnalysis();
|
||||||
g.wptPoints = points.size();
|
g.wptPoints = points.size();
|
||||||
g.wptCategoryNames = getWaypointCategories(true);
|
g.wptCategoryNames = getWaypointCategories(true);
|
||||||
List<SplitSegment> splitSegments = new ArrayList<>();
|
List<SplitSegment> splitSegments = new ArrayList<GPXUtilities.SplitSegment>();
|
||||||
for (int i = 0; i < tracks.size(); i++) {
|
for (int i = 0; i < tracks.size(); i++) {
|
||||||
Track subtrack = tracks.get(i);
|
Track subtrack = tracks.get(i);
|
||||||
for (TrkSegment segment : subtrack.segments) {
|
for (TrkSegment segment : subtrack.segments) {
|
||||||
|
@ -1288,14 +1230,10 @@ public class GPXUtilities {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
g.prepareInformation(fileTimestamp, splitSegments.toArray(new SplitSegment[0]));
|
g.prepareInformation(fileTimestamp, splitSegments.toArray(new SplitSegment[splitSegments.size()]));
|
||||||
return g;
|
return g;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean containsRoutePoint(WptPt point) {
|
|
||||||
return getRoutePoints().contains(point);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<WptPt> getRoutePoints() {
|
public List<WptPt> getRoutePoints() {
|
||||||
List<WptPt> points = new ArrayList<>();
|
List<WptPt> points = new ArrayList<>();
|
||||||
for (int i = 0; i < routes.size(); i++) {
|
for (int i = 0; i < routes.size(); i++) {
|
||||||
|
@ -1305,15 +1243,6 @@ public class GPXUtilities {
|
||||||
return points;
|
return points;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<WptPt> getRoutePoints(int routeIndex) {
|
|
||||||
List<WptPt> points = new ArrayList<>();
|
|
||||||
if (routes.size() > routeIndex) {
|
|
||||||
Route rt = routes.get(routeIndex);
|
|
||||||
points.addAll(rt.points);
|
|
||||||
}
|
|
||||||
return points;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasRtePt() {
|
public boolean hasRtePt() {
|
||||||
for (Route r : routes) {
|
for (Route r : routes) {
|
||||||
if (r.points.size() > 0) {
|
if (r.points.size() > 0) {
|
||||||
|
@ -1389,16 +1318,15 @@ public class GPXUtilities {
|
||||||
return pt;
|
return pt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TrkSegment> getNonEmptyTrkSegments(boolean routesOnly) {
|
public TrkSegment getNonEmptyTrkSegment() {
|
||||||
List<TrkSegment> segments = new ArrayList<>();
|
for (GPXUtilities.Track t : tracks) {
|
||||||
for (Track t : tracks) {
|
|
||||||
for (TrkSegment s : t.segments) {
|
for (TrkSegment s : t.segments) {
|
||||||
if (!s.generalSegment && s.points.size() > 0 && (!routesOnly || s.hasRoute())) {
|
if (s.points.size() > 0) {
|
||||||
segments.add(s);
|
return s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return segments;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addTrkSegment(List<WptPt> points) {
|
public void addTrkSegment(List<WptPt> points) {
|
||||||
|
@ -1437,8 +1365,8 @@ public class GPXUtilities {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addRoutePoints(List<WptPt> points, boolean addRoute) {
|
public void addRoutePoints(List<WptPt> points) {
|
||||||
if (routes.size() == 0 || addRoute) {
|
if (routes.size() == 0) {
|
||||||
Route route = new Route();
|
Route route = new Route();
|
||||||
routes.add(route);
|
routes.add(route);
|
||||||
}
|
}
|
||||||
|
@ -1680,7 +1608,7 @@ public class GPXUtilities {
|
||||||
bottom = Math.min(bottom, p.getLatitude());
|
bottom = Math.min(bottom, p.getLatitude());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Route route : routes) {
|
for (GPXUtilities.Route route : routes) {
|
||||||
for (WptPt p : route.points) {
|
for (WptPt p : route.points) {
|
||||||
if (left == 0 && right == 0) {
|
if (left == 0 && right == 0) {
|
||||||
left = p.getLongitude();
|
left = p.getLongitude();
|
||||||
|
@ -1698,16 +1626,16 @@ public class GPXUtilities {
|
||||||
return new QuadRect(left, top, right, bottom);
|
return new QuadRect(left, top, right, bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int[] getGradientScaleColor(String gradientScaleType) {
|
public int getGradientScaleColor(String gradientScaleType, int defColor) {
|
||||||
String clrValue = null;
|
String clrValue = null;
|
||||||
if (extensions != null) {
|
if (extensions != null) {
|
||||||
clrValue = extensions.get(gradientScaleType);
|
clrValue = extensions.get(gradientScaleType);
|
||||||
}
|
}
|
||||||
return Algorithms.stringToGradientPalette(clrValue);
|
return parseColor(clrValue, defColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGradientScaleColor(String gradientScaleType, int[] gradientScalePalette) {
|
public void setGradientScaleColor(String gradientScaleType, int gradientScaleColor) {
|
||||||
getExtensionsToWrite().put(gradientScaleType, Algorithms.gradientPaletteToString(gradientScalePalette));
|
getExtensionsToWrite().put(gradientScaleType, Algorithms.colorToString(gradientScaleColor));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getGradientScaleType() {
|
public String getGradientScaleType() {
|
||||||
|
@ -1792,7 +1720,7 @@ public class GPXUtilities {
|
||||||
|
|
||||||
public static String asString(GPXFile file) {
|
public static String asString(GPXFile file) {
|
||||||
final Writer writer = new StringWriter();
|
final Writer writer = new StringWriter();
|
||||||
writeGpx(writer, file);
|
GPXUtilities.writeGpx(writer, file);
|
||||||
return writer.toString();
|
return writer.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1835,7 +1763,6 @@ public class GPXUtilities {
|
||||||
serializer.attribute(null, "creator", file.author); //$NON-NLS-1$
|
serializer.attribute(null, "creator", file.author); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
serializer.attribute(null, "xmlns", "http://www.topografix.com/GPX/1/1"); //$NON-NLS-1$ //$NON-NLS-2$
|
serializer.attribute(null, "xmlns", "http://www.topografix.com/GPX/1/1"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
serializer.attribute(null, "xmlns:osmand", "https://osmand.net");
|
|
||||||
serializer.attribute(null, "xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
|
serializer.attribute(null, "xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
|
||||||
serializer.attribute(null, "xsi:schemaLocation",
|
serializer.attribute(null, "xsi:schemaLocation",
|
||||||
"http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd");
|
"http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd");
|
||||||
|
@ -1867,10 +1794,24 @@ public class GPXUtilities {
|
||||||
}
|
}
|
||||||
serializer.endTag(null, "metadata");
|
serializer.endTag(null, "metadata");
|
||||||
|
|
||||||
for (WptPt l : file.points) {
|
|
||||||
serializer.startTag(null, "wpt"); //$NON-NLS-1$
|
for (Track track : file.tracks) {
|
||||||
writeWpt(format, serializer, l);
|
if (!track.generalTrack) {
|
||||||
serializer.endTag(null, "wpt"); //$NON-NLS-1$
|
serializer.startTag(null, "trk"); //$NON-NLS-1$
|
||||||
|
writeNotNullText(serializer, "name", track.name);
|
||||||
|
writeNotNullText(serializer, "desc", track.desc);
|
||||||
|
for (TrkSegment segment : track.segments) {
|
||||||
|
serializer.startTag(null, "trkseg"); //$NON-NLS-1$
|
||||||
|
for (WptPt p : segment.points) {
|
||||||
|
serializer.startTag(null, "trkpt"); //$NON-NLS-1$
|
||||||
|
writeWpt(format, serializer, p);
|
||||||
|
serializer.endTag(null, "trkpt"); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
serializer.endTag(null, "trkseg"); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
writeExtensions(serializer, track);
|
||||||
|
serializer.endTag(null, "trk"); //$NON-NLS-1$
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Route track : file.routes) {
|
for (Route track : file.routes) {
|
||||||
|
@ -1887,27 +1828,13 @@ public class GPXUtilities {
|
||||||
serializer.endTag(null, "rte"); //$NON-NLS-1$
|
serializer.endTag(null, "rte"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Track track : file.tracks) {
|
for (WptPt l : file.points) {
|
||||||
if (!track.generalTrack) {
|
serializer.startTag(null, "wpt"); //$NON-NLS-1$
|
||||||
serializer.startTag(null, "trk"); //$NON-NLS-1$
|
writeWpt(format, serializer, l);
|
||||||
writeNotNullText(serializer, "name", track.name);
|
serializer.endTag(null, "wpt"); //$NON-NLS-1$
|
||||||
writeNotNullText(serializer, "desc", track.desc);
|
|
||||||
for (TrkSegment segment : track.segments) {
|
|
||||||
serializer.startTag(null, "trkseg"); //$NON-NLS-1$
|
|
||||||
for (WptPt p : segment.points) {
|
|
||||||
serializer.startTag(null, "trkpt"); //$NON-NLS-1$
|
|
||||||
writeWpt(format, serializer, p);
|
|
||||||
serializer.endTag(null, "trkpt"); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
assignRouteExtensionWriter(segment);
|
|
||||||
writeExtensions(serializer, segment);
|
|
||||||
serializer.endTag(null, "trkseg"); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
writeExtensions(serializer, track);
|
|
||||||
serializer.endTag(null, "trk"); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assignRouteExtensionWriter(file);
|
||||||
writeExtensions(serializer, file);
|
writeExtensions(serializer, file);
|
||||||
|
|
||||||
serializer.endTag(null, "gpx"); //$NON-NLS-1$
|
serializer.endTag(null, "gpx"); //$NON-NLS-1$
|
||||||
|
@ -1920,19 +1847,19 @@ public class GPXUtilities {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void assignRouteExtensionWriter(final TrkSegment segment) {
|
private static void assignRouteExtensionWriter(final GPXFile gpxFile) {
|
||||||
if (segment.hasRoute() && segment.getExtensionsWriter() == null) {
|
if (gpxFile.hasRoute() && gpxFile.getExtensionsWriter() == null) {
|
||||||
segment.setExtensionsWriter(new GPXExtensionsWriter() {
|
gpxFile.setExtensionsWriter(new GPXExtensionsWriter() {
|
||||||
@Override
|
@Override
|
||||||
public void writeExtensions(XmlSerializer serializer) {
|
public void writeExtensions(XmlSerializer serializer) {
|
||||||
StringBundle bundle = new StringBundle();
|
StringBundle bundle = new StringBundle();
|
||||||
List<StringBundle> segmentsBundle = new ArrayList<>();
|
List<StringBundle> segmentsBundle = new ArrayList<>();
|
||||||
for (RouteSegment segment : segment.routeSegments) {
|
for (RouteSegment segment : gpxFile.routeSegments) {
|
||||||
segmentsBundle.add(segment.toStringBundle());
|
segmentsBundle.add(segment.toStringBundle());
|
||||||
}
|
}
|
||||||
bundle.putBundleList("route", "segment", segmentsBundle);
|
bundle.putBundleList("route", "segment", segmentsBundle);
|
||||||
List<StringBundle> typesBundle = new ArrayList<>();
|
List<StringBundle> typesBundle = new ArrayList<>();
|
||||||
for (RouteType routeType : segment.routeTypes) {
|
for (RouteType routeType : gpxFile.routeTypes) {
|
||||||
typesBundle.add(routeType.toStringBundle());
|
typesBundle.add(routeType.toStringBundle());
|
||||||
}
|
}
|
||||||
bundle.putBundleList("types", "type", typesBundle);
|
bundle.putBundleList("types", "type", typesBundle);
|
||||||
|
@ -1974,16 +1901,13 @@ public class GPXUtilities {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void writeExtensions(XmlSerializer serializer, GPXExtensions p) throws IOException {
|
private static void writeExtensions(XmlSerializer serializer, GPXExtensions p) throws IOException {
|
||||||
writeExtensions(serializer, p.getExtensionsToRead(), p);
|
Map<String, String> extensionsToRead = p.getExtensionsToRead();
|
||||||
}
|
|
||||||
|
|
||||||
private static void writeExtensions(XmlSerializer serializer, Map<String, String> extensions, GPXExtensions p) throws IOException {
|
|
||||||
GPXExtensionsWriter extensionsWriter = p.getExtensionsWriter();
|
GPXExtensionsWriter extensionsWriter = p.getExtensionsWriter();
|
||||||
if (!extensions.isEmpty() || extensionsWriter != null) {
|
if (!extensionsToRead.isEmpty() || extensionsWriter != null) {
|
||||||
serializer.startTag(null, "extensions");
|
serializer.startTag(null, "extensions");
|
||||||
if (!extensions.isEmpty()) {
|
if (!extensionsToRead.isEmpty()) {
|
||||||
for (Entry<String, String> s : extensions.entrySet()) {
|
for (Entry<String, String> s : extensionsToRead.entrySet()) {
|
||||||
writeNotNullText(serializer,"osmand:" + s.getKey(), s.getValue());
|
writeNotNullText(serializer, s.getKey(), s.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (extensionsWriter != null) {
|
if (extensionsWriter != null) {
|
||||||
|
@ -2019,20 +1943,7 @@ public class GPXUtilities {
|
||||||
if (!Float.isNaN(p.heading)) {
|
if (!Float.isNaN(p.heading)) {
|
||||||
p.getExtensionsToWrite().put("heading", String.valueOf(Math.round(p.heading)));
|
p.getExtensionsToWrite().put("heading", String.valueOf(Math.round(p.heading)));
|
||||||
}
|
}
|
||||||
Map<String, String> extensions = p.getExtensionsToRead();
|
writeExtensions(serializer, p);
|
||||||
if (!"rtept".equals(serializer.getName())) {
|
|
||||||
// Leave "profile" and "trkpt" tags for rtept only
|
|
||||||
extensions.remove(PROFILE_TYPE_EXTENSION);
|
|
||||||
extensions.remove(TRKPT_INDEX_EXTENSION);
|
|
||||||
writeExtensions(serializer, extensions, p);
|
|
||||||
} else {
|
|
||||||
// Remove "gap" profile
|
|
||||||
String profile = extensions.get(PROFILE_TYPE_EXTENSION);
|
|
||||||
if (GAP_PROFILE_TYPE.equals(profile)) {
|
|
||||||
extensions.remove(PROFILE_TYPE_EXTENSION);
|
|
||||||
}
|
|
||||||
writeExtensions(serializer, p);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void writeAuthor(XmlSerializer serializer, Author author) throws IOException {
|
private static void writeAuthor(XmlSerializer serializer, Author author) throws IOException {
|
||||||
|
@ -2188,11 +2099,10 @@ public class GPXUtilities {
|
||||||
TrkSegment routeTrackSegment = new TrkSegment();
|
TrkSegment routeTrackSegment = new TrkSegment();
|
||||||
routeTrack.segments.add(routeTrackSegment);
|
routeTrack.segments.add(routeTrackSegment);
|
||||||
Stack<GPXExtensions> parserState = new Stack<>();
|
Stack<GPXExtensions> parserState = new Stack<>();
|
||||||
TrkSegment firstSegment = null;
|
|
||||||
boolean extensionReadMode = false;
|
boolean extensionReadMode = false;
|
||||||
boolean routePointExtension = false;
|
boolean routePointExtension = false;
|
||||||
List<RouteSegment> routeSegments = new ArrayList<>();
|
List<RouteSegment> routeSegments = gpxFile.routeSegments;
|
||||||
List<RouteType> routeTypes = new ArrayList<>();
|
List<RouteType> routeTypes = gpxFile.routeTypes;
|
||||||
boolean routeExtension = false;
|
boolean routeExtension = false;
|
||||||
boolean typesExtension = false;
|
boolean typesExtension = false;
|
||||||
parserState.push(gpxFile);
|
parserState.push(gpxFile);
|
||||||
|
@ -2493,16 +2403,6 @@ public class GPXUtilities {
|
||||||
assert pop instanceof Route;
|
assert pop instanceof Route;
|
||||||
} else if (tag.equals("trkseg")) {
|
} else if (tag.equals("trkseg")) {
|
||||||
Object pop = parserState.pop();
|
Object pop = parserState.pop();
|
||||||
if (pop instanceof TrkSegment) {
|
|
||||||
TrkSegment segment = (TrkSegment) pop;
|
|
||||||
segment.routeSegments = routeSegments;
|
|
||||||
segment.routeTypes = routeTypes;
|
|
||||||
routeSegments = new ArrayList<>();
|
|
||||||
routeTypes = new ArrayList<>();
|
|
||||||
if (firstSegment == null) {
|
|
||||||
firstSegment = segment;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
assert pop instanceof TrkSegment;
|
assert pop instanceof TrkSegment;
|
||||||
} else if (tag.equals("rpt")) {
|
} else if (tag.equals("rpt")) {
|
||||||
Object pop = parserState.pop();
|
Object pop = parserState.pop();
|
||||||
|
@ -2513,11 +2413,6 @@ public class GPXUtilities {
|
||||||
if (!routeTrackSegment.points.isEmpty()) {
|
if (!routeTrackSegment.points.isEmpty()) {
|
||||||
gpxFile.tracks.add(routeTrack);
|
gpxFile.tracks.add(routeTrack);
|
||||||
}
|
}
|
||||||
if (!routeSegments.isEmpty() && !routeTypes.isEmpty() && firstSegment != null) {
|
|
||||||
firstSegment.routeSegments = routeSegments;
|
|
||||||
firstSegment.routeTypes = routeTypes;
|
|
||||||
}
|
|
||||||
gpxFile.addGeneralTrack();
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
gpxFile.error = e;
|
gpxFile.error = e;
|
||||||
log.error("Error reading gpx", e); //$NON-NLS-1$
|
log.error("Error reading gpx", e); //$NON-NLS-1$
|
||||||
|
@ -2590,7 +2485,7 @@ public class GPXUtilities {
|
||||||
if (maxlat == null) {
|
if (maxlat == null) {
|
||||||
maxlat = parser.getAttributeValue("", "maxLat");
|
maxlat = parser.getAttributeValue("", "maxLat");
|
||||||
}
|
}
|
||||||
if (maxlon == null) {
|
if (maxlat == null) {
|
||||||
maxlon = parser.getAttributeValue("", "maxLon");
|
maxlon = parser.getAttributeValue("", "maxLon");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2632,4 +2527,4 @@ public class GPXUtilities {
|
||||||
to.error = from.error;
|
to.error = from.error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -45,7 +45,7 @@ public interface IProgress {
|
||||||
public boolean isInterrupted() {return false;}
|
public boolean isInterrupted() {return false;}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isIndeterminate() {return true;}
|
public boolean isIndeterminate() {return false;}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void finishTask() {}
|
public void finishTask() {}
|
||||||
|
|
|
@ -14,22 +14,17 @@ public class IndexConstants {
|
||||||
public static final String TEMP_SOURCE_TO_LOAD = "temp";
|
public static final String TEMP_SOURCE_TO_LOAD = "temp";
|
||||||
|
|
||||||
public static final String POI_INDEX_EXT = ".poi.odb"; //$NON-NLS-1$
|
public static final String POI_INDEX_EXT = ".poi.odb"; //$NON-NLS-1$
|
||||||
|
|
||||||
public static final String ZIP_EXT = ".zip"; //$NON-NLS-1$
|
|
||||||
public static final String BINARY_MAP_INDEX_EXT = ".obf"; //$NON-NLS-1$
|
public static final String BINARY_MAP_INDEX_EXT = ".obf"; //$NON-NLS-1$
|
||||||
public static final String BINARY_MAP_INDEX_EXT_ZIP = ".obf.zip"; //$NON-NLS-1$
|
public static final String BINARY_MAP_INDEX_EXT_ZIP = ".obf.zip"; //$NON-NLS-1$
|
||||||
|
|
||||||
public static final String BINARY_WIKIVOYAGE_MAP_INDEX_EXT = ".sqlite"; //$NON-NLS-1$
|
public static final String BINARY_WIKIVOYAGE_MAP_INDEX_EXT = ".sqlite"; //$NON-NLS-1$
|
||||||
public static final String BINARY_TRAVEL_GUIDE_MAP_INDEX_EXT = ".travel.obf"; //$NON-NLS-1$
|
|
||||||
public static final String BINARY_TRAVEL_GUIDE_MAP_INDEX_EXT_ZIP = ".travel.obf.zip"; //$NON-NLS-1$
|
|
||||||
public static final String BINARY_WIKI_MAP_INDEX_EXT = ".wiki.obf"; //$NON-NLS-1$
|
public static final String BINARY_WIKI_MAP_INDEX_EXT = ".wiki.obf"; //$NON-NLS-1$
|
||||||
public static final String BINARY_WIKI_MAP_INDEX_EXT_ZIP = ".wiki.obf.zip"; //$NON-NLS-1$
|
public static final String BINARY_WIKI_MAP_INDEX_EXT_ZIP = ".wiki.obf.zip"; //$NON-NLS-1$
|
||||||
public static final String BINARY_ROAD_MAP_INDEX_EXT = ".road.obf"; //$NON-NLS-1$
|
public static final String BINARY_ROAD_MAP_INDEX_EXT = ".road.obf"; //$NON-NLS-1$
|
||||||
public static final String BINARY_ROAD_MAP_INDEX_EXT_ZIP = ".road.obf.zip"; //$NON-NLS-1$
|
public static final String BINARY_ROAD_MAP_INDEX_EXT_ZIP = ".road.obf.zip"; //$NON-NLS-1$
|
||||||
public static final String BINARY_SRTM_MAP_INDEX_EXT = ".srtm.obf"; //$NON-NLS-1$
|
public static final String BINARY_SRTM_MAP_INDEX_EXT = ".srtm.obf"; //$NON-NLS-1$
|
||||||
public static final String BINARY_SRTM_FEET_MAP_INDEX_EXT = ".srtmf.obf"; //$NON-NLS-1$
|
|
||||||
public static final String BINARY_SRTM_MAP_INDEX_EXT_ZIP = ".srtm.obf.zip"; //$NON-NLS-1$
|
public static final String BINARY_SRTM_MAP_INDEX_EXT_ZIP = ".srtm.obf.zip"; //$NON-NLS-1$
|
||||||
public static final String BINARY_SRTM_FEET_MAP_INDEX_EXT_ZIP = ".srtmf.obf.zip"; //$NON-NLS-1$
|
|
||||||
public static final String EXTRA_EXT = ".extra";
|
public static final String EXTRA_EXT = ".extra";
|
||||||
public static final String EXTRA_ZIP_EXT = ".extra.zip";
|
public static final String EXTRA_ZIP_EXT = ".extra.zip";
|
||||||
|
|
||||||
|
@ -76,11 +71,9 @@ public class IndexConstants {
|
||||||
public static final String FONT_INDEX_DIR = "fonts/"; //$NON-NLS-1$
|
public static final String FONT_INDEX_DIR = "fonts/"; //$NON-NLS-1$
|
||||||
public static final String VOICE_INDEX_DIR = "voice/"; //$NON-NLS-1$
|
public static final String VOICE_INDEX_DIR = "voice/"; //$NON-NLS-1$
|
||||||
public static final String RENDERERS_DIR = "rendering/"; //$NON-NLS-1$
|
public static final String RENDERERS_DIR = "rendering/"; //$NON-NLS-1$
|
||||||
public static final String ROUTING_XML_FILE = "routing.xml";
|
public static final String ROUTING_XML_FILE= "routing.xml";
|
||||||
public static final String SETTINGS_DIR = "settings/"; //$NON-NLS-1$
|
public static final String SETTINGS_DIR = "settings/"; //$NON-NLS-1$
|
||||||
public static final String TEMP_DIR = "temp/";
|
public static final String TEMP_DIR = "temp/";
|
||||||
public static final String ROUTING_PROFILES_DIR = "routing/";
|
public static final String ROUTING_PROFILES_DIR = "routing/";
|
||||||
public static final String PLUGINS_DIR = "plugins/";
|
public static final String PLUGINS_DIR = "plugins/";
|
||||||
|
|
||||||
public static final String VOICE_PROVIDER_SUFFIX = "-tts";
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,6 @@ public class LocationConvert {
|
||||||
public static final int FORMAT_SECONDS = 2;
|
public static final int FORMAT_SECONDS = 2;
|
||||||
public static final int UTM_FORMAT = 3;
|
public static final int UTM_FORMAT = 3;
|
||||||
public static final int OLC_FORMAT = 4;
|
public static final int OLC_FORMAT = 4;
|
||||||
public static final int MGRS_FORMAT = 5;
|
|
||||||
private static final char DELIM = ':';
|
private static final char DELIM = ':';
|
||||||
private static final char DELIMITER_DEGREES = '°';
|
private static final char DELIMITER_DEGREES = '°';
|
||||||
private static final char DELIMITER_MINUTES = '′';
|
private static final char DELIMITER_MINUTES = '′';
|
||||||
|
|
|
@ -1,23 +1,20 @@
|
||||||
package net.osmand;
|
package net.osmand;
|
||||||
|
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class Period {
|
public class Period {
|
||||||
|
|
||||||
public enum PeriodUnit {
|
public enum PeriodUnit {
|
||||||
YEAR("Y", Calendar.YEAR),
|
YEAR("Y"),
|
||||||
MONTH("M", Calendar.MONTH),
|
MONTH("M"),
|
||||||
WEEK("W", Calendar.WEEK_OF_YEAR),
|
WEEK("W"),
|
||||||
DAY("D", Calendar.DATE);
|
DAY("D");
|
||||||
|
|
||||||
private String unitStr;
|
private String unitStr;
|
||||||
private int calendarIdx;
|
|
||||||
|
|
||||||
PeriodUnit(String unitStr, int calendarIdx) {
|
PeriodUnit(String unitStr) {
|
||||||
this.calendarIdx = calendarIdx;
|
|
||||||
this.unitStr = unitStr;
|
this.unitStr = unitStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,10 +22,6 @@ public class Period {
|
||||||
return unitStr;
|
return unitStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCalendarIdx() {
|
|
||||||
return calendarIdx;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getMonthsValue() {
|
public double getMonthsValue() {
|
||||||
switch (this) {
|
switch (this) {
|
||||||
case YEAR:
|
case YEAR:
|
||||||
|
|
|
@ -23,9 +23,7 @@ public class PlatformUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static XmlPullParser newXMLPullParser() throws XmlPullParserException{
|
public static XmlPullParser newXMLPullParser() throws XmlPullParserException{
|
||||||
org.kxml2.io.KXmlParser xmlParser = new org.kxml2.io.KXmlParser();
|
return new org.kxml2.io.KXmlParser();
|
||||||
xmlParser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
|
|
||||||
return xmlParser;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static XmlSerializer newSerializer() {
|
public static XmlSerializer newSerializer() {
|
||||||
|
|
|
@ -106,11 +106,9 @@ public class TspAnt {
|
||||||
// Allocates all memory.
|
// Allocates all memory.
|
||||||
// Adds 1 to edge lengths to ensure no zero length edges.
|
// Adds 1 to edge lengths to ensure no zero length edges.
|
||||||
public TspAnt readGraph(List<LatLon> intermediates, LatLon start, LatLon end) {
|
public TspAnt readGraph(List<LatLon> intermediates, LatLon start, LatLon end) {
|
||||||
boolean keepEndPoint = end != null;
|
boolean keepEndPoint = end != null;
|
||||||
List<LatLon> l = new ArrayList<LatLon>();
|
List<LatLon> l = new ArrayList<LatLon>();
|
||||||
if (start != null) {
|
l.add(start);
|
||||||
l.add(start);
|
|
||||||
}
|
|
||||||
l.addAll(intermediates);
|
l.addAll(intermediates);
|
||||||
if (keepEndPoint) {
|
if (keepEndPoint) {
|
||||||
l.add(end);
|
l.add(end);
|
||||||
|
|
|
@ -68,7 +68,7 @@ public class TspHeldKarp {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
System.err.print(".");
|
System.err.printf(".");
|
||||||
PriorityQueue<Node> children = new PriorityQueue<Node>(11, new NodeComparator());
|
PriorityQueue<Node> children = new PriorityQueue<Node>(11, new NodeComparator());
|
||||||
children.add(exclude(currentNode, i, currentNode.parent[i]));
|
children.add(exclude(currentNode, i, currentNode.parent[i]));
|
||||||
for (int j = 0; j < n; j++) {
|
for (int j = 0; j < n; j++) {
|
||||||
|
|
|
@ -8,7 +8,6 @@ import gnu.trove.set.hash.TIntHashSet;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -628,9 +627,7 @@ public class BinaryMapAddressReaderAdapter {
|
||||||
indexOffset = codedIS.getTotalBytesRead();
|
indexOffset = codedIS.getTotalBytesRead();
|
||||||
int oldLimit = codedIS.pushLimit(length);
|
int oldLimit = codedIS.pushLimit(length);
|
||||||
// here offsets are sorted by distance
|
// here offsets are sorted by distance
|
||||||
TIntArrayList charsList = new TIntArrayList();
|
map.readIndexedStringTable(stringMatcher.getCollator(), req.nameQuery, "", loffsets, 0);
|
||||||
charsList.add(0);
|
|
||||||
map.readIndexedStringTable(stringMatcher.getCollator(), Collections.singletonList(req.nameQuery), "", Collections.singletonList(loffsets), charsList);
|
|
||||||
codedIS.popLimit(oldLimit);
|
codedIS.popLimit(oldLimit);
|
||||||
break;
|
break;
|
||||||
case OsmAndAddressNameIndexData.ATOM_FIELD_NUMBER:
|
case OsmAndAddressNameIndexData.ATOM_FIELD_NUMBER:
|
||||||
|
|
|
@ -83,7 +83,7 @@ public class BinaryMapIndexReader {
|
||||||
|
|
||||||
public final static int TRANSPORT_STOP_ZOOM = 24;
|
public final static int TRANSPORT_STOP_ZOOM = 24;
|
||||||
public static final int SHIFT_COORDINATES = 5;
|
public static final int SHIFT_COORDINATES = 5;
|
||||||
public static final int LABEL_ZOOM_ENCODE = 31 - SHIFT_COORDINATES;
|
public static final int LABEL_ZOOM_ENCODE = 26;
|
||||||
private final static Log log = PlatformUtil.getLog(BinaryMapIndexReader.class);
|
private final static Log log = PlatformUtil.getLog(BinaryMapIndexReader.class);
|
||||||
public static boolean READ_STATS = false;
|
public static boolean READ_STATS = false;
|
||||||
public static final SearchPoiTypeFilter ACCEPT_ALL_POI_TYPE_FILTER = new SearchPoiTypeFilter() {
|
public static final SearchPoiTypeFilter ACCEPT_ALL_POI_TYPE_FILTER = new SearchPoiTypeFilter() {
|
||||||
|
@ -1538,20 +1538,9 @@ public class BinaryMapIndexReader {
|
||||||
|
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SearchRequest<Amenity> buildSearchPoiRequest(LatLon latLon, int radius, int zoom,
|
public static SearchRequest<RouteDataObject> buildSearchRouteRequest(int sleft, int sright, int stop, int sbottom,
|
||||||
SearchPoiTypeFilter poiTypeFilter,
|
ResultMatcher<RouteDataObject> matcher){
|
||||||
ResultMatcher<Amenity> matcher) {
|
|
||||||
SearchRequest<Amenity> request = new SearchRequest<>();
|
|
||||||
request.setBBoxRadius(latLon.getLatitude(), latLon.getLongitude(), radius);
|
|
||||||
request.zoom = zoom;
|
|
||||||
request.poiTypeFilter = poiTypeFilter;
|
|
||||||
request.resultMatcher = matcher;
|
|
||||||
return request;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static SearchRequest<RouteDataObject> buildSearchRouteRequest(int sleft, int sright, int stop, int sbottom,
|
|
||||||
ResultMatcher<RouteDataObject> matcher) {
|
|
||||||
SearchRequest<RouteDataObject> request = new SearchRequest<RouteDataObject>();
|
SearchRequest<RouteDataObject> request = new SearchRequest<RouteDataObject>();
|
||||||
request.left = sleft;
|
request.left = sleft;
|
||||||
request.right = sright;
|
request.right = sright;
|
||||||
|
@ -1568,10 +1557,6 @@ public class BinaryMapIndexReader {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SearchRequest<Amenity> buildSearchPoiRequest(int x, int y, String nameFilter, int sleft, int sright, int stop, int sbottom, ResultMatcher<Amenity> resultMatcher, ResultMatcher<Amenity> rawDataCollector) {
|
public static SearchRequest<Amenity> buildSearchPoiRequest(int x, int y, String nameFilter, int sleft, int sright, int stop, int sbottom, ResultMatcher<Amenity> resultMatcher, ResultMatcher<Amenity> rawDataCollector) {
|
||||||
return buildSearchPoiRequest(x, y, nameFilter, sleft, sright, stop, sbottom, null, resultMatcher, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static SearchRequest<Amenity> buildSearchPoiRequest(int x, int y, String nameFilter, int sleft, int sright, int stop, int sbottom, SearchPoiTypeFilter poiTypeFilter, ResultMatcher<Amenity> resultMatcher, ResultMatcher<Amenity> rawDataCollector) {
|
|
||||||
SearchRequest<Amenity> request = new SearchRequest<Amenity>();
|
SearchRequest<Amenity> request = new SearchRequest<Amenity>();
|
||||||
request.x = x;
|
request.x = x;
|
||||||
request.y = y;
|
request.y = y;
|
||||||
|
@ -1579,7 +1564,6 @@ public class BinaryMapIndexReader {
|
||||||
request.right = sright;
|
request.right = sright;
|
||||||
request.top = stop;
|
request.top = stop;
|
||||||
request.bottom = sbottom;
|
request.bottom = sbottom;
|
||||||
request.poiTypeFilter = poiTypeFilter;
|
|
||||||
request.resultMatcher = resultMatcher;
|
request.resultMatcher = resultMatcher;
|
||||||
request.rawDataCollector = rawDataCollector;
|
request.rawDataCollector = rawDataCollector;
|
||||||
request.nameQuery = nameFilter.trim();
|
request.nameQuery = nameFilter.trim();
|
||||||
|
@ -1727,12 +1711,13 @@ public class BinaryMapIndexReader {
|
||||||
double half16t = MapUtils.getDistance(lat, MapUtils.getLongitudeFromTile(16, ((int) dx) + 0.5),
|
double half16t = MapUtils.getDistance(lat, MapUtils.getLongitudeFromTile(16, ((int) dx) + 0.5),
|
||||||
lat, MapUtils.getLongitudeFromTile(16, (int) dx));
|
lat, MapUtils.getLongitudeFromTile(16, (int) dx));
|
||||||
double cf31 = ((double) radiusMeters / (half16t * 2)) * (1 << 15);
|
double cf31 = ((double) radiusMeters / (half16t * 2)) * (1 << 15);
|
||||||
y = MapUtils.get31TileNumberY(lat);
|
int y31 = MapUtils.get31TileNumberY(lat);
|
||||||
x = MapUtils.get31TileNumberX(lon);
|
int x31 = MapUtils.get31TileNumberX(lon);
|
||||||
left = (int) (x - cf31);
|
left = (int) (x31 - cf31);
|
||||||
right = (int) (x + cf31);
|
right = (int) (x31 + cf31);
|
||||||
top = (int) (y - cf31);
|
top = (int) (y31 - cf31);
|
||||||
bottom = (int) (y + cf31);
|
bottom = (int) (y31 + cf31);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean publish(T obj) {
|
public boolean publish(T obj) {
|
||||||
|
@ -1769,10 +1754,6 @@ public class BinaryMapIndexReader {
|
||||||
return limit != -1 && searchResults.size() > limit;
|
return limit != -1 && searchResults.size() > limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLimit(int limit) {
|
|
||||||
this.limit = limit;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCancelled() {
|
public boolean isCancelled() {
|
||||||
if (this.interrupted) {
|
if (this.interrupted) {
|
||||||
return interrupted;
|
return interrupted;
|
||||||
|
@ -2161,9 +2142,9 @@ public class BinaryMapIndexReader {
|
||||||
private static boolean testAddressSearch = false;
|
private static boolean testAddressSearch = false;
|
||||||
private static boolean testAddressSearchName = false;
|
private static boolean testAddressSearchName = false;
|
||||||
private static boolean testAddressJustifySearch = false;
|
private static boolean testAddressJustifySearch = false;
|
||||||
private static boolean testPoiSearch = true;
|
private static boolean testPoiSearch = false;
|
||||||
private static boolean testPoiSearchOnPath = false;
|
private static boolean testPoiSearchOnPath = false;
|
||||||
private static boolean testTransportSearch = false;
|
private static boolean testTransportSearch = true;
|
||||||
|
|
||||||
private static int sleft = MapUtils.get31TileNumberX(27.55079);
|
private static int sleft = MapUtils.get31TileNumberX(27.55079);
|
||||||
private static int sright = MapUtils.get31TileNumberX(27.55317);
|
private static int sright = MapUtils.get31TileNumberX(27.55317);
|
||||||
|
@ -2177,7 +2158,7 @@ public class BinaryMapIndexReader {
|
||||||
|
|
||||||
public static void main(String[] args) throws IOException {
|
public static void main(String[] args) throws IOException {
|
||||||
File fl = new File(System.getProperty("maps") + "/Synthetic_test_rendering.obf");
|
File fl = new File(System.getProperty("maps") + "/Synthetic_test_rendering.obf");
|
||||||
fl = new File(System.getProperty("maps") +"/Wikivoyage.obf__");
|
fl = new File("/home/madwasp79/OsmAnd-maps/Poly_center2.obf");
|
||||||
|
|
||||||
RandomAccessFile raf = new RandomAccessFile(fl, "r");
|
RandomAccessFile raf = new RandomAccessFile(fl, "r");
|
||||||
|
|
||||||
|
@ -2325,7 +2306,7 @@ public class BinaryMapIndexReader {
|
||||||
|
|
||||||
private static void testPoiSearchByName(BinaryMapIndexReader reader) throws IOException {
|
private static void testPoiSearchByName(BinaryMapIndexReader reader) throws IOException {
|
||||||
println("Searching by name...");
|
println("Searching by name...");
|
||||||
SearchRequest<Amenity> req = buildSearchPoiRequest(0, 0, "central ukraine",
|
SearchRequest<Amenity> req = buildSearchPoiRequest(0, 0, "Art",
|
||||||
0, Integer.MAX_VALUE, 0, Integer.MAX_VALUE, null);
|
0, Integer.MAX_VALUE, 0, Integer.MAX_VALUE, null);
|
||||||
|
|
||||||
reader.searchPoiByName(req);
|
reader.searchPoiByName(req);
|
||||||
|
@ -2385,72 +2366,54 @@ public class BinaryMapIndexReader {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void readIndexedStringTable(Collator instance, List<String> queries, String prefix, List<TIntArrayList> listOffsets, TIntArrayList matchedCharacters) throws IOException {
|
int readIndexedStringTable(Collator instance, String query, String prefix, TIntArrayList list, int charMatches) throws IOException {
|
||||||
String key = null;
|
String key = null;
|
||||||
boolean[] matched = new boolean[matchedCharacters.size()];
|
|
||||||
boolean shouldWeReadSubtable = false;
|
|
||||||
while (true) {
|
while (true) {
|
||||||
int t = codedIS.readTag();
|
int t = codedIS.readTag();
|
||||||
int tag = WireFormat.getTagFieldNumber(t);
|
int tag = WireFormat.getTagFieldNumber(t);
|
||||||
switch (tag) {
|
switch (tag) {
|
||||||
case 0:
|
case 0:
|
||||||
return;
|
return charMatches;
|
||||||
case OsmandOdb.IndexedStringTable.KEY_FIELD_NUMBER :
|
case OsmandOdb.IndexedStringTable.KEY_FIELD_NUMBER :
|
||||||
key = codedIS.readString();
|
key = codedIS.readString();
|
||||||
if (prefix.length() > 0) {
|
if(prefix.length() > 0){
|
||||||
key = prefix + key;
|
key = prefix + key;
|
||||||
}
|
}
|
||||||
shouldWeReadSubtable = false;
|
// check query is part of key (the best matching)
|
||||||
for (int i = 0; i < queries.size(); i++) {
|
if(CollatorStringMatcher.cmatches(instance, key, query, StringMatcherMode.CHECK_ONLY_STARTS_WITH)){
|
||||||
int charMatches = matchedCharacters.get(i);
|
if(query.length() >= charMatches){
|
||||||
String query = queries.get(i);
|
if(query.length() > charMatches){
|
||||||
matched[i] = false;
|
charMatches = query.length();
|
||||||
if (query == null) {
|
list.clear();
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// check query is part of key (the best matching)
|
|
||||||
if (CollatorStringMatcher.cmatches(instance, key, query, StringMatcherMode.CHECK_ONLY_STARTS_WITH)) {
|
|
||||||
if (query.length() >= charMatches) {
|
|
||||||
if (query.length() > charMatches) {
|
|
||||||
matchedCharacters.set(i, query.length());
|
|
||||||
listOffsets.get(i).clear();
|
|
||||||
}
|
|
||||||
matched[i] = true;
|
|
||||||
}
|
|
||||||
// check key is part of query
|
|
||||||
} else if (CollatorStringMatcher.cmatches(instance, query, key, StringMatcherMode.CHECK_ONLY_STARTS_WITH)) {
|
|
||||||
if (key.length() >= charMatches) {
|
|
||||||
if (key.length() > charMatches) {
|
|
||||||
matchedCharacters.set(i, key.length());
|
|
||||||
listOffsets.get(i).clear();
|
|
||||||
}
|
|
||||||
matched[i] = true;
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
key = null;
|
||||||
}
|
}
|
||||||
shouldWeReadSubtable |= matched[i];
|
// check key is part of query
|
||||||
|
} else if (CollatorStringMatcher.cmatches(instance, query, key, StringMatcherMode.CHECK_ONLY_STARTS_WITH)) {
|
||||||
|
if (key.length() >= charMatches) {
|
||||||
|
if (key.length() > charMatches) {
|
||||||
|
charMatches = key.length();
|
||||||
|
list.clear();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
key = null;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
key = null;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OsmandOdb.IndexedStringTable.VAL_FIELD_NUMBER :
|
case OsmandOdb.IndexedStringTable.VAL_FIELD_NUMBER :
|
||||||
int val = readInt();
|
int val = readInt();
|
||||||
for (int i = 0; i < queries.size(); i++) {
|
if (key != null) {
|
||||||
if (matched[i]) {
|
list.add(val);
|
||||||
listOffsets.get(i).add(val);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OsmandOdb.IndexedStringTable.SUBTABLES_FIELD_NUMBER :
|
case OsmandOdb.IndexedStringTable.SUBTABLES_FIELD_NUMBER :
|
||||||
int len = codedIS.readRawVarint32();
|
int len = codedIS.readRawVarint32();
|
||||||
int oldLim = codedIS.pushLimit(len);
|
int oldLim = codedIS.pushLimit(len);
|
||||||
if (shouldWeReadSubtable && key != null) {
|
if (key != null) {
|
||||||
List<String> subqueries = new ArrayList<>(queries);
|
charMatches = readIndexedStringTable(instance, query, key, list, charMatches);
|
||||||
// reset query so we don't search what was not matched
|
|
||||||
for(int i = 0; i < queries.size(); i++) {
|
|
||||||
if(!matched[i]) {
|
|
||||||
subqueries.set(i, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
readIndexedStringTable(instance, subqueries, key, listOffsets, matchedCharacters);
|
|
||||||
} else {
|
} else {
|
||||||
codedIS.skipRawBytes(codedIS.getBytesUntilLimit());
|
codedIS.skipRawBytes(codedIS.getBytesUntilLimit());
|
||||||
}
|
}
|
||||||
|
@ -2538,9 +2501,8 @@ public class BinaryMapIndexReader {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Entry<MapObject, Street> entry : resMap.entrySet()) {
|
for (MapObject e : resMap.keySet()) {
|
||||||
MapObject e = entry.getKey();
|
Street s = resMap.get(e);
|
||||||
Street s = entry.getValue();
|
|
||||||
if (e instanceof Building && MapUtils.getDistance(e.getLocation(), lat, lon) < 40) {
|
if (e instanceof Building && MapUtils.getDistance(e.getLocation(), lat, lon) < 40) {
|
||||||
Building b = (Building) e;
|
Building b = (Building) e;
|
||||||
System.out.println(b.getName() + " " + s);
|
System.out.println(b.getName() + " " + s);
|
||||||
|
|
|
@ -1,21 +1,19 @@
|
||||||
package net.osmand.binary;
|
package net.osmand.binary;
|
||||||
|
|
||||||
|
|
||||||
|
import gnu.trove.list.array.TIntArrayList;
|
||||||
|
import gnu.trove.map.hash.TIntLongHashMap;
|
||||||
|
import gnu.trove.set.hash.TLongHashSet;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
|
|
||||||
import com.google.protobuf.CodedInputStream;
|
|
||||||
import com.google.protobuf.WireFormat;
|
|
||||||
|
|
||||||
import gnu.trove.list.array.TIntArrayList;
|
|
||||||
import gnu.trove.map.hash.TIntLongHashMap;
|
|
||||||
import gnu.trove.set.hash.TLongHashSet;
|
|
||||||
import net.osmand.Collator;
|
import net.osmand.Collator;
|
||||||
import net.osmand.CollatorStringMatcher;
|
import net.osmand.CollatorStringMatcher;
|
||||||
import net.osmand.CollatorStringMatcher.StringMatcherMode;
|
import net.osmand.CollatorStringMatcher.StringMatcherMode;
|
||||||
|
@ -30,6 +28,11 @@ import net.osmand.osm.MapPoiTypes;
|
||||||
import net.osmand.osm.PoiCategory;
|
import net.osmand.osm.PoiCategory;
|
||||||
import net.osmand.util.MapUtils;
|
import net.osmand.util.MapUtils;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
|
import com.google.protobuf.CodedInputStream;
|
||||||
|
import com.google.protobuf.WireFormat;
|
||||||
|
|
||||||
public class BinaryMapPoiReaderAdapter {
|
public class BinaryMapPoiReaderAdapter {
|
||||||
private static final Log LOG = PlatformUtil.getLog(BinaryMapPoiReaderAdapter.class);
|
private static final Log LOG = PlatformUtil.getLog(BinaryMapPoiReaderAdapter.class);
|
||||||
|
|
||||||
|
@ -37,12 +40,7 @@ public class BinaryMapPoiReaderAdapter {
|
||||||
private static final int CATEGORY_MASK = (1 << SHIFT_BITS_CATEGORY) - 1;
|
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_READ = 6;
|
||||||
private static final int ZOOM_TO_SKIP_FILTER = 3;
|
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 = 5;
|
||||||
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 static class PoiSubType {
|
||||||
public boolean text;
|
public boolean text;
|
||||||
|
@ -336,7 +334,7 @@ public class BinaryMapPoiReaderAdapter {
|
||||||
});
|
});
|
||||||
int p = BUCKET_SEARCH_BY_NAME * 3;
|
int p = BUCKET_SEARCH_BY_NAME * 3;
|
||||||
if (p < offKeys.length) {
|
if (p < offKeys.length) {
|
||||||
for (int i = p + BUCKET_SEARCH_BY_NAME;; i += BUCKET_SEARCH_BY_NAME) {
|
for (int i = p + BUCKET_SEARCH_BY_NAME; ; i += BUCKET_SEARCH_BY_NAME) {
|
||||||
if (i > offKeys.length) {
|
if (i > offKeys.length) {
|
||||||
Arrays.sort(offKeys, p, offKeys.length);
|
Arrays.sort(offKeys, p, offKeys.length);
|
||||||
break;
|
break;
|
||||||
|
@ -348,6 +346,7 @@ public class BinaryMapPoiReaderAdapter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LOG.info("Searched poi structure in " + (System.currentTimeMillis() - time) +
|
LOG.info("Searched poi structure in " + (System.currentTimeMillis() - time) +
|
||||||
"ms. Found " + offKeys.length + " subtrees");
|
"ms. Found " + offKeys.length + " subtrees");
|
||||||
for (int j = 0; j < offKeys.length; j++) {
|
for (int j = 0; j < offKeys.length; j++) {
|
||||||
|
@ -373,8 +372,7 @@ public class BinaryMapPoiReaderAdapter {
|
||||||
|
|
||||||
private TIntLongHashMap readPoiNameIndex(Collator instance, String query, SearchRequest<Amenity> req) throws IOException {
|
private TIntLongHashMap readPoiNameIndex(Collator instance, String query, SearchRequest<Amenity> req) throws IOException {
|
||||||
TIntLongHashMap offsets = new TIntLongHashMap();
|
TIntLongHashMap offsets = new TIntLongHashMap();
|
||||||
List<TIntArrayList> listOffsets = null;
|
TIntArrayList dataOffsets = null;
|
||||||
List<TIntLongHashMap> listOfSepOffsets = new ArrayList<TIntLongHashMap>();
|
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
int t = codedIS.readTag();
|
int t = codedIS.readTag();
|
||||||
|
@ -385,51 +383,24 @@ public class BinaryMapPoiReaderAdapter {
|
||||||
case OsmandOdb.OsmAndPoiNameIndex.TABLE_FIELD_NUMBER: {
|
case OsmandOdb.OsmAndPoiNameIndex.TABLE_FIELD_NUMBER: {
|
||||||
int length = readInt();
|
int length = readInt();
|
||||||
int oldLimit = codedIS.pushLimit(length);
|
int oldLimit = codedIS.pushLimit(length);
|
||||||
|
dataOffsets = new TIntArrayList();
|
||||||
offset = codedIS.getTotalBytesRead();
|
offset = codedIS.getTotalBytesRead();
|
||||||
List<String> queries = new ArrayList<>();
|
map.readIndexedStringTable(instance, query, "", dataOffsets, 0);
|
||||||
for (String word : query.split(" ")) {
|
|
||||||
if (word.trim().length() > 0) {
|
|
||||||
queries.add(word.trim());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
TIntArrayList charsList = new TIntArrayList(queries.size());
|
|
||||||
listOffsets = new ArrayList<TIntArrayList>(queries.size());
|
|
||||||
while(listOffsets.size() < queries.size()) {
|
|
||||||
charsList.add(0);
|
|
||||||
listOffsets.add(new TIntArrayList());
|
|
||||||
}
|
|
||||||
map.readIndexedStringTable(instance, queries, "", listOffsets, charsList);
|
|
||||||
codedIS.popLimit(oldLimit);
|
codedIS.popLimit(oldLimit);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case OsmandOdb.OsmAndPoiNameIndex.DATA_FIELD_NUMBER: {
|
case OsmandOdb.OsmAndPoiNameIndex.DATA_FIELD_NUMBER: {
|
||||||
if (listOffsets != null) {
|
if (dataOffsets != null) {
|
||||||
for (TIntArrayList dataOffsets : listOffsets) {
|
dataOffsets.sort(); // 1104125
|
||||||
TIntLongHashMap offsetMap = new TIntLongHashMap();
|
for (int i = 0; i < dataOffsets.size(); i++) {
|
||||||
listOfSepOffsets.add(offsetMap);
|
codedIS.seek(dataOffsets.get(i) + offset);
|
||||||
dataOffsets.sort(); // 1104125
|
int len = codedIS.readRawVarint32();
|
||||||
for (int i = 0; i < dataOffsets.size(); i++) {
|
int oldLim = codedIS.pushLimit(len);
|
||||||
codedIS.seek(dataOffsets.get(i) + offset);
|
readPoiNameIndexData(offsets, req);
|
||||||
int len = codedIS.readRawVarint32();
|
codedIS.popLimit(oldLim);
|
||||||
int oldLim = codedIS.pushLimit(len);
|
if (req.isCancelled()) {
|
||||||
readPoiNameIndexData(offsetMap, req);
|
codedIS.skipRawBytes(codedIS.getBytesUntilLimit());
|
||||||
codedIS.popLimit(oldLim);
|
return offsets;
|
||||||
if (req.isCancelled()) {
|
|
||||||
codedIS.skipRawBytes(codedIS.getBytesUntilLimit());
|
|
||||||
return offsets;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (listOfSepOffsets.size() > 0) {
|
|
||||||
offsets.putAll(listOfSepOffsets.get(0));
|
|
||||||
for (int j = 1; j < listOfSepOffsets.size(); j++) {
|
|
||||||
TIntLongHashMap mp = listOfSepOffsets.get(j);
|
|
||||||
// offsets.retainAll(mp); -- calculate intresection of mp & offsets
|
|
||||||
for (int chKey : offsets.keys()) {
|
|
||||||
if (!mp.containsKey(chKey)) {
|
|
||||||
offsets.remove(chKey);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -605,12 +576,13 @@ public class BinaryMapPoiReaderAdapter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!matches) {
|
if (!matches) {
|
||||||
for (String key : am.getAdditionalInfoKeys()) {
|
Map<String, String> lt = am.getAdditionalInfo();
|
||||||
if(!key.contains("_name") &&
|
for (Entry<String, String> e : lt.entrySet()) {
|
||||||
!key.equals("brand")) {
|
if(!e.getKey().contains("_name") &&
|
||||||
|
!e.getKey().equals("brand")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
matches = matcher.matches(am.getAdditionalInfo(key));
|
matches = matcher.matches(e.getValue());
|
||||||
if (matches) {
|
if (matches) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -719,8 +691,6 @@ public class BinaryMapPoiReaderAdapter {
|
||||||
Amenity am = null;
|
Amenity am = null;
|
||||||
int x = 0;
|
int x = 0;
|
||||||
int y = 0;
|
int y = 0;
|
||||||
int precisionXY = 0;
|
|
||||||
boolean hasLocation = false;
|
|
||||||
StringBuilder retValue = new StringBuilder();
|
StringBuilder retValue = new StringBuilder();
|
||||||
PoiCategory amenityType = null;
|
PoiCategory amenityType = null;
|
||||||
LinkedList<String> textTags = null;
|
LinkedList<String> textTags = null;
|
||||||
|
@ -747,22 +717,12 @@ public class BinaryMapPoiReaderAdapter {
|
||||||
am.setRoutePoint(arp);
|
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;
|
return am;
|
||||||
case OsmandOdb.OsmAndPoiBoxDataAtom.DX_FIELD_NUMBER:
|
case OsmandOdb.OsmAndPoiBoxDataAtom.DX_FIELD_NUMBER:
|
||||||
x = (codedIS.readSInt32() + (px << (BASE_POI_ZOOM - zoom))) << BASE_POI_SHIFT;
|
x = (codedIS.readSInt32() + (px << (24 - zoom))) << 7;
|
||||||
break;
|
break;
|
||||||
case OsmandOdb.OsmAndPoiBoxDataAtom.DY_FIELD_NUMBER:
|
case OsmandOdb.OsmAndPoiBoxDataAtom.DY_FIELD_NUMBER:
|
||||||
y = (codedIS.readSInt32() + (py << (BASE_POI_ZOOM - zoom))) << BASE_POI_SHIFT;
|
y = (codedIS.readSInt32() + (py << (24 - zoom))) << 7;
|
||||||
req.numberOfVisitedObjects++;
|
req.numberOfVisitedObjects++;
|
||||||
if (checkBounds) {
|
if (checkBounds) {
|
||||||
if (left31 > x || right31 < x || top31 > y || bottom31 < y) {
|
if (left31 > x || right31 < x || top31 > y || bottom31 < y) {
|
||||||
|
@ -771,8 +731,7 @@ public class BinaryMapPoiReaderAdapter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
am = new Amenity();
|
am = new Amenity();
|
||||||
hasLocation = true;
|
am.setLocation(MapUtils.get31LatitudeY(y), MapUtils.get31LongitudeX(x));
|
||||||
//am.setLocation(MapUtils.get31LatitudeY(y), MapUtils.get31LongitudeX(x)); // set precise coordinates
|
|
||||||
break;
|
break;
|
||||||
case OsmandOdb.OsmAndPoiBoxDataAtom.SUBCATEGORIES_FIELD_NUMBER:
|
case OsmandOdb.OsmAndPoiBoxDataAtom.SUBCATEGORIES_FIELD_NUMBER:
|
||||||
int subtypev = codedIS.readUInt32();
|
int subtypev = codedIS.readUInt32();
|
||||||
|
@ -845,11 +804,6 @@ public class BinaryMapPoiReaderAdapter {
|
||||||
case OsmandOdb.OsmAndPoiBoxDataAtom.NOTE_FIELD_NUMBER:
|
case OsmandOdb.OsmAndPoiBoxDataAtom.NOTE_FIELD_NUMBER:
|
||||||
am.setDescription(codedIS.readString());
|
am.setDescription(codedIS.readString());
|
||||||
break;
|
break;
|
||||||
case OsmandOdb.OsmAndPoiBoxDataAtom.PRECISIONXY_FIELD_NUMBER:
|
|
||||||
if (hasLocation) {
|
|
||||||
precisionXY = codedIS.readInt32();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
skipUnknownField(t);
|
skipUnknownField(t);
|
||||||
break;
|
break;
|
||||||
|
@ -858,6 +812,7 @@ public class BinaryMapPoiReaderAdapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkCategories(SearchRequest<Amenity> req, PoiRegion region) throws IOException {
|
private boolean checkCategories(SearchRequest<Amenity> req, PoiRegion region) throws IOException {
|
||||||
|
StringBuilder subType = new StringBuilder();
|
||||||
while (true) {
|
while (true) {
|
||||||
int t = codedIS.readTag();
|
int t = codedIS.readTag();
|
||||||
int tag = WireFormat.getTagFieldNumber(t);
|
int tag = WireFormat.getTagFieldNumber(t);
|
||||||
|
|
|
@ -1,9 +1,25 @@
|
||||||
package net.osmand.binary;
|
package net.osmand.binary;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
import com.google.protobuf.CodedInputStream;
|
import com.google.protobuf.CodedInputStream;
|
||||||
import com.google.protobuf.InvalidProtocolBufferException;
|
import com.google.protobuf.InvalidProtocolBufferException;
|
||||||
import com.google.protobuf.WireFormat;
|
import com.google.protobuf.WireFormat;
|
||||||
|
|
||||||
|
import gnu.trove.iterator.TLongObjectIterator;
|
||||||
|
import gnu.trove.list.array.TIntArrayList;
|
||||||
|
import gnu.trove.list.array.TLongArrayList;
|
||||||
|
import gnu.trove.map.hash.TIntObjectHashMap;
|
||||||
|
import gnu.trove.map.hash.TLongObjectHashMap;
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.ResultMatcher;
|
import net.osmand.ResultMatcher;
|
||||||
import net.osmand.binary.BinaryMapIndexReader.SearchRequest;
|
import net.osmand.binary.BinaryMapIndexReader.SearchRequest;
|
||||||
|
@ -18,23 +34,6 @@ import net.osmand.util.Algorithms;
|
||||||
import net.osmand.util.MapUtils;
|
import net.osmand.util.MapUtils;
|
||||||
import net.osmand.util.OpeningHoursParser;
|
import net.osmand.util.OpeningHoursParser;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import gnu.trove.iterator.TLongObjectIterator;
|
|
||||||
import gnu.trove.list.array.TIntArrayList;
|
|
||||||
import gnu.trove.list.array.TLongArrayList;
|
|
||||||
import gnu.trove.map.hash.TIntObjectHashMap;
|
|
||||||
import gnu.trove.map.hash.TLongObjectHashMap;
|
|
||||||
|
|
||||||
public class BinaryMapRouteReaderAdapter {
|
public class BinaryMapRouteReaderAdapter {
|
||||||
protected static final Log LOG = PlatformUtil.getLog(BinaryMapRouteReaderAdapter.class);
|
protected static final Log LOG = PlatformUtil.getLog(BinaryMapRouteReaderAdapter.class);
|
||||||
private static final int SHIFT_COORDINATES = 4;
|
private static final int SHIFT_COORDINATES = 4;
|
||||||
|
@ -304,7 +303,6 @@ public class BinaryMapRouteReaderAdapter {
|
||||||
public int directionTrafficSignalsBackward = -1;
|
public int directionTrafficSignalsBackward = -1;
|
||||||
public int trafficSignals = -1;
|
public int trafficSignals = -1;
|
||||||
public int stopSign = -1;
|
public int stopSign = -1;
|
||||||
public int stopMinor = -1;
|
|
||||||
public int giveWaySign = -1;
|
public int giveWaySign = -1;
|
||||||
|
|
||||||
int nameTypeRule = -1;
|
int nameTypeRule = -1;
|
||||||
|
@ -365,8 +363,6 @@ public class BinaryMapRouteReaderAdapter {
|
||||||
destinationRefTypeRule = id;
|
destinationRefTypeRule = id;
|
||||||
} else if (tags.equals("highway") && val.equals("traffic_signals")){
|
} else if (tags.equals("highway") && val.equals("traffic_signals")){
|
||||||
trafficSignals = id;
|
trafficSignals = id;
|
||||||
} else if (tags.equals("stop") && val.equals("minor")) {
|
|
||||||
stopMinor = id;
|
|
||||||
} else if (tags.equals("highway") && val.equals("stop")){
|
} else if (tags.equals("highway") && val.equals("stop")){
|
||||||
stopSign = id;
|
stopSign = id;
|
||||||
} else if (tags.equals("highway") && val.equals("give_way")){
|
} else if (tags.equals("highway") && val.equals("give_way")){
|
||||||
|
|
|
@ -1,5 +1,11 @@
|
||||||
package net.osmand.binary;
|
package net.osmand.binary;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.RandomAccessFile;
|
||||||
|
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.binary.BinaryMapAddressReaderAdapter.AddressRegion;
|
import net.osmand.binary.BinaryMapAddressReaderAdapter.AddressRegion;
|
||||||
import net.osmand.binary.BinaryMapAddressReaderAdapter.CitiesBlock;
|
import net.osmand.binary.BinaryMapAddressReaderAdapter.CitiesBlock;
|
||||||
|
@ -23,50 +29,42 @@ import net.osmand.binary.OsmandIndex.TransportPart;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.RandomAccessFile;
|
|
||||||
|
|
||||||
public class CachedOsmandIndexes {
|
public class CachedOsmandIndexes {
|
||||||
|
|
||||||
private OsmAndStoredIndex storedIndex;
|
private OsmAndStoredIndex storedIndex;
|
||||||
private OsmAndStoredIndex.Builder storedIndexBuilder;
|
private OsmAndStoredIndex.Builder storedIndexBuilder;
|
||||||
private Log log = PlatformUtil.getLog(CachedOsmandIndexes.class);
|
private Log log = PlatformUtil.getLog(CachedOsmandIndexes.class);
|
||||||
private boolean hasChanged = true;
|
private boolean hasChanged = true;
|
||||||
|
|
||||||
public static final int VERSION = 2;
|
public static final int VERSION = 2;
|
||||||
|
|
||||||
public void addToCache(BinaryMapIndexReader reader, File f) {
|
public void addToCache(BinaryMapIndexReader reader, File f) {
|
||||||
hasChanged = true;
|
hasChanged = true;
|
||||||
if (storedIndexBuilder == null) {
|
if(storedIndexBuilder == null) {
|
||||||
storedIndexBuilder = OsmandIndex.OsmAndStoredIndex.newBuilder();
|
storedIndexBuilder = OsmandIndex.OsmAndStoredIndex.newBuilder();
|
||||||
storedIndexBuilder.setVersion(VERSION);
|
storedIndexBuilder.setVersion(VERSION);
|
||||||
storedIndexBuilder.setDateCreated(System.currentTimeMillis());
|
storedIndexBuilder.setDateCreated(System.currentTimeMillis());
|
||||||
if (storedIndex != null) {
|
if(storedIndex != null) {
|
||||||
for (FileIndex ex : storedIndex.getFileIndexList()) {
|
for(FileIndex ex : storedIndex.getFileIndexList()) {
|
||||||
if (!ex.getFileName().equals(f.getName())) {
|
storedIndexBuilder.addFileIndex(ex);
|
||||||
storedIndexBuilder.addFileIndex(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FileIndex.Builder fileIndex = OsmandIndex.FileIndex.newBuilder();
|
FileIndex.Builder fileIndex = OsmandIndex.FileIndex.newBuilder();
|
||||||
long d = reader.getDateCreated();
|
long d = reader.getDateCreated();
|
||||||
fileIndex.setDateModified(d == 0 ? f.lastModified() : d);
|
fileIndex.setDateModified(d== 0?f.lastModified() : d);
|
||||||
fileIndex.setSize(f.length());
|
fileIndex.setSize(f.length());
|
||||||
fileIndex.setVersion(reader.getVersion());
|
fileIndex.setVersion(reader.getVersion());
|
||||||
fileIndex.setFileName(f.getName());
|
fileIndex.setFileName(f.getName());
|
||||||
for (MapIndex index : reader.getMapIndexes()) {
|
for(MapIndex index : reader.getMapIndexes()) {
|
||||||
MapPart.Builder map = OsmandIndex.MapPart.newBuilder();
|
MapPart.Builder map = OsmandIndex.MapPart.newBuilder();
|
||||||
map.setSize(index.getLength());
|
map.setSize(index.getLength());
|
||||||
map.setOffset(index.getFilePointer());
|
map.setOffset(index.getFilePointer());
|
||||||
if (index.getName() != null) {
|
if(index.getName() != null) {
|
||||||
map.setName(index.getName());
|
map.setName(index.getName());
|
||||||
}
|
}
|
||||||
for (MapRoot mr : index.getRoots()) {
|
for(MapRoot mr : index.getRoots() ) {
|
||||||
MapLevel.Builder lev = OsmandIndex.MapLevel.newBuilder();
|
MapLevel.Builder lev = OsmandIndex.MapLevel.newBuilder();
|
||||||
lev.setSize(mr.length);
|
lev.setSize(mr.length);
|
||||||
lev.setOffset(mr.filePointer);
|
lev.setOffset(mr.filePointer);
|
||||||
|
@ -80,36 +78,36 @@ public class CachedOsmandIndexes {
|
||||||
}
|
}
|
||||||
fileIndex.addMapIndex(map);
|
fileIndex.addMapIndex(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (AddressRegion index : reader.getAddressIndexes()) {
|
for(AddressRegion index : reader.getAddressIndexes()) {
|
||||||
AddressPart.Builder addr = OsmandIndex.AddressPart.newBuilder();
|
AddressPart.Builder addr = OsmandIndex.AddressPart.newBuilder();
|
||||||
addr.setSize(index.getLength());
|
addr.setSize(index.getLength());
|
||||||
addr.setOffset(index.getFilePointer());
|
addr.setOffset(index.getFilePointer());
|
||||||
if (index.getName() != null) {
|
if(index.getName() != null) {
|
||||||
addr.setName(index.getName());
|
addr.setName(index.getName());
|
||||||
}
|
}
|
||||||
if (index.getEnName() != null) {
|
if(index.getEnName() != null) {
|
||||||
addr.setNameEn(index.getEnName());
|
addr.setNameEn(index.getEnName());
|
||||||
}
|
}
|
||||||
addr.setIndexNameOffset(index.getIndexNameOffset());
|
addr.setIndexNameOffset(index.getIndexNameOffset());
|
||||||
for (CitiesBlock mr : index.getCities()) {
|
for(CitiesBlock mr : index.getCities() ) {
|
||||||
CityBlock.Builder cblock = OsmandIndex.CityBlock.newBuilder();
|
CityBlock.Builder cblock = OsmandIndex.CityBlock.newBuilder();
|
||||||
cblock.setSize(mr.length);
|
cblock.setSize(mr.length);
|
||||||
cblock.setOffset(mr.filePointer);
|
cblock.setOffset(mr.filePointer);
|
||||||
cblock.setType(mr.type);
|
cblock.setType(mr.type);
|
||||||
addr.addCities(cblock);
|
addr.addCities(cblock);
|
||||||
}
|
}
|
||||||
for (String s : index.getAttributeTagsTable()) {
|
for(String s : index.getAttributeTagsTable()) {
|
||||||
addr.addAdditionalTags(s);
|
addr.addAdditionalTags(s);
|
||||||
}
|
}
|
||||||
fileIndex.addAddressIndex(addr);
|
fileIndex.addAddressIndex(addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (PoiRegion index : reader.getPoiIndexes()) {
|
for(PoiRegion index : reader.getPoiIndexes()) {
|
||||||
PoiPart.Builder poi = OsmandIndex.PoiPart.newBuilder();
|
PoiPart.Builder poi = OsmandIndex.PoiPart.newBuilder();
|
||||||
poi.setSize(index.getLength());
|
poi.setSize(index.getLength());
|
||||||
poi.setOffset(index.getFilePointer());
|
poi.setOffset(index.getFilePointer());
|
||||||
if (index.getName() != null) {
|
if(index.getName() != null) {
|
||||||
poi.setName(index.getName());
|
poi.setName(index.getName());
|
||||||
}
|
}
|
||||||
poi.setLeft(index.left31);
|
poi.setLeft(index.left31);
|
||||||
|
@ -118,12 +116,12 @@ public class CachedOsmandIndexes {
|
||||||
poi.setBottom(index.bottom31);
|
poi.setBottom(index.bottom31);
|
||||||
fileIndex.addPoiIndex(poi.build());
|
fileIndex.addPoiIndex(poi.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (TransportIndex index : reader.getTransportIndexes()) {
|
for(TransportIndex index : reader.getTransportIndexes()) {
|
||||||
TransportPart.Builder transport = OsmandIndex.TransportPart.newBuilder();
|
TransportPart.Builder transport = OsmandIndex.TransportPart.newBuilder();
|
||||||
transport.setSize(index.getLength());
|
transport.setSize(index.getLength());
|
||||||
transport.setOffset(index.getFilePointer());
|
transport.setOffset(index.getFilePointer());
|
||||||
if (index.getName() != null) {
|
if(index.getName() != null) {
|
||||||
transport.setName(index.getName());
|
transport.setName(index.getName());
|
||||||
}
|
}
|
||||||
transport.setLeft(index.getLeft());
|
transport.setLeft(index.getLeft());
|
||||||
|
@ -132,33 +130,33 @@ public class CachedOsmandIndexes {
|
||||||
transport.setBottom(index.getBottom());
|
transport.setBottom(index.getBottom());
|
||||||
transport.setStopsTableLength(index.stopsFileLength);
|
transport.setStopsTableLength(index.stopsFileLength);
|
||||||
transport.setStopsTableOffset(index.stopsFileOffset);
|
transport.setStopsTableOffset(index.stopsFileOffset);
|
||||||
// if(index.incompleteRoutesLength > 0) {
|
// if(index.incompleteRoutesLength > 0) {
|
||||||
transport.setIncompleteRoutesLength(index.incompleteRoutesLength);
|
transport.setIncompleteRoutesLength(index.incompleteRoutesLength);
|
||||||
transport.setIncompleteRoutesOffset(index.incompleteRoutesOffset);
|
transport.setIncompleteRoutesOffset(index.incompleteRoutesOffset);
|
||||||
// }
|
// }
|
||||||
transport.setStringTableLength(index.stringTable.length);
|
transport.setStringTableLength(index.stringTable.length);
|
||||||
transport.setStringTableOffset(index.stringTable.fileOffset);
|
transport.setStringTableOffset(index.stringTable.fileOffset);
|
||||||
fileIndex.addTransportIndex(transport);
|
fileIndex.addTransportIndex(transport);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (RouteRegion index : reader.getRoutingIndexes()) {
|
for(RouteRegion index : reader.getRoutingIndexes()) {
|
||||||
RoutingPart.Builder routing = OsmandIndex.RoutingPart.newBuilder();
|
RoutingPart.Builder routing = OsmandIndex.RoutingPart.newBuilder();
|
||||||
routing.setSize(index.getLength());
|
routing.setSize(index.getLength());
|
||||||
routing.setOffset(index.getFilePointer());
|
routing.setOffset(index.getFilePointer());
|
||||||
if (index.getName() != null) {
|
if(index.getName() != null) {
|
||||||
routing.setName(index.getName());
|
routing.setName(index.getName());
|
||||||
}
|
}
|
||||||
for (RouteSubregion sub : index.getSubregions()) {
|
for(RouteSubregion sub : index.getSubregions()) {
|
||||||
addRouteSubregion(routing, sub, false);
|
addRouteSubregion(routing, sub, false);
|
||||||
}
|
}
|
||||||
for (RouteSubregion sub : index.getBaseSubregions()) {
|
for(RouteSubregion sub : index.getBaseSubregions()) {
|
||||||
addRouteSubregion(routing, sub, true);
|
addRouteSubregion(routing, sub, true);
|
||||||
}
|
}
|
||||||
fileIndex.addRoutingIndex(routing);
|
fileIndex.addRoutingIndex(routing);
|
||||||
}
|
}
|
||||||
|
|
||||||
storedIndexBuilder.addFileIndex(fileIndex);
|
storedIndexBuilder.addFileIndex(fileIndex);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addRouteSubregion(RoutingPart.Builder routing, RouteSubregion sub, boolean base) {
|
private void addRouteSubregion(RoutingPart.Builder routing, RouteSubregion sub, boolean base) {
|
||||||
|
@ -173,11 +171,11 @@ public class CachedOsmandIndexes {
|
||||||
rpart.setShifToData(sub.shiftToData);
|
rpart.setShifToData(sub.shiftToData);
|
||||||
routing.addSubregions(rpart);
|
routing.addSubregions(rpart);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BinaryMapIndexReader getReader(File f, boolean useStoredIndex) throws IOException {
|
public BinaryMapIndexReader getReader(File f) throws IOException {
|
||||||
RandomAccessFile mf = new RandomAccessFile(f.getPath(), "r");
|
RandomAccessFile mf = new RandomAccessFile(f.getPath(), "r");
|
||||||
FileIndex found = null;
|
FileIndex found = null;
|
||||||
if (storedIndex != null && useStoredIndex) {
|
if (storedIndex != null) {
|
||||||
for (int i = 0; i < storedIndex.getFileIndexCount(); i++) {
|
for (int i = 0; i < storedIndex.getFileIndexCount(); i++) {
|
||||||
FileIndex fi = storedIndex.getFileIndex(i);
|
FileIndex fi = storedIndex.getFileIndex(i);
|
||||||
if (f.length() == fi.getSize() && f.getName().equals(fi.getFileName())) {
|
if (f.length() == fi.getSize() && f.getName().equals(fi.getFileName())) {
|
||||||
|
@ -193,26 +191,26 @@ public class CachedOsmandIndexes {
|
||||||
reader = new BinaryMapIndexReader(mf, f);
|
reader = new BinaryMapIndexReader(mf, f);
|
||||||
addToCache(reader, f);
|
addToCache(reader, f);
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Initializing db " + f.getAbsolutePath() + " " + (System.currentTimeMillis() - val) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
log.debug("Initializing db " + f.getAbsolutePath() + " " + (System.currentTimeMillis() - val ) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
reader = initFileIndex(found, mf, f);
|
reader = initFileIndex(found, mf, f);
|
||||||
}
|
}
|
||||||
return reader;
|
return reader;
|
||||||
}
|
}
|
||||||
|
|
||||||
private BinaryMapIndexReader initFileIndex(FileIndex found, RandomAccessFile mf, File f) throws IOException {
|
private BinaryMapIndexReader initFileIndex(FileIndex found, RandomAccessFile mf, File f) throws IOException {
|
||||||
BinaryMapIndexReader reader = new BinaryMapIndexReader(mf, f, false);
|
BinaryMapIndexReader reader = new BinaryMapIndexReader(mf, f, false);
|
||||||
reader.version = found.getVersion();
|
reader.version = found.getVersion();
|
||||||
reader.dateCreated = found.getDateModified();
|
reader.dateCreated = found.getDateModified();
|
||||||
|
|
||||||
for (MapPart index : found.getMapIndexList()) {
|
for(MapPart index : found.getMapIndexList()) {
|
||||||
MapIndex mi = new MapIndex();
|
MapIndex mi = new MapIndex();
|
||||||
mi.length = (int) index.getSize();
|
mi.length = (int) index.getSize();
|
||||||
mi.filePointer = (int) index.getOffset();
|
mi.filePointer = (int) index.getOffset();
|
||||||
mi.name = index.getName();
|
mi.name = index.getName();
|
||||||
|
|
||||||
for (MapLevel mr : index.getLevelsList()) {
|
for(MapLevel mr : index.getLevelsList()) {
|
||||||
MapRoot root = new MapRoot();
|
MapRoot root = new MapRoot();
|
||||||
root.length = (int) mr.getSize();
|
root.length = (int) mr.getSize();
|
||||||
root.filePointer = (int) mr.getOffset();
|
root.filePointer = (int) mr.getOffset();
|
||||||
|
@ -228,27 +226,29 @@ public class CachedOsmandIndexes {
|
||||||
reader.indexes.add(mi);
|
reader.indexes.add(mi);
|
||||||
reader.basemap = reader.basemap || mi.isBaseMap();
|
reader.basemap = reader.basemap || mi.isBaseMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (AddressPart index : found.getAddressIndexList()) {
|
for(AddressPart index : found.getAddressIndexList()) {
|
||||||
AddressRegion mi = new AddressRegion();
|
AddressRegion mi = new AddressRegion();
|
||||||
mi.length = (int) index.getSize();
|
mi.length = (int) index.getSize();
|
||||||
mi.filePointer = (int) index.getOffset();
|
mi.filePointer = (int) index.getOffset();
|
||||||
mi.name = index.getName();
|
mi.name = index.getName();
|
||||||
mi.enName = index.getNameEn();
|
mi.enName = index.getNameEn();
|
||||||
mi.indexNameOffset = index.getIndexNameOffset();
|
mi.indexNameOffset = index.getIndexNameOffset();
|
||||||
for (CityBlock mr : index.getCitiesList()) {
|
for(CityBlock mr : index.getCitiesList() ) {
|
||||||
CitiesBlock cblock = new CitiesBlock();
|
CitiesBlock cblock = new CitiesBlock();
|
||||||
cblock.length = (int) mr.getSize();
|
cblock.length = (int) mr.getSize();
|
||||||
cblock.filePointer = (int) mr.getOffset();
|
cblock.filePointer = (int) mr.getOffset();
|
||||||
cblock.type = mr.getType();
|
cblock.type = mr.getType();
|
||||||
mi.cities.add(cblock);
|
mi.cities.add(cblock);
|
||||||
}
|
}
|
||||||
mi.attributeTagsTable.addAll(index.getAdditionalTagsList());
|
for(String s : index.getAdditionalTagsList()) {
|
||||||
|
mi.attributeTagsTable.add(s);
|
||||||
|
}
|
||||||
reader.addressIndexes.add(mi);
|
reader.addressIndexes.add(mi);
|
||||||
reader.indexes.add(mi);
|
reader.indexes.add(mi);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (PoiPart index : found.getPoiIndexList()) {
|
for(PoiPart index : found.getPoiIndexList()) {
|
||||||
PoiRegion mi = new PoiRegion();
|
PoiRegion mi = new PoiRegion();
|
||||||
mi.length = (int) index.getSize();
|
mi.length = (int) index.getSize();
|
||||||
mi.filePointer = (int) index.getOffset();
|
mi.filePointer = (int) index.getOffset();
|
||||||
|
@ -260,14 +260,14 @@ public class CachedOsmandIndexes {
|
||||||
reader.poiIndexes.add(mi);
|
reader.poiIndexes.add(mi);
|
||||||
reader.indexes.add(mi);
|
reader.indexes.add(mi);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (TransportPart index : found.getTransportIndexList()) {
|
for(TransportPart index : found.getTransportIndexList()) {
|
||||||
TransportIndex mi = new TransportIndex();
|
TransportIndex mi = new TransportIndex();
|
||||||
mi.length = (int) index.getSize();
|
mi.length = (int) index.getSize();
|
||||||
mi.filePointer = (int) index.getOffset();
|
mi.filePointer = (int) index.getOffset();
|
||||||
mi.name = index.getName();
|
mi.name = index.getName();
|
||||||
mi.left = index.getLeft();
|
mi.left = index.getLeft();
|
||||||
mi.right = index.getRight();
|
mi.right =index.getRight();
|
||||||
mi.top = index.getTop();
|
mi.top = index.getTop();
|
||||||
mi.bottom = index.getBottom();
|
mi.bottom = index.getBottom();
|
||||||
mi.stopsFileLength = index.getStopsTableLength();
|
mi.stopsFileLength = index.getStopsTableLength();
|
||||||
|
@ -280,14 +280,14 @@ public class CachedOsmandIndexes {
|
||||||
reader.transportIndexes.add(mi);
|
reader.transportIndexes.add(mi);
|
||||||
reader.indexes.add(mi);
|
reader.indexes.add(mi);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (RoutingPart index : found.getRoutingIndexList()) {
|
for(RoutingPart index : found.getRoutingIndexList()) {
|
||||||
RouteRegion mi = new RouteRegion();
|
RouteRegion mi = new RouteRegion();
|
||||||
mi.length = (int) index.getSize();
|
mi.length = (int) index.getSize();
|
||||||
mi.filePointer = (int) index.getOffset();
|
mi.filePointer = (int) index.getOffset();
|
||||||
mi.name = index.getName();
|
mi.name = index.getName();
|
||||||
|
|
||||||
for (RoutingSubregion mr : index.getSubregionsList()) {
|
for(RoutingSubregion mr : index.getSubregionsList()) {
|
||||||
RouteSubregion sub = new RouteSubregion(mi);
|
RouteSubregion sub = new RouteSubregion(mi);
|
||||||
sub.length = (int) mr.getSize();
|
sub.length = (int) mr.getSize();
|
||||||
sub.filePointer = (int) mr.getOffset();
|
sub.filePointer = (int) mr.getOffset();
|
||||||
|
@ -296,7 +296,7 @@ public class CachedOsmandIndexes {
|
||||||
sub.top = mr.getTop();
|
sub.top = mr.getTop();
|
||||||
sub.bottom = mr.getBottom();
|
sub.bottom = mr.getBottom();
|
||||||
sub.shiftToData = mr.getShifToData();
|
sub.shiftToData = mr.getShifToData();
|
||||||
if (mr.getBasemap()) {
|
if(mr.getBasemap()) {
|
||||||
mi.basesubregions.add(sub);
|
mi.basesubregions.add(sub);
|
||||||
} else {
|
} else {
|
||||||
mi.subregions.add(sub);
|
mi.subregions.add(sub);
|
||||||
|
@ -305,7 +305,7 @@ public class CachedOsmandIndexes {
|
||||||
reader.routingIndexes.add(mi);
|
reader.routingIndexes.add(mi);
|
||||||
reader.indexes.add(mi);
|
reader.indexes.add(mi);
|
||||||
}
|
}
|
||||||
|
|
||||||
return reader;
|
return reader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -315,7 +315,7 @@ public class CachedOsmandIndexes {
|
||||||
try {
|
try {
|
||||||
storedIndex = OsmandIndex.OsmAndStoredIndex.newBuilder().mergeFrom(is).build();
|
storedIndex = OsmandIndex.OsmAndStoredIndex.newBuilder().mergeFrom(is).build();
|
||||||
hasChanged = false;
|
hasChanged = false;
|
||||||
if (storedIndex.getVersion() != version) {
|
if(storedIndex.getVersion() != version){
|
||||||
storedIndex = null;
|
storedIndex = null;
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -323,7 +323,7 @@ public class CachedOsmandIndexes {
|
||||||
}
|
}
|
||||||
log.info("Initialize cache " + (System.currentTimeMillis() - time));
|
log.info("Initialize cache " + (System.currentTimeMillis() - time));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeToFile(File f) throws IOException {
|
public void writeToFile(File f) throws IOException {
|
||||||
if (hasChanged) {
|
if (hasChanged) {
|
||||||
FileOutputStream outputStream = new FileOutputStream(f);
|
FileOutputStream outputStream = new FileOutputStream(f);
|
||||||
|
|
|
@ -764,7 +764,6 @@ public class CommonWords {
|
||||||
addFrequentlyUsed("martiri");
|
addFrequentlyUsed("martiri");
|
||||||
addFrequentlyUsed("verdi");
|
addFrequentlyUsed("verdi");
|
||||||
addFrequentlyUsed("augusta");
|
addFrequentlyUsed("augusta");
|
||||||
addFrequentlyUsed("neuburger");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -282,12 +282,10 @@ public class GeocodingUtilities {
|
||||||
} else {
|
} else {
|
||||||
Collections.sort(streetsList, DISTANCE_COMPARATOR);
|
Collections.sort(streetsList, DISTANCE_COMPARATOR);
|
||||||
double streetDistance = 0;
|
double streetDistance = 0;
|
||||||
boolean isBuildingFound = knownMinBuildingDistance > 0;
|
|
||||||
for (GeocodingResult street : streetsList) {
|
for (GeocodingResult street : streetsList) {
|
||||||
if (streetDistance == 0) {
|
if (streetDistance == 0) {
|
||||||
streetDistance = street.getDistance();
|
streetDistance = street.getDistance();
|
||||||
} else if (streetDistance > 0 && street.getDistance() > streetDistance + DISTANCE_STREET_FROM_CLOSEST_WITH_SAME_NAME &&
|
} else if (street.getDistance() > streetDistance + DISTANCE_STREET_FROM_CLOSEST_WITH_SAME_NAME) {
|
||||||
isBuildingFound) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
street.connectionPoint = road.connectionPoint;
|
street.connectionPoint = road.connectionPoint;
|
||||||
|
@ -298,7 +296,6 @@ public class GeocodingUtilities {
|
||||||
if (knownMinBuildingDistance == 0) {
|
if (knownMinBuildingDistance == 0) {
|
||||||
GeocodingResult firstBld = it.next();
|
GeocodingResult firstBld = it.next();
|
||||||
knownMinBuildingDistance = firstBld.getDistance();
|
knownMinBuildingDistance = firstBld.getDistance();
|
||||||
isBuildingFound = true;
|
|
||||||
res.add(firstBld);
|
res.add(firstBld);
|
||||||
}
|
}
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
|
|
|
@ -54371,24 +54371,6 @@ public final class OsmandOdb {
|
||||||
*/
|
*/
|
||||||
com.google.protobuf.ByteString
|
com.google.protobuf.ByteString
|
||||||
getTextValuesBytes(int index);
|
getTextValuesBytes(int index);
|
||||||
|
|
||||||
// optional int32 precisionXY = 16;
|
|
||||||
/**
|
|
||||||
* <code>optional int32 precisionXY = 16;</code>
|
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
* precision in 1-xy-xy-xy binary format
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
boolean hasPrecisionXY();
|
|
||||||
/**
|
|
||||||
* <code>optional int32 precisionXY = 16;</code>
|
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
* precision in 1-xy-xy-xy binary format
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
int getPrecisionXY();
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Protobuf type {@code OsmAnd.OBF.OsmAndPoiBoxDataAtom}
|
* Protobuf type {@code OsmAnd.OBF.OsmAndPoiBoxDataAtom}
|
||||||
|
@ -54557,11 +54539,6 @@ public final class OsmandOdb {
|
||||||
textValues_.add(input.readBytes());
|
textValues_.add(input.readBytes());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 128: {
|
|
||||||
bitField0_ |= 0x00000200;
|
|
||||||
precisionXY_ = input.readInt32();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
|
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
|
||||||
|
@ -55071,30 +55048,6 @@ public final class OsmandOdb {
|
||||||
return textValues_.getByteString(index);
|
return textValues_.getByteString(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
// optional int32 precisionXY = 16;
|
|
||||||
public static final int PRECISIONXY_FIELD_NUMBER = 16;
|
|
||||||
private int precisionXY_;
|
|
||||||
/**
|
|
||||||
* <code>optional int32 precisionXY = 16;</code>
|
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
* precision in 1-xy-xy-xy binary format
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
public boolean hasPrecisionXY() {
|
|
||||||
return ((bitField0_ & 0x00000200) == 0x00000200);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* <code>optional int32 precisionXY = 16;</code>
|
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
* precision in 1-xy-xy-xy binary format
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
public int getPrecisionXY() {
|
|
||||||
return precisionXY_;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initFields() {
|
private void initFields() {
|
||||||
dx_ = 0;
|
dx_ = 0;
|
||||||
dy_ = 0;
|
dy_ = 0;
|
||||||
|
@ -55109,7 +55062,6 @@ public final class OsmandOdb {
|
||||||
note_ = "";
|
note_ = "";
|
||||||
textCategories_ = java.util.Collections.emptyList();
|
textCategories_ = java.util.Collections.emptyList();
|
||||||
textValues_ = com.google.protobuf.LazyStringArrayList.EMPTY;
|
textValues_ = com.google.protobuf.LazyStringArrayList.EMPTY;
|
||||||
precisionXY_ = 0;
|
|
||||||
}
|
}
|
||||||
private byte memoizedIsInitialized = -1;
|
private byte memoizedIsInitialized = -1;
|
||||||
public final boolean isInitialized() {
|
public final boolean isInitialized() {
|
||||||
|
@ -55170,9 +55122,6 @@ public final class OsmandOdb {
|
||||||
for (int i = 0; i < textValues_.size(); i++) {
|
for (int i = 0; i < textValues_.size(); i++) {
|
||||||
output.writeBytes(15, textValues_.getByteString(i));
|
output.writeBytes(15, textValues_.getByteString(i));
|
||||||
}
|
}
|
||||||
if (((bitField0_ & 0x00000200) == 0x00000200)) {
|
|
||||||
output.writeInt32(16, precisionXY_);
|
|
||||||
}
|
|
||||||
getUnknownFields().writeTo(output);
|
getUnknownFields().writeTo(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55254,10 +55203,6 @@ public final class OsmandOdb {
|
||||||
size += dataSize;
|
size += dataSize;
|
||||||
size += 1 * getTextValuesList().size();
|
size += 1 * getTextValuesList().size();
|
||||||
}
|
}
|
||||||
if (((bitField0_ & 0x00000200) == 0x00000200)) {
|
|
||||||
size += com.google.protobuf.CodedOutputStream
|
|
||||||
.computeInt32Size(16, precisionXY_);
|
|
||||||
}
|
|
||||||
size += getUnknownFields().getSerializedSize();
|
size += getUnknownFields().getSerializedSize();
|
||||||
memoizedSerializedSize = size;
|
memoizedSerializedSize = size;
|
||||||
return size;
|
return size;
|
||||||
|
@ -55400,8 +55345,6 @@ public final class OsmandOdb {
|
||||||
bitField0_ = (bitField0_ & ~0x00000800);
|
bitField0_ = (bitField0_ & ~0x00000800);
|
||||||
textValues_ = com.google.protobuf.LazyStringArrayList.EMPTY;
|
textValues_ = com.google.protobuf.LazyStringArrayList.EMPTY;
|
||||||
bitField0_ = (bitField0_ & ~0x00001000);
|
bitField0_ = (bitField0_ & ~0x00001000);
|
||||||
precisionXY_ = 0;
|
|
||||||
bitField0_ = (bitField0_ & ~0x00002000);
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55487,10 +55430,6 @@ public final class OsmandOdb {
|
||||||
bitField0_ = (bitField0_ & ~0x00001000);
|
bitField0_ = (bitField0_ & ~0x00001000);
|
||||||
}
|
}
|
||||||
result.textValues_ = textValues_;
|
result.textValues_ = textValues_;
|
||||||
if (((from_bitField0_ & 0x00002000) == 0x00002000)) {
|
|
||||||
to_bitField0_ |= 0x00000200;
|
|
||||||
}
|
|
||||||
result.precisionXY_ = precisionXY_;
|
|
||||||
result.bitField0_ = to_bitField0_;
|
result.bitField0_ = to_bitField0_;
|
||||||
onBuilt();
|
onBuilt();
|
||||||
return result;
|
return result;
|
||||||
|
@ -55586,9 +55525,6 @@ public final class OsmandOdb {
|
||||||
}
|
}
|
||||||
onChanged();
|
onChanged();
|
||||||
}
|
}
|
||||||
if (other.hasPrecisionXY()) {
|
|
||||||
setPrecisionXY(other.getPrecisionXY());
|
|
||||||
}
|
|
||||||
this.mergeUnknownFields(other.getUnknownFields());
|
this.mergeUnknownFields(other.getUnknownFields());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -56570,55 +56506,6 @@ public final class OsmandOdb {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// optional int32 precisionXY = 16;
|
|
||||||
private int precisionXY_ ;
|
|
||||||
/**
|
|
||||||
* <code>optional int32 precisionXY = 16;</code>
|
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
* precision in 1-xy-xy-xy binary format
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
public boolean hasPrecisionXY() {
|
|
||||||
return ((bitField0_ & 0x00002000) == 0x00002000);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* <code>optional int32 precisionXY = 16;</code>
|
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
* precision in 1-xy-xy-xy binary format
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
public int getPrecisionXY() {
|
|
||||||
return precisionXY_;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* <code>optional int32 precisionXY = 16;</code>
|
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
* precision in 1-xy-xy-xy binary format
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
public Builder setPrecisionXY(int value) {
|
|
||||||
bitField0_ |= 0x00002000;
|
|
||||||
precisionXY_ = value;
|
|
||||||
onChanged();
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* <code>optional int32 precisionXY = 16;</code>
|
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
* precision in 1-xy-xy-xy binary format
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
public Builder clearPrecisionXY() {
|
|
||||||
bitField0_ = (bitField0_ & ~0x00002000);
|
|
||||||
precisionXY_ = 0;
|
|
||||||
onChanged();
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
// @@protoc_insertion_point(builder_scope:OsmAnd.OBF.OsmAndPoiBoxDataAtom)
|
// @@protoc_insertion_point(builder_scope:OsmAnd.OBF.OsmAndPoiBoxDataAtom)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65121,38 +65008,37 @@ public final class OsmandOdb {
|
||||||
"tegories\030\003 \003(\r\022\025\n\rsubcategories\030\005 \003(\r\"i\n" +
|
"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" +
|
"\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." +
|
"(\r\022\t\n\001y\030\003 \001(\r\0221\n\007poiData\030\005 \003(\0132 .OsmAnd." +
|
||||||
"OBF.OsmAndPoiBoxDataAtom\"\205\002\n\024OsmAndPoiBo",
|
"OBF.OsmAndPoiBoxDataAtom\"\360\001\n\024OsmAndPoiBo",
|
||||||
"xDataAtom\022\n\n\002dx\030\002 \002(\021\022\n\n\002dy\030\003 \002(\021\022\022\n\ncat" +
|
"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" +
|
"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" +
|
"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" +
|
"\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" +
|
"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\022\023\n\013precision" +
|
"s\030\016 \003(\r\022\022\n\ntextValues\030\017 \003(\t\"\032\n\007IdTable\022\017" +
|
||||||
"XY\030\020 \001(\005\"\032\n\007IdTable\022\017\n\007routeId\030\001 \003(\022\"F\n\017" +
|
"\n\007routeId\030\001 \003(\022\"F\n\017RestrictionData\022\014\n\004ty" +
|
||||||
"RestrictionData\022\014\n\004type\030\001 \002(\005\022\014\n\004from\030\002 " +
|
"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" +
|
||||||
"\002(\005\022\n\n\002to\030\003 \002(\005\022\013\n\003via\030\004 \001(\005\"x\n\tRouteDat" +
|
"a\030\004 \001(\005\"x\n\tRouteData\022\016\n\006points\030\001 \002(\014\022\022\n\n" +
|
||||||
"a\022\016\n\006points\030\001 \002(\014\022\022\n\npointTypes\030\004 \001(\014\022\022\n",
|
"pointTypes\030\004 \001(\014\022\022\n\npointNames\030\005 \001(\014\022\r\n\005",
|
||||||
"\npointNames\030\005 \001(\014\022\r\n\005types\030\007 \002(\014\022\017\n\007rout" +
|
"types\030\007 \002(\014\022\017\n\007routeId\030\014 \002(\005\022\023\n\013stringNa" +
|
||||||
"eId\030\014 \002(\005\022\023\n\013stringNames\030\016 \001(\014\"\304\005\n\022OsmAn" +
|
"mes\030\016 \001(\014\"\304\005\n\022OsmAndRoutingIndex\022\014\n\004name" +
|
||||||
"dRoutingIndex\022\014\n\004name\030\001 \002(\t\022?\n\005rules\030\002 \003" +
|
"\030\001 \002(\t\022?\n\005rules\030\002 \003(\01320.OsmAnd.OBF.OsmAn" +
|
||||||
"(\01320.OsmAnd.OBF.OsmAndRoutingIndex.Route" +
|
"dRoutingIndex.RouteEncodingRule\022>\n\trootB" +
|
||||||
"EncodingRule\022>\n\trootBoxes\030\003 \003(\0132+.OsmAnd" +
|
"oxes\030\003 \003(\0132+.OsmAnd.OBF.OsmAndRoutingInd" +
|
||||||
".OBF.OsmAndRoutingIndex.RouteDataBox\022A\n\014" +
|
"ex.RouteDataBox\022A\n\014basemapBoxes\030\004 \003(\0132+." +
|
||||||
"basemapBoxes\030\004 \003(\0132+.OsmAnd.OBF.OsmAndRo" +
|
"OsmAnd.OBF.OsmAndRoutingIndex.RouteDataB" +
|
||||||
"utingIndex.RouteDataBox\022=\n\006blocks\030\005 \003(\0132" +
|
"ox\022=\n\006blocks\030\005 \003(\0132-.OsmAnd.OBF.OsmAndRo" +
|
||||||
"-.OsmAnd.OBF.OsmAndRoutingIndex.RouteDat" +
|
"utingIndex.RouteDataBlock\032;\n\021RouteEncodi" +
|
||||||
"aBlock\032;\n\021RouteEncodingRule\022\013\n\003tag\030\003 \002(\t",
|
"ngRule\022\013\n\003tag\030\003 \002(\t\022\r\n\005value\030\005 \002(\t\022\n\n\002id",
|
||||||
"\022\r\n\005value\030\005 \002(\t\022\n\n\002id\030\007 \001(\r\032\231\001\n\014RouteDat" +
|
"\030\007 \001(\r\032\231\001\n\014RouteDataBox\022\014\n\004left\030\001 \002(\021\022\r\n" +
|
||||||
"aBox\022\014\n\004left\030\001 \002(\021\022\r\n\005right\030\002 \002(\021\022\013\n\003top" +
|
"\005right\030\002 \002(\021\022\013\n\003top\030\003 \002(\021\022\016\n\006bottom\030\004 \002(" +
|
||||||
"\030\003 \002(\021\022\016\n\006bottom\030\004 \002(\021\022\023\n\013shiftToData\030\005 " +
|
"\021\022\023\n\013shiftToData\030\005 \001(\007\022:\n\005boxes\030\007 \003(\0132+." +
|
||||||
"\001(\007\022:\n\005boxes\030\007 \003(\0132+.OsmAnd.OBF.OsmAndRo" +
|
"OsmAnd.OBF.OsmAndRoutingIndex.RouteDataB" +
|
||||||
"utingIndex.RouteDataBox\032\303\001\n\016RouteDataBlo" +
|
"ox\032\303\001\n\016RouteDataBlock\022$\n\007idTable\030\005 \001(\0132\023" +
|
||||||
"ck\022$\n\007idTable\030\005 \001(\0132\023.OsmAnd.OBF.IdTable" +
|
".OsmAnd.OBF.IdTable\022*\n\013dataObjects\030\006 \003(\013" +
|
||||||
"\022*\n\013dataObjects\030\006 \003(\0132\025.OsmAnd.OBF.Route" +
|
"2\025.OsmAnd.OBF.RouteData\0221\n\014restrictions\030" +
|
||||||
"Data\0221\n\014restrictions\030\007 \003(\0132\033.OsmAnd.OBF." +
|
"\007 \003(\0132\033.OsmAnd.OBF.RestrictionData\022,\n\013st" +
|
||||||
"RestrictionData\022,\n\013stringTable\030\010 \001(\0132\027.O" +
|
"ringTable\030\010 \001(\0132\027.OsmAnd.OBF.StringTable" +
|
||||||
"smAnd.OBF.StringTableB\036\n\021net.osmand.bina",
|
"B\036\n\021net.osmand.binaryB\tOsmandOdb"
|
||||||
"ryB\tOsmandOdb"
|
|
||||||
};
|
};
|
||||||
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
|
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
|
||||||
new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
|
new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
|
||||||
|
@ -65410,7 +65296,7 @@ public final class OsmandOdb {
|
||||||
internal_static_OsmAnd_OBF_OsmAndPoiBoxDataAtom_fieldAccessorTable = new
|
internal_static_OsmAnd_OBF_OsmAndPoiBoxDataAtom_fieldAccessorTable = new
|
||||||
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
|
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
|
||||||
internal_static_OsmAnd_OBF_OsmAndPoiBoxDataAtom_descriptor,
|
internal_static_OsmAnd_OBF_OsmAndPoiBoxDataAtom_descriptor,
|
||||||
new java.lang.String[] { "Dx", "Dy", "Categories", "Subcategories", "Name", "NameEn", "Id", "OpeningHours", "Site", "Phone", "Note", "TextCategories", "TextValues", "PrecisionXY", });
|
new java.lang.String[] { "Dx", "Dy", "Categories", "Subcategories", "Name", "NameEn", "Id", "OpeningHours", "Site", "Phone", "Note", "TextCategories", "TextValues", });
|
||||||
internal_static_OsmAnd_OBF_IdTable_descriptor =
|
internal_static_OsmAnd_OBF_IdTable_descriptor =
|
||||||
getDescriptor().getMessageTypes().get(36);
|
getDescriptor().getMessageTypes().get(36);
|
||||||
internal_static_OsmAnd_OBF_IdTable_fieldAccessorTable = new
|
internal_static_OsmAnd_OBF_IdTable_fieldAccessorTable = new
|
||||||
|
|
|
@ -4,7 +4,6 @@ import net.osmand.Location;
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteRegion;
|
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteRegion;
|
||||||
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteTypeRule;
|
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteTypeRule;
|
||||||
import net.osmand.data.LatLon;
|
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
import net.osmand.util.MapUtils;
|
import net.osmand.util.MapUtils;
|
||||||
import net.osmand.util.TransliterationHelper;
|
import net.osmand.util.TransliterationHelper;
|
||||||
|
@ -38,9 +37,7 @@ public class RouteDataObject {
|
||||||
public int[] nameIds;
|
public int[] nameIds;
|
||||||
// mixed array [0, height, cumulative_distance height, cumulative_distance, height, ...] - length is length(points)*2
|
// mixed array [0, height, cumulative_distance height, cumulative_distance, height, ...] - length is length(points)*2
|
||||||
public float[] heightDistanceArray = null;
|
public float[] heightDistanceArray = null;
|
||||||
public float heightByCurrentLocation = Float.NaN;
|
|
||||||
private static final Log LOG = PlatformUtil.getLog(RouteDataObject.class);
|
private static final Log LOG = PlatformUtil.getLog(RouteDataObject.class);
|
||||||
|
|
||||||
public RouteDataObject(RouteRegion region) {
|
public RouteDataObject(RouteRegion region) {
|
||||||
this.region = region;
|
this.region = region;
|
||||||
}
|
}
|
||||||
|
@ -127,7 +124,7 @@ public class RouteDataObject {
|
||||||
equals = this.pointTypes[i] == thatObj.pointTypes[i];
|
equals = this.pointTypes[i] == thatObj.pointTypes[i];
|
||||||
} else if (pointTypes[i].length != thatObj.pointTypes[i].length) {
|
} else if (pointTypes[i].length != thatObj.pointTypes[i].length) {
|
||||||
equals = false;
|
equals = false;
|
||||||
} else {
|
} else {
|
||||||
for (int j = 0; j < this.pointTypes[i].length && equals; j++) {
|
for (int j = 0; j < this.pointTypes[i].length && equals; j++) {
|
||||||
String thisTag = region.routeEncodingRules.get(pointTypes[i][j]).getTag();
|
String thisTag = region.routeEncodingRules.get(pointTypes[i][j]).getTag();
|
||||||
String thisValue = region.routeEncodingRules.get(pointTypes[i][j]).getValue();
|
String thisValue = region.routeEncodingRules.get(pointTypes[i][j]).getValue();
|
||||||
|
@ -150,7 +147,7 @@ public class RouteDataObject {
|
||||||
equals = this.pointNameTypes[i] == thatObj.pointNameTypes[i];
|
equals = this.pointNameTypes[i] == thatObj.pointNameTypes[i];
|
||||||
} else if (pointNameTypes[i].length != thatObj.pointNameTypes[i].length) {
|
} else if (pointNameTypes[i].length != thatObj.pointNameTypes[i].length) {
|
||||||
equals = false;
|
equals = false;
|
||||||
} else {
|
} else {
|
||||||
for (int j = 0; j < this.pointNameTypes[i].length && equals; j++) {
|
for (int j = 0; j < this.pointNameTypes[i].length && equals; j++) {
|
||||||
String thisTag = region.routeEncodingRules.get(pointNameTypes[i][j]).getTag();
|
String thisTag = region.routeEncodingRules.get(pointNameTypes[i][j]).getTag();
|
||||||
String thisValue = pointNames[i][j];
|
String thisValue = pointNames[i][j];
|
||||||
|
@ -168,68 +165,53 @@ public class RouteDataObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
public float[] calculateHeightArray() {
|
public float[] calculateHeightArray() {
|
||||||
return calculateHeightArray(null);
|
if(heightDistanceArray != null) {
|
||||||
}
|
|
||||||
|
|
||||||
public float[] calculateHeightArray(LatLon currentLocation) {
|
|
||||||
if (heightDistanceArray != null) {
|
|
||||||
return heightDistanceArray;
|
return heightDistanceArray;
|
||||||
}
|
}
|
||||||
int startHeight = Algorithms.parseIntSilently(getValue("osmand_ele_start"), HEIGHT_UNDEFINED);
|
int startHeight = Algorithms.parseIntSilently(getValue("osmand_ele_start"), HEIGHT_UNDEFINED);
|
||||||
int endHeight = Algorithms.parseIntSilently(getValue("osmand_ele_end"), startHeight);
|
int endHeight = Algorithms.parseIntSilently(getValue("osmand_ele_end"), startHeight);
|
||||||
if (startHeight == HEIGHT_UNDEFINED) {
|
if(startHeight == HEIGHT_UNDEFINED) {
|
||||||
heightDistanceArray = new float[0];
|
heightDistanceArray = new float[0];
|
||||||
return heightDistanceArray;
|
return heightDistanceArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
heightDistanceArray = new float[2 * getPointsLength()];
|
heightDistanceArray = new float[2*getPointsLength()];
|
||||||
double plon = 0;
|
double plon = 0;
|
||||||
double plat = 0;
|
double plat = 0;
|
||||||
float prevHeight = startHeight;
|
float prevHeight = startHeight;
|
||||||
heightByCurrentLocation = Float.NaN;
|
for(int k = 0; k < getPointsLength(); k++) {
|
||||||
double prevDistance = 0;
|
|
||||||
for (int k = 0; k < getPointsLength(); k++) {
|
|
||||||
double lon = MapUtils.get31LongitudeX(getPoint31XTile(k));
|
double lon = MapUtils.get31LongitudeX(getPoint31XTile(k));
|
||||||
double lat = MapUtils.get31LatitudeY(getPoint31YTile(k));
|
double lat = MapUtils.get31LatitudeY(getPoint31YTile(k));
|
||||||
if (k > 0) {
|
if(k > 0) {
|
||||||
double dd = MapUtils.getDistance(plat, plon, lat, lon);
|
double dd = MapUtils.getDistance(plat, plon, lat, lon);
|
||||||
float height = HEIGHT_UNDEFINED;
|
float height = HEIGHT_UNDEFINED;
|
||||||
if (k == getPointsLength() - 1) {
|
if(k == getPointsLength() - 1) {
|
||||||
height = endHeight;
|
height = endHeight;
|
||||||
} else {
|
} else {
|
||||||
String asc = getValue(k, "osmand_ele_asc");
|
String asc = getValue(k, "osmand_ele_asc");
|
||||||
if (asc != null && asc.length() > 0) {
|
if(asc != null && asc.length() > 0) {
|
||||||
height = (prevHeight + Float.parseFloat(asc));
|
height = (prevHeight + Float.parseFloat(asc));
|
||||||
} else {
|
} else {
|
||||||
String desc = getValue(k, "osmand_ele_desc");
|
String desc = getValue(k, "osmand_ele_desc");
|
||||||
if (desc != null && desc.length() > 0) {
|
if(desc != null && desc.length() > 0) {
|
||||||
height = (prevHeight - Float.parseFloat(desc));
|
height = (prevHeight - Float.parseFloat(desc));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
heightDistanceArray[2 * k] = (float) dd;
|
heightDistanceArray[2*k] = (float) dd;
|
||||||
heightDistanceArray[2 * k + 1] = height;
|
heightDistanceArray[2*k+1] = height;
|
||||||
|
if(height != HEIGHT_UNDEFINED) {
|
||||||
if (currentLocation != null) {
|
|
||||||
double distance = MapUtils.getDistance(currentLocation, lat, lon);
|
|
||||||
if (height != HEIGHT_UNDEFINED && distance < prevDistance) {
|
|
||||||
prevDistance = distance;
|
|
||||||
heightByCurrentLocation = height;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (height != HEIGHT_UNDEFINED) {
|
|
||||||
// interpolate undefined
|
// interpolate undefined
|
||||||
double totalDistance = dd;
|
double totalDistance = dd;
|
||||||
int startUndefined = k;
|
int startUndefined = k;
|
||||||
while (startUndefined - 1 >= 0 && heightDistanceArray[2 * (startUndefined - 1) + 1] == HEIGHT_UNDEFINED) {
|
while(startUndefined - 1 >= 0 && heightDistanceArray[2*(startUndefined - 1)+1] == HEIGHT_UNDEFINED) {
|
||||||
startUndefined--;
|
startUndefined --;
|
||||||
totalDistance += heightDistanceArray[2 * (startUndefined)];
|
totalDistance += heightDistanceArray[2*(startUndefined)];
|
||||||
}
|
}
|
||||||
if (totalDistance > 0) {
|
if(totalDistance > 0) {
|
||||||
double angle = (height - prevHeight) / totalDistance;
|
double angle = (height - prevHeight) / totalDistance;
|
||||||
for (int j = startUndefined; j < k; j++) {
|
for(int j = startUndefined; j < k; j++) {
|
||||||
heightDistanceArray[2 * j + 1] = (float) ((heightDistanceArray[2 * j] * angle) + heightDistanceArray[2 * j - 1]);
|
heightDistanceArray[2*j+1] = (float) ((heightDistanceArray[2*j] * angle) + heightDistanceArray[2*j-1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
prevHeight = height;
|
prevHeight = height;
|
||||||
|
@ -241,9 +223,6 @@ public class RouteDataObject {
|
||||||
}
|
}
|
||||||
plat = lat;
|
plat = lat;
|
||||||
plon = lon;
|
plon = lon;
|
||||||
if (currentLocation != null) {
|
|
||||||
prevDistance = MapUtils.getDistance(currentLocation, plat, plon);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return heightDistanceArray;
|
return heightDistanceArray;
|
||||||
}
|
}
|
||||||
|
@ -252,34 +231,34 @@ public class RouteDataObject {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName(){
|
||||||
if (names != null) {
|
if(names != null ) {
|
||||||
return names.get(region.nameTypeRule);
|
return names.get(region.nameTypeRule);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getName(String lang) {
|
public String getName(String lang){
|
||||||
return getName(lang, false);
|
return getName(lang, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName(String lang, boolean transliterate) {
|
public String getName(String lang, boolean transliterate){
|
||||||
if (names != null) {
|
if(names != null ) {
|
||||||
if (Algorithms.isEmpty(lang)) {
|
if(Algorithms.isEmpty(lang)) {
|
||||||
return names.get(region.nameTypeRule);
|
return names.get(region.nameTypeRule);
|
||||||
}
|
}
|
||||||
int[] kt = names.keys();
|
int[] kt = names.keys();
|
||||||
for (int i = 0; i < kt.length; i++) {
|
for(int i = 0 ; i < kt.length; i++) {
|
||||||
int k = kt[i];
|
int k = kt[i];
|
||||||
if (region.routeEncodingRules.size() > k) {
|
if(region.routeEncodingRules.size() > k) {
|
||||||
if (("name:" + lang).equals(region.routeEncodingRules.get(k).getTag())) {
|
if(("name:"+lang).equals(region.routeEncodingRules.get(k).getTag())) {
|
||||||
return names.get(k);
|
return names.get(k);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String nmDef = names.get(region.nameTypeRule);
|
String nmDef = names.get(region.nameTypeRule);
|
||||||
if (transliterate && nmDef != null && nmDef.length() > 0) {
|
if(transliterate && nmDef != null && nmDef.length() > 0) {
|
||||||
return TransliterationHelper.transliterate(nmDef);
|
return TransliterationHelper.transliterate(nmDef);
|
||||||
}
|
}
|
||||||
return nmDef;
|
return nmDef;
|
||||||
|
@ -300,20 +279,20 @@ public class RouteDataObject {
|
||||||
// return getDestinationRef(direction);
|
// return getDestinationRef(direction);
|
||||||
//}
|
//}
|
||||||
if (names != null) {
|
if (names != null) {
|
||||||
if (Algorithms.isEmpty(lang)) {
|
if(Algorithms.isEmpty(lang)) {
|
||||||
return names.get(region.refTypeRule);
|
return names.get(region.refTypeRule);
|
||||||
}
|
}
|
||||||
int[] kt = names.keys();
|
int[] kt = names.keys();
|
||||||
for (int i = 0; i < kt.length; i++) {
|
for(int i = 0 ; i < kt.length; i++) {
|
||||||
int k = kt[i];
|
int k = kt[i];
|
||||||
if (region.routeEncodingRules.size() > k) {
|
if(region.routeEncodingRules.size() > k) {
|
||||||
if (("ref:" + lang).equals(region.routeEncodingRules.get(k).getTag())) {
|
if(("ref:"+lang).equals(region.routeEncodingRules.get(k).getTag())) {
|
||||||
return names.get(k);
|
return names.get(k);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String refDefault = names.get(region.refTypeRule);
|
String refDefault = names.get(region.refTypeRule);
|
||||||
if (transliterate && refDefault != null && refDefault.length() > 0) {
|
if(transliterate && refDefault != null && refDefault.length() > 0) {
|
||||||
return TransliterationHelper.transliterate(refDefault);
|
return TransliterationHelper.transliterate(refDefault);
|
||||||
}
|
}
|
||||||
return refDefault;
|
return refDefault;
|
||||||
|
@ -328,13 +307,13 @@ public class RouteDataObject {
|
||||||
String refTagDefault = "destination:ref";
|
String refTagDefault = "destination:ref";
|
||||||
String refDefault = null;
|
String refDefault = null;
|
||||||
|
|
||||||
for (int i = 0; i < kt.length; i++) {
|
for(int i = 0 ; i < kt.length; i++) {
|
||||||
int k = kt[i];
|
int k = kt[i];
|
||||||
if (region.routeEncodingRules.size() > k) {
|
if(region.routeEncodingRules.size() > k) {
|
||||||
if (refTag.equals(region.routeEncodingRules.get(k).getTag())) {
|
if(refTag.equals(region.routeEncodingRules.get(k).getTag())) {
|
||||||
return names.get(k);
|
return names.get(k);
|
||||||
}
|
}
|
||||||
if (refTagDefault.equals(region.routeEncodingRules.get(k).getTag())) {
|
if(refTagDefault.equals(region.routeEncodingRules.get(k).getTag())) {
|
||||||
refDefault = names.get(k);
|
refDefault = names.get(k);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -347,12 +326,12 @@ public class RouteDataObject {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDestinationName(String lang, boolean transliterate, boolean direction) {
|
public String getDestinationName(String lang, boolean transliterate, boolean direction){
|
||||||
//Issue #3289: Treat destination:ref like a destination, not like a ref
|
//Issue #3289: Treat destination:ref like a destination, not like a ref
|
||||||
String destRef = ((getDestinationRef(direction) == null) || getDestinationRef(direction).equals(getRef(lang, transliterate, direction))) ? "" : getDestinationRef(direction);
|
String destRef = ((getDestinationRef(direction) == null) || getDestinationRef(direction).equals(getRef(lang, transliterate, direction))) ? "" : getDestinationRef(direction);
|
||||||
String destRef1 = Algorithms.isEmpty(destRef) ? "" : destRef + ", ";
|
String destRef1 = ("".equals(destRef)) ? "" : destRef + ", ";
|
||||||
|
|
||||||
if (names != null) {
|
if(names != null) {
|
||||||
int[] kt = names.keys();
|
int[] kt = names.keys();
|
||||||
|
|
||||||
// Issue #3181: Parse destination keys in this order:
|
// Issue #3181: Parse destination keys in this order:
|
||||||
|
@ -362,39 +341,39 @@ public class RouteDataObject {
|
||||||
// destination
|
// destination
|
||||||
|
|
||||||
String destinationTagLangFB = "destination:lang:XX";
|
String destinationTagLangFB = "destination:lang:XX";
|
||||||
if (!Algorithms.isEmpty(lang)) {
|
if(!Algorithms.isEmpty(lang)) {
|
||||||
destinationTagLangFB = (direction == true) ? "destination:lang:" + lang + ":forward" : "destination:lang:" + lang + ":backward";
|
destinationTagLangFB = (direction == true) ? "destination:lang:" + lang + ":forward" : "destination:lang:" + lang + ":backward";
|
||||||
}
|
}
|
||||||
String destinationTagFB = (direction == true) ? "destination:forward" : "destination:backward";
|
String destinationTagFB = (direction == true) ? "destination:forward" : "destination:backward";
|
||||||
String destinationTagLang = "destination:lang:XX";
|
String destinationTagLang = "destination:lang:XX";
|
||||||
if (!Algorithms.isEmpty(lang)) {
|
if(!Algorithms.isEmpty(lang)) {
|
||||||
destinationTagLang = "destination:lang:" + lang;
|
destinationTagLang = "destination:lang:" + lang;
|
||||||
}
|
}
|
||||||
String destinationTagDefault = "destination";
|
String destinationTagDefault = "destination";
|
||||||
String destinationDefault = null;
|
String destinationDefault = null;
|
||||||
|
|
||||||
for (int i = 0; i < kt.length; i++) {
|
for(int i = 0 ; i < kt.length; i++) {
|
||||||
int k = kt[i];
|
int k = kt[i];
|
||||||
if (region.routeEncodingRules.size() > k) {
|
if(region.routeEncodingRules.size() > k) {
|
||||||
if (!Algorithms.isEmpty(lang) && destinationTagLangFB.equals(region.routeEncodingRules.get(k).getTag())) {
|
if(!Algorithms.isEmpty(lang) && destinationTagLangFB.equals(region.routeEncodingRules.get(k).getTag())) {
|
||||||
return destRef1 + ((transliterate) ? TransliterationHelper.transliterate(names.get(k)) : names.get(k));
|
return destRef1 + ((transliterate) ? TransliterationHelper.transliterate(names.get(k)) : names.get(k));
|
||||||
}
|
}
|
||||||
if (destinationTagFB.equals(region.routeEncodingRules.get(k).getTag())) {
|
if(destinationTagFB.equals(region.routeEncodingRules.get(k).getTag())) {
|
||||||
return destRef1 + ((transliterate) ? TransliterationHelper.transliterate(names.get(k)) : names.get(k));
|
return destRef1 + ((transliterate) ? TransliterationHelper.transliterate(names.get(k)) : names.get(k));
|
||||||
}
|
}
|
||||||
if (!Algorithms.isEmpty(lang) && destinationTagLang.equals(region.routeEncodingRules.get(k).getTag())) {
|
if(!Algorithms.isEmpty(lang) && destinationTagLang.equals(region.routeEncodingRules.get(k).getTag())) {
|
||||||
return destRef1 + ((transliterate) ? TransliterationHelper.transliterate(names.get(k)) : names.get(k));
|
return destRef1 + ((transliterate) ? TransliterationHelper.transliterate(names.get(k)) : names.get(k));
|
||||||
}
|
}
|
||||||
if (destinationTagDefault.equals(region.routeEncodingRules.get(k).getTag())) {
|
if(destinationTagDefault.equals(region.routeEncodingRules.get(k).getTag())) {
|
||||||
destinationDefault = names.get(k);
|
destinationDefault = names.get(k);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (destinationDefault != null) {
|
if(destinationDefault != null) {
|
||||||
return destRef1 + ((transliterate) ? TransliterationHelper.transliterate(destinationDefault) : destinationDefault);
|
return destRef1 + ((transliterate) ? TransliterationHelper.transliterate(destinationDefault) : destinationDefault);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Algorithms.isEmpty(destRef) ? null : destRef;
|
return "".equals(destRef) ? null : destRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPoint31XTile(int i) {
|
public int getPoint31XTile(int i) {
|
||||||
|
@ -421,14 +400,14 @@ public class RouteDataObject {
|
||||||
RestrictionInfo ri = new RestrictionInfo();
|
RestrictionInfo ri = new RestrictionInfo();
|
||||||
ri.toWay = getRestrictionId(k);
|
ri.toWay = getRestrictionId(k);
|
||||||
ri.type = getRestrictionType(k);
|
ri.type = getRestrictionType(k);
|
||||||
if (restrictionsVia != null && k < restrictionsVia.length) {
|
if(restrictionsVia != null && k < restrictionsVia.length) {
|
||||||
ri.viaWay = restrictionsVia[k];
|
ri.viaWay = restrictionsVia[k];
|
||||||
}
|
}
|
||||||
return ri;
|
return ri;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getRestrictionVia(int i) {
|
public long getRestrictionVia(int i) {
|
||||||
if (restrictionsVia != null && restrictionsVia.length > i) {
|
if(restrictionsVia != null && restrictionsVia.length > i) {
|
||||||
return restrictionsVia[i];
|
return restrictionsVia[i];
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -462,7 +441,7 @@ public class RouteDataObject {
|
||||||
}
|
}
|
||||||
if (insNames) {
|
if (insNames) {
|
||||||
pointNames = new String[opointNames.length + 1][];
|
pointNames = new String[opointNames.length + 1][];
|
||||||
pointNameTypes = new int[opointNameTypes.length + 1][];
|
pointNameTypes = new int[opointNameTypes.length +1][];
|
||||||
}
|
}
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (; i < pos; i++) {
|
for (; i < pos; i++) {
|
||||||
|
@ -520,24 +499,6 @@ public class RouteDataObject {
|
||||||
}
|
}
|
||||||
return pointTypes[ind];
|
return pointTypes[ind];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removePointType(int ind, int type) {
|
|
||||||
if (pointTypes != null || ind < pointTypes.length) {
|
|
||||||
int[] typesArr = pointTypes[ind];
|
|
||||||
|
|
||||||
for (int i = 0; i < typesArr.length; i++) {
|
|
||||||
if (typesArr[i] == type) {
|
|
||||||
int[] result = new int[typesArr.length - 1];
|
|
||||||
System.arraycopy(typesArr, 0, result, 0, i);
|
|
||||||
if (typesArr.length != i) {
|
|
||||||
System.arraycopy(typesArr, i + 1, result, i, typesArr.length - 1 - i);
|
|
||||||
pointTypes[ind] = result;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int[] getTypes() {
|
public int[] getTypes() {
|
||||||
return types;
|
return types;
|
||||||
|
@ -584,7 +545,7 @@ public class RouteDataObject {
|
||||||
String nonCondTag = rtr.getTag();
|
String nonCondTag = rtr.getTag();
|
||||||
int ks;
|
int ks;
|
||||||
for (ks = 0; ks < pointTypes[i].length; ks++) {
|
for (ks = 0; ks < pointTypes[i].length; ks++) {
|
||||||
RouteTypeRule toReplace = region.quickGetEncodingRule(pointTypes[i][ks]);
|
RouteTypeRule toReplace = region.quickGetEncodingRule(pointTypes[i][j]);
|
||||||
if (toReplace != null && toReplace.getTag().contentEquals(nonCondTag)) {
|
if (toReplace != null && toReplace.getTag().contentEquals(nonCondTag)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -629,7 +590,7 @@ public class RouteDataObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float parseSpeed(String v, float def) {
|
public static float parseSpeed(String v, float def) {
|
||||||
if (v.equals("none")) {
|
if(v.equals("none")) {
|
||||||
return RouteDataObject.NONE_MAX_SPEED;
|
return RouteDataObject.NONE_MAX_SPEED;
|
||||||
} else {
|
} else {
|
||||||
int i = Algorithms.findFirstNumberEndIndex(v);
|
int i = Algorithms.findFirstNumberEndIndex(v);
|
||||||
|
@ -653,20 +614,20 @@ public class RouteDataObject {
|
||||||
f += Float.parseFloat(v.substring(0, i));
|
f += Float.parseFloat(v.substring(0, i));
|
||||||
String pref = v.substring(i, v.length()).trim();
|
String pref = v.substring(i, v.length()).trim();
|
||||||
float add = 0;
|
float add = 0;
|
||||||
for (int ik = 0; ik < pref.length(); ik++) {
|
for(int ik = 0; ik < pref.length(); ik++) {
|
||||||
if (Algorithms.isDigit(pref.charAt(ik)) || pref.charAt(ik) == '.' || pref.charAt(ik) == '-') {
|
if(Algorithms.isDigit(pref.charAt(ik)) || pref.charAt(ik) == '.' || pref.charAt(ik) == '-') {
|
||||||
int first = Algorithms.findFirstNumberEndIndex(pref.substring(ik));
|
int first = Algorithms.findFirstNumberEndIndex(pref.substring(ik));
|
||||||
if (first != -1) {
|
if(first != -1) {
|
||||||
add = parseLength(pref.substring(ik), 0);
|
add = parseLength(pref.substring(ik), 0);
|
||||||
pref = pref.substring(0, ik);
|
pref = pref.substring(0, ik);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (pref.contains("km")) {
|
if(pref.contains("km")) {
|
||||||
f *= 1000;
|
f *= 1000;
|
||||||
}
|
}
|
||||||
if (pref.contains("\"") || pref.contains("in")) {
|
if(pref.contains("\"") || pref.contains("in")) {
|
||||||
f *= 0.0254;
|
f *= 0.0254;
|
||||||
} else if (pref.contains("\'") || pref.contains("ft") || pref.contains("feet")) {
|
} else if (pref.contains("\'") || pref.contains("ft") || pref.contains("feet")) {
|
||||||
// foot to meters
|
// foot to meters
|
||||||
|
@ -712,27 +673,27 @@ public class RouteDataObject {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean roundabout() {
|
public boolean roundabout(){
|
||||||
int sz = types.length;
|
int sz = types.length;
|
||||||
for (int i = 0; i < sz; i++) {
|
for(int i=0; i<sz; i++) {
|
||||||
RouteTypeRule r = region.quickGetEncodingRule(types[i]);
|
RouteTypeRule r = region.quickGetEncodingRule(types[i]);
|
||||||
if (r.roundabout()) {
|
if(r.roundabout()) {
|
||||||
return true;
|
return true;
|
||||||
} else if (r.onewayDirection() != 0 && loop()) {
|
} else if(r.onewayDirection() != 0 && loop()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean tunnel() {
|
public boolean tunnel(){
|
||||||
int sz = types.length;
|
int sz = types.length;
|
||||||
for (int i = 0; i < sz; i++) {
|
for(int i=0; i<sz; i++) {
|
||||||
RouteTypeRule r = region.quickGetEncodingRule(types[i]);
|
RouteTypeRule r = region.quickGetEncodingRule(types[i]);
|
||||||
if (r.getTag().equals("tunnel") && r.getValue().equals("yes")) {
|
if(r.getTag().equals("tunnel") && r.getValue().equals("yes")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (r.getTag().equals("layer") && r.getValue().equals("-1")) {
|
if(r.getTag().equals("layer") && r.getValue().equals("-1")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -921,7 +882,7 @@ public class RouteDataObject {
|
||||||
|
|
||||||
public boolean bearingVsRouteDirection(Location loc) {
|
public boolean bearingVsRouteDirection(Location loc) {
|
||||||
boolean direction = true;
|
boolean direction = true;
|
||||||
if (loc != null && loc.hasBearing()) {
|
if(loc != null && loc.hasBearing()) {
|
||||||
double diff = MapUtils.alignAngleDifference(directionRoute(0, true) - loc.getBearing() / 180f * Math.PI);
|
double diff = MapUtils.alignAngleDifference(directionRoute(0, true) - loc.getBearing() / 180f * Math.PI);
|
||||||
direction = Math.abs(diff) < Math.PI / 2f;
|
direction = Math.abs(diff) < Math.PI / 2f;
|
||||||
}
|
}
|
||||||
|
@ -971,13 +932,13 @@ public class RouteDataObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
public double distance(int startPoint, int endPoint) {
|
public double distance(int startPoint, int endPoint) {
|
||||||
if (startPoint > endPoint) {
|
if(startPoint > endPoint) {
|
||||||
int k = endPoint;
|
int k = endPoint;
|
||||||
endPoint = startPoint;
|
endPoint = startPoint;
|
||||||
startPoint = k;
|
startPoint = k;
|
||||||
}
|
}
|
||||||
double d = 0;
|
double d = 0;
|
||||||
for (int k = startPoint; k < endPoint && k < getPointsLength() - 1; k++) {
|
for(int k = startPoint; k < endPoint && k < getPointsLength() -1; k++) {
|
||||||
int x = getPoint31XTile(k);
|
int x = getPoint31XTile(k);
|
||||||
int y = getPoint31YTile(k);
|
int y = getPoint31YTile(k);
|
||||||
int kx = getPoint31XTile(k + 1);
|
int kx = getPoint31XTile(k + 1);
|
||||||
|
@ -1013,16 +974,16 @@ public class RouteDataObject {
|
||||||
// translate into meters
|
// translate into meters
|
||||||
total += simplifyDistance(x, y, px, py);
|
total += simplifyDistance(x, y, px, py);
|
||||||
} while (total < dist);
|
} while (total < dist);
|
||||||
return -Math.atan2(x - px, y - py);
|
return -Math.atan2( x - px, y - py );
|
||||||
}
|
}
|
||||||
|
|
||||||
private double simplifyDistance(int x, int y, int px, int py) {
|
private double simplifyDistance(int x, int y, int px, int py) {
|
||||||
return Math.abs(px - x) * 0.011d + Math.abs(py - y) * 0.01863d;
|
return Math.abs(px - x) * 0.011d + Math.abs(py - y) * 0.01863d;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void assertTrueLength(String vl, float exp) {
|
private static void assertTrueLength(String vl, float exp){
|
||||||
float dest = parseLength(vl, 0);
|
float dest = parseLength(vl, 0);
|
||||||
if (exp != dest) {
|
if(exp != dest) {
|
||||||
System.err.println("FAIL " + vl + " " + dest);
|
System.err.println("FAIL " + vl + " " + dest);
|
||||||
} else {
|
} else {
|
||||||
System.out.println("OK " + vl);
|
System.out.println("OK " + vl);
|
||||||
|
@ -1031,24 +992,24 @@ public class RouteDataObject {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
assertTrueLength("10 km", 10000);
|
assertTrueLength("10 km", 10000);
|
||||||
assertTrueLength("0.01 km", 10);
|
assertTrueLength("0.01 km", 10);
|
||||||
assertTrueLength("0.01 km 10 m", 20);
|
assertTrueLength("0.01 km 10 m", 20);
|
||||||
assertTrueLength("10 m", 10);
|
assertTrueLength("10 m", 10);
|
||||||
assertTrueLength("10m", 10);
|
assertTrueLength("10m", 10);
|
||||||
assertTrueLength("3.4 m", 3.4f);
|
assertTrueLength("3.4 m", 3.4f);
|
||||||
assertTrueLength("3.40 m", 3.4f);
|
assertTrueLength("3.40 m", 3.4f);
|
||||||
assertTrueLength("10 m 10m", 20);
|
assertTrueLength("10 m 10m", 20);
|
||||||
assertTrueLength("14'10\"", 4.5212f);
|
assertTrueLength("14'10\"", 4.5212f);
|
||||||
assertTrueLength("14.5'", 4.4196f);
|
assertTrueLength("14.5'", 4.4196f);
|
||||||
assertTrueLength("14.5 ft", 4.4196f);
|
assertTrueLength("14.5 ft", 4.4196f);
|
||||||
assertTrueLength("14'0\"", 4.2672f);
|
assertTrueLength("14'0\"", 4.2672f);
|
||||||
assertTrueLength("15ft", 4.572f);
|
assertTrueLength("15ft", 4.572f);
|
||||||
assertTrueLength("15 ft 1 in", 4.5974f);
|
assertTrueLength("15 ft 1 in", 4.5974f);
|
||||||
assertTrueLength("4.1 metres", 4.1f);
|
assertTrueLength("4.1 metres", 4.1f);
|
||||||
assertTrueLength("14'0''", 4.2672f);
|
assertTrueLength("14'0''", 4.2672f);
|
||||||
assertTrueLength("14 feet", 4.2672f);
|
assertTrueLength("14 feet", 4.2672f);
|
||||||
assertTrueLength("14 mile", 22530.76f);
|
assertTrueLength("14 mile", 22530.76f);
|
||||||
assertTrueLength("14 cm", 0.14f);
|
assertTrueLength("14 cm", 0.14f);
|
||||||
|
|
||||||
// float badValue = -1;
|
// float badValue = -1;
|
||||||
// assertTrueLength("none", badValue);
|
// assertTrueLength("none", badValue);
|
||||||
|
@ -1093,7 +1054,7 @@ public class RouteDataObject {
|
||||||
public RestrictionInfo next; // optional to simulate linked list
|
public RestrictionInfo next; // optional to simulate linked list
|
||||||
|
|
||||||
public int length() {
|
public int length() {
|
||||||
if (next == null) {
|
if(next == null) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return next.length() + 1;
|
return next.length() + 1;
|
||||||
|
@ -1103,16 +1064,16 @@ public class RouteDataObject {
|
||||||
public void setRestriction(int k, long to, int type, long viaWay) {
|
public void setRestriction(int k, long to, int type, long viaWay) {
|
||||||
long valto = (to << RouteDataObject.RESTRICTION_SHIFT) | ((long) type & RouteDataObject.RESTRICTION_MASK);
|
long valto = (to << RouteDataObject.RESTRICTION_SHIFT) | ((long) type & RouteDataObject.RESTRICTION_MASK);
|
||||||
restrictions[k] = valto;
|
restrictions[k] = valto;
|
||||||
if (viaWay != 0) {
|
if(viaWay != 0) {
|
||||||
setRestrictionVia(k, viaWay);
|
setRestrictionVia(k, viaWay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRestrictionVia(int k, long viaWay) {
|
public void setRestrictionVia(int k, long viaWay) {
|
||||||
if (restrictionsVia != null) {
|
if(restrictionsVia != null) {
|
||||||
long[] nrestrictionsVia = new long[Math.max(k + 1, restrictions.length)];
|
long[] nrestrictionsVia = new long[Math.max(k + 1, restrictions.length)];
|
||||||
System.arraycopy(restrictions, 0, nrestrictionsVia, 0, restrictions.length);
|
System.arraycopy(restrictions, 0, nrestrictionsVia, 0, restrictions.length);
|
||||||
restrictionsVia = nrestrictionsVia;
|
restrictionsVia = nrestrictionsVia;
|
||||||
} else {
|
} else {
|
||||||
restrictionsVia = new long[k + 1];
|
restrictionsVia = new long[k + 1];
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ public abstract class StringBundleWriter {
|
||||||
|
|
||||||
public void writeBundle() {
|
public void writeBundle() {
|
||||||
for (Entry<String, Item<?>> entry : bundle.getMap().entrySet()) {
|
for (Entry<String, Item<?>> entry : bundle.getMap().entrySet()) {
|
||||||
writeItem("osmand:" + entry.getKey(), entry.getValue());
|
writeItem(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,17 @@
|
||||||
package net.osmand.data;
|
package net.osmand.data;
|
||||||
|
|
||||||
|
import net.osmand.Location;
|
||||||
|
import net.osmand.osm.MapPoiTypes;
|
||||||
|
import net.osmand.osm.PoiCategory;
|
||||||
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
@ -11,14 +21,9 @@ import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
import java.util.zip.GZIPInputStream;
|
||||||
import org.json.JSONObject;
|
|
||||||
|
|
||||||
import gnu.trove.list.array.TIntArrayList;
|
import gnu.trove.list.array.TIntArrayList;
|
||||||
import net.osmand.Location;
|
|
||||||
import net.osmand.osm.MapPoiTypes;
|
|
||||||
import net.osmand.osm.PoiCategory;
|
|
||||||
import net.osmand.util.Algorithms;
|
|
||||||
|
|
||||||
|
|
||||||
public class Amenity extends MapObject {
|
public class Amenity extends MapObject {
|
||||||
|
@ -39,17 +44,6 @@ public class Amenity extends MapObject {
|
||||||
public static final String REF = "ref";
|
public static final String REF = "ref";
|
||||||
public static final String OSM_DELETE_VALUE = "delete";
|
public static final String OSM_DELETE_VALUE = "delete";
|
||||||
public static final String OSM_DELETE_TAG = "osmand_change";
|
public static final String OSM_DELETE_TAG = "osmand_change";
|
||||||
public static final String IMAGE_TITLE = "image_title";
|
|
||||||
public static final String IS_PART = "is_part";
|
|
||||||
public static final String IS_PARENT_OF = "is_parent_of";
|
|
||||||
public static final String IS_AGGR_PART = "is_aggr_part";
|
|
||||||
public static final String CONTENT_JSON = "content_json";
|
|
||||||
public static final String ROUTE_ID = "route_id";
|
|
||||||
public static final String ROUTE_SOURCE = "route_source";
|
|
||||||
public static final String COLOR = "color";
|
|
||||||
public static final String LANG_YES = "lang_yes";
|
|
||||||
public static final String GPX_ICON = "gpx_icon";
|
|
||||||
|
|
||||||
|
|
||||||
private String subType;
|
private String subType;
|
||||||
private PoiCategory type;
|
private PoiCategory type;
|
||||||
|
@ -102,46 +96,12 @@ public class Amenity extends MapObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// this method should be used carefully
|
public Map<String, String> getAdditionalInfo() {
|
||||||
public Map<String, String> getInternalAdditionalInfoMap() {
|
|
||||||
if (additionalInfo == null) {
|
if (additionalInfo == null) {
|
||||||
return Collections.emptyMap();
|
return Collections.emptyMap();
|
||||||
}
|
}
|
||||||
return additionalInfo;
|
return additionalInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<String> getAdditionalInfoValues(boolean excludeZipped) {
|
|
||||||
if (additionalInfo == null) {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
boolean zipped = false;
|
|
||||||
for(String v : additionalInfo.values()) {
|
|
||||||
if(isContentZipped(v)) {
|
|
||||||
zipped = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(zipped) {
|
|
||||||
List<String> r = new ArrayList<>(additionalInfo.size());
|
|
||||||
for(String str : additionalInfo.values()) {
|
|
||||||
if(excludeZipped && isContentZipped(str)) {
|
|
||||||
|
|
||||||
} else {
|
|
||||||
r.add(unzipContent(str));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return r;
|
|
||||||
} else {
|
|
||||||
return additionalInfo.values();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Collection<String> getAdditionalInfoKeys() {
|
|
||||||
if (additionalInfo == null) {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
return additionalInfo.keySet();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAdditionalInfo(Map<String, String> additionalInfo) {
|
public void setAdditionalInfo(Map<String, String> additionalInfo) {
|
||||||
this.additionalInfo = null;
|
this.additionalInfo = null;
|
||||||
|
@ -174,7 +134,7 @@ public class Amenity extends MapObject {
|
||||||
}
|
}
|
||||||
this.additionalInfo.put(tag, value);
|
this.additionalInfo.put(tag, value);
|
||||||
if (OPENING_HOURS.equals(tag)) {
|
if (OPENING_HOURS.equals(tag)) {
|
||||||
this.openingHours = unzipContent(value);
|
this.openingHours = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -205,15 +165,6 @@ public class Amenity extends MapObject {
|
||||||
setAdditionalInfo(PHONE, phone);
|
setAdditionalInfo(PHONE, phone);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getColor() {
|
|
||||||
return getAdditionalInfo(COLOR);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getGpxIcon() {
|
|
||||||
return getAdditionalInfo(GPX_ICON);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public String getContentLanguage(String tag, String lang, String defLang) {
|
public String getContentLanguage(String tag, String lang, String defLang) {
|
||||||
if (lang != null) {
|
if (lang != null) {
|
||||||
String translateName = getAdditionalInfo(tag + ":" + lang);
|
String translateName = getAdditionalInfo(tag + ":" + lang);
|
||||||
|
@ -231,7 +182,7 @@ public class Amenity extends MapObject {
|
||||||
}
|
}
|
||||||
int maxLen = 0;
|
int maxLen = 0;
|
||||||
String lng = defLang;
|
String lng = defLang;
|
||||||
for (String nm : getAdditionalInfoKeys()) {
|
for (String nm : getAdditionalInfo().keySet()) {
|
||||||
if (nm.startsWith(tag + ":")) {
|
if (nm.startsWith(tag + ":")) {
|
||||||
String key = nm.substring(tag.length() + 1);
|
String key = nm.substring(tag.length() + 1);
|
||||||
String cnt = getAdditionalInfo(tag + ":" + key);
|
String cnt = getAdditionalInfo(tag + ":" + key);
|
||||||
|
@ -253,7 +204,7 @@ public class Amenity extends MapObject {
|
||||||
|
|
||||||
public List<String> getNames(String tag, String defTag) {
|
public List<String> getNames(String tag, String defTag) {
|
||||||
List<String> l = new ArrayList<String>();
|
List<String> l = new ArrayList<String>();
|
||||||
for (String nm : getAdditionalInfoKeys()) {
|
for (String nm : getAdditionalInfo().keySet()) {
|
||||||
if (nm.startsWith(tag + ":")) {
|
if (nm.startsWith(tag + ":")) {
|
||||||
l.add(nm.substring(tag.length() + 1));
|
l.add(nm.substring(tag.length() + 1));
|
||||||
} else if (nm.equals(tag)) {
|
} else if (nm.equals(tag)) {
|
||||||
|
@ -263,35 +214,7 @@ public class Amenity extends MapObject {
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTagSuffix(String tagPrefix) {
|
|
||||||
for (String infoTag : getAdditionalInfoKeys()) {
|
|
||||||
if (infoTag.startsWith(tagPrefix)) {
|
|
||||||
if (infoTag.length() > tagPrefix.length()) {
|
|
||||||
return infoTag.substring(tagPrefix.length());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTagContent(String tag) {
|
|
||||||
return getTagContent(tag, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTagContent(String tag, String lang) {
|
public String getTagContent(String tag, String lang) {
|
||||||
String translateName = getStrictTagContent(tag, lang);
|
|
||||||
if (translateName != null) {
|
|
||||||
return translateName;
|
|
||||||
}
|
|
||||||
for (String nm : getAdditionalInfoKeys()) {
|
|
||||||
if (nm.startsWith(tag + ":")) {
|
|
||||||
return getAdditionalInfo(nm);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getStrictTagContent(String tag, String lang) {
|
|
||||||
if (lang != null) {
|
if (lang != null) {
|
||||||
String translateName = getAdditionalInfo(tag + ":" + lang);
|
String translateName = getAdditionalInfo(tag + ":" + lang);
|
||||||
if (!Algorithms.isEmpty(translateName)) {
|
if (!Algorithms.isEmpty(translateName)) {
|
||||||
|
@ -306,6 +229,11 @@ public class Amenity extends MapObject {
|
||||||
if (!Algorithms.isEmpty(enName)) {
|
if (!Algorithms.isEmpty(enName)) {
|
||||||
return enName;
|
return enName;
|
||||||
}
|
}
|
||||||
|
for (String nm : getAdditionalInfo().keySet()) {
|
||||||
|
if (nm.startsWith(tag + ":")) {
|
||||||
|
return getAdditionalInfo(nm);
|
||||||
|
}
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -417,4 +345,4 @@ public class Amenity extends MapObject {
|
||||||
}
|
}
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,42 +106,25 @@ public class Building extends MapObject {
|
||||||
|
|
||||||
|
|
||||||
public float interpolation(String hno) {
|
public float interpolation(String hno) {
|
||||||
if (getInterpolationType() != null || getInterpolationInterval() > 0
|
if(getInterpolationType() != null || getInterpolationInterval() > 0
|
||||||
// || checkNameAsInterpolation() // disable due to situation in NL #4284
|
//|| checkNameAsInterpolation() // disable due to situation in NL #4284
|
||||||
) {
|
) {
|
||||||
int num = Algorithms.extractFirstIntegerNumber(hno);
|
int num = Algorithms.extractFirstIntegerNumber(hno);
|
||||||
String fname = super.getName();
|
String fname = super.getName();
|
||||||
int numB = Algorithms.extractFirstIntegerNumber(fname);
|
int numB = Algorithms.extractFirstIntegerNumber(fname);
|
||||||
int numT = numB;
|
int numT = numB;
|
||||||
String sname = getName2();
|
|
||||||
if (getInterpolationType() == BuildingInterpolation.ALPHABETIC) {
|
|
||||||
if (num != numB) {
|
|
||||||
// currently not supported
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
int hint = (int) hno.charAt(hno.length() - 1);
|
|
||||||
int fch = (int) fname.charAt(fname.length() - 1);
|
|
||||||
int sch = sname.charAt(sname.length() - 1);
|
|
||||||
if (fch == sch) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
float res = ((float) hint - fch) / (((float) sch - fch));
|
|
||||||
if (res > 1 || res < 0) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
if (num >= numB) {
|
if (num >= numB) {
|
||||||
if (fname.contains("-") && sname == null) {
|
String sname = getName2();
|
||||||
|
if(fname.contains("-") && sname == null){
|
||||||
int l = fname.indexOf('-');
|
int l = fname.indexOf('-');
|
||||||
sname = fname.substring(l + 1, fname.length());
|
sname = fname.substring(l + 1, fname.length());
|
||||||
}
|
}
|
||||||
if (sname != null) {
|
if (sname != null) {
|
||||||
numT = Algorithms.extractFirstIntegerNumber(sname);
|
numT = Algorithms.extractFirstIntegerNumber(sname);
|
||||||
if (numT < num) {
|
if(numT < num) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (getInterpolationType() == BuildingInterpolation.EVEN && num % 2 == 1) {
|
if (getInterpolationType() == BuildingInterpolation.EVEN && num % 2 == 1) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -154,8 +137,8 @@ public class Building extends MapObject {
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (numT > numB) {
|
if(numT > numB){
|
||||||
return ((float) num - numB) / (((float) numT - numB));
|
return ((float)num - numB) / (((float)numT - numB));
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -182,10 +165,10 @@ public class Building extends MapObject {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
if (interpolationInterval != 0) {
|
if(interpolationInterval !=0){
|
||||||
return name + "-" + name2 + " (+" + interpolationInterval + ") ";
|
return name+"-"+name2 +" (+"+interpolationInterval+") ";
|
||||||
} else if (interpolationType != null) {
|
} else if(interpolationType != null) {
|
||||||
return name + "-" + name2 + " (" + interpolationType + ") ";
|
return name+"-"+name2 +" ("+interpolationType+") ";
|
||||||
}
|
}
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,10 +24,6 @@ public class City extends MapObject {
|
||||||
public double getRadius() {
|
public double getRadius() {
|
||||||
return radius;
|
return radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean storedAsSeparateAdminEntity() {
|
|
||||||
return this != DISTRICT && this != NEIGHBOURHOOD && this != BOROUGH;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String valueToString(CityType t) {
|
public static String valueToString(CityType t) {
|
||||||
return t.toString().toLowerCase();
|
return t.toString().toLowerCase();
|
||||||
|
|
|
@ -13,6 +13,7 @@ import java.io.ByteArrayInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -89,22 +90,23 @@ public abstract class MapObject implements Comparable<MapObject> {
|
||||||
names.putAll(name);
|
names.putAll(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, String> getNamesMap(boolean includeEn) {
|
public Map<String, String> getNamesMap(boolean includeEn) {
|
||||||
if ((!includeEn || Algorithms.isEmpty(enName)) && names == null) {
|
if (!includeEn || Algorithms.isEmpty(enName)) {
|
||||||
return Collections.emptyMap();
|
if (names == null) {
|
||||||
|
return Collections.emptyMap();
|
||||||
|
}
|
||||||
|
return names;
|
||||||
}
|
}
|
||||||
Map<String, String> mp = new HashMap<String, String>();
|
Map<String, String> mp = new HashMap<String, String>();
|
||||||
if (names != null) {
|
if (names != null) {
|
||||||
Iterator<Entry<String, String>> it = names.entrySet().iterator();
|
Iterator<Entry<String, String>> it = mp.entrySet().iterator();
|
||||||
while (it.hasNext()) {
|
while(it.hasNext()) {
|
||||||
Entry<String, String> e = it.next();
|
Entry<String, String> e = it.next();
|
||||||
mp.put(e.getKey(), unzipContent(e.getValue()));
|
mp.put(e.getKey(), unzipContent(e.getValue()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (includeEn && !Algorithms.isEmpty(enName)) {
|
mp.put("en", unzipContent(enName));
|
||||||
mp.put("en", unzipContent(enName));
|
|
||||||
}
|
|
||||||
return mp;
|
return mp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +116,7 @@ public abstract class MapObject implements Comparable<MapObject> {
|
||||||
l.add(unzipContent(enName));
|
l.add(unzipContent(enName));
|
||||||
}
|
}
|
||||||
if (names != null) {
|
if (names != null) {
|
||||||
for (String nm : names.values()) {
|
for(String nm : names.values()) {
|
||||||
l.add(unzipContent(nm));
|
l.add(unzipContent(nm));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -181,9 +183,8 @@ public abstract class MapObject implements Comparable<MapObject> {
|
||||||
public String getName(String lang, boolean transliterate) {
|
public String getName(String lang, boolean transliterate) {
|
||||||
if (lang != null && lang.length() > 0) {
|
if (lang != null && lang.length() > 0) {
|
||||||
if (lang.equals("en")) {
|
if (lang.equals("en")) {
|
||||||
// for some objects like wikipedia, english name is stored 'name' tag
|
// ignore transliterate option here for backward compatibility
|
||||||
String enName = getEnName(transliterate);
|
return getEnName(true);
|
||||||
return !Algorithms.isEmpty(enName) ? enName : getName();
|
|
||||||
} else {
|
} else {
|
||||||
// get name
|
// get name
|
||||||
if (names != null) {
|
if (names != null) {
|
||||||
|
@ -350,8 +351,8 @@ public abstract class MapObject implements Comparable<MapObject> {
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
String unzipContent(String str) {
|
public String unzipContent(String str) {
|
||||||
if (isContentZipped(str)) {
|
if (str != null && str.startsWith(" gz ")) {
|
||||||
try {
|
try {
|
||||||
int ind = 4;
|
int ind = 4;
|
||||||
byte[] bytes = new byte[str.length() - ind];
|
byte[] bytes = new byte[str.length() - ind];
|
||||||
|
@ -368,10 +369,6 @@ public abstract class MapObject implements Comparable<MapObject> {
|
||||||
}
|
}
|
||||||
br.close();
|
br.close();
|
||||||
str = bld.toString();
|
str = bld.toString();
|
||||||
// ugly fix of temporary problem of map generation
|
|
||||||
if(isContentZipped(str)) {
|
|
||||||
str = unzipContent(str);
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -379,10 +376,6 @@ public abstract class MapObject implements Comparable<MapObject> {
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isContentZipped(String str) {
|
|
||||||
return str != null && str.startsWith(" gz ");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static void parseJSON(JSONObject json, MapObject o) {
|
protected static void parseJSON(JSONObject json, MapObject o) {
|
||||||
if (json.has("name")) {
|
if (json.has("name")) {
|
||||||
o.name = json.getString("name");
|
o.name = json.getString("name");
|
||||||
|
|
|
@ -61,9 +61,9 @@ public class Multipolygon {
|
||||||
innerLinearRings.add(innerRing.toLinearRing());
|
innerLinearRings.add(innerRing.toLinearRing());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
polygons.add(geometryFactory.createPolygon(outerRing.toLinearRing(), innerLinearRings.toArray(new LinearRing[0])));
|
polygons.add(geometryFactory.createPolygon(outerRing.toLinearRing(), innerLinearRings.toArray(new LinearRing[innerLinearRings.size()])));
|
||||||
}
|
}
|
||||||
return geometryFactory.createMultiPolygon(polygons.toArray(new Polygon[0]));
|
return geometryFactory.createMultiPolygon(polygons.toArray(new Polygon[polygons.size()]));
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getId() {
|
public long getId() {
|
||||||
|
@ -163,7 +163,9 @@ public class Multipolygon {
|
||||||
* @return true if this multipolygon is correct and contains the point
|
* @return true if this multipolygon is correct and contains the point
|
||||||
*/
|
*/
|
||||||
public boolean containsPoint(LatLon point) {
|
public boolean containsPoint(LatLon point) {
|
||||||
|
|
||||||
return containsPoint(point.getLatitude(), point.getLongitude());
|
return containsPoint(point.getLatitude(), point.getLongitude());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int countOuterPolygons() {
|
public int countOuterPolygons() {
|
||||||
|
|
|
@ -6,7 +6,6 @@ public class QuadRect {
|
||||||
public double top;
|
public double top;
|
||||||
public double bottom;
|
public double bottom;
|
||||||
|
|
||||||
// left & right / top & bottom could be flipped (so it's useful for latlon bbox)
|
|
||||||
public QuadRect(double left, double top, double right, double bottom) {
|
public QuadRect(double left, double top, double right, double bottom) {
|
||||||
this.left = left;
|
this.left = left;
|
||||||
this.right = right;
|
this.right = right;
|
||||||
|
@ -22,18 +21,16 @@ public class QuadRect {
|
||||||
}
|
}
|
||||||
|
|
||||||
public double width() {
|
public double width() {
|
||||||
return Math.abs(right - left);
|
return right - left;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double height() {
|
public double height() {
|
||||||
return Math.abs(bottom - top);
|
return bottom - top;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean contains(double left, double top, double right, double bottom) {
|
public boolean contains(double left, double top, double right, double bottom) {
|
||||||
return Math.min(this.left, this.right) <= Math.min(left, right)
|
return this.left < this.right && this.top < this.bottom && this.left <= left && this.top <= top && this.right >= right
|
||||||
&& Math.max(this.left, this.right) >= Math.max(left, right)
|
&& this.bottom >= bottom;
|
||||||
&& Math.min(this.top, this.bottom) <= Math.min(top, bottom)
|
|
||||||
&& Math.max(this.top, this.bottom) >= Math.max(top, bottom);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean contains(QuadRect box) {
|
public boolean contains(QuadRect box) {
|
||||||
|
@ -41,15 +38,12 @@ public class QuadRect {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean intersects(QuadRect a, QuadRect b) {
|
public static boolean intersects(QuadRect a, QuadRect b) {
|
||||||
return Math.min(a.left, a.right) <= Math.max(b.left, b.right)
|
return a.left < b.right && b.left < a.right && a.top < b.bottom && b.top < a.bottom;
|
||||||
&& Math.max(a.left, a.right) >= Math.min(b.left, b.right)
|
}
|
||||||
&& Math.min(a.bottom, a.top) <= Math.max(b.bottom, b.top)
|
|
||||||
&& Math.max(a.bottom, a.top) >= Math.min(b.bottom, b.top);
|
public static boolean trivialOverlap(QuadRect a, QuadRect b) {
|
||||||
|
return !((a.right < b.left) || (a.left > b.right) || (a.top < b.bottom) || (a.bottom > b.top));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean trivialOverlap(QuadRect a, QuadRect b) {
|
|
||||||
return intersects(a, b);
|
|
||||||
}
|
|
||||||
|
|
||||||
public double centerX() {
|
public double centerX() {
|
||||||
return (left + right) / 2;
|
return (left + right) / 2;
|
||||||
|
|
|
@ -103,16 +103,18 @@ public class QuadTree<T> {
|
||||||
void splitBox(QuadRect node_extent, QuadRect[] n) {
|
void splitBox(QuadRect node_extent, QuadRect[] n) {
|
||||||
// coord2d c=node_extent.center();
|
// coord2d c=node_extent.center();
|
||||||
|
|
||||||
|
double width = node_extent.width();
|
||||||
|
double height = node_extent.height();
|
||||||
|
|
||||||
double lx = node_extent.left;
|
double lox = node_extent.left;
|
||||||
double ly = node_extent.top;
|
double loy = node_extent.top;
|
||||||
double hx = node_extent.right;
|
double hix = node_extent.right;
|
||||||
double hy = node_extent.bottom;
|
double hiy = node_extent.bottom;
|
||||||
|
|
||||||
n[0] = new QuadRect(lx, ly, lx + (hx - lx) * ratio, ly + (hy - ly) * ratio);
|
n[0] = new QuadRect(lox, loy, lox + width * ratio, loy + height * ratio);
|
||||||
n[1] = new QuadRect(lx + (hx - lx) * (1 - ratio), ly, hx, ly + (hy - ly) * ratio);
|
n[1] = new QuadRect(hix - width * ratio, loy, hix, loy + height * ratio);
|
||||||
n[2] = new QuadRect(lx, ly + (hy - ly) * (1 - ratio), lx + (hx - lx) * ratio, hy);
|
n[2] = new QuadRect(lox, hiy - height * ratio, lox + width * ratio, hiy);
|
||||||
n[3] = new QuadRect(lx + (hx - lx) * (1 - ratio), ly + (hy - ly) * (1 - ratio), hx, hy);
|
n[3] = new QuadRect(hix - width * ratio, hiy - height * ratio, hix, hiy);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -436,7 +436,6 @@ public class OsmandRegions {
|
||||||
cx /= object.getPointsLength();
|
cx /= object.getPointsLength();
|
||||||
cy /= object.getPointsLength();
|
cy /= object.getPointsLength();
|
||||||
rd.regionCenter = new LatLon(MapUtils.get31LatitudeY((int) cy), MapUtils.get31LongitudeX((int) cx));
|
rd.regionCenter = new LatLon(MapUtils.get31LatitudeY((int) cy), MapUtils.get31LongitudeX((int) cx));
|
||||||
findBoundaries(rd, object);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rd.regionParentFullName = mapIndexFields.get(mapIndexFields.parentFullName, object);
|
rd.regionParentFullName = mapIndexFields.get(mapIndexFields.parentFullName, object);
|
||||||
|
@ -462,47 +461,6 @@ public class OsmandRegions {
|
||||||
return rd;
|
return rd;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void findBoundaries(WorldRegion rd, BinaryMapDataObject object) {
|
|
||||||
if (object.getPointsLength() == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<LatLon> polygon = new ArrayList<>();
|
|
||||||
double currentX = object.getPoint31XTile(0);
|
|
||||||
double currentY = object.getPoint31YTile(0);
|
|
||||||
polygon.add(new LatLon(currentX, currentY));
|
|
||||||
double minX = currentX;
|
|
||||||
double maxX = currentX;
|
|
||||||
double minY = currentY;
|
|
||||||
double maxY = currentY;
|
|
||||||
|
|
||||||
if (object.getPointsLength() > 1) {
|
|
||||||
for (int i = 1; i < object.getPointsLength(); i++) {
|
|
||||||
currentX = object.getPoint31XTile(i);
|
|
||||||
currentY = object.getPoint31YTile(i);
|
|
||||||
if (currentX > maxX) {
|
|
||||||
maxX = currentX;
|
|
||||||
} else if (currentX < minX) {
|
|
||||||
minX = currentX;
|
|
||||||
}
|
|
||||||
if (currentY > maxY) {
|
|
||||||
maxY = currentY;
|
|
||||||
} else if (currentY < minY) {
|
|
||||||
minY = currentY;
|
|
||||||
}
|
|
||||||
polygon.add(new LatLon(currentX, currentY));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
minX = MapUtils.get31LongitudeX((int) minX);
|
|
||||||
maxX = MapUtils.get31LongitudeX((int) maxX);
|
|
||||||
double revertedMinY = MapUtils.get31LatitudeY((int) maxY);
|
|
||||||
double revertedMaxY = MapUtils.get31LatitudeY((int) minY);
|
|
||||||
|
|
||||||
rd.boundingBox = new QuadRect(minX, revertedMinY, maxX, revertedMaxY);
|
|
||||||
rd.polygon = polygon;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getSearchIndex(BinaryMapDataObject object) {
|
private String getSearchIndex(BinaryMapDataObject object) {
|
||||||
MapIndex mi = object.getMapIndex();
|
MapIndex mi = object.getMapIndex();
|
||||||
TIntObjectIterator<String> it = object.getObjectNames().iterator();
|
TIntObjectIterator<String> it = object.getObjectNames().iterator();
|
||||||
|
|
|
@ -140,7 +140,7 @@ public class TileSourceManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return randoms.toArray(new String[0]);
|
return randoms.toArray(new String[randoms.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMinZoom(int minZoom) {
|
public void setMinZoom(int minZoom) {
|
||||||
|
@ -518,8 +518,8 @@ public class TileSourceManager {
|
||||||
}
|
}
|
||||||
if (override || !metainfo.exists()) {
|
if (override || !metainfo.exists()) {
|
||||||
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(metainfo)));
|
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(metainfo)));
|
||||||
for (Map.Entry<String, String> entry : properties.entrySet()) {
|
for (String key : properties.keySet()) {
|
||||||
writer.write("[" + entry.getKey() + "]\n" + entry.getValue() + "\n");
|
writer.write("[" + key + "]\n" + properties.get(key) + "\n");
|
||||||
}
|
}
|
||||||
writer.close();
|
writer.close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,11 @@
|
||||||
package net.osmand.map;
|
package net.osmand.map;
|
||||||
|
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.data.QuadRect;
|
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class WorldRegion implements Serializable {
|
public class WorldRegion implements Serializable {
|
||||||
|
|
||||||
|
@ -44,8 +40,6 @@ public class WorldRegion implements Serializable {
|
||||||
protected String regionDownloadName;
|
protected String regionDownloadName;
|
||||||
protected boolean regionMapDownload;
|
protected boolean regionMapDownload;
|
||||||
protected LatLon regionCenter;
|
protected LatLon regionCenter;
|
||||||
protected QuadRect boundingBox;
|
|
||||||
protected List<LatLon> polygon;
|
|
||||||
|
|
||||||
public static class RegionParams {
|
public static class RegionParams {
|
||||||
protected String regionLeftHandDriving;
|
protected String regionLeftHandDriving;
|
||||||
|
@ -80,12 +74,12 @@ public class WorldRegion implements Serializable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public boolean isRegionMapDownload() {
|
public boolean isRegionMapDownload() {
|
||||||
return regionMapDownload;
|
return regionMapDownload;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLocaleName() {
|
public String getLocaleName() {
|
||||||
if(!Algorithms.isEmpty(regionNameLocale)) {
|
if(!Algorithms.isEmpty(regionNameLocale)) {
|
||||||
return regionNameLocale;
|
return regionNameLocale;
|
||||||
|
@ -96,14 +90,14 @@ public class WorldRegion implements Serializable {
|
||||||
if(!Algorithms.isEmpty(regionName)) {
|
if(!Algorithms.isEmpty(regionName)) {
|
||||||
return regionName;
|
return regionName;
|
||||||
}
|
}
|
||||||
|
|
||||||
return capitalize(regionFullName.replace('_', ' '));
|
return capitalize(regionFullName.replace('_', ' '));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRegionDownloadName() {
|
public String getRegionDownloadName() {
|
||||||
return regionDownloadName;
|
return regionDownloadName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRegionDownloadNameLC() {
|
public String getRegionDownloadNameLC() {
|
||||||
return regionDownloadName == null ? null : regionDownloadName.toLowerCase();
|
return regionDownloadName == null ? null : regionDownloadName.toLowerCase();
|
||||||
}
|
}
|
||||||
|
@ -115,7 +109,7 @@ public class WorldRegion implements Serializable {
|
||||||
public LatLon getRegionCenter() {
|
public LatLon getRegionCenter() {
|
||||||
return regionCenter;
|
return regionCenter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRegionSearchText() {
|
public String getRegionSearchText() {
|
||||||
return regionSearchText;
|
return regionSearchText;
|
||||||
}
|
}
|
||||||
|
@ -149,7 +143,7 @@ public class WorldRegion implements Serializable {
|
||||||
this.regionDownloadName = downloadName;
|
this.regionDownloadName = downloadName;
|
||||||
superregion = null;
|
superregion = null;
|
||||||
subregions = new LinkedList<WorldRegion>();
|
subregions = new LinkedList<WorldRegion>();
|
||||||
|
|
||||||
}
|
}
|
||||||
public WorldRegion(String id) {
|
public WorldRegion(String id) {
|
||||||
this(id, null);
|
this(id, null);
|
||||||
|
@ -158,7 +152,7 @@ public class WorldRegion implements Serializable {
|
||||||
public String getRegionId() {
|
public String getRegionId() {
|
||||||
return regionFullName;
|
return regionFullName;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String capitalize(String s) {
|
private String capitalize(String s) {
|
||||||
String[] words = s.split(" ");
|
String[] words = s.split(" ");
|
||||||
if (words[0].length() > 0) {
|
if (words[0].length() > 0) {
|
||||||
|
@ -188,49 +182,4 @@ public class WorldRegion implements Serializable {
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean containsRegion(WorldRegion region) {
|
|
||||||
if (containsBoundingBox(region.boundingBox)) {
|
|
||||||
// check polygon only if bounding box match
|
|
||||||
return containsPolygon(region.polygon);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean containsBoundingBox(QuadRect rectangle) {
|
|
||||||
return (boundingBox != null && rectangle != null) &&
|
|
||||||
boundingBox.contains(rectangle);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean containsPolygon(List<LatLon> another) {
|
|
||||||
return (polygon != null && another != null) &&
|
|
||||||
Algorithms.isFirstPolygonInsideSecond(another, polygon);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isContinent() {
|
|
||||||
if (superregion != null) {
|
|
||||||
String superRegionId = superregion.getRegionId();
|
|
||||||
String thisRegionId = getRegionId();
|
|
||||||
return WORLD.equals(superRegionId) && !RUSSIA_REGION_ID.equals(thisRegionId);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<WorldRegion> removeDuplicates(List<WorldRegion> regions) {
|
|
||||||
List<WorldRegion> copy = new ArrayList<>(regions);
|
|
||||||
Set<WorldRegion> duplicates = new HashSet<>();
|
|
||||||
for (int i = 0; i < copy.size() - 1; i++) {
|
|
||||||
WorldRegion r1 = copy.get(i);
|
|
||||||
for (int j = i + 1; j < copy.size(); j++) {
|
|
||||||
WorldRegion r2 = copy.get(j);
|
|
||||||
if (r1.containsRegion(r2)) {
|
|
||||||
duplicates.add(r2);
|
|
||||||
} else if (r2.containsRegion(r1)) {
|
|
||||||
duplicates.add(r1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
copy.removeAll(duplicates);
|
|
||||||
return copy;
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -658,8 +658,6 @@ public class MapPoiTypes {
|
||||||
tp.setOsmValue(parser.getAttributeValue("", "value"));
|
tp.setOsmValue(parser.getAttributeValue("", "value"));
|
||||||
tp.setOsmEditTagValue(parser.getAttributeValue("", "edit_tag"),
|
tp.setOsmEditTagValue(parser.getAttributeValue("", "edit_tag"),
|
||||||
parser.getAttributeValue("", "edit_value"));
|
parser.getAttributeValue("", "edit_value"));
|
||||||
tp.setOsmEditTagValue2(parser.getAttributeValue("", "edit_tag2"),
|
|
||||||
parser.getAttributeValue("", "edit_value2"));
|
|
||||||
|
|
||||||
tp.setOsmTag2(parser.getAttributeValue("", "tag2"));
|
tp.setOsmTag2(parser.getAttributeValue("", "tag2"));
|
||||||
tp.setOsmValue2(parser.getAttributeValue("", "value2"));
|
tp.setOsmValue2(parser.getAttributeValue("", "value2"));
|
||||||
|
@ -825,7 +823,7 @@ public class MapPoiTypes {
|
||||||
}
|
}
|
||||||
String name = keyName;
|
String name = keyName;
|
||||||
name = name.replace('_', ' ');
|
name = name.replace('_', ' ');
|
||||||
return Algorithms.capitalizeFirstLetter(name);
|
return Algorithms.capitalizeFirstLetterAndLowercase(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isRegisteredType(PoiCategory t) {
|
public boolean isRegisteredType(PoiCategory t) {
|
||||||
|
|
|
@ -27,7 +27,7 @@ public abstract class MapRenderingTypes {
|
||||||
|
|
||||||
private static final Log log = PlatformUtil.getLog(MapRenderingTypes.class);
|
private static final Log log = PlatformUtil.getLog(MapRenderingTypes.class);
|
||||||
public static final String[] langs = new String[] { "af", "als", "ar", "az", "be", "bg", "bn", "bpy", "br", "bs", "ca", "ceb", "cs", "cy", "da", "de", "el", "eo", "es", "et", "eu", "fa", "fi", "fr", "fy", "ga", "gl", "he", "hi", "hsb",
|
public static final String[] langs = new String[] { "af", "als", "ar", "az", "be", "bg", "bn", "bpy", "br", "bs", "ca", "ceb", "cs", "cy", "da", "de", "el", "eo", "es", "et", "eu", "fa", "fi", "fr", "fy", "ga", "gl", "he", "hi", "hsb",
|
||||||
"hr", "ht", "hu", "hy", "id", "is", "it", "ja", "ka", "kn", "ko", "ku", "la", "lb", "lo", "lt", "lv", "mk", "ml", "mr", "ms", "nds", "new", "nl", "nn", "no", "nv", "os", "pl", "pms", "pt", "ro", "ru", "sc", "sh", "sk", "sl", "sq", "sr", "sv", "sw", "ta", "te", "th", "tl", "tr", "uk", "vi", "vo", "zh", "zh-hans", "zh-hant", };
|
"hr", "ht", "hu", "hy", "id", "is", "it", "ja", "ka", "ko", "ku", "la", "lb", "lo", "lt", "lv", "mk", "ml", "mr", "ms", "nds", "new", "nl", "nn", "no", "nv", "os", "pl", "pms", "pt", "ro", "ru", "sc", "sh", "sk", "sl", "sq", "sr", "sv", "sw", "ta", "te", "th", "tl", "tr", "uk", "vi", "vo", "zh", "zh-hans", "zh-hant", };
|
||||||
|
|
||||||
|
|
||||||
public final static byte RESTRICTION_NO_RIGHT_TURN = 1;
|
public final static byte RESTRICTION_NO_RIGHT_TURN = 1;
|
||||||
|
@ -96,9 +96,8 @@ public abstract class MapRenderingTypes {
|
||||||
Map<String, String> common = new HashMap<String, String>();
|
Map<String, String> common = new HashMap<String, String>();
|
||||||
String ATTACHED_KEY = "seamark:attached";
|
String ATTACHED_KEY = "seamark:attached";
|
||||||
String type = "";
|
String type = "";
|
||||||
for (Entry<String, String> entry : tags.entrySet()) {
|
for (String s : tags.keySet()) {
|
||||||
String s = entry.getKey();
|
String value = tags.get(s);
|
||||||
String value = entry.getValue();
|
|
||||||
if (s.equals("seamark:type")) {
|
if (s.equals("seamark:type")) {
|
||||||
type = value;
|
type = value;
|
||||||
common.put(ATTACHED_KEY, openSeaType(value));
|
common.put(ATTACHED_KEY, openSeaType(value));
|
||||||
|
|
|
@ -16,10 +16,9 @@ public class PoiType extends AbstractPoiType {
|
||||||
|
|
||||||
private String editTag;
|
private String editTag;
|
||||||
private String editValue;
|
private String editValue;
|
||||||
private String editTag2;
|
|
||||||
private String editValue2;
|
|
||||||
private boolean filterOnly;
|
private boolean filterOnly;
|
||||||
|
|
||||||
|
|
||||||
private String nameTag;
|
private String nameTag;
|
||||||
private boolean text;
|
private boolean text;
|
||||||
private boolean nameOnly;
|
private boolean nameOnly;
|
||||||
|
@ -69,46 +68,27 @@ public class PoiType extends AbstractPoiType {
|
||||||
this.editTag = osmTag;
|
this.editTag = osmTag;
|
||||||
this.editValue = editValue;
|
this.editValue = editValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOsmEditTagValue2(String osmTag, String editValue) {
|
|
||||||
this.editTag2 = osmTag;
|
|
||||||
this.editValue2 = editValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getEditOsmTag() {
|
public String getEditOsmTag() {
|
||||||
if (isReference()) {
|
if(isReference()) {
|
||||||
return referenceType.getEditOsmTag();
|
return referenceType.getEditOsmTag();
|
||||||
}
|
}
|
||||||
if (editTag == null) {
|
if(editTag == null) {
|
||||||
return getOsmTag();
|
return getOsmTag();
|
||||||
}
|
}
|
||||||
return editTag;
|
return editTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEditOsmValue() {
|
public String getEditOsmValue() {
|
||||||
if (isReference()) {
|
if(isReference()) {
|
||||||
return referenceType.getEditOsmValue();
|
return referenceType.getEditOsmValue();
|
||||||
}
|
}
|
||||||
if (editValue == null) {
|
if(editValue == null) {
|
||||||
return getOsmValue();
|
return getOsmValue();
|
||||||
}
|
}
|
||||||
return editValue;
|
return editValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEditOsmTag2() {
|
|
||||||
if (isReference()) {
|
|
||||||
return referenceType.getEditOsmTag2();
|
|
||||||
}
|
|
||||||
return editTag2;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getEditOsmValue2() {
|
|
||||||
if (isReference()) {
|
|
||||||
return referenceType.getEditOsmValue2();
|
|
||||||
}
|
|
||||||
return editValue2;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOsmTag(String osmTag) {
|
public void setOsmTag(String osmTag) {
|
||||||
this.osmTag = osmTag;
|
this.osmTag = osmTag;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,266 +0,0 @@
|
||||||
package net.osmand.osm;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class RouteActivityType {
|
|
||||||
private static final List<RouteActivityType> 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;
|
|
||||||
|
|
||||||
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 || 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)) {
|
|
||||||
return HIKING;
|
|
||||||
}
|
|
||||||
if ("motorcar".equalsIgnoreCase(t)) {
|
|
||||||
return CAR;
|
|
||||||
}
|
|
||||||
if ("laufen".equalsIgnoreCase(t)) {
|
|
||||||
return RUNNING;
|
|
||||||
}
|
|
||||||
if ("pedestrian".equalsIgnoreCase(t)) {
|
|
||||||
return WALKING;
|
|
||||||
}
|
|
||||||
switch (t) {
|
|
||||||
case "mountainbiking":
|
|
||||||
case "mtb":
|
|
||||||
case "mountainbike":
|
|
||||||
case "mountain bike":
|
|
||||||
case "mountain biking":
|
|
||||||
case "mountbarker":
|
|
||||||
case "mtb-tour":
|
|
||||||
case "ciclismo-mtb-gravel":
|
|
||||||
case "vtt":
|
|
||||||
case "btt":
|
|
||||||
case "vth":
|
|
||||||
case "mtb ride":
|
|
||||||
return MOUNTAINBIKE;
|
|
||||||
case "hiking":
|
|
||||||
case "route=hiking":
|
|
||||||
case "mountain hiking":
|
|
||||||
case "hiking trail":
|
|
||||||
case "wandern":
|
|
||||||
case "hike":
|
|
||||||
case "randonnée":
|
|
||||||
case "trekking":
|
|
||||||
case "climbing":
|
|
||||||
return HIKING;
|
|
||||||
case "bike":
|
|
||||||
case "biking":
|
|
||||||
case "bicycling":
|
|
||||||
case "bicycle":
|
|
||||||
case "cycling":
|
|
||||||
case "cycle":
|
|
||||||
case "cycleway":
|
|
||||||
case "cykel":
|
|
||||||
case "handcycle":
|
|
||||||
case "cyclotourisme":
|
|
||||||
case "route=bicycle":
|
|
||||||
case "cyclotourism":
|
|
||||||
case "fietsen":
|
|
||||||
case "вело":
|
|
||||||
case "велосипед":
|
|
||||||
case "rower":
|
|
||||||
case "trasa rowerem":
|
|
||||||
case "vélo":
|
|
||||||
case "velo":
|
|
||||||
case "radtour":
|
|
||||||
case "bici":
|
|
||||||
case "fiets":
|
|
||||||
case "fahrrad":
|
|
||||||
case "ncn":
|
|
||||||
case "icn":
|
|
||||||
case "lcn":
|
|
||||||
case "network=ncn":
|
|
||||||
case "network=icn":
|
|
||||||
case "network=lcn":
|
|
||||||
return CYCLING;
|
|
||||||
case "car":
|
|
||||||
case "motorcar":
|
|
||||||
case "by car":
|
|
||||||
case "auto":
|
|
||||||
case "автомобиль":
|
|
||||||
case "automobile":
|
|
||||||
case "autós":
|
|
||||||
case "driving":
|
|
||||||
case "drive":
|
|
||||||
case "van":
|
|
||||||
case "авто":
|
|
||||||
case "на автомобиле":
|
|
||||||
case "bus":
|
|
||||||
case "truck":
|
|
||||||
case "taxi":
|
|
||||||
return CAR;
|
|
||||||
case "running":
|
|
||||||
case "run":
|
|
||||||
case "rungis":
|
|
||||||
case "trail running":
|
|
||||||
case "trailrunning":
|
|
||||||
case "бег":
|
|
||||||
case "laufen":
|
|
||||||
case "langlauf":
|
|
||||||
case "lauf":
|
|
||||||
case "course":
|
|
||||||
case "jogging":
|
|
||||||
case "fitotrack":
|
|
||||||
return RUNNING;
|
|
||||||
case "wanderung":
|
|
||||||
case "walking":
|
|
||||||
case "walk":
|
|
||||||
case "nightwalk":
|
|
||||||
case "walkway":
|
|
||||||
case "пешком":
|
|
||||||
case "пеший":
|
|
||||||
case "pěšky":
|
|
||||||
case "marche":
|
|
||||||
case "pedestrian":
|
|
||||||
case "foot":
|
|
||||||
case "footing":
|
|
||||||
case "on_foot":
|
|
||||||
case "byfoot":
|
|
||||||
case "onfoot":
|
|
||||||
case "sightseeing":
|
|
||||||
case "geocaching":
|
|
||||||
case "etnanatura":
|
|
||||||
case "etna":
|
|
||||||
case "iwn":
|
|
||||||
case "lwn":
|
|
||||||
case "rwn":
|
|
||||||
case "network=iwn":
|
|
||||||
case "network=lwn":
|
|
||||||
case "network=rwn":
|
|
||||||
return WALKING;
|
|
||||||
case "ling-moto":
|
|
||||||
case "motorbiking":
|
|
||||||
case "motorcycle":
|
|
||||||
case "motorrad":
|
|
||||||
case "motorbike":
|
|
||||||
case "motor bike":
|
|
||||||
case "FVbike":
|
|
||||||
case "Motorrad":
|
|
||||||
return MOTORBIKE;
|
|
||||||
case "offroad":
|
|
||||||
case "off-road":
|
|
||||||
case "off road":
|
|
||||||
case "4x4":
|
|
||||||
case "terrain":
|
|
||||||
case "quad":
|
|
||||||
case "enduro":
|
|
||||||
case "feldwege":
|
|
||||||
case "feldweg":
|
|
||||||
return OFFROAD;
|
|
||||||
case "boat":
|
|
||||||
case "water":
|
|
||||||
case "boating":
|
|
||||||
case "kayak":
|
|
||||||
case "river":
|
|
||||||
case "lake":
|
|
||||||
case "lakes":
|
|
||||||
case "canal":
|
|
||||||
return WATER;
|
|
||||||
case "ski":
|
|
||||||
case "skiing":
|
|
||||||
case "skating":
|
|
||||||
case "skitour":
|
|
||||||
case "winter":
|
|
||||||
case "wintersports":
|
|
||||||
case "snowboard":
|
|
||||||
case "лыжи":
|
|
||||||
case "лыжня":
|
|
||||||
case "nordic":
|
|
||||||
case "piste":
|
|
||||||
return WINTER;
|
|
||||||
case "snowmobile=designated":
|
|
||||||
case "snowmobile=permissive":
|
|
||||||
case "snowmobile=yes":
|
|
||||||
case "snowmobile":
|
|
||||||
return SNOWMOBILE;
|
|
||||||
case "ride":
|
|
||||||
case "horse":
|
|
||||||
case "horse trail":
|
|
||||||
return RIDING;
|
|
||||||
case "racing":
|
|
||||||
return RACING;
|
|
||||||
}
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -114,8 +114,6 @@ public abstract class Entity implements Serializable {
|
||||||
public static final int MODIFY_DELETED = -1;
|
public static final int MODIFY_DELETED = -1;
|
||||||
public static final int MODIFY_MODIFIED = 1;
|
public static final int MODIFY_MODIFIED = 1;
|
||||||
public static final int MODIFY_CREATED = 2;
|
public static final int MODIFY_CREATED = 2;
|
||||||
public static final String POI_TYPE_TAG = "poi_type_tag";
|
|
||||||
public static final String REMOVE_TAG_PREFIX = "----";
|
|
||||||
|
|
||||||
public Entity(long id) {
|
public Entity(long id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
@ -243,11 +241,6 @@ public abstract class Entity implements Serializable {
|
||||||
return Collections.unmodifiableMap(tags);
|
return Collections.unmodifiableMap(tags);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isNotValid(String tag) {
|
|
||||||
String val = getTag(tag);
|
|
||||||
return val == null || val.length() == 0 || tag.length() == 0
|
|
||||||
|| tag.startsWith(REMOVE_TAG_PREFIX) || tag.equals(POI_TYPE_TAG);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Collection<String> getTagKeySet() {
|
public Collection<String> getTagKeySet() {
|
||||||
if (tags == null) {
|
if (tags == null) {
|
||||||
|
|
|
@ -21,7 +21,7 @@ import net.osmand.osm.edit.Relation.RelationMember;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
public class EntityParser {
|
public class EntityParser {
|
||||||
|
|
||||||
public static void parseMapObject(MapObject mo, Entity e, Map<String, String> tags) {
|
public static void parseMapObject(MapObject mo, Entity e, Map<String, String> tags) {
|
||||||
mo.setId(e.getId());
|
mo.setId(e.getId());
|
||||||
if(mo instanceof Amenity) {
|
if(mo instanceof Amenity) {
|
||||||
|
@ -33,10 +33,9 @@ public class EntityParser {
|
||||||
if (mo.getEnName(false).length() == 0) {
|
if (mo.getEnName(false).length() == 0) {
|
||||||
mo.setEnName(tags.get(OSMTagKey.NAME_EN.getValue()));
|
mo.setEnName(tags.get(OSMTagKey.NAME_EN.getValue()));
|
||||||
}
|
}
|
||||||
for (Map.Entry<String, String> entry : tags.entrySet()) {
|
for (String ts : tags.keySet()) {
|
||||||
String ts = entry.getKey();
|
|
||||||
if (ts.startsWith("name:") && !ts.equals(OSMTagKey.NAME_EN.getValue())) {
|
if (ts.startsWith("name:") && !ts.equals(OSMTagKey.NAME_EN.getValue())) {
|
||||||
mo.setName(ts.substring(("name:").length()), entry.getValue());
|
mo.setName(ts.substring(("name:").length()), tags.get(ts));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mo.getName().length() == 0) {
|
if (mo.getName().length() == 0) {
|
||||||
|
@ -123,7 +122,7 @@ public class EntityParser {
|
||||||
mo.setName(ref);
|
mo.setName(ref);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setNameFromBrand(MapObject mo, Map<String, String> tags) {
|
private static void setNameFromBrand(MapObject mo, Map<String, String> tags) {
|
||||||
String ref = tags.get(OSMTagKey.BRAND.getValue());
|
String ref = tags.get(OSMTagKey.BRAND.getValue());
|
||||||
if(ref != null){
|
if(ref != null){
|
||||||
|
@ -140,7 +139,7 @@ public class EntityParser {
|
||||||
op += " [" + ref + "]";
|
op += " [" + ref + "]";
|
||||||
mo.setName(op);
|
mo.setName(op);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static String getWebSiteURL(Map<String, String> tagValues, boolean checkWikipedia) {
|
private static String getWebSiteURL(Map<String, String> tagValues, boolean checkWikipedia) {
|
||||||
String siteUrl = null;
|
String siteUrl = null;
|
||||||
|
@ -170,14 +169,14 @@ public class EntityParser {
|
||||||
}
|
}
|
||||||
return siteUrl;
|
return siteUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static List<Amenity> parseAmenities(MapPoiTypes poiTypes, Entity entity, Map<String, String> tags,
|
public static List<Amenity> parseAmenities(MapPoiTypes poiTypes, Entity entity, Map<String, String> tags,
|
||||||
List<Amenity> amenitiesList) {
|
List<Amenity> amenitiesList) {
|
||||||
amenitiesList.clear();
|
amenitiesList.clear();
|
||||||
// it could be collection of amenities
|
// it could be collection of amenities
|
||||||
boolean relation = entity instanceof Relation;
|
boolean relation = entity instanceof Relation;
|
||||||
boolean purerelation = relation &&
|
boolean purerelation = relation &&
|
||||||
!("multipolygon".equals(tags.get("type")) || "boundary".equals(tags.get("type")));
|
!("multipolygon".equals(tags.get("type")) || "boundary".equals(tags.get("type")));
|
||||||
Collection<Map<String, String>> it = MapRenderingTypes.splitTagsIntoDifferentObjects(tags);
|
Collection<Map<String, String>> it = MapRenderingTypes.splitTagsIntoDifferentObjects(tags);
|
||||||
for (Map<String, String> ts : it) {
|
for (Map<String, String> ts : it) {
|
||||||
|
@ -201,7 +200,9 @@ public class EntityParser {
|
||||||
}
|
}
|
||||||
return amenitiesList;
|
return amenitiesList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static boolean checkAmenitiesToAdd(Amenity a, List<Amenity> amenitiesList){
|
private static boolean checkAmenitiesToAdd(Amenity a, List<Amenity> amenitiesList){
|
||||||
// check amenity for duplication
|
// check amenity for duplication
|
||||||
for(Amenity b : amenitiesList){
|
for(Amenity b : amenitiesList){
|
||||||
|
@ -210,9 +211,9 @@ public class EntityParser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Building parseBuilding(Entity e){
|
public static Building parseBuilding(Entity e){
|
||||||
Building b = new Building();
|
Building b = new Building();
|
||||||
parseMapObject(b, e, e.getTags());
|
parseMapObject(b, e, e.getTags());
|
||||||
|
@ -226,7 +227,7 @@ public class EntityParser {
|
||||||
List<Node> nodes = ((Way) e).getNodes();
|
List<Node> nodes = ((Way) e).getNodes();
|
||||||
for(int i = 0; i < nodes.size(); i++) {
|
for(int i = 0; i < nodes.size(); i++) {
|
||||||
Node node = nodes.get(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))) {
|
!Algorithms.isEmpty(node.getTag(OSMTagKey.REF))) {
|
||||||
b.addEntrance(node.getTag(OSMTagKey.REF), node.getLatLon());
|
b.addEntrance(node.getTag(OSMTagKey.REF), node.getLatLon());
|
||||||
}
|
}
|
||||||
|
@ -234,11 +235,11 @@ public class EntityParser {
|
||||||
}
|
}
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static City parseCity(Node el) {
|
public static City parseCity(Node el) {
|
||||||
return parseCity(el, CityType.valueFromString(el.getTag(OSMTagKey.PLACE.getValue())));
|
return parseCity(el, CityType.valueFromString(el.getTag(OSMTagKey.PLACE.getValue())));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static City parseCity(Entity el, CityType t) {
|
public static City parseCity(Entity el, CityType t) {
|
||||||
if(t == null) {
|
if(t == null) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -250,15 +251,15 @@ public class EntityParser {
|
||||||
c.setIsin(isin);
|
c.setIsin(isin);
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static TransportRoute parserRoute(Relation r, String ref){
|
public static TransportRoute parserRoute(Relation r, String ref){
|
||||||
TransportRoute rt = new TransportRoute();
|
TransportRoute rt = new TransportRoute();
|
||||||
parseMapObject(rt, r, r.getTags());
|
parseMapObject(rt, r, r.getTags());
|
||||||
rt.setRef(ref);
|
rt.setRef(ref);
|
||||||
return rt;
|
return rt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TransportStop parseTransportStop(Entity e){
|
public static TransportStop parseTransportStop(Entity e){
|
||||||
TransportStop st = new TransportStop();
|
TransportStop st = new TransportStop();
|
||||||
parseMapObject(st, e, e.getTags());
|
parseMapObject(st, e, e.getTags());
|
||||||
|
|
|
@ -153,34 +153,35 @@ public class OsmMapUtils {
|
||||||
}
|
}
|
||||||
boolean area = w.getFirstNodeId() == w.getLastNodeId();
|
boolean area = w.getFirstNodeId() == w.getLastNodeId();
|
||||||
// double check for area (could be negative all)
|
// double check for area (could be negative all)
|
||||||
if (area) {
|
if(area) {
|
||||||
Node fn = w.getFirstNode();
|
Node fn = w.getFirstNode();
|
||||||
Node ln = w.getLastNode();
|
Node ln = w.getLastNode();
|
||||||
if (fn != null && fn != null && MapUtils.getDistance(fn.getLatLon(), ln.getLatLon()) < 50) {
|
if(fn != null && fn != null && MapUtils.getDistance(fn.getLatLon(), ln.getLatLon()) < 50) {
|
||||||
area = true;
|
area = true;
|
||||||
} else {
|
} else {
|
||||||
area = false;
|
area = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LatLon ll = area ? getComplexPolyCenter(nodes, null) : getWeightCenterForNodes(nodes);
|
LatLon ll = area ? getComplexPolyCenter(nodes, null) : getWeightCenterForNodes(nodes);
|
||||||
if (ll == null) {
|
if(ll == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
double flat = ll.getLatitude();
|
double flat = ll.getLatitude();
|
||||||
double flon = ll.getLongitude();
|
double flon = ll.getLongitude();
|
||||||
if (!area || !MapAlgorithms.containsPoint(nodes, ll.getLatitude(), ll.getLongitude())) {
|
if(!area || !MapAlgorithms.containsPoint(nodes, ll.getLatitude(), ll.getLongitude())) {
|
||||||
double minDistance = Double.MAX_VALUE;
|
double minDistance = Double.MAX_VALUE;
|
||||||
for (Node n : nodes) {
|
for (Node n : nodes) {
|
||||||
if (n != null) {
|
if (n != null) {
|
||||||
double d = MapUtils.getDistance(n.getLatitude(), n.getLongitude(), ll.getLatitude(), ll.getLongitude());
|
double d = MapUtils.getDistance(n.getLatitude(), n.getLongitude(), ll.getLatitude(), ll.getLongitude());
|
||||||
if (d < minDistance) {
|
if(d < minDistance) {
|
||||||
flat = n.getLatitude();
|
flat = n.getLatitude();
|
||||||
flon = n.getLongitude();
|
flon = n.getLongitude();
|
||||||
minDistance = d;
|
minDistance = d;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new LatLon(flat, flon);
|
return new LatLon(flat, flon);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -340,30 +341,6 @@ public class OsmMapUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void simplifyDouglasPeucker(List<Node> nodes, int start, int end, List<Node> survivedNodes, double epsilon) {
|
|
||||||
double dmax = Double.NEGATIVE_INFINITY;
|
|
||||||
int index = -1;
|
|
||||||
|
|
||||||
Node startPt = nodes.get(start);
|
|
||||||
Node endPt = nodes.get(end);
|
|
||||||
|
|
||||||
for (int i = start + 1; i < end; i++) {
|
|
||||||
Node pt = nodes.get(i);
|
|
||||||
double d = MapUtils.getOrthogonalDistance(pt.getLatitude(), pt.getLongitude(),
|
|
||||||
startPt.getLatitude(), startPt.getLongitude(), endPt.getLatitude(), endPt.getLongitude());
|
|
||||||
if (d > dmax) {
|
|
||||||
dmax = d;
|
|
||||||
index = i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (dmax > epsilon) {
|
|
||||||
simplifyDouglasPeucker(nodes, start, index, survivedNodes, epsilon);
|
|
||||||
simplifyDouglasPeucker(nodes, index, end, survivedNodes, epsilon);
|
|
||||||
} else {
|
|
||||||
survivedNodes.add(nodes.get(end));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static double orthogonalDistance(int zoom, Node nodeLineStart, Node nodeLineEnd, Node node) {
|
private static double orthogonalDistance(int zoom, Node nodeLineStart, Node nodeLineEnd, Node node) {
|
||||||
LatLon p = MapUtils.getProjection(node.getLatitude(), node.getLongitude(), nodeLineStart.getLatitude(),
|
LatLon p = MapUtils.getProjection(node.getLatitude(), node.getLongitude(), nodeLineStart.getLatitude(),
|
||||||
nodeLineStart.getLongitude(), nodeLineEnd.getLatitude(), nodeLineEnd.getLongitude());
|
nodeLineStart.getLongitude(), nodeLineEnd.getLatitude(), nodeLineEnd.getLongitude());
|
||||||
|
|
|
@ -1,22 +1,30 @@
|
||||||
package net.osmand.osm.io;
|
package net.osmand.osm.io;
|
||||||
|
|
||||||
import com.github.scribejava.core.model.OAuthRequest;
|
import java.io.BufferedInputStream;
|
||||||
import com.github.scribejava.core.model.Response;
|
import java.io.BufferedReader;
|
||||||
import com.github.scribejava.core.model.Verb;
|
import java.io.File;
|
||||||
import net.osmand.PlatformUtil;
|
import java.io.FileInputStream;
|
||||||
import net.osmand.osm.oauth.OsmOAuthAuthorizationClient;
|
import java.io.IOException;
|
||||||
import net.osmand.util.Algorithms;
|
import java.io.InputStream;
|
||||||
import org.apache.commons.logging.Log;
|
import java.io.InputStreamReader;
|
||||||
|
import java.io.OutputStream;
|
||||||
import java.io.*;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.*;
|
import java.net.InetSocketAddress;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.Proxy;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLEncoder;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.zip.GZIPOutputStream;
|
import java.util.zip.GZIPOutputStream;
|
||||||
|
|
||||||
|
import net.osmand.PlatformUtil;
|
||||||
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
public class NetworkUtils {
|
public class NetworkUtils {
|
||||||
private static final Log log = PlatformUtil.getLog(NetworkUtils.class);
|
private static final Log log = PlatformUtil.getLog(NetworkUtils.class);
|
||||||
private static final String GPX_UPLOAD_USER_AGENT = "OsmGPXUploadAgent";
|
|
||||||
private static Proxy proxy = null;
|
private static Proxy proxy = null;
|
||||||
|
|
||||||
public static String sendGetRequest(String urlText, String userNamePassword, StringBuilder responseBody){
|
public static String sendGetRequest(String urlText, String userNamePassword, StringBuilder responseBody){
|
||||||
|
@ -29,7 +37,7 @@ public class NetworkUtils {
|
||||||
if(userNamePassword != null) {
|
if(userNamePassword != null) {
|
||||||
conn.setRequestProperty("Authorization", "Basic " + Base64.encode(userNamePassword)); //$NON-NLS-1$ //$NON-NLS-2$
|
conn.setRequestProperty("Authorization", "Basic " + Base64.encode(userNamePassword)); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
}
|
}
|
||||||
conn.setRequestProperty("User-Agent", "OsmAnd"); //$NON-NLS-1$ //$NON-NLS-2$
|
conn.setRequestProperty("User-Agent", "OsmAnd"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
log.info("Response code and message : " + conn.getResponseCode() + " " + conn.getResponseMessage());
|
log.info("Response code and message : " + conn.getResponseCode() + " " + conn.getResponseMessage());
|
||||||
if(conn.getResponseCode() != 200){
|
if(conn.getResponseCode() != 200){
|
||||||
return conn.getResponseMessage();
|
return conn.getResponseMessage();
|
||||||
|
@ -47,6 +55,7 @@ public class NetworkUtils {
|
||||||
responseBody.append("\n"); //$NON-NLS-1$
|
responseBody.append("\n"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
responseBody.append(s);
|
responseBody.append(s);
|
||||||
|
|
||||||
}
|
}
|
||||||
is.close();
|
is.close();
|
||||||
}
|
}
|
||||||
|
@ -56,110 +65,46 @@ public class NetworkUtils {
|
||||||
return e.getMessage();
|
return e.getMessage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String sendPostDataRequest(String urlText, String formName, String fileName, InputStream data) {
|
|
||||||
try {
|
|
||||||
log.info("POST : " + urlText);
|
|
||||||
HttpURLConnection conn = getHttpURLConnection(urlText);
|
|
||||||
conn.setDoInput(true);
|
|
||||||
conn.setDoOutput(false);
|
|
||||||
conn.setRequestMethod("POST");
|
|
||||||
conn.setRequestProperty("Accept", "*/*");
|
|
||||||
conn.setRequestProperty("User-Agent", "OsmAnd"); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
conn.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + BOUNDARY);
|
|
||||||
OutputStream ous = conn.getOutputStream();
|
|
||||||
ous.write(("--" + BOUNDARY + "\r\n").getBytes());
|
|
||||||
ous.write(("Content-Disposition: form-data; name=\"" + formName + "\"; filename=\"" + fileName + "\"\r\n").getBytes()); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
ous.write(("Content-Type: application/octet-stream\r\n\r\n").getBytes()); //$NON-NLS-1$
|
|
||||||
Algorithms.streamCopy(data, ous);
|
|
||||||
ous.write(("\r\n--" + BOUNDARY + "--\r\n").getBytes()); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
ous.flush();
|
|
||||||
log.info("Response code and message : " + conn.getResponseCode() + " " + conn.getResponseMessage());
|
|
||||||
if (conn.getResponseCode() != 200) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
StringBuilder responseBody = new StringBuilder();
|
|
||||||
InputStream is = conn.getInputStream();
|
|
||||||
responseBody.setLength(0);
|
|
||||||
if (is != null) {
|
|
||||||
BufferedReader in = new BufferedReader(new InputStreamReader(is, "UTF-8")); //$NON-NLS-1$
|
|
||||||
String s;
|
|
||||||
boolean first = true;
|
|
||||||
while ((s = in.readLine()) != null) {
|
|
||||||
if (first) {
|
|
||||||
first = false;
|
|
||||||
} else {
|
|
||||||
responseBody.append("\n"); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
responseBody.append(s);
|
|
||||||
}
|
|
||||||
is.close();
|
|
||||||
}
|
|
||||||
Algorithms.closeStream(is);
|
|
||||||
Algorithms.closeStream(data);
|
|
||||||
Algorithms.closeStream(ous);
|
|
||||||
return responseBody.toString();
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.error(e.getMessage(), e);
|
|
||||||
return e.getMessage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String BOUNDARY = "CowMooCowMooCowCowCow"; //$NON-NLS-1$
|
private static final String BOUNDARY = "CowMooCowMooCowCowCow"; //$NON-NLS-1$
|
||||||
public static String uploadFile(String urlText, File fileToUpload, String userNamePassword,
|
public static String uploadFile(String urlText, File fileToUpload, String userNamePassword, String formName, boolean gzip, Map<String, String> additionalMapData){
|
||||||
OsmOAuthAuthorizationClient client,
|
|
||||||
String formName, boolean gzip, Map<String, String> additionalMapData){
|
|
||||||
URL url;
|
URL url;
|
||||||
try {
|
try {
|
||||||
boolean firstPrm =!urlText.contains("?");
|
boolean firstPrm =!urlText.contains("?");
|
||||||
for (Map.Entry<String, String> entry : additionalMapData.entrySet()) {
|
for (String key : additionalMapData.keySet()) {
|
||||||
urlText += (firstPrm ? "?" : "&") + entry.getKey() + "=" + URLEncoder.encode(entry.getValue(), "UTF-8");
|
urlText += (firstPrm ? "?" : "&") + key + "=" + URLEncoder.encode(additionalMapData.get(key), "UTF-8");
|
||||||
firstPrm = false;
|
firstPrm = false;
|
||||||
}
|
}
|
||||||
log.info("Start uploading file to " + urlText + " " +fileToUpload.getName());
|
log.info("Start uploading file to " + urlText + " " +fileToUpload.getName());
|
||||||
url = new URL(urlText);
|
url = new URL(urlText);
|
||||||
HttpURLConnection conn;
|
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||||
if (client != null && client.isValidToken()){
|
conn.setDoInput(true);
|
||||||
OAuthRequest req = new OAuthRequest(Verb.POST, urlText);
|
conn.setDoOutput(true);
|
||||||
client.getService().signRequest(client.getAccessToken(), req);
|
conn.setRequestMethod("POST");
|
||||||
req.addHeader("Content-Type", "multipart/form-data; boundary=" + BOUNDARY);
|
if(userNamePassword != null) {
|
||||||
try {
|
conn.setRequestProperty("Authorization", "Basic " + Base64.encode(userNamePassword)); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
Response r = client.getHttpClient().execute(GPX_UPLOAD_USER_AGENT, req.getHeaders(), req.getVerb(),
|
|
||||||
req.getCompleteUrl(), fileToUpload);
|
|
||||||
if (r.getCode() != 200) {
|
|
||||||
return r.getBody();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
log.error(e);
|
|
||||||
} catch (ExecutionException e) {
|
|
||||||
log.error(e);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
conn = (HttpURLConnection) url.openConnection();
|
conn.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + BOUNDARY); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
conn.setDoInput(true);
|
conn.setRequestProperty("User-Agent", "OsmAnd"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
conn.setDoOutput(true);
|
|
||||||
conn.setRequestMethod("POST");
|
OutputStream ous = conn.getOutputStream();
|
||||||
if(userNamePassword != null) {
|
// for (String key : additionalMapData.keySet()) {
|
||||||
conn.setRequestProperty("Authorization", "Basic " + Base64.encode(userNamePassword)); //$NON-NLS-1$ //$NON-NLS-2$
|
// ous.write(("--" + BOUNDARY + "\r\n").getBytes());
|
||||||
}
|
// ous.write(("content-disposition: form-data; name=\"" + key + "\"\r\n").getBytes()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
}
|
// ous.write((additionalMapData.get(key) + "\r\n").getBytes());
|
||||||
conn.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + BOUNDARY); //$NON-NLS-1$ //$NON-NLS-2$
|
// }
|
||||||
conn.setRequestProperty("User-Agent", "OsmAnd"); //$NON-NLS-1$ //$NON-NLS-2$
|
ous.write(("--" + BOUNDARY+"\r\n").getBytes());
|
||||||
OutputStream ous = conn.getOutputStream();
|
|
||||||
ous.write(("--" + BOUNDARY + "\r\n").getBytes());
|
|
||||||
String filename = fileToUpload.getName();
|
String filename = fileToUpload.getName();
|
||||||
if (gzip) {
|
if(gzip){
|
||||||
filename += ".gz";
|
filename+=".gz";
|
||||||
}
|
}
|
||||||
ous.write(("content-disposition: form-data; name=\"" + formName + "\"; filename=\"" + filename + "\"\r\n").getBytes()); //$NON-NLS-1$ //$NON-NLS-2$
|
ous.write(("content-disposition: form-data; name=\""+formName+"\"; filename=\"" + filename + "\"\r\n").getBytes()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
ous.write(("Content-Type: application/octet-stream\r\n\r\n").getBytes()); //$NON-NLS-1$
|
ous.write(("Content-Type: application/octet-stream\r\n\r\n").getBytes()); //$NON-NLS-1$
|
||||||
InputStream fis = new FileInputStream(fileToUpload);
|
InputStream fis = new FileInputStream(fileToUpload);
|
||||||
BufferedInputStream bis = new BufferedInputStream(fis, 20 * 1024);
|
BufferedInputStream bis = new BufferedInputStream(fis, 20 * 1024);
|
||||||
ous.flush();
|
ous.flush();
|
||||||
if (gzip) {
|
if(gzip){
|
||||||
GZIPOutputStream gous = new GZIPOutputStream(ous, 1024);
|
GZIPOutputStream gous = new GZIPOutputStream(ous, 1024);
|
||||||
Algorithms.streamCopy(bis, gous);
|
Algorithms.streamCopy(bis, gous);
|
||||||
gous.flush();
|
gous.flush();
|
||||||
|
@ -167,7 +112,8 @@ public class NetworkUtils {
|
||||||
} else {
|
} else {
|
||||||
Algorithms.streamCopy(bis, ous);
|
Algorithms.streamCopy(bis, ous);
|
||||||
}
|
}
|
||||||
ous.write(("\r\n--" + BOUNDARY + "--\r\n").getBytes()); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
|
ous.write(("\r\n--" + BOUNDARY + "--\r\n").getBytes()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
ous.flush();
|
ous.flush();
|
||||||
Algorithms.closeStream(bis);
|
Algorithms.closeStream(bis);
|
||||||
Algorithms.closeStream(ous);
|
Algorithms.closeStream(ous);
|
||||||
|
@ -190,6 +136,7 @@ public class NetworkUtils {
|
||||||
responseBody.append("\n"); //$NON-NLS-1$
|
responseBody.append("\n"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
responseBody.append(s);
|
responseBody.append(s);
|
||||||
|
|
||||||
}
|
}
|
||||||
is.close();
|
is.close();
|
||||||
}
|
}
|
||||||
|
@ -210,6 +157,7 @@ public class NetworkUtils {
|
||||||
proxy = null;
|
proxy = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Proxy getProxy() {
|
public static Proxy getProxy() {
|
||||||
return proxy;
|
return proxy;
|
||||||
}
|
}
|
||||||
|
|
|
@ -183,7 +183,7 @@ public class OsmBaseStorage {
|
||||||
protected static final int moduleProgress = 1 << 10;
|
protected static final int moduleProgress = 1 << 10;
|
||||||
|
|
||||||
public void startElement(XmlPullParser parser, String name) {
|
public void startElement(XmlPullParser parser, String name) {
|
||||||
if (!parseStarted) {
|
if(!parseStarted){
|
||||||
initRootElement(parser, name);
|
initRootElement(parser, name);
|
||||||
}
|
}
|
||||||
if (ELEM_MODIFY.equals(name) ) {
|
if (ELEM_MODIFY.equals(name) ) {
|
||||||
|
@ -283,14 +283,13 @@ public class OsmBaseStorage {
|
||||||
if (type != null) {
|
if (type != null) {
|
||||||
if(currentParsedEntity != null){
|
if(currentParsedEntity != null){
|
||||||
EntityId entityId = new EntityId(type, currentParsedEntity.getId());
|
EntityId entityId = new EntityId(type, currentParsedEntity.getId());
|
||||||
if (acceptEntityToLoad(entityId, currentParsedEntity)) {
|
if(acceptEntityToLoad(entityId, currentParsedEntity)){
|
||||||
Entity oldEntity = entities.put(entityId, currentParsedEntity);
|
Entity oldEntity = entities.put(entityId, currentParsedEntity);
|
||||||
if (parseEntityInfo && currentParsedEntityInfo != null) {
|
if(parseEntityInfo && currentParsedEntityInfo != null){
|
||||||
entityInfo.put(entityId, currentParsedEntityInfo);
|
entityInfo.put(entityId, currentParsedEntityInfo);
|
||||||
}
|
}
|
||||||
if (!supressWarnings && oldEntity != null) {
|
if(!supressWarnings && oldEntity!= null){
|
||||||
throw new UnsupportedOperationException(
|
throw new UnsupportedOperationException("Entity with id=" + oldEntity.getId() +" is duplicated in osm map"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
"Entity with id=" + oldEntity.getId() + " is duplicated in osm map"); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// System.gc();
|
// System.gc();
|
||||||
|
@ -309,8 +308,8 @@ public class OsmBaseStorage {
|
||||||
|
|
||||||
|
|
||||||
protected boolean acceptEntityToLoad(EntityId entityId, Entity entity) {
|
protected boolean acceptEntityToLoad(EntityId entityId, Entity entity) {
|
||||||
for (IOsmStorageFilter f : filters) {
|
for(IOsmStorageFilter f : filters){
|
||||||
if (!f.acceptEntityToLoad(this, entityId, entity)) {
|
if(!f.acceptEntityToLoad(this, entityId, entity)){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,259 +0,0 @@
|
||||||
package net.osmand.osm.oauth;
|
|
||||||
|
|
||||||
import com.github.scribejava.core.exceptions.OAuthException;
|
|
||||||
import com.github.scribejava.core.httpclient.HttpClient;
|
|
||||||
import com.github.scribejava.core.httpclient.jdk.JDKHttpClientConfig;
|
|
||||||
import com.github.scribejava.core.httpclient.jdk.JDKHttpFuture;
|
|
||||||
import com.github.scribejava.core.httpclient.multipart.MultipartPayload;
|
|
||||||
import com.github.scribejava.core.httpclient.multipart.MultipartUtils;
|
|
||||||
import com.github.scribejava.core.model.*;
|
|
||||||
import net.osmand.util.Algorithms;
|
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
import java.net.HttpURLConnection;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.net.UnknownHostException;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.Future;
|
|
||||||
|
|
||||||
public class OsmAndJDKHttpClient implements HttpClient {
|
|
||||||
private static final String BOUNDARY = "CowMooCowMooCowCowCow";
|
|
||||||
private final JDKHttpClientConfig config;
|
|
||||||
|
|
||||||
public OsmAndJDKHttpClient() {
|
|
||||||
this(JDKHttpClientConfig.defaultConfig());
|
|
||||||
}
|
|
||||||
|
|
||||||
public OsmAndJDKHttpClient(JDKHttpClientConfig clientConfig) {
|
|
||||||
config = clientConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void close() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T> Future<T> executeAsync(String userAgent, Map<String, String> headers, Verb httpVerb, String completeUrl,
|
|
||||||
byte[] bodyContents, OAuthAsyncRequestCallback<T> callback, OAuthRequest.ResponseConverter<T> converter) {
|
|
||||||
|
|
||||||
return doExecuteAsync(userAgent, headers, httpVerb, completeUrl, BodyType.BYTE_ARRAY, bodyContents, callback,
|
|
||||||
converter);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T> Future<T> executeAsync(String userAgent, Map<String, String> headers, Verb httpVerb, String completeUrl,
|
|
||||||
MultipartPayload bodyContents, OAuthAsyncRequestCallback<T> callback,
|
|
||||||
OAuthRequest.ResponseConverter<T> converter) {
|
|
||||||
|
|
||||||
return doExecuteAsync(userAgent, headers, httpVerb, completeUrl, BodyType.MULTIPART, bodyContents, callback,
|
|
||||||
converter);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T> Future<T> executeAsync(String userAgent, Map<String, String> headers, Verb httpVerb, String completeUrl,
|
|
||||||
String bodyContents, OAuthAsyncRequestCallback<T> callback, OAuthRequest.ResponseConverter<T> converter) {
|
|
||||||
|
|
||||||
return doExecuteAsync(userAgent, headers, httpVerb, completeUrl, BodyType.STRING, bodyContents, callback,
|
|
||||||
converter);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T> Future<T> executeAsync(String userAgent, Map<String, String> headers, Verb httpVerb, String completeUrl,
|
|
||||||
File bodyContents, OAuthAsyncRequestCallback<T> callback, OAuthRequest.ResponseConverter<T> converter) {
|
|
||||||
return doExecuteAsync(userAgent, headers, httpVerb, completeUrl, BodyType.STREAM, bodyContents, callback,
|
|
||||||
converter);
|
|
||||||
}
|
|
||||||
|
|
||||||
private <T> Future<T> doExecuteAsync(String userAgent, Map<String, String> headers, Verb httpVerb,
|
|
||||||
String completeUrl, BodyType bodyType, Object bodyContents, OAuthAsyncRequestCallback<T> callback,
|
|
||||||
OAuthRequest.ResponseConverter<T> converter) {
|
|
||||||
try {
|
|
||||||
final Response response = doExecute(userAgent, headers, httpVerb, completeUrl, bodyType, bodyContents);
|
|
||||||
@SuppressWarnings("unchecked") final T t = converter == null ? (T) response : converter.convert(response);
|
|
||||||
if (callback != null) {
|
|
||||||
callback.onCompleted(t);
|
|
||||||
}
|
|
||||||
return new JDKHttpFuture<>(t);
|
|
||||||
} catch (IOException | RuntimeException e) {
|
|
||||||
if (callback != null) {
|
|
||||||
callback.onThrowable(e);
|
|
||||||
}
|
|
||||||
return new JDKHttpFuture<>(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Response execute(String userAgent, Map<String, String> headers, Verb httpVerb, String completeUrl,
|
|
||||||
byte[] bodyContents) throws InterruptedException, ExecutionException, IOException {
|
|
||||||
return doExecute(userAgent, headers, httpVerb, completeUrl, BodyType.BYTE_ARRAY, bodyContents);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Response execute(String userAgent, Map<String, String> headers, Verb httpVerb, String completeUrl,
|
|
||||||
MultipartPayload multipartPayloads) throws InterruptedException, ExecutionException, IOException {
|
|
||||||
return doExecute(userAgent, headers, httpVerb, completeUrl, BodyType.MULTIPART, multipartPayloads);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Response execute(String userAgent, Map<String, String> headers, Verb httpVerb, String completeUrl,
|
|
||||||
String bodyContents) throws InterruptedException, ExecutionException, IOException {
|
|
||||||
return doExecute(userAgent, headers, httpVerb, completeUrl, BodyType.STRING, bodyContents);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Response execute(String userAgent, Map<String, String> headers, Verb httpVerb, String completeUrl,
|
|
||||||
File bodyContents) throws InterruptedException, ExecutionException, IOException {
|
|
||||||
return doExecute(userAgent, headers, httpVerb, completeUrl, BodyType.STREAM, bodyContents);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Response doExecute(String userAgent, Map<String, String> headers, Verb httpVerb, String completeUrl,
|
|
||||||
BodyType bodyType, Object bodyContents) throws IOException {
|
|
||||||
final URL url = new URL(completeUrl);
|
|
||||||
final HttpURLConnection connection;
|
|
||||||
if (config.getProxy() == null) {
|
|
||||||
connection = (HttpURLConnection) url.openConnection();
|
|
||||||
} else {
|
|
||||||
connection = (HttpURLConnection) url.openConnection(config.getProxy());
|
|
||||||
}
|
|
||||||
connection.setInstanceFollowRedirects(config.isFollowRedirects());
|
|
||||||
connection.setRequestMethod(httpVerb.name());
|
|
||||||
if (config.getConnectTimeout() != null) {
|
|
||||||
connection.setConnectTimeout(config.getConnectTimeout());
|
|
||||||
}
|
|
||||||
if (config.getReadTimeout() != null) {
|
|
||||||
connection.setReadTimeout(config.getReadTimeout());
|
|
||||||
}
|
|
||||||
addHeaders(connection, headers, userAgent);
|
|
||||||
if (httpVerb.isPermitBody()) {
|
|
||||||
bodyType.setBody(connection, bodyContents, httpVerb.isRequiresBody());
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
connection.connect();
|
|
||||||
final int responseCode = connection.getResponseCode();
|
|
||||||
return new Response(responseCode, connection.getResponseMessage(), parseHeaders(connection),
|
|
||||||
responseCode >= 200 && responseCode < 400 ? connection.getInputStream()
|
|
||||||
: connection.getErrorStream());
|
|
||||||
} catch (UnknownHostException e) {
|
|
||||||
throw new OAuthException("The IP address of a host could not be determined.", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private enum BodyType {
|
|
||||||
BYTE_ARRAY {
|
|
||||||
@Override
|
|
||||||
void setBody(HttpURLConnection connection, Object bodyContents, boolean requiresBody) throws IOException {
|
|
||||||
addBody(connection, (byte[]) bodyContents, requiresBody);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
STREAM {
|
|
||||||
@Override
|
|
||||||
void setBody(HttpURLConnection connection, Object bodyContents, boolean requiresBody) throws IOException {
|
|
||||||
addBody(connection, (File) bodyContents, requiresBody);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
MULTIPART {
|
|
||||||
@Override
|
|
||||||
void setBody(HttpURLConnection connection, Object bodyContents, boolean requiresBody) throws IOException {
|
|
||||||
addBody(connection, (MultipartPayload) bodyContents, requiresBody);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
STRING {
|
|
||||||
@Override
|
|
||||||
void setBody(HttpURLConnection connection, Object bodyContents, boolean requiresBody) throws IOException {
|
|
||||||
addBody(connection, ((String) bodyContents).getBytes(), requiresBody);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
abstract void setBody(HttpURLConnection connection, Object bodyContents, boolean requiresBody)
|
|
||||||
throws IOException;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Map<String, String> parseHeaders(HttpURLConnection conn) {
|
|
||||||
final Map<String, String> headers = new HashMap<>();
|
|
||||||
|
|
||||||
for (Map.Entry<String, List<String>> headerField : conn.getHeaderFields().entrySet()) {
|
|
||||||
final String key = headerField.getKey();
|
|
||||||
final String value = headerField.getValue().get(0);
|
|
||||||
if ("Content-Encoding".equalsIgnoreCase(key)) {
|
|
||||||
headers.put("Content-Encoding", value);
|
|
||||||
} else {
|
|
||||||
headers.put(key, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return headers;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void addHeaders(HttpURLConnection connection, Map<String, String> headers, String userAgent) {
|
|
||||||
for (Map.Entry<String, String> header : headers.entrySet()) {
|
|
||||||
connection.setRequestProperty(header.getKey(), header.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (userAgent != null) {
|
|
||||||
connection.setRequestProperty(OAuthConstants.USER_AGENT_HEADER_NAME, userAgent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void addBody(HttpURLConnection connection, File file, boolean requiresBody) throws IOException {
|
|
||||||
if (requiresBody) {
|
|
||||||
String filename = file.getName();
|
|
||||||
String formName = "file";
|
|
||||||
InputStream stream = new FileInputStream(file);
|
|
||||||
connection.setDoInput(true);
|
|
||||||
connection.setDoOutput(true);
|
|
||||||
connection.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + BOUNDARY); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
connection.setRequestProperty("User-Agent", "OsmAnd"); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
final OutputStream ous = connection.getOutputStream();
|
|
||||||
ous.write(("--" + BOUNDARY + "\r\n").getBytes());
|
|
||||||
ous.write(("content-disposition: form-data; name=\"" + formName + "\"; filename=\"" + filename + "\"\r\n").getBytes()); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
ous.write(("Content-Type: application/octet-stream\r\n\r\n").getBytes()); //$NON-NLS-1$
|
|
||||||
BufferedInputStream bis = new BufferedInputStream(stream, 20 * 1024);
|
|
||||||
ous.flush();
|
|
||||||
Algorithms.streamCopy(bis, ous);
|
|
||||||
ous.write(("\r\n--" + BOUNDARY + "--\r\n").getBytes()); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
ous.flush();
|
|
||||||
Algorithms.closeStream(bis);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void addBody(HttpURLConnection connection, byte[] content, boolean requiresBody) throws IOException {
|
|
||||||
final int contentLength = content.length;
|
|
||||||
if (requiresBody || contentLength > 0) {
|
|
||||||
connection.setDoOutput(true);
|
|
||||||
final OutputStream outputStream = prepareConnectionForBodyAndGetOutputStream(connection, contentLength);
|
|
||||||
if (contentLength > 0) {
|
|
||||||
outputStream.write(content);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void addBody(HttpURLConnection connection, MultipartPayload multipartPayload, boolean requiresBody)
|
|
||||||
throws IOException {
|
|
||||||
|
|
||||||
for (Map.Entry<String, String> header : multipartPayload.getHeaders().entrySet()) {
|
|
||||||
connection.setRequestProperty(header.getKey(), header.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (requiresBody) {
|
|
||||||
final ByteArrayOutputStream os = MultipartUtils.getPayload(multipartPayload);
|
|
||||||
final int contentLength = os.size();
|
|
||||||
connection.setDoOutput(true);
|
|
||||||
final OutputStream outputStream = prepareConnectionForBodyAndGetOutputStream(connection, contentLength);
|
|
||||||
if (contentLength > 0) {
|
|
||||||
os.writeTo(outputStream);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static OutputStream prepareConnectionForBodyAndGetOutputStream(HttpURLConnection connection,
|
|
||||||
int contentLength) throws IOException {
|
|
||||||
connection.setRequestProperty(CONTENT_LENGTH, String.valueOf(contentLength));
|
|
||||||
if (connection.getRequestProperty(CONTENT_TYPE) == null) {
|
|
||||||
connection.setRequestProperty(CONTENT_TYPE, DEFAULT_CONTENT_TYPE);
|
|
||||||
}
|
|
||||||
return connection.getOutputStream();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,175 +0,0 @@
|
||||||
// License: GPL. For details, see LICENSE file.
|
|
||||||
package net.osmand.osm.oauth;
|
|
||||||
|
|
||||||
import com.github.scribejava.core.builder.ServiceBuilder;
|
|
||||||
import com.github.scribejava.core.builder.api.DefaultApi10a;
|
|
||||||
import com.github.scribejava.core.builder.api.OAuth1SignatureType;
|
|
||||||
import com.github.scribejava.core.httpclient.jdk.JDKHttpClientConfig;
|
|
||||||
import com.github.scribejava.core.model.*;
|
|
||||||
import com.github.scribejava.core.oauth.OAuth10aService;
|
|
||||||
import net.osmand.PlatformUtil;
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An OAuth 1.0 authorization client.
|
|
||||||
*
|
|
||||||
* @since 2746
|
|
||||||
*/
|
|
||||||
public class OsmOAuthAuthorizationClient {
|
|
||||||
private OAuth1RequestToken requestToken;
|
|
||||||
private OAuth1AccessToken accessToken;
|
|
||||||
private final OAuth10aService service;
|
|
||||||
private final OsmAndJDKHttpClient httpClient;
|
|
||||||
public final static Log log = PlatformUtil.getLog(OsmOAuthAuthorizationClient.class);
|
|
||||||
|
|
||||||
public OsmOAuthAuthorizationClient(String key, String secret, DefaultApi10a api) {
|
|
||||||
httpClient = new OsmAndJDKHttpClient(JDKHttpClientConfig.defaultConfig());
|
|
||||||
service = new ServiceBuilder(key)
|
|
||||||
.apiSecret(secret)
|
|
||||||
.httpClient(httpClient)
|
|
||||||
.callback("osmand-oauth://example.com/oauth")
|
|
||||||
.build(api);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class OsmApi extends DefaultApi10a {
|
|
||||||
@Override
|
|
||||||
public OAuth1SignatureType getSignatureType() {
|
|
||||||
return OAuth1SignatureType.QUERY_STRING;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getRequestTokenEndpoint() {
|
|
||||||
return "https://www.openstreetmap.org/oauth/request_token";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getAccessTokenEndpoint() {
|
|
||||||
return "https://www.openstreetmap.org/oauth/access_token";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getAuthorizationBaseUrl() {
|
|
||||||
return "https://www.openstreetmap.org/oauth/authorize";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class OsmDevApi extends DefaultApi10a {
|
|
||||||
@Override
|
|
||||||
public OAuth1SignatureType getSignatureType() {
|
|
||||||
return OAuth1SignatureType.QUERY_STRING;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getRequestTokenEndpoint() {
|
|
||||||
return "https://master.apis.dev.openstreetmap.org/oauth/request_token";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getAccessTokenEndpoint() {
|
|
||||||
return "https://master.apis.dev.openstreetmap.org/oauth/access_token";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getAuthorizationBaseUrl() {
|
|
||||||
return "https://master.apis.dev.openstreetmap.org/oauth/authorize";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public OsmAndJDKHttpClient getHttpClient() {
|
|
||||||
return httpClient;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OAuth10aService getService() {
|
|
||||||
return service;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAccessToken(OAuth1AccessToken accessToken) {
|
|
||||||
this.accessToken = accessToken;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OAuth1AccessToken getAccessToken() {
|
|
||||||
return accessToken;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OAuth1RequestToken getRequestToken() {
|
|
||||||
return requestToken;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Response performRequestWithoutAuth(String url, String requestMethod, String requestBody)
|
|
||||||
throws InterruptedException, ExecutionException, IOException {
|
|
||||||
Verb verb = parseRequestMethod(requestMethod);
|
|
||||||
OAuthRequest req = new OAuthRequest(verb, url);
|
|
||||||
req.setPayload(requestBody);
|
|
||||||
return service.execute(req);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void performGetRequest(String url, OAuthAsyncRequestCallback<Response> callback) {
|
|
||||||
if (accessToken == null) {
|
|
||||||
throw new IllegalStateException("Access token is null");
|
|
||||||
}
|
|
||||||
OAuthRequest req = new OAuthRequest(Verb.GET, url);
|
|
||||||
service.signRequest(accessToken, req);
|
|
||||||
service.execute(req, callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Response performRequest(String url, String method, String body)
|
|
||||||
throws InterruptedException, ExecutionException, IOException {
|
|
||||||
service.getApi().getSignatureType();
|
|
||||||
if (accessToken == null) {
|
|
||||||
throw new IllegalStateException("Access token is null");
|
|
||||||
}
|
|
||||||
Verb verbMethod = parseRequestMethod(method);
|
|
||||||
OAuthRequest req = new OAuthRequest(verbMethod, url);
|
|
||||||
req.setPayload(body);
|
|
||||||
service.signRequest(accessToken, req);
|
|
||||||
req.addHeader("Content-Type", "application/xml");
|
|
||||||
return service.execute(req);
|
|
||||||
}
|
|
||||||
|
|
||||||
public OAuth1RequestToken startOAuth() {
|
|
||||||
try {
|
|
||||||
requestToken = service.getRequestToken();
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.error(e);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
log.error(e);
|
|
||||||
} catch (ExecutionException e) {
|
|
||||||
log.error(e);
|
|
||||||
}
|
|
||||||
return requestToken;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OAuth1AccessToken authorize(String oauthVerifier) {
|
|
||||||
try {
|
|
||||||
setAccessToken(service.getAccessToken(requestToken, oauthVerifier));
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.error(e);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
log.error(e);
|
|
||||||
} catch (ExecutionException e) {
|
|
||||||
log.error(e);
|
|
||||||
}
|
|
||||||
return accessToken;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isValidToken() {
|
|
||||||
return !(accessToken == null);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Verb parseRequestMethod(String method) {
|
|
||||||
Verb m = Verb.GET;
|
|
||||||
if (method.equals("POST")) {
|
|
||||||
m = Verb.POST;
|
|
||||||
}
|
|
||||||
if (method.equals("PUT")) {
|
|
||||||
m = Verb.PUT;
|
|
||||||
}
|
|
||||||
if (method.equals("DELETE")) {
|
|
||||||
m = Verb.DELETE;
|
|
||||||
}
|
|
||||||
return m;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -41,7 +41,7 @@ public class RenderingRule {
|
||||||
public void init(Map<String, String> attributes) {
|
public void init(Map<String, String> attributes) {
|
||||||
ArrayList<RenderingRuleProperty> props = new ArrayList<RenderingRuleProperty>(attributes.size());
|
ArrayList<RenderingRuleProperty> props = new ArrayList<RenderingRuleProperty>(attributes.size());
|
||||||
intProperties = new int[attributes.size()];
|
intProperties = new int[attributes.size()];
|
||||||
floatProperties = new float[attributes.size()];
|
floatProperties = null;
|
||||||
attributesRef = null;
|
attributesRef = null;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
Iterator<Entry<String, String>> it = attributes.entrySet().iterator();
|
Iterator<Entry<String, String>> it = attributes.entrySet().iterator();
|
||||||
|
@ -58,19 +58,20 @@ public class RenderingRule {
|
||||||
attributesRef[i] = storage.getRenderingAttributeRule(vl.substring(1));
|
attributesRef[i] = storage.getRenderingAttributeRule(vl.substring(1));
|
||||||
} else if (property.isString()) {
|
} else if (property.isString()) {
|
||||||
intProperties[i] = storage.getDictionaryValue(vl);
|
intProperties[i] = storage.getDictionaryValue(vl);
|
||||||
|
} else if (property.isFloat()) {
|
||||||
|
if (floatProperties == null) {
|
||||||
|
// lazy creates
|
||||||
|
floatProperties = new float[attributes.size()];
|
||||||
|
}
|
||||||
|
floatProperties[i] = property.parseFloatValue(vl);
|
||||||
|
intProperties[i] = property.parseIntValue(vl);
|
||||||
} else {
|
} else {
|
||||||
float floatVal = property.parseFloatValue(vl);
|
|
||||||
// if (floatProperties == null && floatVal != 0) {
|
|
||||||
// // lazy creates
|
|
||||||
// floatProperties = new float[attributes.size()];
|
|
||||||
floatProperties[i] = floatVal;
|
|
||||||
// }
|
|
||||||
intProperties[i] = property.parseIntValue(vl);
|
intProperties[i] = property.parseIntValue(vl);
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
properties = props.toArray(new RenderingRuleProperty[0]);
|
properties = props.toArray(new RenderingRuleProperty[props.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getPropertyIndex(String property){
|
private int getPropertyIndex(String property){
|
||||||
|
@ -94,7 +95,7 @@ public class RenderingRule {
|
||||||
|
|
||||||
public float getFloatPropertyValue(String property) {
|
public float getFloatPropertyValue(String property) {
|
||||||
int i = getPropertyIndex(property);
|
int i = getPropertyIndex(property);
|
||||||
if (i >= 0) {
|
if(i >= 0 && floatProperties != null){
|
||||||
return floatProperties[i];
|
return floatProperties[i];
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -155,7 +155,12 @@ public class RenderingRuleProperty {
|
||||||
try {
|
try {
|
||||||
int colon = value.indexOf(':');
|
int colon = value.indexOf(':');
|
||||||
if(colon != -1) {
|
if(colon != -1) {
|
||||||
return (int) Float.parseFloat(value.substring(colon + 1));
|
int c = 0;
|
||||||
|
if(colon > 0) {
|
||||||
|
c += (int) Float.parseFloat(value.substring(0, colon));
|
||||||
|
}
|
||||||
|
c += (int) Float.parseFloat(value.substring(colon + 1));
|
||||||
|
return c;
|
||||||
}
|
}
|
||||||
return (int) Float.parseFloat(value);
|
return (int) Float.parseFloat(value);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
|
@ -185,35 +190,30 @@ public class RenderingRuleProperty {
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
log.error("Rendering parse " + value + " in " + attrName);
|
log.error("Rendering parse " + value + " in " + attrName);
|
||||||
}
|
}
|
||||||
return 0;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public float parseFloatValue(String value) {
|
public float parseFloatValue(String value){
|
||||||
try {
|
if(type == FLOAT_TYPE){
|
||||||
if (type == FLOAT_TYPE) {
|
try {
|
||||||
int colon = value.indexOf(':');
|
int colon = value.indexOf(':');
|
||||||
if (colon != -1) {
|
if(colon != -1) {
|
||||||
if (colon > 0) {
|
if(colon > 0) {
|
||||||
return Float.parseFloat(value.substring(0, colon));
|
return Float.parseFloat(value.substring(0, colon));
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return Float.parseFloat(value);
|
return Float.parseFloat(value);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
} else if (type == INT_TYPE) {
|
log.error("Rendering parse " + value + " in " + attrName);
|
||||||
int colon = value.indexOf(':');
|
|
||||||
if (colon != -1 && colon > 0) {
|
|
||||||
return Float.parseFloat(value.substring(0, colon));
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException e) {
|
return -1;
|
||||||
log.error("Rendering parse " + value + " in " + attrName);
|
} else {
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -244,6 +244,8 @@ public class RenderingRuleStorageProperties {
|
||||||
R_TEXT_HALO_COLOR = registerRuleInternal(RenderingRuleProperty.createOutputColorProperty(TEXT_HALO_COLOR));
|
R_TEXT_HALO_COLOR = registerRuleInternal(RenderingRuleProperty.createOutputColorProperty(TEXT_HALO_COLOR));
|
||||||
R_TEXT_SIZE = registerRuleInternal(RenderingRuleProperty.createOutputFloatProperty(TEXT_SIZE));
|
R_TEXT_SIZE = registerRuleInternal(RenderingRuleProperty.createOutputFloatProperty(TEXT_SIZE));
|
||||||
R_TEXT_ORDER = registerRuleInternal(RenderingRuleProperty.createOutputIntProperty(TEXT_ORDER));
|
R_TEXT_ORDER = registerRuleInternal(RenderingRuleProperty.createOutputIntProperty(TEXT_ORDER));
|
||||||
|
R_ICON_ORDER = registerRuleInternal(RenderingRuleProperty.createOutputIntProperty(ICON_ORDER));
|
||||||
|
R_ICON_VISIBLE_SIZE = registerRuleInternal(RenderingRuleProperty.createOutputFloatProperty(ICON_VISIBLE_SIZE));
|
||||||
R_TEXT_MIN_DISTANCE = registerRuleInternal(RenderingRuleProperty.createOutputFloatProperty(TEXT_MIN_DISTANCE));
|
R_TEXT_MIN_DISTANCE = registerRuleInternal(RenderingRuleProperty.createOutputFloatProperty(TEXT_MIN_DISTANCE));
|
||||||
R_TEXT_SHIELD = registerRuleInternal(RenderingRuleProperty.createOutputStringProperty(TEXT_SHIELD));
|
R_TEXT_SHIELD = registerRuleInternal(RenderingRuleProperty.createOutputStringProperty(TEXT_SHIELD));
|
||||||
|
|
||||||
|
@ -263,9 +265,7 @@ public class RenderingRuleStorageProperties {
|
||||||
R_ICON_3 = registerRuleInternal(RenderingRuleProperty.createOutputStringProperty("icon_3"));
|
R_ICON_3 = registerRuleInternal(RenderingRuleProperty.createOutputStringProperty("icon_3"));
|
||||||
R_ICON_4 = registerRuleInternal(RenderingRuleProperty.createOutputStringProperty("icon_4"));
|
R_ICON_4 = registerRuleInternal(RenderingRuleProperty.createOutputStringProperty("icon_4"));
|
||||||
R_ICON_5 = registerRuleInternal(RenderingRuleProperty.createOutputStringProperty("icon_5"));
|
R_ICON_5 = registerRuleInternal(RenderingRuleProperty.createOutputStringProperty("icon_5"));
|
||||||
R_ICON_ORDER = registerRuleInternal(RenderingRuleProperty.createOutputIntProperty(ICON_ORDER));
|
|
||||||
R_SHIELD = registerRuleInternal(RenderingRuleProperty.createOutputStringProperty(SHIELD));
|
R_SHIELD = registerRuleInternal(RenderingRuleProperty.createOutputStringProperty(SHIELD));
|
||||||
R_ICON_VISIBLE_SIZE = registerRuleInternal(RenderingRuleProperty.createOutputFloatProperty(ICON_VISIBLE_SIZE));
|
|
||||||
|
|
||||||
// polygon/way
|
// polygon/way
|
||||||
R_COLOR = registerRuleInternal(RenderingRuleProperty.createOutputColorProperty(COLOR));
|
R_COLOR = registerRuleInternal(RenderingRuleProperty.createOutputColorProperty(COLOR));
|
||||||
|
@ -318,7 +318,7 @@ public class RenderingRuleStorageProperties {
|
||||||
}
|
}
|
||||||
|
|
||||||
public RenderingRuleProperty[] getPoperties() {
|
public RenderingRuleProperty[] getPoperties() {
|
||||||
return rules.toArray(new RenderingRuleProperty[0]);
|
return rules.toArray(new RenderingRuleProperty[rules.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<RenderingRuleProperty> getCustomRules() {
|
public List<RenderingRuleProperty> getCustomRules() {
|
||||||
|
|
|
@ -432,7 +432,8 @@ public class RenderingRulesStorage {
|
||||||
for(RenderingRule ch : caseChildren) {
|
for(RenderingRule ch : caseChildren) {
|
||||||
List<RenderingRule> apply = applyRules;
|
List<RenderingRule> apply = applyRules;
|
||||||
if(!renderingRule.getIfChildren().isEmpty()) {
|
if(!renderingRule.getIfChildren().isEmpty()) {
|
||||||
apply = new ArrayList<>(renderingRule.getIfChildren());
|
apply = new ArrayList<RenderingRule>();
|
||||||
|
apply.addAll(renderingRule.getIfChildren());
|
||||||
if(applyRules != null) {
|
if(applyRules != null) {
|
||||||
apply.addAll(applyRules);
|
apply.addAll(applyRules);
|
||||||
}
|
}
|
||||||
|
@ -491,10 +492,10 @@ public class RenderingRulesStorage {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getRenderingAttributeNames() {
|
public String[] getRenderingAttributeNames() {
|
||||||
return renderingAttributes.keySet().toArray(new String[0]);
|
return renderingAttributes.keySet().toArray(new String[renderingAttributes.size()]);
|
||||||
}
|
}
|
||||||
public RenderingRule[] getRenderingAttributeValues() {
|
public RenderingRule[] getRenderingAttributeValues() {
|
||||||
return renderingAttributes.values().toArray(new RenderingRule[0]);
|
return renderingAttributes.values().toArray(new RenderingRule[renderingAttributes.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public RenderingRule[] getRules(int state){
|
public RenderingRule[] getRules(int state){
|
||||||
|
|
|
@ -152,9 +152,9 @@ public class RenderingRulesStoragePrinter {
|
||||||
for (int i = 0; i < 15; i++) {
|
for (int i = 0; i < 15; i++) {
|
||||||
out.println("" + indent + ti + "RenderingRule rule" + i + " = null;");
|
out.println("" + indent + ti + "RenderingRule rule" + i + " = null;");
|
||||||
}
|
}
|
||||||
for (Entry<String, RenderingRule> entry : storage.renderingAttributes.entrySet()) {
|
for (String s : storage.renderingAttributes.keySet()) {
|
||||||
generateRenderingRule(storage, out, indent + ti, "rule", 0, entry.getValue());
|
generateRenderingRule(storage, out, indent + ti, "rule", 0, storage.renderingAttributes.get(s));
|
||||||
out.println("" + indent + ti + "storage.renderingAttributes.put(" + javaString(entry.getKey()) + ", rule0);");
|
out.println("" + indent + ti + "storage.renderingAttributes.put(" + javaString(s) + ", rule0);");
|
||||||
}
|
}
|
||||||
out.println(""+indent +"}");
|
out.println(""+indent +"}");
|
||||||
}
|
}
|
||||||
|
@ -221,7 +221,7 @@ public class RenderingRulesStoragePrinter {
|
||||||
mp+=", ";
|
mp+=", ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(mp.isEmpty()) {
|
if(mp.equals("")) {
|
||||||
mp = "java.util.Collections.EMPTY_MAP";
|
mp = "java.util.Collections.EMPTY_MAP";
|
||||||
} else {
|
} else {
|
||||||
mp = "createMap(" +mp +")";
|
mp = "createMap(" +mp +")";
|
||||||
|
@ -242,9 +242,9 @@ public class RenderingRulesStoragePrinter {
|
||||||
|
|
||||||
private void printJavaInitConstants(RenderingRulesStorage storage, PrintStream out, String indent, String ti) {
|
private void printJavaInitConstants(RenderingRulesStorage storage, PrintStream out, String indent, String ti) {
|
||||||
out.println("\n" + indent + "public void initConstants() {");
|
out.println("\n" + indent + "public void initConstants() {");
|
||||||
for (Entry<String, String> entry : storage.renderingConstants.entrySet()) {
|
for (String s : storage.renderingConstants.keySet()) {
|
||||||
out.println("" + indent + ti + "storage.renderingConstants.put(" + javaString(entry.getKey()) + ", "
|
out.println("" + indent + ti + "storage.renderingConstants.put(" + javaString(s) + ", "
|
||||||
+ javaString(entry.getValue()) + ");");
|
+ javaString(storage.renderingConstants.get(s)) + ");");
|
||||||
}
|
}
|
||||||
out.println(""+indent +"}");
|
out.println(""+indent +"}");
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,7 @@ public class RenderingRulesTransformer {
|
||||||
for (int i = 0; i < nl.getLength();) {
|
for (int i = 0; i < nl.getLength();) {
|
||||||
Element app = (Element) nl.item(i);
|
Element app = (Element) nl.item(i);
|
||||||
String pt = app.getAttribute("pattern");
|
String pt = app.getAttribute("pattern");
|
||||||
if (!pt.isEmpty()) {
|
if (!pt.equals("")) {
|
||||||
if (!patterns.containsKey(pt)) {
|
if (!patterns.containsKey(pt)) {
|
||||||
throw new IllegalStateException("Pattern '" + pt + "' is not defined");
|
throw new IllegalStateException("Pattern '" + pt + "' is not defined");
|
||||||
}
|
}
|
||||||
|
|
|
@ -533,19 +533,16 @@ public class BinaryRoutePlanner {
|
||||||
long fid = to.getRoad().getId();
|
long fid = to.getRoad().getId();
|
||||||
for (int i = 0; i < from.getRoad().getRestrictionLength(); i++) {
|
for (int i = 0; i < from.getRoad().getRestrictionLength(); i++) {
|
||||||
long id = from.getRoad().getRestrictionId(i);
|
long id = from.getRoad().getRestrictionId(i);
|
||||||
int tp = from.getRoad().getRestrictionType(i);
|
|
||||||
if (fid == id) {
|
if (fid == id) {
|
||||||
if (tp == MapRenderingTypes.RESTRICTION_NO_LEFT_TURN
|
int tp = from.getRoad().getRestrictionType(i);
|
||||||
|| tp == MapRenderingTypes.RESTRICTION_NO_RIGHT_TURN
|
if (tp == MapRenderingTypes.RESTRICTION_NO_LEFT_TURN ||
|
||||||
|| tp == MapRenderingTypes.RESTRICTION_NO_STRAIGHT_ON
|
tp == MapRenderingTypes.RESTRICTION_NO_RIGHT_TURN ||
|
||||||
|| tp == MapRenderingTypes.RESTRICTION_NO_U_TURN) {
|
tp == MapRenderingTypes.RESTRICTION_NO_STRAIGHT_ON ||
|
||||||
|
tp == MapRenderingTypes.RESTRICTION_NO_U_TURN) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (tp == MapRenderingTypes.RESTRICTION_ONLY_STRAIGHT_ON) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -650,36 +647,24 @@ public class BinaryRoutePlanner {
|
||||||
int type = -1;
|
int type = -1;
|
||||||
if (!reverseWay) {
|
if (!reverseWay) {
|
||||||
for (int i = 0; i < road.getRestrictionLength(); i++) {
|
for (int i = 0; i < road.getRestrictionLength(); i++) {
|
||||||
int rt = road.getRestrictionType(i);
|
|
||||||
long rv = road.getRestrictionVia(i);
|
|
||||||
if (road.getRestrictionId(i) == next.road.id) {
|
if (road.getRestrictionId(i) == next.road.id) {
|
||||||
if (!via || rv == viaId) {
|
if(!via || road.getRestrictionVia(i) == viaId) {
|
||||||
type = rt;
|
type = road.getRestrictionType(i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (rv == viaId && via && rt == MapRenderingTypes.RESTRICTION_ONLY_STRAIGHT_ON) {
|
|
||||||
type = MapRenderingTypes.RESTRICTION_NO_STRAIGHT_ON;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < next.road.getRestrictionLength(); i++) {
|
for (int i = 0; i < next.road.getRestrictionLength(); i++) {
|
||||||
int rt = next.road.getRestrictionType(i);
|
int rt = next.road.getRestrictionType(i);
|
||||||
long rv = next.road.getRestrictionVia(i);
|
|
||||||
long restrictedTo = next.road.getRestrictionId(i);
|
long restrictedTo = next.road.getRestrictionId(i);
|
||||||
if (restrictedTo == road.id) {
|
if (restrictedTo == road.id) {
|
||||||
if (!via || rv == viaId) {
|
if(!via || next.road.getRestrictionVia(i) == viaId) {
|
||||||
type = rt;
|
type = rt;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rv == viaId && via && rt == MapRenderingTypes.RESTRICTION_ONLY_STRAIGHT_ON) {
|
|
||||||
type = MapRenderingTypes.RESTRICTION_NO_STRAIGHT_ON;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if there is restriction only to the other than current road
|
// Check if there is restriction only to the other than current road
|
||||||
if (rt == MapRenderingTypes.RESTRICTION_ONLY_RIGHT_TURN || rt == MapRenderingTypes.RESTRICTION_ONLY_LEFT_TURN
|
if (rt == MapRenderingTypes.RESTRICTION_ONLY_RIGHT_TURN || rt == MapRenderingTypes.RESTRICTION_ONLY_LEFT_TURN
|
||||||
|| rt == MapRenderingTypes.RESTRICTION_ONLY_STRAIGHT_ON) {
|
|| rt == MapRenderingTypes.RESTRICTION_ONLY_STRAIGHT_ON) {
|
||||||
|
|
|
@ -63,9 +63,9 @@ public class GeneralRouter implements VehicleRouter {
|
||||||
|
|
||||||
// cached values
|
// cached values
|
||||||
private boolean restrictionsAware = true;
|
private boolean restrictionsAware = true;
|
||||||
private float sharpTurn;
|
private float leftTurn;
|
||||||
private float roundaboutTurn;
|
private float roundaboutTurn;
|
||||||
private float slightTurn;
|
private float rightTurn;
|
||||||
// speed in m/s
|
// speed in m/s
|
||||||
private float minSpeed = 0.28f;
|
private float minSpeed = 0.28f;
|
||||||
// speed in m/s
|
// speed in m/s
|
||||||
|
@ -220,19 +220,19 @@ public class GeneralRouter implements VehicleRouter {
|
||||||
|
|
||||||
public void addAttribute(String k, String v) {
|
public void addAttribute(String k, String v) {
|
||||||
attributes.put(k, v);
|
attributes.put(k, v);
|
||||||
if (k.equals("restrictionsAware")) {
|
if(k.equals("restrictionsAware")) {
|
||||||
restrictionsAware = parseSilentBoolean(v, restrictionsAware);
|
restrictionsAware = parseSilentBoolean(v, restrictionsAware);
|
||||||
} else if (k.equals("sharpTurn") || k.equals("leftTurn")) {
|
} else if(k.equals("leftTurn")) {
|
||||||
sharpTurn = parseSilentFloat(v, sharpTurn);
|
leftTurn = parseSilentFloat(v, leftTurn);
|
||||||
} else if (k.equals("slightTurn") || k.equals("rightTurn")) {
|
} else if(k.equals("rightTurn")) {
|
||||||
slightTurn = parseSilentFloat(v, slightTurn);
|
rightTurn = parseSilentFloat(v, rightTurn);
|
||||||
} else if (k.equals("roundaboutTurn")) {
|
} else if(k.equals("roundaboutTurn")) {
|
||||||
roundaboutTurn = parseSilentFloat(v, roundaboutTurn);
|
roundaboutTurn = parseSilentFloat(v, roundaboutTurn);
|
||||||
} else if (k.equals("minDefaultSpeed") || k.equals("defaultSpeed")) {
|
} else if(k.equals("minDefaultSpeed") || k.equals("defaultSpeed")) {
|
||||||
defaultSpeed = parseSilentFloat(v, defaultSpeed * 3.6f) / 3.6f;
|
defaultSpeed = parseSilentFloat(v, defaultSpeed * 3.6f) / 3.6f;
|
||||||
} else if (k.equals("minSpeed")) {
|
} else if( k.equals("minSpeed")) {
|
||||||
minSpeed = parseSilentFloat(v, minSpeed * 3.6f) / 3.6f;
|
minSpeed = parseSilentFloat(v, minSpeed * 3.6f) / 3.6f;
|
||||||
} else if (k.equals("maxDefaultSpeed") || k.equals("maxSpeed")) {
|
} else if(k.equals("maxDefaultSpeed") || k.equals("maxSpeed")) {
|
||||||
maxSpeed = parseSilentFloat(v, maxSpeed * 3.6f) / 3.6f;
|
maxSpeed = parseSilentFloat(v, maxSpeed * 3.6f) / 3.6f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -605,11 +605,11 @@ public class GeneralRouter implements VehicleRouter {
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getLeftTurn() {
|
public double getLeftTurn() {
|
||||||
return sharpTurn;
|
return leftTurn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getRightTurn() {
|
public double getRightTurn() {
|
||||||
return slightTurn;
|
return rightTurn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getRoundaboutTurn() {
|
public double getRoundaboutTurn() {
|
||||||
|
@ -620,11 +620,9 @@ public class GeneralRouter implements VehicleRouter {
|
||||||
public double calculateTurnTime(RouteSegment segment, int segmentEnd, RouteSegment prev, int prevSegmentEnd) {
|
public double calculateTurnTime(RouteSegment segment, int segmentEnd, RouteSegment prev, int prevSegmentEnd) {
|
||||||
float ts = getPenaltyTransition(segment.getRoad());
|
float ts = getPenaltyTransition(segment.getRoad());
|
||||||
float prevTs = getPenaltyTransition(prev.getRoad());
|
float prevTs = getPenaltyTransition(prev.getRoad());
|
||||||
float totalPenalty = 0;
|
if(prevTs != ts) {
|
||||||
if (prevTs != ts) {
|
return Math.abs(ts - prevTs) / 2;
|
||||||
totalPenalty += Math.abs(ts - prevTs) / 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// int[] pt = prev.getRoad().getPointTypes(prevSegmentEnd);
|
// int[] pt = prev.getRoad().getPointTypes(prevSegmentEnd);
|
||||||
// if(pt != null) {
|
// if(pt != null) {
|
||||||
// RouteRegion reg = prev.getRoad().region;
|
// RouteRegion reg = prev.getRoad().region;
|
||||||
|
@ -636,28 +634,27 @@ public class GeneralRouter implements VehicleRouter {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
if (shortestRoute) {
|
|
||||||
return totalPenalty;
|
|
||||||
}
|
|
||||||
if(segment.getRoad().roundabout() && !prev.getRoad().roundabout()) {
|
if(segment.getRoad().roundabout() && !prev.getRoad().roundabout()) {
|
||||||
double rt = getRoundaboutTurn();
|
double rt = getRoundaboutTurn();
|
||||||
if(rt > 0) {
|
if(rt > 0) {
|
||||||
totalPenalty += rt;
|
return rt;
|
||||||
}
|
}
|
||||||
} else if (getLeftTurn() > 0 || getRightTurn() > 0) {
|
}
|
||||||
double a1 = segment.getRoad().directionRoute(segment.getSegmentStart(),
|
if (getLeftTurn() > 0 || getRightTurn() > 0) {
|
||||||
segment.getSegmentStart() < segmentEnd);
|
double a1 = segment.getRoad().directionRoute(segment.getSegmentStart(), segment.getSegmentStart() < segmentEnd);
|
||||||
double a2 = prev.getRoad().directionRoute(prevSegmentEnd, prevSegmentEnd < prev.getSegmentStart());
|
double a2 = prev.getRoad().directionRoute(prevSegmentEnd, prevSegmentEnd < prev.getSegmentStart());
|
||||||
double diff = Math.abs(MapUtils.alignAngleDifference(a1 - a2 - Math.PI));
|
double diff = Math.abs(MapUtils.alignAngleDifference(a1 - a2 - Math.PI));
|
||||||
// more like UT
|
// more like UT
|
||||||
if (diff > 2 * Math.PI / 3) {
|
if (diff > 2 * Math.PI / 3) {
|
||||||
totalPenalty += getLeftTurn();
|
return getLeftTurn();
|
||||||
} else if (diff > Math.PI / 3) {
|
} else if (diff > Math.PI / 3) {
|
||||||
totalPenalty += getRightTurn();
|
return getRightTurn();
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
return totalPenalty;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -757,21 +754,21 @@ public class GeneralRouter implements VehicleRouter {
|
||||||
}
|
}
|
||||||
|
|
||||||
public RouteAttributeEvalRule[] getRules() {
|
public RouteAttributeEvalRule[] getRules() {
|
||||||
return rules.toArray(new RouteAttributeEvalRule[0]);
|
return rules.toArray(new RouteAttributeEvalRule[rules.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getParamKeys() {
|
public String[] getParamKeys() {
|
||||||
if(paramContext == null) {
|
if(paramContext == null) {
|
||||||
return new String[0];
|
return new String[0];
|
||||||
}
|
}
|
||||||
return paramContext.vars.keySet().toArray(new String[0]);
|
return paramContext.vars.keySet().toArray(new String[paramContext.vars.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getParamValues() {
|
public String[] getParamValues() {
|
||||||
if(paramContext == null) {
|
if(paramContext == null) {
|
||||||
return new String[0];
|
return new String[0];
|
||||||
}
|
}
|
||||||
return paramContext.vars.values().toArray(new String[0]);
|
return paramContext.vars.values().toArray(new String[paramContext.vars.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object evaluate(RouteDataObject ro) {
|
private Object evaluate(RouteDataObject ro) {
|
||||||
|
@ -991,19 +988,19 @@ public class GeneralRouter implements VehicleRouter {
|
||||||
|
|
||||||
|
|
||||||
public RouteAttributeExpression[] getExpressions() {
|
public RouteAttributeExpression[] getExpressions() {
|
||||||
return expressions.toArray(new RouteAttributeExpression[0]);
|
return expressions.toArray(new RouteAttributeExpression[expressions.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getParameters() {
|
public String[] getParameters() {
|
||||||
return parameters.toArray(new String[0]);
|
return parameters.toArray(new String[parameters.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getTagValueCondDefTag() {
|
public String[] getTagValueCondDefTag() {
|
||||||
return tagValueCondDefTag.toArray(new String[0]);
|
return tagValueCondDefTag.toArray(new String[tagValueCondDefTag.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getTagValueCondDefValue() {
|
public String[] getTagValueCondDefValue() {
|
||||||
return tagValueCondDefValue.toArray(new String[0]);
|
return tagValueCondDefValue.toArray(new String[tagValueCondDefValue.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean[] getTagValueCondDefNot() {
|
public boolean[] getTagValueCondDefNot() {
|
||||||
|
|
|
@ -1,501 +0,0 @@
|
||||||
package net.osmand.router;
|
|
||||||
|
|
||||||
import net.osmand.GPXUtilities.GPXFile;
|
|
||||||
import net.osmand.GPXUtilities.GPXTrackAnalysis;
|
|
||||||
import net.osmand.GPXUtilities.Track;
|
|
||||||
import net.osmand.GPXUtilities.TrkSegment;
|
|
||||||
import net.osmand.GPXUtilities.WptPt;
|
|
||||||
import net.osmand.PlatformUtil;
|
|
||||||
import net.osmand.osm.edit.Node;
|
|
||||||
import net.osmand.osm.edit.OsmMapUtils;
|
|
||||||
import net.osmand.util.Algorithms;
|
|
||||||
import net.osmand.util.MapUtils;
|
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class RouteColorize {
|
|
||||||
|
|
||||||
public int zoom;
|
|
||||||
public double[] latitudes;
|
|
||||||
public double[] longitudes;
|
|
||||||
public double[] values;
|
|
||||||
public double minValue;
|
|
||||||
public double maxValue;
|
|
||||||
public double[][] palette;
|
|
||||||
|
|
||||||
private List<RouteColorizationPoint> dataList;
|
|
||||||
|
|
||||||
public static final int DARK_GREY = rgbaToDecimal(92, 92, 92, 255);
|
|
||||||
public static final int LIGHT_GREY = rgbaToDecimal(200, 200, 200, 255);
|
|
||||||
public static final int GREEN = rgbaToDecimal(90, 220, 95, 255);
|
|
||||||
public static final int YELLOW = rgbaToDecimal(212, 239, 50, 255);
|
|
||||||
public static final int RED = rgbaToDecimal(243, 55, 77, 255);
|
|
||||||
public static final int[] colors = new int[] {GREEN, YELLOW, RED};
|
|
||||||
|
|
||||||
private static final float DEFAULT_BASE = 17.2f;
|
|
||||||
private static final int MAX_SLOPE_VALUE = 25;
|
|
||||||
|
|
||||||
public enum ColorizationType {
|
|
||||||
ELEVATION,
|
|
||||||
SPEED,
|
|
||||||
SLOPE,
|
|
||||||
NONE
|
|
||||||
}
|
|
||||||
|
|
||||||
private final int VALUE_INDEX = 0;
|
|
||||||
private final int DECIMAL_COLOR_INDEX = 1;//sRGB decimal format
|
|
||||||
private final int RED_COLOR_INDEX = 1;//RGB
|
|
||||||
private final int GREEN_COLOR_INDEX = 2;//RGB
|
|
||||||
private final int BLUE_COLOR_INDEX = 3;//RGB
|
|
||||||
private final int ALPHA_COLOR_INDEX = 4;//RGBA
|
|
||||||
|
|
||||||
private ColorizationType colorizationType;
|
|
||||||
|
|
||||||
public static int SLOPE_RANGE = 150;//150 meters
|
|
||||||
private static final double MIN_DIFFERENCE_SLOPE = 0.05d;//5%
|
|
||||||
|
|
||||||
private static final Log LOG = PlatformUtil.getLog(RouteColorize.class);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param minValue can be NaN
|
|
||||||
* @param maxValue can be NaN
|
|
||||||
* @param palette array {{value,color},...} - color in sRGB (decimal) format OR {{value,RED,GREEN,BLUE,ALPHA},...} - color in RGBA format
|
|
||||||
*/
|
|
||||||
public RouteColorize(int zoom, double[] latitudes, double[] longitudes, double[] values, double minValue, double maxValue, double[][] palette) {
|
|
||||||
this.zoom = zoom;
|
|
||||||
this.latitudes = latitudes;
|
|
||||||
this.longitudes = longitudes;
|
|
||||||
this.values = values;
|
|
||||||
this.minValue = minValue;
|
|
||||||
this.maxValue = maxValue;
|
|
||||||
this.palette = palette;
|
|
||||||
|
|
||||||
if (Double.isNaN(minValue) || Double.isNaN(maxValue)) {
|
|
||||||
calculateMinMaxValue();
|
|
||||||
}
|
|
||||||
checkPalette();
|
|
||||||
sortPalette();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param type ELEVATION, SPEED, SLOPE
|
|
||||||
*/
|
|
||||||
public RouteColorize(int zoom, GPXFile gpxFile, ColorizationType type) {
|
|
||||||
this(zoom, gpxFile, null, type, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public RouteColorize(int zoom, GPXFile gpxFile, GPXTrackAnalysis analysis, ColorizationType type, float maxProfileSpeed) {
|
|
||||||
|
|
||||||
if (!gpxFile.hasTrkPt()) {
|
|
||||||
LOG.warn("GPX file is not consist of track points");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Double> latList = new ArrayList<>();
|
|
||||||
List<Double> lonList = new ArrayList<>();
|
|
||||||
List<Double> valList = new ArrayList<>();
|
|
||||||
int wptIdx = 0;
|
|
||||||
|
|
||||||
if (analysis == null) {
|
|
||||||
analysis = Algorithms.isEmpty(gpxFile.path)
|
|
||||||
? gpxFile.getAnalysis(System.currentTimeMillis())
|
|
||||||
: gpxFile.getAnalysis(gpxFile.modifiedTime);
|
|
||||||
}
|
|
||||||
for (Track t : gpxFile.tracks) {
|
|
||||||
for (TrkSegment ts : t.segments) {
|
|
||||||
if (ts.generalSegment || ts.points.size() < 2) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (WptPt p : ts.points) {
|
|
||||||
latList.add(p.lat);
|
|
||||||
lonList.add(p.lon);
|
|
||||||
if (type == ColorizationType.SPEED) {
|
|
||||||
valList.add((double) analysis.speedData.get(wptIdx).speed);
|
|
||||||
} else {
|
|
||||||
valList.add((double) analysis.elevationData.get(wptIdx).elevation);
|
|
||||||
}
|
|
||||||
wptIdx++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.zoom = zoom;
|
|
||||||
colorizationType = type;
|
|
||||||
latitudes = listToArray(latList);
|
|
||||||
longitudes = listToArray(lonList);
|
|
||||||
|
|
||||||
if (type == ColorizationType.SLOPE) {
|
|
||||||
values = calculateSlopesByElevations(latitudes, longitudes, listToArray(valList), SLOPE_RANGE);
|
|
||||||
} else {
|
|
||||||
values = listToArray(valList);
|
|
||||||
}
|
|
||||||
calculateMinMaxValue();
|
|
||||||
maxValue = getMaxValue(colorizationType, analysis, minValue, maxProfileSpeed);
|
|
||||||
checkPalette();
|
|
||||||
sortPalette();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Calculate slopes from elevations needs for right colorizing
|
|
||||||
*
|
|
||||||
* @param slopeRange - in what range calculate the derivative, usually we used 150 meters
|
|
||||||
* @return slopes array, in the begin and the end present NaN values!
|
|
||||||
*/
|
|
||||||
public double[] calculateSlopesByElevations(double[] latitudes, double[] longitudes, double[] elevations, double slopeRange) {
|
|
||||||
|
|
||||||
double[] newElevations = elevations;
|
|
||||||
for (int i = 2; i < elevations.length - 2; i++) {
|
|
||||||
newElevations[i] = elevations[i - 2]
|
|
||||||
+ elevations[i - 1]
|
|
||||||
+ elevations[i]
|
|
||||||
+ elevations[i + 1]
|
|
||||||
+ elevations[i + 2];
|
|
||||||
newElevations[i] /= 5;
|
|
||||||
}
|
|
||||||
elevations = newElevations;
|
|
||||||
|
|
||||||
double[] slopes = new double[elevations.length];
|
|
||||||
if (latitudes.length != longitudes.length || latitudes.length != elevations.length) {
|
|
||||||
LOG.warn("Sizes of arrays latitudes, longitudes and values are not match");
|
|
||||||
return slopes;
|
|
||||||
}
|
|
||||||
|
|
||||||
double[] distances = new double[elevations.length];
|
|
||||||
double totalDistance = 0.0d;
|
|
||||||
distances[0] = totalDistance;
|
|
||||||
for (int i = 0; i < elevations.length - 1; i++) {
|
|
||||||
totalDistance += MapUtils.getDistance(latitudes[i], longitudes[i], latitudes[i + 1], longitudes[i + 1]);
|
|
||||||
distances[i + 1] = totalDistance;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < elevations.length; i++) {
|
|
||||||
if (distances[i] < slopeRange / 2 || distances[i] > totalDistance - slopeRange / 2) {
|
|
||||||
slopes[i] = Double.NaN;
|
|
||||||
} else {
|
|
||||||
double[] arg = findDerivativeArguments(distances, elevations, i, slopeRange);
|
|
||||||
slopes[i] = (arg[1] - arg[0]) / (arg[3] - arg[2]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return slopes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<RouteColorizationPoint> getResult(boolean simplify) {
|
|
||||||
List<RouteColorizationPoint> result = new ArrayList<>();
|
|
||||||
if (simplify) {
|
|
||||||
result = simplify(zoom);
|
|
||||||
} else {
|
|
||||||
for (int i = 0; i < latitudes.length; i++) {
|
|
||||||
result.add(new RouteColorizationPoint(i, latitudes[i], longitudes[i], values[i]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (RouteColorizationPoint data : result) {
|
|
||||||
data.color = getColorByValue(data.val);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getColorByValue(double value) {
|
|
||||||
if (Double.isNaN(value)) {
|
|
||||||
value = colorizationType == ColorizationType.SLOPE ? minValue : (minValue + maxValue) / 2;
|
|
||||||
}
|
|
||||||
for (int i = 0; i < palette.length - 1; i++) {
|
|
||||||
if (value == palette[i][VALUE_INDEX])
|
|
||||||
return (int) palette[i][DECIMAL_COLOR_INDEX];
|
|
||||||
if (value >= palette[i][VALUE_INDEX] && value <= palette[i + 1][VALUE_INDEX]) {
|
|
||||||
int minPaletteColor = (int) palette[i][DECIMAL_COLOR_INDEX];
|
|
||||||
int maxPaletteColor = (int) palette[i + 1][DECIMAL_COLOR_INDEX];
|
|
||||||
double minPaletteValue = palette[i][VALUE_INDEX];
|
|
||||||
double maxPaletteValue = palette[i + 1][VALUE_INDEX];
|
|
||||||
double percent = (value - minPaletteValue) / (maxPaletteValue - minPaletteValue);
|
|
||||||
double resultRed = getRed(minPaletteColor) + percent * (getRed(maxPaletteColor) - getRed(minPaletteColor));
|
|
||||||
double resultGreen = getGreen(minPaletteColor) + percent * (getGreen(maxPaletteColor) - getGreen(minPaletteColor));
|
|
||||||
double resultBlue = getBlue(minPaletteColor) + percent * (getBlue(maxPaletteColor) - getBlue(minPaletteColor));
|
|
||||||
double resultAlpha = getAlpha(minPaletteColor) + percent * (getAlpha(maxPaletteColor) - getAlpha(minPaletteColor));
|
|
||||||
return rgbaToDecimal((int) resultRed, (int) resultGreen, (int) resultBlue, (int) resultAlpha);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return getTransparentColor();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPalette(double[][] palette) {
|
|
||||||
this.palette = palette;
|
|
||||||
checkPalette();
|
|
||||||
sortPalette();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPalette(int[] gradientPalette) {
|
|
||||||
if (gradientPalette == null || gradientPalette.length != 3) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
setPalette(new double[][] {
|
|
||||||
{minValue, gradientPalette[0]},
|
|
||||||
{(minValue + maxValue) / 2, gradientPalette[1]},
|
|
||||||
{maxValue, gradientPalette[2]}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getTransparentColor() {
|
|
||||||
return rgbaToDecimal(0, 0, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<RouteColorizationPoint> simplify(int zoom) {
|
|
||||||
if (dataList == null) {
|
|
||||||
dataList = new ArrayList<>();
|
|
||||||
for (int i = 0; i < latitudes.length; i++) {
|
|
||||||
dataList.add(new RouteColorizationPoint(i, latitudes[i], longitudes[i], values[i]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
List<Node> nodes = new ArrayList<>();
|
|
||||||
List<Node> result = new ArrayList<>();
|
|
||||||
for (RouteColorizationPoint data : dataList) {
|
|
||||||
nodes.add(new net.osmand.osm.edit.Node(data.lat, data.lon, data.id));
|
|
||||||
}
|
|
||||||
|
|
||||||
double epsilon = Math.pow(2.0, DEFAULT_BASE - zoom);
|
|
||||||
result.add(nodes.get(0));
|
|
||||||
OsmMapUtils.simplifyDouglasPeucker(nodes, 0, nodes.size() - 1, result, epsilon);
|
|
||||||
|
|
||||||
List<RouteColorizationPoint> simplified = new ArrayList<>();
|
|
||||||
for (int i = 1; i < result.size(); i++) {
|
|
||||||
int prevId = (int) result.get(i - 1).getId();
|
|
||||||
int currentId = (int) result.get(i).getId();
|
|
||||||
List<RouteColorizationPoint> sublist = dataList.subList(prevId, currentId);
|
|
||||||
simplified.addAll(getExtremums(sublist));
|
|
||||||
}
|
|
||||||
Node lastSurvivedPoint = result.get(result.size() - 1);
|
|
||||||
simplified.add(dataList.get((int) lastSurvivedPoint.getId()));
|
|
||||||
return simplified;
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<RouteColorizationPoint> getExtremums(List<RouteColorizationPoint> subDataList) {
|
|
||||||
if (subDataList.size() <= 2) {
|
|
||||||
return subDataList;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<RouteColorizationPoint> result = new ArrayList<>();
|
|
||||||
double min;
|
|
||||||
double max;
|
|
||||||
min = max = subDataList.get(0).val;
|
|
||||||
for (RouteColorizationPoint pt : subDataList) {
|
|
||||||
if (min > pt.val) {
|
|
||||||
min = pt.val;
|
|
||||||
}
|
|
||||||
if (max < pt.val) {
|
|
||||||
max = pt.val;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
double diff = max - min;
|
|
||||||
|
|
||||||
result.add(subDataList.get(0));
|
|
||||||
for (int i = 1; i < subDataList.size() - 1; i++) {
|
|
||||||
double prev = subDataList.get(i - 1).val;
|
|
||||||
double current = subDataList.get(i).val;
|
|
||||||
double next = subDataList.get(i + 1).val;
|
|
||||||
RouteColorizationPoint currentData = subDataList.get(i);
|
|
||||||
|
|
||||||
if ((current > prev && current > next) || (current < prev && current < next)
|
|
||||||
|| (current < prev && current == next) || (current == prev && current < next)
|
|
||||||
|| (current > prev && current == next) || (current == prev && current > next)) {
|
|
||||||
RouteColorizationPoint prevInResult;
|
|
||||||
if (result.size() > 0) {
|
|
||||||
prevInResult = result.get(0);
|
|
||||||
if (prevInResult.val / diff > MIN_DIFFERENCE_SLOPE) {
|
|
||||||
result.add(currentData);
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
result.add(currentData);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
result.add(subDataList.get(subDataList.size() - 1));
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void checkPalette() {
|
|
||||||
if (palette == null || palette.length < 2 || palette[0].length < 2 || palette[1].length < 2) {
|
|
||||||
LOG.info("Will use default palette");
|
|
||||||
palette = new double[3][2];
|
|
||||||
|
|
||||||
double[][] defaultPalette = {
|
|
||||||
{minValue, GREEN},
|
|
||||||
{(minValue + maxValue) / 2, YELLOW},
|
|
||||||
{maxValue, RED}
|
|
||||||
};
|
|
||||||
palette = defaultPalette;
|
|
||||||
}
|
|
||||||
double min;
|
|
||||||
double max = min = palette[0][VALUE_INDEX];
|
|
||||||
int minIndex = 0;
|
|
||||||
int maxIndex = 0;
|
|
||||||
double[][] sRGBPalette = new double[palette.length][2];
|
|
||||||
for (int i = 0; i < palette.length; i++) {
|
|
||||||
double[] p = palette[i];
|
|
||||||
if (p.length == 2) {
|
|
||||||
sRGBPalette[i] = p;
|
|
||||||
} else if (p.length == 4) {
|
|
||||||
int color = rgbaToDecimal((int) p[RED_COLOR_INDEX], (int) p[GREEN_COLOR_INDEX], (int) p[BLUE_COLOR_INDEX], 255);
|
|
||||||
sRGBPalette[i] = new double[]{p[VALUE_INDEX], color};
|
|
||||||
} else if (p.length >= 5) {
|
|
||||||
int color = rgbaToDecimal((int) p[RED_COLOR_INDEX], (int) p[GREEN_COLOR_INDEX], (int) p[BLUE_COLOR_INDEX], (int) p[ALPHA_COLOR_INDEX]);
|
|
||||||
sRGBPalette[i] = new double[]{p[VALUE_INDEX], color};
|
|
||||||
}
|
|
||||||
if (p[VALUE_INDEX] > max) {
|
|
||||||
max = p[VALUE_INDEX];
|
|
||||||
maxIndex = i;
|
|
||||||
}
|
|
||||||
if (p[VALUE_INDEX] < min) {
|
|
||||||
min = p[VALUE_INDEX];
|
|
||||||
minIndex = i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
palette = sRGBPalette;
|
|
||||||
if (minValue < min) {
|
|
||||||
palette[minIndex][VALUE_INDEX] = minValue;
|
|
||||||
}
|
|
||||||
if (maxValue > max) {
|
|
||||||
palette[maxIndex][VALUE_INDEX] = maxValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void sortPalette() {
|
|
||||||
java.util.Arrays.sort(palette, new java.util.Comparator<double[]>() {
|
|
||||||
public int compare(double[] a, double[] b) {
|
|
||||||
return Double.compare(a[VALUE_INDEX], b[VALUE_INDEX]);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return double[minElevation, maxElevation, minDist, maxDist]
|
|
||||||
*/
|
|
||||||
private double[] findDerivativeArguments(double[] distances, double[] elevations, int index, double slopeRange) {
|
|
||||||
double[] result = new double[4];
|
|
||||||
double minDist = distances[index] - slopeRange / 2;
|
|
||||||
double maxDist = distances[index] + slopeRange / 2;
|
|
||||||
result[0] = Double.NaN;
|
|
||||||
result[1] = Double.NaN;
|
|
||||||
result[2] = minDist;
|
|
||||||
result[3] = maxDist;
|
|
||||||
int closestMaxIndex = -1;
|
|
||||||
int closestMinIndex = -1;
|
|
||||||
for (int i = index; i < distances.length; i++) {
|
|
||||||
if (distances[i] == maxDist) {
|
|
||||||
result[1] = elevations[i];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (distances[i] > maxDist) {
|
|
||||||
closestMaxIndex = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int i = index; i >= 0; i--) {
|
|
||||||
if (distances[i] == minDist) {
|
|
||||||
result[0] = elevations[i];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (distances[i] < minDist) {
|
|
||||||
closestMinIndex = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (closestMaxIndex > 0) {
|
|
||||||
double diff = distances[closestMaxIndex] - distances[closestMaxIndex - 1];
|
|
||||||
double coef = (maxDist - distances[closestMaxIndex - 1]) / diff;
|
|
||||||
if (coef > 1 || coef < 0) {
|
|
||||||
LOG.warn("Coefficient fo max must be 0..1 , coef=" + coef);
|
|
||||||
}
|
|
||||||
result[1] = (1 - coef) * elevations[closestMaxIndex - 1] + coef * elevations[closestMaxIndex];
|
|
||||||
}
|
|
||||||
if (closestMinIndex >= 0) {
|
|
||||||
double diff = distances[closestMinIndex + 1] - distances[closestMinIndex];
|
|
||||||
double coef = (minDist - distances[closestMinIndex]) / diff;
|
|
||||||
if (coef > 1 || coef < 0) {
|
|
||||||
LOG.warn("Coefficient for min must be 0..1 , coef=" + coef);
|
|
||||||
}
|
|
||||||
result[0] = (1 - coef) * elevations[closestMinIndex] + coef * elevations[closestMinIndex + 1];
|
|
||||||
}
|
|
||||||
if (Double.isNaN(result[0]) || Double.isNaN(result[1])) {
|
|
||||||
LOG.warn("Elevations wasn't calculated");
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static double getMinValue(ColorizationType type, GPXTrackAnalysis analysis) {
|
|
||||||
return type == ColorizationType.ELEVATION ? analysis.minElevation : 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static double getMaxValue(ColorizationType type, GPXTrackAnalysis analysis, double minValue, double maxProfileSpeed) {
|
|
||||||
if (type == ColorizationType.SPEED) {
|
|
||||||
return Math.max(analysis.maxSpeed, maxProfileSpeed);
|
|
||||||
} else if (type == ColorizationType.ELEVATION) {
|
|
||||||
return Math.max(analysis.maxElevation, minValue + 50);
|
|
||||||
} else {
|
|
||||||
return MAX_SLOPE_VALUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void calculateMinMaxValue() {
|
|
||||||
if (values.length == 0)
|
|
||||||
return;
|
|
||||||
minValue = maxValue = Double.NaN;
|
|
||||||
for (double value : values) {
|
|
||||||
if ((Double.isNaN(maxValue) || Double.isNaN(minValue)) && !Double.isNaN(value))
|
|
||||||
maxValue = minValue = value;
|
|
||||||
if (minValue > value)
|
|
||||||
minValue = value;
|
|
||||||
if (maxValue < value)
|
|
||||||
maxValue = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private double[] listToArray(List<Double> doubleList) {
|
|
||||||
double[] result = new double[doubleList.size()];
|
|
||||||
for (int i = 0; i < doubleList.size(); i++) {
|
|
||||||
result[i] = doubleList.get(i);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int rgbaToDecimal(int r, int g, int b, int a) {
|
|
||||||
int value = ((a & 0xFF) << 24) |
|
|
||||||
((r & 0xFF) << 16) |
|
|
||||||
((g & 0xFF) << 8) |
|
|
||||||
((b & 0xFF) << 0);
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getRed(int value) {
|
|
||||||
return (value >> 16) & 0xFF;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getGreen(int value) {
|
|
||||||
return (value >> 8) & 0xFF;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getBlue(int value) {
|
|
||||||
return (value >> 0) & 0xFF;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getAlpha(int value) {
|
|
||||||
return (value >> 24) & 0xff;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class RouteColorizationPoint {
|
|
||||||
public int id;
|
|
||||||
public double lat;
|
|
||||||
public double lon;
|
|
||||||
public double val;
|
|
||||||
public int color;
|
|
||||||
|
|
||||||
RouteColorizationPoint(int id, double lat, double lon, double val) {
|
|
||||||
this.id = id;
|
|
||||||
this.lat = lat;
|
|
||||||
this.lon = lon;
|
|
||||||
this.val = val;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -20,10 +20,10 @@ public class RouteExporter {
|
||||||
|
|
||||||
public static final String OSMAND_ROUTER_V2 = "OsmAndRouterV2";
|
public static final String OSMAND_ROUTER_V2 = "OsmAndRouterV2";
|
||||||
|
|
||||||
private final String name;
|
private String name;
|
||||||
private final List<RouteSegmentResult> route;
|
private List<RouteSegmentResult> route;
|
||||||
private final List<Location> locations;
|
private List<Location> locations;
|
||||||
private final List<WptPt> points;
|
private List<WptPt> points;
|
||||||
|
|
||||||
public RouteExporter(String name, List<RouteSegmentResult> route, List<Location> locations, List<WptPt> points) {
|
public RouteExporter(String name, List<RouteSegmentResult> route, List<Location> locations, List<WptPt> points) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
@ -33,34 +33,6 @@ public class RouteExporter {
|
||||||
}
|
}
|
||||||
|
|
||||||
public GPXFile exportRoute() {
|
public GPXFile exportRoute() {
|
||||||
GPXFile gpx = new GPXFile(OSMAND_ROUTER_V2);
|
|
||||||
Track track = new Track();
|
|
||||||
track.name = name;
|
|
||||||
gpx.tracks.add(track);
|
|
||||||
track.segments.add(generateRouteSegment());
|
|
||||||
if (points != null) {
|
|
||||||
for (WptPt pt : points) {
|
|
||||||
gpx.addPoint(pt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return gpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static GPXFile exportRoute(String name, List<TrkSegment> trkSegments, List<WptPt> points) {
|
|
||||||
GPXFile gpx = new GPXFile(OSMAND_ROUTER_V2);
|
|
||||||
Track track = new Track();
|
|
||||||
track.name = name;
|
|
||||||
gpx.tracks.add(track);
|
|
||||||
track.segments.addAll(trkSegments);
|
|
||||||
if (points != null) {
|
|
||||||
for (WptPt pt : points) {
|
|
||||||
gpx.addPoint(pt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return gpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TrkSegment generateRouteSegment() {
|
|
||||||
RouteDataResources resources = new RouteDataResources(locations);
|
RouteDataResources resources = new RouteDataResources(locations);
|
||||||
List<StringBundle> routeItems = new ArrayList<>();
|
List<StringBundle> routeItems = new ArrayList<>();
|
||||||
if (!Algorithms.isEmpty(route)) {
|
if (!Algorithms.isEmpty(route)) {
|
||||||
|
@ -85,9 +57,15 @@ public class RouteExporter {
|
||||||
typeList.add(typeBundle);
|
typeList.add(typeBundle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GPXFile gpx = new GPXFile(OSMAND_ROUTER_V2);
|
||||||
|
Track track = new Track();
|
||||||
|
track.name = name;
|
||||||
|
gpx.tracks.add(track);
|
||||||
TrkSegment trkSegment = new TrkSegment();
|
TrkSegment trkSegment = new TrkSegment();
|
||||||
|
track.segments.add(trkSegment);
|
||||||
|
|
||||||
if (locations == null || locations.isEmpty()) {
|
if (locations == null || locations.isEmpty()) {
|
||||||
return trkSegment;
|
return gpx;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < locations.size(); i++) {
|
for (int i = 0; i < locations.size(); i++) {
|
||||||
Location loc = locations.get(i);
|
Location loc = locations.get(i);
|
||||||
|
@ -105,17 +83,23 @@ public class RouteExporter {
|
||||||
}
|
}
|
||||||
trkSegment.points.add(pt);
|
trkSegment.points.add(pt);
|
||||||
}
|
}
|
||||||
|
if (points != null) {
|
||||||
|
for (WptPt pt : points) {
|
||||||
|
gpx.addPoint(pt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
List<RouteSegment> routeSegments = new ArrayList<>();
|
List<RouteSegment> routeSegments = new ArrayList<>();
|
||||||
for (StringBundle item : routeItems) {
|
for (StringBundle item : routeItems) {
|
||||||
routeSegments.add(RouteSegment.fromStringBundle(item));
|
routeSegments.add(RouteSegment.fromStringBundle(item));
|
||||||
}
|
}
|
||||||
trkSegment.routeSegments = routeSegments;
|
gpx.routeSegments = routeSegments;
|
||||||
List<RouteType> routeTypes = new ArrayList<>();
|
List<RouteType> routeTypes = new ArrayList<>();
|
||||||
for (StringBundle item : typeList) {
|
for (StringBundle item : typeList) {
|
||||||
routeTypes.add(RouteType.fromStringBundle(item));
|
routeTypes.add(RouteType.fromStringBundle(item));
|
||||||
}
|
}
|
||||||
trkSegment.routeTypes = routeTypes;
|
gpx.routeTypes = routeTypes;
|
||||||
return trkSegment;
|
|
||||||
|
return gpx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ import net.osmand.GPXUtilities;
|
||||||
import net.osmand.GPXUtilities.GPXFile;
|
import net.osmand.GPXUtilities.GPXFile;
|
||||||
import net.osmand.GPXUtilities.RouteSegment;
|
import net.osmand.GPXUtilities.RouteSegment;
|
||||||
import net.osmand.GPXUtilities.RouteType;
|
import net.osmand.GPXUtilities.RouteType;
|
||||||
import net.osmand.GPXUtilities.TrkSegment;
|
|
||||||
import net.osmand.GPXUtilities.WptPt;
|
import net.osmand.GPXUtilities.WptPt;
|
||||||
import net.osmand.Location;
|
import net.osmand.Location;
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
|
@ -29,9 +28,10 @@ public class RouteImporter {
|
||||||
|
|
||||||
private File file;
|
private File file;
|
||||||
private GPXFile gpxFile;
|
private GPXFile gpxFile;
|
||||||
private TrkSegment segment;
|
|
||||||
|
|
||||||
private final List<RouteSegmentResult> route = new ArrayList<>();
|
private List<RouteSegmentResult> route = new ArrayList<>();
|
||||||
|
private RouteRegion region = new RouteRegion();
|
||||||
|
private RouteDataResources resources = new RouteDataResources();
|
||||||
|
|
||||||
public RouteImporter(File file) {
|
public RouteImporter(File file) {
|
||||||
this.file = file;
|
this.file = file;
|
||||||
|
@ -41,12 +41,8 @@ public class RouteImporter {
|
||||||
this.gpxFile = gpxFile;
|
this.gpxFile = gpxFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RouteImporter(TrkSegment segment) {
|
|
||||||
this.segment = segment;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<RouteSegmentResult> importRoute() {
|
public List<RouteSegmentResult> importRoute() {
|
||||||
if (gpxFile != null || segment != null) {
|
if (gpxFile != null) {
|
||||||
parseRoute();
|
parseRoute();
|
||||||
} else if (file != null) {
|
} else if (file != null) {
|
||||||
FileInputStream fis = null;
|
FileInputStream fis = null;
|
||||||
|
@ -73,34 +69,19 @@ public class RouteImporter {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void parseRoute() {
|
private void parseRoute() {
|
||||||
if (segment != null) {
|
collectLocations();
|
||||||
parseRoute(segment);
|
collectSegments();
|
||||||
} else if (gpxFile != null) {
|
collectTypes();
|
||||||
List<TrkSegment> segments = gpxFile.getNonEmptyTrkSegments(true);
|
for (RouteSegmentResult segment : route) {
|
||||||
for (TrkSegment s : segments) {
|
segment.fillNames(resources);
|
||||||
parseRoute(s);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void parseRoute(TrkSegment segment) {
|
private void collectLocations() {
|
||||||
RouteRegion region = new RouteRegion();
|
|
||||||
RouteDataResources resources = new RouteDataResources();
|
|
||||||
|
|
||||||
collectLocations(resources, segment);
|
|
||||||
List<RouteSegmentResult> route = collectRouteSegments(region, resources, segment);
|
|
||||||
collectRouteTypes(region, segment);
|
|
||||||
for (RouteSegmentResult routeSegment : route) {
|
|
||||||
routeSegment.fillNames(resources);
|
|
||||||
}
|
|
||||||
this.route.addAll(route);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void collectLocations(RouteDataResources resources, TrkSegment segment) {
|
|
||||||
List<Location> locations = resources.getLocations();
|
List<Location> locations = resources.getLocations();
|
||||||
double lastElevation = HEIGHT_UNDEFINED;
|
double lastElevation = HEIGHT_UNDEFINED;
|
||||||
if (segment.hasRoute()) {
|
if (gpxFile.tracks.size() > 0 && gpxFile.tracks.get(0).segments.size() > 0 && gpxFile.tracks.get(0).segments.get(0).points.size() > 0) {
|
||||||
for (WptPt point : segment.points) {
|
for (WptPt point : gpxFile.tracks.get(0).segments.get(0).points) {
|
||||||
Location loc = new Location("", point.getLatitude(), point.getLongitude());
|
Location loc = new Location("", point.getLatitude(), point.getLongitude());
|
||||||
if (!Double.isNaN(point.ele)) {
|
if (!Double.isNaN(point.ele)) {
|
||||||
loc.setAltitude(point.ele);
|
loc.setAltitude(point.ele);
|
||||||
|
@ -113,20 +94,18 @@ public class RouteImporter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<RouteSegmentResult> collectRouteSegments(RouteRegion region, RouteDataResources resources, TrkSegment segment) {
|
private void collectSegments() {
|
||||||
List<RouteSegmentResult> route = new ArrayList<>();
|
for (RouteSegment segment : gpxFile.routeSegments) {
|
||||||
for (RouteSegment routeSegment : segment.routeSegments) {
|
|
||||||
RouteDataObject object = new RouteDataObject(region);
|
RouteDataObject object = new RouteDataObject(region);
|
||||||
RouteSegmentResult segmentResult = new RouteSegmentResult(object);
|
RouteSegmentResult segmentResult = new RouteSegmentResult(object);
|
||||||
segmentResult.readFromBundle(new RouteDataBundle(resources, routeSegment.toStringBundle()));
|
segmentResult.readFromBundle(new RouteDataBundle(resources, segment.toStringBundle()));
|
||||||
route.add(segmentResult);
|
route.add(segmentResult);
|
||||||
}
|
}
|
||||||
return route;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void collectRouteTypes(RouteRegion region, TrkSegment segment) {
|
private void collectTypes() {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (RouteType routeType : segment.routeTypes) {
|
for (RouteType routeType : gpxFile.routeTypes) {
|
||||||
StringBundle bundle = routeType.toStringBundle();
|
StringBundle bundle = routeType.toStringBundle();
|
||||||
String t = bundle.getString("t", null);
|
String t = bundle.getString("t", null);
|
||||||
String v = bundle.getString("v", null);
|
String v = bundle.getString("v", null);
|
||||||
|
|
|
@ -6,6 +6,7 @@ import net.osmand.NativeLibrary;
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.ResultMatcher;
|
import net.osmand.ResultMatcher;
|
||||||
import net.osmand.binary.BinaryMapIndexReader;
|
import net.osmand.binary.BinaryMapIndexReader;
|
||||||
|
import net.osmand.binary.BinaryMapRouteReaderAdapter;
|
||||||
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteRegion;
|
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteRegion;
|
||||||
import net.osmand.binary.RouteDataObject;
|
import net.osmand.binary.RouteDataObject;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
|
@ -242,6 +243,9 @@ public class RoutePlannerFrontEnd {
|
||||||
start = gpxPoints.get(0);
|
start = gpxPoints.get(0);
|
||||||
}
|
}
|
||||||
while (start != null && !gctx.ctx.calculationProgress.isCancelled) {
|
while (start != null && !gctx.ctx.calculationProgress.isCancelled) {
|
||||||
|
if (Thread.currentThread().isInterrupted()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
double routeDist = gctx.MAXIMUM_STEP_APPROXIMATION;
|
double routeDist = gctx.MAXIMUM_STEP_APPROXIMATION;
|
||||||
GpxPoint next = findNextGpxPointWithin(gctx, gpxPoints, start, routeDist);
|
GpxPoint next = findNextGpxPointWithin(gctx, gpxPoints, start, routeDist);
|
||||||
boolean routeFound = false;
|
boolean routeFound = false;
|
||||||
|
@ -688,15 +692,15 @@ public class RoutePlannerFrontEnd {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ctx.calculationMode == RouteCalculationMode.COMPLEX && routeDirection == null
|
if (ctx.calculationMode == RouteCalculationMode.COMPLEX && routeDirection == null
|
||||||
&& maxDistance > RoutingConfiguration.DEVIATION_RADIUS * 6) {
|
&& maxDistance > ctx.config.DEVIATION_RADIUS * 6) {
|
||||||
ctx.calculationProgress.totalIterations++;
|
ctx.calculationProgress.totalIterations++;
|
||||||
RoutingContext nctx = buildRoutingContext(ctx.config, ctx.nativeLib, ctx.getMaps(), RouteCalculationMode.BASE);
|
RoutingContext nctx = buildRoutingContext(ctx.config, ctx.nativeLib, ctx.getMaps(), RouteCalculationMode.BASE);
|
||||||
nctx.calculationProgress = ctx.calculationProgress;
|
nctx.calculationProgress = ctx.calculationProgress;
|
||||||
List<RouteSegmentResult> ls = searchRoute(nctx, start, end, intermediates);
|
List<RouteSegmentResult> ls = searchRoute(nctx, start, end, intermediates);
|
||||||
if (ls == null) {
|
if(ls == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
routeDirection = PrecalculatedRouteDirection.build(ls, RoutingConfiguration.DEVIATION_RADIUS, ctx.getRouter().getMaxSpeed());
|
routeDirection = PrecalculatedRouteDirection.build(ls, ctx.config.DEVIATION_RADIUS, ctx.getRouter().getMaxSpeed());
|
||||||
}
|
}
|
||||||
List<RouteSegmentResult> res ;
|
List<RouteSegmentResult> res ;
|
||||||
if (intermediatesEmpty && ctx.nativeLib != null) {
|
if (intermediatesEmpty && ctx.nativeLib != null) {
|
||||||
|
@ -735,7 +739,7 @@ public class RoutePlannerFrontEnd {
|
||||||
res = searchRouteImpl(ctx, points, routeDirection);
|
res = searchRouteImpl(ctx, points, routeDirection);
|
||||||
}
|
}
|
||||||
if (ctx.calculationProgress != null) {
|
if (ctx.calculationProgress != null) {
|
||||||
ctx.calculationProgress.timeToCalculate = (System.nanoTime() - timeToCalculate);
|
ctx.calculationProgress.timeToCalculate += (System.nanoTime() - timeToCalculate);
|
||||||
}
|
}
|
||||||
BinaryRoutePlanner.printDebugMemoryInformation(ctx);
|
BinaryRoutePlanner.printDebugMemoryInformation(ctx);
|
||||||
if (res != null) {
|
if (res != null) {
|
||||||
|
@ -917,7 +921,7 @@ public class RoutePlannerFrontEnd {
|
||||||
|
|
||||||
private List<RouteSegmentResult> runNativeRouting(final RoutingContext ctx, RouteSegment recalculationEnd) throws IOException {
|
private List<RouteSegmentResult> runNativeRouting(final RoutingContext ctx, RouteSegment recalculationEnd) throws IOException {
|
||||||
refreshProgressDistance(ctx);
|
refreshProgressDistance(ctx);
|
||||||
RouteRegion[] regions = ctx.reverseMap.keySet().toArray(new RouteRegion[0]);
|
RouteRegion[] regions = ctx.reverseMap.keySet().toArray(new BinaryMapRouteReaderAdapter.RouteRegion[ctx.reverseMap.size()]);
|
||||||
ctx.checkOldRoutingFiles(ctx.startX, ctx.startY);
|
ctx.checkOldRoutingFiles(ctx.startX, ctx.startY);
|
||||||
ctx.checkOldRoutingFiles(ctx.targetX, ctx.targetY);
|
ctx.checkOldRoutingFiles(ctx.targetX, ctx.targetY);
|
||||||
|
|
||||||
|
|
|
@ -176,49 +176,11 @@ public class RouteResultPreparation {
|
||||||
combineWayPointsForAreaRouting(ctx, result);
|
combineWayPointsForAreaRouting(ctx, result);
|
||||||
validateAllPointsConnected(result);
|
validateAllPointsConnected(result);
|
||||||
splitRoadsAndAttachRoadSegments(ctx, result, recalculation);
|
splitRoadsAndAttachRoadSegments(ctx, result, recalculation);
|
||||||
for (int i = 0; i < result.size(); i++) {
|
|
||||||
filterMinorStops(result.get(i));
|
|
||||||
}
|
|
||||||
calculateTimeSpeed(ctx, result);
|
calculateTimeSpeed(ctx, result);
|
||||||
|
|
||||||
prepareTurnResults(ctx, result);
|
prepareTurnResults(ctx, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RouteSegmentResult filterMinorStops(RouteSegmentResult seg) {
|
|
||||||
List<Integer> stops = null;
|
|
||||||
boolean plus = seg.getStartPointIndex() < seg.getEndPointIndex();
|
|
||||||
int next;
|
|
||||||
|
|
||||||
for (int i = seg.getStartPointIndex(); i != seg.getEndPointIndex(); i = next) {
|
|
||||||
next = plus ? i + 1 : i - 1;
|
|
||||||
int[] pointTypes = seg.getObject().getPointTypes(i);
|
|
||||||
if (pointTypes != null) {
|
|
||||||
for (int j = 0; j < pointTypes.length; j++) {
|
|
||||||
if (pointTypes[j] == seg.getObject().region.stopMinor) {
|
|
||||||
if (stops == null) {
|
|
||||||
stops = new ArrayList<>();
|
|
||||||
}
|
|
||||||
stops.add(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (stops != null) {
|
|
||||||
for (int stop : stops) {
|
|
||||||
List<RouteSegmentResult> attachedRoutes = seg.getAttachedRoutes(stop);
|
|
||||||
for (RouteSegmentResult attached : attachedRoutes) {
|
|
||||||
int attStopPriority = highwaySpeakPriority(attached.getObject().getHighway());
|
|
||||||
int segStopPriority = highwaySpeakPriority(seg.getObject().getHighway());
|
|
||||||
if (segStopPriority < attStopPriority) {
|
|
||||||
seg.getObject().removePointType(stop, seg.getObject().region.stopSign);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return seg;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void prepareTurnResults(RoutingContext ctx, List<RouteSegmentResult> result) {
|
public void prepareTurnResults(RoutingContext ctx, List<RouteSegmentResult> result) {
|
||||||
for (int i = 0; i < result.size(); i ++) {
|
for (int i = 0; i < result.size(); i ++) {
|
||||||
|
@ -1117,8 +1079,8 @@ public class RouteResultPreparation {
|
||||||
if (UNMATCHED_HIGHWAY_TYPE.equals(rr.getObject().getHighway())) {
|
if (UNMATCHED_HIGHWAY_TYPE.equals(rr.getObject().getHighway())) {
|
||||||
bearingDist = RouteSegmentResult.DIST_BEARING_DETECT_UNMATCHED;
|
bearingDist = RouteSegmentResult.DIST_BEARING_DETECT_UNMATCHED;
|
||||||
}
|
}
|
||||||
double mpi = MapUtils.degreesDiff(prev.getBearingEnd(prev.getEndPointIndex(), Math.min(prev.getDistance(), bearingDist)),
|
double mpi = MapUtils.degreesDiff(prev.getBearingEnd(prev.getEndPointIndex(), bearingDist),
|
||||||
rr.getBearingBegin(rr.getStartPointIndex(), Math.min(rr.getDistance(), bearingDist)));
|
rr.getBearingBegin(rr.getStartPointIndex(), bearingDist));
|
||||||
if (mpi >= TURN_DEGREE_MIN) {
|
if (mpi >= TURN_DEGREE_MIN) {
|
||||||
if (mpi < TURN_DEGREE_MIN) {
|
if (mpi < TURN_DEGREE_MIN) {
|
||||||
// Slight turn detection here causes many false positives where drivers would expect a "normal" TL. Best use limit-angle=TURN_DEGREE_MIN, this reduces TSL to the turn-lanes cases.
|
// Slight turn detection here causes many false positives where drivers would expect a "normal" TL. Best use limit-angle=TURN_DEGREE_MIN, this reduces TSL to the turn-lanes cases.
|
||||||
|
@ -1227,7 +1189,6 @@ public class RouteResultPreparation {
|
||||||
RouteSegmentResult last = rr;
|
RouteSegmentResult last = rr;
|
||||||
RouteSegmentResult firstRoundabout = rr;
|
RouteSegmentResult firstRoundabout = rr;
|
||||||
RouteSegmentResult lastRoundabout = rr;
|
RouteSegmentResult lastRoundabout = rr;
|
||||||
|
|
||||||
for (int j = i; j < result.size(); j++) {
|
for (int j = i; j < result.size(); j++) {
|
||||||
RouteSegmentResult rnext = result.get(j);
|
RouteSegmentResult rnext = result.get(j);
|
||||||
last = rnext;
|
last = rnext;
|
||||||
|
@ -1254,18 +1215,12 @@ public class RouteResultPreparation {
|
||||||
TurnType t = TurnType.getExitTurn(exit, 0, leftSide);
|
TurnType t = TurnType.getExitTurn(exit, 0, leftSide);
|
||||||
// usually covers more than expected
|
// usually covers more than expected
|
||||||
float turnAngleBasedOnOutRoads = (float) MapUtils.degreesDiff(last.getBearingBegin(), prev.getBearingEnd());
|
float turnAngleBasedOnOutRoads = (float) MapUtils.degreesDiff(last.getBearingBegin(), prev.getBearingEnd());
|
||||||
// Angle based on circle method tries
|
// usually covers less than expected
|
||||||
// 1. to calculate antinormal to roundabout circle on roundabout entrance and
|
|
||||||
// 2. normal to roundabout circle on roundabout exit
|
|
||||||
// 3. calculate angle difference
|
|
||||||
// This method doesn't work if you go from S to N touching only 1 point of roundabout,
|
|
||||||
// but it is very important to identify very sharp or very large angle to understand did you pass whole roundabout or small entrance
|
|
||||||
float turnAngleBasedOnCircle = (float) -MapUtils.degreesDiff(firstRoundabout.getBearingBegin(), lastRoundabout.getBearingEnd() + 180);
|
float turnAngleBasedOnCircle = (float) -MapUtils.degreesDiff(firstRoundabout.getBearingBegin(), lastRoundabout.getBearingEnd() + 180);
|
||||||
if (Math.abs(turnAngleBasedOnOutRoads) > 120) {
|
if(Math.abs(turnAngleBasedOnOutRoads - turnAngleBasedOnCircle) > 180) {
|
||||||
// correctly identify if angle is +- 180, so we approach from left or right side
|
t.setTurnAngle(turnAngleBasedOnCircle ) ;
|
||||||
t.setTurnAngle(turnAngleBasedOnCircle) ;
|
|
||||||
} else {
|
} else {
|
||||||
t.setTurnAngle(turnAngleBasedOnOutRoads) ;
|
t.setTurnAngle((turnAngleBasedOnCircle + turnAngleBasedOnOutRoads) / 2) ;
|
||||||
}
|
}
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
@ -1762,7 +1717,7 @@ public class RouteResultPreparation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Integer[] array = possibleTurns.toArray(new Integer[0]);
|
Integer[] array = possibleTurns.toArray(new Integer[possibleTurns.size()]);
|
||||||
Arrays.sort(array, new Comparator<Integer>() {
|
Arrays.sort(array, new Comparator<Integer>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -255,8 +255,7 @@ public class RouteSegmentResult implements StringExternalizable<RouteDataBundle>
|
||||||
@Override
|
@Override
|
||||||
public void writeToBundle(RouteDataBundle bundle) {
|
public void writeToBundle(RouteDataBundle bundle) {
|
||||||
Map<RouteTypeRule, Integer> rules = bundle.getResources().getRules();
|
Map<RouteTypeRule, Integer> rules = bundle.getResources().getRules();
|
||||||
boolean reversed = endPointIndex < startPointIndex;
|
bundle.putInt("length", (Math.abs(endPointIndex - startPointIndex) + 1) * (endPointIndex >= startPointIndex ? 1 : -1));
|
||||||
bundle.putInt("length", Math.abs(endPointIndex - startPointIndex) + 1);
|
|
||||||
bundle.putFloat("segmentTime", segmentTime, 2);
|
bundle.putFloat("segmentTime", segmentTime, 2);
|
||||||
bundle.putFloat("speed", speed, 2);
|
bundle.putFloat("speed", speed, 2);
|
||||||
if (turnType != null) {
|
if (turnType != null) {
|
||||||
|
@ -279,22 +278,17 @@ public class RouteSegmentResult implements StringExternalizable<RouteDataBundle>
|
||||||
int end = Math.max(startPointIndex, endPointIndex) + 1;
|
int end = Math.max(startPointIndex, endPointIndex) + 1;
|
||||||
if (object.pointTypes != null && start < object.pointTypes.length) {
|
if (object.pointTypes != null && start < object.pointTypes.length) {
|
||||||
int[][] types = Arrays.copyOfRange(object.pointTypes, start, Math.min(end, object.pointTypes.length));
|
int[][] types = Arrays.copyOfRange(object.pointTypes, start, Math.min(end, object.pointTypes.length));
|
||||||
if (reversed) {
|
|
||||||
Algorithms.reverseArray(types);
|
|
||||||
}
|
|
||||||
bundle.putArray("pointTypes", convertTypes(types, rules));
|
bundle.putArray("pointTypes", convertTypes(types, rules));
|
||||||
}
|
}
|
||||||
if (object.nameIds != null) {
|
if (object.nameIds != null) {
|
||||||
bundle.putArray("names", convertNameIds(object.nameIds, rules));
|
bundle.putArray("names", convertNameIds(object.nameIds, rules));
|
||||||
}
|
}
|
||||||
if (object.pointNameTypes != null && start < object.pointNameTypes.length && object.pointNames != null) {
|
if (object.pointNameTypes != null && start < object.pointNameTypes.length) {
|
||||||
int[][] types = Arrays.copyOfRange(object.pointNameTypes, start, Math.min(end, object.pointNameTypes.length));
|
int[][] types = Arrays.copyOfRange(object.pointNameTypes, start, Math.min(end, object.pointNameTypes.length));
|
||||||
String[][] names = Arrays.copyOfRange(object.pointNames, start, Math.min(end, object.pointNames.length));
|
if (object.pointNames != null) {
|
||||||
if (reversed) {
|
String[][] names = Arrays.copyOfRange(object.pointNames, start, Math.min(end, object.pointNames.length));
|
||||||
Algorithms.reverseArray(types);
|
bundle.putArray("pointNames", convertPointNames(types, names, rules));
|
||||||
Algorithms.reverseArray(names);
|
|
||||||
}
|
}
|
||||||
bundle.putArray("pointNames", convertPointNames(types, names, rules));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -315,7 +309,7 @@ public class RouteSegmentResult implements StringExternalizable<RouteDataBundle>
|
||||||
int[] turnLanes = TurnType.lanesFromString(bundle.getString("turnLanes", null));
|
int[] turnLanes = TurnType.lanesFromString(bundle.getString("turnLanes", null));
|
||||||
turnType.setLanes(turnLanes);
|
turnType.setLanes(turnLanes);
|
||||||
}
|
}
|
||||||
object.id = bundle.getLong("id", object.id) << 6;
|
object.id = bundle.getLong("id", object.id);
|
||||||
object.types = bundle.getIntArray("types", null);
|
object.types = bundle.getIntArray("types", null);
|
||||||
object.pointTypes = bundle.getIntIntArray("pointTypes", null);
|
object.pointTypes = bundle.getIntIntArray("pointTypes", null);
|
||||||
object.nameIds = bundle.getIntArray("names", null);
|
object.nameIds = bundle.getIntArray("names", null);
|
||||||
|
@ -457,7 +451,7 @@ public class RouteSegmentResult implements StringExternalizable<RouteDataBundle>
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getBearingBegin() {
|
public float getBearingBegin() {
|
||||||
return getBearingBegin(startPointIndex, distance > 0 && distance < DIST_BEARING_DETECT ? distance : DIST_BEARING_DETECT);
|
return getBearingBegin(startPointIndex, DIST_BEARING_DETECT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getBearingBegin(int point, float dist) {
|
public float getBearingBegin(int point, float dist) {
|
||||||
|
@ -465,7 +459,7 @@ public class RouteSegmentResult implements StringExternalizable<RouteDataBundle>
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getBearingEnd() {
|
public float getBearingEnd() {
|
||||||
return getBearingEnd(endPointIndex, distance > 0 && distance < DIST_BEARING_DETECT ? distance : DIST_BEARING_DETECT);
|
return getBearingEnd(endPointIndex, DIST_BEARING_DETECT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getBearingEnd(int point, float dist) {
|
public float getBearingEnd(int point, float dist) {
|
||||||
|
|
|
@ -367,9 +367,8 @@ public class RouteStatisticsHelper {
|
||||||
RouteDataObject obj = segment.obj;
|
RouteDataObject obj = segment.obj;
|
||||||
for (int type : obj.getTypes()) {
|
for (int type : obj.getTypes()) {
|
||||||
BinaryMapRouteReaderAdapter.RouteTypeRule tp = obj.region.quickGetEncodingRule(type);
|
BinaryMapRouteReaderAdapter.RouteTypeRule tp = obj.region.quickGetEncodingRule(type);
|
||||||
if (tp.getTag().equals("highway") || tp.getTag().equals("route")
|
if (tp.getTag().equals("highway") || tp.getTag().equals("route") ||
|
||||||
|| tp.getTag().equals("railway") || tp.getTag().equals("aeroway")
|
tp.getTag().equals("railway") || tp.getTag().equals("aeroway") || tp.getTag().equals("aerialway")) {
|
||||||
|| tp.getTag().equals("aerialway") || tp.getTag().equals("piste:type")) {
|
|
||||||
if (!mainTagAdded) {
|
if (!mainTagAdded) {
|
||||||
req.setStringFilter(rrs.PROPS.R_TAG, tp.getTag());
|
req.setStringFilter(rrs.PROPS.R_TAG, tp.getTag());
|
||||||
req.setStringFilter(rrs.PROPS.R_VALUE, tp.getValue());
|
req.setStringFilter(rrs.PROPS.R_VALUE, tp.getValue());
|
||||||
|
|
|
@ -20,7 +20,7 @@ import java.util.Stack;
|
||||||
public class RoutingConfiguration {
|
public class RoutingConfiguration {
|
||||||
|
|
||||||
public static final int DEFAULT_MEMORY_LIMIT = 30;
|
public static final int DEFAULT_MEMORY_LIMIT = 30;
|
||||||
public static final float DEVIATION_RADIUS = 3000;
|
public final float DEVIATION_RADIUS = 3000;
|
||||||
public Map<String, String> attributes = new LinkedHashMap<String, String>();
|
public Map<String, String> attributes = new LinkedHashMap<String, String>();
|
||||||
|
|
||||||
// 1. parameters of routing and different tweaks
|
// 1. parameters of routing and different tweaks
|
||||||
|
|
|
@ -802,7 +802,7 @@ public class RoutingContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
public BinaryMapIndexReader[] getMaps() {
|
public BinaryMapIndexReader[] getMaps() {
|
||||||
return map.keySet().toArray(new BinaryMapIndexReader[0]);
|
return map.keySet().toArray(new BinaryMapIndexReader[map.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getVisitedSegments() {
|
public int getVisitedSegments() {
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue