Compare commits
No commits in common. "master" and "r3.7" have entirely different histories.
2476 changed files with 180485 additions and 174603 deletions
16
.github/ISSUE_TEMPLATE/1-support-request.md
vendored
16
.github/ISSUE_TEMPLATE/1-support-request.md
vendored
|
@ -1,16 +0,0 @@
|
|||
---
|
||||
name: "❓ Support request"
|
||||
about: Questions and requests for support
|
||||
---
|
||||
|
||||
🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑
|
||||
|
||||
Please do not file questions or support requests on the GitHub issues tracker.
|
||||
|
||||
In case you aren't sure whether to open an issue or not, please send your request to support@osmand.net.
|
||||
|
||||
You can get your questions answered using the [Google group](https://groups.google.com/forum/#!forum/osmand) or chat in real-time via our Telegram instances: [English](https://t.me/OsmAndMaps), [German](https://t.me/deosmand), [French](https://t.me/frosmand), [Ukrainian](https://t.me/uaosmand), [Italian](https://t.me/itosmand), [Russian](https://t.me/ruosmand).
|
||||
|
||||
Thank you!
|
||||
|
||||
🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑
|
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.
|
72
.github/ISSUE_TEMPLATE/3-routing-report.md
vendored
72
.github/ISSUE_TEMPLATE/3-routing-report.md
vendored
|
@ -1,72 +0,0 @@
|
|||
---
|
||||
name: "\U0001F6A9 Routing report"
|
||||
about: Report a routing issue 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:
|
||||
|
||||
🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅-->
|
||||
|
||||
# 🐞 routing report
|
||||
|
||||
### Routing engine
|
||||
|
||||
<!-- Which routing provider was used? (please tick the proper box [x]) -->
|
||||
|
||||
- [ ] OsmAnd's in-app offline routing
|
||||
- [ ] Any online routing provider (YOURS, OpenRouteService, OSRM, etc.)
|
||||
|
||||
### Routing Profile
|
||||
|
||||
<!-- What routing profile is chosen in the OsmAnd app? (car, bike, pedestrian, fastest or shortest, etc.) -->
|
||||
|
||||
### Start and end points
|
||||
|
||||
<!-- Please specify (as exactly as possible) the start and endpoint of your route by telling us the city and street name so that we can find it via the in-app address search easily.
|
||||
Also, a permalink from [openstreetmap.org](https://www.openstreetmap.org/) can be helpful. -->
|
||||
|
||||
### Actual and expected routes
|
||||
|
||||
<!-- Tell us your expected routing and how OsmAnd routes, or add screenshots here. -->
|
||||
|
||||
### 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: ....
|
||||
|
||||
## 🌍 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?**
|
34
.github/ISSUE_TEMPLATE/4-feature-request.md
vendored
34
.github/ISSUE_TEMPLATE/4-feature-request.md
vendored
|
@ -1,34 +0,0 @@
|
|||
---
|
||||
name: "\U0001F680 Feature request"
|
||||
about: Suggest a feature for 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 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.
|
||||
|
||||
🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅-->
|
||||
|
||||
# 🚀 feature request
|
||||
|
||||
### Description
|
||||
|
||||
<!-- ✍️ A clear and concise description of the feature... -->
|
||||
|
||||
### Describe the solution you'd like
|
||||
|
||||
<!-- ✍️--> If you have a solution in mind, please describe it.
|
||||
|
||||
### Describe alternatives you've considered
|
||||
|
||||
<!-- ✍️--> Have you considered any alternative solutions or workarounds?
|
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
|
10
.github/workflows/gradle-wrapper-validation.yml
vendored
10
.github/workflows/gradle-wrapper-validation.yml
vendored
|
@ -1,10 +0,0 @@
|
|||
name: "Validate Gradle Wrapper"
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
validation:
|
||||
name: "Validation"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: gradle/wrapper-validation-action@v1
|
7
.gitignore
vendored
7
.gitignore
vendored
|
@ -16,14 +16,9 @@ OsmAndCore_*.aar
|
|||
*.iml
|
||||
.settings
|
||||
.idea
|
||||
**/.project
|
||||
**/.classpath
|
||||
.project
|
||||
out/
|
||||
|
||||
# Huawei
|
||||
agconnect-services.json
|
||||
OsmAndHms.jks
|
||||
|
||||
# Android Studio
|
||||
/.idea
|
||||
*.iml
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
### Credits to all major contributors / developers:
|
||||
Major contributors / developers listed here https://github.com/osmandapp/osmandapp.github.io/blob/master/website/help/about.html#L8
|
||||
### Credits to all major contributors/developers:
|
||||
Major contributors /developers listed here https://github.com/osmandapp/osmandapp.github.io/blob/master/website/help/about.html#L8
|
||||
|
||||
### Other Pull requests
|
||||
Copyright © All authors of translations and pull requests can be found in the commit history:
|
||||
Copyright © All authors of translations and pull requests could be found in commits history:
|
||||
- Translations are under special “contributor” name ‘weblate’
|
||||
- Pull requests have two committers: first is original contributor, and second is project maintainer
|
||||
- Pull requests have two committers, first is original contributor and second is project maintainer
|
||||
|
|
26
ISSUE_TEMPLATE.md
Normal file
26
ISSUE_TEMPLATE.md
Normal file
|
@ -0,0 +1,26 @@
|
|||
Before entering an issue, please read the information below.
|
||||
|
||||
```GitHub is a main development tool for developers. There are hundreds requests a month and there are only 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 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.```
|
||||
|
||||
In case you are not sure to open issue or not, please send your request to support support@osmand.net. For **general questions** about OsmAnd, please use the [Google group](https://groups.google.com/forum/#!forum/osmand).
|
||||
|
||||
Please be sure to have read our [FAQ](http://osmand.net/help-online) before creating an issue here. (Also, tell us in Google Groups when the FAQ is wrong or outdated.)
|
||||
|
||||
The best way to get help about an OsmAnd issue is to create a valid and detailed issue content.
|
||||
Please give us the following information so that we can try to **reproduce** your issue:
|
||||
|
||||
What version of OsmAnd are you using, on what device and Android/iOS version?
|
||||
|
||||
Do you use the offline maps offered within the OsmAnd app for download, or online (tile / raster) maps?
|
||||
|
||||
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.
|
||||
|
||||
__*In case of wrong routing:*__
|
||||
|
||||
Tell us whether you have used OsmAnd's in-app offline routing, or any online routing provider like YOURS, OpenRouteService or OSRM.
|
||||
|
||||
What routing profile is chosen in OsmAnd app? (car, bike, pedestrian, fastest or shortest)
|
||||
|
||||
Please specify as exactly as possible the start and end point of your route by telling us city name and street name so that we can find it via in-app address search easily. Also, a permalink from openstreetmap.org can be helpful.
|
||||
|
||||
Tell us your expected routing, and how OsmAnd routes, or add screenshots here.
|
70
LICENSE
70
LICENSE
|
@ -1,11 +1,11 @@
|
|||
|
||||
OsmAnd – OSM Automated Navigation Directions – navigation software based on OpenStreetMap.
|
||||
Copyright © 2010–2020 OsmAnd BV (Amstelveen, Netherlands - KvK 62066714, BTW 854627704B01).
|
||||
Copyright © 2010–2018 OsmAnd BV (Amstelveen, Netherlands - KvK 62066714, BTW 854627704B01).
|
||||
|
||||
The code in this repository is covered by *GPLv3* (for code) and the artwork is covered by [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/) (for artwork), except for some third-party libraries and resources.
|
||||
ATTENTION: Please be aware that some artwork uses a proprietary license.
|
||||
The code in this repository is covered by *GPLv3* (for code) and the artwork is covered by [ CC-BY-NC-ND 4.0 ](https://creativecommons.org/licenses/by-nc-nd/4.0/) (for artwork), except some 3rd party libs and resources.
|
||||
ATTENTION: please be aware that some artwork has proprietary license.
|
||||
|
||||
Main AUTHORS (more detailed list in AUTHORS.md):
|
||||
Main AUTHORS (more detailed list in AUTHORS):
|
||||
Victor Shcherb – all parts of the project, originator
|
||||
Alexey Pelykh – rendering and core parts
|
||||
Hardy Mueller – main parts of the project, mostly rendering, UI interaction design
|
||||
|
@ -30,33 +30,33 @@
|
|||
* Source code in main repositories is covered by GPLv3 (license exceptions below):
|
||||
- https://github.com/osmandapp/Osmand/tree/master/OsmAnd
|
||||
- https://github.com/osmandapp/Osmand/tree/master/OsmAnd-java
|
||||
- https://github.com/osmandapp/OsmAnd-core/tree/legacy_core
|
||||
- https://github.com/osmandapp/OsmAnd-core
|
||||
- https://github.com/osmandapp/Osmand-core/tree/legacy_core
|
||||
- https://github.com/osmandapp/Osmand-core/
|
||||
- https://github.com/osmandapp/OsmAnd-misc
|
||||
- https://github.com/osmandapp/OsmAnd-tools
|
||||
- https://github.com/osmandapp/OsmAnd-resources
|
||||
|
||||
* UI Design and UX work, such as layout and icons, are covered by [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/)
|
||||
* UI Design and UX work, such as layout, icons is covered by CC-BY-NC-ND
|
||||
- https://github.com/osmandapp/Osmand/tree/master/OsmAnd/res and others
|
||||
Restriction to UI/UX CC-BY-NC-ND:
|
||||
* Publishing applications using the OsmAnd UI/UX code to Google Play, Amazon Market, or Apple Store must be done with written permission.*
|
||||
* Publishing applications using the OsmAnd UI/UX code to Google Play, Amazon Market or Apple Store must be done with written permission*
|
||||
|
||||
|
||||
* Map icons are taken from sjjb and some are drawn and distributed under Public Domain (except icons8)
|
||||
- https://github.com/osmandapp/OsmAnd-resources/tree/master/icons/svg
|
||||
- some icons are from http://osm-icons.org/wiki/Icons (CC-0 by Markus59, CC BY-SA 2.0)
|
||||
|
||||
* Integration with Qt library in (https://github.com/osmandapp/OsmAnd-core) - dynamic linking
|
||||
- LGPL (https://www.qt.io/terms-conditions/)
|
||||
* Integration with Qt library in (https://github.com/osmandapp/Osmand-core/) - dynamic linking
|
||||
- LGPL (http://www.qt.io/qt-licensing-terms/)
|
||||
|
||||
* Map icons and their derived primitives are covered by a proprietary license:
|
||||
* Map icons and their derived primitives are covered by proprietary license:
|
||||
- © icons8.com (https://github.com/osmandapp/OsmAnd-resources/tree/master/icons/svg/icons8)
|
||||
|
||||
* Generated voice files from TTS files are covered by a proprietary license:
|
||||
* Generated voice files from TTS files are covered by proprietary license:
|
||||
- Voice files (https://github.com/osmandapp/OsmAnd-resources/tree/master/voice)
|
||||
|
||||
* Fonts (https://github.com/osmandapp/OsmAnd-resources/tree/master/rendering_styles/fonts)
|
||||
- Google Fonts (Apache License 2.0)
|
||||
- Google Fonts (Apache License 2)
|
||||
|
||||
* Map icons (Mapnik):
|
||||
- Open-SVG-Map-Icons - Public Domain
|
||||
|
@ -65,27 +65,49 @@
|
|||
- SherlockBar - Apache License - https://github.com/osmandapp/Osmand/tree/master/SherlockBar (https://github.com/JakeWharton/ActionBarSherlock/blob/master/LICENSE.txt)
|
||||
|
||||
* Patched libraries:
|
||||
- Protobuf - New BSD License (patches - https://github.com/osmandapp/Osmand/tree/master/OsmAnd-java/src/main/java/com/google/protobuf, https://github.com/osmandapp/OsmAnd-core/tree/legacy_core/externals/protobuf)
|
||||
- Protobuf - New BSD License (patches - https://github.com/osmandapp/Osmand/tree/master/OsmAnd-java/protobuf-src, https://github.com/osmandapp/OsmAnd-core/tree/legacy_core/externals/protobuf)
|
||||
- Expat - (https://github.com/osmandapp/OsmAnd-core/tree/legacy_core/externals/expat)
|
||||
- Freetype - (https://github.com/osmandapp/OsmAnd-core/tree/legacy_core/externals/freetype)
|
||||
- Giflib - (https://github.com/osmandapp/OsmAnd-core/tree/legacy_core/externals/giflib)
|
||||
- Jpeg - (https://github.com/osmandapp/OsmAnd-core/tree/legacy_core/externals/jpeg)
|
||||
- Libpng - (https://github.com/osmandapp/OsmAnd-core/tree/legacy_core/externals/libpng)
|
||||
- Skia - (https://github.com/osmandapp/OsmAnd-core/tree/legacy_core/externals/skia)
|
||||
- android-openmap-framework - (https://github.com/osmandapp/Osmand/tree/master/OsmAnd-java/src/main/java/com/jwetherell/openmap/common)
|
||||
- mapbox-vector-tile - (https://github.com/osmandapp/Osmand/tree/master/OsmAnd-java/src/main/java/com/wdtinc/mapbox_vector_tile)
|
||||
- ZLib - (https://github.com/osmandapp/OsmAnd-core/tree/legacy_core/externals/zlib)
|
||||
|
||||
* 3rd party libraries present in the libs folder (https://github.com/osmandapp/Osmand/tree/master/OsmAnd-java/libs):
|
||||
- bzip2-20090327.jar Bzip2 - Apache License
|
||||
- commons-logging-1.1.1.jar - Apache License
|
||||
- gnu-trove-osmand.jar GNU trove - LGPL
|
||||
- icu4j-49_1_patched.jar - ICU license (https://home.unicode.org/basic-info/projects/#/icu/icu/trunk/license.html)
|
||||
- icu4j-49_1.jar - ICU license (http://source.icu-project.org/repos/icu/icu/trunk/license.html)
|
||||
- json-20090211.jar - BSD alike (http://www.json.org/license.html)
|
||||
- junidecode-0.1.jar - BSD-4-Clause-UC (http://sourceforge.net/projects/junidecode/)
|
||||
- kxml2-2.3.0.jar - BSD license (http://www.kxml.org/)
|
||||
- tuprolog.jar - LGPL (http://apice.unibo.it/xwiki/bin/view/Tuprolog/)
|
||||
- OpenMap framework - Apache License (https://code.google.com/p/android-openmap-framework/)
|
||||
|
||||
* Pull-requests and translations:
|
||||
- All pull requests are accepted under MIT License (most honorable contributors are mentioned in AUTHORS list).
|
||||
- All pull requests are accepted under MIT License (most honorable contributors are mentioned in AUTHORS list)
|
||||
|
||||
* Libraries not used in final product (https://github.com/osmandapp/OsmAnd-tools/tree/master/OsmAndMapCreator/libi)
|
||||
- Ant libraries - (tools) https://github.com/osmandapp/Osmand/tree/master/OsmAnd/ant-lib
|
||||
- jleveldb-v01.jar
|
||||
- jsch-20120101.jar
|
||||
- junit-4.10.jar
|
||||
- mysql-connector-java-5.1.18-bin.jar
|
||||
- sqlite-jdbc-3.7.6.3-20110609.081603-3.jar
|
||||
- h2-latest.jar
|
||||
|
||||
* Special tools for new rendering (GPLv3)
|
||||
- https://github.com/osmandapp/OsmAnd-tools
|
||||
- https://github.com/osmandapp/OsmAnd-tools/tree/master/obf-inspector
|
||||
- https://github.com/osmandapp/OsmAnd-tools/tree/master/obf-verifier
|
||||
- https://github.com/osmandapp/OsmAnd-tools/tree/master/route-tester
|
||||
|
||||
* OSM data
|
||||
- Extracts - https://github.com/osmandapp/OsmAnd-misc/tree/master/osm-planet/osm-data
|
||||
* OSM data 2014
|
||||
- Extracts - https://github.com/osmandapp/OsmAnd-misc/blob/master/osm-planet/osm-data/
|
||||
|
||||
* Data files
|
||||
- Country boundaries - https://github.com/osmandapp/OsmAnd-misc/tree/master/osm-planet/polygons © by Geofabrik - data free to use
|
||||
- Country boundaries - https://github.com/osmandapp/OsmAnd-misc/tree/master/osm-planet/geo-polygons © by Geofabrik - data free to use
|
||||
- Country boundaries - https://github.com/osmandapp/OsmAnd-misc/tree/master/osm-planet/gislab-polygons © by http://be.gis-lab.info - data free to use
|
||||
|
||||
* Subway icons
|
||||
- Moscow: Art Lebedev Studio (http://www.artlebedev.ru/everything/metro/logo/) [Public domain], undefined
|
||||
|
@ -97,7 +119,7 @@
|
|||
- Kazan: «Kazan-metro-Logo» (Россиянин) - own work. Under Public domain Commons license from the site - https://commons.wikimedia.org/wiki/File:Kazan-metro-Logo.svg#/media/File:Kazan-metro-Logo.svg
|
||||
- Tbilisi: «Metro Tbilisi logo» (Carnby) - own work. Under CC BY-SA 3.0 license from site - https://commons.wikimedia.org/wiki/File:Metro_Tbilisi_logo.svg#/media/File:Metro_Tbilisi_logo.svg
|
||||
- Minsk: «Minsk metro logo» (Skip405) - own work. Under Public domain Commons license from the site - https://commons.wikimedia.org/wiki/File:Minsk_metro_logo.svg#/media/File:Minsk_metro_logo.svg
|
||||
- Nizhny Novgorod: «NNMetro» (AlexTref871) - own work. This vector image includes elements borrowed from another image: Coat of arms of Nizhny Novgorod Region.svg.. Under Public domain Commons licensefrom the site - https://commons.wikimedia.org/wiki/File:NNMetro.svg#/media/File:NNMetro.svg
|
||||
- Nizhny Novgorod: «NNMetro» (AlexTref871) - own work. This vector image includes elements borrowed from another image: Coat of arms of Nizhny Novgorod Region.svg.. Under Public domain Commons licensefrom the site - https://commons.wikimedia.org/wiki/File:NNMetro.svg#/media/File:NNMetro.svg
|
||||
- Novosibirsk: «Logo-Nsk-Metro» (AlexTref871) - own work. Under Public domain Commons license from the site - https://commons.wikimedia.org/wiki/File:Logo-Nsk-Metro.svg#/media/File:Logo-Nsk-Metro.svg
|
||||
- Yekaterinburg: «Ekt-metro-logo-01» (AlexTref871) - own work. Under CC BY-SA 4.0 license from site - https://commons.wikimedia.org/wiki/File:Ekt-metro-logo-01.svg#/media/File:Ekt-metro-logo-01.svg
|
||||
- New York: «MTA New York City Subway logo» (Metropolitan Transportation Authority) - http://mta.info/. Under Public domain Commons license from the site - https://commons.wikimedia.org/wiki/File:MTA_New_York_City_Subway_logo.svg#/media/File:MTA_New_York_City_Subway_logo.svg
|
||||
|
@ -130,7 +152,7 @@
|
|||
- Los Angeles: "Lametro" by Los Angeles County Metropolitan Transportation Authority. Original uploader was Cheeselouise at en.wikipedia - Metro materials at http://www.metro.net/riding_metro/pocket_guide_cambodian_printers.pdf. Licensed under Public Domain via Commons - https://commons.wikimedia.org/wiki/File:Lametro.svg#/media/File:Lametro.svg
|
||||
|
||||
* Depth maps
|
||||
- The GEBCO_2020 Grid, www.gebco.net
|
||||
- The GEBCO_2014 Grid, version 20150318, www.gebco.net
|
||||
- U.S. Bureau of Ocean Energy Management (24 may 2017,12m per pixel)
|
||||
- South_Padre_Island_DEM_4133: Grothe, P.G., L.A. Taylor, B.W. Eakins, K.S. Carignan, D.Z. Friday, and M. Love, 2012. Digital Elevation Models of South Padre Island, Texas: Procedures, Data Sources and Analysis, NOAA National Geophysical Data Center technical report, Boulder, CO, 15 pp.
|
||||
- Corpus_Christi_DEM_1035: Taylor, L.A., B.W. Eakins, K.S. Carignan, R.R. Warnken, T. Sazonova, and D.C. Schoolcraft, 2008. Digital Elevation Model of Corpus Christi, Texas: Procedures, Data Sources and Analysis, NOAA Technical Memorandum NESDIS NGDC-11, National Geophysical Data Center, Boulder, CO, 19 pp.
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
apply plugin: 'com.android.library'
|
||||
apply plugin: 'ivy-publish'
|
||||
apply plugin: 'com.github.dcendents.android-maven'
|
||||
|
||||
group = 'com.github.osmandapp.osmand'
|
||||
version = '2.0.0'
|
||||
|
||||
android {
|
||||
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 {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
implementation 'com.android.support:support-annotations:28.0.0'
|
||||
|
@ -64,4 +38,4 @@ task sourcesJar(type: Jar) {
|
|||
|
||||
artifacts {
|
||||
archives sourcesJar
|
||||
}
|
||||
}
|
|
@ -51,9 +51,4 @@ interface IOsmAndAidlCallback {
|
|||
* Callback for {@link IOsmAndAidlInterface} registerForVoiceRouterMessages() method.
|
||||
*/
|
||||
void onVoiceRouterNotify(in OnVoiceNavigationParams params);
|
||||
|
||||
/**
|
||||
* Callback for {@link IOsmAndAidlInterface} registerForKeyEvents() method.
|
||||
*/
|
||||
void onKeyEvent(in KeyEvent params);
|
||||
}
|
|
@ -2,7 +2,6 @@ package net.osmand.aidlapi;
|
|||
|
||||
import net.osmand.aidlapi.map.ALatLon;
|
||||
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.AddFavoriteGroupParams;
|
||||
|
@ -21,8 +20,6 @@ import net.osmand.aidlapi.mapmarker.UpdateMapMarkerParams;
|
|||
|
||||
import net.osmand.aidlapi.calculateroute.CalculateRouteParams;
|
||||
|
||||
import net.osmand.aidlapi.profile.ExportProfileParams;
|
||||
|
||||
import net.osmand.aidlapi.gpx.ImportGpxParams;
|
||||
import net.osmand.aidlapi.gpx.ShowGpxParams;
|
||||
import net.osmand.aidlapi.gpx.StartGpxRecordingParams;
|
||||
|
@ -77,10 +74,6 @@ import net.osmand.aidlapi.customization.OsmandSettingsParams;
|
|||
import net.osmand.aidlapi.customization.OsmandSettingsInfoParams;
|
||||
import net.osmand.aidlapi.customization.CustomizationInfoParams;
|
||||
import net.osmand.aidlapi.customization.ProfileSettingsParams;
|
||||
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.AGpxFileDetails;
|
||||
|
@ -93,9 +86,6 @@ import net.osmand.aidlapi.copyfile.CopyFileParams;
|
|||
|
||||
import net.osmand.aidlapi.navigation.ANavigationUpdateParams;
|
||||
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.UpdateContextMenuButtonsParams;
|
||||
|
@ -106,14 +96,6 @@ import net.osmand.aidlapi.mapmarker.RemoveMapMarkersParams;
|
|||
import net.osmand.aidlapi.quickaction.QuickActionParams;
|
||||
import net.osmand.aidlapi.quickaction.QuickActionInfoParams;
|
||||
|
||||
import net.osmand.aidlapi.lock.SetLockStateParams;
|
||||
|
||||
import net.osmand.aidlapi.events.AKeyEventsParams;
|
||||
|
||||
import net.osmand.aidlapi.info.AppInfoParams;
|
||||
|
||||
import net.osmand.aidlapi.profile.ExportProfileParams;
|
||||
|
||||
// NOTE: Add new methods at the end of file!!!
|
||||
|
||||
interface IOsmAndAidlInterface {
|
||||
|
@ -859,49 +841,4 @@ interface IOsmAndAidlInterface {
|
|||
boolean executeQuickAction(in QuickActionParams params);
|
||||
|
||||
boolean getQuickActionsInfo(out List<QuickActionInfoParams> quickActions);
|
||||
|
||||
/**
|
||||
* Toggle Lock/Unlock screen.
|
||||
*/
|
||||
boolean setLockState(in SetLockStateParams params);
|
||||
|
||||
/**
|
||||
* Method to register for key events.
|
||||
*
|
||||
* @params subscribeToUpdates (boolean) - boolean flag to subscribe or unsubscribe from key events
|
||||
* @params callbackId (long) - id of callback, needed to unsubscribe key events
|
||||
* @params callback (IOsmAndAidlCallback) - callback to notify user on key event
|
||||
* @params keyEventList (List<Integer>) - list of requested key events
|
||||
*/
|
||||
long registerForKeyEvents(in AKeyEventsParams params, IOsmAndAidlCallback callback);
|
||||
|
||||
AppInfoParams getAppInfo();
|
||||
|
||||
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:
|
||||
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_MAP_MARKERS_ID = DRAWER_ITEM_ID_SCHEME + "map_markers";
|
||||
String DRAWER_MY_PLACES_ID = DRAWER_ITEM_ID_SCHEME + "my_places";
|
||||
String DRAWER_SEARCH_ID = DRAWER_ITEM_ID_SCHEME + "search";
|
||||
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_DOWNLOAD_MAPS_ID = DRAWER_ITEM_ID_SCHEME + "download_maps";
|
||||
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 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 byte[] filePartData;
|
||||
private long startTime;
|
||||
private boolean done;
|
||||
|
||||
public CopyFileParams(@NonNull String destinationDir, @NonNull String fileName, @NonNull byte[] filePartData,
|
||||
long startTime, boolean done) {
|
||||
|
||||
this.destinationDir = destinationDir;
|
||||
public CopyFileParams(@NonNull String fileName, @NonNull byte[] filePartData, long startTime, boolean done) {
|
||||
this.fileName = fileName;
|
||||
this.filePartData = filePartData;
|
||||
this.startTime = startTime;
|
||||
|
@ -46,10 +37,6 @@ public class CopyFileParams extends AidlParams {
|
|||
}
|
||||
};
|
||||
|
||||
public String getDestinationDir() {
|
||||
return destinationDir;
|
||||
}
|
||||
|
||||
public String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
|
@ -68,26 +55,23 @@ public class CopyFileParams extends AidlParams {
|
|||
|
||||
@Override
|
||||
public void writeToBundle(Bundle bundle) {
|
||||
bundle.putString(DESTINATION_DIR_KEY, destinationDir);
|
||||
bundle.putString(FILE_NAME_KEY, fileName);
|
||||
bundle.putByteArray(FILE_PART_DATA_KEY, filePartData);
|
||||
bundle.putLong(START_TIME_KEY, startTime);
|
||||
bundle.putBoolean(DONE_KEY, done);
|
||||
bundle.putString("fileName", fileName);
|
||||
bundle.putByteArray("filePartData", filePartData);
|
||||
bundle.putLong("startTime", startTime);
|
||||
bundle.putBoolean("done", done);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readFromBundle(Bundle bundle) {
|
||||
destinationDir = bundle.getString(DESTINATION_DIR_KEY);
|
||||
fileName = bundle.getString(FILE_NAME_KEY);
|
||||
filePartData = bundle.getByteArray(FILE_PART_DATA_KEY);
|
||||
startTime = bundle.getLong(START_TIME_KEY);
|
||||
done = bundle.getBoolean(DONE_KEY);
|
||||
fileName = bundle.getString("fileName");
|
||||
filePartData = bundle.getByteArray("filePartData");
|
||||
startTime = bundle.getLong("startTime");
|
||||
done = bundle.getBoolean("done");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CopyFileParams {" +
|
||||
" destinationDir=" + destinationDir +
|
||||
" fileName=" + fileName +
|
||||
", filePartData size=" + filePartData.length +
|
||||
", 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);
|
||||
}
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
package net.osmand.aidlapi.customization;
|
||||
|
||||
parcelable MapMarginsParams;
|
|
@ -1,90 +0,0 @@
|
|||
package net.osmand.aidlapi.customization;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcel;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import net.osmand.aidlapi.AidlParams;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MapMarginsParams extends AidlParams {
|
||||
|
||||
public static final String LEFT_MARGIN_KEY = "leftMargin";
|
||||
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 topMargin;
|
||||
private int rightMargin;
|
||||
private int bottomMargin;
|
||||
|
||||
public MapMarginsParams(int leftMargin, int topMargin, int rightMargin, int bottomMargin,
|
||||
@Nullable List<String> appModesKeys) {
|
||||
if (appModesKeys != null) {
|
||||
this.appModesKeys.addAll(appModesKeys);
|
||||
}
|
||||
this.leftMargin = leftMargin;
|
||||
this.topMargin = topMargin;
|
||||
this.rightMargin = rightMargin;
|
||||
this.bottomMargin = bottomMargin;
|
||||
}
|
||||
|
||||
public MapMarginsParams(Parcel in) {
|
||||
readFromParcel(in);
|
||||
}
|
||||
|
||||
public static final Creator<MapMarginsParams> CREATOR = new Creator<MapMarginsParams>() {
|
||||
@Override
|
||||
public MapMarginsParams createFromParcel(Parcel in) {
|
||||
return new MapMarginsParams(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MapMarginsParams[] newArray(int size) {
|
||||
return new MapMarginsParams[size];
|
||||
}
|
||||
};
|
||||
|
||||
public List<String> getAppModesKeys() {
|
||||
return appModesKeys;
|
||||
}
|
||||
|
||||
public int getLeftMargin() {
|
||||
return leftMargin;
|
||||
}
|
||||
|
||||
public int getTopMargin() {
|
||||
return topMargin;
|
||||
}
|
||||
|
||||
public int getRightMargin() {
|
||||
return rightMargin;
|
||||
}
|
||||
|
||||
public int getBottomMargin() {
|
||||
return bottomMargin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToBundle(Bundle bundle) {
|
||||
bundle.putInt(LEFT_MARGIN_KEY, leftMargin);
|
||||
bundle.putInt(TOP_MARGIN_KEY, topMargin);
|
||||
bundle.putInt(RIGHT_MARGIN_KEY, rightMargin);
|
||||
bundle.putInt(BOTTOM_MARGIN_KEY, bottomMargin);
|
||||
bundle.putStringArrayList(APP_MODES_KEYS_KEY, appModesKeys);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readFromBundle(Bundle bundle) {
|
||||
leftMargin = bundle.getInt(LEFT_MARGIN_KEY);
|
||||
topMargin = bundle.getInt(TOP_MARGIN_KEY);
|
||||
rightMargin = bundle.getInt(RIGHT_MARGIN_KEY);
|
||||
bottomMargin = bundle.getInt(BOTTOM_MARGIN_KEY);
|
||||
appModesKeys = bundle.getStringArrayList(APP_MODES_KEYS_KEY);
|
||||
}
|
||||
}
|
|
@ -5,42 +5,17 @@ import android.os.Bundle;
|
|||
import android.os.Parcel;
|
||||
|
||||
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 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 String latestChanges;
|
||||
private int version;
|
||||
private List<String> settingsTypeKeyList = new ArrayList<>();
|
||||
private boolean silent;
|
||||
private boolean replace;
|
||||
|
||||
public ProfileSettingsParams(Uri profileSettingsUri, List<AExportSettingsType> settingsTypeList, boolean replace,
|
||||
boolean silent, String latestChanges, int version) {
|
||||
public ProfileSettingsParams(Uri profileSettingsUri, String latestChanges, int version) {
|
||||
this.profileSettingsUri = profileSettingsUri;
|
||||
for (AExportSettingsType settingsType : settingsTypeList) {
|
||||
settingsTypeKeyList.add(settingsType.name());
|
||||
}
|
||||
this.replace = replace;
|
||||
this.latestChanges = latestChanges;
|
||||
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) {
|
||||
|
@ -71,35 +46,17 @@ public class ProfileSettingsParams extends AidlParams {
|
|||
return profileSettingsUri;
|
||||
}
|
||||
|
||||
public List<String> getSettingsTypeKeys() {
|
||||
return settingsTypeKeyList;
|
||||
}
|
||||
|
||||
public boolean isReplace() {
|
||||
return replace;
|
||||
}
|
||||
|
||||
public boolean isSilent() {
|
||||
return silent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToBundle(Bundle bundle) {
|
||||
bundle.putInt(VERSION_KEY, version);
|
||||
bundle.putString(LATEST_CHANGES_KEY, latestChanges);
|
||||
bundle.putParcelable(PROFILE_SETTINGS_URI_KEY, profileSettingsUri);
|
||||
bundle.putStringArrayList(SETTINGS_TYPE_KEY, new ArrayList<>(settingsTypeKeyList));
|
||||
bundle.putBoolean(REPLACE_KEY, replace);
|
||||
bundle.putBoolean(SILENT_IMPORT_KEY, silent);
|
||||
bundle.putInt("version", version);
|
||||
bundle.putString("latestChanges", latestChanges);
|
||||
bundle.putParcelable("profileSettingsUri", profileSettingsUri);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readFromBundle(Bundle bundle) {
|
||||
version = bundle.getInt(VERSION_KEY);
|
||||
latestChanges = bundle.getString(LATEST_CHANGES_KEY);
|
||||
profileSettingsUri = bundle.getParcelable(PROFILE_SETTINGS_URI_KEY);
|
||||
settingsTypeKeyList = bundle.getStringArrayList(SETTINGS_TYPE_KEY);
|
||||
replace = bundle.getBoolean(REPLACE_KEY);
|
||||
silent = bundle.getBoolean(SILENT_IMPORT_KEY);
|
||||
version = bundle.getInt("version");
|
||||
latestChanges = bundle.getString("latestChanges");
|
||||
profileSettingsUri = bundle.getParcelable("profileSettingsUri");
|
||||
}
|
||||
}
|
|
@ -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,2 +0,0 @@
|
|||
package net.osmand.aidlapi.events;
|
||||
parcelable AKeyEventsParams;
|
|
@ -1,73 +0,0 @@
|
|||
package net.osmand.aidlapi.events;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import net.osmand.aidlapi.AidlParams;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class AKeyEventsParams extends AidlParams {
|
||||
|
||||
private long callbackId = -1L;
|
||||
private boolean subscribeToUpdates = true;
|
||||
private ArrayList<Integer> keyEventList;
|
||||
|
||||
public AKeyEventsParams() {
|
||||
}
|
||||
|
||||
protected AKeyEventsParams(Parcel in) {
|
||||
readFromParcel(in);
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator<AKeyEventsParams> CREATOR = new Parcelable.Creator<AKeyEventsParams>() {
|
||||
@Override
|
||||
public AKeyEventsParams createFromParcel(Parcel in) {
|
||||
return new AKeyEventsParams(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AKeyEventsParams[] newArray(int size) {
|
||||
return new AKeyEventsParams[size];
|
||||
}
|
||||
};
|
||||
|
||||
public long getCallbackId() {
|
||||
return callbackId;
|
||||
}
|
||||
|
||||
public void setCallbackId(long callbackId) {
|
||||
this.callbackId = callbackId;
|
||||
}
|
||||
|
||||
public void setSubscribeToUpdates(boolean subscribeToUpdates) {
|
||||
this.subscribeToUpdates = subscribeToUpdates;
|
||||
}
|
||||
|
||||
public boolean isSubscribeToUpdates() {
|
||||
return subscribeToUpdates;
|
||||
}
|
||||
|
||||
public void setKeyEventList(ArrayList<Integer> keyEventList) {
|
||||
this.keyEventList = keyEventList;
|
||||
}
|
||||
|
||||
public ArrayList<Integer> getKeyEventList() {
|
||||
return keyEventList;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readFromBundle(Bundle bundle) {
|
||||
callbackId = bundle.getLong("callbackId");
|
||||
subscribeToUpdates = bundle.getBoolean("subscribeToUpdates");
|
||||
keyEventList = bundle.getIntegerArrayList("keyEventList");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToBundle(Bundle bundle) {
|
||||
bundle.putLong("callbackId", callbackId);
|
||||
bundle.putBoolean("subscribeToUpdates", subscribeToUpdates);
|
||||
bundle.putIntegerArrayList("keyEventList", keyEventList);
|
||||
}
|
||||
}
|
|
@ -11,18 +11,16 @@ public class AFavorite extends AidlParams {
|
|||
private double lon;
|
||||
private String name;
|
||||
private String description;
|
||||
private String address;
|
||||
private String category;
|
||||
private String color;
|
||||
private boolean visible;
|
||||
|
||||
public AFavorite(double lat, double lon, String name, String description, String address,
|
||||
public AFavorite(double lat, double lon, String name, String description,
|
||||
String category, String color, boolean visible) {
|
||||
this.lat = lat;
|
||||
this.lon = lon;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.address = address;
|
||||
this.category = category;
|
||||
this.color = color;
|
||||
this.visible = visible;
|
||||
|
@ -60,8 +58,6 @@ public class AFavorite extends AidlParams {
|
|||
return description;
|
||||
}
|
||||
|
||||
public String getAddress() { return address; }
|
||||
|
||||
public String getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
@ -80,7 +76,6 @@ public class AFavorite extends AidlParams {
|
|||
bundle.putDouble("lon", lon);
|
||||
bundle.putString("name", name);
|
||||
bundle.putString("description", description);
|
||||
bundle.putString("address", address);
|
||||
bundle.putString("category", category);
|
||||
bundle.putString("color", color);
|
||||
bundle.putBoolean("visible", visible);
|
||||
|
@ -92,7 +87,6 @@ public class AFavorite extends AidlParams {
|
|||
lon = bundle.getDouble("lon");
|
||||
name = bundle.getString("name");
|
||||
description = bundle.getString("description");
|
||||
address = bundle.getString("address");
|
||||
category = bundle.getString("category");
|
||||
color = bundle.getString("color");
|
||||
visible = bundle.getBoolean("visible");
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
package net.osmand.aidlapi.info;
|
||||
|
||||
parcelable AppInfoParams;
|
|
@ -1,95 +0,0 @@
|
|||
package net.osmand.aidlapi.info;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcel;
|
||||
|
||||
import net.osmand.aidlapi.AidlParams;
|
||||
import net.osmand.aidlapi.map.ALatLon;
|
||||
|
||||
public class AppInfoParams extends AidlParams {
|
||||
|
||||
private ALatLon lastKnownLocation;
|
||||
private ALatLon mapLocation;
|
||||
|
||||
private Bundle turnInfo;
|
||||
private int leftTime;
|
||||
private int leftDistance;
|
||||
private long arrivalTime;
|
||||
private boolean mapVisible;
|
||||
|
||||
public AppInfoParams(ALatLon lastKnownLocation, ALatLon mapLocation, Bundle turnInfo, int leftTime, int leftDistance, long arrivalTime, boolean mapVisible) {
|
||||
this.lastKnownLocation = lastKnownLocation;
|
||||
this.mapLocation = mapLocation;
|
||||
this.leftTime = leftTime;
|
||||
this.leftDistance = leftDistance;
|
||||
this.arrivalTime = arrivalTime;
|
||||
this.turnInfo = turnInfo;
|
||||
this.mapVisible = mapVisible;
|
||||
}
|
||||
|
||||
public AppInfoParams(Parcel in) {
|
||||
readFromParcel(in);
|
||||
}
|
||||
|
||||
public static final Creator<AppInfoParams> CREATOR = new Creator<AppInfoParams>() {
|
||||
@Override
|
||||
public AppInfoParams createFromParcel(Parcel in) {
|
||||
return new AppInfoParams(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppInfoParams[] newArray(int size) {
|
||||
return new AppInfoParams[size];
|
||||
}
|
||||
};
|
||||
|
||||
public ALatLon getLastKnownLocation() {
|
||||
return lastKnownLocation;
|
||||
}
|
||||
|
||||
public ALatLon getMapLocation() {
|
||||
return mapLocation;
|
||||
}
|
||||
|
||||
public int getLeftTime() {
|
||||
return leftTime;
|
||||
}
|
||||
|
||||
public long getArrivalTime() {
|
||||
return arrivalTime;
|
||||
}
|
||||
|
||||
public int getLeftDistance() {
|
||||
return leftDistance;
|
||||
}
|
||||
|
||||
public boolean isMapVisible() {
|
||||
return mapVisible;
|
||||
}
|
||||
|
||||
public Bundle getTurnInfo() {
|
||||
return turnInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToBundle(Bundle bundle) {
|
||||
bundle.putParcelable("lastKnownLocation", lastKnownLocation);
|
||||
bundle.putParcelable("mapLocation", mapLocation);
|
||||
bundle.putInt("leftTime", leftTime);
|
||||
bundle.putLong("arrivalTime", arrivalTime);
|
||||
bundle.putInt("leftDistance", leftDistance);
|
||||
bundle.putBundle("turnInfo", turnInfo);
|
||||
bundle.putBoolean("mapVisible", mapVisible);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readFromBundle(Bundle bundle) {
|
||||
lastKnownLocation = bundle.getParcelable("lastKnownLocation");
|
||||
mapLocation = bundle.getParcelable("mapLocation");
|
||||
leftTime = bundle.getInt("leftTime");
|
||||
arrivalTime = bundle.getLong("arrivalTime");
|
||||
leftDistance = bundle.getInt("leftDistance");
|
||||
turnInfo = bundle.getBundle("turnInfo");
|
||||
mapVisible = bundle.getBoolean("mapVisible");
|
||||
}
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
package net.osmand.aidlapi.lock;
|
||||
|
||||
parcelable SetLockStateParams;
|
|
@ -1,45 +0,0 @@
|
|||
package net.osmand.aidlapi.lock;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcel;
|
||||
|
||||
import net.osmand.aidlapi.AidlParams;
|
||||
|
||||
public class SetLockStateParams extends AidlParams {
|
||||
|
||||
private boolean lock;
|
||||
|
||||
public SetLockStateParams(boolean lock) {
|
||||
this.lock = lock;
|
||||
}
|
||||
|
||||
public SetLockStateParams(Parcel in) {
|
||||
readFromParcel(in);
|
||||
}
|
||||
|
||||
public static final Creator<SetLockStateParams> CREATOR = new Creator<SetLockStateParams>() {
|
||||
@Override
|
||||
public SetLockStateParams createFromParcel(Parcel in) {
|
||||
return new SetLockStateParams(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SetLockStateParams[] newArray(int size) {
|
||||
return new SetLockStateParams[size];
|
||||
}
|
||||
};
|
||||
|
||||
public boolean getLockState() {
|
||||
return lock;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToBundle(Bundle bundle) {
|
||||
bundle.putBoolean("lock", this.lock);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readFromBundle(Bundle bundle) {
|
||||
lock = bundle.getBoolean("lock");
|
||||
}
|
||||
}
|
|
@ -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");
|
||||
}
|
||||
}
|
|
@ -10,14 +10,12 @@ public class SetMapLocationParams extends AidlParams {
|
|||
private double latitude;
|
||||
private double longitude;
|
||||
private int zoom;
|
||||
private float rotation;
|
||||
private boolean animated;
|
||||
|
||||
public SetMapLocationParams(double latitude, double longitude, int zoom, float rotation, boolean animated) {
|
||||
public SetMapLocationParams(double latitude, double longitude, int zoom, boolean animated) {
|
||||
this.latitude = latitude;
|
||||
this.longitude = longitude;
|
||||
this.zoom = zoom;
|
||||
this.rotation = rotation;
|
||||
this.animated = animated;
|
||||
}
|
||||
|
||||
|
@ -49,10 +47,6 @@ public class SetMapLocationParams extends AidlParams {
|
|||
return zoom;
|
||||
}
|
||||
|
||||
public float getRotation() {
|
||||
return rotation;
|
||||
}
|
||||
|
||||
public boolean isAnimated() {
|
||||
return animated;
|
||||
}
|
||||
|
@ -62,7 +56,6 @@ public class SetMapLocationParams extends AidlParams {
|
|||
bundle.putDouble("latitude", latitude);
|
||||
bundle.putDouble("longitude", longitude);
|
||||
bundle.putInt("zoom", zoom);
|
||||
bundle.putFloat("rotation", rotation);
|
||||
bundle.putBoolean("animated", animated);
|
||||
}
|
||||
|
||||
|
@ -71,7 +64,6 @@ public class SetMapLocationParams extends AidlParams {
|
|||
latitude = bundle.getDouble("latitude");
|
||||
longitude = bundle.getDouble("longitude");
|
||||
zoom = bundle.getInt("zoom");
|
||||
rotation = bundle.getFloat("rotation");
|
||||
animated = bundle.getBoolean("animated");
|
||||
}
|
||||
}
|
|
@ -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 Uri uri;
|
||||
private boolean force;
|
||||
private boolean needLocationPermission;
|
||||
|
||||
public NavigateGpxParams(String data, boolean force, boolean needLocationPermission) {
|
||||
public NavigateGpxParams(String data, boolean force) {
|
||||
this.data = data;
|
||||
this.force = force;
|
||||
this.needLocationPermission = needLocationPermission;
|
||||
}
|
||||
|
||||
public NavigateGpxParams(Uri uri, boolean force, boolean needLocationPermission) {
|
||||
public NavigateGpxParams(Uri uri, boolean force) {
|
||||
this.uri = uri;
|
||||
this.force = force;
|
||||
this.needLocationPermission = needLocationPermission;
|
||||
}
|
||||
|
||||
public NavigateGpxParams(Parcel in) {
|
||||
|
@ -53,16 +50,11 @@ public class NavigateGpxParams extends AidlParams {
|
|||
return force;
|
||||
}
|
||||
|
||||
public boolean isNeedLocationPermission() {
|
||||
return needLocationPermission;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToBundle(Bundle bundle) {
|
||||
bundle.putString("data", data);
|
||||
bundle.putParcelable("uri", uri);
|
||||
bundle.putBoolean("force", force);
|
||||
bundle.putBoolean("needLocationPermission", needLocationPermission);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -70,6 +62,5 @@ public class NavigateGpxParams extends AidlParams {
|
|||
data = bundle.getString("data");
|
||||
uri = bundle.getParcelable("uri");
|
||||
force = bundle.getBoolean("force");
|
||||
needLocationPermission = bundle.getBoolean("needLocationPermission");
|
||||
}
|
||||
}
|
|
@ -17,10 +17,8 @@ public class NavigateParams extends AidlParams {
|
|||
private double destLon;
|
||||
|
||||
private boolean force;
|
||||
private boolean needLocationPermission;
|
||||
|
||||
public NavigateParams(String startName, double startLat, double startLon, String destName, double destLat,
|
||||
double destLon, String profile, boolean force, boolean needLocationPermission) {
|
||||
public NavigateParams(String startName, double startLat, double startLon, String destName, double destLat, double destLon, String profile, boolean force) {
|
||||
this.startName = startName;
|
||||
this.startLat = startLat;
|
||||
this.startLon = startLon;
|
||||
|
@ -29,7 +27,6 @@ public class NavigateParams extends AidlParams {
|
|||
this.destLon = destLon;
|
||||
this.profile = profile;
|
||||
this.force = force;
|
||||
this.needLocationPermission = needLocationPermission;
|
||||
}
|
||||
|
||||
public NavigateParams(Parcel in) {
|
||||
|
@ -80,10 +77,6 @@ public class NavigateParams extends AidlParams {
|
|||
return force;
|
||||
}
|
||||
|
||||
public boolean isNeedLocationPermission() {
|
||||
return needLocationPermission;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToBundle(Bundle bundle) {
|
||||
bundle.putString("startName", startName);
|
||||
|
@ -94,7 +87,6 @@ public class NavigateParams extends AidlParams {
|
|||
bundle.putDouble("destLon", destLon);
|
||||
bundle.putString("profile", profile);
|
||||
bundle.putBoolean("force", force);
|
||||
bundle.putBoolean("needLocationPermission", needLocationPermission);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -107,6 +99,5 @@ public class NavigateParams extends AidlParams {
|
|||
destLon = bundle.getDouble("destLon");
|
||||
profile = bundle.getString("profile");
|
||||
force = bundle.getBoolean("force");
|
||||
needLocationPermission = bundle.getBoolean("needLocationPermission");
|
||||
}
|
||||
}
|
|
@ -17,11 +17,10 @@ public class NavigateSearchParams extends AidlParams {
|
|||
private double searchLon;
|
||||
|
||||
private boolean force;
|
||||
private boolean needLocationPermission;
|
||||
|
||||
public NavigateSearchParams(String startName, double startLat, double startLon,
|
||||
String searchQuery, double searchLat, double searchLon,
|
||||
String profile, boolean force, boolean needLocationPermission) {
|
||||
String searchQuery, double searchLat, double searchLon,
|
||||
String profile, boolean force) {
|
||||
this.startName = startName;
|
||||
this.startLat = startLat;
|
||||
this.startLon = startLon;
|
||||
|
@ -30,7 +29,6 @@ public class NavigateSearchParams extends AidlParams {
|
|||
this.searchLon = searchLon;
|
||||
this.profile = profile;
|
||||
this.force = force;
|
||||
this.needLocationPermission = needLocationPermission;
|
||||
}
|
||||
|
||||
public NavigateSearchParams(Parcel in) {
|
||||
|
@ -81,10 +79,6 @@ public class NavigateSearchParams extends AidlParams {
|
|||
return force;
|
||||
}
|
||||
|
||||
public boolean isNeedLocationPermission() {
|
||||
return needLocationPermission;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToBundle(Bundle bundle) {
|
||||
bundle.putString("startName", startName);
|
||||
|
@ -95,7 +89,6 @@ public class NavigateSearchParams extends AidlParams {
|
|||
bundle.putBoolean("force", force);
|
||||
bundle.putDouble("searchLat", searchLat);
|
||||
bundle.putDouble("searchLon", searchLon);
|
||||
bundle.putBoolean("needLocationPermission", needLocationPermission);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -108,6 +101,5 @@ public class NavigateSearchParams extends AidlParams {
|
|||
force = bundle.getBoolean("force");
|
||||
searchLat = bundle.getDouble("searchLat");
|
||||
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: 'maven-publish'
|
||||
apply plugin: 'ivy-publish'
|
||||
|
||||
|
||||
configurations {
|
||||
android
|
||||
}
|
||||
|
@ -44,7 +43,6 @@ task collectTestResources(type: Copy) {
|
|||
into "src/test/resources/"
|
||||
from("../../resources/test-resources") {
|
||||
include "*"
|
||||
include "/search/*"
|
||||
}
|
||||
from("../../resources/poi") {
|
||||
include "poi_types.xml"
|
||||
|
@ -86,22 +84,12 @@ artifacts {
|
|||
}
|
||||
|
||||
publishing {
|
||||
repositories {
|
||||
ivy {
|
||||
url = System.getenv("OSMAND_BINARIES_IVY_ROOT") ?: "./"
|
||||
}
|
||||
}
|
||||
publications {
|
||||
maven(MavenPublication) {
|
||||
artifactId "osmand-base"
|
||||
from components.java
|
||||
}
|
||||
ivyJava(IvyPublication) {
|
||||
artifact androidJar {
|
||||
classifier 'android'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
@ -115,9 +103,6 @@ dependencies {
|
|||
implementation 'com.moparisthebest:junidecode:0.1.1'
|
||||
implementation 'com.vividsolutions:jts-core:1.14.0'
|
||||
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
|
||||
//implementation 'com.atilika.kuromoji:kuromoji-ipadic:0.9.0'
|
||||
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
|
||||
// the lock for as short a time as possible.
|
||||
cachedFlushBuffers =
|
||||
flushedBuffers.toArray(new ByteString[0]);
|
||||
flushedBuffers.toArray(new ByteString[flushedBuffers.size()]);
|
||||
cachedBuffer = buffer;
|
||||
cachedBufferPos = bufferPos;
|
||||
}
|
||||
|
|
|
@ -242,7 +242,8 @@ final class FieldSet<FieldDescriptorType extends
|
|||
|
||||
// Wrap the contents in a new list so that the caller cannot change
|
||||
// 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) {
|
||||
verifyType(descriptor.getLiteType(), element);
|
||||
}
|
||||
|
|
|
@ -14,11 +14,6 @@
|
|||
|
||||
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 {
|
||||
|
||||
/**
|
||||
|
@ -109,15 +104,6 @@ public class MGRSPoint extends ZonedUTMPoint {
|
|||
* an UPPERCASE coordinate string is expected.
|
||||
*/
|
||||
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) {
|
||||
throw new NumberFormatException("MGRSPoint coverting from nothing");
|
||||
}
|
||||
|
@ -647,96 +633,6 @@ public class MGRSPoint extends ZonedUTMPoint {
|
|||
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}
|
||||
*/
|
||||
|
|
|
@ -345,6 +345,7 @@ public final class JtsAdapter {
|
|||
for(int i = 0; i < geom.getNumGeometries(); ++i) {
|
||||
|
||||
final Polygon nextPoly = (Polygon) geom.getGeometryN(i);
|
||||
final List<Integer> nextPolyGeom = new ArrayList<>();
|
||||
boolean valid = true;
|
||||
|
||||
// Add exterior ring
|
||||
|
@ -361,7 +362,7 @@ public final class JtsAdapter {
|
|||
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
|
||||
|
|
|
@ -322,7 +322,7 @@ public final class MvtReader {
|
|||
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);
|
||||
|
||||
} 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 (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();
|
||||
}
|
||||
|
||||
|
@ -533,7 +533,7 @@ public final class MvtReader {
|
|||
|
||||
if (outerPoly != null) {
|
||||
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;
|
||||
|
@ -569,7 +569,7 @@ public final class MvtReader {
|
|||
|
||||
if (outerPoly == null || (outerArea < 0 == area < 0)) {
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -590,7 +590,7 @@ public final class MvtReader {
|
|||
|
||||
if (outerPoly != null) {
|
||||
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;
|
||||
|
|
|
@ -33,18 +33,8 @@ public class CollatorStringMatcher implements StringMatcher {
|
|||
|
||||
public CollatorStringMatcher(String part, StringMatcherMode mode) {
|
||||
this.collator = OsmAndCollator.primaryCollator();
|
||||
part = simplifyStringAndAlignChars(part);
|
||||
if (part.length() > 0 && part.charAt(part.length() - 1) == '.') {
|
||||
part = part.substring(0, part.length() - 1);
|
||||
if (mode == StringMatcherMode.CHECK_EQUALS_FROM_SPACE) {
|
||||
mode = StringMatcherMode.CHECK_STARTS_FROM_SPACE;
|
||||
} else if (mode == StringMatcherMode.CHECK_EQUALS) {
|
||||
mode = StringMatcherMode.CHECK_ONLY_STARTS_WITH;
|
||||
}
|
||||
}
|
||||
this.part = part;
|
||||
this.part = part.toLowerCase(Locale.getDefault());
|
||||
this.mode = mode;
|
||||
|
||||
}
|
||||
|
||||
public Collator getCollator() {
|
||||
|
@ -133,15 +123,14 @@ public class CollatorStringMatcher implements StringMatcher {
|
|||
* @param theStart
|
||||
* @return true if searchIn starts with token
|
||||
*/
|
||||
public static boolean cstartsWith(Collator collator, String fullTextP, String theStart,
|
||||
public static boolean cstartsWith(Collator collator, String fullText, String theStart,
|
||||
boolean checkBeginning, boolean checkSpaces, boolean equals) {
|
||||
String searchIn = simplifyStringAndAlignChars(fullTextP);
|
||||
String searchIn = fullText.toLowerCase(Locale.getDefault());
|
||||
int searchInLength = searchIn.length();
|
||||
int startLength = theStart.length();
|
||||
if (startLength == 0) {
|
||||
return true;
|
||||
}
|
||||
// this is not correct because of Auhofstrasse != Auhofstraße
|
||||
if (startLength > searchInLength) {
|
||||
return false;
|
||||
}
|
||||
|
@ -163,8 +152,7 @@ public class CollatorStringMatcher implements StringMatcher {
|
|||
if (isSpace(searchIn.charAt(i - 1)) && !isSpace(searchIn.charAt(i))) {
|
||||
if (collator.equals(searchIn.substring(i, i + startLength), theStart)) {
|
||||
if(equals) {
|
||||
if(i + startLength == searchInLength ||
|
||||
isSpace(searchIn.charAt(i + startLength))) {
|
||||
if(i + startLength == searchInLength || isSpace(searchIn.charAt(i + startLength))) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
|
@ -180,17 +168,7 @@ public class CollatorStringMatcher implements StringMatcher {
|
|||
return false;
|
||||
}
|
||||
|
||||
private static String simplifyStringAndAlignChars(String fullText) {
|
||||
int i;
|
||||
fullText = fullText.toLowerCase(Locale.getDefault());
|
||||
while( (i = fullText.indexOf('ß') ) != -1 ) {
|
||||
fullText = fullText.substring(0, i) + "ss" + fullText.substring(i+1);
|
||||
}
|
||||
return fullText;
|
||||
}
|
||||
|
||||
private static boolean isSpace(char c){
|
||||
return !Character.isLetter(c) && !Character.isDigit(c);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,12 +1,7 @@
|
|||
|
||||
package net.osmand;
|
||||
|
||||
|
||||
import net.osmand.binary.StringBundle;
|
||||
import net.osmand.binary.StringBundleWriter;
|
||||
import net.osmand.binary.StringBundleXmlWriter;
|
||||
import net.osmand.data.QuadRect;
|
||||
import net.osmand.router.RouteColorize.ColorizationType;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
@ -17,6 +12,7 @@ import org.xmlpull.v1.XmlSerializer;
|
|||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
@ -46,23 +42,17 @@ import java.util.Stack;
|
|||
import java.util.TimeZone;
|
||||
|
||||
public class GPXUtilities {
|
||||
|
||||
public final static Log log = PlatformUtil.getLog(GPXUtilities.class);
|
||||
|
||||
private static final String ICON_NAME_EXTENSION = "icon";
|
||||
private static final String DEFAULT_ICON_NAME = "special_star";
|
||||
private static final String BACKGROUND_TYPE_EXTENSION = "background";
|
||||
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";
|
||||
|
||||
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 NumberFormat latLonFormat = new DecimalFormat("0.00#####", new DecimalFormatSymbols(
|
||||
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")));
|
||||
|
||||
public enum GPXColor {
|
||||
|
@ -73,7 +63,6 @@ public class GPXUtilities {
|
|||
WHITE(0xFFFFFFFF),
|
||||
RED(0xFFFF0000),
|
||||
GREEN(0xFF00FF00),
|
||||
DARKGREEN(0xFF006400),
|
||||
BLUE(0xFF0000FF),
|
||||
YELLOW(0xFFFFFF00),
|
||||
CYAN(0xFF00FFFF),
|
||||
|
@ -126,20 +115,6 @@ public class GPXUtilities {
|
|||
return extensions;
|
||||
}
|
||||
|
||||
public Map<String, String> getExtensionsToWrite() {
|
||||
if (extensions == null) {
|
||||
extensions = new LinkedHashMap<>();
|
||||
}
|
||||
return extensions;
|
||||
}
|
||||
|
||||
public void copyExtensions(GPXExtensions e) {
|
||||
Map<String, String> extensionsToRead = e.getExtensionsToRead();
|
||||
if (!extensionsToRead.isEmpty()) {
|
||||
getExtensionsToWrite().putAll(extensionsToRead);
|
||||
}
|
||||
}
|
||||
|
||||
public GPXExtensionsWriter getExtensionsWriter() {
|
||||
return extensionsWriter;
|
||||
}
|
||||
|
@ -173,7 +148,14 @@ public class GPXUtilities {
|
|||
getExtensionsToWrite().remove("color");
|
||||
}
|
||||
|
||||
protected int parseColor(String colorString, int defColor) {
|
||||
public Map<String, String> getExtensionsToWrite() {
|
||||
if (extensions == null) {
|
||||
extensions = new LinkedHashMap<>();
|
||||
}
|
||||
return extensions;
|
||||
}
|
||||
|
||||
private int parseColor(String colorString, int defColor) {
|
||||
if (!Algorithms.isEmpty(colorString)) {
|
||||
if (colorString.charAt(0) == '#') {
|
||||
long color = Long.parseLong(colorString.substring(1), 16);
|
||||
|
@ -228,9 +210,6 @@ public class GPXUtilities {
|
|||
public double hdop = Double.NaN;
|
||||
public float heading = Float.NaN;
|
||||
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 double distance = 0.0; // cumulative distance, if in a track
|
||||
|
||||
|
@ -253,9 +232,6 @@ public class GPXUtilities {
|
|||
this.hdop = wptPt.hdop;
|
||||
this.heading = wptPt.heading;
|
||||
this.deleted = wptPt.deleted;
|
||||
this.speedColor = wptPt.speedColor;
|
||||
this.altitudeColor = wptPt.altitudeColor;
|
||||
this.slopeColor = wptPt.slopeColor;
|
||||
this.colourARGB = wptPt.colourARGB;
|
||||
this.distance = wptPt.distance;
|
||||
}
|
||||
|
@ -318,26 +294,6 @@ public class GPXUtilities {
|
|||
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() {
|
||||
return getExtensionsToRead().get(BACKGROUND_TYPE_EXTENSION);
|
||||
}
|
||||
|
@ -346,44 +302,6 @@ public class GPXUtilities {
|
|||
getExtensionsToWrite().put(BACKGROUND_TYPE_EXTENSION, backType);
|
||||
}
|
||||
|
||||
public String getProfileType() {
|
||||
return getExtensionsToRead().get(PROFILE_TYPE_EXTENSION);
|
||||
}
|
||||
|
||||
public void setProfileType(String 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() {
|
||||
getExtensionsToWrite().remove(PROFILE_TYPE_EXTENSION);
|
||||
}
|
||||
|
||||
public int getTrkPtIndex() {
|
||||
try {
|
||||
return Integer.parseInt(getExtensionsToRead().get(TRKPT_INDEX_EXTENSION));
|
||||
} catch (NumberFormatException e) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
public void setTrkPtIndex(int index) {
|
||||
getExtensionsToWrite().put(TRKPT_INDEX_EXTENSION, String.valueOf(index));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
|
@ -418,16 +336,11 @@ public class GPXUtilities {
|
|||
|
||||
public static class TrkSegment extends GPXExtensions {
|
||||
public boolean generalSegment = false;
|
||||
|
||||
public List<WptPt> points = new ArrayList<>();
|
||||
|
||||
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) {
|
||||
return split(getDistanceMetric(), getTimeSplit(), meters, joinSegments);
|
||||
|
@ -442,6 +355,7 @@ public class GPXUtilities {
|
|||
splitSegment(metric, secondaryMetric, metricLimit, splitSegments, this, joinSegments);
|
||||
return convert(splitSegments);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class Track extends GPXExtensions {
|
||||
|
@ -477,10 +391,6 @@ public class GPXUtilities {
|
|||
public String getArticleLang() {
|
||||
return getExtensionsToRead().get("article_lang");
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return getExtensionsToRead().get("desc");
|
||||
}
|
||||
}
|
||||
|
||||
public static class Author extends GPXExtensions {
|
||||
|
@ -502,65 +412,6 @@ public class GPXUtilities {
|
|||
public double maxlon;
|
||||
}
|
||||
|
||||
public static class RouteSegment {
|
||||
public String id;
|
||||
public String length;
|
||||
public String segmentTime;
|
||||
public String speed;
|
||||
public String turnType;
|
||||
public String turnAngle;
|
||||
public String types;
|
||||
public String pointTypes;
|
||||
public String names;
|
||||
|
||||
public static RouteSegment fromStringBundle(StringBundle bundle) {
|
||||
RouteSegment s = new RouteSegment();
|
||||
s.id = bundle.getString("id", null);
|
||||
s.length = bundle.getString("length", null);
|
||||
s.segmentTime = bundle.getString("segmentTime", null);
|
||||
s.speed = bundle.getString("speed", null);
|
||||
s.turnType = bundle.getString("turnType", null);
|
||||
s.turnAngle = bundle.getString("turnAngle", null);
|
||||
s.types = bundle.getString("types", null);
|
||||
s.pointTypes = bundle.getString("pointTypes", null);
|
||||
s.names = bundle.getString("names", null);
|
||||
return s;
|
||||
}
|
||||
|
||||
public StringBundle toStringBundle() {
|
||||
StringBundle bundle = new StringBundle();
|
||||
bundle.putString("id", id);
|
||||
bundle.putString("length", length);
|
||||
bundle.putString("segmentTime", segmentTime);
|
||||
bundle.putString("speed", speed);
|
||||
bundle.putString("turnType", turnType);
|
||||
bundle.putString("turnAngle", turnAngle);
|
||||
bundle.putString("types", types);
|
||||
bundle.putString("pointTypes", pointTypes);
|
||||
bundle.putString("names", names);
|
||||
return bundle;
|
||||
}
|
||||
}
|
||||
|
||||
public static class RouteType {
|
||||
public String tag;
|
||||
public String value;
|
||||
|
||||
public static RouteType fromStringBundle(StringBundle bundle) {
|
||||
RouteType t = new RouteType();
|
||||
t.tag = bundle.getString("t", null);
|
||||
t.value = bundle.getString("v", null);
|
||||
return t;
|
||||
}
|
||||
|
||||
public StringBundle toStringBundle() {
|
||||
StringBundle bundle = new StringBundle();
|
||||
bundle.putString("t", tag);
|
||||
bundle.putString("v", value);
|
||||
return bundle;
|
||||
}
|
||||
}
|
||||
|
||||
public static class GPXTrackAnalysis {
|
||||
public float totalDistance = 0;
|
||||
public float totalDistanceWithoutGaps = 0;
|
||||
|
@ -1081,6 +932,7 @@ public class GPXUtilities {
|
|||
|
||||
sp = new SplitSegment(segment, k - 1, cf);
|
||||
currentMetricEnd += metricLimit;
|
||||
prev = sp.get(0);
|
||||
}
|
||||
total += currentSegment;
|
||||
}
|
||||
|
@ -1105,33 +957,6 @@ public class GPXUtilities {
|
|||
return ls;
|
||||
}
|
||||
|
||||
public static QuadRect calculateBounds(List<WptPt> pts) {
|
||||
QuadRect trackBounds = new QuadRect(Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY,
|
||||
Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);
|
||||
updateBounds(trackBounds, pts, 0);
|
||||
|
||||
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) {
|
||||
for (int i = startIndex; i < pts.size(); i++) {
|
||||
WptPt pt = pts.get(i);
|
||||
trackBounds.right = Math.max(trackBounds.right, pt.lon);
|
||||
trackBounds.left = Math.min(trackBounds.left, pt.lon);
|
||||
trackBounds.top = Math.max(trackBounds.top, pt.lat);
|
||||
trackBounds.bottom = Math.min(trackBounds.bottom, pt.lat);
|
||||
}
|
||||
}
|
||||
|
||||
public static class GPXFile extends GPXExtensions {
|
||||
public String author;
|
||||
public Metadata metadata;
|
||||
|
@ -1165,10 +990,6 @@ public class GPXUtilities {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean hasRoute() {
|
||||
return getNonEmptyTrkSegments(true).size() > 0;
|
||||
}
|
||||
|
||||
public List<WptPt> getPoints() {
|
||||
return Collections.unmodifiableList(points);
|
||||
}
|
||||
|
@ -1276,7 +1097,7 @@ public class GPXUtilities {
|
|||
GPXTrackAnalysis g = new GPXTrackAnalysis();
|
||||
g.wptPoints = points.size();
|
||||
g.wptCategoryNames = getWaypointCategories(true);
|
||||
List<SplitSegment> splitSegments = new ArrayList<>();
|
||||
List<SplitSegment> splitSegments = new ArrayList<GPXUtilities.SplitSegment>();
|
||||
for (int i = 0; i < tracks.size(); i++) {
|
||||
Track subtrack = tracks.get(i);
|
||||
for (TrkSegment segment : subtrack.segments) {
|
||||
|
@ -1288,14 +1109,10 @@ public class GPXUtilities {
|
|||
}
|
||||
}
|
||||
}
|
||||
g.prepareInformation(fileTimestamp, splitSegments.toArray(new SplitSegment[0]));
|
||||
g.prepareInformation(fileTimestamp, splitSegments.toArray(new SplitSegment[splitSegments.size()]));
|
||||
return g;
|
||||
}
|
||||
|
||||
public boolean containsRoutePoint(WptPt point) {
|
||||
return getRoutePoints().contains(point);
|
||||
}
|
||||
|
||||
public List<WptPt> getRoutePoints() {
|
||||
List<WptPt> points = new ArrayList<>();
|
||||
for (int i = 0; i < routes.size(); i++) {
|
||||
|
@ -1305,15 +1122,6 @@ public class GPXUtilities {
|
|||
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() {
|
||||
for (Route r : routes) {
|
||||
if (r.points.size() > 0) {
|
||||
|
@ -1389,18 +1197,6 @@ public class GPXUtilities {
|
|||
return pt;
|
||||
}
|
||||
|
||||
public List<TrkSegment> getNonEmptyTrkSegments(boolean routesOnly) {
|
||||
List<TrkSegment> segments = new ArrayList<>();
|
||||
for (Track t : tracks) {
|
||||
for (TrkSegment s : t.segments) {
|
||||
if (!s.generalSegment && s.points.size() > 0 && (!routesOnly || s.hasRoute())) {
|
||||
segments.add(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
return segments;
|
||||
}
|
||||
|
||||
public void addTrkSegment(List<WptPt> points) {
|
||||
removeGeneralTrackIfExists();
|
||||
|
||||
|
@ -1437,8 +1233,8 @@ public class GPXUtilities {
|
|||
return false;
|
||||
}
|
||||
|
||||
public void addRoutePoints(List<WptPt> points, boolean addRoute) {
|
||||
if (routes.size() == 0 || addRoute) {
|
||||
public void addRoutePoints(List<WptPt> points) {
|
||||
if (routes.size() == 0) {
|
||||
Route route = new Route();
|
||||
routes.add(route);
|
||||
}
|
||||
|
@ -1680,7 +1476,7 @@ public class GPXUtilities {
|
|||
bottom = Math.min(bottom, p.getLatitude());
|
||||
}
|
||||
}
|
||||
for (Route route : routes) {
|
||||
for (GPXUtilities.Route route : routes) {
|
||||
for (WptPt p : route.points) {
|
||||
if (left == 0 && right == 0) {
|
||||
left = p.getLongitude();
|
||||
|
@ -1697,102 +1493,11 @@ public class GPXUtilities {
|
|||
}
|
||||
return new QuadRect(left, top, right, bottom);
|
||||
}
|
||||
|
||||
public int[] getGradientScaleColor(String gradientScaleType) {
|
||||
String clrValue = null;
|
||||
if (extensions != null) {
|
||||
clrValue = extensions.get(gradientScaleType);
|
||||
}
|
||||
return Algorithms.stringToGradientPalette(clrValue);
|
||||
}
|
||||
|
||||
public void setGradientScaleColor(String gradientScaleType, int[] gradientScalePalette) {
|
||||
getExtensionsToWrite().put(gradientScaleType, Algorithms.gradientPaletteToString(gradientScalePalette));
|
||||
}
|
||||
|
||||
public String getGradientScaleType() {
|
||||
if (extensions != null) {
|
||||
return extensions.get("gradient_scale_type");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setGradientScaleType(String gradientScaleType) {
|
||||
getExtensionsToWrite().put("gradient_scale_type", gradientScaleType);
|
||||
}
|
||||
|
||||
public void removeGradientScaleType() {
|
||||
getExtensionsToWrite().remove("gradient_scale_type");
|
||||
}
|
||||
|
||||
public String getSplitType() {
|
||||
if (extensions != null) {
|
||||
return extensions.get("split_type");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setSplitType(String gpxSplitType) {
|
||||
getExtensionsToWrite().put("split_type", gpxSplitType);
|
||||
}
|
||||
|
||||
public double getSplitInterval() {
|
||||
if (extensions != null) {
|
||||
String splitIntervalStr = extensions.get("split_interval");
|
||||
if (!Algorithms.isEmpty(splitIntervalStr)) {
|
||||
try {
|
||||
return Double.parseDouble(splitIntervalStr);
|
||||
} catch (NumberFormatException e) {
|
||||
log.error("Error reading split_interval", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setSplitInterval(double splitInterval) {
|
||||
getExtensionsToWrite().put("split_interval", String.valueOf(splitInterval));
|
||||
}
|
||||
|
||||
public String getWidth(String defWidth) {
|
||||
String widthValue = null;
|
||||
if (extensions != null) {
|
||||
widthValue = extensions.get("width");
|
||||
}
|
||||
return widthValue != null ? widthValue : defWidth;
|
||||
}
|
||||
|
||||
public void setWidth(String width) {
|
||||
getExtensionsToWrite().put("width", width);
|
||||
}
|
||||
|
||||
public boolean isShowArrows() {
|
||||
String showArrows = null;
|
||||
if (extensions != null) {
|
||||
showArrows = extensions.get("show_arrows");
|
||||
}
|
||||
return Boolean.parseBoolean(showArrows);
|
||||
}
|
||||
|
||||
public void setShowArrows(boolean showArrows) {
|
||||
getExtensionsToWrite().put("show_arrows", String.valueOf(showArrows));
|
||||
}
|
||||
|
||||
public boolean isShowStartFinish() {
|
||||
if (extensions != null && extensions.containsKey("show_start_finish")) {
|
||||
return Boolean.parseBoolean(extensions.get("show_start_finish"));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setShowStartFinish(boolean showStartFinish) {
|
||||
getExtensionsToWrite().put("show_start_finish", String.valueOf(showStartFinish));
|
||||
}
|
||||
}
|
||||
|
||||
public static String asString(GPXFile file) {
|
||||
final Writer writer = new StringWriter();
|
||||
writeGpx(writer, file);
|
||||
GPXUtilities.writeGpx(writer, file);
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
|
@ -1835,7 +1540,6 @@ public class GPXUtilities {
|
|||
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:osmand", "https://osmand.net");
|
||||
serializer.attribute(null, "xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
|
||||
serializer.attribute(null, "xsi:schemaLocation",
|
||||
"http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd");
|
||||
|
@ -1867,10 +1571,24 @@ public class GPXUtilities {
|
|||
}
|
||||
serializer.endTag(null, "metadata");
|
||||
|
||||
for (WptPt l : file.points) {
|
||||
serializer.startTag(null, "wpt"); //$NON-NLS-1$
|
||||
writeWpt(format, serializer, l);
|
||||
serializer.endTag(null, "wpt"); //$NON-NLS-1$
|
||||
|
||||
for (Track track : file.tracks) {
|
||||
if (!track.generalTrack) {
|
||||
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) {
|
||||
|
@ -1887,25 +1605,10 @@ public class GPXUtilities {
|
|||
serializer.endTag(null, "rte"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
for (Track track : file.tracks) {
|
||||
if (!track.generalTrack) {
|
||||
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$
|
||||
}
|
||||
assignRouteExtensionWriter(segment);
|
||||
writeExtensions(serializer, segment);
|
||||
serializer.endTag(null, "trkseg"); //$NON-NLS-1$
|
||||
}
|
||||
writeExtensions(serializer, track);
|
||||
serializer.endTag(null, "trk"); //$NON-NLS-1$
|
||||
}
|
||||
for (WptPt l : file.points) {
|
||||
serializer.startTag(null, "wpt"); //$NON-NLS-1$
|
||||
writeWpt(format, serializer, l);
|
||||
serializer.endTag(null, "wpt"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
writeExtensions(serializer, file);
|
||||
|
@ -1920,29 +1623,6 @@ public class GPXUtilities {
|
|||
return null;
|
||||
}
|
||||
|
||||
private static void assignRouteExtensionWriter(final TrkSegment segment) {
|
||||
if (segment.hasRoute() && segment.getExtensionsWriter() == null) {
|
||||
segment.setExtensionsWriter(new GPXExtensionsWriter() {
|
||||
@Override
|
||||
public void writeExtensions(XmlSerializer serializer) {
|
||||
StringBundle bundle = new StringBundle();
|
||||
List<StringBundle> segmentsBundle = new ArrayList<>();
|
||||
for (RouteSegment segment : segment.routeSegments) {
|
||||
segmentsBundle.add(segment.toStringBundle());
|
||||
}
|
||||
bundle.putBundleList("route", "segment", segmentsBundle);
|
||||
List<StringBundle> typesBundle = new ArrayList<>();
|
||||
for (RouteType routeType : segment.routeTypes) {
|
||||
typesBundle.add(routeType.toStringBundle());
|
||||
}
|
||||
bundle.putBundleList("types", "type", typesBundle);
|
||||
StringBundleWriter bundleWriter = new StringBundleXmlWriter(bundle, serializer);
|
||||
bundleWriter.writeBundle();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private static String getFilename(String path) {
|
||||
if(path != null) {
|
||||
int i = path.lastIndexOf('/');
|
||||
|
@ -1974,16 +1654,13 @@ public class GPXUtilities {
|
|||
}
|
||||
|
||||
private static void writeExtensions(XmlSerializer serializer, GPXExtensions p) throws IOException {
|
||||
writeExtensions(serializer, p.getExtensionsToRead(), p);
|
||||
}
|
||||
|
||||
private static void writeExtensions(XmlSerializer serializer, Map<String, String> extensions, GPXExtensions p) throws IOException {
|
||||
Map<String, String> extensionsToRead = p.getExtensionsToRead();
|
||||
GPXExtensionsWriter extensionsWriter = p.getExtensionsWriter();
|
||||
if (!extensions.isEmpty() || extensionsWriter != null) {
|
||||
if (!extensionsToRead.isEmpty() || extensionsWriter != null) {
|
||||
serializer.startTag(null, "extensions");
|
||||
if (!extensions.isEmpty()) {
|
||||
for (Entry<String, String> s : extensions.entrySet()) {
|
||||
writeNotNullText(serializer,"osmand:" + s.getKey(), s.getValue());
|
||||
if (!extensionsToRead.isEmpty()) {
|
||||
for (Entry<String, String> s : extensionsToRead.entrySet()) {
|
||||
writeNotNullText(serializer, s.getKey(), s.getValue());
|
||||
}
|
||||
}
|
||||
if (extensionsWriter != null) {
|
||||
|
@ -2019,20 +1696,7 @@ public class GPXUtilities {
|
|||
if (!Float.isNaN(p.heading)) {
|
||||
p.getExtensionsToWrite().put("heading", String.valueOf(Math.round(p.heading)));
|
||||
}
|
||||
Map<String, String> extensions = p.getExtensionsToRead();
|
||||
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);
|
||||
}
|
||||
writeExtensions(serializer, p);
|
||||
}
|
||||
|
||||
private static void writeAuthor(XmlSerializer serializer, Author author) throws IOException {
|
||||
|
@ -2176,7 +1840,23 @@ public class GPXUtilities {
|
|||
}
|
||||
|
||||
public static GPXFile loadGPXFile(InputStream f) {
|
||||
GPXFile gpxFile = new GPXFile(null);
|
||||
return loadGPXFile(f, null, null);
|
||||
}
|
||||
|
||||
public static GPXFile loadGPXFile(InputStream f, GPXFile gpxFile, GPXExtensionsReader extensionsReader) {
|
||||
boolean readExtensionsOnly = false;
|
||||
if (gpxFile == null) {
|
||||
gpxFile = new GPXFile(null);
|
||||
} else {
|
||||
if (f == null) {
|
||||
try {
|
||||
f = new FileInputStream(new File(gpxFile.path));
|
||||
} catch (FileNotFoundException e) {
|
||||
return gpxFile;
|
||||
}
|
||||
}
|
||||
readExtensionsOnly = extensionsReader != null;
|
||||
}
|
||||
SimpleDateFormat format = new SimpleDateFormat(GPX_TIME_FORMAT, Locale.US);
|
||||
format.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
SimpleDateFormat formatMillis = new SimpleDateFormat(GPX_TIME_FORMAT_MILLIS, Locale.US);
|
||||
|
@ -2188,13 +1868,8 @@ public class GPXUtilities {
|
|||
TrkSegment routeTrackSegment = new TrkSegment();
|
||||
routeTrack.segments.add(routeTrackSegment);
|
||||
Stack<GPXExtensions> parserState = new Stack<>();
|
||||
TrkSegment firstSegment = null;
|
||||
boolean extensionReadMode = false;
|
||||
boolean routePointExtension = false;
|
||||
List<RouteSegment> routeSegments = new ArrayList<>();
|
||||
List<RouteType> routeTypes = new ArrayList<>();
|
||||
boolean routeExtension = false;
|
||||
boolean typesExtension = false;
|
||||
parserState.push(gpxFile);
|
||||
int tok;
|
||||
while ((tok = parser.next()) != XmlPullParser.END_DOCUMENT) {
|
||||
|
@ -2203,50 +1878,37 @@ public class GPXUtilities {
|
|||
String tag = parser.getName();
|
||||
if (extensionReadMode && parse != null && !routePointExtension) {
|
||||
String tagName = tag.toLowerCase();
|
||||
if (routeExtension) {
|
||||
if (tagName.equals("segment")) {
|
||||
RouteSegment segment = parseRouteSegmentAttributes(parser);
|
||||
routeSegments.add(segment);
|
||||
}
|
||||
} else if (typesExtension) {
|
||||
if (tagName.equals("type")) {
|
||||
RouteType type = parseRouteTypeAttributes(parser);
|
||||
routeTypes.add(type);
|
||||
}
|
||||
boolean extensionsRead = false;
|
||||
if (extensionsReader != null) {
|
||||
extensionsRead = extensionsReader.readExtensions(gpxFile, parser);
|
||||
}
|
||||
switch (tagName) {
|
||||
case "routepointextension":
|
||||
routePointExtension = true;
|
||||
if (parse instanceof WptPt) {
|
||||
parse.getExtensionsToWrite().put("offset", routeTrackSegment.points.size() + "");
|
||||
}
|
||||
break;
|
||||
if (!readExtensionsOnly && !extensionsRead) {
|
||||
switch (tagName) {
|
||||
case "routepointextension":
|
||||
routePointExtension = true;
|
||||
if (parse instanceof WptPt) {
|
||||
parse.getExtensionsToWrite().put("offset", routeTrackSegment.points.size() + "");
|
||||
}
|
||||
break;
|
||||
|
||||
case "route":
|
||||
routeExtension = true;
|
||||
break;
|
||||
|
||||
case "types":
|
||||
typesExtension = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
Map<String, String> values = readTextMap(parser, tag);
|
||||
if (values.size() > 0) {
|
||||
for (Entry<String, String> entry : values.entrySet()) {
|
||||
String t = entry.getKey().toLowerCase();
|
||||
String value = entry.getValue();
|
||||
parse.getExtensionsToWrite().put(t, value);
|
||||
if (tag.equals("speed") && parse instanceof WptPt) {
|
||||
try {
|
||||
((WptPt) parse).speed = Float.parseFloat(value);
|
||||
} catch (NumberFormatException e) {
|
||||
log.debug(e.getMessage(), e);
|
||||
default:
|
||||
Map<String, String> values = readTextMap(parser, tag);
|
||||
if (values.size() > 0) {
|
||||
for (Entry<String, String> entry : values.entrySet()) {
|
||||
String t = entry.getKey().toLowerCase();
|
||||
String value = entry.getValue();
|
||||
parse.getExtensionsToWrite().put(t, value);
|
||||
if (tag.equals("speed") && parse instanceof WptPt) {
|
||||
try {
|
||||
((WptPt) parse).speed = Float.parseFloat(value);
|
||||
} catch (NumberFormatException e) {
|
||||
log.debug(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (parse != null && tag.equals("extensions")) {
|
||||
extensionReadMode = true;
|
||||
|
@ -2256,7 +1918,7 @@ public class GPXUtilities {
|
|||
routeTrackSegment.points.add(wptPt);
|
||||
parserState.push(wptPt);
|
||||
}
|
||||
} else {
|
||||
} else if (!readExtensionsOnly) {
|
||||
if (parse instanceof GPXFile) {
|
||||
if (tag.equals("gpx")) {
|
||||
((GPXFile) parse).author = parser.getAttributeValue("", "creator");
|
||||
|
@ -2452,12 +2114,7 @@ public class GPXUtilities {
|
|||
if (parse != null && tag.equals("extensions")) {
|
||||
extensionReadMode = false;
|
||||
}
|
||||
if (extensionReadMode && tag.equals("route")) {
|
||||
routeExtension = false;
|
||||
continue;
|
||||
}
|
||||
if (extensionReadMode && tag.equals("types")) {
|
||||
typesExtension = false;
|
||||
if (readExtensionsOnly) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -2493,16 +2150,6 @@ public class GPXUtilities {
|
|||
assert pop instanceof Route;
|
||||
} else if (tag.equals("trkseg")) {
|
||||
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;
|
||||
} else if (tag.equals("rpt")) {
|
||||
Object pop = parserState.pop();
|
||||
|
@ -2513,11 +2160,6 @@ public class GPXUtilities {
|
|||
if (!routeTrackSegment.points.isEmpty()) {
|
||||
gpxFile.tracks.add(routeTrack);
|
||||
}
|
||||
if (!routeSegments.isEmpty() && !routeTypes.isEmpty() && firstSegment != null) {
|
||||
firstSegment.routeSegments = routeSegments;
|
||||
firstSegment.routeTypes = routeTypes;
|
||||
}
|
||||
gpxFile.addGeneralTrack();
|
||||
} catch (Exception e) {
|
||||
gpxFile.error = e;
|
||||
log.error("Error reading gpx", e); //$NON-NLS-1$
|
||||
|
@ -2552,27 +2194,6 @@ public class GPXUtilities {
|
|||
return wpt;
|
||||
}
|
||||
|
||||
private static RouteSegment parseRouteSegmentAttributes(XmlPullParser parser) {
|
||||
RouteSegment segment = new RouteSegment();
|
||||
segment.id = parser.getAttributeValue("", "id");
|
||||
segment.length = parser.getAttributeValue("", "length");
|
||||
segment.segmentTime = parser.getAttributeValue("", "segmentTime");
|
||||
segment.speed = parser.getAttributeValue("", "speed");
|
||||
segment.turnType = parser.getAttributeValue("", "turnType");
|
||||
segment.turnAngle = parser.getAttributeValue("", "turnAngle");
|
||||
segment.types = parser.getAttributeValue("", "types");
|
||||
segment.pointTypes = parser.getAttributeValue("", "pointTypes");
|
||||
segment.names = parser.getAttributeValue("", "names");
|
||||
return segment;
|
||||
}
|
||||
|
||||
private static RouteType parseRouteTypeAttributes(XmlPullParser parser) {
|
||||
RouteType type = new RouteType();
|
||||
type.tag = parser.getAttributeValue("", "t");
|
||||
type.value = parser.getAttributeValue("", "v");
|
||||
return type;
|
||||
}
|
||||
|
||||
private static Bounds parseBoundsAttributes(XmlPullParser parser) {
|
||||
Bounds bounds = new Bounds();
|
||||
try {
|
||||
|
@ -2590,7 +2211,7 @@ public class GPXUtilities {
|
|||
if (maxlat == null) {
|
||||
maxlat = parser.getAttributeValue("", "maxLat");
|
||||
}
|
||||
if (maxlon == null) {
|
||||
if (maxlat == null) {
|
||||
maxlon = parser.getAttributeValue("", "maxLon");
|
||||
}
|
||||
|
||||
|
@ -2632,4 +2253,4 @@ public class GPXUtilities {
|
|||
to.error = from.error;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -45,7 +45,7 @@ public interface IProgress {
|
|||
public boolean isInterrupted() {return false;}
|
||||
|
||||
@Override
|
||||
public boolean isIndeterminate() {return true;}
|
||||
public boolean isIndeterminate() {return false;}
|
||||
|
||||
@Override
|
||||
public void finishTask() {}
|
||||
|
|
|
@ -14,25 +14,23 @@ public class IndexConstants {
|
|||
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 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_ZIP = ".obf.zip"; //$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_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_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_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_FEET_MAP_INDEX_EXT_ZIP = ".srtmf.obf.zip"; //$NON-NLS-1$
|
||||
public static final String EXTRA_EXT = ".extra";
|
||||
public static final String EXTRA_ZIP_EXT = ".extra.zip";
|
||||
|
||||
public static final String TOUR_INDEX_EXT = ".tour"; //$NON-NLS-1$
|
||||
public static final String TOUR_INDEX_EXT_ZIP = ".tour.zip"; //$NON-NLS-1$
|
||||
|
||||
public static final String GEN_LOG_EXT = ".gen.log"; //$NON-NLS-1$
|
||||
|
||||
public static final String VOICE_INDEX_EXT_ZIP = ".voice.zip"; //$NON-NLS-1$
|
||||
|
@ -50,9 +48,6 @@ public class IndexConstants {
|
|||
|
||||
public static final String GPX_FILE_EXT = ".gpx"; //$NON-NLS-1$
|
||||
|
||||
public static final String WPT_CHART_FILE_EXT = ".wpt.chart";
|
||||
public static final String SQLITE_CHART_FILE_EXT = ".3d.chart";
|
||||
|
||||
public final static String POI_TABLE = "poi"; //$NON-NLS-1$
|
||||
|
||||
public static final String INDEX_DOWNLOAD_DOMAIN = "download.osmand.net";
|
||||
|
@ -76,11 +71,9 @@ public class IndexConstants {
|
|||
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 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 TEMP_DIR = "temp/";
|
||||
public static final String ROUTING_PROFILES_DIR = "routing/";
|
||||
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 UTM_FORMAT = 3;
|
||||
public static final int OLC_FORMAT = 4;
|
||||
public static final int MGRS_FORMAT = 5;
|
||||
private static final char DELIM = ':';
|
||||
private static final char DELIMITER_DEGREES = '°';
|
||||
private static final char DELIMITER_MINUTES = '′';
|
||||
|
|
|
@ -1,159 +0,0 @@
|
|||
package net.osmand;
|
||||
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class LocationsHolder {
|
||||
|
||||
private static final int LOCATION_TYPE_UNKNOWN = -1;
|
||||
private static final int LOCATION_TYPE_LATLON = 0;
|
||||
private static final int LOCATION_TYPE_LOCATION = 1;
|
||||
private static final int LOCATION_TYPE_WPTPT = 2;
|
||||
|
||||
private List<LatLon> latLonList;
|
||||
private List<Location> locationList;
|
||||
private List<WptPt> wptPtList;
|
||||
private int locationType;
|
||||
private int size;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public LocationsHolder(List<?> locations) {
|
||||
this.locationType = resolveLocationType(locations);
|
||||
switch (locationType) {
|
||||
case LOCATION_TYPE_LATLON:
|
||||
latLonList = new ArrayList<>((List<LatLon>) locations);
|
||||
size = locations.size();
|
||||
break;
|
||||
case LOCATION_TYPE_LOCATION:
|
||||
locationList = new ArrayList<>((List<Location>) locations);
|
||||
size = locations.size();
|
||||
break;
|
||||
case LOCATION_TYPE_WPTPT:
|
||||
wptPtList = new ArrayList<>((List<WptPt>) locations);
|
||||
size = locations.size();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private int resolveLocationType(List<?> locations) {
|
||||
if (!Algorithms.isEmpty(locations)) {
|
||||
Object locationObj = locations.get(0);
|
||||
if (locationObj instanceof LatLon) {
|
||||
return LOCATION_TYPE_LATLON;
|
||||
} else if (locationObj instanceof WptPt) {
|
||||
return LOCATION_TYPE_WPTPT;
|
||||
} else if (locationObj instanceof Location) {
|
||||
return LOCATION_TYPE_LOCATION;
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unsupported location type: " + locationObj.getClass().getSimpleName());
|
||||
}
|
||||
}
|
||||
return LOCATION_TYPE_UNKNOWN;
|
||||
}
|
||||
|
||||
public double getLatitude(int index) {
|
||||
switch (locationType) {
|
||||
case LOCATION_TYPE_LATLON:
|
||||
return latLonList.get(index).getLatitude();
|
||||
case LOCATION_TYPE_LOCATION:
|
||||
return locationList.get(index).getLatitude();
|
||||
case LOCATION_TYPE_WPTPT:
|
||||
return wptPtList.get(index).getLatitude();
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public double getLongitude(int index) {
|
||||
switch (locationType) {
|
||||
case LOCATION_TYPE_LATLON:
|
||||
return latLonList.get(index).getLongitude();
|
||||
case LOCATION_TYPE_LOCATION:
|
||||
return locationList.get(index).getLongitude();
|
||||
case LOCATION_TYPE_WPTPT:
|
||||
return wptPtList.get(index).getLongitude();
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T> List<T> getList(int locationType) {
|
||||
List<T> res = new ArrayList<>();
|
||||
if (size > 0) {
|
||||
for (int i = 0; i < size; i++) {
|
||||
switch (locationType) {
|
||||
case LOCATION_TYPE_LATLON:
|
||||
res.add((T) getLatLon(i));
|
||||
break;
|
||||
case LOCATION_TYPE_LOCATION:
|
||||
res.add((T) getLocation(i));
|
||||
break;
|
||||
case LOCATION_TYPE_WPTPT:
|
||||
res.add((T) getWptPt(i));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public List<LatLon> getLatLonList() {
|
||||
if (this.locationType == LOCATION_TYPE_LATLON) {
|
||||
return latLonList;
|
||||
} else {
|
||||
return getList(LOCATION_TYPE_LATLON);
|
||||
}
|
||||
}
|
||||
|
||||
public List<WptPt> getWptPtList() {
|
||||
if (this.locationType == LOCATION_TYPE_WPTPT) {
|
||||
return wptPtList;
|
||||
} else {
|
||||
return getList(LOCATION_TYPE_WPTPT);
|
||||
}
|
||||
}
|
||||
|
||||
public List<Location> getLocationsList() {
|
||||
if (this.locationType == LOCATION_TYPE_LOCATION) {
|
||||
return locationList;
|
||||
} else {
|
||||
return getList(LOCATION_TYPE_LOCATION);
|
||||
}
|
||||
}
|
||||
|
||||
public LatLon getLatLon(int index) {
|
||||
if (this.locationType == LOCATION_TYPE_LATLON) {
|
||||
return latLonList.get(index);
|
||||
} else {
|
||||
return new LatLon(getLatitude(index), getLongitude(index));
|
||||
}
|
||||
}
|
||||
|
||||
public WptPt getWptPt(int index) {
|
||||
if (this.locationType == LOCATION_TYPE_WPTPT) {
|
||||
return wptPtList.get(index);
|
||||
} else {
|
||||
WptPt wptPt = new WptPt();
|
||||
wptPt.lat = getLatitude(index);
|
||||
wptPt.lon = getLongitude(index);
|
||||
return wptPt;
|
||||
}
|
||||
}
|
||||
|
||||
public Location getLocation(int index) {
|
||||
if (this.locationType == LOCATION_TYPE_LOCATION) {
|
||||
return locationList.get(index);
|
||||
} else {
|
||||
return new Location("", getLatitude(index), getLongitude(index));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -26,9 +26,10 @@ import net.osmand.data.QuadRect;
|
|||
import net.osmand.render.RenderingRuleSearchRequest;
|
||||
import net.osmand.render.RenderingRulesStorage;
|
||||
import net.osmand.router.NativeTransportRoutingResult;
|
||||
import net.osmand.router.PrecalculatedRouteDirection;
|
||||
import net.osmand.router.RouteCalculationProgress;
|
||||
import net.osmand.router.RouteSegmentResult;
|
||||
import net.osmand.router.RoutingContext;
|
||||
import net.osmand.router.RoutingConfiguration;
|
||||
import net.osmand.router.TransportRoutingConfiguration;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
|
@ -134,10 +135,12 @@ public class NativeLibrary {
|
|||
return nativeTransportRouting(new int[] { sx31, sy31, ex31, ey31 }, cfg, progress);
|
||||
}
|
||||
|
||||
public RouteSegmentResult[] runNativeRouting(RoutingContext c, RouteRegion[] regions, boolean basemap) {
|
||||
public RouteSegmentResult[] runNativeRouting(int sx31, int sy31, int ex31, int ey31, RoutingConfiguration config,
|
||||
RouteRegion[] regions, RouteCalculationProgress progress, PrecalculatedRouteDirection precalculatedRouteDirection,
|
||||
boolean basemap, boolean publicTransport, boolean startTransportStop, boolean targetTransportStop) {
|
||||
// config.router.printRules(System.out);
|
||||
return nativeRouting(c, c.config.initialDirection == null ? -360 : c.config.initialDirection.floatValue(),
|
||||
regions, basemap);
|
||||
return nativeRouting(new int[] { sx31, sy31, ex31, ey31 }, config, config.initialDirection == null ? -360 : config.initialDirection.floatValue(),
|
||||
regions, progress, precalculatedRouteDirection, basemap, publicTransport, startTransportStop, targetTransportStop);
|
||||
}
|
||||
|
||||
|
||||
|
@ -153,15 +156,16 @@ public class NativeLibrary {
|
|||
protected static native NativeRouteSearchResult loadRoutingData(RouteRegion reg, String regName, int regfp, RouteSubregion subreg,
|
||||
boolean loadObjects);
|
||||
|
||||
public static native void deleteNativeRoutingContext(long handle);
|
||||
|
||||
protected static native void deleteRenderingContextHandle(long handle);
|
||||
|
||||
protected static native void deleteRouteSearchResult(long searchResultHandle);
|
||||
|
||||
protected static native RouteDataObject[] getRouteDataObjects(RouteRegion reg, long rs, int x31, int y31);
|
||||
|
||||
protected static native RouteSegmentResult[] nativeRouting(RoutingContext c, float initDirection, RouteRegion[] regions, boolean basemap);
|
||||
protected static native RouteSegmentResult[] nativeRouting(int[] coordinates, RoutingConfiguration r,
|
||||
float initDirection, RouteRegion[] regions, RouteCalculationProgress progress,
|
||||
PrecalculatedRouteDirection precalculatedRouteDirection, boolean basemap,
|
||||
boolean publicTransport, boolean startTransportStop, boolean targetTransportStop);
|
||||
|
||||
protected static native NativeTransportRoutingResult[] nativeTransportRouting(int[] coordinates, TransportRoutingConfiguration cfg,
|
||||
RouteCalculationProgress progress);
|
||||
|
@ -350,7 +354,6 @@ public class NativeLibrary {
|
|||
FileInputStream fis = new FileInputStream(f);
|
||||
Algorithms.streamCopy(fis, ous);
|
||||
fis.close();
|
||||
System.out.println("FONT " + name);
|
||||
initFontType(ous.toByteArray(), name.substring(0, name.length() - 4), name.toLowerCase().contains("bold"),
|
||||
name.toLowerCase().contains("italic"));
|
||||
} catch (IOException e) {
|
||||
|
|
|
@ -38,5 +38,4 @@ public class OsmAndCollator {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,23 +1,20 @@
|
|||
package net.osmand;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.Calendar;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class Period {
|
||||
|
||||
public enum PeriodUnit {
|
||||
YEAR("Y", Calendar.YEAR),
|
||||
MONTH("M", Calendar.MONTH),
|
||||
WEEK("W", Calendar.WEEK_OF_YEAR),
|
||||
DAY("D", Calendar.DATE);
|
||||
YEAR("Y"),
|
||||
MONTH("M"),
|
||||
WEEK("W"),
|
||||
DAY("D");
|
||||
|
||||
private String unitStr;
|
||||
private int calendarIdx;
|
||||
|
||||
PeriodUnit(String unitStr, int calendarIdx) {
|
||||
this.calendarIdx = calendarIdx;
|
||||
PeriodUnit(String unitStr) {
|
||||
this.unitStr = unitStr;
|
||||
}
|
||||
|
||||
|
@ -25,10 +22,6 @@ public class Period {
|
|||
return unitStr;
|
||||
}
|
||||
|
||||
public int getCalendarIdx() {
|
||||
return calendarIdx;
|
||||
}
|
||||
|
||||
public double getMonthsValue() {
|
||||
switch (this) {
|
||||
case YEAR:
|
||||
|
|
|
@ -23,9 +23,7 @@ public class PlatformUtil {
|
|||
}
|
||||
|
||||
public static XmlPullParser newXMLPullParser() throws XmlPullParserException{
|
||||
org.kxml2.io.KXmlParser xmlParser = new org.kxml2.io.KXmlParser();
|
||||
xmlParser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
|
||||
return xmlParser;
|
||||
return new org.kxml2.io.KXmlParser();
|
||||
}
|
||||
|
||||
public static XmlSerializer newSerializer() {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package net.osmand;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
|
@ -20,67 +19,61 @@ public class Reshaper {
|
|||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public static String reshape(String s) {
|
||||
// if(true) {
|
||||
// return s;
|
||||
// }
|
||||
try {
|
||||
ArabicShaping as = new ArabicShaping(ArabicShaping.LETTERS_SHAPE |
|
||||
ArabicShaping.LENGTH_GROW_SHRINK);
|
||||
//printSplit("B", s);
|
||||
ArabicShaping as = new ArabicShaping(ArabicShaping.LETTERS_SHAPE | ArabicShaping.LENGTH_GROW_SHRINK);
|
||||
try {
|
||||
s = as.shape(s);
|
||||
} catch (ArabicShapingException e) {
|
||||
LOG.error(e.getMessage(), e);
|
||||
}
|
||||
//printSplit("A", s);
|
||||
Bidi line = new Bidi(s.length(), s.length());
|
||||
line.setPara(s, Bidi.LEVEL_DEFAULT_LTR, null);
|
||||
// line.setPara(s, Bidi.LEVEL_DEFAULT_LTR, null);
|
||||
// s = line.writeReordered(Bidi.DO_MIRRORING);
|
||||
// s = reordered;
|
||||
line.setPara(s, Bidi.LEVEL_DEFAULT_LTR, null);
|
||||
byte direction = line.getDirection();
|
||||
if (direction != Bidi.MIXED) {
|
||||
// unidirectional
|
||||
if (line.isLeftToRight()) {
|
||||
return s;
|
||||
} else {
|
||||
if(line.isLeftToRight()) {
|
||||
return s;
|
||||
} else {
|
||||
char[] chs = new char[s.length()];
|
||||
for(int i = 0; i< chs.length ; i++) {
|
||||
// chs[i] = s.charAt(chs.length - i - 1);
|
||||
chs[i] = mirror(s.charAt(chs.length - i - 1));
|
||||
chs[i] = s.charAt(chs.length - i - 1);
|
||||
}
|
||||
return new String(chs);
|
||||
}
|
||||
} else {
|
||||
// mixed-directional
|
||||
// System.out.println(s);
|
||||
// printSplit("Split", s);
|
||||
// // mixed-directional
|
||||
int count = line.countRuns();
|
||||
// if (styleRunCount <= 1) {
|
||||
// int style = styleRuns[0].style;
|
||||
// // iterate over directional runs
|
||||
// for (i = 0; i < count; ++i) {
|
||||
// run = line.getVisualRun(i);
|
||||
// renderRun(text, run.getStart(), run.getLimit(),
|
||||
// run.getDirection(), style);
|
||||
// }
|
||||
// }
|
||||
StringBuilder res = new StringBuilder();
|
||||
// iterate over both directional and style runs
|
||||
for (int i = 0; i < count; ++i) {
|
||||
StringBuilder runs = new StringBuilder();
|
||||
BidiRun run = line.getVisualRun(i);
|
||||
boolean ltr = run.getDirection() == Bidi.LTR;
|
||||
int start = run.getStart();
|
||||
int limit = run.getLimit();
|
||||
int begin = ltr ? start : limit - 1;
|
||||
int end = ltr ? limit : start - 1;
|
||||
int ind = begin;
|
||||
while (ind != end) {
|
||||
char ch = s.charAt(ind);
|
||||
if (!ltr) {
|
||||
ch = mirror(ch);
|
||||
}
|
||||
res.append(ch);
|
||||
runs.append(ch);
|
||||
if (ltr) {
|
||||
ind++;
|
||||
|
||||
int st = run.getStart();
|
||||
int e = run.getLimit();
|
||||
int j = run.getDirection() == Bidi.LTR ? st : e - 1;
|
||||
int l = run.getDirection() == Bidi.LTR ? e : st - 1;
|
||||
boolean plus = run.getDirection() == Bidi.LTR;
|
||||
while (j != l) {
|
||||
res.append(s.charAt(j));
|
||||
if (plus) {
|
||||
j++;
|
||||
} else {
|
||||
ind--;
|
||||
j--;
|
||||
}
|
||||
|
||||
}
|
||||
printSplit(run.getDirection() + " " + run.getEmbeddingLevel(), runs.toString());
|
||||
}
|
||||
return res.toString();
|
||||
}
|
||||
|
@ -90,77 +83,24 @@ public class Reshaper {
|
|||
}
|
||||
|
||||
}
|
||||
private static char mirror(char ch) {
|
||||
switch (ch) {
|
||||
case '(': ch = ')'; break;
|
||||
case ')': ch = '('; break;
|
||||
case '[': ch = ']'; break;
|
||||
case ']': ch = '['; break;
|
||||
}
|
||||
return ch;
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
// char[] c = new char[] {'א', 'ד','ם', ' ', '1', '2'} ;
|
||||
// String reshape = "אדם";
|
||||
char[] c = new char[] {'א', 'ד','ם'} ;
|
||||
String reshape = reshape(new String(c));
|
||||
for(int i=0; i < reshape.length(); i++) {
|
||||
System.out.println(reshape.charAt(i));
|
||||
}
|
||||
test2();
|
||||
test3();
|
||||
test4();
|
||||
test5();
|
||||
}
|
||||
|
||||
public static void test3() {
|
||||
String s = "מרכז מסחרי/השלום (40050)";
|
||||
String reshape = reshape(s);
|
||||
String expected = "(40050) םולשה/ירחסמ זכרמ";
|
||||
check(s, reshape, expected);
|
||||
}
|
||||
|
||||
public static void test5() {
|
||||
String s = "מרכז מסחרי/השלום (מרז)";
|
||||
String reshape = reshape(s);
|
||||
String expected = "(זרמ) םולשה/ירחסמ זכרמ";
|
||||
check(s, reshape, expected);
|
||||
}
|
||||
|
||||
public static void check(String source, String reshape, String expected) {
|
||||
printSplit("Source ", source);
|
||||
printSplit("Expected", expected);
|
||||
printSplit("Reshaped", reshape);
|
||||
System.out.println(reshape);
|
||||
if (!reshape.equals(expected)) {
|
||||
throw new IllegalArgumentException(String.format("Bug: expected '%s', reshaped '%s'", expected, reshape));
|
||||
}
|
||||
}
|
||||
|
||||
static void printSplit(String p, String source) {
|
||||
printSplit(p, source, true);
|
||||
printSplit(p, source, false);
|
||||
}
|
||||
static void printSplit(String p, String source, boolean f) {
|
||||
System.out.print(p);
|
||||
System.out.print(": \u2066");
|
||||
for (int i = 0; i < source.length(); i++) {
|
||||
if (f) {
|
||||
System.out.print(source.charAt(i));
|
||||
System.out.print(" \u200e");
|
||||
} else {
|
||||
System.out.print(String.format("%04x ", (int) source.charAt(i)));
|
||||
}
|
||||
}
|
||||
// System.out.println(Arrays.toString(source.toCharArray()));
|
||||
System.out.println();
|
||||
System.out.flush();
|
||||
}
|
||||
|
||||
public static void test2() {
|
||||
private static void test2() {
|
||||
String s = "گچ پژ نمکی باللغة العربي";
|
||||
String reshape = reshape(s);
|
||||
String expected1 = "ﻲﺑﺮﻌﻟﺍ ﺔﻐﻠﻟﺎﺑ ﯽﮑﻤﻧ ﮋﭘ ﭻﮔ";
|
||||
String expected2 = "ﻲﺑﺮﻌﻟﺍ ﺔﻐﻠﻟﺎﺑ یکﻤﻧ ژپ چگ";
|
||||
check(s, reshape, expected1);
|
||||
}
|
||||
|
||||
public static void test4() {
|
||||
String s = "Abc (123)";
|
||||
check(s, reshape(s), s);
|
||||
|
||||
if (!reshape.equals("ﻲﺑﺮﻌﻟﺍ ﺔﻐﻠﻟﺎﺑ ﯽﮑﻤﻧ ﮋﭘ ﭻﮔ")) {
|
||||
throw new IllegalArgumentException("BUG!!!");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -106,11 +106,9 @@ public class TspAnt {
|
|||
// Allocates all memory.
|
||||
// Adds 1 to edge lengths to ensure no zero length edges.
|
||||
public TspAnt readGraph(List<LatLon> intermediates, LatLon start, LatLon end) {
|
||||
boolean keepEndPoint = end != null;
|
||||
List<LatLon> l = new ArrayList<LatLon>();
|
||||
if (start != null) {
|
||||
l.add(start);
|
||||
}
|
||||
boolean keepEndPoint = end != null;
|
||||
List<LatLon> l = new ArrayList<LatLon>();
|
||||
l.add(start);
|
||||
l.addAll(intermediates);
|
||||
if (keepEndPoint) {
|
||||
l.add(end);
|
||||
|
|
|
@ -68,7 +68,7 @@ public class TspHeldKarp {
|
|||
}
|
||||
break;
|
||||
}
|
||||
System.err.print(".");
|
||||
System.err.printf(".");
|
||||
PriorityQueue<Node> children = new PriorityQueue<Node>(11, new NodeComparator());
|
||||
children.add(exclude(currentNode, i, currentNode.parent[i]));
|
||||
for (int j = 0; j < n; j++) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import gnu.trove.set.hash.TIntHashSet;
|
|||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -222,7 +221,7 @@ public class BinaryMapAddressReaderAdapter {
|
|||
int fp = codedIS.getTotalBytesRead();
|
||||
int length = codedIS.readRawVarint32();
|
||||
int oldLimit = codedIS.pushLimit(length);
|
||||
City c = readCityHeader(resultMatcher, new DefaultCityMatcher(matcher), fp, additionalTagsTable);
|
||||
City c = readCityHeader(new DefaultCityMatcher(matcher), fp, additionalTagsTable);
|
||||
if (c != null) {
|
||||
if (resultMatcher == null || resultMatcher.publish(c)) {
|
||||
cities.add(c);
|
||||
|
@ -257,7 +256,6 @@ public class BinaryMapAddressReaderAdapter {
|
|||
int oldLimit = codedIS.pushLimit(length);
|
||||
readStreet(s, null, false, x >> 7, y >> 7, city.isPostcode() ? city.getName() : null,
|
||||
attributeTagsTable);
|
||||
publishRawData(resultMatcher, s);
|
||||
if (resultMatcher == null || resultMatcher.publish(s)) {
|
||||
city.registerStreet(s);
|
||||
}
|
||||
|
@ -305,7 +303,7 @@ public class BinaryMapAddressReaderAdapter {
|
|||
}
|
||||
}
|
||||
|
||||
protected City readCityHeader(SearchRequest<? super City> resultMatcher, CityMatcher matcher, int filePointer, List<String> additionalTagsTable) throws IOException {
|
||||
protected City readCityHeader(CityMatcher matcher, int filePointer, List<String> additionalTagsTable) throws IOException {
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
City c = null;
|
||||
|
@ -315,7 +313,6 @@ public class BinaryMapAddressReaderAdapter {
|
|||
int tag = WireFormat.getTagFieldNumber(t);
|
||||
switch (tag) {
|
||||
case 0:
|
||||
publishRawData(resultMatcher, c);
|
||||
return (matcher == null || matcher.matches(c)) ? c : null;
|
||||
case OsmandOdb.CityIndex.CITY_TYPE_FIELD_NUMBER:
|
||||
int type = codedIS.readUInt32();
|
||||
|
@ -448,7 +445,6 @@ public class BinaryMapAddressReaderAdapter {
|
|||
if (loadBuildingsAndIntersected) {
|
||||
int oldLimit = codedIS.pushLimit(length);
|
||||
Building b = readBuilding(offset, x, y, additionalTagsTable);
|
||||
publishRawData(buildingsMatcher, b);
|
||||
if (postcodeFilter == null || postcodeFilter.equalsIgnoreCase(b.getPostcode())) {
|
||||
if (buildingsMatcher == null || buildingsMatcher.publish(b)) {
|
||||
s.addBuilding(b);
|
||||
|
@ -628,9 +624,7 @@ public class BinaryMapAddressReaderAdapter {
|
|||
indexOffset = codedIS.getTotalBytesRead();
|
||||
int oldLimit = codedIS.pushLimit(length);
|
||||
// here offsets are sorted by distance
|
||||
TIntArrayList charsList = new TIntArrayList();
|
||||
charsList.add(0);
|
||||
map.readIndexedStringTable(stringMatcher.getCollator(), Collections.singletonList(req.nameQuery), "", Collections.singletonList(loffsets), charsList);
|
||||
map.readIndexedStringTable(stringMatcher.getCollator(), req.nameQuery, "", loffsets, 0);
|
||||
codedIS.popLimit(oldLimit);
|
||||
break;
|
||||
case OsmAndAddressNameIndexData.ATOM_FIELD_NUMBER:
|
||||
|
@ -694,7 +688,7 @@ public class BinaryMapAddressReaderAdapter {
|
|||
codedIS.seek(contOffset);
|
||||
int len = codedIS.readRawVarint32();
|
||||
int old = codedIS.pushLimit(len);
|
||||
obj = readCityHeader(req, null, contOffset, reg.attributeTagsTable);
|
||||
obj = readCityHeader(null, contOffset, reg.attributeTagsTable);
|
||||
codedIS.popLimit(old);
|
||||
}
|
||||
if (obj != null) {
|
||||
|
@ -707,7 +701,6 @@ public class BinaryMapAddressReaderAdapter {
|
|||
readStreet(s, null, false, MapUtils.get31TileNumberX(l.getLongitude()) >> 7,
|
||||
MapUtils.get31TileNumberY(l.getLatitude()) >> 7, obj.isPostcode() ? obj.getName() : null,
|
||||
reg.attributeTagsTable);
|
||||
publishRawData(req, s);
|
||||
boolean matches = stringMatcher.matches(s.getName());
|
||||
if (!matches) {
|
||||
for (String n : s.getAllNames()) {
|
||||
|
@ -734,8 +727,7 @@ public class BinaryMapAddressReaderAdapter {
|
|||
codedIS.seek(offset);
|
||||
int len = codedIS.readRawVarint32();
|
||||
int old = codedIS.pushLimit(len);
|
||||
City obj = readCityHeader(req, cityPostcodeMatcher, list.get(j), reg.attributeTagsTable);
|
||||
publishRawData(req, obj);
|
||||
City obj = readCityHeader(cityPostcodeMatcher, list.get(j), reg.attributeTagsTable);
|
||||
if (obj != null && !published.contains(offset)) {
|
||||
req.publish(obj);
|
||||
published.add(offset);
|
||||
|
@ -813,9 +805,4 @@ public class BinaryMapAddressReaderAdapter {
|
|||
}
|
||||
}
|
||||
|
||||
private <T> void publishRawData(SearchRequest<T> resultMatcher, T obj) {
|
||||
if (resultMatcher != null && obj != null) {
|
||||
resultMatcher.collectRawData(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ public class BinaryMapIndexReader {
|
|||
|
||||
public final static int TRANSPORT_STOP_ZOOM = 24;
|
||||
public static final int SHIFT_COORDINATES = 5;
|
||||
public static final int LABEL_ZOOM_ENCODE = 31 - SHIFT_COORDINATES;
|
||||
public static final int LABEL_ZOOM_ENCODE = 26;
|
||||
private final static Log log = PlatformUtil.getLog(BinaryMapIndexReader.class);
|
||||
public static boolean READ_STATS = false;
|
||||
public static final SearchPoiTypeFilter ACCEPT_ALL_POI_TYPE_FILTER = new SearchPoiTypeFilter() {
|
||||
|
@ -496,7 +496,7 @@ public class BinaryMapIndexReader {
|
|||
}
|
||||
}
|
||||
Iterator<Entry<TransportIndex, TIntArrayList>> it = groupPoints.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
if (it.hasNext()) {
|
||||
Entry<TransportIndex, TIntArrayList> e = it.next();
|
||||
TransportIndex ind = e.getKey();
|
||||
TIntArrayList pointers = e.getValue();
|
||||
|
@ -696,7 +696,6 @@ public class BinaryMapIndexReader {
|
|||
private void readMapIndex(MapIndex index, boolean onlyInitEncodingRules) throws IOException {
|
||||
int defaultId = 1;
|
||||
int oldLimit;
|
||||
int encodingRulesSize = 0;
|
||||
while (true) {
|
||||
int t = codedIS.readTag();
|
||||
int tag = WireFormat.getTagFieldNumber(t);
|
||||
|
@ -713,14 +712,10 @@ public class BinaryMapIndexReader {
|
|||
break;
|
||||
case OsmandOdb.OsmAndMapIndex.RULES_FIELD_NUMBER :
|
||||
if (onlyInitEncodingRules) {
|
||||
if(encodingRulesSize == 0) {
|
||||
encodingRulesSize = codedIS.getTotalBytesRead();
|
||||
}
|
||||
int len = codedIS.readInt32();
|
||||
oldLimit = codedIS.pushLimit(len);
|
||||
readMapEncodingRule(index, defaultId++);
|
||||
codedIS.popLimit(oldLimit);
|
||||
index.encodingRulesSizeBytes = (codedIS.getTotalBytesRead() - encodingRulesSize);
|
||||
} else {
|
||||
skipUnknownField(t);
|
||||
}
|
||||
|
@ -1462,14 +1457,8 @@ public class BinaryMapIndexReader {
|
|||
|
||||
public static <T> SearchRequest<T> buildAddressByNameRequest(ResultMatcher<T> resultMatcher, String nameRequest,
|
||||
StringMatcherMode matcherMode) {
|
||||
return buildAddressByNameRequest(resultMatcher, null, nameRequest, matcherMode);
|
||||
}
|
||||
|
||||
public static <T> SearchRequest<T> buildAddressByNameRequest(ResultMatcher<T> resultMatcher, ResultMatcher<T> rawDataCollector, String nameRequest,
|
||||
StringMatcherMode matcherMode) {
|
||||
SearchRequest<T> request = new SearchRequest<T>();
|
||||
request.resultMatcher = resultMatcher;
|
||||
request.rawDataCollector = rawDataCollector;
|
||||
request.nameQuery = nameRequest.trim();
|
||||
request.matcherMode = matcherMode;
|
||||
return request;
|
||||
|
@ -1538,20 +1527,9 @@ public class BinaryMapIndexReader {
|
|||
|
||||
return request;
|
||||
}
|
||||
|
||||
public static SearchRequest<Amenity> buildSearchPoiRequest(LatLon latLon, int radius, int zoom,
|
||||
SearchPoiTypeFilter poiTypeFilter,
|
||||
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) {
|
||||
|
||||
public static SearchRequest<RouteDataObject> buildSearchRouteRequest(int sleft, int sright, int stop, int sbottom,
|
||||
ResultMatcher<RouteDataObject> matcher){
|
||||
SearchRequest<RouteDataObject> request = new SearchRequest<RouteDataObject>();
|
||||
request.left = sleft;
|
||||
request.right = sright;
|
||||
|
@ -1564,14 +1542,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) {
|
||||
return buildSearchPoiRequest(x, y, nameFilter, sleft, sright, stop, sbottom, resultMatcher, null);
|
||||
}
|
||||
|
||||
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>();
|
||||
request.x = x;
|
||||
request.y = y;
|
||||
|
@ -1579,9 +1549,7 @@ public class BinaryMapIndexReader {
|
|||
request.right = sright;
|
||||
request.top = stop;
|
||||
request.bottom = sbottom;
|
||||
request.poiTypeFilter = poiTypeFilter;
|
||||
request.resultMatcher = resultMatcher;
|
||||
request.rawDataCollector = rawDataCollector;
|
||||
request.nameQuery = nameFilter.trim();
|
||||
return request;
|
||||
}
|
||||
|
@ -1666,7 +1634,6 @@ public class BinaryMapIndexReader {
|
|||
private boolean ocean = false;
|
||||
|
||||
private ResultMatcher<T> resultMatcher;
|
||||
private ResultMatcher<T> rawDataCollector;
|
||||
|
||||
// 31 zoom tiles
|
||||
// common variables
|
||||
|
@ -1727,12 +1694,13 @@ public class BinaryMapIndexReader {
|
|||
double half16t = MapUtils.getDistance(lat, MapUtils.getLongitudeFromTile(16, ((int) dx) + 0.5),
|
||||
lat, MapUtils.getLongitudeFromTile(16, (int) dx));
|
||||
double cf31 = ((double) radiusMeters / (half16t * 2)) * (1 << 15);
|
||||
y = MapUtils.get31TileNumberY(lat);
|
||||
x = MapUtils.get31TileNumberX(lon);
|
||||
left = (int) (x - cf31);
|
||||
right = (int) (x + cf31);
|
||||
top = (int) (y - cf31);
|
||||
bottom = (int) (y + cf31);
|
||||
int y31 = MapUtils.get31TileNumberY(lat);
|
||||
int x31 = MapUtils.get31TileNumberX(lon);
|
||||
left = (int) (x31 - cf31);
|
||||
right = (int) (x31 + cf31);
|
||||
top = (int) (y31 - cf31);
|
||||
bottom = (int) (y31 + cf31);
|
||||
|
||||
}
|
||||
|
||||
public boolean publish(T obj) {
|
||||
|
@ -1743,12 +1711,6 @@ public class BinaryMapIndexReader {
|
|||
return false;
|
||||
}
|
||||
|
||||
public void collectRawData(T obj) {
|
||||
if (rawDataCollector != null) {
|
||||
rawDataCollector.publish(obj);
|
||||
}
|
||||
}
|
||||
|
||||
protected void publishOceanTile(boolean ocean) {
|
||||
if (ocean) {
|
||||
this.ocean = true;
|
||||
|
@ -1769,10 +1731,6 @@ public class BinaryMapIndexReader {
|
|||
return limit != -1 && searchResults.size() > limit;
|
||||
}
|
||||
|
||||
public void setLimit(int limit) {
|
||||
this.limit = limit;
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
if (this.interrupted) {
|
||||
return interrupted;
|
||||
|
@ -1853,13 +1811,10 @@ public class BinaryMapIndexReader {
|
|||
public int onewayReverseAttribute = -1;
|
||||
public TIntHashSet positiveLayers = new TIntHashSet(2);
|
||||
public TIntHashSet negativeLayers = new TIntHashSet(2);
|
||||
public int encodingRulesSizeBytes;
|
||||
|
||||
// to speed up comparision
|
||||
private MapIndex referenceMapIndex;
|
||||
|
||||
|
||||
|
||||
public Integer getRule(String t, String v) {
|
||||
Map<String, Integer> m = encodingRules.get(t);
|
||||
if (m != null) {
|
||||
|
@ -2161,9 +2116,9 @@ public class BinaryMapIndexReader {
|
|||
private static boolean testAddressSearch = false;
|
||||
private static boolean testAddressSearchName = false;
|
||||
private static boolean testAddressJustifySearch = false;
|
||||
private static boolean testPoiSearch = true;
|
||||
private static boolean testPoiSearch = 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 sright = MapUtils.get31TileNumberX(27.55317);
|
||||
|
@ -2177,7 +2132,7 @@ public class BinaryMapIndexReader {
|
|||
|
||||
public static void main(String[] args) throws IOException {
|
||||
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");
|
||||
|
||||
|
@ -2325,7 +2280,7 @@ public class BinaryMapIndexReader {
|
|||
|
||||
private static void testPoiSearchByName(BinaryMapIndexReader reader) throws IOException {
|
||||
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);
|
||||
|
||||
reader.searchPoiByName(req);
|
||||
|
@ -2385,72 +2340,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;
|
||||
boolean[] matched = new boolean[matchedCharacters.size()];
|
||||
boolean shouldWeReadSubtable = false;
|
||||
while (true) {
|
||||
int t = codedIS.readTag();
|
||||
int tag = WireFormat.getTagFieldNumber(t);
|
||||
switch (tag) {
|
||||
case 0:
|
||||
return;
|
||||
return charMatches;
|
||||
case OsmandOdb.IndexedStringTable.KEY_FIELD_NUMBER :
|
||||
key = codedIS.readString();
|
||||
if (prefix.length() > 0) {
|
||||
if(prefix.length() > 0){
|
||||
key = prefix + key;
|
||||
}
|
||||
shouldWeReadSubtable = false;
|
||||
for (int i = 0; i < queries.size(); i++) {
|
||||
int charMatches = matchedCharacters.get(i);
|
||||
String query = queries.get(i);
|
||||
matched[i] = false;
|
||||
if (query == null) {
|
||||
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;
|
||||
// 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){
|
||||
charMatches = query.length();
|
||||
list.clear();
|
||||
}
|
||||
} 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;
|
||||
case OsmandOdb.IndexedStringTable.VAL_FIELD_NUMBER :
|
||||
int val = readInt();
|
||||
for (int i = 0; i < queries.size(); i++) {
|
||||
if (matched[i]) {
|
||||
listOffsets.get(i).add(val);
|
||||
}
|
||||
if (key != null) {
|
||||
list.add(val);
|
||||
}
|
||||
break;
|
||||
case OsmandOdb.IndexedStringTable.SUBTABLES_FIELD_NUMBER :
|
||||
int len = codedIS.readRawVarint32();
|
||||
int oldLim = codedIS.pushLimit(len);
|
||||
if (shouldWeReadSubtable && key != null) {
|
||||
List<String> subqueries = new ArrayList<>(queries);
|
||||
// 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);
|
||||
if (key != null) {
|
||||
charMatches = readIndexedStringTable(instance, query, key, list, charMatches);
|
||||
} else {
|
||||
codedIS.skipRawBytes(codedIS.getBytesUntilLimit());
|
||||
}
|
||||
|
@ -2538,9 +2475,8 @@ public class BinaryMapIndexReader {
|
|||
}
|
||||
}
|
||||
}
|
||||
for (Entry<MapObject, Street> entry : resMap.entrySet()) {
|
||||
MapObject e = entry.getKey();
|
||||
Street s = entry.getValue();
|
||||
for (MapObject e : resMap.keySet()) {
|
||||
Street s = resMap.get(e);
|
||||
if (e instanceof Building && MapUtils.getDistance(e.getLocation(), lat, lon) < 40) {
|
||||
Building b = (Building) e;
|
||||
System.out.println(b.getName() + " " + s);
|
||||
|
@ -2701,20 +2637,18 @@ public class BinaryMapIndexReader {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public TLongObjectHashMap<IncompleteTransportRoute> getIncompleteTransportRoutes() throws InvalidProtocolBufferException, IOException {
|
||||
if (incompleteTransportRoutes == null) {
|
||||
incompleteTransportRoutes = new TLongObjectHashMap<>();
|
||||
for (TransportIndex ti : transportIndexes) {
|
||||
if (ti.incompleteRoutesLength > 0) {
|
||||
codedIS.seek(ti.incompleteRoutesOffset);
|
||||
int oldLimit = codedIS.pushLimit(ti.incompleteRoutesLength);
|
||||
transportAdapter.readIncompleteRoutesList(incompleteTransportRoutes, ti.filePointer);
|
||||
codedIS.popLimit(oldLimit);
|
||||
transportAdapter.readIncompleteRoutesList(incompleteTransportRoutes, ti.incompleteRoutesLength,
|
||||
ti.incompleteRoutesOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
return incompleteTransportRoutes;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,21 +1,19 @@
|
|||
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.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedList;
|
||||
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.CollatorStringMatcher;
|
||||
import net.osmand.CollatorStringMatcher.StringMatcherMode;
|
||||
|
@ -28,8 +26,14 @@ import net.osmand.data.Amenity.AmenityRoutePoint;
|
|||
import net.osmand.data.LatLon;
|
||||
import net.osmand.osm.MapPoiTypes;
|
||||
import net.osmand.osm.PoiCategory;
|
||||
import net.osmand.osm.PoiType;
|
||||
import net.osmand.util.MapUtils;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
import com.google.protobuf.CodedInputStream;
|
||||
import com.google.protobuf.WireFormat;
|
||||
|
||||
public class BinaryMapPoiReaderAdapter {
|
||||
private static final Log LOG = PlatformUtil.getLog(BinaryMapPoiReaderAdapter.class);
|
||||
|
||||
|
@ -37,12 +41,7 @@ public class BinaryMapPoiReaderAdapter {
|
|||
private static final int CATEGORY_MASK = (1 << SHIFT_BITS_CATEGORY) - 1;
|
||||
private static final int ZOOM_TO_SKIP_FILTER_READ = 6;
|
||||
private static final int ZOOM_TO_SKIP_FILTER = 3;
|
||||
private static final int BUCKET_SEARCH_BY_NAME = 15; // should be bigger 100?
|
||||
private static final int 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
|
||||
|
||||
private static final int BUCKET_SEARCH_BY_NAME = 5;
|
||||
|
||||
public static class PoiSubType {
|
||||
public boolean text;
|
||||
|
@ -336,7 +335,7 @@ public class BinaryMapPoiReaderAdapter {
|
|||
});
|
||||
int p = BUCKET_SEARCH_BY_NAME * 3;
|
||||
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) {
|
||||
Arrays.sort(offKeys, p, offKeys.length);
|
||||
break;
|
||||
|
@ -348,6 +347,7 @@ public class BinaryMapPoiReaderAdapter {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
LOG.info("Searched poi structure in " + (System.currentTimeMillis() - time) +
|
||||
"ms. Found " + offKeys.length + " subtrees");
|
||||
for (int j = 0; j < offKeys.length; j++) {
|
||||
|
@ -373,8 +373,7 @@ public class BinaryMapPoiReaderAdapter {
|
|||
|
||||
private TIntLongHashMap readPoiNameIndex(Collator instance, String query, SearchRequest<Amenity> req) throws IOException {
|
||||
TIntLongHashMap offsets = new TIntLongHashMap();
|
||||
List<TIntArrayList> listOffsets = null;
|
||||
List<TIntLongHashMap> listOfSepOffsets = new ArrayList<TIntLongHashMap>();
|
||||
TIntArrayList dataOffsets = null;
|
||||
int offset = 0;
|
||||
while (true) {
|
||||
int t = codedIS.readTag();
|
||||
|
@ -385,51 +384,24 @@ public class BinaryMapPoiReaderAdapter {
|
|||
case OsmandOdb.OsmAndPoiNameIndex.TABLE_FIELD_NUMBER: {
|
||||
int length = readInt();
|
||||
int oldLimit = codedIS.pushLimit(length);
|
||||
dataOffsets = new TIntArrayList();
|
||||
offset = codedIS.getTotalBytesRead();
|
||||
List<String> queries = new ArrayList<>();
|
||||
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);
|
||||
map.readIndexedStringTable(instance, query, "", dataOffsets, 0);
|
||||
codedIS.popLimit(oldLimit);
|
||||
break;
|
||||
}
|
||||
case OsmandOdb.OsmAndPoiNameIndex.DATA_FIELD_NUMBER: {
|
||||
if (listOffsets != null) {
|
||||
for (TIntArrayList dataOffsets : listOffsets) {
|
||||
TIntLongHashMap offsetMap = new TIntLongHashMap();
|
||||
listOfSepOffsets.add(offsetMap);
|
||||
dataOffsets.sort(); // 1104125
|
||||
for (int i = 0; i < dataOffsets.size(); i++) {
|
||||
codedIS.seek(dataOffsets.get(i) + offset);
|
||||
int len = codedIS.readRawVarint32();
|
||||
int oldLim = codedIS.pushLimit(len);
|
||||
readPoiNameIndexData(offsetMap, req);
|
||||
codedIS.popLimit(oldLim);
|
||||
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);
|
||||
}
|
||||
if (dataOffsets != null) {
|
||||
dataOffsets.sort(); // 1104125
|
||||
for (int i = 0; i < dataOffsets.size(); i++) {
|
||||
codedIS.seek(dataOffsets.get(i) + offset);
|
||||
int len = codedIS.readRawVarint32();
|
||||
int oldLim = codedIS.pushLimit(len);
|
||||
readPoiNameIndexData(offsets, req);
|
||||
codedIS.popLimit(oldLim);
|
||||
if (req.isCancelled()) {
|
||||
codedIS.skipRawBytes(codedIS.getBytesUntilLimit());
|
||||
return offsets;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -605,12 +577,13 @@ public class BinaryMapPoiReaderAdapter {
|
|||
}
|
||||
}
|
||||
if (!matches) {
|
||||
for (String key : am.getAdditionalInfoKeys()) {
|
||||
if(!key.contains("_name") &&
|
||||
!key.equals("brand")) {
|
||||
Map<String, String> lt = am.getAdditionalInfo();
|
||||
for (Entry<String, String> e : lt.entrySet()) {
|
||||
if(!e.getKey().contains("_name") &&
|
||||
!e.getKey().equals("brand")) {
|
||||
continue;
|
||||
}
|
||||
matches = matcher.matches(am.getAdditionalInfo(key));
|
||||
matches = matcher.matches(e.getValue());
|
||||
if (matches) {
|
||||
break;
|
||||
}
|
||||
|
@ -618,7 +591,6 @@ public class BinaryMapPoiReaderAdapter {
|
|||
}
|
||||
}
|
||||
if (matches) {
|
||||
req.collectRawData(am);
|
||||
req.publish(am);
|
||||
}
|
||||
}
|
||||
|
@ -665,7 +637,6 @@ public class BinaryMapPoiReaderAdapter {
|
|||
int yp = (int) MapUtils.getTileNumberY(zSkip, am.getLocation().getLatitude());
|
||||
long valSkip = (((long) xp) << zSkip) | yp;
|
||||
if (!toSkip.contains(valSkip)) {
|
||||
req.collectRawData(am);
|
||||
boolean publish = req.publish(am);
|
||||
if (publish) {
|
||||
read = true;
|
||||
|
@ -676,7 +647,6 @@ public class BinaryMapPoiReaderAdapter {
|
|||
return read;
|
||||
}
|
||||
} else {
|
||||
req.collectRawData(am);
|
||||
if (req.publish(am)) {
|
||||
read = true;
|
||||
}
|
||||
|
@ -719,8 +689,6 @@ public class BinaryMapPoiReaderAdapter {
|
|||
Amenity am = null;
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int precisionXY = 0;
|
||||
boolean hasLocation = false;
|
||||
StringBuilder retValue = new StringBuilder();
|
||||
PoiCategory amenityType = null;
|
||||
LinkedList<String> textTags = null;
|
||||
|
@ -747,22 +715,12 @@ public class BinaryMapPoiReaderAdapter {
|
|||
am.setRoutePoint(arp);
|
||||
}
|
||||
}
|
||||
if (hasLocation) {
|
||||
if (precisionXY != 0) {
|
||||
int[] xy = MapUtils.calculateFinalXYFromBaseAndPrecisionXY(BASE_POI_ZOOM, FINAL_POI_ZOOM, precisionXY, x >> BASE_POI_SHIFT, y >> BASE_POI_SHIFT, true);
|
||||
int x31 = xy[0] << FINAL_POI_SHIFT;
|
||||
int y31 = xy[1] << FINAL_POI_SHIFT;
|
||||
am.setLocation(MapUtils.get31LatitudeY(y31), MapUtils.get31LongitudeX(x31));
|
||||
} else {
|
||||
am.setLocation(MapUtils.get31LatitudeY(y), MapUtils.get31LongitudeX(x));
|
||||
}
|
||||
}
|
||||
return am;
|
||||
case OsmandOdb.OsmAndPoiBoxDataAtom.DX_FIELD_NUMBER:
|
||||
x = (codedIS.readSInt32() + (px << (BASE_POI_ZOOM - zoom))) << BASE_POI_SHIFT;
|
||||
x = (codedIS.readSInt32() + (px << (24 - zoom))) << 7;
|
||||
break;
|
||||
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++;
|
||||
if (checkBounds) {
|
||||
if (left31 > x || right31 < x || top31 > y || bottom31 < y) {
|
||||
|
@ -771,8 +729,7 @@ public class BinaryMapPoiReaderAdapter {
|
|||
}
|
||||
}
|
||||
am = new Amenity();
|
||||
hasLocation = true;
|
||||
//am.setLocation(MapUtils.get31LatitudeY(y), MapUtils.get31LongitudeX(x)); // set precise coordinates
|
||||
am.setLocation(MapUtils.get31LatitudeY(y), MapUtils.get31LongitudeX(x));
|
||||
break;
|
||||
case OsmandOdb.OsmAndPoiBoxDataAtom.SUBCATEGORIES_FIELD_NUMBER:
|
||||
int subtypev = codedIS.readUInt32();
|
||||
|
@ -813,8 +770,7 @@ public class BinaryMapPoiReaderAdapter {
|
|||
}
|
||||
}
|
||||
subtype = poiTypes.replaceDeprecatedSubtype(type, subtype);
|
||||
boolean isForbidden = poiTypes.isTypeForbidden(subtype);
|
||||
if (!isForbidden && (req.poiTypeFilter == null || req.poiTypeFilter.accept(type, subtype))) {
|
||||
if (req.poiTypeFilter == null || req.poiTypeFilter.accept(type, subtype)) {
|
||||
if (amenityType == null) {
|
||||
amenityType = type;
|
||||
am.setSubType(subtype);
|
||||
|
@ -845,11 +801,6 @@ public class BinaryMapPoiReaderAdapter {
|
|||
case OsmandOdb.OsmAndPoiBoxDataAtom.NOTE_FIELD_NUMBER:
|
||||
am.setDescription(codedIS.readString());
|
||||
break;
|
||||
case OsmandOdb.OsmAndPoiBoxDataAtom.PRECISIONXY_FIELD_NUMBER:
|
||||
if (hasLocation) {
|
||||
precisionXY = codedIS.readInt32();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
skipUnknownField(t);
|
||||
break;
|
||||
|
@ -858,6 +809,7 @@ public class BinaryMapPoiReaderAdapter {
|
|||
}
|
||||
|
||||
private boolean checkCategories(SearchRequest<Amenity> req, PoiRegion region) throws IOException {
|
||||
StringBuilder subType = new StringBuilder();
|
||||
while (true) {
|
||||
int t = codedIS.readTag();
|
||||
int tag = WireFormat.getTagFieldNumber(t);
|
||||
|
|
|
@ -172,7 +172,7 @@ public class BinaryMapRouteReaderAdapter {
|
|||
}
|
||||
return tag;
|
||||
}
|
||||
|
||||
|
||||
public int onewayDirection(){
|
||||
if(type == ONEWAY){
|
||||
return intValue;
|
||||
|
@ -293,20 +293,10 @@ public class BinaryMapRouteReaderAdapter {
|
|||
public static class RouteRegion extends BinaryIndexPart {
|
||||
public int regionsRead;
|
||||
public List<RouteTypeRule> routeEncodingRules = new ArrayList<BinaryMapRouteReaderAdapter.RouteTypeRule>();
|
||||
public int routeEncodingRulesBytes = 0;
|
||||
public Map<String, Integer> decodingRules = null;
|
||||
List<RouteSubregion> subregions = new ArrayList<RouteSubregion>();
|
||||
List<RouteSubregion> basesubregions = new ArrayList<RouteSubregion>();
|
||||
|
||||
public int directionForward = -1;
|
||||
public int directionBackward = -1;
|
||||
public int directionTrafficSignalsForward = -1;
|
||||
public int directionTrafficSignalsBackward = -1;
|
||||
public int trafficSignals = -1;
|
||||
public int stopSign = -1;
|
||||
public int stopMinor = -1;
|
||||
public int giveWaySign = -1;
|
||||
|
||||
int nameTypeRule = -1;
|
||||
int refTypeRule = -1;
|
||||
int destinationTypeRule = -1;
|
||||
|
@ -363,30 +353,9 @@ public class BinaryMapRouteReaderAdapter {
|
|||
destinationTypeRule = id;
|
||||
} else if (tags.equals("destination:ref") || tags.equals("destination:ref:forward") || tags.equals("destination:ref:backward")) {
|
||||
destinationRefTypeRule = id;
|
||||
} else if (tags.equals("highway") && val.equals("traffic_signals")){
|
||||
trafficSignals = id;
|
||||
} else if (tags.equals("stop") && val.equals("minor")) {
|
||||
stopMinor = id;
|
||||
} else if (tags.equals("highway") && val.equals("stop")){
|
||||
stopSign = id;
|
||||
} else if (tags.equals("highway") && val.equals("give_way")){
|
||||
giveWaySign = id;
|
||||
} else if (tags.equals("traffic_signals:direction") && val != null){
|
||||
if (val.equals("forward")) {
|
||||
directionTrafficSignalsForward = id;
|
||||
} else if (val.equals("backward")) {
|
||||
directionTrafficSignalsBackward = id;
|
||||
}
|
||||
} else if (tags.equals("direction") && val != null) {
|
||||
if (val.equals("forward")) {
|
||||
directionForward = id;
|
||||
} else if (val.equals("backward")) {
|
||||
directionBackward = id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void completeRouteEncodingRules() {
|
||||
for(int i = 0; i < routeEncodingRules.size(); i++) {
|
||||
RouteTypeRule rtr = routeEncodingRules.get(i);
|
||||
|
@ -619,7 +588,6 @@ public class BinaryMapRouteReaderAdapter {
|
|||
|
||||
protected void readRouteIndex(RouteRegion region) throws IOException {
|
||||
int routeEncodingRule = 1;
|
||||
int routeEncodingRulesSize = 0;
|
||||
while(true){
|
||||
int t = codedIS.readTag();
|
||||
int tag = WireFormat.getTagFieldNumber(t);
|
||||
|
@ -632,13 +600,10 @@ public class BinaryMapRouteReaderAdapter {
|
|||
break;
|
||||
case OsmandOdb.OsmAndRoutingIndex.RULES_FIELD_NUMBER: {
|
||||
int len = codedIS.readInt32();
|
||||
if(routeEncodingRulesSize == 0) {
|
||||
routeEncodingRulesSize = codedIS.getTotalBytesRead();
|
||||
}
|
||||
int oldLimit = codedIS.pushLimit(len);
|
||||
readRouteEncodingRule(region, routeEncodingRule++);
|
||||
codedIS.skipRawBytes(codedIS.getBytesUntilLimit());
|
||||
codedIS.popLimit(oldLimit);
|
||||
region.routeEncodingRulesBytes = codedIS.getTotalBytesRead() - routeEncodingRulesSize;
|
||||
} break;
|
||||
case OsmandOdb.OsmAndRoutingIndex.ROOTBOXES_FIELD_NUMBER :
|
||||
case OsmandOdb.OsmAndRoutingIndex.BASEMAPBOXES_FIELD_NUMBER :{
|
||||
|
|
|
@ -11,7 +11,6 @@ import com.google.protobuf.WireFormat;
|
|||
import gnu.trove.map.hash.TIntObjectHashMap;
|
||||
import gnu.trove.map.hash.TLongObjectHashMap;
|
||||
import net.osmand.binary.BinaryMapIndexReader.SearchRequest;
|
||||
import net.osmand.data.IncompleteTransportRoute;
|
||||
import net.osmand.data.TransportSchedule;
|
||||
import net.osmand.data.TransportStop;
|
||||
import net.osmand.data.TransportStopExit;
|
||||
|
@ -72,6 +71,7 @@ public class BinaryMapTransportReaderAdapter {
|
|||
return bottom;
|
||||
}
|
||||
|
||||
|
||||
IndexStringTable stringTable = null;
|
||||
}
|
||||
|
||||
|
@ -251,7 +251,9 @@ public class BinaryMapTransportReaderAdapter {
|
|||
return ((char) i)+"";
|
||||
}
|
||||
|
||||
public void readIncompleteRoutesList(TLongObjectHashMap<net.osmand.data.IncompleteTransportRoute> incompleteRoutes, int transportIndexStart) throws IOException {
|
||||
public void readIncompleteRoutesList(TLongObjectHashMap<net.osmand.data.IncompleteTransportRoute> incompleteRoutes,
|
||||
int length, int offset) throws IOException {
|
||||
codedIS.seek(offset);
|
||||
boolean end = false;
|
||||
while (!end) {
|
||||
int t = codedIS.readTag();
|
||||
|
@ -263,7 +265,7 @@ public class BinaryMapTransportReaderAdapter {
|
|||
case OsmandOdb.IncompleteTransportRoutes.ROUTES_FIELD_NUMBER:
|
||||
int l = codedIS.readRawVarint32();
|
||||
int olds = codedIS.pushLimit(l);
|
||||
net.osmand.data.IncompleteTransportRoute ir = readIncompleteRoute(transportIndexStart);
|
||||
net.osmand.data.IncompleteTransportRoute ir = readIncompleteRoute();
|
||||
net.osmand.data.IncompleteTransportRoute itr = incompleteRoutes.get(ir.getRouteId());
|
||||
if(itr != null) {
|
||||
itr.setNextLinkedRoute(ir);
|
||||
|
@ -281,7 +283,7 @@ public class BinaryMapTransportReaderAdapter {
|
|||
|
||||
}
|
||||
|
||||
public net.osmand.data.IncompleteTransportRoute readIncompleteRoute(int transportIndexStart) throws IOException {
|
||||
public net.osmand.data.IncompleteTransportRoute readIncompleteRoute() throws IOException {
|
||||
net.osmand.data.IncompleteTransportRoute dataObject = new net.osmand.data.IncompleteTransportRoute();
|
||||
boolean end = false;
|
||||
while(!end){
|
||||
|
@ -295,12 +297,7 @@ public class BinaryMapTransportReaderAdapter {
|
|||
dataObject.setRouteId(codedIS.readUInt64());
|
||||
break;
|
||||
case OsmandOdb.IncompleteTransportRoute.ROUTEREF_FIELD_NUMBER :
|
||||
int delta = codedIS.readRawVarint32();
|
||||
if (delta > transportIndexStart) {
|
||||
dataObject.setRouteOffset(delta);
|
||||
} else {
|
||||
dataObject.setRouteOffset(transportIndexStart + delta);
|
||||
}
|
||||
dataObject.setRouteOffset(codedIS.readRawVarint32());
|
||||
break;
|
||||
case OsmandOdb.IncompleteTransportRoute.OPERATOR_FIELD_NUMBER :
|
||||
skipUnknownField(t);
|
||||
|
@ -323,6 +320,7 @@ public class BinaryMapTransportReaderAdapter {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return dataObject;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
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.binary.BinaryMapAddressReaderAdapter.AddressRegion;
|
||||
import net.osmand.binary.BinaryMapAddressReaderAdapter.CitiesBlock;
|
||||
|
@ -23,50 +29,42 @@ import net.osmand.binary.OsmandIndex.TransportPart;
|
|||
|
||||
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 {
|
||||
|
||||
|
||||
private OsmAndStoredIndex storedIndex;
|
||||
private OsmAndStoredIndex.Builder storedIndexBuilder;
|
||||
private Log log = PlatformUtil.getLog(CachedOsmandIndexes.class);
|
||||
private boolean hasChanged = true;
|
||||
|
||||
|
||||
public static final int VERSION = 2;
|
||||
|
||||
public void addToCache(BinaryMapIndexReader reader, File f) {
|
||||
hasChanged = true;
|
||||
if (storedIndexBuilder == null) {
|
||||
if(storedIndexBuilder == null) {
|
||||
storedIndexBuilder = OsmandIndex.OsmAndStoredIndex.newBuilder();
|
||||
storedIndexBuilder.setVersion(VERSION);
|
||||
storedIndexBuilder.setDateCreated(System.currentTimeMillis());
|
||||
if (storedIndex != null) {
|
||||
for (FileIndex ex : storedIndex.getFileIndexList()) {
|
||||
if (!ex.getFileName().equals(f.getName())) {
|
||||
storedIndexBuilder.addFileIndex(ex);
|
||||
}
|
||||
if(storedIndex != null) {
|
||||
for(FileIndex ex : storedIndex.getFileIndexList()) {
|
||||
storedIndexBuilder.addFileIndex(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
FileIndex.Builder fileIndex = OsmandIndex.FileIndex.newBuilder();
|
||||
long d = reader.getDateCreated();
|
||||
fileIndex.setDateModified(d == 0 ? f.lastModified() : d);
|
||||
fileIndex.setDateModified(d== 0?f.lastModified() : d);
|
||||
fileIndex.setSize(f.length());
|
||||
fileIndex.setVersion(reader.getVersion());
|
||||
fileIndex.setFileName(f.getName());
|
||||
for (MapIndex index : reader.getMapIndexes()) {
|
||||
for(MapIndex index : reader.getMapIndexes()) {
|
||||
MapPart.Builder map = OsmandIndex.MapPart.newBuilder();
|
||||
map.setSize(index.getLength());
|
||||
map.setOffset(index.getFilePointer());
|
||||
if (index.getName() != null) {
|
||||
if(index.getName() != null) {
|
||||
map.setName(index.getName());
|
||||
}
|
||||
for (MapRoot mr : index.getRoots()) {
|
||||
for(MapRoot mr : index.getRoots() ) {
|
||||
MapLevel.Builder lev = OsmandIndex.MapLevel.newBuilder();
|
||||
lev.setSize(mr.length);
|
||||
lev.setOffset(mr.filePointer);
|
||||
|
@ -80,36 +78,36 @@ public class CachedOsmandIndexes {
|
|||
}
|
||||
fileIndex.addMapIndex(map);
|
||||
}
|
||||
|
||||
for (AddressRegion index : reader.getAddressIndexes()) {
|
||||
|
||||
for(AddressRegion index : reader.getAddressIndexes()) {
|
||||
AddressPart.Builder addr = OsmandIndex.AddressPart.newBuilder();
|
||||
addr.setSize(index.getLength());
|
||||
addr.setOffset(index.getFilePointer());
|
||||
if (index.getName() != null) {
|
||||
if(index.getName() != null) {
|
||||
addr.setName(index.getName());
|
||||
}
|
||||
if (index.getEnName() != null) {
|
||||
if(index.getEnName() != null) {
|
||||
addr.setNameEn(index.getEnName());
|
||||
}
|
||||
addr.setIndexNameOffset(index.getIndexNameOffset());
|
||||
for (CitiesBlock mr : index.getCities()) {
|
||||
for(CitiesBlock mr : index.getCities() ) {
|
||||
CityBlock.Builder cblock = OsmandIndex.CityBlock.newBuilder();
|
||||
cblock.setSize(mr.length);
|
||||
cblock.setOffset(mr.filePointer);
|
||||
cblock.setType(mr.type);
|
||||
addr.addCities(cblock);
|
||||
}
|
||||
for (String s : index.getAttributeTagsTable()) {
|
||||
for(String s : index.getAttributeTagsTable()) {
|
||||
addr.addAdditionalTags(s);
|
||||
}
|
||||
fileIndex.addAddressIndex(addr);
|
||||
}
|
||||
|
||||
for (PoiRegion index : reader.getPoiIndexes()) {
|
||||
|
||||
for(PoiRegion index : reader.getPoiIndexes()) {
|
||||
PoiPart.Builder poi = OsmandIndex.PoiPart.newBuilder();
|
||||
poi.setSize(index.getLength());
|
||||
poi.setOffset(index.getFilePointer());
|
||||
if (index.getName() != null) {
|
||||
if(index.getName() != null) {
|
||||
poi.setName(index.getName());
|
||||
}
|
||||
poi.setLeft(index.left31);
|
||||
|
@ -118,12 +116,12 @@ public class CachedOsmandIndexes {
|
|||
poi.setBottom(index.bottom31);
|
||||
fileIndex.addPoiIndex(poi.build());
|
||||
}
|
||||
|
||||
for (TransportIndex index : reader.getTransportIndexes()) {
|
||||
|
||||
for(TransportIndex index : reader.getTransportIndexes()) {
|
||||
TransportPart.Builder transport = OsmandIndex.TransportPart.newBuilder();
|
||||
transport.setSize(index.getLength());
|
||||
transport.setOffset(index.getFilePointer());
|
||||
if (index.getName() != null) {
|
||||
if(index.getName() != null) {
|
||||
transport.setName(index.getName());
|
||||
}
|
||||
transport.setLeft(index.getLeft());
|
||||
|
@ -132,33 +130,33 @@ public class CachedOsmandIndexes {
|
|||
transport.setBottom(index.getBottom());
|
||||
transport.setStopsTableLength(index.stopsFileLength);
|
||||
transport.setStopsTableOffset(index.stopsFileOffset);
|
||||
// if(index.incompleteRoutesLength > 0) {
|
||||
// if(index.incompleteRoutesLength > 0) {
|
||||
transport.setIncompleteRoutesLength(index.incompleteRoutesLength);
|
||||
transport.setIncompleteRoutesOffset(index.incompleteRoutesOffset);
|
||||
// }
|
||||
// }
|
||||
transport.setStringTableLength(index.stringTable.length);
|
||||
transport.setStringTableOffset(index.stringTable.fileOffset);
|
||||
fileIndex.addTransportIndex(transport);
|
||||
}
|
||||
|
||||
for (RouteRegion index : reader.getRoutingIndexes()) {
|
||||
|
||||
for(RouteRegion index : reader.getRoutingIndexes()) {
|
||||
RoutingPart.Builder routing = OsmandIndex.RoutingPart.newBuilder();
|
||||
routing.setSize(index.getLength());
|
||||
routing.setOffset(index.getFilePointer());
|
||||
if (index.getName() != null) {
|
||||
if(index.getName() != null) {
|
||||
routing.setName(index.getName());
|
||||
}
|
||||
for (RouteSubregion sub : index.getSubregions()) {
|
||||
for(RouteSubregion sub : index.getSubregions()) {
|
||||
addRouteSubregion(routing, sub, false);
|
||||
}
|
||||
for (RouteSubregion sub : index.getBaseSubregions()) {
|
||||
for(RouteSubregion sub : index.getBaseSubregions()) {
|
||||
addRouteSubregion(routing, sub, true);
|
||||
}
|
||||
fileIndex.addRoutingIndex(routing);
|
||||
}
|
||||
|
||||
|
||||
storedIndexBuilder.addFileIndex(fileIndex);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void addRouteSubregion(RoutingPart.Builder routing, RouteSubregion sub, boolean base) {
|
||||
|
@ -173,11 +171,11 @@ public class CachedOsmandIndexes {
|
|||
rpart.setShifToData(sub.shiftToData);
|
||||
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");
|
||||
FileIndex found = null;
|
||||
if (storedIndex != null && useStoredIndex) {
|
||||
if (storedIndex != null) {
|
||||
for (int i = 0; i < storedIndex.getFileIndexCount(); i++) {
|
||||
FileIndex fi = storedIndex.getFileIndex(i);
|
||||
if (f.length() == fi.getSize() && f.getName().equals(fi.getFileName())) {
|
||||
|
@ -193,26 +191,26 @@ public class CachedOsmandIndexes {
|
|||
reader = new BinaryMapIndexReader(mf, f);
|
||||
addToCache(reader, f);
|
||||
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 {
|
||||
reader = initFileIndex(found, mf, f);
|
||||
}
|
||||
return reader;
|
||||
}
|
||||
|
||||
|
||||
private BinaryMapIndexReader initFileIndex(FileIndex found, RandomAccessFile mf, File f) throws IOException {
|
||||
BinaryMapIndexReader reader = new BinaryMapIndexReader(mf, f, false);
|
||||
reader.version = found.getVersion();
|
||||
reader.dateCreated = found.getDateModified();
|
||||
|
||||
for (MapPart index : found.getMapIndexList()) {
|
||||
|
||||
for(MapPart index : found.getMapIndexList()) {
|
||||
MapIndex mi = new MapIndex();
|
||||
mi.length = (int) index.getSize();
|
||||
mi.filePointer = (int) index.getOffset();
|
||||
mi.name = index.getName();
|
||||
|
||||
for (MapLevel mr : index.getLevelsList()) {
|
||||
|
||||
for(MapLevel mr : index.getLevelsList()) {
|
||||
MapRoot root = new MapRoot();
|
||||
root.length = (int) mr.getSize();
|
||||
root.filePointer = (int) mr.getOffset();
|
||||
|
@ -228,27 +226,29 @@ public class CachedOsmandIndexes {
|
|||
reader.indexes.add(mi);
|
||||
reader.basemap = reader.basemap || mi.isBaseMap();
|
||||
}
|
||||
|
||||
for (AddressPart index : found.getAddressIndexList()) {
|
||||
|
||||
for(AddressPart index : found.getAddressIndexList()) {
|
||||
AddressRegion mi = new AddressRegion();
|
||||
mi.length = (int) index.getSize();
|
||||
mi.filePointer = (int) index.getOffset();
|
||||
mi.name = index.getName();
|
||||
mi.enName = index.getNameEn();
|
||||
mi.indexNameOffset = index.getIndexNameOffset();
|
||||
for (CityBlock mr : index.getCitiesList()) {
|
||||
for(CityBlock mr : index.getCitiesList() ) {
|
||||
CitiesBlock cblock = new CitiesBlock();
|
||||
cblock.length = (int) mr.getSize();
|
||||
cblock.filePointer = (int) mr.getOffset();
|
||||
cblock.type = mr.getType();
|
||||
mi.cities.add(cblock);
|
||||
}
|
||||
mi.attributeTagsTable.addAll(index.getAdditionalTagsList());
|
||||
for(String s : index.getAdditionalTagsList()) {
|
||||
mi.attributeTagsTable.add(s);
|
||||
}
|
||||
reader.addressIndexes.add(mi);
|
||||
reader.indexes.add(mi);
|
||||
}
|
||||
|
||||
for (PoiPart index : found.getPoiIndexList()) {
|
||||
|
||||
for(PoiPart index : found.getPoiIndexList()) {
|
||||
PoiRegion mi = new PoiRegion();
|
||||
mi.length = (int) index.getSize();
|
||||
mi.filePointer = (int) index.getOffset();
|
||||
|
@ -260,14 +260,14 @@ public class CachedOsmandIndexes {
|
|||
reader.poiIndexes.add(mi);
|
||||
reader.indexes.add(mi);
|
||||
}
|
||||
|
||||
for (TransportPart index : found.getTransportIndexList()) {
|
||||
|
||||
for(TransportPart index : found.getTransportIndexList()) {
|
||||
TransportIndex mi = new TransportIndex();
|
||||
mi.length = (int) index.getSize();
|
||||
mi.filePointer = (int) index.getOffset();
|
||||
mi.name = index.getName();
|
||||
mi.left = index.getLeft();
|
||||
mi.right = index.getRight();
|
||||
mi.right =index.getRight();
|
||||
mi.top = index.getTop();
|
||||
mi.bottom = index.getBottom();
|
||||
mi.stopsFileLength = index.getStopsTableLength();
|
||||
|
@ -280,14 +280,14 @@ public class CachedOsmandIndexes {
|
|||
reader.transportIndexes.add(mi);
|
||||
reader.indexes.add(mi);
|
||||
}
|
||||
|
||||
for (RoutingPart index : found.getRoutingIndexList()) {
|
||||
|
||||
for(RoutingPart index : found.getRoutingIndexList()) {
|
||||
RouteRegion mi = new RouteRegion();
|
||||
mi.length = (int) index.getSize();
|
||||
mi.filePointer = (int) index.getOffset();
|
||||
mi.name = index.getName();
|
||||
|
||||
for (RoutingSubregion mr : index.getSubregionsList()) {
|
||||
|
||||
for(RoutingSubregion mr : index.getSubregionsList()) {
|
||||
RouteSubregion sub = new RouteSubregion(mi);
|
||||
sub.length = (int) mr.getSize();
|
||||
sub.filePointer = (int) mr.getOffset();
|
||||
|
@ -296,7 +296,7 @@ public class CachedOsmandIndexes {
|
|||
sub.top = mr.getTop();
|
||||
sub.bottom = mr.getBottom();
|
||||
sub.shiftToData = mr.getShifToData();
|
||||
if (mr.getBasemap()) {
|
||||
if(mr.getBasemap()) {
|
||||
mi.basesubregions.add(sub);
|
||||
} else {
|
||||
mi.subregions.add(sub);
|
||||
|
@ -305,7 +305,7 @@ public class CachedOsmandIndexes {
|
|||
reader.routingIndexes.add(mi);
|
||||
reader.indexes.add(mi);
|
||||
}
|
||||
|
||||
|
||||
return reader;
|
||||
}
|
||||
|
||||
|
@ -315,7 +315,7 @@ public class CachedOsmandIndexes {
|
|||
try {
|
||||
storedIndex = OsmandIndex.OsmAndStoredIndex.newBuilder().mergeFrom(is).build();
|
||||
hasChanged = false;
|
||||
if (storedIndex.getVersion() != version) {
|
||||
if(storedIndex.getVersion() != version){
|
||||
storedIndex = null;
|
||||
}
|
||||
} finally {
|
||||
|
@ -323,7 +323,7 @@ public class CachedOsmandIndexes {
|
|||
}
|
||||
log.info("Initialize cache " + (System.currentTimeMillis() - time));
|
||||
}
|
||||
|
||||
|
||||
public void writeToFile(File f) throws IOException {
|
||||
if (hasChanged) {
|
||||
FileOutputStream outputStream = new FileOutputStream(f);
|
||||
|
|
|
@ -764,7 +764,6 @@ public class CommonWords {
|
|||
addFrequentlyUsed("martiri");
|
||||
addFrequentlyUsed("verdi");
|
||||
addFrequentlyUsed("augusta");
|
||||
addFrequentlyUsed("neuburger");
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ import net.osmand.PlatformUtil;
|
|||
import net.osmand.ResultMatcher;
|
||||
import net.osmand.CollatorStringMatcher.StringMatcherMode;
|
||||
import net.osmand.binary.BinaryMapIndexReader.SearchRequest;
|
||||
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteRegion;
|
||||
import net.osmand.data.Building;
|
||||
import net.osmand.data.City;
|
||||
import net.osmand.data.LatLon;
|
||||
|
@ -24,11 +23,9 @@ import java.text.Collator;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import gnu.trove.set.hash.TLongHashSet;
|
||||
|
@ -43,7 +40,7 @@ public class GeocodingUtilities {
|
|||
public static final float STOP_SEARCHING_STREET_WITH_MULTIPLIER_RADIUS = 250;
|
||||
public static final float STOP_SEARCHING_STREET_WITHOUT_MULTIPLIER_RADIUS = 400;
|
||||
|
||||
public static final int DISTANCE_STREET_NAME_PROXIMITY_BY_NAME = 45000;
|
||||
public static final int DISTANCE_STREET_NAME_PROXIMITY_BY_NAME = 15000;
|
||||
public static final float DISTANCE_STREET_FROM_CLOSEST_WITH_SAME_NAME = 1000;
|
||||
|
||||
public static final float THRESHOLD_MULTIPLIER_SKIP_BUILDINGS_AFTER = 1.5f;
|
||||
|
@ -145,12 +142,15 @@ public class GeocodingUtilities {
|
|||
RoutePlannerFrontEnd rp = new RoutePlannerFrontEnd();
|
||||
List<GeocodingResult> lst = new ArrayList<GeocodingUtilities.GeocodingResult>();
|
||||
List<RouteSegmentPoint> listR = new ArrayList<BinaryRoutePlanner.RouteSegmentPoint>();
|
||||
// we allow duplications to search in both files for boundary regions
|
||||
rp.findRouteSegment(lat, lon, ctx, listR, false, true);
|
||||
rp.findRouteSegment(lat, lon, ctx, listR);
|
||||
double distSquare = 0;
|
||||
Map<String, List<RouteRegion>> streetNames = new HashMap<>();
|
||||
TLongHashSet set = new TLongHashSet();
|
||||
Set<String> streetNames = new HashSet<String>();
|
||||
for (RouteSegmentPoint p : listR) {
|
||||
RouteDataObject road = p.getRoad();
|
||||
if (!set.add(road.getId())) {
|
||||
continue;
|
||||
}
|
||||
// System.out.println(road.toString() + " " + Math.sqrt(p.distSquare));
|
||||
String name = Algorithms.isEmpty(road.getName()) ? road.getRef("", false, true) : road.getName();
|
||||
if (allowEmptyNames || !Algorithms.isEmpty(name)) {
|
||||
|
@ -164,13 +164,7 @@ public class GeocodingUtilities {
|
|||
sr.connectionPoint = new LatLon(MapUtils.get31LatitudeY(p.preciseY), MapUtils.get31LongitudeX(p.preciseX));
|
||||
sr.regionFP = road.region.getFilePointer();
|
||||
sr.regionLen = road.region.getLength();
|
||||
List<RouteRegion> plst = streetNames.get(sr.streetName);
|
||||
if (plst == null) {
|
||||
plst = new ArrayList<BinaryMapRouteReaderAdapter.RouteRegion>();
|
||||
streetNames.put(sr.streetName, plst);
|
||||
}
|
||||
if (!plst.contains(road.region)) {
|
||||
plst.add(road.region);
|
||||
if (streetNames.add(sr.streetName)) {
|
||||
lst.add(sr);
|
||||
}
|
||||
}
|
||||
|
@ -282,12 +276,10 @@ public class GeocodingUtilities {
|
|||
} else {
|
||||
Collections.sort(streetsList, DISTANCE_COMPARATOR);
|
||||
double streetDistance = 0;
|
||||
boolean isBuildingFound = knownMinBuildingDistance > 0;
|
||||
for (GeocodingResult street : streetsList) {
|
||||
if (streetDistance == 0) {
|
||||
streetDistance = street.getDistance();
|
||||
} else if (streetDistance > 0 && street.getDistance() > streetDistance + DISTANCE_STREET_FROM_CLOSEST_WITH_SAME_NAME &&
|
||||
isBuildingFound) {
|
||||
} else if (street.getDistance() > streetDistance + DISTANCE_STREET_FROM_CLOSEST_WITH_SAME_NAME) {
|
||||
continue;
|
||||
}
|
||||
street.connectionPoint = road.connectionPoint;
|
||||
|
@ -298,7 +290,6 @@ public class GeocodingUtilities {
|
|||
if (knownMinBuildingDistance == 0) {
|
||||
GeocodingResult firstBld = it.next();
|
||||
knownMinBuildingDistance = firstBld.getDistance();
|
||||
isBuildingFound = true;
|
||||
res.add(firstBld);
|
||||
}
|
||||
while (it.hasNext()) {
|
||||
|
@ -317,50 +308,6 @@ public class GeocodingUtilities {
|
|||
return res;
|
||||
}
|
||||
|
||||
public void filterDuplicateRegionResults(final List<GeocodingResult> res) {
|
||||
Collections.sort(res, DISTANCE_COMPARATOR);
|
||||
// filter duplicate city results (when building is in both regions on boundary)
|
||||
for (int i = 0; i < res.size() - 1;) {
|
||||
int cmp = cmpResult(res.get(i), res.get(i + 1));
|
||||
if (cmp > 0) {
|
||||
res.remove(i);
|
||||
} else if (cmp < 0) {
|
||||
res.remove(i + 1);
|
||||
} else {
|
||||
// nothing to delete
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int cmpResult(GeocodingResult gr1, GeocodingResult gr2) {
|
||||
boolean eqStreet = Algorithms.stringsEqual(gr1.streetName, gr2.streetName);
|
||||
if (eqStreet) {
|
||||
boolean sameObj = false;
|
||||
if (gr1.city != null && gr2.city != null) {
|
||||
if (gr1.building != null && gr2.building != null) {
|
||||
if (Algorithms.stringsEqual(gr1.building.getName(), gr2.building.getName())) {
|
||||
// same building
|
||||
sameObj = true;
|
||||
}
|
||||
} else if (gr1.building == null && gr2.building == null) {
|
||||
// same street
|
||||
sameObj = true;
|
||||
}
|
||||
}
|
||||
if (sameObj) {
|
||||
double cityDist1 = MapUtils.getDistance(gr1.searchPoint, gr1.city.getLocation());
|
||||
double cityDist2 = MapUtils.getDistance(gr2.searchPoint, gr2.city.getLocation());
|
||||
if (cityDist1 < cityDist2) {
|
||||
return -1;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private List<GeocodingResult> loadStreetBuildings(final GeocodingResult road, BinaryMapIndexReader reader,
|
||||
GeocodingResult street) throws IOException {
|
||||
final List<GeocodingResult> streetBuildings = new ArrayList<GeocodingResult>();
|
||||
|
|
|
@ -54371,24 +54371,6 @@ public final class OsmandOdb {
|
|||
*/
|
||||
com.google.protobuf.ByteString
|
||||
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}
|
||||
|
@ -54557,11 +54539,6 @@ public final class OsmandOdb {
|
|||
textValues_.add(input.readBytes());
|
||||
break;
|
||||
}
|
||||
case 128: {
|
||||
bitField0_ |= 0x00000200;
|
||||
precisionXY_ = input.readInt32();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
|
||||
|
@ -55071,30 +55048,6 @@ public final class OsmandOdb {
|
|||
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() {
|
||||
dx_ = 0;
|
||||
dy_ = 0;
|
||||
|
@ -55109,7 +55062,6 @@ public final class OsmandOdb {
|
|||
note_ = "";
|
||||
textCategories_ = java.util.Collections.emptyList();
|
||||
textValues_ = com.google.protobuf.LazyStringArrayList.EMPTY;
|
||||
precisionXY_ = 0;
|
||||
}
|
||||
private byte memoizedIsInitialized = -1;
|
||||
public final boolean isInitialized() {
|
||||
|
@ -55170,9 +55122,6 @@ public final class OsmandOdb {
|
|||
for (int i = 0; i < textValues_.size(); i++) {
|
||||
output.writeBytes(15, textValues_.getByteString(i));
|
||||
}
|
||||
if (((bitField0_ & 0x00000200) == 0x00000200)) {
|
||||
output.writeInt32(16, precisionXY_);
|
||||
}
|
||||
getUnknownFields().writeTo(output);
|
||||
}
|
||||
|
||||
|
@ -55254,10 +55203,6 @@ public final class OsmandOdb {
|
|||
size += dataSize;
|
||||
size += 1 * getTextValuesList().size();
|
||||
}
|
||||
if (((bitField0_ & 0x00000200) == 0x00000200)) {
|
||||
size += com.google.protobuf.CodedOutputStream
|
||||
.computeInt32Size(16, precisionXY_);
|
||||
}
|
||||
size += getUnknownFields().getSerializedSize();
|
||||
memoizedSerializedSize = size;
|
||||
return size;
|
||||
|
@ -55400,8 +55345,6 @@ public final class OsmandOdb {
|
|||
bitField0_ = (bitField0_ & ~0x00000800);
|
||||
textValues_ = com.google.protobuf.LazyStringArrayList.EMPTY;
|
||||
bitField0_ = (bitField0_ & ~0x00001000);
|
||||
precisionXY_ = 0;
|
||||
bitField0_ = (bitField0_ & ~0x00002000);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -55487,10 +55430,6 @@ public final class OsmandOdb {
|
|||
bitField0_ = (bitField0_ & ~0x00001000);
|
||||
}
|
||||
result.textValues_ = textValues_;
|
||||
if (((from_bitField0_ & 0x00002000) == 0x00002000)) {
|
||||
to_bitField0_ |= 0x00000200;
|
||||
}
|
||||
result.precisionXY_ = precisionXY_;
|
||||
result.bitField0_ = to_bitField0_;
|
||||
onBuilt();
|
||||
return result;
|
||||
|
@ -55586,9 +55525,6 @@ public final class OsmandOdb {
|
|||
}
|
||||
onChanged();
|
||||
}
|
||||
if (other.hasPrecisionXY()) {
|
||||
setPrecisionXY(other.getPrecisionXY());
|
||||
}
|
||||
this.mergeUnknownFields(other.getUnknownFields());
|
||||
return this;
|
||||
}
|
||||
|
@ -56570,55 +56506,6 @@ public final class OsmandOdb {
|
|||
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)
|
||||
}
|
||||
|
||||
|
@ -65121,38 +65008,37 @@ public final class OsmandOdb {
|
|||
"tegories\030\003 \003(\r\022\025\n\rsubcategories\030\005 \003(\r\"i\n" +
|
||||
"\020OsmAndPoiBoxData\022\014\n\004zoom\030\001 \001(\r\022\t\n\001x\030\002 \001" +
|
||||
"(\r\022\t\n\001y\030\003 \001(\r\0221\n\007poiData\030\005 \003(\0132 .OsmAnd." +
|
||||
"OBF.OsmAndPoiBoxDataAtom\"\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" +
|
||||
"egories\030\004 \003(\r\022\025\n\rsubcategories\030\005 \003(\r\022\014\n\004" +
|
||||
"name\030\006 \001(\t\022\016\n\006nameEn\030\007 \001(\t\022\n\n\002id\030\010 \001(\004\022\024" +
|
||||
"\n\014openingHours\030\n \001(\t\022\014\n\004site\030\013 \001(\t\022\r\n\005ph" +
|
||||
"one\030\014 \001(\t\022\014\n\004note\030\r \001(\t\022\026\n\016textCategorie" +
|
||||
"s\030\016 \003(\r\022\022\n\ntextValues\030\017 \003(\t\022\023\n\013precision" +
|
||||
"XY\030\020 \001(\005\"\032\n\007IdTable\022\017\n\007routeId\030\001 \003(\022\"F\n\017" +
|
||||
"RestrictionData\022\014\n\004type\030\001 \002(\005\022\014\n\004from\030\002 " +
|
||||
"\002(\005\022\n\n\002to\030\003 \002(\005\022\013\n\003via\030\004 \001(\005\"x\n\tRouteDat" +
|
||||
"a\022\016\n\006points\030\001 \002(\014\022\022\n\npointTypes\030\004 \001(\014\022\022\n",
|
||||
"\npointNames\030\005 \001(\014\022\r\n\005types\030\007 \002(\014\022\017\n\007rout" +
|
||||
"eId\030\014 \002(\005\022\023\n\013stringNames\030\016 \001(\014\"\304\005\n\022OsmAn" +
|
||||
"dRoutingIndex\022\014\n\004name\030\001 \002(\t\022?\n\005rules\030\002 \003" +
|
||||
"(\01320.OsmAnd.OBF.OsmAndRoutingIndex.Route" +
|
||||
"EncodingRule\022>\n\trootBoxes\030\003 \003(\0132+.OsmAnd" +
|
||||
".OBF.OsmAndRoutingIndex.RouteDataBox\022A\n\014" +
|
||||
"basemapBoxes\030\004 \003(\0132+.OsmAnd.OBF.OsmAndRo" +
|
||||
"utingIndex.RouteDataBox\022=\n\006blocks\030\005 \003(\0132" +
|
||||
"-.OsmAnd.OBF.OsmAndRoutingIndex.RouteDat" +
|
||||
"aBlock\032;\n\021RouteEncodingRule\022\013\n\003tag\030\003 \002(\t",
|
||||
"\022\r\n\005value\030\005 \002(\t\022\n\n\002id\030\007 \001(\r\032\231\001\n\014RouteDat" +
|
||||
"aBox\022\014\n\004left\030\001 \002(\021\022\r\n\005right\030\002 \002(\021\022\013\n\003top" +
|
||||
"\030\003 \002(\021\022\016\n\006bottom\030\004 \002(\021\022\023\n\013shiftToData\030\005 " +
|
||||
"\001(\007\022:\n\005boxes\030\007 \003(\0132+.OsmAnd.OBF.OsmAndRo" +
|
||||
"utingIndex.RouteDataBox\032\303\001\n\016RouteDataBlo" +
|
||||
"ck\022$\n\007idTable\030\005 \001(\0132\023.OsmAnd.OBF.IdTable" +
|
||||
"\022*\n\013dataObjects\030\006 \003(\0132\025.OsmAnd.OBF.Route" +
|
||||
"Data\0221\n\014restrictions\030\007 \003(\0132\033.OsmAnd.OBF." +
|
||||
"RestrictionData\022,\n\013stringTable\030\010 \001(\0132\027.O" +
|
||||
"smAnd.OBF.StringTableB\036\n\021net.osmand.bina",
|
||||
"ryB\tOsmandOdb"
|
||||
"s\030\016 \003(\r\022\022\n\ntextValues\030\017 \003(\t\"\032\n\007IdTable\022\017" +
|
||||
"\n\007routeId\030\001 \003(\022\"F\n\017RestrictionData\022\014\n\004ty" +
|
||||
"pe\030\001 \002(\005\022\014\n\004from\030\002 \002(\005\022\n\n\002to\030\003 \002(\005\022\013\n\003vi" +
|
||||
"a\030\004 \001(\005\"x\n\tRouteData\022\016\n\006points\030\001 \002(\014\022\022\n\n" +
|
||||
"pointTypes\030\004 \001(\014\022\022\n\npointNames\030\005 \001(\014\022\r\n\005",
|
||||
"types\030\007 \002(\014\022\017\n\007routeId\030\014 \002(\005\022\023\n\013stringNa" +
|
||||
"mes\030\016 \001(\014\"\304\005\n\022OsmAndRoutingIndex\022\014\n\004name" +
|
||||
"\030\001 \002(\t\022?\n\005rules\030\002 \003(\01320.OsmAnd.OBF.OsmAn" +
|
||||
"dRoutingIndex.RouteEncodingRule\022>\n\trootB" +
|
||||
"oxes\030\003 \003(\0132+.OsmAnd.OBF.OsmAndRoutingInd" +
|
||||
"ex.RouteDataBox\022A\n\014basemapBoxes\030\004 \003(\0132+." +
|
||||
"OsmAnd.OBF.OsmAndRoutingIndex.RouteDataB" +
|
||||
"ox\022=\n\006blocks\030\005 \003(\0132-.OsmAnd.OBF.OsmAndRo" +
|
||||
"utingIndex.RouteDataBlock\032;\n\021RouteEncodi" +
|
||||
"ngRule\022\013\n\003tag\030\003 \002(\t\022\r\n\005value\030\005 \002(\t\022\n\n\002id",
|
||||
"\030\007 \001(\r\032\231\001\n\014RouteDataBox\022\014\n\004left\030\001 \002(\021\022\r\n" +
|
||||
"\005right\030\002 \002(\021\022\013\n\003top\030\003 \002(\021\022\016\n\006bottom\030\004 \002(" +
|
||||
"\021\022\023\n\013shiftToData\030\005 \001(\007\022:\n\005boxes\030\007 \003(\0132+." +
|
||||
"OsmAnd.OBF.OsmAndRoutingIndex.RouteDataB" +
|
||||
"ox\032\303\001\n\016RouteDataBlock\022$\n\007idTable\030\005 \001(\0132\023" +
|
||||
".OsmAnd.OBF.IdTable\022*\n\013dataObjects\030\006 \003(\013" +
|
||||
"2\025.OsmAnd.OBF.RouteData\0221\n\014restrictions\030" +
|
||||
"\007 \003(\0132\033.OsmAnd.OBF.RestrictionData\022,\n\013st" +
|
||||
"ringTable\030\010 \001(\0132\027.OsmAnd.OBF.StringTable" +
|
||||
"B\036\n\021net.osmand.binaryB\tOsmandOdb"
|
||||
};
|
||||
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
|
||||
new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
|
||||
|
@ -65410,7 +65296,7 @@ public final class OsmandOdb {
|
|||
internal_static_OsmAnd_OBF_OsmAndPoiBoxDataAtom_fieldAccessorTable = new
|
||||
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
|
||||
internal_static_OsmAnd_OBF_OsmAndPoiBoxDataAtom_descriptor,
|
||||
new java.lang.String[] { "Dx", "Dy", "Categories", "Subcategories", "Name", "NameEn", "Id", "OpeningHours", "Site", "Phone", "Note", "TextCategories", "TextValues", "PrecisionXY", });
|
||||
new java.lang.String[] { "Dx", "Dy", "Categories", "Subcategories", "Name", "NameEn", "Id", "OpeningHours", "Site", "Phone", "Note", "TextCategories", "TextValues", });
|
||||
internal_static_OsmAnd_OBF_IdTable_descriptor =
|
||||
getDescriptor().getMessageTypes().get(36);
|
||||
internal_static_OsmAnd_OBF_IdTable_fieldAccessorTable = new
|
||||
|
|
|
@ -1,16 +1,12 @@
|
|||
package net.osmand.binary;
|
||||
|
||||
import net.osmand.Location;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteRegion;
|
||||
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteTypeRule;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.util.Algorithms;
|
||||
import net.osmand.util.MapUtils;
|
||||
import net.osmand.util.TransliterationHelper;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Arrays;
|
||||
|
||||
|
@ -38,8 +34,6 @@ public class RouteDataObject {
|
|||
public int[] nameIds;
|
||||
// mixed array [0, height, cumulative_distance height, cumulative_distance, height, ...] - length is length(points)*2
|
||||
public float[] heightDistanceArray = null;
|
||||
public float heightByCurrentLocation = Float.NaN;
|
||||
private static final Log LOG = PlatformUtil.getLog(RouteDataObject.class);
|
||||
|
||||
public RouteDataObject(RouteRegion region) {
|
||||
this.region = region;
|
||||
|
@ -62,7 +56,6 @@ public class RouteDataObject {
|
|||
this.pointsY = copy.pointsY;
|
||||
this.types = copy.types;
|
||||
this.names = copy.names;
|
||||
this.nameIds = copy.nameIds;
|
||||
this.restrictions = copy.restrictions;
|
||||
this.restrictionsVia = copy.restrictionsVia;
|
||||
this.pointTypes = copy.pointTypes;
|
||||
|
@ -127,7 +120,7 @@ public class RouteDataObject {
|
|||
equals = this.pointTypes[i] == thatObj.pointTypes[i];
|
||||
} else if (pointTypes[i].length != thatObj.pointTypes[i].length) {
|
||||
equals = false;
|
||||
} else {
|
||||
} else {
|
||||
for (int j = 0; j < this.pointTypes[i].length && equals; j++) {
|
||||
String thisTag = region.routeEncodingRules.get(pointTypes[i][j]).getTag();
|
||||
String thisValue = region.routeEncodingRules.get(pointTypes[i][j]).getValue();
|
||||
|
@ -150,7 +143,7 @@ public class RouteDataObject {
|
|||
equals = this.pointNameTypes[i] == thatObj.pointNameTypes[i];
|
||||
} else if (pointNameTypes[i].length != thatObj.pointNameTypes[i].length) {
|
||||
equals = false;
|
||||
} else {
|
||||
} else {
|
||||
for (int j = 0; j < this.pointNameTypes[i].length && equals; j++) {
|
||||
String thisTag = region.routeEncodingRules.get(pointNameTypes[i][j]).getTag();
|
||||
String thisValue = pointNames[i][j];
|
||||
|
@ -168,68 +161,53 @@ public class RouteDataObject {
|
|||
}
|
||||
|
||||
public float[] calculateHeightArray() {
|
||||
return calculateHeightArray(null);
|
||||
}
|
||||
|
||||
public float[] calculateHeightArray(LatLon currentLocation) {
|
||||
if (heightDistanceArray != null) {
|
||||
if(heightDistanceArray != null) {
|
||||
return heightDistanceArray;
|
||||
}
|
||||
int startHeight = Algorithms.parseIntSilently(getValue("osmand_ele_start"), HEIGHT_UNDEFINED);
|
||||
int endHeight = Algorithms.parseIntSilently(getValue("osmand_ele_end"), startHeight);
|
||||
if (startHeight == HEIGHT_UNDEFINED) {
|
||||
if(startHeight == HEIGHT_UNDEFINED) {
|
||||
heightDistanceArray = new float[0];
|
||||
return heightDistanceArray;
|
||||
}
|
||||
|
||||
heightDistanceArray = new float[2 * getPointsLength()];
|
||||
heightDistanceArray = new float[2*getPointsLength()];
|
||||
double plon = 0;
|
||||
double plat = 0;
|
||||
float prevHeight = startHeight;
|
||||
heightByCurrentLocation = Float.NaN;
|
||||
double prevDistance = 0;
|
||||
for (int k = 0; k < getPointsLength(); k++) {
|
||||
for(int k = 0; k < getPointsLength(); k++) {
|
||||
double lon = MapUtils.get31LongitudeX(getPoint31XTile(k));
|
||||
double lat = MapUtils.get31LatitudeY(getPoint31YTile(k));
|
||||
if (k > 0) {
|
||||
if(k > 0) {
|
||||
double dd = MapUtils.getDistance(plat, plon, lat, lon);
|
||||
float height = HEIGHT_UNDEFINED;
|
||||
if (k == getPointsLength() - 1) {
|
||||
if(k == getPointsLength() - 1) {
|
||||
height = endHeight;
|
||||
} else {
|
||||
String asc = getValue(k, "osmand_ele_asc");
|
||||
if (asc != null && asc.length() > 0) {
|
||||
if(asc != null && asc.length() > 0) {
|
||||
height = (prevHeight + Float.parseFloat(asc));
|
||||
} else {
|
||||
String desc = getValue(k, "osmand_ele_desc");
|
||||
if (desc != null && desc.length() > 0) {
|
||||
if(desc != null && desc.length() > 0) {
|
||||
height = (prevHeight - Float.parseFloat(desc));
|
||||
}
|
||||
}
|
||||
}
|
||||
heightDistanceArray[2 * k] = (float) dd;
|
||||
heightDistanceArray[2 * k + 1] = height;
|
||||
|
||||
if (currentLocation != null) {
|
||||
double distance = MapUtils.getDistance(currentLocation, lat, lon);
|
||||
if (height != HEIGHT_UNDEFINED && distance < prevDistance) {
|
||||
prevDistance = distance;
|
||||
heightByCurrentLocation = height;
|
||||
}
|
||||
}
|
||||
|
||||
if (height != HEIGHT_UNDEFINED) {
|
||||
heightDistanceArray[2*k] = (float) dd;
|
||||
heightDistanceArray[2*k+1] = height;
|
||||
if(height != HEIGHT_UNDEFINED) {
|
||||
// interpolate undefined
|
||||
double totalDistance = dd;
|
||||
int startUndefined = k;
|
||||
while (startUndefined - 1 >= 0 && heightDistanceArray[2 * (startUndefined - 1) + 1] == HEIGHT_UNDEFINED) {
|
||||
startUndefined--;
|
||||
totalDistance += heightDistanceArray[2 * (startUndefined)];
|
||||
while(startUndefined - 1 >= 0 && heightDistanceArray[2*(startUndefined - 1)+1] == HEIGHT_UNDEFINED) {
|
||||
startUndefined --;
|
||||
totalDistance += heightDistanceArray[2*(startUndefined)];
|
||||
}
|
||||
if (totalDistance > 0) {
|
||||
if(totalDistance > 0) {
|
||||
double angle = (height - prevHeight) / totalDistance;
|
||||
for (int j = startUndefined; j < k; j++) {
|
||||
heightDistanceArray[2 * j + 1] = (float) ((heightDistanceArray[2 * j] * angle) + heightDistanceArray[2 * j - 1]);
|
||||
for(int j = startUndefined; j < k; j++) {
|
||||
heightDistanceArray[2*j+1] = (float) ((heightDistanceArray[2*j] * angle) + heightDistanceArray[2*j-1]);
|
||||
}
|
||||
}
|
||||
prevHeight = height;
|
||||
|
@ -241,9 +219,6 @@ public class RouteDataObject {
|
|||
}
|
||||
plat = lat;
|
||||
plon = lon;
|
||||
if (currentLocation != null) {
|
||||
prevDistance = MapUtils.getDistance(currentLocation, plat, plon);
|
||||
}
|
||||
}
|
||||
return heightDistanceArray;
|
||||
}
|
||||
|
@ -252,34 +227,34 @@ public class RouteDataObject {
|
|||
return id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
if (names != null) {
|
||||
public String getName(){
|
||||
if(names != null ) {
|
||||
return names.get(region.nameTypeRule);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public String getName(String lang) {
|
||||
public String getName(String lang){
|
||||
return getName(lang, false);
|
||||
}
|
||||
|
||||
public String getName(String lang, boolean transliterate) {
|
||||
if (names != null) {
|
||||
if (Algorithms.isEmpty(lang)) {
|
||||
public String getName(String lang, boolean transliterate){
|
||||
if(names != null ) {
|
||||
if(Algorithms.isEmpty(lang)) {
|
||||
return names.get(region.nameTypeRule);
|
||||
}
|
||||
int[] kt = names.keys();
|
||||
for (int i = 0; i < kt.length; i++) {
|
||||
for(int i = 0 ; i < kt.length; i++) {
|
||||
int k = kt[i];
|
||||
if (region.routeEncodingRules.size() > k) {
|
||||
if (("name:" + lang).equals(region.routeEncodingRules.get(k).getTag())) {
|
||||
if(region.routeEncodingRules.size() > k) {
|
||||
if(("name:"+lang).equals(region.routeEncodingRules.get(k).getTag())) {
|
||||
return names.get(k);
|
||||
}
|
||||
}
|
||||
}
|
||||
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 nmDef;
|
||||
|
@ -300,20 +275,20 @@ public class RouteDataObject {
|
|||
// return getDestinationRef(direction);
|
||||
//}
|
||||
if (names != null) {
|
||||
if (Algorithms.isEmpty(lang)) {
|
||||
if(Algorithms.isEmpty(lang)) {
|
||||
return names.get(region.refTypeRule);
|
||||
}
|
||||
int[] kt = names.keys();
|
||||
for (int i = 0; i < kt.length; i++) {
|
||||
for(int i = 0 ; i < kt.length; i++) {
|
||||
int k = kt[i];
|
||||
if (region.routeEncodingRules.size() > k) {
|
||||
if (("ref:" + lang).equals(region.routeEncodingRules.get(k).getTag())) {
|
||||
if(region.routeEncodingRules.size() > k) {
|
||||
if(("ref:"+lang).equals(region.routeEncodingRules.get(k).getTag())) {
|
||||
return names.get(k);
|
||||
}
|
||||
}
|
||||
}
|
||||
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 refDefault;
|
||||
|
@ -328,13 +303,13 @@ public class RouteDataObject {
|
|||
String refTagDefault = "destination:ref";
|
||||
String refDefault = null;
|
||||
|
||||
for (int i = 0; i < kt.length; i++) {
|
||||
for(int i = 0 ; i < kt.length; i++) {
|
||||
int k = kt[i];
|
||||
if (region.routeEncodingRules.size() > k) {
|
||||
if (refTag.equals(region.routeEncodingRules.get(k).getTag())) {
|
||||
if(region.routeEncodingRules.size() > k) {
|
||||
if(refTag.equals(region.routeEncodingRules.get(k).getTag())) {
|
||||
return names.get(k);
|
||||
}
|
||||
if (refTagDefault.equals(region.routeEncodingRules.get(k).getTag())) {
|
||||
if(refTagDefault.equals(region.routeEncodingRules.get(k).getTag())) {
|
||||
refDefault = names.get(k);
|
||||
}
|
||||
}
|
||||
|
@ -347,12 +322,12 @@ public class RouteDataObject {
|
|||
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
|
||||
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();
|
||||
|
||||
// Issue #3181: Parse destination keys in this order:
|
||||
|
@ -362,39 +337,39 @@ public class RouteDataObject {
|
|||
// destination
|
||||
|
||||
String destinationTagLangFB = "destination:lang:XX";
|
||||
if (!Algorithms.isEmpty(lang)) {
|
||||
if(!Algorithms.isEmpty(lang)) {
|
||||
destinationTagLangFB = (direction == true) ? "destination:lang:" + lang + ":forward" : "destination:lang:" + lang + ":backward";
|
||||
}
|
||||
String destinationTagFB = (direction == true) ? "destination:forward" : "destination:backward";
|
||||
String destinationTagLang = "destination:lang:XX";
|
||||
if (!Algorithms.isEmpty(lang)) {
|
||||
if(!Algorithms.isEmpty(lang)) {
|
||||
destinationTagLang = "destination:lang:" + lang;
|
||||
}
|
||||
String destinationTagDefault = "destination";
|
||||
String destinationDefault = null;
|
||||
|
||||
for (int i = 0; i < kt.length; i++) {
|
||||
for(int i = 0 ; i < kt.length; i++) {
|
||||
int k = kt[i];
|
||||
if (region.routeEncodingRules.size() > k) {
|
||||
if (!Algorithms.isEmpty(lang) && destinationTagLangFB.equals(region.routeEncodingRules.get(k).getTag())) {
|
||||
if(region.routeEncodingRules.size() > k) {
|
||||
if(!Algorithms.isEmpty(lang) && destinationTagLangFB.equals(region.routeEncodingRules.get(k).getTag())) {
|
||||
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));
|
||||
}
|
||||
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));
|
||||
}
|
||||
if (destinationTagDefault.equals(region.routeEncodingRules.get(k).getTag())) {
|
||||
if(destinationTagDefault.equals(region.routeEncodingRules.get(k).getTag())) {
|
||||
destinationDefault = names.get(k);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (destinationDefault != null) {
|
||||
if(destinationDefault != null) {
|
||||
return destRef1 + ((transliterate) ? TransliterationHelper.transliterate(destinationDefault) : destinationDefault);
|
||||
}
|
||||
}
|
||||
return Algorithms.isEmpty(destRef) ? null : destRef;
|
||||
return "".equals(destRef) ? null : destRef;
|
||||
}
|
||||
|
||||
public int getPoint31XTile(int i) {
|
||||
|
@ -421,14 +396,14 @@ public class RouteDataObject {
|
|||
RestrictionInfo ri = new RestrictionInfo();
|
||||
ri.toWay = getRestrictionId(k);
|
||||
ri.type = getRestrictionType(k);
|
||||
if (restrictionsVia != null && k < restrictionsVia.length) {
|
||||
if(restrictionsVia != null && k < restrictionsVia.length) {
|
||||
ri.viaWay = restrictionsVia[k];
|
||||
}
|
||||
return ri;
|
||||
}
|
||||
|
||||
public long getRestrictionVia(int i) {
|
||||
if (restrictionsVia != null && restrictionsVia.length > i) {
|
||||
if(restrictionsVia != null && restrictionsVia.length > i) {
|
||||
return restrictionsVia[i];
|
||||
}
|
||||
return 0;
|
||||
|
@ -451,19 +426,12 @@ public class RouteDataObject {
|
|||
int[] opointsX = pointsX;
|
||||
int[] opointsY = pointsY;
|
||||
int[][] opointTypes = pointTypes;
|
||||
String[][] opointNames = pointNames;
|
||||
int[][] opointNameTypes = pointNameTypes;
|
||||
pointsX = new int[pointsX.length + 1];
|
||||
pointsY = new int[pointsY.length + 1];
|
||||
boolean insTypes = this.pointTypes != null && this.pointTypes.length > pos;
|
||||
boolean insNames = this.pointNames != null && this.pointNames.length > pos;
|
||||
if (insTypes) {
|
||||
pointTypes = new int[opointTypes.length + 1][];
|
||||
}
|
||||
if (insNames) {
|
||||
pointNames = new String[opointNames.length + 1][];
|
||||
pointNameTypes = new int[opointNameTypes.length + 1][];
|
||||
}
|
||||
int i = 0;
|
||||
for (; i < pos; i++) {
|
||||
pointsX[i] = opointsX[i];
|
||||
|
@ -471,32 +439,18 @@ public class RouteDataObject {
|
|||
if (insTypes) {
|
||||
pointTypes[i] = opointTypes[i];
|
||||
}
|
||||
if (insNames) {
|
||||
pointNames[i] = opointNames[i];
|
||||
pointNameTypes[i] = opointNameTypes[i];
|
||||
}
|
||||
}
|
||||
pointsX[i] = x31;
|
||||
pointsY[i] = y31;
|
||||
if (insTypes) {
|
||||
pointTypes[i] = null;
|
||||
}
|
||||
if (insNames) {
|
||||
pointNames[i] = null;
|
||||
pointNameTypes[i] = null;
|
||||
}
|
||||
for (i = i + 1; i < pointsX.length; i++) {
|
||||
pointsX[i] = opointsX[i - 1];
|
||||
pointsY[i] = opointsY[i - 1];
|
||||
if (insTypes && i < pointTypes.length) {
|
||||
pointTypes[i] = opointTypes[i - 1];
|
||||
}
|
||||
if (insNames && i < pointNames.length) {
|
||||
pointNames[i] = opointNames[i - 1];
|
||||
}
|
||||
if (insNames && i < pointNameTypes.length) {
|
||||
pointNameTypes[i] = opointNameTypes[i - 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -520,24 +474,6 @@ public class RouteDataObject {
|
|||
}
|
||||
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() {
|
||||
return types;
|
||||
|
@ -584,7 +520,7 @@ public class RouteDataObject {
|
|||
String nonCondTag = rtr.getTag();
|
||||
int 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)) {
|
||||
break;
|
||||
}
|
||||
|
@ -629,7 +565,7 @@ public class RouteDataObject {
|
|||
}
|
||||
|
||||
public static float parseSpeed(String v, float def) {
|
||||
if (v.equals("none")) {
|
||||
if(v.equals("none")) {
|
||||
return RouteDataObject.NONE_MAX_SPEED;
|
||||
} else {
|
||||
int i = Algorithms.findFirstNumberEndIndex(v);
|
||||
|
@ -653,20 +589,20 @@ public class RouteDataObject {
|
|||
f += Float.parseFloat(v.substring(0, i));
|
||||
String pref = v.substring(i, v.length()).trim();
|
||||
float add = 0;
|
||||
for (int ik = 0; ik < pref.length(); ik++) {
|
||||
if (Algorithms.isDigit(pref.charAt(ik)) || pref.charAt(ik) == '.' || pref.charAt(ik) == '-') {
|
||||
for(int ik = 0; ik < pref.length(); ik++) {
|
||||
if(Algorithms.isDigit(pref.charAt(ik)) || pref.charAt(ik) == '.' || pref.charAt(ik) == '-') {
|
||||
int first = Algorithms.findFirstNumberEndIndex(pref.substring(ik));
|
||||
if (first != -1) {
|
||||
if(first != -1) {
|
||||
add = parseLength(pref.substring(ik), 0);
|
||||
pref = pref.substring(0, ik);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (pref.contains("km")) {
|
||||
if(pref.contains("km")) {
|
||||
f *= 1000;
|
||||
}
|
||||
if (pref.contains("\"") || pref.contains("in")) {
|
||||
if(pref.contains("\"") || pref.contains("in")) {
|
||||
f *= 0.0254;
|
||||
} else if (pref.contains("\'") || pref.contains("ft") || pref.contains("feet")) {
|
||||
// foot to meters
|
||||
|
@ -712,27 +648,27 @@ public class RouteDataObject {
|
|||
return false;
|
||||
}
|
||||
|
||||
public boolean roundabout() {
|
||||
public boolean roundabout(){
|
||||
int sz = types.length;
|
||||
for (int i = 0; i < sz; i++) {
|
||||
for(int i=0; i<sz; i++) {
|
||||
RouteTypeRule r = region.quickGetEncodingRule(types[i]);
|
||||
if (r.roundabout()) {
|
||||
if(r.roundabout()) {
|
||||
return true;
|
||||
} else if (r.onewayDirection() != 0 && loop()) {
|
||||
} else if(r.onewayDirection() != 0 && loop()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean tunnel() {
|
||||
public boolean tunnel(){
|
||||
int sz = types.length;
|
||||
for (int i = 0; i < sz; i++) {
|
||||
for(int i=0; i<sz; 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;
|
||||
}
|
||||
if (r.getTag().equals("layer") && r.getValue().equals("-1")) {
|
||||
if(r.getTag().equals("layer") && r.getValue().equals("-1")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -921,7 +857,7 @@ public class RouteDataObject {
|
|||
|
||||
public boolean bearingVsRouteDirection(Location loc) {
|
||||
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);
|
||||
direction = Math.abs(diff) < Math.PI / 2f;
|
||||
}
|
||||
|
@ -971,13 +907,13 @@ public class RouteDataObject {
|
|||
}
|
||||
|
||||
public double distance(int startPoint, int endPoint) {
|
||||
if (startPoint > endPoint) {
|
||||
if(startPoint > endPoint) {
|
||||
int k = endPoint;
|
||||
endPoint = startPoint;
|
||||
startPoint = k;
|
||||
}
|
||||
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 y = getPoint31YTile(k);
|
||||
int kx = getPoint31XTile(k + 1);
|
||||
|
@ -1013,16 +949,16 @@ public class RouteDataObject {
|
|||
// translate into meters
|
||||
total += simplifyDistance(x, y, px, py);
|
||||
} 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) {
|
||||
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);
|
||||
if (exp != dest) {
|
||||
if(exp != dest) {
|
||||
System.err.println("FAIL " + vl + " " + dest);
|
||||
} else {
|
||||
System.out.println("OK " + vl);
|
||||
|
@ -1031,24 +967,24 @@ public class RouteDataObject {
|
|||
|
||||
public static void main(String[] args) {
|
||||
assertTrueLength("10 km", 10000);
|
||||
assertTrueLength("0.01 km", 10);
|
||||
assertTrueLength("0.01 km 10 m", 20);
|
||||
assertTrueLength("10 m", 10);
|
||||
assertTrueLength("10m", 10);
|
||||
assertTrueLength("3.4 m", 3.4f);
|
||||
assertTrueLength("3.40 m", 3.4f);
|
||||
assertTrueLength("10 m 10m", 20);
|
||||
assertTrueLength("14'10\"", 4.5212f);
|
||||
assertTrueLength("14.5'", 4.4196f);
|
||||
assertTrueLength("14.5 ft", 4.4196f);
|
||||
assertTrueLength("14'0\"", 4.2672f);
|
||||
assertTrueLength("15ft", 4.572f);
|
||||
assertTrueLength("15 ft 1 in", 4.5974f);
|
||||
assertTrueLength("4.1 metres", 4.1f);
|
||||
assertTrueLength("14'0''", 4.2672f);
|
||||
assertTrueLength("14 feet", 4.2672f);
|
||||
assertTrueLength("14 mile", 22530.76f);
|
||||
assertTrueLength("14 cm", 0.14f);
|
||||
assertTrueLength("0.01 km", 10);
|
||||
assertTrueLength("0.01 km 10 m", 20);
|
||||
assertTrueLength("10 m", 10);
|
||||
assertTrueLength("10m", 10);
|
||||
assertTrueLength("3.4 m", 3.4f);
|
||||
assertTrueLength("3.40 m", 3.4f);
|
||||
assertTrueLength("10 m 10m", 20);
|
||||
assertTrueLength("14'10\"", 4.5212f);
|
||||
assertTrueLength("14.5'", 4.4196f);
|
||||
assertTrueLength("14.5 ft", 4.4196f);
|
||||
assertTrueLength("14'0\"", 4.2672f);
|
||||
assertTrueLength("15ft", 4.572f);
|
||||
assertTrueLength("15 ft 1 in", 4.5974f);
|
||||
assertTrueLength("4.1 metres", 4.1f);
|
||||
assertTrueLength("14'0''", 4.2672f);
|
||||
assertTrueLength("14 feet", 4.2672f);
|
||||
assertTrueLength("14 mile", 22530.76f);
|
||||
assertTrueLength("14 cm", 0.14f);
|
||||
|
||||
// float badValue = -1;
|
||||
// assertTrueLength("none", badValue);
|
||||
|
@ -1093,7 +1029,7 @@ public class RouteDataObject {
|
|||
public RestrictionInfo next; // optional to simulate linked list
|
||||
|
||||
public int length() {
|
||||
if (next == null) {
|
||||
if(next == null) {
|
||||
return 1;
|
||||
}
|
||||
return next.length() + 1;
|
||||
|
@ -1103,19 +1039,21 @@ public class RouteDataObject {
|
|||
public void setRestriction(int k, long to, int type, long viaWay) {
|
||||
long valto = (to << RouteDataObject.RESTRICTION_SHIFT) | ((long) type & RouteDataObject.RESTRICTION_MASK);
|
||||
restrictions[k] = valto;
|
||||
if (viaWay != 0) {
|
||||
if(viaWay != 0) {
|
||||
setRestrictionVia(k, viaWay);
|
||||
}
|
||||
}
|
||||
|
||||
public void setRestrictionVia(int k, long viaWay) {
|
||||
if (restrictionsVia != null) {
|
||||
if(restrictionsVia != null) {
|
||||
long[] nrestrictionsVia = new long[Math.max(k + 1, restrictions.length)];
|
||||
System.arraycopy(restrictions, 0, nrestrictionsVia, 0, restrictions.length);
|
||||
restrictionsVia = nrestrictionsVia;
|
||||
restrictionsVia = nrestrictionsVia;
|
||||
} else {
|
||||
restrictionsVia = new long[k + 1];
|
||||
}
|
||||
restrictionsVia[k] = viaWay;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ public class StringBundle {
|
|||
private static final DecimalFormat FIVE_DIGITS_FORMATTER = new DecimalFormat("#.#####");
|
||||
private static final DecimalFormat SIX_DIGITS_FORMATTER = new DecimalFormat("#.######");
|
||||
|
||||
private Map<String, Item<?>> map = new LinkedHashMap<>();
|
||||
private Map<String, Item> map = new LinkedHashMap<>();
|
||||
|
||||
public enum ItemType {
|
||||
STRING,
|
||||
|
@ -32,7 +32,7 @@ public class StringBundle {
|
|||
public StringBundle() {
|
||||
}
|
||||
|
||||
protected StringBundle(Map<String, Item<?>> map) {
|
||||
protected StringBundle(Map<String, Item> map) {
|
||||
this.map = map;
|
||||
}
|
||||
|
||||
|
@ -156,16 +156,16 @@ public class StringBundle {
|
|||
}
|
||||
}
|
||||
|
||||
public static class StringListItem extends Item<List<Item<?>>> {
|
||||
public static class StringListItem extends Item<List<Item>> {
|
||||
|
||||
private StringListItem(String name, List<Item<?>> list) {
|
||||
private StringListItem(String name, List<Item> list) {
|
||||
super(name, ItemType.LIST, list);
|
||||
}
|
||||
}
|
||||
|
||||
public static class StringMapItem extends Item<Map<String, Item<?>>> {
|
||||
public static class StringMapItem extends Item<Map<String, Item>> {
|
||||
|
||||
private StringMapItem(String name, Map<String, Item<?>> map) {
|
||||
private StringMapItem(String name, Map<String, Item> map) {
|
||||
super(name, ItemType.MAP, map);
|
||||
}
|
||||
}
|
||||
|
@ -177,11 +177,11 @@ public class StringBundle {
|
|||
}
|
||||
}
|
||||
|
||||
public Map<String, Item<?>> getMap() {
|
||||
public Map<String, Item> getMap() {
|
||||
return Collections.unmodifiableMap(map);
|
||||
}
|
||||
|
||||
public Item<?> getItem(String key) {
|
||||
public Item getItem(String key) {
|
||||
return map.get(key);
|
||||
}
|
||||
|
||||
|
@ -190,7 +190,7 @@ public class StringBundle {
|
|||
}
|
||||
|
||||
public int getInt(String key, int defaultValue) {
|
||||
Item<?> item = map.get(key);
|
||||
Item item = map.get(key);
|
||||
return item instanceof StringItem ? ((StringItem) item).asInt(defaultValue) : defaultValue;
|
||||
}
|
||||
|
||||
|
@ -199,7 +199,7 @@ public class StringBundle {
|
|||
}
|
||||
|
||||
public long getLong(String key, long defaultValue) {
|
||||
Item<?> item = map.get(key);
|
||||
Item item = map.get(key);
|
||||
return item instanceof StringItem ? ((StringItem) item).asLong(defaultValue) : defaultValue;
|
||||
}
|
||||
|
||||
|
@ -212,7 +212,7 @@ public class StringBundle {
|
|||
}
|
||||
|
||||
public float getFloat(String key, float defaultValue) {
|
||||
Item<?> item = map.get(key);
|
||||
Item item = map.get(key);
|
||||
return item instanceof StringItem ? ((StringItem) item).asFloat(defaultValue) : defaultValue;
|
||||
}
|
||||
|
||||
|
@ -221,7 +221,7 @@ public class StringBundle {
|
|||
}
|
||||
|
||||
public boolean getBoolean(String key, boolean defaultValue) {
|
||||
Item<?> item = map.get(key);
|
||||
Item item = map.get(key);
|
||||
return item instanceof StringItem ? ((StringItem) item).asBoolean(defaultValue) : defaultValue;
|
||||
}
|
||||
|
||||
|
@ -232,13 +232,35 @@ public class StringBundle {
|
|||
}
|
||||
|
||||
public String getString(String key, String defaultValue) {
|
||||
Item<?> item = map.get(key);
|
||||
Item item = map.get(key);
|
||||
return item instanceof StringItem ? ((StringItem) item).getValue() : defaultValue;
|
||||
}
|
||||
|
||||
public void putObject(String key, StringExternalizable object) {
|
||||
if (object != null) {
|
||||
StringBundle bundle = newInstance();
|
||||
object.writeToBundle(bundle);
|
||||
map.put(key, new StringBundleItem(key, bundle));
|
||||
}
|
||||
}
|
||||
|
||||
public void putList(String key, String itemName, List<? extends StringExternalizable> list) {
|
||||
if (list != null) {
|
||||
List<Item> itemList = new ArrayList<>();
|
||||
for (StringExternalizable ex : list) {
|
||||
if (ex != null) {
|
||||
StringBundle bundle = newInstance();
|
||||
ex.writeToBundle(bundle);
|
||||
itemList.add(new StringBundleItem(itemName, bundle));
|
||||
}
|
||||
}
|
||||
map.put(key, new StringListItem(key, itemList));
|
||||
}
|
||||
}
|
||||
|
||||
public void putBundleList(String key, String itemName, List<StringBundle> list) {
|
||||
if (list != null) {
|
||||
List<Item<?>> itemList = new ArrayList<>();
|
||||
List<Item> itemList = new ArrayList<>();
|
||||
for (StringBundle bundle : list) {
|
||||
itemList.add(new StringBundleItem(itemName, bundle));
|
||||
}
|
||||
|
@ -257,7 +279,7 @@ public class StringBundle {
|
|||
}
|
||||
|
||||
public int[] getIntArray(String key, int[] defaultValue) {
|
||||
Item<?> item = map.get(key);
|
||||
Item item = map.get(key);
|
||||
return item instanceof StringItem ? ((StringItem) item).asIntArray(defaultValue) : defaultValue;
|
||||
}
|
||||
|
||||
|
@ -268,7 +290,7 @@ public class StringBundle {
|
|||
}
|
||||
|
||||
public int[][] getIntIntArray(String key, int[][] defaultValue) {
|
||||
Item<?> item = map.get(key);
|
||||
Item item = map.get(key);
|
||||
return item instanceof StringItem ? ((StringItem) item).asIntIntArray(defaultValue) : defaultValue;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,11 +16,11 @@ public abstract class StringBundleWriter {
|
|||
return bundle;
|
||||
}
|
||||
|
||||
protected abstract void writeItem(String name, Item<?> item);
|
||||
protected abstract void writeItem(String name, Item item);
|
||||
|
||||
public void writeBundle() {
|
||||
for (Entry<String, Item<?>> entry : bundle.getMap().entrySet()) {
|
||||
writeItem("osmand:" + entry.getKey(), entry.getValue());
|
||||
for (Entry<String, Item> entry : bundle.getMap().entrySet()) {
|
||||
writeItem(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ public class StringBundleXmlWriter extends StringBundleWriter {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void writeItem(String name, Item<?> item) {
|
||||
protected void writeItem(String name, Item item) {
|
||||
if (serializer != null) {
|
||||
try {
|
||||
writeItemImpl(name, item);
|
||||
|
@ -47,7 +47,7 @@ public class StringBundleXmlWriter extends StringBundleWriter {
|
|||
}
|
||||
}
|
||||
|
||||
private void writeItemImpl(String name, Item<?> item) throws IOException {
|
||||
private void writeItemImpl(String name, Item item) throws IOException {
|
||||
if (serializer != null && item != null) {
|
||||
switch (item.getType()) {
|
||||
case STRING: {
|
||||
|
@ -58,13 +58,13 @@ public class StringBundleXmlWriter extends StringBundleWriter {
|
|||
case LIST: {
|
||||
StringListItem listItem = (StringListItem) item;
|
||||
serializer.startTag(null, name);
|
||||
List<Item<?>> list = listItem.getValue();
|
||||
for (Item<?> i : list) {
|
||||
List<Item> list = listItem.getValue();
|
||||
for (Item i : list) {
|
||||
if (i.getType() == StringBundle.ItemType.STRING) {
|
||||
writeItemImpl(i.getName(), i);
|
||||
}
|
||||
}
|
||||
for (Item<?> i : list) {
|
||||
for (Item i : list) {
|
||||
if (i.getType() != StringBundle.ItemType.STRING) {
|
||||
writeItemImpl(i.getName(), i);
|
||||
}
|
||||
|
@ -75,14 +75,14 @@ public class StringBundleXmlWriter extends StringBundleWriter {
|
|||
case MAP: {
|
||||
StringMapItem mapItem = (StringMapItem) item;
|
||||
serializer.startTag(null, name);
|
||||
for (Entry<String, Item<?>> entry : mapItem.getValue().entrySet()) {
|
||||
Item<?> i = entry.getValue();
|
||||
for (Entry<String, Item> entry : mapItem.getValue().entrySet()) {
|
||||
Item i = entry.getValue();
|
||||
if (i.getType() == StringBundle.ItemType.STRING) {
|
||||
writeItemImpl(entry.getKey(), i);
|
||||
}
|
||||
}
|
||||
for (Entry<String, Item<?>> entry : mapItem.getValue().entrySet()) {
|
||||
Item<?> i = entry.getValue();
|
||||
for (Entry<String, Item> entry : mapItem.getValue().entrySet()) {
|
||||
Item i = entry.getValue();
|
||||
if (i.getType() != StringBundle.ItemType.STRING) {
|
||||
writeItemImpl(entry.getKey(), i);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,17 @@
|
|||
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.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
@ -11,14 +21,9 @@ import java.util.Map;
|
|||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
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 {
|
||||
|
@ -33,23 +38,10 @@ public class Amenity extends MapObject {
|
|||
public static final String COLLECTION_TIMES = "collection_times";
|
||||
public static final String CONTENT = "content";
|
||||
public static final String CUISINE = "cuisine";
|
||||
public static final String WIKIDATA = "wikidata";
|
||||
public static final String WIKIMEDIA_COMMONS = "wikimedia_commons";
|
||||
public static final String DISH = "dish";
|
||||
public static final String REF = "ref";
|
||||
public static final String OSM_DELETE_VALUE = "delete";
|
||||
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 PoiCategory type;
|
||||
|
@ -101,47 +93,40 @@ public class Amenity extends MapObject {
|
|||
return str;
|
||||
}
|
||||
|
||||
public String unzipContent(String str) {
|
||||
if (str != null) {
|
||||
if (str.startsWith(" gz ")) {
|
||||
try {
|
||||
int ind = 4;
|
||||
byte[] bytes = new byte[str.length() - ind];
|
||||
for (int i = ind; i < str.length(); i++) {
|
||||
char ch = str.charAt(i);
|
||||
bytes[i - ind] = (byte) ((int) ch - 128 - 32);
|
||||
|
||||
// this method should be used carefully
|
||||
public Map<String, String> getInternalAdditionalInfoMap() {
|
||||
}
|
||||
GZIPInputStream gzn = new GZIPInputStream(new ByteArrayInputStream(bytes));
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(gzn, "UTF-8"));
|
||||
StringBuilder bld = new StringBuilder();
|
||||
String s;
|
||||
while ((s = br.readLine()) != null) {
|
||||
bld.append(s);
|
||||
}
|
||||
br.close();
|
||||
str = bld.toString();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
public Map<String, String> getAdditionalInfo() {
|
||||
if (additionalInfo == null) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
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) {
|
||||
this.additionalInfo = null;
|
||||
|
@ -174,7 +159,7 @@ public class Amenity extends MapObject {
|
|||
}
|
||||
this.additionalInfo.put(tag, value);
|
||||
if (OPENING_HOURS.equals(tag)) {
|
||||
this.openingHours = unzipContent(value);
|
||||
this.openingHours = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -205,15 +190,6 @@ public class Amenity extends MapObject {
|
|||
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) {
|
||||
if (lang != null) {
|
||||
String translateName = getAdditionalInfo(tag + ":" + lang);
|
||||
|
@ -231,7 +207,7 @@ public class Amenity extends MapObject {
|
|||
}
|
||||
int maxLen = 0;
|
||||
String lng = defLang;
|
||||
for (String nm : getAdditionalInfoKeys()) {
|
||||
for (String nm : getAdditionalInfo().keySet()) {
|
||||
if (nm.startsWith(tag + ":")) {
|
||||
String key = nm.substring(tag.length() + 1);
|
||||
String cnt = getAdditionalInfo(tag + ":" + key);
|
||||
|
@ -253,7 +229,7 @@ public class Amenity extends MapObject {
|
|||
|
||||
public List<String> getNames(String tag, String defTag) {
|
||||
List<String> l = new ArrayList<String>();
|
||||
for (String nm : getAdditionalInfoKeys()) {
|
||||
for (String nm : getAdditionalInfo().keySet()) {
|
||||
if (nm.startsWith(tag + ":")) {
|
||||
l.add(nm.substring(tag.length() + 1));
|
||||
} else if (nm.equals(tag)) {
|
||||
|
@ -263,35 +239,7 @@ public class Amenity extends MapObject {
|
|||
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) {
|
||||
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) {
|
||||
String translateName = getAdditionalInfo(tag + ":" + lang);
|
||||
if (!Algorithms.isEmpty(translateName)) {
|
||||
|
@ -306,6 +254,11 @@ public class Amenity extends MapObject {
|
|||
if (!Algorithms.isEmpty(enName)) {
|
||||
return enName;
|
||||
}
|
||||
for (String nm : getAdditionalInfo().keySet()) {
|
||||
if (nm.startsWith(tag + ":")) {
|
||||
return getAdditionalInfo(nm);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -417,4 +370,4 @@ public class Amenity extends MapObject {
|
|||
}
|
||||
return a;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -106,42 +106,25 @@ public class Building extends MapObject {
|
|||
|
||||
|
||||
public float interpolation(String hno) {
|
||||
if (getInterpolationType() != null || getInterpolationInterval() > 0
|
||||
// || checkNameAsInterpolation() // disable due to situation in NL #4284
|
||||
) {
|
||||
if(getInterpolationType() != null || getInterpolationInterval() > 0
|
||||
//|| checkNameAsInterpolation() // disable due to situation in NL #4284
|
||||
) {
|
||||
int num = Algorithms.extractFirstIntegerNumber(hno);
|
||||
String fname = super.getName();
|
||||
int numB = Algorithms.extractFirstIntegerNumber(fname);
|
||||
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;
|
||||
}
|
||||
int numT = numB;
|
||||
if (num >= numB) {
|
||||
if (fname.contains("-") && sname == null) {
|
||||
String sname = getName2();
|
||||
if(fname.contains("-") && sname == null){
|
||||
int l = fname.indexOf('-');
|
||||
sname = fname.substring(l + 1, fname.length());
|
||||
}
|
||||
if (sname != null) {
|
||||
numT = Algorithms.extractFirstIntegerNumber(sname);
|
||||
if (numT < num) {
|
||||
if(numT < num) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (getInterpolationType() == BuildingInterpolation.EVEN && num % 2 == 1) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -154,8 +137,8 @@ public class Building extends MapObject {
|
|||
} else {
|
||||
return -1;
|
||||
}
|
||||
if (numT > numB) {
|
||||
return ((float) num - numB) / (((float) numT - numB));
|
||||
if(numT > numB){
|
||||
return ((float)num - numB) / (((float)numT - numB));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -182,10 +165,10 @@ public class Building extends MapObject {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (interpolationInterval != 0) {
|
||||
return name + "-" + name2 + " (+" + interpolationInterval + ") ";
|
||||
} else if (interpolationType != null) {
|
||||
return name + "-" + name2 + " (" + interpolationType + ") ";
|
||||
if(interpolationInterval !=0){
|
||||
return name+"-"+name2 +" (+"+interpolationInterval+") ";
|
||||
} else if(interpolationType != null) {
|
||||
return name+"-"+name2 +" ("+interpolationType+") ";
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
|
|
@ -24,10 +24,6 @@ public class City extends MapObject {
|
|||
public double getRadius() {
|
||||
return radius;
|
||||
}
|
||||
|
||||
public boolean storedAsSeparateAdminEntity() {
|
||||
return this != DISTRICT && this != NEIGHBOURHOOD && this != BOROUGH;
|
||||
}
|
||||
|
||||
public static String valueToString(CityType t) {
|
||||
return t.toString().toLowerCase();
|
||||
|
|
|
@ -13,11 +13,7 @@ public class IncompleteTransportRoute {
|
|||
}
|
||||
|
||||
public void setNextLinkedRoute(IncompleteTransportRoute nextLinkedRoute) {
|
||||
if (this.nextLinkedRoute == null) {
|
||||
this.nextLinkedRoute = nextLinkedRoute;
|
||||
} else {
|
||||
this.nextLinkedRoute.setNextLinkedRoute(nextLinkedRoute);
|
||||
}
|
||||
this.nextLinkedRoute = nextLinkedRoute;
|
||||
}
|
||||
|
||||
public long getRouteId() {
|
||||
|
|
|
@ -8,11 +8,8 @@ import net.osmand.util.TransliterationHelper;
|
|||
|
||||
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.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
|
@ -21,7 +18,6 @@ import java.util.List;
|
|||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
|
||||
public abstract class MapObject implements Comparable<MapObject> {
|
||||
|
@ -59,7 +55,7 @@ public abstract class MapObject implements Comparable<MapObject> {
|
|||
|
||||
public String getName() {
|
||||
if (name != null) {
|
||||
return unzipContent(name);
|
||||
return name;
|
||||
}
|
||||
return ""; //$NON-NLS-1$
|
||||
}
|
||||
|
@ -77,7 +73,7 @@ public abstract class MapObject implements Comparable<MapObject> {
|
|||
if (names == null) {
|
||||
names = new HashMap<String, String>();
|
||||
}
|
||||
names.put(lang, unzipContent(name));
|
||||
names.put(lang, name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -89,34 +85,29 @@ public abstract class MapObject implements Comparable<MapObject> {
|
|||
names.putAll(name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Map<String, String> getNamesMap(boolean includeEn) {
|
||||
if ((!includeEn || Algorithms.isEmpty(enName)) && names == null) {
|
||||
return Collections.emptyMap();
|
||||
if (!includeEn || Algorithms.isEmpty(enName)) {
|
||||
if (names == null) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
return names;
|
||||
}
|
||||
Map<String, String> mp = new HashMap<String, String>();
|
||||
if (names != null) {
|
||||
Iterator<Entry<String, String>> it = names.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
Entry<String, String> e = it.next();
|
||||
mp.put(e.getKey(), unzipContent(e.getValue()));
|
||||
}
|
||||
}
|
||||
if (includeEn && !Algorithms.isEmpty(enName)) {
|
||||
mp.put("en", unzipContent(enName));
|
||||
mp.putAll(names);
|
||||
}
|
||||
mp.put("en", enName);
|
||||
return mp;
|
||||
}
|
||||
|
||||
public List<String> getAllNames() {
|
||||
List<String> l = new ArrayList<String>();
|
||||
if (!Algorithms.isEmpty(enName)) {
|
||||
l.add(unzipContent(enName));
|
||||
l.add(enName);
|
||||
}
|
||||
if (names != null) {
|
||||
for (String nm : names.values()) {
|
||||
l.add(unzipContent(nm));
|
||||
}
|
||||
l.addAll(names.values());
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
@ -181,15 +172,14 @@ public abstract class MapObject implements Comparable<MapObject> {
|
|||
public String getName(String lang, boolean transliterate) {
|
||||
if (lang != null && lang.length() > 0) {
|
||||
if (lang.equals("en")) {
|
||||
// for some objects like wikipedia, english name is stored 'name' tag
|
||||
String enName = getEnName(transliterate);
|
||||
return !Algorithms.isEmpty(enName) ? enName : getName();
|
||||
// ignore transliterate option here for backward compatibility
|
||||
return getEnName(true);
|
||||
} else {
|
||||
// get name
|
||||
if (names != null) {
|
||||
String nm = names.get(lang);
|
||||
if (!Algorithms.isEmpty(nm)) {
|
||||
return unzipContent(nm);
|
||||
return nm;
|
||||
}
|
||||
if (transliterate) {
|
||||
return TransliterationHelper.transliterate(getName());
|
||||
|
@ -202,7 +192,7 @@ public abstract class MapObject implements Comparable<MapObject> {
|
|||
|
||||
public String getEnName(boolean transliterate) {
|
||||
if (!Algorithms.isEmpty(enName)) {
|
||||
return unzipContent(this.enName);
|
||||
return this.enName;
|
||||
} else if (!Algorithms.isEmpty(getName()) && transliterate) {
|
||||
return TransliterationHelper.transliterate(getName());
|
||||
}
|
||||
|
@ -332,12 +322,12 @@ public abstract class MapObject implements Comparable<MapObject> {
|
|||
|
||||
public JSONObject toJSON() {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("name", unzipContent(name));
|
||||
json.put("enName", unzipContent(enName));
|
||||
json.put("name", name);
|
||||
json.put("enName", enName);
|
||||
if (names != null && names.size() > 0) {
|
||||
JSONObject namesObj = new JSONObject();
|
||||
for (Entry<String, String> e : names.entrySet()) {
|
||||
namesObj.put(e.getKey(), unzipContent(e.getValue()));
|
||||
namesObj.put(e.getKey(), e.getValue());
|
||||
}
|
||||
json.put("names", namesObj);
|
||||
}
|
||||
|
@ -349,39 +339,6 @@ public abstract class MapObject implements Comparable<MapObject> {
|
|||
|
||||
return json;
|
||||
}
|
||||
|
||||
String unzipContent(String str) {
|
||||
if (isContentZipped(str)) {
|
||||
try {
|
||||
int ind = 4;
|
||||
byte[] bytes = new byte[str.length() - ind];
|
||||
for (int i = ind; i < str.length(); i++) {
|
||||
char ch = str.charAt(i);
|
||||
bytes[i - ind] = (byte) ((int) ch - 128 - 32);
|
||||
}
|
||||
GZIPInputStream gzn = new GZIPInputStream(new ByteArrayInputStream(bytes));
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(gzn, "UTF-8"));
|
||||
StringBuilder bld = new StringBuilder();
|
||||
String s;
|
||||
while ((s = br.readLine()) != null) {
|
||||
bld.append(s);
|
||||
}
|
||||
br.close();
|
||||
str = bld.toString();
|
||||
// ugly fix of temporary problem of map generation
|
||||
if(isContentZipped(str)) {
|
||||
str = unzipContent(str);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
boolean isContentZipped(String str) {
|
||||
return str != null && str.startsWith(" gz ");
|
||||
}
|
||||
|
||||
protected static void parseJSON(JSONObject json, MapObject o) {
|
||||
if (json.has("name")) {
|
||||
|
|
|
@ -61,9 +61,9 @@ public class Multipolygon {
|
|||
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() {
|
||||
|
@ -163,7 +163,9 @@ public class Multipolygon {
|
|||
* @return true if this multipolygon is correct and contains the point
|
||||
*/
|
||||
public boolean containsPoint(LatLon point) {
|
||||
|
||||
return containsPoint(point.getLatitude(), point.getLongitude());
|
||||
|
||||
}
|
||||
|
||||
public int countOuterPolygons() {
|
||||
|
|
|
@ -6,7 +6,6 @@ public class QuadRect {
|
|||
public double top;
|
||||
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) {
|
||||
this.left = left;
|
||||
this.right = right;
|
||||
|
@ -22,18 +21,16 @@ public class QuadRect {
|
|||
}
|
||||
|
||||
public double width() {
|
||||
return Math.abs(right - left);
|
||||
return right - left;
|
||||
}
|
||||
|
||||
public double height() {
|
||||
return Math.abs(bottom - top);
|
||||
return bottom - top;
|
||||
}
|
||||
|
||||
public boolean contains(double left, double top, double right, double bottom) {
|
||||
return Math.min(this.left, this.right) <= Math.min(left, right)
|
||||
&& Math.max(this.left, this.right) >= Math.max(left, right)
|
||||
&& Math.min(this.top, this.bottom) <= Math.min(top, bottom)
|
||||
&& Math.max(this.top, this.bottom) >= Math.max(top, bottom);
|
||||
return this.left < this.right && this.top < this.bottom && this.left <= left && this.top <= top && this.right >= right
|
||||
&& this.bottom >= bottom;
|
||||
}
|
||||
|
||||
public boolean contains(QuadRect box) {
|
||||
|
@ -41,15 +38,12 @@ public class QuadRect {
|
|||
}
|
||||
|
||||
public static boolean intersects(QuadRect a, QuadRect b) {
|
||||
return Math.min(a.left, a.right) <= Math.max(b.left, b.right)
|
||||
&& 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);
|
||||
return a.left < b.right && b.left < a.right && a.top < b.bottom && b.top < a.bottom;
|
||||
}
|
||||
|
||||
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() {
|
||||
return (left + right) / 2;
|
||||
|
|
|
@ -103,16 +103,18 @@ public class QuadTree<T> {
|
|||
void splitBox(QuadRect node_extent, QuadRect[] n) {
|
||||
// coord2d c=node_extent.center();
|
||||
|
||||
double width = node_extent.width();
|
||||
double height = node_extent.height();
|
||||
|
||||
double lx = node_extent.left;
|
||||
double ly = node_extent.top;
|
||||
double hx = node_extent.right;
|
||||
double hy = node_extent.bottom;
|
||||
double lox = node_extent.left;
|
||||
double loy = node_extent.top;
|
||||
double hix = node_extent.right;
|
||||
double hiy = node_extent.bottom;
|
||||
|
||||
n[0] = new QuadRect(lx, ly, lx + (hx - lx) * ratio, ly + (hy - ly) * ratio);
|
||||
n[1] = new QuadRect(lx + (hx - lx) * (1 - ratio), ly, hx, ly + (hy - ly) * ratio);
|
||||
n[2] = new QuadRect(lx, ly + (hy - ly) * (1 - ratio), lx + (hx - lx) * ratio, hy);
|
||||
n[3] = new QuadRect(lx + (hx - lx) * (1 - ratio), ly + (hy - ly) * (1 - ratio), hx, hy);
|
||||
n[0] = new QuadRect(lox, loy, lox + width * ratio, loy + height * ratio);
|
||||
n[1] = new QuadRect(hix - width * ratio, loy, hix, loy + height * ratio);
|
||||
n[2] = new QuadRect(lox, hiy - height * ratio, lox + width * ratio, hiy);
|
||||
n[3] = new QuadRect(hix - width * ratio, hiy - height * ratio, hix, hiy);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -32,8 +32,6 @@ public interface ITileSource {
|
|||
|
||||
public String getReferer();
|
||||
|
||||
public String getUserAgent();
|
||||
|
||||
public void deleteTiles(String path);
|
||||
|
||||
public int getAvgSize();
|
||||
|
|
|
@ -7,6 +7,7 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -90,7 +91,6 @@ public class MapTileDownloader {
|
|||
public final int yTile;
|
||||
public String url;
|
||||
public String referer = null;
|
||||
public String userAgent = null;
|
||||
public boolean error;
|
||||
|
||||
public DownloadRequest(String url, File fileToSave, int xTile, int yTile, int zoom) {
|
||||
|
@ -267,7 +267,7 @@ public class MapTileDownloader {
|
|||
request.setError(false);
|
||||
try {
|
||||
URLConnection connection = NetworkUtils.getHttpURLConnection(request.url);
|
||||
connection.setRequestProperty("User-Agent", Algorithms.isEmpty(request.userAgent) ? USER_AGENT : request.userAgent); //$NON-NLS-1$
|
||||
connection.setRequestProperty("User-Agent", USER_AGENT); //$NON-NLS-1$
|
||||
if (request.referer != null)
|
||||
connection.setRequestProperty("Referer", request.referer); //$NON-NLS-1$
|
||||
connection.setConnectTimeout(CONNECTION_TIMEOUT);
|
||||
|
|
|
@ -436,7 +436,6 @@ public class OsmandRegions {
|
|||
cx /= object.getPointsLength();
|
||||
cy /= object.getPointsLength();
|
||||
rd.regionCenter = new LatLon(MapUtils.get31LatitudeY((int) cy), MapUtils.get31LongitudeX((int) cx));
|
||||
findBoundaries(rd, object);
|
||||
}
|
||||
|
||||
rd.regionParentFullName = mapIndexFields.get(mapIndexFields.parentFullName, object);
|
||||
|
@ -462,47 +461,6 @@ public class OsmandRegions {
|
|||
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) {
|
||||
MapIndex mi = object.getMapIndex();
|
||||
TIntObjectIterator<String> it = object.getObjectNames().iterator();
|
||||
|
|
|
@ -68,7 +68,6 @@ public class TileSourceManager {
|
|||
private String[] randomsArray;
|
||||
private String rule;
|
||||
private String referer;
|
||||
private String userAgent;
|
||||
private boolean hidden; // if hidden in configure map settings, for example mapillary sources
|
||||
|
||||
private boolean isRuleAcceptable = true;
|
||||
|
@ -140,7 +139,7 @@ public class TileSourceManager {
|
|||
}
|
||||
}
|
||||
}
|
||||
return randoms.toArray(new String[0]);
|
||||
return randoms.toArray(new String[randoms.size()]);
|
||||
}
|
||||
|
||||
public void setMinZoom(int minZoom) {
|
||||
|
@ -262,14 +261,6 @@ public class TileSourceManager {
|
|||
this.referer = referer;
|
||||
}
|
||||
|
||||
public String getUserAgent() {
|
||||
return userAgent;
|
||||
}
|
||||
|
||||
public void setUserAgent(String userAgent) {
|
||||
this.userAgent = userAgent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTileSize() {
|
||||
return tileSize;
|
||||
|
@ -493,9 +484,6 @@ public class TileSourceManager {
|
|||
if (!Algorithms.isEmpty(tm.getReferer())) {
|
||||
properties.put("referer", tm.getReferer());
|
||||
}
|
||||
if (!Algorithms.isEmpty(tm.getUserAgent())) {
|
||||
properties.put("user_agent", tm.getUserAgent());
|
||||
}
|
||||
|
||||
properties.put("ext", tm.getTileFormat());
|
||||
properties.put("min_zoom", tm.getMinimumZoomSupported() + "");
|
||||
|
@ -518,8 +506,8 @@ public class TileSourceManager {
|
|||
}
|
||||
if (override || !metainfo.exists()) {
|
||||
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(metainfo)));
|
||||
for (Map.Entry<String, String> entry : properties.entrySet()) {
|
||||
writer.write("[" + entry.getKey() + "]\n" + entry.getValue() + "\n");
|
||||
for (String key : properties.keySet()) {
|
||||
writer.write("[" + key + "]\n" + properties.get(key) + "\n");
|
||||
}
|
||||
writer.close();
|
||||
}
|
||||
|
@ -720,12 +708,6 @@ public class TileSourceManager {
|
|||
}
|
||||
String randoms = attributes.get("randoms");
|
||||
TileSourceTemplate templ = new TileSourceTemplate(name, urlTemplate, ext, maxZoom, minZoom, tileSize, bitDensity, avgTileSize);
|
||||
if (attributes.get("referer") != null) {
|
||||
templ.setReferer(attributes.get("referer"));
|
||||
}
|
||||
if (attributes.get("user_agent") != null) {
|
||||
templ.setUserAgent(attributes.get("user_agent"));
|
||||
}
|
||||
if(expirationTime >= 0) {
|
||||
templ.setExpirationTimeMinutes(expirationTime);
|
||||
}
|
||||
|
|
|
@ -1,15 +1,11 @@
|
|||
package net.osmand.map;
|
||||
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.QuadRect;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class WorldRegion implements Serializable {
|
||||
|
||||
|
@ -44,8 +40,6 @@ public class WorldRegion implements Serializable {
|
|||
protected String regionDownloadName;
|
||||
protected boolean regionMapDownload;
|
||||
protected LatLon regionCenter;
|
||||
protected QuadRect boundingBox;
|
||||
protected List<LatLon> polygon;
|
||||
|
||||
public static class RegionParams {
|
||||
protected String regionLeftHandDriving;
|
||||
|
@ -80,12 +74,12 @@ public class WorldRegion implements Serializable {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public boolean isRegionMapDownload() {
|
||||
return regionMapDownload;
|
||||
}
|
||||
|
||||
|
||||
public String getLocaleName() {
|
||||
if(!Algorithms.isEmpty(regionNameLocale)) {
|
||||
return regionNameLocale;
|
||||
|
@ -96,14 +90,14 @@ public class WorldRegion implements Serializable {
|
|||
if(!Algorithms.isEmpty(regionName)) {
|
||||
return regionName;
|
||||
}
|
||||
|
||||
|
||||
return capitalize(regionFullName.replace('_', ' '));
|
||||
}
|
||||
|
||||
|
||||
public String getRegionDownloadName() {
|
||||
return regionDownloadName;
|
||||
}
|
||||
|
||||
|
||||
public String getRegionDownloadNameLC() {
|
||||
return regionDownloadName == null ? null : regionDownloadName.toLowerCase();
|
||||
}
|
||||
|
@ -115,7 +109,7 @@ public class WorldRegion implements Serializable {
|
|||
public LatLon getRegionCenter() {
|
||||
return regionCenter;
|
||||
}
|
||||
|
||||
|
||||
public String getRegionSearchText() {
|
||||
return regionSearchText;
|
||||
}
|
||||
|
@ -149,7 +143,7 @@ public class WorldRegion implements Serializable {
|
|||
this.regionDownloadName = downloadName;
|
||||
superregion = null;
|
||||
subregions = new LinkedList<WorldRegion>();
|
||||
|
||||
|
||||
}
|
||||
public WorldRegion(String id) {
|
||||
this(id, null);
|
||||
|
@ -158,7 +152,7 @@ public class WorldRegion implements Serializable {
|
|||
public String getRegionId() {
|
||||
return regionFullName;
|
||||
}
|
||||
|
||||
|
||||
private String capitalize(String s) {
|
||||
String[] words = s.split(" ");
|
||||
if (words[0].length() > 0) {
|
||||
|
@ -188,49 +182,4 @@ public class WorldRegion implements Serializable {
|
|||
}
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -67,6 +67,7 @@ public abstract class AbstractPoiType {
|
|||
return this instanceof PoiType && this.isAdditional();
|
||||
}
|
||||
|
||||
|
||||
public String getTranslation() {
|
||||
if(translation == null) {
|
||||
translation = registry.getTranslation(this);
|
||||
|
|
|
@ -17,7 +17,6 @@ import java.util.ArrayList;
|
|||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
|
@ -35,14 +34,12 @@ public class MapPoiTypes {
|
|||
private static final Log log = PlatformUtil.getLog(MapRenderingTypes.class);
|
||||
private String resourceName;
|
||||
private List<PoiCategory> categories = new ArrayList<PoiCategory>();
|
||||
private Set<String> forbiddenTypes = new HashSet<>();
|
||||
private PoiCategory otherCategory;
|
||||
private PoiCategory otherMapCategory;
|
||||
|
||||
public static final String WIKI_LANG = "wiki_lang";
|
||||
public static final String WIKI_PLACE = "wiki_place";
|
||||
public static final String OSM_WIKI_CATEGORY = "osmwiki";
|
||||
public static final String SPEED_CAMERA = "speed_camera";
|
||||
|
||||
private PoiTranslator poiTranslator = null;
|
||||
private boolean init;
|
||||
|
@ -658,8 +655,6 @@ public class MapPoiTypes {
|
|||
tp.setOsmValue(parser.getAttributeValue("", "value"));
|
||||
tp.setOsmEditTagValue(parser.getAttributeValue("", "edit_tag"),
|
||||
parser.getAttributeValue("", "edit_value"));
|
||||
tp.setOsmEditTagValue2(parser.getAttributeValue("", "edit_tag2"),
|
||||
parser.getAttributeValue("", "edit_value2"));
|
||||
|
||||
tp.setOsmTag2(parser.getAttributeValue("", "tag2"));
|
||||
tp.setOsmValue2(parser.getAttributeValue("", "value2"));
|
||||
|
@ -825,7 +820,7 @@ public class MapPoiTypes {
|
|||
}
|
||||
String name = keyName;
|
||||
name = name.replace('_', ' ');
|
||||
return Algorithms.capitalizeFirstLetter(name);
|
||||
return Algorithms.capitalizeFirstLetterAndLowercase(name);
|
||||
}
|
||||
|
||||
public boolean isRegisteredType(PoiCategory t) {
|
||||
|
@ -950,12 +945,4 @@ public class MapPoiTypes {
|
|||
return pat.isText();
|
||||
}
|
||||
}
|
||||
|
||||
public void setForbiddenTypes(Set<String> forbiddenTypes) {
|
||||
this.forbiddenTypes = forbiddenTypes;
|
||||
}
|
||||
|
||||
public boolean isTypeForbidden(String typeName) {
|
||||
return forbiddenTypes.contains(typeName);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import java.io.FileInputStream;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
@ -27,7 +26,7 @@ public abstract class MapRenderingTypes {
|
|||
|
||||
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",
|
||||
"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;
|
||||
|
@ -96,9 +95,8 @@ public abstract class MapRenderingTypes {
|
|||
Map<String, String> common = new HashMap<String, String>();
|
||||
String ATTACHED_KEY = "seamark:attached";
|
||||
String type = "";
|
||||
for (Entry<String, String> entry : tags.entrySet()) {
|
||||
String s = entry.getKey();
|
||||
String value = entry.getValue();
|
||||
for (String s : tags.keySet()) {
|
||||
String value = tags.get(s);
|
||||
if (s.equals("seamark:type")) {
|
||||
type = value;
|
||||
common.put(ATTACHED_KEY, openSeaType(value));
|
||||
|
@ -155,34 +153,6 @@ public abstract class MapRenderingTypes {
|
|||
return a;
|
||||
}
|
||||
|
||||
protected MapRulType checkOrCreateTextRule(String targetTag, MapRulType ref) {
|
||||
MapRulType mt = types.get(constructRuleKey(targetTag, null));
|
||||
if (mt == null) {
|
||||
MapRulType ct = MapRulType.createText(targetTag, ref);
|
||||
mt = registerRuleType(ct);
|
||||
}
|
||||
return mt;
|
||||
}
|
||||
|
||||
protected MapRulType checkOrMainRule(String tag, String value, int minzoom) {
|
||||
MapRulType mt = types.get(constructRuleKey(tag, value));
|
||||
if (mt == null) {
|
||||
mt = registerRuleType(MapRulType.createMainEntity(tag, value));
|
||||
mt.minzoom = minzoom;
|
||||
mt.maxzoom = 21;
|
||||
}
|
||||
return mt;
|
||||
}
|
||||
|
||||
protected MapRulType checkOrCreateAdditional(String tag, String value, MapRulType ref) {
|
||||
MapRulType mt = types.get(constructRuleKey(tag, value));
|
||||
if (mt == null) {
|
||||
MapRulType ct = MapRulType.createAdditional(tag, value, ref);
|
||||
mt = registerRuleType(ct);
|
||||
}
|
||||
return mt;
|
||||
}
|
||||
|
||||
protected MapRulType getRuleType(String tag, String val, boolean poi, boolean map) {
|
||||
Map<String, MapRulType> types = getEncodingRuleTypes();
|
||||
tag = lc(tag);
|
||||
|
@ -201,6 +171,7 @@ public abstract class MapRenderingTypes {
|
|||
rType.map = parent.map;
|
||||
rType.poi = parent.poi;
|
||||
rType.onlyPoint = parent.onlyPoint;
|
||||
rType.namePrefix = parent.namePrefix;
|
||||
rType = registerRuleType(rType);
|
||||
}
|
||||
return rType;
|
||||
|
@ -294,112 +265,37 @@ public abstract class MapRenderingTypes {
|
|||
rtype.onlyPoint = Boolean.parseBoolean(parser.getAttributeValue("", "point")); //$NON-NLS-1$
|
||||
rtype.relation = Boolean.parseBoolean(parser.getAttributeValue("", "relation")); //$NON-NLS-1$
|
||||
rtype.relationGroup = Boolean.parseBoolean(parser.getAttributeValue("", "relationGroup")); //$NON-NLS-1$
|
||||
if (rtype.isMain()) {
|
||||
if (rtype.relationGroup) {
|
||||
MapRulType mrt = MapRulType.createMainEntity(tag + "_" + value, null);
|
||||
mrt.order = rtype.order;
|
||||
mrt.category = rtype.category;
|
||||
mrt.poi = rtype.poi;
|
||||
mrt.map = rtype.map;
|
||||
registerMapRule(parser, mrt);
|
||||
if (rtype.isMain()) {
|
||||
rtype.namePrefix = parser.getAttributeValue("", "namePrefix"); //$NON-NLS-1$
|
||||
if (rtype.namePrefix == null) {
|
||||
rtype.namePrefix = "";
|
||||
}
|
||||
|
||||
String groupSort = parser.getAttributeValue("", "relationGroupSort");
|
||||
if (groupSort != null) {
|
||||
rtype.relationSortTags = new LinkedHashMap<String, List<String>>();
|
||||
String[] ls = groupSort.split(";");
|
||||
for(String l : ls) {
|
||||
int sp = l.indexOf('=');
|
||||
String key = l;
|
||||
String[] values = new String[0];
|
||||
if(sp >= 0) {
|
||||
key = l.substring(0, sp);
|
||||
values = l.substring(sp +1).split(",");
|
||||
|
||||
String v = parser.getAttributeValue("", "nameTags");
|
||||
if (v != null) {
|
||||
String[] names = v.split(",");
|
||||
rtype.names = new MapRulType[names.length * (langs.length + 1)];
|
||||
int j = 0;
|
||||
for (int i = 0; i < names.length; i++) {
|
||||
String tagName = names[i];
|
||||
if (rtype.namePrefix.length() > 0) {
|
||||
tagName = rtype.namePrefix + tagName;
|
||||
}
|
||||
rtype.relationSortTags.put(key, Arrays.asList(values));
|
||||
}
|
||||
}
|
||||
|
||||
String additionalTags = parser.getAttributeValue("", "additionalTags");
|
||||
String additionalPrefix = parser.getAttributeValue("", "additionalPrefix");
|
||||
if (additionalTags != null) {
|
||||
rtype.additionalTags = new LinkedHashMap<String, String>();
|
||||
for(String tg : additionalTags.split(",")) {
|
||||
String targetTag = tg;
|
||||
if(!Algorithms.isEmpty(additionalPrefix)) {
|
||||
targetTag = additionalPrefix + tg;
|
||||
}
|
||||
rtype.additionalTags.put(tg, targetTag);
|
||||
}
|
||||
}
|
||||
rtype.relationGroupPrefix = parser.getAttributeValue("", "relationGroupPrefix"); //$NON-NLS-1$
|
||||
String relationGroupAdditionalTags = parser.getAttributeValue("", "relationGroupAdditionalTags");
|
||||
if (relationGroupAdditionalTags != null) {
|
||||
rtype.relationGroupAdditionalTags = new LinkedHashMap<String, String>();
|
||||
for(String tg : relationGroupAdditionalTags.split(",")) {
|
||||
rtype.relationGroupAdditionalTags.put(tg, tg);
|
||||
}
|
||||
}
|
||||
|
||||
String nmts = parser.getAttributeValue("", "nameTags");
|
||||
if (nmts != null) {
|
||||
if (rtype.relation || rtype.relationGroup) {
|
||||
String namePrefix = parser.getAttributeValue("", "namePrefix"); //$NON-NLS-1$
|
||||
if (namePrefix == null) {
|
||||
namePrefix = "";
|
||||
}
|
||||
rtype.relationNames = new LinkedHashMap<String, String>();
|
||||
putNameTags(nmts, rtype.relationNames, namePrefix);
|
||||
} else {
|
||||
String[] nameSplit = nmts.split(",");
|
||||
for (String nameTag : nameSplit) {
|
||||
checkOrCreateTextRule(nameTag, null);
|
||||
MapRulType mt = MapRulType.createText(tagName);
|
||||
mt = registerRuleType(mt);
|
||||
rtype.names[j++] = mt;
|
||||
for(String lng : langs) {
|
||||
mt = MapRulType.createText(tagName + ":" + lng);
|
||||
mt = registerRuleType(mt);
|
||||
rtype.names[j++] = mt;
|
||||
}
|
||||
}
|
||||
}
|
||||
String rnmts = parser.getAttributeValue("", "relationGroupNameTags");
|
||||
if (rnmts != null) {
|
||||
rtype.relationGroupNameTags = new LinkedHashMap<String, String>();
|
||||
putNameTags(rnmts, rtype.relationGroupNameTags, "");
|
||||
}
|
||||
}
|
||||
return rtype;
|
||||
|
||||
}
|
||||
|
||||
private void putNameTags(String namesList, Map<String, String> names, String namePrefix) {
|
||||
if (namesList != null) {
|
||||
String[] nameSplit = namesList.split(",");
|
||||
for (int i = 0; i < nameSplit.length; i++) {
|
||||
String tagName = nameSplit[i];
|
||||
String tagTargetName = tagName;
|
||||
if (namePrefix.length() > 0) {
|
||||
tagTargetName = namePrefix + tagName;
|
||||
}
|
||||
names.put(tagName, tagTargetName);
|
||||
for (String lng : langs) {
|
||||
names.put(tagName + ":" + lng, tagTargetName + ":" + lng);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void registerMapRule(XmlPullParser parser, MapRulType rtype) {
|
||||
String val = parser.getAttributeValue("", "minzoom"); //$NON-NLS-1$
|
||||
if (rtype.isMain()) {
|
||||
rtype.minzoom = 15;
|
||||
}
|
||||
if (val != null) {
|
||||
rtype.minzoom = Integer.parseInt(val);
|
||||
}
|
||||
val = parser.getAttributeValue("", "maxzoom"); //$NON-NLS-1$
|
||||
rtype.maxzoom = 31;
|
||||
if (val != null) {
|
||||
rtype.maxzoom = Integer.parseInt(val);
|
||||
}
|
||||
registerRuleType(rtype);
|
||||
}
|
||||
|
||||
protected MapRulType registerRuleType(MapRulType rt) {
|
||||
String tag = rt.tagValuePattern.tag;
|
||||
String val = rt.tagValuePattern.value;
|
||||
|
@ -526,14 +422,7 @@ public abstract class MapRenderingTypes {
|
|||
}
|
||||
|
||||
public static class MapRulType {
|
||||
// relation part
|
||||
protected Map<String, String> relationNames;
|
||||
protected Map<String, String> additionalTags;
|
||||
protected Map<String, List<String>> relationSortTags;
|
||||
protected String relationGroupPrefix;
|
||||
protected Map<String, String> relationGroupNameTags;
|
||||
protected Map<String, String> relationGroupAdditionalTags;
|
||||
|
||||
protected MapRulType[] names;
|
||||
protected TagValuePattern tagValuePattern;
|
||||
protected boolean additional;
|
||||
protected boolean additionalText;
|
||||
|
@ -551,6 +440,7 @@ public abstract class MapRenderingTypes {
|
|||
protected int minzoom;
|
||||
protected int maxzoom;
|
||||
protected boolean onlyPoint;
|
||||
protected String namePrefix ="";
|
||||
|
||||
|
||||
// inner id
|
||||
|
@ -562,16 +452,6 @@ public abstract class MapRenderingTypes {
|
|||
private MapRulType(){
|
||||
}
|
||||
|
||||
|
||||
private void copyMetadata(MapRulType ref) {
|
||||
minzoom = ref.minzoom;
|
||||
maxzoom = ref.maxzoom;
|
||||
order = ref.order;
|
||||
category = ref.category;
|
||||
onlyPoint = ref.onlyPoint;
|
||||
}
|
||||
|
||||
|
||||
public boolean isPOI(){
|
||||
return poi;
|
||||
}
|
||||
|
@ -591,37 +471,24 @@ public abstract class MapRenderingTypes {
|
|||
return rt;
|
||||
}
|
||||
|
||||
public static MapRulType createText(String tag, MapRulType ref) {
|
||||
public static MapRulType createText(String tag) {
|
||||
MapRulType rt = new MapRulType();
|
||||
rt.additionalText = true;
|
||||
rt.minzoom = 2;
|
||||
rt.maxzoom = 31;
|
||||
if (ref != null) {
|
||||
rt.copyMetadata(ref);
|
||||
}
|
||||
rt.additionalText = true;
|
||||
rt.tagValuePattern = new TagValuePattern(tag, null);
|
||||
rt.tagValuePattern = new TagValuePattern(tag, null);
|
||||
return rt;
|
||||
}
|
||||
|
||||
public static MapRulType createAdditional(String tag, String value, MapRulType ref) {
|
||||
public static MapRulType createAdditional(String tag, String value) {
|
||||
MapRulType rt = new MapRulType();
|
||||
rt.additional = true;
|
||||
rt.minzoom = 2;
|
||||
rt.maxzoom = 31;
|
||||
if (ref != null) {
|
||||
rt.copyMetadata(ref);
|
||||
}
|
||||
rt.additional = true;
|
||||
rt.tagValuePattern = new TagValuePattern(tag, value);
|
||||
return rt;
|
||||
}
|
||||
|
||||
public static MapRulType createText(String tag) {
|
||||
return createText(tag, null);
|
||||
}
|
||||
|
||||
public static MapRulType createAdditional(String tag, String value) {
|
||||
return createAdditional(tag, value, null);
|
||||
}
|
||||
|
||||
public String getTag() {
|
||||
return tagValuePattern.tag;
|
||||
|
@ -682,6 +549,14 @@ public abstract class MapRenderingTypes {
|
|||
return onlyPoint;
|
||||
}
|
||||
|
||||
public boolean isRelation() {
|
||||
return relation;
|
||||
}
|
||||
|
||||
public boolean isRelationGroup() {
|
||||
return relationGroup;
|
||||
}
|
||||
|
||||
|
||||
public int getFreq() {
|
||||
return freq;
|
||||
|
|
|
@ -30,14 +30,13 @@ public class PoiFilter extends AbstractPoiType {
|
|||
List<PoiType> npoiTypes = null;
|
||||
Map<String, PoiType> nmap = null;
|
||||
for (PoiType poiType : poiTypesToAdd.values()) {
|
||||
String keyName = poiType.getKeyName();
|
||||
if (!map.containsKey(keyName) && !registry.isTypeForbidden(keyName)) {
|
||||
if (!map.containsKey(poiType.getKeyName())) {
|
||||
if (npoiTypes == null) {
|
||||
npoiTypes = new ArrayList<PoiType>(this.poiTypes);
|
||||
nmap = new LinkedHashMap<>(map);
|
||||
}
|
||||
npoiTypes.add(poiType);
|
||||
nmap.put(keyName, poiType);
|
||||
nmap.put(poiType.getKeyName(), poiType);
|
||||
}
|
||||
}
|
||||
if (npoiTypes != null) {
|
||||
|
@ -47,9 +46,6 @@ public class PoiFilter extends AbstractPoiType {
|
|||
}
|
||||
|
||||
public void addPoiType(PoiType type) {
|
||||
if (registry.isTypeForbidden(type.keyName)) {
|
||||
return;
|
||||
}
|
||||
if (!map.containsKey(type.getKeyName())) {
|
||||
poiTypes.add(type);
|
||||
map.put(type.getKeyName(), type);
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue