Compare commits
239 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e62e27cf22 | ||
|
|
76bf76a090 | ||
|
|
e906305910 | ||
|
|
08b94a0c42 | ||
|
|
c508bde844 | ||
|
|
d4b7e34d17 | ||
|
|
d5543bd7ef | ||
|
|
354bc16ead | ||
|
|
8889235690 | ||
|
|
9b43d7f498 | ||
|
|
ef2d2dd197 | ||
|
|
1245158ba3 | ||
|
|
ef5f7acbdf | ||
|
|
e1c24ee8cf | ||
|
|
9f5ddd2381 | ||
|
|
1fbc501bef | ||
|
|
d7c69e12d6 | ||
|
|
1fa86b5e07 | ||
|
|
efed81bdeb | ||
|
|
a308eb48ac | ||
|
|
5926dd3e65 | ||
|
|
a11e620792 | ||
|
|
6850eff26c | ||
|
|
ddf94ae2ca | ||
|
|
22ed9653ec | ||
|
|
3bb8ce00c5 | ||
|
|
b9cbd97c40 | ||
|
|
6801b895e4 | ||
|
|
c0d5f4a0ca | ||
|
|
2859a18d72 | ||
|
|
869446ad13 | ||
|
|
b2fd22885e | ||
|
|
7d6c623a80 | ||
|
|
6bea801bf6 | ||
|
|
d446a3448b | ||
|
|
d006ba5361 | ||
|
|
0eb4f3752f | ||
|
|
789c280fc2 | ||
|
|
a881eec9b1 | ||
|
|
1bc1d88464 | ||
|
|
1c18221f05 | ||
|
|
f4162acf04 | ||
|
|
1138978c22 | ||
|
|
bd43baba20 | ||
|
|
2e6da74af8 | ||
|
|
f6561d2a2e | ||
|
|
45a42bb242 | ||
|
|
3043173814 | ||
|
|
cde5d898c7 | ||
|
|
58f6215c0f | ||
|
|
d7d6fa57ac | ||
|
|
57bf615ab7 | ||
|
|
9bf3161010 | ||
|
|
98a977ea72 | ||
|
|
661bc08bbf | ||
|
|
804c8c4603 | ||
|
|
e103c38e3e | ||
|
|
e3b4ff502e | ||
|
|
6116ebb348 | ||
|
|
5c3a728d05 | ||
|
|
2070145880 | ||
|
|
e9a670f274 | ||
|
|
e5c87ba06e | ||
|
|
fa992b93f5 | ||
|
|
bf67074cf3 | ||
|
|
074320d6d2 | ||
|
|
6616c22a32 | ||
|
|
1ddba0fe8f | ||
|
|
0a374bc635 | ||
|
|
8602b5780a | ||
|
|
ab32f25a7c | ||
|
|
ebfb7bd85d | ||
|
|
ed739c59f5 | ||
|
|
238a5f8f14 | ||
|
|
126c47dfd7 | ||
|
|
e8389e6887 | ||
|
|
81f526dc56 | ||
|
|
23ae072ed6 | ||
|
|
20f4fad7f3 | ||
|
|
1805e86173 | ||
|
|
8acda4fbf5 | ||
|
|
65d8bd9675 | ||
|
|
34ea0af92d | ||
|
|
2d64186a1a | ||
|
|
4604f07042 | ||
|
|
52f47bd797 | ||
|
|
50f885b5f8 | ||
|
|
742405a193 | ||
|
|
18ee0a393f | ||
|
|
29634d29b5 | ||
|
|
635d5bacdd | ||
|
|
1156976ea5 | ||
|
|
964736d60f | ||
|
|
2de19ef080 | ||
|
|
0faf3eca66 | ||
|
|
c239d8c1b7 | ||
|
|
c28aec5f59 | ||
|
|
e0efff50a8 | ||
|
|
8364ff83d1 | ||
|
|
5d7a4e0954 | ||
|
|
2785d22a3a | ||
|
|
2768f84a5f | ||
|
|
1ede5c5456 | ||
|
|
5778d0e74a | ||
|
|
6672c57f05 | ||
|
|
c1fbdb42be | ||
|
|
841b3af042 | ||
|
|
bdd08e3486 | ||
|
|
68679c6dc0 | ||
|
|
9f280a41c0 | ||
|
|
65c8d5199f | ||
|
|
2b8326f465 | ||
|
|
488b350671 | ||
|
|
5285b0c272 | ||
|
|
ebe98c8990 | ||
|
|
c30095c59d | ||
|
|
f449a0a6fb | ||
|
|
74dfa07c81 | ||
|
|
bf6b325ce8 | ||
|
|
b43dfc53e4 | ||
|
|
883ed23272 | ||
|
|
0a0c2b3ce0 | ||
|
|
c783255b97 | ||
|
|
c689ad9e67 | ||
|
|
0fabe4c738 | ||
|
|
d4a95dad19 | ||
|
|
4405b6235a | ||
|
|
766b0d9914 | ||
|
|
412cacd1c2 | ||
|
|
299592d352 | ||
|
|
d512731d06 | ||
|
|
b2a8d3040a | ||
|
|
892ea92580 | ||
|
|
f7acfd9017 | ||
|
|
701ac43746 | ||
|
|
b926310296 | ||
|
|
49d1e7bafc | ||
|
|
6f697ed6f8 | ||
|
|
cdcae29ae1 | ||
|
|
a13c4a3793 | ||
|
|
031a3bfa00 | ||
|
|
7122e1fbc5 | ||
|
|
6ed00d9a94 | ||
|
|
327d6f1466 | ||
|
|
17a135813b | ||
|
|
0dd82cb68f | ||
|
|
ae04fa83f6 | ||
|
|
4bfcdadb76 | ||
|
|
fa5a72f20d | ||
|
|
d81eb3d706 | ||
|
|
97332e3e73 | ||
|
|
e4a4857eb8 | ||
|
|
80018de754 | ||
|
|
01bb7ca074 | ||
|
|
a8f5eee505 | ||
|
|
644cf9dcb6 | ||
|
|
cb0109ba42 | ||
|
|
2fa5afec11 | ||
|
|
69ea1e414a | ||
|
|
4866abe38e | ||
|
|
4c10d5848b | ||
|
|
faed3d05a5 | ||
|
|
88a9a9ee7f | ||
|
|
3915e3343d | ||
|
|
b22c023f1a | ||
|
|
5de7c9ec38 | ||
|
|
14c485914c | ||
|
|
c20922b5f5 | ||
|
|
1294ff9fea | ||
|
|
992d9c8e66 | ||
|
|
948449b3ec | ||
|
|
0c1c06c1bb | ||
|
|
7ad3f4a0b1 | ||
|
|
c5836adc17 | ||
|
|
107a429517 | ||
|
|
2cb0a80c47 | ||
|
|
db9f83120a | ||
|
|
5facdb9888 | ||
|
|
3f3caa1912 | ||
|
|
03b9f224b2 | ||
|
|
c013465d49 | ||
|
|
c91833519e | ||
|
|
055cd54beb | ||
|
|
3eaad42903 | ||
|
|
6ab98419df | ||
|
|
a9e18a2add | ||
|
|
83aed13683 | ||
|
|
5779d10632 | ||
|
|
85e818d788 | ||
|
|
cc1d4cf6d9 | ||
|
|
0404effca3 | ||
|
|
eef1a8c779 | ||
|
|
527fc3d42d | ||
|
|
53b262f190 | ||
|
|
dcb7b0d10c | ||
|
|
e6137163b9 | ||
|
|
2cf9a4a472 | ||
|
|
55d8797f37 | ||
|
|
653c6489b9 | ||
|
|
c19e06b718 | ||
|
|
5de4c6b7ab | ||
|
|
900448f8d3 | ||
|
|
4be42dbc0f | ||
|
|
72ba3d6429 | ||
|
|
f5815203c4 | ||
|
|
0c050c7405 | ||
|
|
71bf1390f6 | ||
|
|
368cf1ff4a | ||
|
|
c526599e20 | ||
|
|
fcf7272f2e | ||
|
|
cf2bdb251b | ||
|
|
551c0231a0 | ||
|
|
70741d8f5b | ||
|
|
9209afba01 | ||
|
|
9e81473d36 | ||
|
|
ffeaf1b81c | ||
|
|
efab21f4f2 | ||
|
|
a6ce05034a | ||
|
|
634d67a206 | ||
|
|
30ae0fb48f | ||
|
|
5740290a9b | ||
|
|
149d5d9057 | ||
|
|
fe2d806d73 | ||
|
|
63ccf0dcfa | ||
|
|
5f1c3c3186 | ||
|
|
b98505c815 | ||
|
|
5979161611 | ||
|
|
d6e55edd8e | ||
|
|
431eadaa87 | ||
|
|
df82ebfaa6 | ||
|
|
b5ee7c1b46 | ||
|
|
54b7884fa3 | ||
|
|
e5bc7c7564 | ||
|
|
cf49591d4f | ||
|
|
71f94f3f79 | ||
|
|
db6be82ce2 | ||
|
|
ba65786b5a | ||
|
|
036d63c9dd | ||
|
|
07e86d24f6 |
@@ -4,8 +4,8 @@ jdk:
|
||||
- openjdk8
|
||||
env:
|
||||
global:
|
||||
- ANDROID=28
|
||||
- ANDROID_BUILD_TOOLS=28.0.3
|
||||
- ANDROID=30
|
||||
- ANDROID_BUILD_TOOLS=30.0.3
|
||||
- GRADLE_OPTS="-Xmx2048m"
|
||||
- secure: sW674wuFZOuoX7jHQHDbX3j8NxL8JxR07cyq+CrrqJ537dU9lxWQmMBRUpOb+p/q7sQ74PUtiKJkmFgKCSJSAKY+nr6GJ8P/q6u5TUKbmUWODSn8znehX2zualfvFwpF4PILok/wUzXBQE62jn4lUua7cMdsHRMNHbLmKqBoVL0meObDDjsaJ/RCbOPuruy3FmgvXPp0+Y4zl1GsklDSyjFzg4LBzjAk9Ryvh1O4zvJBkkyfCgurLKCnOKIPy3v5fPMS9oDfO1aarAVGoZZe416pvTW4hb8cdB6kn9XWYDob4NDFX/sP5k7XIhd/NAIn9LrKFg0sLtATaKLX+BcasF1CgDR/u6+SEeQd5QaRF7Go2Nq5Ltuu4OIFONI2qhEeVDDK6Otf2WSWj9KPno2GHuumBfbg4ypWoJgmZrMXk8JeVV/OP/0jIQz3p/7yfF21X1XBEqYaVHPAMKdEYYkCSa46KfACyOt6LfnkuCHtoTOpFo7sq0omIA2HOtpIx1u3vMBUyAbQqT6cokkKB1b6gNTFwhHc+8ybfLFPljJB8cWshI+V/b06S6fekRmvTNxvDykWNsdlkENBYqc9hMfjcT4hO4K+76SWN62mimQYODvFyfTVMC7WkQ3k/XEnmqUPV5XkbaILbS1d/tA57N148FiJ5/QXtI6Y94imubYyVqU=
|
||||
- secure: AdKSZKA4gMuKXI4X4dQNJqcMv5OmPIHdN8fpy55Y9yoOQPQHZE3Zwc4QDWBh20q298jyEC854tVTPTysdZ7h+2s2FhsprYv1Bt/QNzKIrLpeIMj2quuVGMbdPuk08y55gost94KwVLJv0sIDpRlB/PEQkA7Mg/UDsT9zR8E1Ms5x+ul2C8e1ag0zzNl1wVnT5jY8WCp74uA/XXCcJl/80qT1stUERazCKwbKNo007hi7rdm4HA7YGevORq8e2r67je+WIBZUAwrHT0Zjuo4ibwUii4LdwvjuN3w0Z6e9Wf4x5bBqGgnih0T31uom2yPjNx+U/c2AWI+Nxfy/SEF2U+9bjBEZ3ZhI7F1B9ofXo2mhvvsVDiUrymMBbG2V64C9kAzeUh7xIBTqIrbdtpAEBV9FlLAtF2swVTwtCgZgcVTOt3RKXCi3X3nk3cuH7PAorFa/QGfT4xxVu2011FVAt2Rm7SD0ZWztZTSTz/4Nt/egtGBOJfrCc7oLEygLzDmLqsqCwCROITVQjWLjrtqDyLteaNiSXeNIQMKun3izApbXnHmXB+FV3R3EZocboqk3v5bmPTahnG6Ghc2zknWyyxSx+O9qIfOpHUL8JMJiT82lUQUeibtCn7DCE8wVQ/gYC5i+a+KO/d3NemSzIFlZ8aoUiEPYq18dYlsDXeLXwF0=
|
||||
|
||||
@@ -8,11 +8,11 @@
|
||||
|
||||
VTM (Vector Tile Map) was developed within the [OpenScienceMap](https://github.com/opensciencemap) project.
|
||||
|
||||
**This fork continues VTM development and provides compatibility with latest [Mapsforge](https://github.com/mapsforge/mapsforge).**
|
||||
**This fork continues VTM development and provides compatibility with [Mapsforge](https://github.com/mapsforge/mapsforge).**
|
||||
|
||||
See the **[integration guide](docs/Integration.md)** and [changelog](docs/Changelog.md). And read through [how to contribute](docs/CONTRIBUTING.md) guidelines.
|
||||
|
||||
If you have any questions or problems, don't hesitate to ask our public [forum](https://groups.google.com/group/mapsforge-dev) for help.
|
||||
If you have any questions or problems, don't hesitate to ask the Discussions for help.
|
||||
|
||||
## Features
|
||||
- Java map library
|
||||
@@ -21,6 +21,7 @@ If you have any questions or problems, don't hesitate to ask our public [forum](
|
||||
- Support for multiple tile sources:
|
||||
- OpenScienceMap vector tiles
|
||||
- Mapsforge vector maps
|
||||
- MBTiles vector & raster maps
|
||||
- Mapbox vector tiles (e.g. Mapilion, Mapzen, Nextzen, OpenMapTiles)
|
||||
- GeoJSON vector tiles (e.g. Mapzen, Nextzen)
|
||||
- Raster tiles: any quadtree-scheme tiles as texture
|
||||
@@ -37,6 +38,8 @@ If you have any questions or problems, don't hesitate to ask our public [forum](
|
||||
- **vtm-gdx** common libGDX backend
|
||||
- **vtm-android-gdx** Android libGDX backend
|
||||
- **vtm-desktop** Desktop libGDX backend
|
||||
- **vtm-desktop-lwjgl** Desktop LWJGL backend
|
||||
- **vtm-desktop-lwjgl3** Desktop LWJGL 3 backend
|
||||
- **vtm-playground** Desktop examples
|
||||
- **vtm-ios** iOS libGDX backend
|
||||
- **vtm-ios-example** iOS examples
|
||||
|
||||
27
build.gradle
27
build.gradle
@@ -1,10 +1,10 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.3.2'
|
||||
classpath 'com.android.tools.build:gradle:4.1.3'
|
||||
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
|
||||
}
|
||||
}
|
||||
@@ -14,10 +14,10 @@ allprojects {
|
||||
version = 'master-SNAPSHOT'
|
||||
ext.isReleaseVersion = !version.endsWith("SNAPSHOT")
|
||||
|
||||
ext.androidBuildVersionTools = "28.0.3"
|
||||
ext.gdxVersion = "1.9.9"
|
||||
ext.gwtVersion = "2.8.0"
|
||||
ext.slf4jVersion = "1.7.25"
|
||||
ext.androidBuildVersionTools = "30.0.3"
|
||||
ext.gdxVersion = "1.9.10"
|
||||
ext.gwtVersion = "2.8.2"
|
||||
ext.slf4jVersion = "1.7.28"
|
||||
|
||||
if (JavaVersion.current().isJava8Compatible()) {
|
||||
tasks.withType(Javadoc) {
|
||||
@@ -28,12 +28,12 @@ allprojects {
|
||||
}
|
||||
}
|
||||
|
||||
static def androidCompileSdk() { return 28 }
|
||||
static def androidCompileSdk() { return 30 }
|
||||
|
||||
// 14 for Support Library, 16 for sqlite-android
|
||||
static def androidMinSdk() { return 16 }
|
||||
|
||||
static def androidTargetSdk() { return 22 }
|
||||
static def androidTargetSdk() { return 30 }
|
||||
|
||||
static def versionCode() { return 1 }
|
||||
|
||||
@@ -42,14 +42,19 @@ def versionName() { return version }
|
||||
subprojects {
|
||||
repositories {
|
||||
google()
|
||||
maven { url 'https://repo.boundlessgeo.com/main/' }
|
||||
jcenter()
|
||||
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
|
||||
mavenCentral()
|
||||
maven { url 'https://jitpack.io' }
|
||||
maven { url "https://plugins.gradle.org/m2/" }
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_7
|
||||
targetCompatibility = JavaVersion.VERSION_1_7
|
||||
options.encoding = 'UTF-8'
|
||||
if (JavaVersion.current().isJava9Compatible()) {
|
||||
if (!project.properties.containsKey('android')) {
|
||||
options.compilerArgs.addAll(['--release', '7'])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ if (project.hasProperty("android")) {
|
||||
task javadoc(type: Javadoc) {
|
||||
source = android.sourceSets.main.java.srcDirs
|
||||
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
|
||||
classpath += project.android.libraryVariants.toList().first().javaCompileProvider.get().classpath
|
||||
}
|
||||
} else {
|
||||
task sourcesJar(type: Jar) {
|
||||
|
||||
@@ -6,8 +6,10 @@
|
||||
| [Cachebox 3.0](https://github.com/Longri/cachebox3.0) | Geocaching application | Apache 2.0/Free | Android, Desktop, iOS | Open |
|
||||
| [Cruiser](http://wiki.openstreetmap.org/wiki/Cruiser) | Map and navigation application | Proprietary/Free | Android, Desktop | Closed |
|
||||
| [GCDroid](https://play.google.com/store/apps/details?id=com.gcdroid) | Geocaching App | Proprietary/Free and Commercial | Android | Closed |
|
||||
| [GPSLogger II](https://play.google.com/store/apps/details?id=com.emacberry.gpslogger) | Map and navigation, Fitness & Cycling application | Proprietary/Free | Android | Closed |
|
||||
| [HabanaTrans](https://play.google.com/store/apps/details?id=cu.pabloapk.habanatrans&hl=es_419) | Public transport, map offline, gps, routing | Proprietary/Free | Android | Closed |
|
||||
| [Hunt Cyprus](https://play.google.com/store/apps/developer?id=Talent+S.A.) | Map and navigation application for hunters | Proprietary/Free and Commercial | Android | Closed |
|
||||
| [Kurviger](https://kurviger.de/en) | Route planner specialized on motorcyclists | Proprietary/Free and Commercial | Android | Closed |
|
||||
| [Kurviger](https://kurviger.de/en) | Route planner specialized on motorcyclists | Proprietary/Free (in-app purchases) | Android | Closed |
|
||||
| [MapTrek](http://maptrek.mobi) | Application for outdoor activities | GPL3/Free and Commercial | Android | Open |
|
||||
| [MyRunningApp](https://play.google.com/store/apps/details?id=it.nimarsolutions.rungpstracker) | Fitness app | Proprietary/Free | Android | Closed |
|
||||
| [MyTourbook](http://mytourbook.sourceforge.net/mytourbook/) | Visualize and analyze tours | GPL2/Free | Desktop | Open |
|
||||
@@ -17,6 +19,5 @@
|
||||
| [topoGuide](http://www.topoguide.gr/index-en.php) | Digital guides for the outdoor | Proprietary/Free and Commercial | Android | Closed |
|
||||
| [Ubitrek](https://play.google.com/store/apps/details?id=ubicarta.ubitrek) | Hiking with IGN maps | Proprietary/Free | Android | Closed |
|
||||
| [VTM with Eclipse RCP](https://github.com/wolfgang-ch/vtm-with-rcp) | VTM with an Eclipse RCP application | GPL3/Free | Desktop | Open |
|
||||
| [Walkaholic](https://play.google.com/store/apps/details?id=com.walkaholic.hikeapp) | Hiking app with official routes and online/offline maps | Proprietary/Free (in-app purchases) | Android | Closed |
|
||||
| [XCTrack](http://xctrack.org/) | Flight computer for paraglider pilots | Proprietary/Free | Android | Closed |
|
||||
|
||||
You know an application that is missing here? Please inform us by sending a message via our public [forum](https://groups.google.com/group/mapsforge-dev).
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
|
||||
As an open source project, we welcome new contributors and appreciate your help.
|
||||
|
||||
Before you start working on an unresolved issue or try to implement a new feature, please contact us via our public [forum](https://groups.google.com/group/mapsforge-dev).
|
||||
|
||||
You may also create a new issue on [Github](https://github.com/mapsforge/vtm/issues) or comment on an existing one to describe your ideas. We will then discuss the best way to realize your proposal and figure out how we can help you to get started quickly.
|
||||
Before you start working on an unresolved issue or try to implement a new feature, please contact us via the Discussions. We will then discuss the best way to realize your proposal and figure out how we can help you to get started quickly.
|
||||
|
||||
If you are only requesting a small change in the code, you may attach a patch file to the corresponding issue, but it is best to create a pull request on Github. Make sure that your patch is derived from the latest version in our **master** repository, otherwise we might be unable to apply it. Important is to keep pull requests simple with one feature in each. Please follow our code and style conventions.
|
||||
|
||||
|
||||
@@ -1,5 +1,81 @@
|
||||
# Changelog
|
||||
|
||||
## New since 0.16.0
|
||||
|
||||
- Many other minor improvements and bug fixes
|
||||
- [Solved issues](https://github.com/mapsforge/vtm/issues?q=is%3Aclosed+milestone%3A0.17.0)
|
||||
|
||||
## Version 0.16.0 (2021-05-27)
|
||||
|
||||
- Android: scoped storage map / theme example [#804](https://github.com/mapsforge/vtm/pull/804)
|
||||
- Render theme from zip archive [#804](https://github.com/mapsforge/vtm/pull/804)
|
||||
- Render themes: custom resource providers [#804](https://github.com/mapsforge/vtm/pull/804)
|
||||
- Nautical unit adapter with feet [#803](https://github.com/mapsforge/vtm/pull/803)
|
||||
- Distant labels rendering option [#844](https://github.com/mapsforge/vtm/pull/844)
|
||||
- `Parameters.DISTANT_LABELS`
|
||||
- Many other minor improvements and bug fixes
|
||||
- [Solved issues](https://github.com/mapsforge/vtm/issues?q=is%3Aclosed+milestone%3A0.16.0)
|
||||
|
||||
## Version 0.15.0 (2021-01-01)
|
||||
|
||||
- Android: scoped storage map example [#785](https://github.com/mapsforge/vtm/pull/785)
|
||||
- Mapsforge: map stream support [#784](https://github.com/mapsforge/vtm/pull/784)
|
||||
- Render theme from Android content providers [#783](https://github.com/mapsforge/vtm/pull/783)
|
||||
- Render theme xml pull parser [#786](https://github.com/mapsforge/vtm/pull/786)
|
||||
- Symbol scale option [#790](https://github.com/mapsforge/vtm/pull/790)
|
||||
- `Parameters.SYMBOL_SCALING`
|
||||
- Many other minor improvements and bug fixes
|
||||
- [Solved issues](https://github.com/mapsforge/vtm/issues?q=is%3Aclosed+milestone%3A0.15.0)
|
||||
|
||||
## Version 0.14.0 (2020-08-25)
|
||||
|
||||
- Render themes: symbol styles [#769](https://github.com/mapsforge/vtm/pull/769)
|
||||
- More mutable itemized layer [#771](https://github.com/mapsforge/vtm/pull/771)
|
||||
- Marker renderer sort option
|
||||
- `Parameters.MARKER_SORT`
|
||||
- Update vtm-jeo module [#770](https://github.com/mapsforge/vtm/pull/770)
|
||||
- Many other minor improvements and bug fixes
|
||||
- [Solved issues](https://github.com/mapsforge/vtm/issues?q=is%3Aclosed+milestone%3A0.14.0)
|
||||
|
||||
## Version 0.13.0 (2020-01-12)
|
||||
|
||||
- Render themes: symbols on lines with billboard / rotation [#743](https://github.com/mapsforge/vtm/pull/743)
|
||||
- Location texture renderer: rewrite and optimize [#750](https://github.com/mapsforge/vtm/pull/750)
|
||||
- Fix stroke cap line ending [#758](https://github.com/mapsforge/vtm/pull/758)
|
||||
- Mapsforge: fix ways precision loss [#752](https://github.com/mapsforge/vtm/pull/752)
|
||||
- Mapsforge: additional simplification [#757](https://github.com/mapsforge/vtm/pull/757)
|
||||
- `Parameters.SIMPLIFICATION_TOLERANCE`
|
||||
- Android: OpenGL ES 2.0 default for performance / stability [#749](https://github.com/mapsforge/vtm/pull/749)
|
||||
- `MapView.OPENGL_VERSION`
|
||||
- Android: threaded system initialization
|
||||
- `Parameters.THREADED_INIT`
|
||||
- Many other minor improvements and bug fixes
|
||||
- [Solved issues](https://github.com/mapsforge/vtm/issues?q=is%3Aclosed+milestone%3A0.13.0)
|
||||
|
||||
## Version 0.12.0 (2019-09-17)
|
||||
|
||||
- MBTiles vector tile source (Android) [#740](https://github.com/mapsforge/vtm/pull/740)
|
||||
- vtm-android-mvt module
|
||||
- Render themes: text background color [#737](https://github.com/mapsforge/vtm/pull/737)
|
||||
- vtm-desktop-lwjgl module [#714](https://github.com/mapsforge/vtm/pull/714)
|
||||
- vtm-desktop-lwjgl3 module [#717](https://github.com/mapsforge/vtm/pull/717)
|
||||
- Fix marker touch events [#723](https://github.com/mapsforge/vtm/issues/723)
|
||||
- Calculation of centroids for all polygons [#734](https://github.com/mapsforge/vtm/pull/734)
|
||||
- `Parameters.POLY_CENTROID`
|
||||
- Disable optimal placement of labels or symbols on polygons
|
||||
- `Parameters.POLY_LABEL`
|
||||
- Android 10 compatibility [#728](https://github.com/mapsforge/vtm/issues/728)
|
||||
- libGDX 1.9.10 [#731](https://github.com/mapsforge/vtm/issues/731)
|
||||
- Many other minor improvements and bug fixes
|
||||
- [Solved issues](https://github.com/mapsforge/vtm/issues?q=is%3Aclosed+milestone%3A0.12.0)
|
||||
|
||||
## Version 0.11.1 (2019-04-12)
|
||||
|
||||
- MBTiles raster tile source (Android) [#708](https://github.com/mapsforge/vtm/pull/708)
|
||||
- Fix Android 4.2 crash [#713](https://github.com/mapsforge/vtm/issues/713)
|
||||
- Many other minor improvements and bug fixes
|
||||
- [Solved issues](https://github.com/mapsforge/vtm/issues?q=is%3Aclosed+milestone%3A0.11.1)
|
||||
|
||||
## Version 0.11.0 (2019-03-25)
|
||||
|
||||
- Render themes: tag transform [#420](https://github.com/mapsforge/vtm/issues/420)
|
||||
@@ -158,7 +234,7 @@
|
||||
- Many other minor improvements and bug fixes
|
||||
- [Solved issues](https://github.com/mapsforge/vtm/issues?q=is%3Aclosed+milestone%3A0.7.0)
|
||||
|
||||
## Version 0.6.0 (2016-10-28) - VTM revive
|
||||
## Version 0.6.0 (2016-10-28) - VTM revival
|
||||
|
||||
- Mapsforge maps **v4** support [#34](https://github.com/mapsforge/vtm/issues/34)
|
||||
- Render theme SVG resources [#60](https://github.com/mapsforge/vtm/issues/60)
|
||||
@@ -166,7 +242,8 @@
|
||||
- vtm-ios module update [#29](https://github.com/mapsforge/vtm/issues/29)
|
||||
- Native libraries for all platforms [#14](https://github.com/mapsforge/vtm/issues/14)
|
||||
- Line stipple and texture rendering [#105](https://github.com/mapsforge/vtm/issues/105)
|
||||
- Layer groups [#99](https://github.com/mapsforge/vtm/issues/99) [#103](https://github.com/mapsforge/vtm/issues/103)
|
||||
- Group layer implementation [#99](https://github.com/mapsforge/vtm/issues/99)
|
||||
- Layer groups implementation [#103](https://github.com/mapsforge/vtm/issues/103)
|
||||
- Location renderer and layer [#171](https://github.com/mapsforge/vtm/issues/171)
|
||||
- Map scale bar [#84](https://github.com/mapsforge/vtm/issues/84)
|
||||
- Tile size based on scale factor [#183](https://github.com/mapsforge/vtm/issues/183)
|
||||
@@ -174,6 +251,8 @@
|
||||
- libGDX layer gestures [#151](https://github.com/mapsforge/vtm/issues/151)
|
||||
- Render theme area tessellation option [#37](https://github.com/mapsforge/vtm/issues/37)
|
||||
- Render theme resources optional location prefixes [#66](https://github.com/mapsforge/vtm/issues/66)
|
||||
- Render theme from input stream [#161](https://github.com/mapsforge/vtm/issues/161)
|
||||
- Render theme from Android assets [#162](https://github.com/mapsforge/vtm/issues/162)
|
||||
- Graphics API platform enhancements [#92](https://github.com/mapsforge/vtm/issues/92)
|
||||
- GeoPoint & BoundingBox improvements [#201](https://github.com/mapsforge/vtm/issues/201) [#200](https://github.com/mapsforge/vtm/issues/200)
|
||||
- vtm-jts module [#53](https://github.com/mapsforge/vtm/issues/53)
|
||||
|
||||
@@ -1,5 +1 @@
|
||||
For questions or discussion please always use our Forum first and make sure you read our Contributing Guide.
|
||||
|
||||
- Forum: https://groups.google.com/group/mapsforge-dev
|
||||
|
||||
- Contributing Guide: https://github.com/mapsforge/vtm/blob/master/docs/CONTRIBUTING.md
|
||||
For questions, reports and feature requests please use the Discussions.
|
||||
@@ -10,7 +10,8 @@ Current version is [
|
||||
@@ -36,9 +37,9 @@ implementation 'org.mapsforge:vtm-android-gdx:[CURRENT-VERSION]:natives-armeabi-
|
||||
implementation 'org.mapsforge:vtm-android-gdx:[CURRENT-VERSION]:natives-arm64-v8a'
|
||||
implementation 'org.mapsforge:vtm-android-gdx:[CURRENT-VERSION]:natives-x86'
|
||||
implementation 'org.mapsforge:vtm-android-gdx:[CURRENT-VERSION]:natives-x86_64'
|
||||
implementation 'com.badlogicgames.gdx:gdx:1.9.9'
|
||||
implementation 'com.badlogicgames.gdx:gdx-backend-android:1.9.9'
|
||||
implementation 'com.caverock:androidsvg:1.3'
|
||||
implementation 'com.badlogicgames.gdx:gdx:1.9.10'
|
||||
implementation 'com.badlogicgames.gdx:gdx-backend-android:1.9.10'
|
||||
implementation 'com.caverock:androidsvg:1.4'
|
||||
```
|
||||
|
||||
### iOS
|
||||
@@ -47,83 +48,94 @@ Detailed iOS instructions can be found [here](ios.md).
|
||||
|
||||
### Desktop
|
||||
```groovy
|
||||
repositories {
|
||||
maven { url 'https://jitpack.io' }
|
||||
}
|
||||
|
||||
implementation 'org.mapsforge:vtm-gdx:[CURRENT-VERSION]'
|
||||
implementation 'org.mapsforge:vtm-desktop:[CURRENT-VERSION]'
|
||||
implementation 'org.mapsforge:vtm-desktop:[CURRENT-VERSION]:natives-linux'
|
||||
implementation 'org.mapsforge:vtm-desktop:[CURRENT-VERSION]:natives-osx'
|
||||
implementation 'org.mapsforge:vtm-desktop:[CURRENT-VERSION]:natives-windows'
|
||||
implementation 'com.badlogicgames.gdx:gdx:1.9.9'
|
||||
implementation 'com.badlogicgames.gdx:gdx-platform:1.9.9:natives-desktop'
|
||||
implementation 'com.badlogicgames.gdx:gdx-backend-lwjgl:1.9.9'
|
||||
implementation 'com.badlogicgames.gdx:gdx:1.9.10'
|
||||
implementation 'com.badlogicgames.gdx:gdx-platform:1.9.10:natives-desktop'
|
||||
implementation 'com.formdev:svgSalamander:1.1.2.4'
|
||||
```
|
||||
|
||||
### Desktop (LWJGL)
|
||||
```groovy
|
||||
implementation 'org.mapsforge:vtm-desktop-lwjgl:[CURRENT-VERSION]'
|
||||
implementation 'com.badlogicgames.gdx:gdx-backend-lwjgl:1.9.10'
|
||||
implementation 'org.lwjgl.lwjgl:lwjgl:2.9.3'
|
||||
implementation 'org.lwjgl.lwjgl:lwjgl-platform:2.9.3:natives-linux'
|
||||
implementation 'org.lwjgl.lwjgl:lwjgl-platform:2.9.3:natives-osx'
|
||||
implementation 'org.lwjgl.lwjgl:lwjgl-platform:2.9.3:natives-windows'
|
||||
implementation 'com.github.blackears:svgSalamander:v1.1.1'
|
||||
```
|
||||
|
||||
### Desktop (LWJGL 3)
|
||||
```groovy
|
||||
implementation 'org.mapsforge:vtm-desktop-lwjgl3:[CURRENT-VERSION]'
|
||||
implementation 'com.badlogicgames.gdx:gdx-backend-lwjgl3:1.9.10'
|
||||
implementation 'org.lwjgl:lwjgl:3.2.3'
|
||||
implementation 'org.lwjgl:lwjgl:3.2.3:natives-linux'
|
||||
implementation 'org.lwjgl:lwjgl:3.2.3:natives-macos'
|
||||
implementation 'org.lwjgl:lwjgl:3.2.3:natives-windows'
|
||||
```
|
||||
|
||||
### JTS geometries
|
||||
|
||||
```groovy
|
||||
implementation 'org.mapsforge:vtm-jts:[CURRENT-VERSION]'
|
||||
implementation 'org.locationtech.jts:jts-core:1.15.0'
|
||||
// https://github.com/locationtech/jts/issues/145
|
||||
implementation 'org.locationtech.jts:jts-core:1.15.1'
|
||||
```
|
||||
|
||||
### Online tiles
|
||||
|
||||
```groovy
|
||||
implementation 'org.mapsforge:vtm-http:[CURRENT-VERSION]'
|
||||
implementation 'com.squareup.okhttp3:okhttp:3.8.0'
|
||||
implementation 'com.squareup.okio:okio:1.13.0'
|
||||
// https://github.com/square/okhttp/issues/4481
|
||||
implementation 'com.squareup.okhttp3:okhttp:3.12.13'
|
||||
implementation 'com.squareup.okio:okio:1.15.0'
|
||||
```
|
||||
|
||||
### MBTiles (Android)
|
||||
|
||||
```groovy
|
||||
implementation 'org.mapsforge:vtm-android-mvt:[CURRENT-VERSION]'
|
||||
implementation 'org.mapsforge:vtm-mvt:[CURRENT-VERSION]'
|
||||
implementation 'com.google.protobuf:protobuf-java:3.6.1'
|
||||
implementation 'com.wdtinc:mapbox-vector-tile:3.1.0'
|
||||
// https://github.com/locationtech/jts/issues/145
|
||||
implementation 'org.locationtech.jts:jts-core:1.15.1'
|
||||
```
|
||||
|
||||
### Mapbox vector tiles
|
||||
|
||||
```groovy
|
||||
implementation 'org.mapsforge:vtm-mvt:[CURRENT-VERSION]'
|
||||
implementation 'com.google.protobuf:protobuf-java:3.5.1'
|
||||
implementation 'com.wdtinc:mapbox-vector-tile:3.0.0'
|
||||
implementation 'org.locationtech.jts:jts-core:1.15.0'
|
||||
implementation 'com.google.protobuf:protobuf-java:3.6.1'
|
||||
implementation 'com.wdtinc:mapbox-vector-tile:3.1.0'
|
||||
// https://github.com/locationtech/jts/issues/145
|
||||
implementation 'org.locationtech.jts:jts-core:1.15.1'
|
||||
```
|
||||
|
||||
### GeoJSON vector tiles
|
||||
|
||||
```groovy
|
||||
implementation 'org.mapsforge:vtm-json:[CURRENT-VERSION]'
|
||||
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.8.4'
|
||||
implementation 'com.fasterxml.jackson.core:jackson-core:2.8.4'
|
||||
implementation 'com.fasterxml.jackson.core:jackson-databind:2.8.4'
|
||||
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.9.9'
|
||||
implementation 'com.fasterxml.jackson.core:jackson-core:2.9.9'
|
||||
implementation 'com.fasterxml.jackson.core:jackson-databind:2.9.9'
|
||||
```
|
||||
|
||||
### jeo (indoor maps)
|
||||
|
||||
Add _first_ the Boundless repository:
|
||||
```groovy
|
||||
repositories {
|
||||
maven { url 'https://repo.boundlessgeo.com/main/' }
|
||||
jcenter()
|
||||
...
|
||||
maven { url 'https://jitpack.io' }
|
||||
}
|
||||
```
|
||||
|
||||
```groovy
|
||||
implementation 'org.mapsforge:vtm-jeo:[CURRENT-VERSION]'
|
||||
implementation('org.jeo:jeo:0-SNAPSHOT') {
|
||||
implementation('com.github.jeo.jeo:jeo-carto:master-SNAPSHOT') {
|
||||
exclude group: 'org.slf4j', module: 'slf4j-jdk14'
|
||||
}
|
||||
implementation('org.jeo:jeo-carto:0-SNAPSHOT') {
|
||||
exclude group: 'org.slf4j', module: 'slf4j-jdk14'
|
||||
}
|
||||
implementation('org.jeo:jeo-render:0-SNAPSHOT') {
|
||||
exclude group: 'org.slf4j', module: 'slf4j-jdk14'
|
||||
}
|
||||
implementation 'org.osgeo:proj4j:0.1.0:jeo'
|
||||
implementation 'com.metaweb:lessen:1.0'
|
||||
implementation 'com.vividsolutions:jts:1.13'
|
||||
```
|
||||
|
||||
## Snapshots
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
# Mapsforge map providers (in lexical order)
|
||||
|
||||
- [AndroidMaps](http://www.androidmaps.co.uk/)
|
||||
- [Freizeitkarte](http://www.freizeitkarte-osm.de/android/en/index.html)
|
||||
- [Kurviger](https://offline-maps.kurviger.de/)
|
||||
- [Locusvectormaps](http://www.locusvectormaps.com)
|
||||
- [Mapsforge](http://download.mapsforge.org/)
|
||||
- [OpenAndroMaps](http://www.openandromaps.org/en/)
|
||||
- [OpenMaps](http://openmaps.eu/)
|
||||
|
||||
You know a Mapsforge map provider that is missing here? Please inform us by sending a message via our public [forum](https://groups.google.com/group/mapsforge-dev).
|
||||
- [AndroidMaps](https://www.androidmaps.co.uk/)
|
||||
- [BBBike](https://extract.bbbike.org/?format=mapsforge-osm.zip)
|
||||
- [Freizeitkarte](https://www.freizeitkarte-osm.de/android/en/index.html)
|
||||
- [Kurviger](https://download.kurviger.de/)
|
||||
- [Mapsforge](https://download.mapsforge.org/)
|
||||
- [OpenAndroMaps](https://www.openandromaps.org/en/)
|
||||
- [OpenMaps](https://openmaps.eu/)
|
||||
- [vector.city](https://vector.city/)
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
# RenderTheme
|
||||
|
||||
**This article describes how to use XML-based render-themes to style maps.**
|
||||
|
||||
If you have any questions or problems, don't hesitate to ask our public [forum](https://groups.google.com/group/mapsforge-dev) for help. You can also report bugs and improvement requests via our [issue tracker](https://github.com/mapsforge/vtm/issues).
|
||||
This article describes how to use XML-based render-themes to style maps.
|
||||
|
||||
## Introduction
|
||||
|
||||
@@ -109,11 +107,12 @@ There are different possibilities to simplify and accelerate map styling or chan
|
||||
|
||||
### Style patterns
|
||||
|
||||
If you want to use a specific style multiple times you not have to rewrite it for each text, area, or line rule.
|
||||
If you want to use a specific style multiple times you not have to rewrite it for each text, line, area or symbol rule.
|
||||
If you define a style set an `id` and use it with `use` in your rendering instructions:
|
||||
- `style-text`
|
||||
- `style-line`
|
||||
- `style-area`
|
||||
- `style-symbol`
|
||||
|
||||
This example styles all areas with the_residential_ style, which haven't the `highway` or `building` key.
|
||||
|
||||
|
||||
@@ -15,3 +15,5 @@ The jar file can be found in `build/libs` folder. Depending on the main class, p
|
||||
```
|
||||
java -jar vtm-playground-master-SNAPSHOT-jar-with-dependencies.jar /path/to/map
|
||||
```
|
||||
|
||||
To change the libGDX backend can replace the dependency: `vtm-desktop-lwjgl` or `vtm-desktop-lwjgl3`.
|
||||
|
||||
@@ -6,8 +6,12 @@
|
||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||
# Specifies the JVM arguments used for the daemon process.
|
||||
# The setting is particularly useful for tweaking memory settings.
|
||||
org.gradle.jvmargs=-Xmx1536m
|
||||
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. More details, visit
|
||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||
# org.gradle.parallel=true
|
||||
# AndroidX package structure to make it clearer which packages are bundled with the
|
||||
# Android operating system, and which are packaged with your app"s APK
|
||||
# https://developer.android.com/topic/libraries/support-library/androidx-rn
|
||||
android.useAndroidX=true
|
||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
@@ -150,6 +150,7 @@
|
||||
<xs:attribute name="font-family" default="default" type="tns:fontFamily" use="optional" />
|
||||
<xs:attribute name="style" default="normal" type="tns:fontStyle" use="optional" />
|
||||
<xs:attribute name="size" default="0" type="tns:nonNegativeFloat" use="optional" />
|
||||
<xs:attribute name="bg-fill" default="#00000000" type="tns:color" use="optional" />
|
||||
<xs:attribute name="fill" default="#000000" type="tns:color" use="optional" />
|
||||
<xs:attribute name="stroke" default="#000000" type="tns:color" use="optional" />
|
||||
<xs:attribute name="stroke-width" default="0" type="tns:nonNegativeFloat" use="optional" />
|
||||
@@ -219,6 +220,7 @@
|
||||
<xs:attribute name="font-family" default="default" type="tns:fontFamily" use="optional" />
|
||||
<xs:attribute name="style" default="normal" type="tns:fontStyle" use="optional" />
|
||||
<xs:attribute name="size" default="0" type="tns:nonNegativeFloat" use="optional" />
|
||||
<xs:attribute name="bg-fill" default="#00000000" type="tns:color" use="optional" />
|
||||
<xs:attribute name="fill" default="#000000" type="tns:color" use="optional" />
|
||||
<xs:attribute name="stroke" default="#000000" type="tns:color" use="optional" />
|
||||
<xs:attribute name="stroke-width" default="0" type="tns:nonNegativeFloat" use="optional" />
|
||||
@@ -231,13 +233,21 @@
|
||||
|
||||
<xs:complexType name="symbol">
|
||||
<xs:attribute name="cat" type="xs:string" use="optional" />
|
||||
<xs:attribute name="src" type="tns:src" use="required" />
|
||||
|
||||
<xs:attribute name="id" default="0" type="xs:string" use="optional" />
|
||||
<xs:attribute name="use" default="0" type="xs:string" use="optional" />
|
||||
|
||||
<xs:attribute name="src" type="tns:src" use="optional" />
|
||||
<xs:attribute name="symbol-width" type="xs:positiveInteger" use="optional" />
|
||||
<xs:attribute name="symbol-height" type="xs:positiveInteger" use="optional" />
|
||||
<xs:attribute name="symbol-percent" type="xs:positiveInteger" use="optional" />
|
||||
|
||||
<!-- symbols on lines -->
|
||||
<xs:attribute name="billboard" default="false" type="xs:boolean" use="optional" />
|
||||
<xs:attribute name="repeat" default="false" type="xs:boolean" use="optional" />
|
||||
<xs:attribute name="repeat-gap" default="200" type="xs:float" use="optional" />
|
||||
<xs:attribute name="repeat-start" default="30" type="xs:float" use="optional" />
|
||||
<xs:attribute name="rotate" default="true" type="xs:boolean" use="optional" />
|
||||
</xs:complexType>
|
||||
|
||||
<xs:complexType name="extrusion">
|
||||
@@ -326,6 +336,7 @@
|
||||
<xs:sequence maxOccurs="256" minOccurs="0">
|
||||
<xs:choice maxOccurs="unbounded" minOccurs="0">
|
||||
<xs:element name="style-text" type="tns:text" />
|
||||
<xs:element name="style-symbol" type="tns:symbol" />
|
||||
<xs:element name="style-area" type="tns:area" />
|
||||
<xs:element name="style-line" type="tns:line" />
|
||||
<!-- <xs:element name="style-outline" type="tns:line" /> -->
|
||||
|
||||
@@ -3,8 +3,11 @@ include ':vtm'
|
||||
include ':vtm-android'
|
||||
include ':vtm-android-example'
|
||||
include ':vtm-android-gdx'
|
||||
include ':vtm-android-mvt'
|
||||
include ':vtm-app'
|
||||
include ':vtm-desktop'
|
||||
include ':vtm-desktop-lwjgl'
|
||||
include ':vtm-desktop-lwjgl3'
|
||||
include ':vtm-extras'
|
||||
include ':vtm-gdx'
|
||||
include ':vtm-gdx-poi3d'
|
||||
|
||||
@@ -7,12 +7,15 @@
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission
|
||||
android:name="android.permission.READ_EXTERNAL_STORAGE"
|
||||
android:maxSdkVersion="18" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:requestLegacyExternalStorage="true"
|
||||
android:usesCleartextTraffic="true">
|
||||
<activity
|
||||
android:name=".Samples"
|
||||
@@ -22,21 +25,18 @@
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".AtlasMarkerOverlayActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||
<activity
|
||||
android:name=".AtlasMultiTextureActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||
<activity
|
||||
android:name=".AtlasThemeActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||
<activity
|
||||
android:name=".BitmapTileActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||
<activity
|
||||
android:name=".ClusterMarkerOverlayActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||
<activity
|
||||
android:name=".FragmentActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||
<activity
|
||||
android:name=".GettingStarted"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||
@@ -49,9 +49,6 @@
|
||||
<activity
|
||||
android:name=".JeoIndoorActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||
<activity
|
||||
android:name=".LayerGroupActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||
<activity
|
||||
android:name=".LineTexActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||
@@ -61,21 +58,12 @@
|
||||
<activity
|
||||
android:name=".LocationTextureActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||
<activity
|
||||
android:name=".MapEventLayer2Activity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||
<activity
|
||||
android:name=".MapilionMvtActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||
<activity
|
||||
android:name=".MapsforgeActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||
<activity
|
||||
android:name=".MapsforgeActivity$MapFilePicker"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||
<activity
|
||||
android:name=".MapsforgeActivity$ThemeFilePicker"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||
<activity
|
||||
android:name=".MapsforgeS3DBActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||
@@ -92,7 +80,10 @@
|
||||
android:name=".MarkerOverlayActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||
<activity
|
||||
android:name=".MultiMapViewActivity"
|
||||
android:name=".MBTilesBitmapActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||
<activity
|
||||
android:name=".MBTilesMvtActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||
<activity
|
||||
android:name=".NextzenGeojsonActivity"
|
||||
@@ -103,9 +94,6 @@
|
||||
<activity
|
||||
android:name=".OpenMapTilesMvtActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||
<activity
|
||||
android:name=".OSciMapS3DBActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||
<activity
|
||||
android:name=".OverpassActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||
@@ -118,15 +106,9 @@
|
||||
<activity
|
||||
android:name=".PoiSearchActivity$PoiFilePicker"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||
<activity
|
||||
android:name=".POTTextureActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||
<activity
|
||||
android:name=".ReverseGeocodeActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||
<activity
|
||||
android:name=".RotateMarkerOverlayActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||
<activity
|
||||
android:name=".ShadowActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||
|
||||
@@ -1,14 +1,8 @@
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
/*
|
||||
configurations.all {
|
||||
// Check latest snapshot on every build
|
||||
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
|
||||
}
|
||||
*/
|
||||
|
||||
dependencies {
|
||||
implementation project(':vtm-android')
|
||||
implementation project(':vtm-android-mvt')
|
||||
implementation project(':vtm-extras')
|
||||
implementation project(':vtm-http')
|
||||
implementation project(':vtm-jeo')
|
||||
@@ -22,11 +16,11 @@ dependencies {
|
||||
implementation project(':vtm-gdx')
|
||||
implementation project(':vtm-gdx-poi3d')
|
||||
|
||||
implementation 'org.mapsforge:mapsforge-poi-android:master-SNAPSHOT'
|
||||
implementation 'org.mapsforge:sqlite-android:master-SNAPSHOT:natives-armeabi-v7a'
|
||||
implementation 'org.mapsforge:sqlite-android:master-SNAPSHOT:natives-arm64-v8a'
|
||||
implementation 'org.mapsforge:sqlite-android:master-SNAPSHOT:natives-x86'
|
||||
implementation 'org.mapsforge:sqlite-android:master-SNAPSHOT:natives-x86_64'
|
||||
implementation 'org.mapsforge:mapsforge-poi-android:0.16.0'
|
||||
implementation 'org.mapsforge:sqlite-android:0.16.0:natives-armeabi-v7a'
|
||||
implementation 'org.mapsforge:sqlite-android:0.16.0:natives-arm64-v8a'
|
||||
implementation 'org.mapsforge:sqlite-android:0.16.0:natives-x86'
|
||||
implementation 'org.mapsforge:sqlite-android:0.16.0:natives-x86_64'
|
||||
}
|
||||
|
||||
android {
|
||||
@@ -39,8 +33,8 @@ android {
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
versionCode versionCode()
|
||||
versionName versionName()
|
||||
versionCode project.versionCode()
|
||||
versionName project.versionName()
|
||||
minSdkVersion androidMinSdk()
|
||||
targetSdkVersion androidTargetSdk()
|
||||
}
|
||||
|
||||
12
vtm-android-example/res/layout/fragment_blank.xml
Normal file
12
vtm-android-example/res/layout/fragment_blank.xml
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@android:color/white">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:text="@string/empty_fragment_text" />
|
||||
|
||||
</RelativeLayout>
|
||||
@@ -1,9 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@android:color/white">
|
||||
|
||||
<org.oscim.android.MapView
|
||||
<RelativeLayout
|
||||
android:id="@+id/mapView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
9
vtm-android-example/res/menu/fragment_menu.xml
Normal file
9
vtm-android-example/res/menu/fragment_menu.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item
|
||||
android:id="@+id/replace_fragment"
|
||||
android:showAsAction="never"
|
||||
android:title="@string/replace_fragment" />
|
||||
|
||||
</menu>
|
||||
@@ -20,6 +20,9 @@
|
||||
<item
|
||||
android:id="@+id/theme_newtron"
|
||||
android:title="@string/theme_newtron" />
|
||||
<item
|
||||
android:id="@+id/theme_external_archive"
|
||||
android:title="@string/theme_external_archive" />
|
||||
<item
|
||||
android:id="@+id/theme_external"
|
||||
android:title="@string/theme_external" />
|
||||
|
||||
15
vtm-android-example/res/raw/marker.svg
Executable file
15
vtm-android-example/res/raw/marker.svg
Executable file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://www.w3.org/2000/svg" height="580" width="580" version="1.0" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/">
|
||||
<title>other</title>
|
||||
<metadata>
|
||||
<rdf:RDF>
|
||||
<cc:Work rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
|
||||
<dc:title>other</dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<circle opacity=".8" cx="290" cy="290" r="145" fill="#fff"/>
|
||||
<circle cy="290" cx="290" r="116" fill="#0092DA"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 651 B |
@@ -6,7 +6,8 @@
|
||||
<string name="theme_osmagray">Osmagray</string>
|
||||
<string name="theme_tubes">Tubes</string>
|
||||
<string name="theme_newtron">NewTron</string>
|
||||
<string name="theme_external">External theme</string>
|
||||
<string name="theme_external">External theme (Android 5)</string>
|
||||
<string name="theme_external_archive">External theme archive</string>
|
||||
<string name="styler_mode_line">Line</string>
|
||||
<string name="styler_mode_area">Area</string>
|
||||
<string name="styler_mode_outline">Outline</string>
|
||||
@@ -15,6 +16,7 @@
|
||||
<string name="style_2">Hide nature</string>
|
||||
<string name="menu_gridlayer">Grid</string>
|
||||
<string name="dialog_reverse_geocoding_title">Reverse Geocoding</string>
|
||||
<string name="dialog_theme_title">Select a theme</string>
|
||||
<string name="add">Add</string>
|
||||
<string name="cancel">Cancel</string>
|
||||
<string name="error">Error</string>
|
||||
@@ -25,5 +27,10 @@
|
||||
<string name="search_key">\'*\' or OSM key</string>
|
||||
<string name="search_value">void or value</string>
|
||||
<string name="now">Now</string>
|
||||
<string name="warning">Warning</string>
|
||||
<string name="startup_message_mbtiles">To run this sample activity, you need an MBTiles database installed on storage.\n\nadb push %s %s</string>
|
||||
<string name="exit">Exit</string>
|
||||
<string name="replace_fragment">Replace fragment</string>
|
||||
<string name="empty_fragment_text">This is a fragment to test the back stack behaviour of the map fragment.</string>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010, 2011, 2012 mapsforge.org
|
||||
* Copyright 2016 devemux86
|
||||
* Copyright 2016-2019 devemux86
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
@@ -22,11 +22,9 @@ import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.Editor;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.GridView;
|
||||
|
||||
import org.oscim.android.test.R;
|
||||
|
||||
import java.io.File;
|
||||
@@ -60,7 +58,6 @@ public class FilePicker extends Activity implements AdapterView.OnItemClickListe
|
||||
|
||||
private static final String PREFERENCES_FILE = "FilePicker";
|
||||
private static final String CURRENT_DIRECTORY = "currentDirectory";
|
||||
private static final String DEFAULT_DIRECTORY = Environment.getExternalStorageDirectory().getAbsolutePath();
|
||||
private static final int DIALOG_FILE_INVALID = 0;
|
||||
|
||||
// private static final int DIALOG_FILE_SELECT = 1;
|
||||
@@ -122,6 +119,7 @@ public class FilePicker extends Activity implements AdapterView.OnItemClickListe
|
||||
};
|
||||
}
|
||||
|
||||
private String mDefaultDirectory;
|
||||
private File mDirectory;
|
||||
private FilePickerIconAdapter mFilePickerIconAdapter;
|
||||
private File[] mFiles;
|
||||
@@ -164,7 +162,7 @@ public class FilePicker extends Activity implements AdapterView.OnItemClickListe
|
||||
}
|
||||
|
||||
// if a parent directory exists, add it at the first position
|
||||
if (mDirectory.getParentFile() != null) {
|
||||
if (mDirectory.getParentFile() != null && mDirectory.getParentFile().canRead()) {
|
||||
mFilesWithParentFolder = new File[mFiles.length + 1];
|
||||
mFilesWithParentFolder[0] = mDirectory.getParentFile();
|
||||
System.arraycopy(mFiles, 0, mFilesWithParentFolder, 1,
|
||||
@@ -182,6 +180,7 @@ public class FilePicker extends Activity implements AdapterView.OnItemClickListe
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_file_picker);
|
||||
|
||||
mDefaultDirectory = getExternalFilesDir(null) != null ? getExternalFilesDir(null).getAbsolutePath() : "/sdcard/";
|
||||
mFilePickerIconAdapter = new FilePickerIconAdapter(this);
|
||||
GridView gridView = (GridView) findViewById(R.id.filePickerView);
|
||||
gridView.setOnItemClickListener(this);
|
||||
@@ -239,10 +238,9 @@ public class FilePicker extends Activity implements AdapterView.OnItemClickListe
|
||||
// restore the current directory
|
||||
SharedPreferences preferences = getSharedPreferences(PREFERENCES_FILE,
|
||||
MODE_PRIVATE);
|
||||
mDirectory = new File(preferences.getString(CURRENT_DIRECTORY,
|
||||
DEFAULT_DIRECTORY));
|
||||
mDirectory = new File(preferences.getString(CURRENT_DIRECTORY, mDefaultDirectory));
|
||||
if (!mDirectory.exists() || !mDirectory.canRead()) {
|
||||
mDirectory = new File(DEFAULT_DIRECTORY);
|
||||
mDirectory = new File(mDefaultDirectory);
|
||||
}
|
||||
browseToCurrentDirectory();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010, 2011, 2012 mapsforge.org
|
||||
* Copyright 2016-2018 devemux86
|
||||
* Copyright 2016-2020 devemux86
|
||||
* Copyright 2017 Longri
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
@@ -16,18 +16,11 @@
|
||||
*/
|
||||
package org.oscim.android.filepicker;
|
||||
|
||||
import org.oscim.theme.ExternalRenderTheme;
|
||||
import org.oscim.theme.ThemeFile;
|
||||
import org.oscim.theme.XmlThemeBuilder;
|
||||
import org.oscim.theme.ThemeLoader;
|
||||
import org.oscim.tiling.TileSource.OpenResult;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.XMLReader;
|
||||
import org.xml.sax.helpers.DefaultHandler;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import javax.xml.parsers.SAXParserFactory;
|
||||
|
||||
/**
|
||||
* Accepts all valid render theme XML files.
|
||||
*/
|
||||
@@ -36,13 +29,8 @@ public final class ValidRenderTheme implements ValidFileFilter {
|
||||
|
||||
@Override
|
||||
public boolean accept(File file) {
|
||||
|
||||
try {
|
||||
ThemeFile theme = new ExternalRenderTheme(file.getAbsolutePath());
|
||||
DefaultHandler renderThemeHandler = new XmlThemeBuilder(theme);
|
||||
XMLReader xmlReader = SAXParserFactory.newInstance().newSAXParser().getXMLReader();
|
||||
xmlReader.setContentHandler(renderThemeHandler);
|
||||
xmlReader.parse(new InputSource(theme.getRenderThemeAsStream()));
|
||||
ThemeLoader.load(file.getAbsolutePath());
|
||||
mOpenResult = OpenResult.SUCCESS;
|
||||
} catch (Exception e) {
|
||||
mOpenResult = new OpenResult(e.getMessage());
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 Hannes Janetzek
|
||||
* Copyright 2016-2018 devemux86
|
||||
* Copyright 2017 Longri
|
||||
*
|
||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.android.test;
|
||||
|
||||
import org.oscim.backend.canvas.Bitmap;
|
||||
import org.oscim.core.GeoPoint;
|
||||
import org.oscim.layers.marker.ItemizedLayer;
|
||||
import org.oscim.layers.marker.MarkerItem;
|
||||
import org.oscim.layers.marker.MarkerSymbol;
|
||||
import org.oscim.layers.marker.MarkerSymbol.HotspotPlace;
|
||||
import org.oscim.layers.tile.bitmap.BitmapTileLayer;
|
||||
import org.oscim.renderer.atlas.TextureAtlas;
|
||||
import org.oscim.renderer.atlas.TextureRegion;
|
||||
import org.oscim.tiling.TileSource;
|
||||
import org.oscim.tiling.source.OkHttpEngine;
|
||||
import org.oscim.tiling.source.bitmap.DefaultSources;
|
||||
import org.oscim.utils.TextureAtlasUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
import static org.oscim.android.canvas.AndroidGraphics.drawableToBitmap;
|
||||
|
||||
public class AtlasMarkerOverlayActivity extends MarkerOverlayActivity {
|
||||
|
||||
@Override
|
||||
void createLayers() {
|
||||
// Map events receiver
|
||||
mMap.layers().add(new MapEventsReceiver(mMap));
|
||||
|
||||
TileSource tileSource = DefaultSources.OPENSTREETMAP
|
||||
.httpFactory(new OkHttpEngine.OkHttpFactory())
|
||||
.build();
|
||||
mMap.layers().add(new BitmapTileLayer(mMap, tileSource));
|
||||
|
||||
Bitmap bitmapPoi = drawableToBitmap(getResources().getDrawable(R.drawable.marker_poi));
|
||||
Bitmap bitmapFocus = drawableToBitmap(getResources().getDrawable(R.drawable.marker_focus));
|
||||
|
||||
// Create Atlas from Bitmaps
|
||||
java.util.Map<Object, Bitmap> inputMap = new LinkedHashMap<>();
|
||||
java.util.Map<Object, TextureRegion> regionsMap = new LinkedHashMap<>();
|
||||
List<TextureAtlas> atlasList = new ArrayList<>();
|
||||
|
||||
inputMap.put("poi", bitmapPoi);
|
||||
inputMap.put("focus", bitmapFocus);
|
||||
|
||||
// Bitmaps will never used any more
|
||||
// With iOS we must flip the Y-Axis
|
||||
TextureAtlasUtils.createTextureRegions(inputMap, regionsMap, atlasList, true, false);
|
||||
|
||||
MarkerSymbol symbol;
|
||||
if (BILLBOARDS)
|
||||
symbol = new MarkerSymbol(regionsMap.get("poi"), HotspotPlace.BOTTOM_CENTER);
|
||||
else
|
||||
symbol = new MarkerSymbol(regionsMap.get("poi"), HotspotPlace.CENTER, false);
|
||||
|
||||
if (BILLBOARDS)
|
||||
mFocusMarker = new MarkerSymbol(regionsMap.get("focus"), HotspotPlace.BOTTOM_CENTER);
|
||||
else
|
||||
mFocusMarker = new MarkerSymbol(regionsMap.get("focus"), HotspotPlace.CENTER, false);
|
||||
|
||||
mMarkerLayer = new ItemizedLayer<>(mMap, new ArrayList<MarkerItem>(), symbol, this);
|
||||
mMap.layers().add(mMarkerLayer);
|
||||
|
||||
List<MarkerItem> pts = new ArrayList<>();
|
||||
|
||||
for (double lat = -90; lat <= 90; lat += 5) {
|
||||
for (double lon = -180; lon <= 180; lon += 5)
|
||||
pts.add(new MarkerItem(lat + "/" + lon, "", new GeoPoint(lat, lon)));
|
||||
}
|
||||
|
||||
mMarkerLayer.addItems(pts);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright 2014 Hannes Janetzek
|
||||
* Copyright 2016-2018 devemux86
|
||||
* Copyright 2016-2020 devemux86
|
||||
* Copyright 2017 Longri
|
||||
*
|
||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||
@@ -19,7 +19,6 @@
|
||||
package org.oscim.android.test;
|
||||
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.oscim.backend.CanvasAdapter;
|
||||
import org.oscim.backend.canvas.Bitmap;
|
||||
import org.oscim.backend.canvas.Canvas;
|
||||
@@ -27,18 +26,20 @@ import org.oscim.backend.canvas.Color;
|
||||
import org.oscim.backend.canvas.Paint;
|
||||
import org.oscim.core.GeoPoint;
|
||||
import org.oscim.layers.marker.ItemizedLayer;
|
||||
import org.oscim.layers.marker.MarkerInterface;
|
||||
import org.oscim.layers.marker.MarkerItem;
|
||||
import org.oscim.layers.marker.MarkerSymbol;
|
||||
import org.oscim.layers.marker.MarkerSymbol.HotspotPlace;
|
||||
import org.oscim.layers.tile.bitmap.BitmapTileLayer;
|
||||
import org.oscim.renderer.atlas.TextureAtlas;
|
||||
import org.oscim.renderer.atlas.TextureRegion;
|
||||
import org.oscim.tiling.TileSource;
|
||||
import org.oscim.tiling.source.OkHttpEngine;
|
||||
import org.oscim.tiling.source.UrlTileSource;
|
||||
import org.oscim.tiling.source.bitmap.DefaultSources;
|
||||
import org.oscim.utils.TextureAtlasUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
@@ -49,9 +50,10 @@ public class AtlasMultiTextureActivity extends MarkerOverlayActivity {
|
||||
// Map events receiver
|
||||
mMap.layers().add(new MapEventsReceiver(mMap));
|
||||
|
||||
TileSource tileSource = DefaultSources.OPENSTREETMAP
|
||||
UrlTileSource tileSource = DefaultSources.OPENSTREETMAP
|
||||
.httpFactory(new OkHttpEngine.OkHttpFactory())
|
||||
.build();
|
||||
tileSource.setHttpRequestHeaders(Collections.singletonMap("User-Agent", "vtm-android-example"));
|
||||
mMap.layers().add(new BitmapTileLayer(mMap, tileSource));
|
||||
|
||||
// Create Atlas from Bitmaps
|
||||
@@ -65,7 +67,7 @@ public class AtlasMultiTextureActivity extends MarkerOverlayActivity {
|
||||
paint.setTextSize(12 * CanvasAdapter.getScale());
|
||||
paint.setStrokeWidth(2 * CanvasAdapter.getScale());
|
||||
paint.setColor(Color.BLACK);
|
||||
List<MarkerItem> pts = new ArrayList<>();
|
||||
List<MarkerInterface> pts = new ArrayList<>();
|
||||
for (double lat = -90; lat <= 90; lat += 10) {
|
||||
for (double lon = -180; lon <= 180; lon += 10) {
|
||||
String title = lat + "/" + lon;
|
||||
@@ -85,29 +87,32 @@ public class AtlasMultiTextureActivity extends MarkerOverlayActivity {
|
||||
// With iOS we must flip the Y-Axis
|
||||
TextureAtlasUtils.createTextureRegions(inputMap, regionsMap, atlasList, true, false);
|
||||
|
||||
mMarkerLayer = new ItemizedLayer<>(mMap, new ArrayList<MarkerItem>(), (MarkerSymbol) null, this);
|
||||
mMarkerLayer = new ItemizedLayer(mMap, new ArrayList<MarkerInterface>(), (MarkerSymbol) null, this);
|
||||
mMap.layers().add(mMarkerLayer);
|
||||
|
||||
mMarkerLayer.addItems(pts);
|
||||
|
||||
// set all markers
|
||||
for (MarkerItem item : pts) {
|
||||
MarkerSymbol markerSymbol = new MarkerSymbol(regionsMap.get(item.getTitle()), HotspotPlace.BOTTOM_CENTER);
|
||||
item.setMarker(markerSymbol);
|
||||
for (MarkerInterface item : pts) {
|
||||
MarkerItem markerItem = (MarkerItem) item;
|
||||
MarkerSymbol markerSymbol = new MarkerSymbol(regionsMap.get(markerItem.getTitle()), HotspotPlace.BOTTOM_CENTER);
|
||||
markerItem.setMarker(markerSymbol);
|
||||
}
|
||||
|
||||
Toast.makeText(this, "Atlas count: " + atlasList.size(), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemSingleTapUp(int index, MarkerItem item) {
|
||||
Toast.makeText(this, "Marker tap\n" + item.getTitle(), Toast.LENGTH_SHORT).show();
|
||||
public boolean onItemSingleTapUp(int index, MarkerInterface item) {
|
||||
MarkerItem markerItem = (MarkerItem) item;
|
||||
Toast.makeText(this, "Marker tap\n" + markerItem.getTitle(), Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemLongPress(int index, MarkerItem item) {
|
||||
Toast.makeText(this, "Marker long press\n" + item.getTitle(), Toast.LENGTH_SHORT).show();
|
||||
public boolean onItemLongPress(int index, MarkerInterface item) {
|
||||
MarkerItem markerItem = (MarkerItem) item;
|
||||
Toast.makeText(this, "Marker long press\n" + markerItem.getTitle(), Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright 2013 Hannes Janetzek
|
||||
* Copyright 2016-2018 devemux86
|
||||
* Copyright 2016-2020 devemux86
|
||||
*
|
||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||
*
|
||||
@@ -20,8 +20,8 @@ package org.oscim.android.test;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import org.oscim.android.cache.TileCache;
|
||||
import okhttp3.Cache;
|
||||
import okhttp3.OkHttpClient;
|
||||
import org.oscim.core.MapPosition;
|
||||
import org.oscim.layers.TileGridLayer;
|
||||
import org.oscim.layers.tile.vector.VectorTileLayer;
|
||||
@@ -29,11 +29,10 @@ import org.oscim.theme.VtmThemes;
|
||||
import org.oscim.tiling.TileSource;
|
||||
import org.oscim.tiling.source.OkHttpEngine;
|
||||
import org.oscim.tiling.source.oscimap4.OSciMap4TileSource;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class BaseMapActivity extends MapActivity {
|
||||
static final Logger log = LoggerFactory.getLogger(BaseMapActivity.class);
|
||||
|
||||
static final boolean USE_CACHE = false;
|
||||
|
||||
@@ -41,8 +40,6 @@ public class BaseMapActivity extends MapActivity {
|
||||
TileSource mTileSource;
|
||||
TileGridLayer mGridLayer;
|
||||
|
||||
private TileCache mCache;
|
||||
|
||||
public BaseMapActivity(int contentView) {
|
||||
super(contentView);
|
||||
}
|
||||
@@ -54,15 +51,19 @@ public class BaseMapActivity extends MapActivity {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
OkHttpClient.Builder builder = new OkHttpClient.Builder();
|
||||
if (USE_CACHE) {
|
||||
// Cache the tiles into file system
|
||||
File cacheDirectory = new File(getExternalCacheDir(), "tiles");
|
||||
int cacheSize = 10 * 1024 * 1024; // 10 MB
|
||||
Cache cache = new Cache(cacheDirectory, cacheSize);
|
||||
builder.cache(cache);
|
||||
}
|
||||
|
||||
mTileSource = OSciMap4TileSource.builder()
|
||||
.httpFactory(new OkHttpEngine.OkHttpFactory())
|
||||
.httpFactory(new OkHttpEngine.OkHttpFactory(builder))
|
||||
.build();
|
||||
|
||||
if (USE_CACHE) {
|
||||
mCache = new TileCache(this, null, "tile.db");
|
||||
mCache.setCacheSize(512 * (1 << 10));
|
||||
mTileSource.setCache(mCache);
|
||||
}
|
||||
mBaseLayer = mMap.setBaseMap(mTileSource);
|
||||
|
||||
/* set initial position on first run */
|
||||
@@ -72,14 +73,6 @@ public class BaseMapActivity extends MapActivity {
|
||||
mMap.setMapPosition(53.08, 8.83, Math.pow(2, 16));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
if (mCache != null)
|
||||
mCache.dispose();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright 2014 Hannes Janetzek
|
||||
* Copyright 2017-2018 devemux86
|
||||
* Copyright 2017-2020 devemux86
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
@@ -16,21 +16,21 @@
|
||||
package org.oscim.android.test;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import org.oscim.android.cache.TileCache;
|
||||
import okhttp3.Cache;
|
||||
import okhttp3.OkHttpClient;
|
||||
import org.oscim.core.MapPosition;
|
||||
import org.oscim.core.MercatorProjection;
|
||||
import org.oscim.layers.tile.bitmap.BitmapTileLayer;
|
||||
import org.oscim.renderer.MapRenderer;
|
||||
import org.oscim.tiling.source.OkHttpEngine;
|
||||
import org.oscim.tiling.source.bitmap.BitmapTileSource;
|
||||
import org.oscim.tiling.source.bitmap.DefaultSources;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
|
||||
public class BitmapTileActivity extends MapActivity {
|
||||
|
||||
static final Logger log = LoggerFactory.getLogger(BitmapTileActivity.class);
|
||||
|
||||
private static final boolean USE_CACHE = false;
|
||||
|
||||
private final BitmapTileSource mTileSource;
|
||||
@@ -45,8 +45,6 @@ public class BitmapTileActivity extends MapActivity {
|
||||
mTileSource = tileSource;
|
||||
}
|
||||
|
||||
private TileCache mCache;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@@ -56,31 +54,24 @@ public class BitmapTileActivity extends MapActivity {
|
||||
if (mTileSource == null)
|
||||
return;
|
||||
|
||||
OkHttpClient.Builder builder = new OkHttpClient.Builder();
|
||||
if (USE_CACHE) {
|
||||
String cacheFile = mTileSource.getUrl()
|
||||
.toString()
|
||||
.replaceFirst("https?://", "")
|
||||
.replaceAll("/", "-");
|
||||
|
||||
log.debug("use bitmap cache {}", cacheFile);
|
||||
mCache = new TileCache(this, null, cacheFile);
|
||||
mCache.setCacheSize(512 * (1 << 10));
|
||||
mTileSource.setCache(mCache);
|
||||
// Cache the tiles into file system
|
||||
File cacheDirectory = new File(getExternalCacheDir(), "tiles");
|
||||
int cacheSize = 10 * 1024 * 1024; // 10 MB
|
||||
Cache cache = new Cache(cacheDirectory, cacheSize);
|
||||
builder.cache(cache);
|
||||
}
|
||||
|
||||
mTileSource.setHttpEngine(new OkHttpEngine.OkHttpFactory(builder));
|
||||
mTileSource.setHttpRequestHeaders(Collections.singletonMap("User-Agent", "vtm-android-example"));
|
||||
|
||||
mBitmapLayer = new BitmapTileLayer(mMap, mTileSource);
|
||||
mMap.layers().add(mBitmapLayer);
|
||||
|
||||
//loooop(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (mCache != null)
|
||||
mCache.dispose();
|
||||
}
|
||||
|
||||
// Stress testing
|
||||
void loooop(final int i) {
|
||||
final long time = (long) (500 + Math.random() * 1000);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017 Longri
|
||||
* Copyright 2017-2018 devemux86
|
||||
* Copyright 2020 Meibes
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
@@ -15,23 +14,25 @@
|
||||
*/
|
||||
package org.oscim.android.test;
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import org.oscim.utils.Parameters;
|
||||
@SuppressWarnings("deprecation")
|
||||
public class BlankFragment extends Fragment {
|
||||
|
||||
public class AtlasThemeActivity extends SimpleMapActivity {
|
||||
static BlankFragment newInstance() {
|
||||
BlankFragment instance = new BlankFragment();
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
Parameters.TEXTURE_ATLAS = true;
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
Bundle args = new Bundle();
|
||||
instance.setArguments(args);
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
Parameters.TEXTURE_ATLAS = false;
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_blank, container, false);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2018 devemux86
|
||||
* Copyright 2016-2020 devemux86
|
||||
* Copyright 2017 nebular
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
@@ -15,26 +15,21 @@
|
||||
*/
|
||||
package org.oscim.android.test;
|
||||
|
||||
import android.graphics.BitmapFactory;
|
||||
import org.oscim.android.canvas.AndroidBitmap;
|
||||
import org.oscim.backend.canvas.Bitmap;
|
||||
import org.oscim.backend.canvas.Color;
|
||||
import org.oscim.core.GeoPoint;
|
||||
import org.oscim.layers.marker.ClusterMarkerRenderer;
|
||||
import org.oscim.layers.marker.ItemizedLayer;
|
||||
import org.oscim.layers.marker.MarkerItem;
|
||||
import org.oscim.layers.marker.MarkerLayer;
|
||||
import org.oscim.layers.marker.MarkerRenderer;
|
||||
import org.oscim.layers.marker.MarkerRendererFactory;
|
||||
import org.oscim.layers.marker.MarkerSymbol;
|
||||
import org.oscim.layers.marker.*;
|
||||
import org.oscim.layers.tile.bitmap.BitmapTileLayer;
|
||||
import org.oscim.tiling.TileSource;
|
||||
import org.oscim.tiling.source.OkHttpEngine;
|
||||
import org.oscim.tiling.source.UrlTileSource;
|
||||
import org.oscim.tiling.source.bitmap.DefaultSources;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.oscim.android.canvas.AndroidGraphics.drawableToBitmap;
|
||||
|
||||
public class ClusterMarkerOverlayActivity extends MarkerOverlayActivity {
|
||||
|
||||
private static final int COUNT = 5;
|
||||
@@ -45,12 +40,13 @@ public class ClusterMarkerOverlayActivity extends MarkerOverlayActivity {
|
||||
// Map events receiver
|
||||
mMap.layers().add(new MapEventsReceiver(mMap));
|
||||
|
||||
TileSource tileSource = DefaultSources.OPENSTREETMAP
|
||||
UrlTileSource tileSource = DefaultSources.OPENSTREETMAP
|
||||
.httpFactory(new OkHttpEngine.OkHttpFactory())
|
||||
.build();
|
||||
tileSource.setHttpRequestHeaders(Collections.singletonMap("User-Agent", "vtm-android-example"));
|
||||
mMap.layers().add(new BitmapTileLayer(mMap, tileSource));
|
||||
|
||||
Bitmap bitmapPoi = drawableToBitmap(getResources().getDrawable(R.drawable.marker_poi));
|
||||
Bitmap bitmapPoi = new AndroidBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.marker_poi));
|
||||
final MarkerSymbol symbol;
|
||||
if (BILLBOARDS)
|
||||
symbol = new MarkerSymbol(bitmapPoi, MarkerSymbol.HotspotPlace.BOTTOM_CENTER);
|
||||
@@ -69,15 +65,15 @@ public class ClusterMarkerOverlayActivity extends MarkerOverlayActivity {
|
||||
};
|
||||
}
|
||||
};
|
||||
mMarkerLayer = new ItemizedLayer<>(
|
||||
mMarkerLayer = new ItemizedLayer(
|
||||
mMap,
|
||||
new ArrayList<MarkerItem>(),
|
||||
new ArrayList<MarkerInterface>(),
|
||||
markerRendererFactory,
|
||||
this);
|
||||
mMap.layers().add(mMarkerLayer);
|
||||
|
||||
// Create some markers spaced STEP degrees
|
||||
List<MarkerItem> pts = new ArrayList<>();
|
||||
List<MarkerInterface> pts = new ArrayList<>();
|
||||
mMap.setMapPosition(53.08, 8.83, 1 << 15);
|
||||
GeoPoint center = mMap.getMapPosition().getGeoPoint();
|
||||
for (int x = -COUNT; x < COUNT; x++) {
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright 2020 Meibes
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.android.test;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Fragment;
|
||||
import android.app.FragmentTransaction;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
|
||||
public class FragmentActivity extends Activity {
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_map_fragment);
|
||||
|
||||
setTitle(getClass().getSimpleName());
|
||||
|
||||
if (savedInstanceState == null) {
|
||||
Fragment mapFragment = MapFragment.newInstance();
|
||||
FragmentTransaction ft = getFragmentManager().beginTransaction();
|
||||
ft.add(R.id.fragment_container, mapFragment).commit();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.fragment_menu, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (item.getItemId() == R.id.replace_fragment) {
|
||||
Fragment blankFragment = BlankFragment.newInstance();
|
||||
FragmentTransaction ft = getFragmentManager().beginTransaction();
|
||||
ft.replace(R.id.fragment_container, blankFragment);
|
||||
ft.addToBackStack(null);
|
||||
ft.commit();
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright 2013 Hannes Janetzek
|
||||
* Copyright 2016-2018 devemux86
|
||||
* Copyright 2016-2020 devemux86
|
||||
* Copyright 2018-2019 Gustl22
|
||||
*
|
||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||
@@ -71,7 +71,7 @@ public class GdxActivity extends AndroidApplication {
|
||||
DateTimeAdapter.init(new DateTime());
|
||||
|
||||
DisplayMetrics metrics = getResources().getDisplayMetrics();
|
||||
CanvasAdapter.dpi = (int) (metrics.scaledDensity * CanvasAdapter.DEFAULT_DPI);
|
||||
CanvasAdapter.dpi = (int) (metrics.density * CanvasAdapter.DEFAULT_DPI);
|
||||
Tile.SIZE = Tile.calculateTileSize();
|
||||
|
||||
AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018-2019 devemux86
|
||||
* Copyright 2018-2020 devemux86
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
@@ -15,9 +15,10 @@
|
||||
package org.oscim.android.test;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
|
||||
import org.oscim.android.MapView;
|
||||
import org.oscim.backend.CanvasAdapter;
|
||||
import org.oscim.layers.tile.buildings.BuildingLayer;
|
||||
@@ -27,10 +28,11 @@ import org.oscim.renderer.GLViewport;
|
||||
import org.oscim.scalebar.DefaultMapScaleBar;
|
||||
import org.oscim.scalebar.MapScaleBar;
|
||||
import org.oscim.scalebar.MapScaleBarLayer;
|
||||
import org.oscim.theme.IRenderTheme;
|
||||
import org.oscim.theme.VtmThemes;
|
||||
import org.oscim.tiling.source.mapfile.MapFileTileSource;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
|
||||
/**
|
||||
* A very basic Android app example.
|
||||
@@ -39,11 +41,11 @@ import java.io.File;
|
||||
*/
|
||||
public class GettingStarted extends Activity {
|
||||
|
||||
// Name of the map file in device storage
|
||||
private static final String MAP_FILE = "berlin.map";
|
||||
// Request code for selecting a map file
|
||||
private static final int SELECT_MAP_FILE = 0;
|
||||
|
||||
private MapView mapView;
|
||||
private MapScaleBar mapScaleBar;
|
||||
private IRenderTheme theme;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
@@ -53,10 +55,30 @@ public class GettingStarted extends Activity {
|
||||
mapView = new MapView(this);
|
||||
setContentView(mapView);
|
||||
|
||||
// Tile source
|
||||
MapFileTileSource tileSource = new MapFileTileSource();
|
||||
String mapPath = new File(Environment.getExternalStorageDirectory(), MAP_FILE).getAbsolutePath();
|
||||
if (tileSource.setMapFile(mapPath)) {
|
||||
// Open map
|
||||
Intent intent = new Intent(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT ? Intent.ACTION_OPEN_DOCUMENT : Intent.ACTION_GET_CONTENT);
|
||||
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||
intent.setType("*/*");
|
||||
startActivityForResult(intent, SELECT_MAP_FILE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (requestCode == SELECT_MAP_FILE && resultCode == Activity.RESULT_OK) {
|
||||
if (data != null) {
|
||||
Uri uri = data.getData();
|
||||
openMap(uri);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void openMap(Uri uri) {
|
||||
try {
|
||||
// Tile source
|
||||
MapFileTileSource tileSource = new MapFileTileSource();
|
||||
FileInputStream fis = (FileInputStream) getContentResolver().openInputStream(uri);
|
||||
tileSource.setMapFileInputStream(fis);
|
||||
|
||||
// Vector layer
|
||||
VectorTileLayer tileLayer = mapView.map().setBaseMap(tileSource);
|
||||
|
||||
@@ -67,10 +89,10 @@ public class GettingStarted extends Activity {
|
||||
mapView.map().layers().add(new LabelLayer(mapView.map(), tileLayer));
|
||||
|
||||
// Render theme
|
||||
mapView.map().setTheme(VtmThemes.DEFAULT);
|
||||
theme = mapView.map().setTheme(VtmThemes.DEFAULT);
|
||||
|
||||
// Scale bar
|
||||
mapScaleBar = new DefaultMapScaleBar(mapView.map());
|
||||
MapScaleBar mapScaleBar = new DefaultMapScaleBar(mapView.map());
|
||||
MapScaleBarLayer mapScaleBarLayer = new MapScaleBarLayer(mapView.map(), mapScaleBar);
|
||||
mapScaleBarLayer.getRenderer().setPosition(GLViewport.Position.BOTTOM_LEFT);
|
||||
mapScaleBarLayer.getRenderer().setOffset(5 * CanvasAdapter.getScale(), 0);
|
||||
@@ -78,6 +100,11 @@ public class GettingStarted extends Activity {
|
||||
|
||||
// Note: this map position is specific to Berlin area
|
||||
mapView.map().setMapPosition(52.517037, 13.38886, 1 << 12);
|
||||
} catch (Exception e) {
|
||||
/*
|
||||
* In case of map file errors avoid crash, but developers should handle these cases!
|
||||
*/
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,9 +122,8 @@ public class GettingStarted extends Activity {
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
if (mapScaleBar != null)
|
||||
mapScaleBar.destroy();
|
||||
mapView.onDestroy();
|
||||
theme.dispose();
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,9 +22,8 @@ import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
import android.widget.ToggleButton;
|
||||
|
||||
import org.jeo.map.Style;
|
||||
import org.jeo.vector.VectorDataset;
|
||||
import io.jeo.map.Style;
|
||||
import io.jeo.vector.VectorDataset;
|
||||
import org.oscim.backend.CanvasAdapter;
|
||||
import org.oscim.backend.canvas.Color;
|
||||
import org.oscim.layers.OSMIndoorLayer;
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013 Hannes Janetzek
|
||||
* Copyright 2016-2018 devemux86
|
||||
* Copyright 2016 Andrey Novikov
|
||||
*
|
||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.android.test;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import org.oscim.backend.CanvasAdapter;
|
||||
import org.oscim.layers.tile.buildings.BuildingLayer;
|
||||
import org.oscim.layers.tile.vector.labeling.LabelLayer;
|
||||
import org.oscim.map.Layers;
|
||||
import org.oscim.renderer.BitmapRenderer;
|
||||
import org.oscim.renderer.GLViewport;
|
||||
import org.oscim.scalebar.DefaultMapScaleBar;
|
||||
import org.oscim.scalebar.ImperialUnitAdapter;
|
||||
import org.oscim.scalebar.MapScaleBar;
|
||||
import org.oscim.scalebar.MapScaleBarLayer;
|
||||
import org.oscim.scalebar.MetricUnitAdapter;
|
||||
import org.oscim.theme.VtmThemes;
|
||||
|
||||
public class LayerGroupActivity extends BaseMapActivity {
|
||||
|
||||
private static final int GROUP_3D_OBJECTS = 1;
|
||||
private static final int GROUP_LABELS = 2;
|
||||
private static final int GROUP_OVERLAYS = 3;
|
||||
|
||||
private DefaultMapScaleBar mapScaleBar;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
Layers layers = mMap.layers();
|
||||
|
||||
layers.addGroup(GROUP_3D_OBJECTS);
|
||||
layers.add(new BuildingLayer(mMap, mBaseLayer), GROUP_3D_OBJECTS);
|
||||
|
||||
layers.addGroup(GROUP_LABELS);
|
||||
layers.add(new LabelLayer(mMap, mBaseLayer), GROUP_LABELS);
|
||||
|
||||
mapScaleBar = new DefaultMapScaleBar(mMap);
|
||||
mapScaleBar.setScaleBarMode(DefaultMapScaleBar.ScaleBarMode.BOTH);
|
||||
mapScaleBar.setDistanceUnitAdapter(MetricUnitAdapter.INSTANCE);
|
||||
mapScaleBar.setSecondaryDistanceUnitAdapter(ImperialUnitAdapter.INSTANCE);
|
||||
mapScaleBar.setScaleBarPosition(MapScaleBar.ScaleBarPosition.BOTTOM_LEFT);
|
||||
|
||||
MapScaleBarLayer mapScaleBarLayer = new MapScaleBarLayer(mMap, mapScaleBar);
|
||||
BitmapRenderer renderer = mapScaleBarLayer.getRenderer();
|
||||
renderer.setPosition(GLViewport.Position.BOTTOM_LEFT);
|
||||
renderer.setOffset(5 * CanvasAdapter.getScale(), 0);
|
||||
|
||||
layers.addGroup(GROUP_OVERLAYS);
|
||||
layers.add(mapScaleBarLayer, GROUP_OVERLAYS);
|
||||
|
||||
mMap.setTheme(VtmThemes.DEFAULT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
if (mapScaleBar != null)
|
||||
mapScaleBar.destroy();
|
||||
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright 2014 Hannes Janetzek
|
||||
* Copyright 2016-2018 devemux86
|
||||
* Copyright 2016-2019 devemux86
|
||||
*
|
||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||
*
|
||||
@@ -18,7 +18,6 @@
|
||||
package org.oscim.android.test;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import org.oscim.backend.CanvasAdapter;
|
||||
import org.oscim.backend.canvas.Color;
|
||||
import org.oscim.core.MapPosition;
|
||||
@@ -38,7 +37,7 @@ import java.util.List;
|
||||
*/
|
||||
public class LineTexActivity extends BitmapTileActivity {
|
||||
|
||||
private static final boolean ANIMATION = false;
|
||||
private static final boolean ANIMATION = true;
|
||||
|
||||
private List<PathLayer> mPathLayers = new ArrayList<>();
|
||||
|
||||
@@ -49,7 +48,7 @@ public class LineTexActivity extends BitmapTileActivity {
|
||||
TextureItem tex = null;
|
||||
try {
|
||||
tex = new TextureItem(CanvasAdapter.getBitmapAsset("", "patterns/pike.png"));
|
||||
tex.mipmap = true;
|
||||
//tex.mipmap = true;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2018 devemux86
|
||||
* Copyright 2016-2019 devemux86
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
@@ -14,16 +14,20 @@
|
||||
*/
|
||||
package org.oscim.android.test;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.location.Location;
|
||||
import android.location.LocationListener;
|
||||
import android.location.LocationManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
|
||||
import org.oscim.core.MapPosition;
|
||||
import org.oscim.layers.LocationLayer;
|
||||
import org.oscim.renderer.LocationCallback;
|
||||
|
||||
public class LocationActivity extends BitmapTileActivity implements LocationListener {
|
||||
private Location location;
|
||||
private LocationLayer locationLayer;
|
||||
private LocationManager locationManager;
|
||||
private final MapPosition mapPosition = new MapPosition();
|
||||
@@ -35,27 +39,46 @@ public class LocationActivity extends BitmapTileActivity implements LocationList
|
||||
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
|
||||
|
||||
locationLayer = new LocationLayer(mMap);
|
||||
locationLayer.locationRenderer.setShader("location_1_reverse");
|
||||
locationLayer.locationRenderer.setCallback(new LocationCallback() {
|
||||
@Override
|
||||
public boolean hasRotation() {
|
||||
return location != null && location.hasBearing();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getRotation() {
|
||||
return location != null && location.hasBearing() ? location.getBearing() : 0;
|
||||
}
|
||||
});
|
||||
locationLayer.setEnabled(false);
|
||||
mMap.layers().add(locationLayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
public void onRequestPermissionsResult(final int requestCode, final String[] permissions, final int[] grantResults) {
|
||||
if (requestCode == 0) {
|
||||
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED)
|
||||
enableAvailableProviders();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
|
||||
enableAvailableProviders();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
|
||||
public void onStop() {
|
||||
locationManager.removeUpdates(this);
|
||||
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocationChanged(Location location) {
|
||||
this.location = location;
|
||||
locationLayer.setEnabled(true);
|
||||
locationLayer.setPosition(location.getLatitude(), location.getLongitude(), location.getAccuracy());
|
||||
|
||||
@@ -78,6 +101,13 @@ public class LocationActivity extends BitmapTileActivity implements LocationList
|
||||
}
|
||||
|
||||
private void enableAvailableProviders() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||
requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
locationManager.removeUpdates(this);
|
||||
|
||||
for (String provider : locationManager.getProviders(true)) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2018 devemux86
|
||||
* Copyright 2016-2019 devemux86
|
||||
* Copyright 2018 Longri
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
@@ -15,26 +15,26 @@
|
||||
*/
|
||||
package org.oscim.android.test;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.location.Location;
|
||||
import android.location.LocationListener;
|
||||
import android.location.LocationManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
|
||||
import org.oscim.backend.CanvasAdapter;
|
||||
import org.oscim.backend.canvas.Bitmap;
|
||||
import org.oscim.backend.canvas.Color;
|
||||
import org.oscim.core.MapPosition;
|
||||
import org.oscim.layers.LocationTextureLayer;
|
||||
import org.oscim.renderer.atlas.TextureAtlas;
|
||||
import org.oscim.renderer.atlas.TextureRegion;
|
||||
import org.oscim.renderer.bucket.TextureItem;
|
||||
import org.oscim.renderer.LocationCallback;
|
||||
import org.oscim.utils.IOUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class LocationTextureActivity extends BitmapTileActivity implements LocationListener {
|
||||
private Location location;
|
||||
private LocationTextureLayer locationLayer;
|
||||
private LocationManager locationManager;
|
||||
private final MapPosition mapPosition = new MapPosition();
|
||||
@@ -45,56 +45,72 @@ public class LocationTextureActivity extends BitmapTileActivity implements Locat
|
||||
|
||||
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
|
||||
|
||||
// load a Bitmap/SVG from resources
|
||||
InputStream is = null;
|
||||
Bitmap bmp = null;
|
||||
Bitmap bitmapArrow = null;
|
||||
try {
|
||||
is = getResources().openRawResource(R.raw.arrow);
|
||||
float scale = CanvasAdapter.getScale();
|
||||
bmp = CanvasAdapter.decodeSvgBitmap(is, (int) (60 * scale), (int) (60 * scale), 100);
|
||||
bitmapArrow = CanvasAdapter.decodeSvgBitmap(is, (int) (48 * CanvasAdapter.getScale()), (int) (48 * CanvasAdapter.getScale()), 100);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
IOUtils.closeQuietly(is);
|
||||
}
|
||||
|
||||
// create TextureRegion from Bitmap
|
||||
TextureRegion textureRegion = new TextureRegion(new TextureItem(bmp), new TextureAtlas.Rect(0, 0, bmp.getWidth(), bmp.getHeight()));
|
||||
Bitmap bitmapMarker = null;
|
||||
try {
|
||||
is = getResources().openRawResource(R.raw.marker);
|
||||
bitmapMarker = CanvasAdapter.decodeSvgBitmap(is, (int) (48 * CanvasAdapter.getScale()), (int) (48 * CanvasAdapter.getScale()), 100);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
IOUtils.closeQuietly(is);
|
||||
}
|
||||
|
||||
// create LocationTextureLayer with created/loaded TextureRegion
|
||||
locationLayer = new LocationTextureLayer(mMap, textureRegion);
|
||||
|
||||
// set color of accuracy circle (Color.BLUE is default)
|
||||
locationLayer.locationRenderer.setAccuracyColor(Color.get(50, 50, 255));
|
||||
|
||||
// set color of indicator circle (Color.RED is default)
|
||||
locationLayer.locationRenderer.setIndicatorColor(Color.MAGENTA);
|
||||
|
||||
// set billboard rendering for TextureRegion (false is default)
|
||||
locationLayer.locationRenderer.setBillboard(false);
|
||||
locationLayer = new LocationTextureLayer(mMap);
|
||||
locationLayer.locationRenderer.setBitmapArrow(bitmapArrow);
|
||||
locationLayer.locationRenderer.setBitmapMarker(bitmapMarker);
|
||||
locationLayer.locationRenderer.setCallback(new LocationCallback() {
|
||||
@Override
|
||||
public boolean hasRotation() {
|
||||
return location != null && location.hasBearing();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getRotation() {
|
||||
return location != null && location.hasBearing() ? location.getBearing() : 0;
|
||||
}
|
||||
});
|
||||
locationLayer.setEnabled(false);
|
||||
mMap.layers().add(locationLayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
public void onRequestPermissionsResult(final int requestCode, final String[] permissions, final int[] grantResults) {
|
||||
if (requestCode == 0) {
|
||||
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED)
|
||||
enableAvailableProviders();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
|
||||
enableAvailableProviders();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
|
||||
public void onStop() {
|
||||
locationManager.removeUpdates(this);
|
||||
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocationChanged(Location location) {
|
||||
this.location = location;
|
||||
locationLayer.setEnabled(true);
|
||||
locationLayer.setPosition(location.getLatitude(), location.getLongitude(), location.getBearing(), location.getAccuracy());
|
||||
locationLayer.setPosition(location.getLatitude(), location.getLongitude(), location.getAccuracy());
|
||||
|
||||
// Follow location
|
||||
mMap.getMapPosition(mapPosition);
|
||||
@@ -115,6 +131,13 @@ public class LocationTextureActivity extends BitmapTileActivity implements Locat
|
||||
}
|
||||
|
||||
private void enableAvailableProviders() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||
requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
locationManager.removeUpdates(this);
|
||||
|
||||
for (String provider : locationManager.getProviders(true)) {
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright 2019 Andrea Antonello
|
||||
* Copyright 2019 devemux86
|
||||
* Copyright 2019 Kostas Tzounopoulos
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.android.test;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import org.oscim.android.tiling.source.mbtiles.MBTilesBitmapTileSource;
|
||||
import org.oscim.android.tiling.source.mbtiles.MBTilesTileSource;
|
||||
import org.oscim.core.BoundingBox;
|
||||
import org.oscim.core.MapPosition;
|
||||
import org.oscim.core.Tile;
|
||||
import org.oscim.layers.tile.bitmap.BitmapTileLayer;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* An example activity making use of raster MBTiles.
|
||||
*/
|
||||
public class MBTilesBitmapActivity extends BitmapTileActivity {
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
File file = new File(getExternalFilesDir(null), "raster.mbtiles");
|
||||
if (!file.exists()) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this)
|
||||
.setTitle(R.string.warning)
|
||||
.setMessage(getResources().getString(R.string.startup_message_mbtiles, file.getName(), file.getAbsolutePath()))
|
||||
.setPositiveButton(R.string.exit, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
builder.show();
|
||||
return;
|
||||
}
|
||||
|
||||
MBTilesTileSource tileSource = new MBTilesBitmapTileSource(file.getAbsolutePath(), 128, null);
|
||||
|
||||
BitmapTileLayer bitmapLayer = new BitmapTileLayer(mMap, tileSource);
|
||||
mMap.layers().add(bitmapLayer);
|
||||
|
||||
/* set initial position on first run */
|
||||
MapPosition pos = new MapPosition();
|
||||
mMap.getMapPosition(pos);
|
||||
if (pos.x == 0.5 && pos.y == 0.5) {
|
||||
BoundingBox bbox = tileSource.getDataSource().getBounds();
|
||||
if (bbox != null) {
|
||||
pos.setByBoundingBox(bbox, Tile.SIZE * 4, Tile.SIZE * 4);
|
||||
mMap.setMapPosition(pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright 2019 Andrea Antonello
|
||||
* Copyright 2019 devemux86
|
||||
* Copyright 2019 Kostas Tzounopoulos
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.android.test;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import org.oscim.android.mvt.tiling.source.mbtiles.MBTilesMvtTileSource;
|
||||
import org.oscim.android.tiling.source.mbtiles.MBTilesTileSource;
|
||||
import org.oscim.android.tiling.source.mbtiles.MBTilesUnsupportedException;
|
||||
import org.oscim.core.BoundingBox;
|
||||
import org.oscim.core.MapPosition;
|
||||
import org.oscim.core.Tile;
|
||||
import org.oscim.layers.tile.buildings.BuildingLayer;
|
||||
import org.oscim.layers.tile.vector.VectorTileLayer;
|
||||
import org.oscim.layers.tile.vector.labeling.LabelLayer;
|
||||
import org.oscim.theme.VtmThemes;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* An example activity making use of vector MBTiles.
|
||||
*/
|
||||
public class MBTilesMvtActivity extends MapActivity {
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
File file = new File(getExternalFilesDir(null), "vector.mbtiles");
|
||||
if (!file.exists()) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this)
|
||||
.setTitle(R.string.warning)
|
||||
.setMessage(getResources().getString(R.string.startup_message_mbtiles, file.getName(), file.getAbsolutePath()))
|
||||
.setPositiveButton(R.string.exit, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
builder.show();
|
||||
return;
|
||||
}
|
||||
|
||||
MBTilesTileSource tileSource;
|
||||
try {
|
||||
tileSource = new MBTilesMvtTileSource(file.getAbsolutePath(), "en");
|
||||
} catch (MBTilesUnsupportedException e) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this)
|
||||
.setTitle(R.string.warning)
|
||||
.setMessage(e.getMessage())
|
||||
.setPositiveButton(R.string.exit, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
builder.show();
|
||||
return;
|
||||
}
|
||||
|
||||
VectorTileLayer l = mMap.setBaseMap(tileSource);
|
||||
mMap.setTheme(VtmThemes.OPENMAPTILES);
|
||||
|
||||
mMap.layers().add(new BuildingLayer(mMap, l));
|
||||
mMap.layers().add(new LabelLayer(mMap, l));
|
||||
|
||||
/* set initial position on first run */
|
||||
MapPosition pos = new MapPosition();
|
||||
mMap.getMapPosition(pos);
|
||||
if (pos.x == 0.5 && pos.y == 0.5) {
|
||||
BoundingBox bbox = tileSource.getDataSource().getBounds();
|
||||
if (bbox != null) {
|
||||
pos.setByBoundingBox(bbox, Tile.SIZE * 4, Tile.SIZE * 4);
|
||||
mMap.setMapPosition(pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Copyright 2016-2017 devemux86
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.android.test;
|
||||
|
||||
import org.oscim.utils.Parameters;
|
||||
|
||||
public class MapEventLayer2Activity extends MarkerOverlayActivity {
|
||||
|
||||
public MapEventLayer2Activity() {
|
||||
super();
|
||||
Parameters.MAP_EVENT_LAYER2 = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
Parameters.MAP_EVENT_LAYER2 = false;
|
||||
}
|
||||
}
|
||||
125
vtm-android-example/src/org/oscim/android/test/MapFragment.java
Normal file
125
vtm-android-example/src/org/oscim/android/test/MapFragment.java
Normal file
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* Copyright 2018-2020 devemux86
|
||||
* Copyright 2020 Meibes
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.android.test;
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.RelativeLayout;
|
||||
import org.oscim.android.MapView;
|
||||
import org.oscim.backend.CanvasAdapter;
|
||||
import org.oscim.layers.tile.buildings.BuildingLayer;
|
||||
import org.oscim.layers.tile.vector.VectorTileLayer;
|
||||
import org.oscim.layers.tile.vector.labeling.LabelLayer;
|
||||
import org.oscim.renderer.GLViewport;
|
||||
import org.oscim.scalebar.DefaultMapScaleBar;
|
||||
import org.oscim.scalebar.MapScaleBar;
|
||||
import org.oscim.scalebar.MapScaleBarLayer;
|
||||
import org.oscim.theme.IRenderTheme;
|
||||
import org.oscim.theme.VtmThemes;
|
||||
import org.oscim.tiling.source.mapfile.MapFileTileSource;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* You'll need a map with filename berlin.map from download.mapsforge.org in device storage.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class MapFragment extends Fragment {
|
||||
|
||||
private MapView mapView;
|
||||
private IRenderTheme theme;
|
||||
|
||||
public static MapFragment newInstance() {
|
||||
MapFragment instance = new MapFragment();
|
||||
|
||||
Bundle args = new Bundle();
|
||||
instance.setArguments(args);
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_map, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
mapView = new MapView(getActivity());
|
||||
RelativeLayout relativeLayout = view.findViewById(R.id.mapView);
|
||||
relativeLayout.addView(mapView);
|
||||
|
||||
// Tile source
|
||||
MapFileTileSource tileSource = new MapFileTileSource();
|
||||
File file = new File(getActivity().getExternalFilesDir(null), "berlin.map");
|
||||
tileSource.setMapFile(file.getAbsolutePath());
|
||||
|
||||
// Vector layer
|
||||
VectorTileLayer tileLayer = mapView.map().setBaseMap(tileSource);
|
||||
|
||||
// Building layer
|
||||
mapView.map().layers().add(new BuildingLayer(mapView.map(), tileLayer));
|
||||
|
||||
// Label layer
|
||||
mapView.map().layers().add(new LabelLayer(mapView.map(), tileLayer));
|
||||
|
||||
// Render theme
|
||||
theme = mapView.map().setTheme(VtmThemes.DEFAULT);
|
||||
|
||||
// Scale bar
|
||||
MapScaleBar mapScaleBar = new DefaultMapScaleBar(mapView.map());
|
||||
MapScaleBarLayer mapScaleBarLayer = new MapScaleBarLayer(mapView.map(), mapScaleBar);
|
||||
mapScaleBarLayer.getRenderer().setPosition(GLViewport.Position.BOTTOM_LEFT);
|
||||
mapScaleBarLayer.getRenderer().setOffset(5 * CanvasAdapter.getScale(), 0);
|
||||
mapView.map().layers().add(mapScaleBarLayer);
|
||||
|
||||
// Note: this map position is specific to Berlin area
|
||||
mapView.map().setMapPosition(52.517037, 13.38886, 1 << 12);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (mapView != null) {
|
||||
mapView.onResume();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
if (mapView != null) {
|
||||
mapView.onPause();
|
||||
}
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
if (mapView != null) {
|
||||
mapView.onDestroy();
|
||||
mapView = null;
|
||||
}
|
||||
if (theme != null) {
|
||||
theme.dispose();
|
||||
theme = null;
|
||||
}
|
||||
super.onDestroyView();
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018-2019 devemux86
|
||||
* Copyright 2018-2020 devemux86
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
@@ -14,9 +14,12 @@
|
||||
*/
|
||||
package org.oscim.android.test;
|
||||
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
|
||||
import org.oscim.android.cache.TileCache;
|
||||
import okhttp3.Cache;
|
||||
import okhttp3.CipherSuite;
|
||||
import okhttp3.ConnectionSpec;
|
||||
import okhttp3.OkHttpClient;
|
||||
import org.oscim.layers.tile.bitmap.BitmapTileLayer;
|
||||
import org.oscim.layers.tile.buildings.BuildingLayer;
|
||||
import org.oscim.layers.tile.vector.VectorTileLayer;
|
||||
@@ -27,6 +30,11 @@ import org.oscim.tiling.source.UrlTileSource;
|
||||
import org.oscim.tiling.source.bitmap.DefaultSources;
|
||||
import org.oscim.tiling.source.mvt.MapilionMvtTileSource;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class MapilionMvtActivity extends MapActivity {
|
||||
|
||||
// Metered API key for demonstration purposes
|
||||
@@ -34,13 +42,34 @@ public class MapilionMvtActivity extends MapActivity {
|
||||
|
||||
private static final boolean USE_CACHE = false;
|
||||
|
||||
private TileCache mCache;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
OkHttpEngine.OkHttpFactory factory = new OkHttpEngine.OkHttpFactory();
|
||||
OkHttpClient.Builder builder = new OkHttpClient.Builder();
|
||||
if (USE_CACHE) {
|
||||
// Cache the tiles into file system
|
||||
File cacheDirectory = new File(getExternalCacheDir(), "tiles");
|
||||
int cacheSize = 10 * 1024 * 1024; // 10 MB
|
||||
Cache cache = new Cache(cacheDirectory, cacheSize);
|
||||
builder.cache(cache);
|
||||
}
|
||||
|
||||
// https://github.com/square/okhttp/issues/4053
|
||||
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
|
||||
List<CipherSuite> cipherSuites = new ArrayList<>();
|
||||
List<CipherSuite> modernTlsCipherSuites = ConnectionSpec.MODERN_TLS.cipherSuites();
|
||||
if (modernTlsCipherSuites != null)
|
||||
cipherSuites.addAll(modernTlsCipherSuites);
|
||||
cipherSuites.add(CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA);
|
||||
cipherSuites.add(CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA);
|
||||
ConnectionSpec legacyTls = new ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS)
|
||||
.cipherSuites(cipherSuites.toArray(new CipherSuite[0]))
|
||||
.build();
|
||||
builder.connectionSpecs(Arrays.asList(legacyTls, ConnectionSpec.CLEARTEXT));
|
||||
}
|
||||
|
||||
OkHttpEngine.OkHttpFactory factory = new OkHttpEngine.OkHttpFactory(builder);
|
||||
|
||||
UrlTileSource tileSource = MapilionMvtTileSource.builder()
|
||||
.apiKey(API_KEY)
|
||||
@@ -48,13 +77,6 @@ public class MapilionMvtActivity extends MapActivity {
|
||||
//.locale("en")
|
||||
.build();
|
||||
|
||||
if (USE_CACHE) {
|
||||
// Cache the tiles into a local SQLite database
|
||||
mCache = new TileCache(this, null, "tile.db");
|
||||
mCache.setCacheSize(512 * (1 << 10));
|
||||
tileSource.setCache(mCache);
|
||||
}
|
||||
|
||||
VectorTileLayer l = mMap.setBaseMap(tileSource);
|
||||
mMap.setTheme(VtmThemes.OPENMAPTILES);
|
||||
|
||||
@@ -68,12 +90,4 @@ public class MapilionMvtActivity extends MapActivity {
|
||||
mMap.layers().add(new BuildingLayer(mMap, l));
|
||||
mMap.layers().add(new LabelLayer(mMap, l));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
if (mCache != null)
|
||||
mCache.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
/*
|
||||
* Copyright 2014 Hannes Janetzek
|
||||
* Copyright 2016-2018 devemux86
|
||||
* Copyright 2016-2021 devemux86
|
||||
* Copyright 2017 Longri
|
||||
* Copyright 2018 Gustl22
|
||||
* Copyright 2021 eddiemuc
|
||||
*
|
||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||
*
|
||||
@@ -19,15 +20,18 @@
|
||||
*/
|
||||
package org.oscim.android.test;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.provider.DocumentsContract;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import org.oscim.android.filepicker.FilePicker;
|
||||
import org.oscim.android.filepicker.FilterByFileExtension;
|
||||
import org.oscim.android.filepicker.ValidMapFile;
|
||||
import org.oscim.android.filepicker.ValidRenderTheme;
|
||||
import org.oscim.android.theme.ContentRenderTheme;
|
||||
import org.oscim.android.theme.ContentResolverResourceProvider;
|
||||
import org.oscim.backend.CanvasAdapter;
|
||||
import org.oscim.core.MapElement;
|
||||
import org.oscim.core.MapPosition;
|
||||
@@ -42,34 +46,40 @@ import org.oscim.layers.tile.vector.labeling.LabelLayer;
|
||||
import org.oscim.renderer.BitmapRenderer;
|
||||
import org.oscim.renderer.GLViewport;
|
||||
import org.oscim.renderer.bucket.RenderBuckets;
|
||||
import org.oscim.scalebar.DefaultMapScaleBar;
|
||||
import org.oscim.scalebar.ImperialUnitAdapter;
|
||||
import org.oscim.scalebar.MapScaleBar;
|
||||
import org.oscim.scalebar.MapScaleBarLayer;
|
||||
import org.oscim.scalebar.MetricUnitAdapter;
|
||||
import org.oscim.theme.ExternalRenderTheme;
|
||||
import org.oscim.theme.ThemeUtils;
|
||||
import org.oscim.theme.VtmThemes;
|
||||
import org.oscim.scalebar.*;
|
||||
import org.oscim.theme.*;
|
||||
import org.oscim.theme.styles.AreaStyle;
|
||||
import org.oscim.theme.styles.RenderStyle;
|
||||
import org.oscim.tiling.source.mapfile.MapFileTileSource;
|
||||
import org.oscim.tiling.source.mapfile.MapInfo;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
public class MapsforgeActivity extends MapActivity {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(MapsforgeActivity.class);
|
||||
|
||||
static final int SELECT_MAP_FILE = 0;
|
||||
static final int SELECT_THEME_FILE = SELECT_MAP_FILE + 1;
|
||||
private static final int SELECT_THEME_ARCHIVE = 1;
|
||||
private static final int SELECT_THEME_DIR = 2;
|
||||
static final int SELECT_THEME_FILE = 3;
|
||||
|
||||
private static final Tag ISSEA_TAG = new Tag("natural", "issea");
|
||||
private static final Tag NOSEA_TAG = new Tag("natural", "nosea");
|
||||
private static final Tag SEA_TAG = new Tag("natural", "sea");
|
||||
|
||||
private TileGridLayer mGridLayer;
|
||||
private DefaultMapScaleBar mMapScaleBar;
|
||||
private Menu mMenu;
|
||||
private boolean mS3db;
|
||||
private VectorTileLayer mTileLayer;
|
||||
MapFileTileSource mTileSource;
|
||||
private final boolean mS3db;
|
||||
IRenderTheme mTheme;
|
||||
VectorTileLayer mTileLayer;
|
||||
private Uri mThemeDirUri;
|
||||
|
||||
public MapsforgeActivity() {
|
||||
this(false);
|
||||
@@ -89,30 +99,10 @@ public class MapsforgeActivity extends MapActivity {
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
startActivityForResult(new Intent(this, MapFilePicker.class),
|
||||
SELECT_MAP_FILE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
if (mMapScaleBar != null)
|
||||
mMapScaleBar.destroy();
|
||||
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
public static class MapFilePicker extends FilePicker {
|
||||
public MapFilePicker() {
|
||||
setFileDisplayFilter(new FilterByFileExtension(".map"));
|
||||
setFileSelectFilter(new ValidMapFile());
|
||||
}
|
||||
}
|
||||
|
||||
public static class ThemeFilePicker extends FilePicker {
|
||||
public ThemeFilePicker() {
|
||||
setFileDisplayFilter(new FilterByFileExtension(".xml"));
|
||||
setFileSelectFilter(new ValidRenderTheme());
|
||||
}
|
||||
Intent intent = new Intent(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT ? Intent.ACTION_OPEN_DOCUMENT : Intent.ACTION_GET_CONTENT);
|
||||
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||
intent.setType("*/*");
|
||||
startActivityForResult(intent, SELECT_MAP_FILE);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -127,33 +117,53 @@ public class MapsforgeActivity extends MapActivity {
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case R.id.theme_default:
|
||||
mMap.setTheme(VtmThemes.DEFAULT);
|
||||
if (mTheme != null)
|
||||
mTheme.dispose();
|
||||
mTheme = mMap.setTheme(VtmThemes.DEFAULT);
|
||||
item.setChecked(true);
|
||||
return true;
|
||||
|
||||
case R.id.theme_osmarender:
|
||||
mMap.setTheme(VtmThemes.OSMARENDER);
|
||||
if (mTheme != null)
|
||||
mTheme.dispose();
|
||||
mTheme = mMap.setTheme(VtmThemes.OSMARENDER);
|
||||
item.setChecked(true);
|
||||
return true;
|
||||
|
||||
case R.id.theme_osmagray:
|
||||
mMap.setTheme(VtmThemes.OSMAGRAY);
|
||||
if (mTheme != null)
|
||||
mTheme.dispose();
|
||||
mTheme = mMap.setTheme(VtmThemes.OSMAGRAY);
|
||||
item.setChecked(true);
|
||||
return true;
|
||||
|
||||
case R.id.theme_tubes:
|
||||
mMap.setTheme(VtmThemes.TRONRENDER);
|
||||
if (mTheme != null)
|
||||
mTheme.dispose();
|
||||
mTheme = mMap.setTheme(VtmThemes.TRONRENDER);
|
||||
item.setChecked(true);
|
||||
return true;
|
||||
|
||||
case R.id.theme_newtron:
|
||||
mMap.setTheme(VtmThemes.NEWTRON);
|
||||
if (mTheme != null)
|
||||
mTheme.dispose();
|
||||
mTheme = mMap.setTheme(VtmThemes.NEWTRON);
|
||||
item.setChecked(true);
|
||||
return true;
|
||||
|
||||
case R.id.theme_external_archive:
|
||||
Intent intent = new Intent(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT ? Intent.ACTION_OPEN_DOCUMENT : Intent.ACTION_GET_CONTENT);
|
||||
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||
intent.setType("*/*");
|
||||
startActivityForResult(intent, SELECT_THEME_ARCHIVE);
|
||||
return true;
|
||||
|
||||
case R.id.theme_external:
|
||||
startActivityForResult(new Intent(this, ThemeFilePicker.class),
|
||||
SELECT_THEME_FILE);
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
|
||||
return false;
|
||||
intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
|
||||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
startActivityForResult(intent, SELECT_THEME_DIR);
|
||||
return true;
|
||||
|
||||
case R.id.gridlayer:
|
||||
@@ -175,20 +185,23 @@ public class MapsforgeActivity extends MapActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
|
||||
if (requestCode == SELECT_MAP_FILE) {
|
||||
if (resultCode != RESULT_OK || intent == null || intent.getStringExtra(FilePicker.SELECTED_FILE) == null) {
|
||||
if (resultCode != Activity.RESULT_OK || data == null) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
mTileSource = new MapFileTileSource();
|
||||
//mTileSource.setPreferredLanguage("en");
|
||||
String file = intent.getStringExtra(FilePicker.SELECTED_FILE);
|
||||
if (mTileSource.setMapFile(file)) {
|
||||
try {
|
||||
Uri uri = data.getData();
|
||||
|
||||
mTileLayer = mMap.setBaseMap(mTileSource);
|
||||
MapFileTileSource tileSource = new MapFileTileSource();
|
||||
//tileSource.setPreferredLanguage("en");
|
||||
FileInputStream fis = (FileInputStream) getContentResolver().openInputStream(uri);
|
||||
tileSource.setMapFileInputStream(fis);
|
||||
|
||||
mTileLayer = mMap.setBaseMap(tileSource);
|
||||
loadTheme(null);
|
||||
|
||||
if (mS3db)
|
||||
@@ -197,58 +210,114 @@ public class MapsforgeActivity extends MapActivity {
|
||||
mMap.layers().add(new BuildingLayer(mMap, mTileLayer));
|
||||
mMap.layers().add(new LabelLayer(mMap, mTileLayer));
|
||||
|
||||
mMapScaleBar = new DefaultMapScaleBar(mMap);
|
||||
mMapScaleBar.setScaleBarMode(DefaultMapScaleBar.ScaleBarMode.BOTH);
|
||||
mMapScaleBar.setDistanceUnitAdapter(MetricUnitAdapter.INSTANCE);
|
||||
mMapScaleBar.setSecondaryDistanceUnitAdapter(ImperialUnitAdapter.INSTANCE);
|
||||
mMapScaleBar.setScaleBarPosition(MapScaleBar.ScaleBarPosition.BOTTOM_LEFT);
|
||||
DefaultMapScaleBar mapScaleBar = new DefaultMapScaleBar(mMap);
|
||||
mapScaleBar.setScaleBarMode(DefaultMapScaleBar.ScaleBarMode.BOTH);
|
||||
mapScaleBar.setDistanceUnitAdapter(MetricUnitAdapter.INSTANCE);
|
||||
mapScaleBar.setSecondaryDistanceUnitAdapter(ImperialUnitAdapter.INSTANCE);
|
||||
mapScaleBar.setScaleBarPosition(MapScaleBar.ScaleBarPosition.BOTTOM_LEFT);
|
||||
|
||||
MapScaleBarLayer mapScaleBarLayer = new MapScaleBarLayer(mMap, mMapScaleBar);
|
||||
MapScaleBarLayer mapScaleBarLayer = new MapScaleBarLayer(mMap, mapScaleBar);
|
||||
BitmapRenderer renderer = mapScaleBarLayer.getRenderer();
|
||||
renderer.setPosition(GLViewport.Position.BOTTOM_LEFT);
|
||||
renderer.setOffset(5 * CanvasAdapter.getScale(), 0);
|
||||
mMap.layers().add(mapScaleBarLayer);
|
||||
|
||||
MapInfo info = mTileSource.getMapInfo();
|
||||
MapInfo info = tileSource.getMapInfo();
|
||||
if (!info.boundingBox.contains(mMap.getMapPosition().getGeoPoint())) {
|
||||
MapPosition pos = new MapPosition();
|
||||
pos.setByBoundingBox(info.boundingBox, Tile.SIZE * 4, Tile.SIZE * 4);
|
||||
mMap.setMapPosition(pos);
|
||||
mPrefs.clear();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
finish();
|
||||
}
|
||||
} else if (requestCode == SELECT_THEME_FILE) {
|
||||
if (resultCode != RESULT_OK || intent == null || intent.getStringExtra(FilePicker.SELECTED_FILE) == null) {
|
||||
} else if (requestCode == SELECT_THEME_ARCHIVE) {
|
||||
if (resultCode != Activity.RESULT_OK || data == null)
|
||||
return;
|
||||
}
|
||||
|
||||
String file = intent.getStringExtra(FilePicker.SELECTED_FILE);
|
||||
ExternalRenderTheme externalRenderTheme = new ExternalRenderTheme(file);
|
||||
try {
|
||||
final Uri uri = data.getData();
|
||||
|
||||
// Use tessellation with sea and land for Mapsforge themes
|
||||
if (ThemeUtils.isMapsforgeTheme(externalRenderTheme)) {
|
||||
mTileLayer.addHook(new VectorTileLayer.TileLoaderThemeHook() {
|
||||
final List<String> xmlThemes = ZipXmlThemeResourceProvider.scanXmlThemes(new ZipInputStream(new BufferedInputStream(getContentResolver().openInputStream(uri))));
|
||||
if (xmlThemes.isEmpty())
|
||||
return;
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle(R.string.dialog_theme_title);
|
||||
builder.setSingleChoiceItems(xmlThemes.toArray(new String[0]), -1, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public boolean process(MapTile tile, RenderBuckets buckets, MapElement element, RenderStyle style, int level) {
|
||||
if (element.tags.contains(ISSEA_TAG) || element.tags.contains(SEA_TAG) || element.tags.contains(NOSEA_TAG)) {
|
||||
if (style instanceof AreaStyle)
|
||||
((AreaStyle) style).mesh = true;
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
try {
|
||||
dialog.dismiss();
|
||||
ThemeFile theme = new ZipRenderTheme(xmlThemes.get(which), new ZipXmlThemeResourceProvider(new ZipInputStream(new BufferedInputStream(getContentResolver().openInputStream(uri)))));
|
||||
if (mTheme != null)
|
||||
mTheme.dispose();
|
||||
mTheme = mMap.setTheme(theme);
|
||||
mapsforgeTheme(mTheme);
|
||||
mMenu.findItem(R.id.theme_external_archive).setChecked(true);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void complete(MapTile tile, boolean success) {
|
||||
}
|
||||
});
|
||||
builder.show();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else if (requestCode == SELECT_THEME_DIR) {
|
||||
if (resultCode != Activity.RESULT_OK || data == null)
|
||||
return;
|
||||
|
||||
mMap.setTheme(externalRenderTheme);
|
||||
mThemeDirUri = data.getData();
|
||||
|
||||
// Now we have the directory for resources, but we need to let the user also select a theme file
|
||||
Intent intent = new Intent(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT ? Intent.ACTION_OPEN_DOCUMENT : Intent.ACTION_GET_CONTENT);
|
||||
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||
intent.setType("*/*");
|
||||
intent.putExtra(DocumentsContract.EXTRA_INITIAL_URI, mThemeDirUri);
|
||||
startActivityForResult(intent, SELECT_THEME_FILE);
|
||||
} else if (requestCode == SELECT_THEME_FILE) {
|
||||
if (resultCode != Activity.RESULT_OK || data == null)
|
||||
return;
|
||||
|
||||
Uri uri = data.getData();
|
||||
ThemeFile theme = new ContentRenderTheme(getContentResolver(), uri);
|
||||
theme.setResourceProvider(new ContentResolverResourceProvider(getContentResolver(), mThemeDirUri));
|
||||
|
||||
if (mTheme != null)
|
||||
mTheme.dispose();
|
||||
mTheme = mMap.setTheme(theme);
|
||||
mapsforgeTheme(mTheme);
|
||||
mMenu.findItem(R.id.theme_external).setChecked(true);
|
||||
}
|
||||
}
|
||||
|
||||
protected void loadTheme(final String styleId) {
|
||||
mMap.setTheme(VtmThemes.DEFAULT);
|
||||
if (mTheme != null)
|
||||
mTheme.dispose();
|
||||
mTheme = mMap.setTheme(VtmThemes.DEFAULT);
|
||||
}
|
||||
|
||||
private void mapsforgeTheme(IRenderTheme theme) {
|
||||
if (!theme.isMapsforgeTheme())
|
||||
return;
|
||||
|
||||
// Use tessellation with sea and land for Mapsforge themes
|
||||
mTileLayer.addHook(new VectorTileLayer.TileLoaderThemeHook() {
|
||||
@Override
|
||||
public boolean process(MapTile tile, RenderBuckets buckets, MapElement element, RenderStyle style, int level) {
|
||||
if (element.tags.contains(ISSEA_TAG) || element.tags.contains(SEA_TAG) || element.tags.contains(NOSEA_TAG)) {
|
||||
if (style instanceof AreaStyle)
|
||||
((AreaStyle) style).mesh = true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void complete(MapTile tile, boolean success) {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2017 devemux86
|
||||
* Copyright 2016-2020 devemux86
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
@@ -17,7 +17,6 @@ package org.oscim.android.test;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.oscim.android.theme.AssetsRenderTheme;
|
||||
import org.oscim.theme.XmlRenderThemeMenuCallback;
|
||||
import org.oscim.theme.XmlRenderThemeStyleLayer;
|
||||
@@ -58,7 +57,9 @@ public class MapsforgeStyleActivity extends MapsforgeActivity {
|
||||
|
||||
@Override
|
||||
protected void loadTheme(final String styleId) {
|
||||
mMap.setTheme(new AssetsRenderTheme(getAssets(), "", "vtm/stylemenu.xml", new XmlRenderThemeMenuCallback() {
|
||||
if (mTheme != null)
|
||||
mTheme.dispose();
|
||||
mTheme = mMap.setTheme(new AssetsRenderTheme(getAssets(), "", "vtm/stylemenu.xml", new XmlRenderThemeMenuCallback() {
|
||||
@Override
|
||||
public Set<String> getCategories(XmlRenderThemeStyleMenu renderThemeStyleMenu) {
|
||||
// Use the selected style or the default
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017-2018 devemux86
|
||||
* Copyright 2017-2020 devemux86
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
@@ -15,8 +15,8 @@
|
||||
package org.oscim.android.test;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import org.oscim.android.cache.TileCache;
|
||||
import okhttp3.Cache;
|
||||
import okhttp3.OkHttpClient;
|
||||
import org.oscim.layers.tile.buildings.BuildingLayer;
|
||||
import org.oscim.layers.tile.vector.VectorTileLayer;
|
||||
import org.oscim.layers.tile.vector.labeling.LabelLayer;
|
||||
@@ -25,41 +25,35 @@ import org.oscim.tiling.source.OkHttpEngine;
|
||||
import org.oscim.tiling.source.UrlTileSource;
|
||||
import org.oscim.tiling.source.geojson.MapzenGeojsonTileSource;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class MapzenGeojsonActivity extends MapActivity {
|
||||
|
||||
private static final boolean USE_CACHE = false;
|
||||
|
||||
private TileCache mCache;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
OkHttpClient.Builder builder = new OkHttpClient.Builder();
|
||||
if (USE_CACHE) {
|
||||
// Cache the tiles into file system
|
||||
File cacheDirectory = new File(getExternalCacheDir(), "tiles");
|
||||
int cacheSize = 10 * 1024 * 1024; // 10 MB
|
||||
Cache cache = new Cache(cacheDirectory, cacheSize);
|
||||
builder.cache(cache);
|
||||
}
|
||||
|
||||
UrlTileSource tileSource = MapzenGeojsonTileSource.builder()
|
||||
.apiKey("xxxxxxx") // Put a proper API key
|
||||
.httpFactory(new OkHttpEngine.OkHttpFactory())
|
||||
.httpFactory(new OkHttpEngine.OkHttpFactory(builder))
|
||||
//.locale("en")
|
||||
.build();
|
||||
|
||||
if (USE_CACHE) {
|
||||
// Cache the tiles into a local SQLite database
|
||||
mCache = new TileCache(this, null, "tile.db");
|
||||
mCache.setCacheSize(512 * (1 << 10));
|
||||
tileSource.setCache(mCache);
|
||||
}
|
||||
|
||||
VectorTileLayer l = mMap.setBaseMap(tileSource);
|
||||
mMap.setTheme(VtmThemes.MAPZEN);
|
||||
|
||||
mMap.layers().add(new BuildingLayer(mMap, l));
|
||||
mMap.layers().add(new LabelLayer(mMap, l));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
if (mCache != null)
|
||||
mCache.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2018 devemux86
|
||||
* Copyright 2016-2020 devemux86
|
||||
* Copyright 2017 Mathieu De Brito
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
@@ -16,8 +16,8 @@
|
||||
package org.oscim.android.test;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import org.oscim.android.cache.TileCache;
|
||||
import okhttp3.Cache;
|
||||
import okhttp3.OkHttpClient;
|
||||
import org.oscim.layers.tile.buildings.BuildingLayer;
|
||||
import org.oscim.layers.tile.vector.VectorTileLayer;
|
||||
import org.oscim.layers.tile.vector.labeling.LabelLayer;
|
||||
@@ -26,41 +26,35 @@ import org.oscim.tiling.source.OkHttpEngine;
|
||||
import org.oscim.tiling.source.UrlTileSource;
|
||||
import org.oscim.tiling.source.mvt.MapzenMvtTileSource;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class MapzenMvtActivity extends MapActivity {
|
||||
|
||||
private static final boolean USE_CACHE = false;
|
||||
|
||||
private TileCache mCache;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
OkHttpClient.Builder builder = new OkHttpClient.Builder();
|
||||
if (USE_CACHE) {
|
||||
// Cache the tiles into file system
|
||||
File cacheDirectory = new File(getExternalCacheDir(), "tiles");
|
||||
int cacheSize = 10 * 1024 * 1024; // 10 MB
|
||||
Cache cache = new Cache(cacheDirectory, cacheSize);
|
||||
builder.cache(cache);
|
||||
}
|
||||
|
||||
UrlTileSource tileSource = MapzenMvtTileSource.builder()
|
||||
.apiKey("xxxxxxx") // Put a proper API key
|
||||
.httpFactory(new OkHttpEngine.OkHttpFactory())
|
||||
.httpFactory(new OkHttpEngine.OkHttpFactory(builder))
|
||||
//.locale("en")
|
||||
.build();
|
||||
|
||||
if (USE_CACHE) {
|
||||
// Cache the tiles into a local SQLite database
|
||||
mCache = new TileCache(this, null, "tile.db");
|
||||
mCache.setCacheSize(512 * (1 << 10));
|
||||
tileSource.setCache(mCache);
|
||||
}
|
||||
|
||||
VectorTileLayer l = mMap.setBaseMap(tileSource);
|
||||
mMap.setTheme(VtmThemes.MAPZEN);
|
||||
|
||||
mMap.layers().add(new BuildingLayer(mMap, l));
|
||||
mMap.layers().add(new LabelLayer(mMap, l));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
if (mCache != null)
|
||||
mCache.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright 2014 Hannes Janetzek
|
||||
* Copyright 2016-2018 devemux86
|
||||
* Copyright 2016-2020 devemux86
|
||||
*
|
||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||
*
|
||||
@@ -17,9 +17,10 @@
|
||||
*/
|
||||
package org.oscim.android.test;
|
||||
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.os.Bundle;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.oscim.android.canvas.AndroidBitmap;
|
||||
import org.oscim.backend.canvas.Bitmap;
|
||||
import org.oscim.core.GeoPoint;
|
||||
import org.oscim.event.Gesture;
|
||||
@@ -27,26 +28,25 @@ import org.oscim.event.GestureListener;
|
||||
import org.oscim.event.MotionEvent;
|
||||
import org.oscim.layers.Layer;
|
||||
import org.oscim.layers.marker.ItemizedLayer;
|
||||
import org.oscim.layers.marker.MarkerInterface;
|
||||
import org.oscim.layers.marker.MarkerItem;
|
||||
import org.oscim.layers.marker.MarkerSymbol;
|
||||
import org.oscim.layers.marker.MarkerSymbol.HotspotPlace;
|
||||
import org.oscim.layers.tile.bitmap.BitmapTileLayer;
|
||||
import org.oscim.map.Map;
|
||||
import org.oscim.tiling.TileSource;
|
||||
import org.oscim.tiling.source.OkHttpEngine;
|
||||
import org.oscim.tiling.source.UrlTileSource;
|
||||
import org.oscim.tiling.source.bitmap.DefaultSources;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.oscim.android.canvas.AndroidGraphics.drawableToBitmap;
|
||||
|
||||
public class MarkerOverlayActivity extends MapActivity
|
||||
implements ItemizedLayer.OnItemGestureListener<MarkerItem> {
|
||||
public class MarkerOverlayActivity extends MapActivity implements ItemizedLayer.OnItemGestureListener<MarkerInterface> {
|
||||
|
||||
static final boolean BILLBOARDS = true;
|
||||
MarkerSymbol mFocusMarker;
|
||||
ItemizedLayer<MarkerItem> mMarkerLayer;
|
||||
ItemizedLayer mMarkerLayer;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
@@ -59,28 +59,29 @@ public class MarkerOverlayActivity extends MapActivity
|
||||
// Map events receiver
|
||||
mMap.layers().add(new MapEventsReceiver(mMap));
|
||||
|
||||
TileSource tileSource = DefaultSources.OPENSTREETMAP
|
||||
UrlTileSource tileSource = DefaultSources.OPENSTREETMAP
|
||||
.httpFactory(new OkHttpEngine.OkHttpFactory())
|
||||
.build();
|
||||
tileSource.setHttpRequestHeaders(Collections.singletonMap("User-Agent", "vtm-android-example"));
|
||||
mMap.layers().add(new BitmapTileLayer(mMap, tileSource));
|
||||
|
||||
Bitmap bitmapPoi = drawableToBitmap(getResources().getDrawable(R.drawable.marker_poi));
|
||||
Bitmap bitmapPoi = new AndroidBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.marker_poi));
|
||||
MarkerSymbol symbol;
|
||||
if (BILLBOARDS)
|
||||
symbol = new MarkerSymbol(bitmapPoi, HotspotPlace.BOTTOM_CENTER);
|
||||
else
|
||||
symbol = new MarkerSymbol(bitmapPoi, HotspotPlace.CENTER, false);
|
||||
|
||||
Bitmap bitmapFocus = drawableToBitmap(getResources().getDrawable(R.drawable.marker_focus));
|
||||
Bitmap bitmapFocus = new AndroidBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.marker_focus));
|
||||
if (BILLBOARDS)
|
||||
mFocusMarker = new MarkerSymbol(bitmapFocus, HotspotPlace.BOTTOM_CENTER);
|
||||
else
|
||||
mFocusMarker = new MarkerSymbol(bitmapFocus, HotspotPlace.CENTER, false);
|
||||
|
||||
mMarkerLayer = new ItemizedLayer<>(mMap, new ArrayList<MarkerItem>(), symbol, this);
|
||||
mMarkerLayer = new ItemizedLayer(mMap, new ArrayList<MarkerInterface>(), symbol, this);
|
||||
mMap.layers().add(mMarkerLayer);
|
||||
|
||||
List<MarkerItem> pts = new ArrayList<>();
|
||||
List<MarkerInterface> pts = new ArrayList<>();
|
||||
|
||||
for (double lat = -90; lat <= 90; lat += 5) {
|
||||
for (double lon = -180; lon <= 180; lon += 5)
|
||||
@@ -99,24 +100,26 @@ public class MarkerOverlayActivity extends MapActivity
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemSingleTapUp(int index, MarkerItem item) {
|
||||
if (item.getMarker() == null)
|
||||
item.setMarker(mFocusMarker);
|
||||
public boolean onItemSingleTapUp(int index, MarkerInterface item) {
|
||||
MarkerItem markerItem = (MarkerItem) item;
|
||||
if (markerItem.getMarker() == null)
|
||||
markerItem.setMarker(mFocusMarker);
|
||||
else
|
||||
item.setMarker(null);
|
||||
markerItem.setMarker(null);
|
||||
|
||||
Toast.makeText(this, "Marker tap\n" + item.getTitle(), Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(this, "Marker tap\n" + markerItem.getTitle(), Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemLongPress(int index, MarkerItem item) {
|
||||
if (item.getMarker() == null)
|
||||
item.setMarker(mFocusMarker);
|
||||
public boolean onItemLongPress(int index, MarkerInterface item) {
|
||||
MarkerItem markerItem = (MarkerItem) item;
|
||||
if (markerItem.getMarker() == null)
|
||||
markerItem.setMarker(mFocusMarker);
|
||||
else
|
||||
item.setMarker(null);
|
||||
markerItem.setMarker(null);
|
||||
|
||||
Toast.makeText(this, "Marker long press\n" + item.getTitle(), Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(this, "Marker long press\n" + markerItem.getTitle(), Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
/*
|
||||
* Copyright 2016 Marvin W
|
||||
* Copyright 2016-2017 devemux86
|
||||
*
|
||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.android.test;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
|
||||
import org.oscim.android.MapPreferences;
|
||||
import org.oscim.android.MapView;
|
||||
import org.oscim.layers.tile.buildings.BuildingLayer;
|
||||
import org.oscim.layers.tile.vector.VectorTileLayer;
|
||||
import org.oscim.layers.tile.vector.labeling.LabelLayer;
|
||||
import org.oscim.map.Map;
|
||||
import org.oscim.theme.VtmThemes;
|
||||
import org.oscim.tiling.TileSource;
|
||||
import org.oscim.tiling.source.OkHttpEngine;
|
||||
import org.oscim.tiling.source.oscimap4.OSciMap4TileSource;
|
||||
|
||||
public class MultiMapViewActivity extends Activity {
|
||||
private MapView mMapView1, mMapView2;
|
||||
private MapPreferences mPrefs1, mPrefs2;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_map_multi);
|
||||
|
||||
setTitle(getClass().getSimpleName());
|
||||
|
||||
// 1st map view
|
||||
mMapView1 = (MapView) findViewById(R.id.mapView1);
|
||||
Map map1 = mMapView1.map();
|
||||
mPrefs1 = new MapPreferences(MultiMapViewActivity.class.getName() + "1", this);
|
||||
TileSource tileSource1 = OSciMap4TileSource.builder()
|
||||
.httpFactory(new OkHttpEngine.OkHttpFactory())
|
||||
.build();
|
||||
VectorTileLayer baseLayer1 = map1.setBaseMap(tileSource1);
|
||||
map1.layers().add(new BuildingLayer(map1, baseLayer1));
|
||||
map1.layers().add(new LabelLayer(map1, baseLayer1));
|
||||
map1.setTheme(VtmThemes.DEFAULT);
|
||||
|
||||
// 2nd map view
|
||||
mMapView2 = (MapView) findViewById(R.id.mapView2);
|
||||
Map map2 = mMapView2.map();
|
||||
mPrefs2 = new MapPreferences(MultiMapViewActivity.class.getName() + "2", this);
|
||||
TileSource tileSource2 = OSciMap4TileSource.builder()
|
||||
.httpFactory(new OkHttpEngine.OkHttpFactory())
|
||||
.build();
|
||||
VectorTileLayer baseLayer2 = map2.setBaseMap(tileSource2);
|
||||
map2.layers().add(new BuildingLayer(map2, baseLayer2));
|
||||
map2.layers().add(new LabelLayer(map2, baseLayer2));
|
||||
map2.setTheme(VtmThemes.DEFAULT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
mPrefs1.load(mMapView1.map());
|
||||
mMapView1.onResume();
|
||||
|
||||
mPrefs2.load(mMapView2.map());
|
||||
mMapView2.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
|
||||
mMapView1.onPause();
|
||||
mPrefs1.save(mMapView1.map());
|
||||
|
||||
mMapView2.onPause();
|
||||
mPrefs2.save(mMapView2.map());
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018 devemux86
|
||||
* Copyright 2018-2020 devemux86
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
@@ -15,8 +15,8 @@
|
||||
package org.oscim.android.test;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import org.oscim.android.cache.TileCache;
|
||||
import okhttp3.Cache;
|
||||
import okhttp3.OkHttpClient;
|
||||
import org.oscim.layers.tile.buildings.BuildingLayer;
|
||||
import org.oscim.layers.tile.vector.VectorTileLayer;
|
||||
import org.oscim.layers.tile.vector.labeling.LabelLayer;
|
||||
@@ -25,41 +25,35 @@ import org.oscim.tiling.source.OkHttpEngine;
|
||||
import org.oscim.tiling.source.UrlTileSource;
|
||||
import org.oscim.tiling.source.geojson.NextzenGeojsonTileSource;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class NextzenGeojsonActivity extends MapActivity {
|
||||
|
||||
private static final boolean USE_CACHE = false;
|
||||
|
||||
private TileCache mCache;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
OkHttpClient.Builder builder = new OkHttpClient.Builder();
|
||||
if (USE_CACHE) {
|
||||
// Cache the tiles into file system
|
||||
File cacheDirectory = new File(getExternalCacheDir(), "tiles");
|
||||
int cacheSize = 10 * 1024 * 1024; // 10 MB
|
||||
Cache cache = new Cache(cacheDirectory, cacheSize);
|
||||
builder.cache(cache);
|
||||
}
|
||||
|
||||
UrlTileSource tileSource = NextzenGeojsonTileSource.builder()
|
||||
.apiKey("xxxxxxx") // Put a proper API key
|
||||
.httpFactory(new OkHttpEngine.OkHttpFactory())
|
||||
.httpFactory(new OkHttpEngine.OkHttpFactory(builder))
|
||||
//.locale("en")
|
||||
.build();
|
||||
|
||||
if (USE_CACHE) {
|
||||
// Cache the tiles into a local SQLite database
|
||||
mCache = new TileCache(this, null, "tile.db");
|
||||
mCache.setCacheSize(512 * (1 << 10));
|
||||
tileSource.setCache(mCache);
|
||||
}
|
||||
|
||||
VectorTileLayer l = mMap.setBaseMap(tileSource);
|
||||
mMap.setTheme(VtmThemes.MAPZEN);
|
||||
|
||||
mMap.layers().add(new BuildingLayer(mMap, l));
|
||||
mMap.layers().add(new LabelLayer(mMap, l));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
if (mCache != null)
|
||||
mCache.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018 devemux86
|
||||
* Copyright 2018-2020 devemux86
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
@@ -15,8 +15,8 @@
|
||||
package org.oscim.android.test;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import org.oscim.android.cache.TileCache;
|
||||
import okhttp3.Cache;
|
||||
import okhttp3.OkHttpClient;
|
||||
import org.oscim.layers.tile.buildings.BuildingLayer;
|
||||
import org.oscim.layers.tile.vector.VectorTileLayer;
|
||||
import org.oscim.layers.tile.vector.labeling.LabelLayer;
|
||||
@@ -25,41 +25,35 @@ import org.oscim.tiling.source.OkHttpEngine;
|
||||
import org.oscim.tiling.source.UrlTileSource;
|
||||
import org.oscim.tiling.source.mvt.NextzenMvtTileSource;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class NextzenMvtActivity extends MapActivity {
|
||||
|
||||
private static final boolean USE_CACHE = false;
|
||||
|
||||
private TileCache mCache;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
OkHttpClient.Builder builder = new OkHttpClient.Builder();
|
||||
if (USE_CACHE) {
|
||||
// Cache the tiles into file system
|
||||
File cacheDirectory = new File(getExternalCacheDir(), "tiles");
|
||||
int cacheSize = 10 * 1024 * 1024; // 10 MB
|
||||
Cache cache = new Cache(cacheDirectory, cacheSize);
|
||||
builder.cache(cache);
|
||||
}
|
||||
|
||||
UrlTileSource tileSource = NextzenMvtTileSource.builder()
|
||||
.apiKey("xxxxxxx") // Put a proper API key
|
||||
.httpFactory(new OkHttpEngine.OkHttpFactory())
|
||||
.httpFactory(new OkHttpEngine.OkHttpFactory(builder))
|
||||
//.locale("en")
|
||||
.build();
|
||||
|
||||
if (USE_CACHE) {
|
||||
// Cache the tiles into a local SQLite database
|
||||
mCache = new TileCache(this, null, "tile.db");
|
||||
mCache.setCacheSize(512 * (1 << 10));
|
||||
tileSource.setCache(mCache);
|
||||
}
|
||||
|
||||
VectorTileLayer l = mMap.setBaseMap(tileSource);
|
||||
mMap.setTheme(VtmThemes.MAPZEN);
|
||||
|
||||
mMap.layers().add(new BuildingLayer(mMap, l));
|
||||
mMap.layers().add(new LabelLayer(mMap, l));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
if (mCache != null)
|
||||
mCache.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
/*
|
||||
* Copyright 2016-2017 devemux86
|
||||
*
|
||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.android.test;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import org.oscim.android.cache.TileCache;
|
||||
import org.oscim.layers.tile.TileLayer;
|
||||
import org.oscim.layers.tile.buildings.S3DBTileLayer;
|
||||
import org.oscim.layers.tile.vector.labeling.LabelLayer;
|
||||
import org.oscim.theme.VtmThemes;
|
||||
import org.oscim.tiling.TileSource;
|
||||
import org.oscim.tiling.source.OkHttpEngine;
|
||||
import org.oscim.tiling.source.oscimap4.OSciMap4TileSource;
|
||||
|
||||
public class OSciMapS3DBActivity extends BaseMapActivity {
|
||||
|
||||
TileCache mS3dbCache;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
mMap.setTheme(VtmThemes.DEFAULT);
|
||||
|
||||
TileSource ts = OSciMap4TileSource.builder()
|
||||
.httpFactory(new OkHttpEngine.OkHttpFactory())
|
||||
.url("http://opensciencemap.org/tiles/s3db")
|
||||
.zoomMin(16)
|
||||
.zoomMax(16)
|
||||
.build();
|
||||
|
||||
if (USE_CACHE) {
|
||||
mS3dbCache = new TileCache(this, null, "s3db.db");
|
||||
mS3dbCache.setCacheSize(512 * (1 << 10));
|
||||
ts.setCache(mS3dbCache);
|
||||
}
|
||||
TileLayer tl = new S3DBTileLayer(mMap, ts, true, false);
|
||||
mMap.layers().add(tl);
|
||||
mMap.layers().add(new LabelLayer(mMap, mBaseLayer));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
if (mS3dbCache != null)
|
||||
mS3dbCache.dispose();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
/* ignore saved position */
|
||||
mMap.setMapPosition(53.5620092, 9.9866457, 1 << 16);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2018 devemux86
|
||||
* Copyright 2016-2020 devemux86
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
@@ -15,8 +15,8 @@
|
||||
package org.oscim.android.test;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import org.oscim.android.cache.TileCache;
|
||||
import okhttp3.Cache;
|
||||
import okhttp3.OkHttpClient;
|
||||
import org.oscim.layers.tile.buildings.BuildingLayer;
|
||||
import org.oscim.layers.tile.vector.VectorTileLayer;
|
||||
import org.oscim.layers.tile.vector.labeling.LabelLayer;
|
||||
@@ -25,41 +25,35 @@ import org.oscim.tiling.source.OkHttpEngine;
|
||||
import org.oscim.tiling.source.UrlTileSource;
|
||||
import org.oscim.tiling.source.mvt.OpenMapTilesMvtTileSource;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class OpenMapTilesMvtActivity extends MapActivity {
|
||||
|
||||
private static final boolean USE_CACHE = false;
|
||||
|
||||
private TileCache mCache;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
OkHttpClient.Builder builder = new OkHttpClient.Builder();
|
||||
if (USE_CACHE) {
|
||||
// Cache the tiles into file system
|
||||
File cacheDirectory = new File(getExternalCacheDir(), "tiles");
|
||||
int cacheSize = 10 * 1024 * 1024; // 10 MB
|
||||
Cache cache = new Cache(cacheDirectory, cacheSize);
|
||||
builder.cache(cache);
|
||||
}
|
||||
|
||||
UrlTileSource tileSource = OpenMapTilesMvtTileSource.builder()
|
||||
.apiKey("xxxxxxx") // Put a proper API key
|
||||
.httpFactory(new OkHttpEngine.OkHttpFactory())
|
||||
.httpFactory(new OkHttpEngine.OkHttpFactory(builder))
|
||||
//.locale("en")
|
||||
.build();
|
||||
|
||||
if (USE_CACHE) {
|
||||
// Cache the tiles into a local SQLite database
|
||||
mCache = new TileCache(this, null, "tile.db");
|
||||
mCache.setCacheSize(512 * (1 << 10));
|
||||
tileSource.setCache(mCache);
|
||||
}
|
||||
|
||||
VectorTileLayer l = mMap.setBaseMap(tileSource);
|
||||
mMap.setTheme(VtmThemes.OPENMAPTILES);
|
||||
|
||||
mMap.layers().add(new BuildingLayer(mMap, l));
|
||||
mMap.layers().add(new LabelLayer(mMap, l));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
if (mCache != null)
|
||||
mCache.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright 2019 Gustl22
|
||||
* Copyright 2020 devemux86
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
@@ -15,7 +16,6 @@
|
||||
package org.oscim.android.test;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import org.oscim.layers.tile.bitmap.BitmapTileLayer;
|
||||
import org.oscim.layers.tile.buildings.BuildingLayer;
|
||||
import org.oscim.layers.tile.buildings.S3DBLayer;
|
||||
@@ -25,9 +25,12 @@ import org.oscim.map.Viewport;
|
||||
import org.oscim.theme.VtmThemes;
|
||||
import org.oscim.tiling.TileSource;
|
||||
import org.oscim.tiling.source.OkHttpEngine;
|
||||
import org.oscim.tiling.source.UrlTileSource;
|
||||
import org.oscim.tiling.source.bitmap.DefaultSources;
|
||||
import org.oscim.tiling.source.overpass.OverpassTileSource;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* Use Overpass API data for vector layer.
|
||||
* Only for developing as can be error-prone.
|
||||
@@ -46,7 +49,7 @@ public class OverpassActivity extends MapActivity {
|
||||
.build();
|
||||
VectorTileLayer l = mMap.setBaseMap(tileSource);
|
||||
|
||||
TileSource bitmapTileSource = DefaultSources.OPENSTREETMAP
|
||||
UrlTileSource bitmapTileSource = DefaultSources.OPENSTREETMAP
|
||||
.httpFactory(new OkHttpEngine.OkHttpFactory())
|
||||
.zoomMax(15)
|
||||
.fadeSteps(new BitmapTileLayer.FadeStep[]{
|
||||
@@ -54,6 +57,7 @@ public class OverpassActivity extends MapActivity {
|
||||
new BitmapTileLayer.FadeStep(16, Viewport.MAX_ZOOM_LEVEL, 0f, 0f)
|
||||
})
|
||||
.build();
|
||||
bitmapTileSource.setHttpRequestHeaders(Collections.singletonMap("User-Agent", "vtm-android-example"));
|
||||
mMap.layers().add(new BitmapTileLayer(mMap, bitmapTileSource));
|
||||
|
||||
BuildingLayer.RAW_DATA = true;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017-2018 devemux86
|
||||
* Copyright 2017-2020 devemux86
|
||||
* Copyright 2018 Gustl22
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
@@ -17,6 +17,7 @@ package org.oscim.android.test;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
@@ -25,20 +26,11 @@ import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ListView;
|
||||
import android.widget.Toast;
|
||||
import android.widget.ToggleButton;
|
||||
|
||||
import android.widget.*;
|
||||
import org.mapsforge.core.model.Tag;
|
||||
import org.mapsforge.poi.android.storage.AndroidPoiPersistenceManagerFactory;
|
||||
import org.mapsforge.poi.storage.ExactMatchPoiCategoryFilter;
|
||||
import org.mapsforge.poi.storage.PoiCategoryFilter;
|
||||
import org.mapsforge.poi.storage.PoiCategoryManager;
|
||||
import org.mapsforge.poi.storage.PoiPersistenceManager;
|
||||
import org.mapsforge.poi.storage.PointOfInterest;
|
||||
import org.mapsforge.poi.storage.*;
|
||||
import org.oscim.android.canvas.AndroidBitmap;
|
||||
import org.oscim.android.filepicker.FilePicker;
|
||||
import org.oscim.android.filepicker.FilterByFileExtension;
|
||||
import org.oscim.backend.canvas.Bitmap;
|
||||
@@ -49,6 +41,7 @@ import org.oscim.event.GestureListener;
|
||||
import org.oscim.event.MotionEvent;
|
||||
import org.oscim.layers.Layer;
|
||||
import org.oscim.layers.marker.ItemizedLayer;
|
||||
import org.oscim.layers.marker.MarkerInterface;
|
||||
import org.oscim.layers.marker.MarkerItem;
|
||||
import org.oscim.layers.marker.MarkerSymbol;
|
||||
import org.oscim.map.Map;
|
||||
@@ -60,21 +53,19 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static org.oscim.android.canvas.AndroidGraphics.drawableToBitmap;
|
||||
|
||||
/**
|
||||
* POI search.<br/>
|
||||
* Long press on map to search inside visible bounding box.<br/>
|
||||
* Tap on POIs to show their name (in default locale).
|
||||
*/
|
||||
public class PoiSearchActivity extends MapsforgeActivity implements ItemizedLayer.OnItemGestureListener<MarkerItem> {
|
||||
public class PoiSearchActivity extends MapsforgeActivity implements ItemizedLayer.OnItemGestureListener<MarkerInterface> {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(PoiSearchActivity.class);
|
||||
|
||||
private static final String POI_CATEGORY = "Restaurants";
|
||||
private static final int SELECT_POI_FILE = MapsforgeActivity.SELECT_THEME_FILE + 1;
|
||||
|
||||
private ItemizedLayer<MarkerItem> mMarkerLayer;
|
||||
private ItemizedLayer mMarkerLayer;
|
||||
private PoiPersistenceManager mPersistenceManager;
|
||||
|
||||
public static class PoiFilePicker extends FilePicker {
|
||||
@@ -148,7 +139,7 @@ public class PoiSearchActivity extends MapsforgeActivity implements ItemizedLaye
|
||||
super.onActivityResult(requestCode, resultCode, intent);
|
||||
|
||||
if (requestCode == SELECT_MAP_FILE) {
|
||||
if (mTileSource != null)
|
||||
if (mTileLayer.getTileSource() != null)
|
||||
startActivityForResult(new Intent(this, PoiFilePicker.class),
|
||||
SELECT_POI_FILE);
|
||||
else
|
||||
@@ -162,21 +153,22 @@ public class PoiSearchActivity extends MapsforgeActivity implements ItemizedLaye
|
||||
String file = intent.getStringExtra(FilePicker.SELECTED_FILE);
|
||||
mPersistenceManager = AndroidPoiPersistenceManagerFactory.getPoiPersistenceManager(file);
|
||||
|
||||
Bitmap bitmap = drawableToBitmap(getResources().getDrawable(R.drawable.marker_green));
|
||||
Bitmap bitmap = new AndroidBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.marker_green));
|
||||
MarkerSymbol symbol = new MarkerSymbol(bitmap, MarkerSymbol.HotspotPlace.BOTTOM_CENTER);
|
||||
mMarkerLayer = new ItemizedLayer<>(mMap, new ArrayList<MarkerItem>(), symbol, this);
|
||||
mMarkerLayer = new ItemizedLayer(mMap, new ArrayList<MarkerInterface>(), symbol, this);
|
||||
mMap.layers().add(mMarkerLayer);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemSingleTapUp(int index, MarkerItem item) {
|
||||
Toast.makeText(this, item.getTitle(), Toast.LENGTH_SHORT).show();
|
||||
public boolean onItemSingleTapUp(int index, MarkerInterface item) {
|
||||
MarkerItem markerItem = (MarkerItem) item;
|
||||
Toast.makeText(this, markerItem.getTitle(), Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemLongPress(int index, MarkerItem item) {
|
||||
public boolean onItemLongPress(int index, MarkerInterface item) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -325,7 +317,7 @@ public class PoiSearchActivity extends MapsforgeActivity implements ItemizedLaye
|
||||
}
|
||||
|
||||
// Overlay POI
|
||||
List<MarkerItem> pts = new ArrayList<>();
|
||||
List<MarkerInterface> pts = new ArrayList<>();
|
||||
for (PointOfInterest pointOfInterest : pointOfInterests)
|
||||
pts.add(new MarkerItem(pointOfInterest.getName(), "", new GeoPoint(pointOfInterest.getLatitude(), pointOfInterest.getLongitude())));
|
||||
mMarkerLayer.addItems(pts);
|
||||
|
||||
@@ -97,7 +97,7 @@ public class ReverseGeocodeActivity extends MapsforgeActivity {
|
||||
int tileYMax = MercatorProjection.pixelYToTileY(pixelY + touchRadius, (byte) mMap.getMapPosition().getZoomLevel());
|
||||
Tile upperLeft = new Tile(tileXMin, tileYMin, (byte) mMap.getMapPosition().getZoomLevel());
|
||||
Tile lowerRight = new Tile(tileXMax, tileYMax, (byte) mMap.getMapPosition().getZoomLevel());
|
||||
MapReadResult mapReadResult = ((MapDatabase) ((OverzoomTileDataSource) mTileSource.getDataSource()).getDataSource()).readLabels(upperLeft, lowerRight);
|
||||
MapReadResult mapReadResult = ((MapDatabase) ((OverzoomTileDataSource) mTileLayer.getTileSource().getDataSource()).getDataSource()).readLabels(upperLeft, lowerRight);
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
|
||||
@@ -1,78 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 Hannes Janetzek
|
||||
* Copyright 2016-2017 devemux86
|
||||
* Copyright 2017 Longri
|
||||
*
|
||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.android.test;
|
||||
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.oscim.layers.marker.MarkerItem;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class RotateMarkerOverlayActivity extends MarkerOverlayActivity {
|
||||
|
||||
private Timer timer;
|
||||
private int markerCount = 0;
|
||||
|
||||
private void itemEvent(final MarkerItem item) {
|
||||
if (item.getMarker() == null) {
|
||||
item.setMarker(mFocusMarker);
|
||||
markerCount++;
|
||||
final AtomicInteger rotValue = new AtomicInteger(0);
|
||||
if (timer != null)
|
||||
timer.cancel();
|
||||
timer = new Timer();
|
||||
TimerTask timerTask = new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
float value = (float) (rotValue.incrementAndGet() * 10);
|
||||
item.setRotation(value);
|
||||
if (rotValue.get() > 36)
|
||||
rotValue.set(0);
|
||||
mMarkerLayer.update();
|
||||
mMap.updateMap(true);
|
||||
}
|
||||
};
|
||||
timer.schedule(timerTask, 1000, 1000);
|
||||
|
||||
} else {
|
||||
item.setMarker(null);
|
||||
markerCount--;
|
||||
if (timer != null && markerCount == 0)
|
||||
timer.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemSingleTapUp(int index, MarkerItem item) {
|
||||
itemEvent(item);
|
||||
|
||||
Toast.makeText(this, "Marker tap\n" + item.getTitle(), Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemLongPress(int index, MarkerItem item) {
|
||||
itemEvent(item);
|
||||
|
||||
Toast.makeText(this, "Marker long press\n" + item.getTitle(), Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,15 @@
|
||||
/*
|
||||
* Copyright 2010, 2011, 2012, 2013 mapsforge.org
|
||||
* Copyright 2013 Hannes Janetzek
|
||||
* Copyright 2016-2019 devemux86
|
||||
* Copyright 2016-2020 devemux86
|
||||
* Copyright 2016 mar-v-in
|
||||
* Copyright 2016 Mathieu de Brito
|
||||
* Copyright 2017-2018 Longri
|
||||
* Copyright 2017 nebular
|
||||
* Copyright 2018 boldtrn
|
||||
* Copyright 2018-2019 Gustl22
|
||||
* Copyright 2019 Andrea Antonello
|
||||
* Copyright 2019 Kostas Tzounopoulos
|
||||
*
|
||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||
*
|
||||
@@ -26,7 +28,6 @@ package org.oscim.android.test;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
@@ -85,23 +86,18 @@ public class Samples extends Activity {
|
||||
LinearLayout linearLayout = findViewById(R.id.samples);
|
||||
linearLayout.addView(createButton(GettingStarted.class));
|
||||
linearLayout.addView(createLabel(null));
|
||||
linearLayout.addView(createButton(SimpleMapActivity.class));
|
||||
linearLayout.addView(createButton(MapsforgeActivity.class));
|
||||
linearLayout.addView(createButton(SimpleMapActivity.class));
|
||||
linearLayout.addView(createButton(MBTilesMvtActivity.class));
|
||||
linearLayout.addView(createButton(MapilionMvtActivity.class));
|
||||
/*linearLayout.addView(createButton(MapzenMvtActivity.class));
|
||||
linearLayout.addView(createButton(MapzenGeojsonActivity.class));*/
|
||||
linearLayout.addView(createButton(MapzenGeojsonActivity.class));
|
||||
linearLayout.addView(createButton(NextzenMvtActivity.class));
|
||||
linearLayout.addView(createButton(NextzenGeojsonActivity.class));
|
||||
linearLayout.addView(createButton(OpenMapTilesMvtActivity.class));
|
||||
linearLayout.addView(createButton(OpenMapTilesMvtActivity.class));*/
|
||||
linearLayout.addView(createButton(GdxActivity.class));
|
||||
|
||||
linearLayout.addView(createLabel("Features"));
|
||||
linearLayout.addView(createButton(null, "GraphHopper Routing", new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/graphhopper/graphhopper/tree/master/android")));
|
||||
}
|
||||
}));
|
||||
linearLayout.addView(createButton(LocationActivity.class));
|
||||
linearLayout.addView(createButton(LocationTextureActivity.class));
|
||||
linearLayout.addView(createButton(PoiSearchActivity.class));
|
||||
@@ -109,36 +105,26 @@ public class Samples extends Activity {
|
||||
linearLayout.addView(createLabel("Vector Features"));
|
||||
linearLayout.addView(createButton(MapsforgeStyleActivity.class));
|
||||
linearLayout.addView(createButton(MapsforgeS3DBActivity.class));
|
||||
linearLayout.addView(createButton(AtlasThemeActivity.class));
|
||||
linearLayout.addView(createButton(POTTextureActivity.class));
|
||||
linearLayout.addView(createButton(ShadowActivity.class));
|
||||
|
||||
linearLayout.addView(createLabel("Raster Maps"));
|
||||
linearLayout.addView(createButton(BitmapTileActivity.class));
|
||||
linearLayout.addView(createButton(MBTilesBitmapActivity.class));
|
||||
|
||||
linearLayout.addView(createLabel("Overlays"));
|
||||
linearLayout.addView(createButton(MarkerOverlayActivity.class));
|
||||
linearLayout.addView(createButton(RotateMarkerOverlayActivity.class));
|
||||
linearLayout.addView(createButton(AtlasMarkerOverlayActivity.class));
|
||||
linearLayout.addView(createButton(AtlasMultiTextureActivity.class));
|
||||
linearLayout.addView(createButton(ClusterMarkerOverlayActivity.class));
|
||||
linearLayout.addView(createButton(PathOverlayActivity.class));
|
||||
linearLayout.addView(createButton(LineTexActivity.class));
|
||||
linearLayout.addView(createButton(VectorLayerActivity.class));
|
||||
|
||||
linearLayout.addView(createLabel("User Interaction"));
|
||||
linearLayout.addView(createButton(MapEventLayer2Activity.class));
|
||||
linearLayout.addView(createButton(LayerGroupActivity.class));
|
||||
|
||||
linearLayout.addView(createLabel("Dual Map Views"));
|
||||
linearLayout.addView(createButton(MultiMapViewActivity.class));
|
||||
linearLayout.addView(createButton(AtlasMultiTextureActivity.class));
|
||||
|
||||
linearLayout.addView(createLabel("Experiments"));
|
||||
linearLayout.addView(createButton(ReverseGeocodeActivity.class));
|
||||
linearLayout.addView(createButton(OSciMapS3DBActivity.class));
|
||||
linearLayout.addView(createButton(ThemeStylerActivity.class));
|
||||
linearLayout.addView(createButton(JeoIndoorActivity.class));
|
||||
linearLayout.addView(createButton(GdxPoi3DActivity.class));
|
||||
linearLayout.addView(createButton(OverpassActivity.class));
|
||||
linearLayout.addView(createButton(ClusterMarkerOverlayActivity.class));
|
||||
linearLayout.addView(createButton(FragmentActivity.class));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,6 @@ import org.oscim.theme.ThemeLoader;
|
||||
import org.oscim.theme.VtmThemes;
|
||||
|
||||
public class SimpleMapActivity extends BaseMapActivity {
|
||||
private DefaultMapScaleBar mapScaleBar;
|
||||
|
||||
BuildingLayer mBuildingLayer;
|
||||
private boolean mShadow;
|
||||
@@ -71,7 +70,7 @@ public class SimpleMapActivity extends BaseMapActivity {
|
||||
groupLayer.layers.add(new LabelLayer(mMap, mBaseLayer));
|
||||
mMap.layers().add(groupLayer);
|
||||
|
||||
mapScaleBar = new DefaultMapScaleBar(mMap);
|
||||
DefaultMapScaleBar mapScaleBar = new DefaultMapScaleBar(mMap);
|
||||
mapScaleBar.setScaleBarMode(DefaultMapScaleBar.ScaleBarMode.BOTH);
|
||||
mapScaleBar.setDistanceUnitAdapter(MetricUnitAdapter.INSTANCE);
|
||||
mapScaleBar.setSecondaryDistanceUnitAdapter(ImperialUnitAdapter.INSTANCE);
|
||||
@@ -86,14 +85,6 @@ public class SimpleMapActivity extends BaseMapActivity {
|
||||
mMap.setTheme(VtmThemes.DEFAULT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
if (mapScaleBar != null)
|
||||
mapScaleBar.destroy();
|
||||
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
void runTheMonkey() {
|
||||
themes[0] = ThemeLoader.load(VtmThemes.DEFAULT);
|
||||
themes[1] = ThemeLoader.load(VtmThemes.OSMARENDER);
|
||||
|
||||
@@ -16,8 +16,8 @@ android {
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
versionCode versionCode()
|
||||
versionName versionName()
|
||||
versionCode project.versionCode()
|
||||
versionName project.versionName()
|
||||
minSdkVersion androidMinSdk()
|
||||
targetSdkVersion androidTargetSdk()
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2
vtm-android-mvt/AndroidManifest.xml
Normal file
2
vtm-android-mvt/AndroidManifest.xml
Normal file
@@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<manifest package="org.oscim.android.mvt" />
|
||||
55
vtm-android-mvt/build.gradle
Normal file
55
vtm-android-mvt/build.gradle
Normal file
@@ -0,0 +1,55 @@
|
||||
apply plugin: 'com.android.library'
|
||||
apply plugin: 'com.github.dcendents.android-maven'
|
||||
|
||||
dependencies {
|
||||
api project(':vtm-android')
|
||||
api project(':vtm-mvt')
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion androidCompileSdk()
|
||||
buildToolsVersion "$androidBuildVersionTools"
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_7
|
||||
targetCompatibility JavaVersion.VERSION_1_7
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
versionCode project.versionCode()
|
||||
versionName project.versionName()
|
||||
minSdkVersion androidMinSdk()
|
||||
targetSdkVersion androidTargetSdk()
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
manifest.srcFile 'AndroidManifest.xml'
|
||||
java.srcDirs = ['src']
|
||||
}
|
||||
debug.setRoot('build-types/debug')
|
||||
release.setRoot('build-types/release')
|
||||
}
|
||||
|
||||
lintOptions { abortOnError false }
|
||||
}
|
||||
|
||||
android.libraryVariants.all { variant ->
|
||||
def name = variant.buildType.name
|
||||
if (name == "debug")
|
||||
return
|
||||
|
||||
def jar = project.tasks.create "jar${name.capitalize()}", Jar
|
||||
jar.dependsOn variant.javaCompileProvider
|
||||
jar.exclude '**/BuildConfig.class'
|
||||
jar.exclude '**/R.class'
|
||||
jar.exclude '**/R$*.class'
|
||||
jar.from variant.javaCompileProvider.get().destinationDir
|
||||
artifacts.add('archives', jar)
|
||||
}
|
||||
|
||||
if (project.hasProperty("SONATYPE_USERNAME")) {
|
||||
afterEvaluate {
|
||||
project.apply from: "${rootProject.projectDir}/deploy.gradle"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
* Copyright 2019 Kostas Tzounopoulos
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.android.mvt.tiling.source.mbtiles;
|
||||
|
||||
import android.database.Cursor;
|
||||
import org.oscim.android.tiling.source.mbtiles.MBTilesTileDataSource;
|
||||
import org.oscim.android.tiling.source.mbtiles.MBTilesUnsupportedException;
|
||||
import org.oscim.core.MercatorProjection;
|
||||
import org.oscim.layers.tile.MapTile;
|
||||
import org.oscim.tiling.ITileDataSink;
|
||||
import org.oscim.tiling.OverzoomDataSink;
|
||||
import org.oscim.tiling.QueryResult;
|
||||
import org.oscim.tiling.source.mvt.TileDecoder;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
/**
|
||||
* A tile data source for MBTiles vector databases.
|
||||
*/
|
||||
public class MBTilesMvtTileDataSource extends MBTilesTileDataSource {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(MBTilesMvtTileDataSource.class);
|
||||
|
||||
private static final List<String> SUPPORTED_FORMATS = Collections.singletonList("pbf");
|
||||
private static final String WHERE_FORMAT = "zoom_level=%d AND tile_column=%d AND tile_row=%d";
|
||||
|
||||
private final String mLanguage;
|
||||
|
||||
private final ThreadLocal<TileDecoder> mThreadLocalDecoders = new ThreadLocal<TileDecoder>() {
|
||||
@Override
|
||||
protected TileDecoder initialValue() {
|
||||
return new TileDecoder(mLanguage);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Create a tile data source for MBTiles vector databases.
|
||||
*
|
||||
* @param path the path to the MBTiles database.
|
||||
* @param language the language to use when rendering the MBTiles.
|
||||
*/
|
||||
public MBTilesMvtTileDataSource(String path, String language) {
|
||||
super(path);
|
||||
mLanguage = language != null ? language : "en";
|
||||
|
||||
try {
|
||||
assertDatabaseFormat();
|
||||
} catch (MBTilesUnsupportedException e) {
|
||||
log.error("Invalid MBTiles database", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
if (mDatabase != null && mDatabase.isOpen())
|
||||
mDatabase.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSupportedFormats() {
|
||||
return SUPPORTED_FORMATS;
|
||||
}
|
||||
|
||||
private MapTile mapTile(Cursor cursor) {
|
||||
int tileX = cursor.getInt(cursor.getColumnIndexOrThrow("tile_column"));
|
||||
int tileY = cursor.getInt(cursor.getColumnIndexOrThrow("tile_row"));
|
||||
int zoomLevel = cursor.getInt(cursor.getColumnIndexOrThrow("zoom_level"));
|
||||
long tmsTileY = MercatorProjection.tileYToTMS(tileY, (byte) zoomLevel);
|
||||
return new MapTile(tileX, (int) tmsTileY, zoomLevel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overzoom on the DB layer: generate a query for all tiles with lower zoomLevel than the one requested.
|
||||
*/
|
||||
private String overzoomQuery(MapTile tile) {
|
||||
long tmsTileY = MercatorProjection.tileYToTMS(tile.tileY, tile.zoomLevel);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("(");
|
||||
for (int zoomLevel = tile.zoomLevel - 1; zoomLevel > 0; zoomLevel--) {
|
||||
int diff = tile.zoomLevel - zoomLevel;
|
||||
sb.append(String.format(Locale.US, WHERE_FORMAT, zoomLevel, tile.tileX >> diff, tmsTileY >> diff));
|
||||
if (zoomLevel > 1) // Not the last iteration
|
||||
sb.append(") OR (");
|
||||
}
|
||||
sb.append(")");
|
||||
return String.format(SELECT_TILES_FORMAT, sb.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void query(MapTile requestTile, ITileDataSink requestDataSink) {
|
||||
Cursor cursor = null;
|
||||
ITileDataSink responseDataSink = requestDataSink;
|
||||
try {
|
||||
long tmsTileY = MercatorProjection.tileYToTMS(requestTile.tileY, requestTile.zoomLevel);
|
||||
cursor = mDatabase.rawQuery(String.format(SELECT_TILES_FORMAT, String.format(Locale.US, WHERE_FORMAT, requestTile.zoomLevel, requestTile.tileX, tmsTileY)), null);
|
||||
|
||||
if (cursor.getCount() == 0) {
|
||||
cursor.close();
|
||||
cursor = mDatabase.rawQuery(overzoomQuery(requestTile), null);
|
||||
}
|
||||
|
||||
if (cursor.moveToFirst()) {
|
||||
byte[] bytes = cursor.getBlob(cursor.getColumnIndexOrThrow("tile_data"));
|
||||
|
||||
MapTile responseTile = mapTile(cursor);
|
||||
if (requestTile.zoomLevel != responseTile.zoomLevel)
|
||||
responseDataSink = new OverzoomDataSink(requestDataSink, responseTile, requestTile);
|
||||
|
||||
boolean success = mThreadLocalDecoders.get().decode(responseTile, responseDataSink, new GZIPInputStream(new ByteArrayInputStream(bytes)));
|
||||
responseDataSink.completed(success ? QueryResult.SUCCESS : QueryResult.FAILED);
|
||||
} else
|
||||
responseDataSink.completed(QueryResult.TILE_NOT_FOUND);
|
||||
} catch (IOException e) {
|
||||
responseDataSink.completed(QueryResult.FAILED);
|
||||
} finally {
|
||||
if (cursor != null)
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright 2019 Kostas Tzounopoulos
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.android.mvt.tiling.source.mbtiles;
|
||||
|
||||
import org.oscim.android.tiling.source.mbtiles.MBTilesTileSource;
|
||||
|
||||
/**
|
||||
* A tile source for MBTiles vector databases.
|
||||
*/
|
||||
public class MBTilesMvtTileSource extends MBTilesTileSource {
|
||||
|
||||
/**
|
||||
* Create a tile source for MBTiles vector databases.
|
||||
*
|
||||
* @param path the path to the MBTiles database.
|
||||
*/
|
||||
public MBTilesMvtTileSource(String path) {
|
||||
this(path, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a tile source for MBTiles vector databases.
|
||||
*
|
||||
* @param path the path to the MBTiles database.
|
||||
* @param language the language to use when rendering the MBTiles.
|
||||
*/
|
||||
public MBTilesMvtTileSource(String path, String language) {
|
||||
super(new MBTilesMvtTileDataSource(path, language));
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ apply plugin: 'com.github.dcendents.android-maven'
|
||||
|
||||
dependencies {
|
||||
api project(':vtm')
|
||||
api 'com.caverock:androidsvg:1.3'
|
||||
api 'com.caverock:androidsvg:1.4'
|
||||
}
|
||||
|
||||
android {
|
||||
@@ -16,8 +16,8 @@ android {
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
versionCode versionCode()
|
||||
versionName versionName()
|
||||
versionCode project.versionCode()
|
||||
versionName project.versionName()
|
||||
minSdkVersion androidMinSdk()
|
||||
targetSdkVersion androidTargetSdk()
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright 2012 Hannes Janetzek
|
||||
* Copyright 2016-2019 devemux86
|
||||
* Copyright 2016-2020 devemux86
|
||||
* Copyright 2018-2019 Gustl22
|
||||
*
|
||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||
@@ -28,7 +28,6 @@ import android.util.DisplayMetrics;
|
||||
import android.view.Display;
|
||||
import android.view.GestureDetector;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import org.oscim.android.canvas.AndroidGraphics;
|
||||
import org.oscim.android.gl.AndroidGL;
|
||||
import org.oscim.android.gl.AndroidGL30;
|
||||
@@ -47,11 +46,10 @@ import org.oscim.utils.Parameters;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.microedition.khronos.egl.EGLConfig;
|
||||
import javax.microedition.khronos.opengles.GL10;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* The MapView,
|
||||
@@ -67,12 +65,21 @@ public class MapView extends GLSurfaceView {
|
||||
private static final Pattern GL_PATTERN = Pattern.compile("OpenGL ES (\\d(\\.\\d){0,2})");
|
||||
|
||||
/**
|
||||
* Target OpenGL ES version, if not available fall back to OpenGL ES 2.0
|
||||
* OpenGL ES 2.0 default on Android for performance / stability.
|
||||
* Any larger not available versions fall back to OpenGL ES 2.0.
|
||||
*/
|
||||
public static double targetGLESVersion = 3.0;
|
||||
public static double OPENGL_VERSION = 2.0;
|
||||
|
||||
private static void init() {
|
||||
System.loadLibrary("vtm-jni");
|
||||
if (Parameters.THREADED_INIT)
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
System.loadLibrary("vtm-jni");
|
||||
}
|
||||
}).start();
|
||||
else
|
||||
System.loadLibrary("vtm-jni");
|
||||
}
|
||||
|
||||
protected AndroidMap mMap;
|
||||
@@ -105,7 +112,7 @@ public class MapView extends GLSurfaceView {
|
||||
DateTimeAdapter.init(new DateTime());
|
||||
|
||||
DisplayMetrics metrics = getResources().getDisplayMetrics();
|
||||
CanvasAdapter.dpi = (int) (metrics.scaledDensity * CanvasAdapter.DEFAULT_DPI);
|
||||
CanvasAdapter.dpi = (int) (metrics.density * CanvasAdapter.DEFAULT_DPI);
|
||||
if (!Parameters.CUSTOM_TILE_SIZE)
|
||||
Tile.SIZE = Tile.calculateTileSize();
|
||||
|
||||
@@ -127,11 +134,19 @@ public class MapView extends GLSurfaceView {
|
||||
mMap = new AndroidMap(this);
|
||||
|
||||
/* Initialize Renderer */
|
||||
try {
|
||||
setEGLContextFactory(new GlContextFactory());
|
||||
} catch (Throwable t) {
|
||||
log.error("Falling back to GLES 2", t);
|
||||
if (OPENGL_VERSION == 2.0)
|
||||
setEGLContextClientVersion(2);
|
||||
else {
|
||||
// OpenGL ES 3.0 is supported with Android 4.3 (API level 18) and higher
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
|
||||
try {
|
||||
setEGLContextFactory(new GlContextFactory());
|
||||
} catch (Throwable t) {
|
||||
log.error("Falling back to GLES 2", t);
|
||||
setEGLContextClientVersion(2);
|
||||
}
|
||||
} else
|
||||
setEGLContextClientVersion(2);
|
||||
}
|
||||
setEGLConfigChooser(new GlConfigChooser());
|
||||
|
||||
@@ -344,23 +359,27 @@ public class MapView extends GLSurfaceView {
|
||||
|
||||
@Override
|
||||
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
|
||||
try {
|
||||
// Create a minimum supported OpenGL ES context, then check:
|
||||
String versionString = gl.glGetString(GL10.GL_VERSION);
|
||||
log.info("Version: " + versionString);
|
||||
// The version format is displayed as: "OpenGL ES <major>.<minor>"
|
||||
// followed by optional content provided by the implementation.
|
||||
|
||||
// OpenGL<space>ES<space><version number><space><vendor-specific information>.
|
||||
int[] version = extractVersion(versionString);
|
||||
int majorVersion = version[0];
|
||||
if (majorVersion >= 3)
|
||||
GLAdapter.init(new AndroidGL30());
|
||||
else
|
||||
GLAdapter.init(new AndroidGL());
|
||||
} catch (Throwable t) {
|
||||
log.error("Falling back to GLES 2", t);
|
||||
if (OPENGL_VERSION == 2.0)
|
||||
GLAdapter.init(new AndroidGL());
|
||||
else {
|
||||
try {
|
||||
// Create a minimum supported OpenGL ES context, then check:
|
||||
String versionString = gl.glGetString(GL10.GL_VERSION);
|
||||
log.info("Version: " + versionString);
|
||||
// The version format is displayed as: "OpenGL ES <major>.<minor>"
|
||||
// followed by optional content provided by the implementation.
|
||||
|
||||
// OpenGL<space>ES<space><version number><space><vendor-specific information>.
|
||||
int[] version = extractVersion(versionString);
|
||||
int majorVersion = Math.min(version[0], (int) OPENGL_VERSION);
|
||||
if (majorVersion >= 3)
|
||||
GLAdapter.init(new AndroidGL30());
|
||||
else
|
||||
GLAdapter.init(new AndroidGL());
|
||||
} catch (Throwable t) {
|
||||
log.error("Falling back to GLES 2", t);
|
||||
GLAdapter.init(new AndroidGL());
|
||||
}
|
||||
}
|
||||
|
||||
super.onSurfaceCreated();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Copyright 2013 Hannes Janetzek
|
||||
* Copyright 2016 Longri
|
||||
* Copyright 2016-2018 devemux86
|
||||
* Copyright 2016-2021 devemux86
|
||||
*
|
||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||
*
|
||||
@@ -22,7 +22,6 @@ import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.opengl.GLES20;
|
||||
import android.opengl.GLUtils;
|
||||
|
||||
import org.oscim.backend.CanvasAdapter;
|
||||
import org.oscim.utils.GraphicUtils;
|
||||
import org.oscim.utils.IOUtils;
|
||||
@@ -39,6 +38,7 @@ public class AndroidBitmap implements org.oscim.backend.canvas.Bitmap {
|
||||
Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
|
||||
try {
|
||||
GLUtils.getType(bitmap);
|
||||
GLUtils.getInternalFormat(bitmap);
|
||||
} catch (IllegalArgumentException e) {
|
||||
bitmap = bitmap.copy(ARGB_8888, false);
|
||||
}
|
||||
@@ -95,6 +95,9 @@ public class AndroidBitmap implements org.oscim.backend.canvas.Bitmap {
|
||||
|
||||
@Override
|
||||
public void uploadToTexture(boolean replace) {
|
||||
if (mBitmap.isRecycled())
|
||||
return;
|
||||
|
||||
int format = GLUtils.getInternalFormat(mBitmap);
|
||||
int type = GLUtils.getType(mBitmap);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright 2013 Hannes Janetzek
|
||||
* Copyright 2016-2017 devemux86
|
||||
* Copyright 2016-2019 devemux86
|
||||
* Copyright 2017 nebular
|
||||
* Copyright 2017 Longri
|
||||
*
|
||||
@@ -21,8 +21,8 @@ package org.oscim.android.canvas;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffXfermode;
|
||||
import android.graphics.RectF;
|
||||
|
||||
import org.oscim.backend.canvas.Bitmap;
|
||||
import org.oscim.backend.canvas.Canvas;
|
||||
import org.oscim.backend.canvas.Paint;
|
||||
@@ -93,6 +93,7 @@ public class AndroidCanvas implements Canvas {
|
||||
RectF rect = new RectF(x, y, x + width, y + height);
|
||||
android.graphics.Paint paint = new android.graphics.Paint();
|
||||
paint.setColor(color);
|
||||
paint.setXfermode(new PorterDuffXfermode(color == Color.TRANSPARENT ? PorterDuff.Mode.CLEAR : PorterDuff.Mode.SRC_OVER));
|
||||
canvas.drawRect(rect, paint);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010, 2011, 2012 mapsforge.org
|
||||
* Copyright 2016-2018 devemux86
|
||||
* Copyright 2016-2019 devemux86
|
||||
* Copyright 2017 Longri
|
||||
*
|
||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||
@@ -22,7 +22,7 @@ import android.content.res.Resources;
|
||||
import android.graphics.Bitmap.Config;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
import android.os.Build;
|
||||
import org.oscim.backend.CanvasAdapter;
|
||||
import org.oscim.backend.Platform;
|
||||
import org.oscim.backend.canvas.Bitmap;
|
||||
@@ -30,6 +30,7 @@ import org.oscim.backend.canvas.Canvas;
|
||||
import org.oscim.backend.canvas.Paint;
|
||||
import org.oscim.layers.marker.MarkerSymbol;
|
||||
import org.oscim.layers.marker.MarkerSymbol.HotspotPlace;
|
||||
import org.oscim.theme.XmlThemeResourceProvider;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@@ -69,8 +70,8 @@ public final class AndroidGraphics extends CanvasAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bitmap loadBitmapAssetImpl(String relativePathPrefix, String src, int width, int height, int percent) throws IOException {
|
||||
return createBitmap(relativePathPrefix, src, width, height, percent);
|
||||
public Bitmap loadBitmapAssetImpl(String relativePathPrefix, String src, XmlThemeResourceProvider resourceProvider, int width, int height, int percent) throws IOException {
|
||||
return createBitmap(relativePathPrefix, src, resourceProvider, width, height, percent);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -90,7 +91,7 @@ public final class AndroidGraphics extends CanvasAdapter {
|
||||
|
||||
//-------------------------------------
|
||||
public static Bitmap drawableToBitmap(Drawable drawable) {
|
||||
if (drawable instanceof BitmapDrawable) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P && drawable instanceof BitmapDrawable) {
|
||||
return new AndroidBitmap(((BitmapDrawable) drawable).getBitmap());
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
package org.oscim.android.gl;
|
||||
|
||||
import android.opengl.GLSurfaceView;
|
||||
|
||||
import org.oscim.android.MapView;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -51,18 +50,18 @@ public class GlContextFactory implements GLSurfaceView.EGLContextFactory {
|
||||
|
||||
@Override
|
||||
public EGLContext createContext(EGL10 egl, EGLDisplay display, EGLConfig eglConfig) {
|
||||
log.info("creating OpenGL ES " + MapView.targetGLESVersion + " context");
|
||||
checkEglError("Before eglCreateContext " + MapView.targetGLESVersion, egl);
|
||||
int[] attrib_list = {EGL_CONTEXT_CLIENT_VERSION, (int) MapView.targetGLESVersion, EGL10.EGL_NONE};
|
||||
log.info("creating OpenGL ES " + MapView.OPENGL_VERSION + " context");
|
||||
checkEglError("Before eglCreateContext " + MapView.OPENGL_VERSION, egl);
|
||||
int[] attrib_list = {EGL_CONTEXT_CLIENT_VERSION, (int) MapView.OPENGL_VERSION, EGL10.EGL_NONE};
|
||||
EGLContext context = egl.eglCreateContext(display, eglConfig, EGL10.EGL_NO_CONTEXT, attrib_list);
|
||||
boolean success = checkEglError("After eglCreateContext " + MapView.targetGLESVersion, egl);
|
||||
boolean success = checkEglError("After eglCreateContext " + MapView.OPENGL_VERSION, egl);
|
||||
|
||||
if ((!success || context == null) && MapView.targetGLESVersion > 2) {
|
||||
if ((!success || context == null) && MapView.OPENGL_VERSION > 2) {
|
||||
log.warn("Falling back to GLES 2");
|
||||
MapView.targetGLESVersion = 2.0;
|
||||
MapView.OPENGL_VERSION = 2.0;
|
||||
return createContext(egl, display, eglConfig);
|
||||
}
|
||||
log.info("Returning a GLES " + MapView.targetGLESVersion + " context");
|
||||
log.info("Returning a GLES " + MapView.OPENGL_VERSION + " context");
|
||||
return context;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
/*
|
||||
* Copyright 2010, 2011, 2012 mapsforge.org
|
||||
* Copyright 2016-2017 devemux86
|
||||
* Copyright 2016-2021 devemux86
|
||||
* Copyright 2017 Andrey Novikov
|
||||
* Copyright 2021 eddiemuc
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
@@ -18,11 +19,10 @@ package org.oscim.android.theme;
|
||||
|
||||
import android.content.res.AssetManager;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import org.oscim.theme.IRenderTheme.ThemeException;
|
||||
import org.oscim.theme.ThemeFile;
|
||||
import org.oscim.theme.ThemeUtils;
|
||||
import org.oscim.theme.XmlRenderThemeMenuCallback;
|
||||
import org.oscim.theme.XmlThemeResourceProvider;
|
||||
import org.oscim.utils.Utils;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -37,8 +37,10 @@ public class AssetsRenderTheme implements ThemeFile {
|
||||
|
||||
private final AssetManager mAssetManager;
|
||||
private final String mFileName;
|
||||
private boolean mMapsforgeTheme;
|
||||
private XmlRenderThemeMenuCallback mMenuCallback;
|
||||
private final String mRelativePathPrefix;
|
||||
private XmlThemeResourceProvider mResourceProvider;
|
||||
|
||||
/**
|
||||
* @param assetManager the Android asset manager.
|
||||
@@ -100,13 +102,28 @@ public class AssetsRenderTheme implements ThemeFile {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public XmlThemeResourceProvider getResourceProvider() {
|
||||
return mResourceProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMapsforgeTheme() {
|
||||
return ThemeUtils.isMapsforgeTheme(this);
|
||||
return mMapsforgeTheme;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMapsforgeTheme(boolean mapsforgeTheme) {
|
||||
mMapsforgeTheme = mapsforgeTheme;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMenuCallback(XmlRenderThemeMenuCallback menuCallback) {
|
||||
mMenuCallback = menuCallback;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setResourceProvider(XmlThemeResourceProvider resourceProvider) {
|
||||
mResourceProvider = resourceProvider;
|
||||
}
|
||||
}
|
||||
|
||||
119
vtm-android/src/org/oscim/android/theme/ContentRenderTheme.java
Normal file
119
vtm-android/src/org/oscim/android/theme/ContentRenderTheme.java
Normal file
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* Copyright 2020-2021 devemux86
|
||||
* Copyright 2021 eddiemuc
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.android.theme;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.net.Uri;
|
||||
import org.oscim.theme.IRenderTheme.ThemeException;
|
||||
import org.oscim.theme.ThemeFile;
|
||||
import org.oscim.theme.XmlRenderThemeMenuCallback;
|
||||
import org.oscim.theme.XmlThemeResourceProvider;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* An ContentRenderTheme allows for customizing the rendering style of the map
|
||||
* via an XML from the Android content providers.
|
||||
*/
|
||||
public class ContentRenderTheme implements ThemeFile {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final ContentResolver mContentResolver;
|
||||
private boolean mMapsforgeTheme;
|
||||
private XmlRenderThemeMenuCallback mMenuCallback;
|
||||
private XmlThemeResourceProvider mResourceProvider;
|
||||
private final Uri mUri;
|
||||
|
||||
/**
|
||||
* @param contentResolver the Android content resolver.
|
||||
* @param uri the XML render theme URI.
|
||||
* @throws ThemeException if an error occurs while reading the render theme XML.
|
||||
*/
|
||||
public ContentRenderTheme(ContentResolver contentResolver, Uri uri) throws ThemeException {
|
||||
this(contentResolver, uri, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param contentResolver the Android content resolver.
|
||||
* @param uri the XML render theme URI.
|
||||
* @param menuCallback the interface callback to create a settings menu on the fly.
|
||||
* @throws ThemeException if an error occurs while reading the render theme XML.
|
||||
*/
|
||||
public ContentRenderTheme(ContentResolver contentResolver, Uri uri, XmlRenderThemeMenuCallback menuCallback) throws ThemeException {
|
||||
mContentResolver = contentResolver;
|
||||
mUri = uri;
|
||||
mMenuCallback = menuCallback;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
} else if (!(obj instanceof ContentRenderTheme)) {
|
||||
return false;
|
||||
}
|
||||
ContentRenderTheme other = (ContentRenderTheme) obj;
|
||||
if (getRenderThemeAsStream() != other.getRenderThemeAsStream()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XmlRenderThemeMenuCallback getMenuCallback() {
|
||||
return mMenuCallback;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRelativePathPrefix() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getRenderThemeAsStream() throws ThemeException {
|
||||
try {
|
||||
return mContentResolver.openInputStream(mUri);
|
||||
} catch (IOException e) {
|
||||
throw new ThemeException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public XmlThemeResourceProvider getResourceProvider() {
|
||||
return mResourceProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMapsforgeTheme() {
|
||||
return mMapsforgeTheme;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMapsforgeTheme(boolean mapsforgeTheme) {
|
||||
mMapsforgeTheme = mapsforgeTheme;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMenuCallback(XmlRenderThemeMenuCallback menuCallback) {
|
||||
mMenuCallback = menuCallback;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setResourceProvider(XmlThemeResourceProvider resourceProvider) {
|
||||
mResourceProvider = resourceProvider;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,179 @@
|
||||
/*
|
||||
* Copyright 2021 eddiemuc
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.android.theme;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.provider.DocumentsContract;
|
||||
import org.oscim.backend.CanvasAdapter;
|
||||
import org.oscim.theme.XmlThemeResourceProvider;
|
||||
import org.oscim.utils.IOUtils;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* An xml theme resource provider resolving resources using Android scoped storage (document framework).
|
||||
* <p>
|
||||
* Implementation note: these methods do not use DocumentFile internally,
|
||||
* but query directly for document info due to vastly better performance.
|
||||
* Also for better performance, this implementation caches resource uris.
|
||||
* <p>
|
||||
* Note: this implementation requires minimum Android 5.0 (API 21)
|
||||
*/
|
||||
public class ContentResolverResourceProvider implements XmlThemeResourceProvider {
|
||||
|
||||
private final ContentResolver contentResolver;
|
||||
private final Uri relativeRootUri;
|
||||
private final boolean isDocumentUri;
|
||||
|
||||
private final Map<String, Uri> resourceUriCache = new HashMap<>();
|
||||
|
||||
private static class DocumentInfo {
|
||||
private final String name;
|
||||
private final Uri uri;
|
||||
private final boolean isDirectory;
|
||||
|
||||
private DocumentInfo(String name, Uri uri, boolean isDirectory) {
|
||||
this.name = name;
|
||||
this.uri = uri;
|
||||
this.isDirectory = isDirectory;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new content resolver resource provider.
|
||||
*
|
||||
* @param contentResolver content resolver used to read content.
|
||||
* @param relativeRootUri uri pointing to a directory.
|
||||
* Uri is assumed to be a pure tree Uri (as e.g. returned by {@link Intent#ACTION_OPEN_DOCUMENT_TREE}).
|
||||
*/
|
||||
public ContentResolverResourceProvider(ContentResolver contentResolver, Uri relativeRootUri) {
|
||||
this(contentResolver, relativeRootUri, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new content resolver resource provider.
|
||||
*
|
||||
* @param contentResolver content resolver used to read content.
|
||||
* @param relativeRootUri uri pointing to a directory.
|
||||
* @param isDocumentUri Uris as returned e.g. by {@link Intent#ACTION_OPEN_DOCUMENT_TREE}) cannot directly be used to scan directories and read content.
|
||||
* They must be converted to document uris first using {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}.
|
||||
* However, in some situations this conversion was done previously by caller (e.g. if root dir should be subdirectory of a directory returned by {@link Intent#ACTION_OPEN_DOCUMENT_TREE}).
|
||||
* In these cases, converted Uri will point to original root directory which is not always the wanted behaviour.
|
||||
* Thus, this parameter allows caller to control whether conversion should be done or not.
|
||||
* If set to true, then given Uri is considered to be a document uri already and no conversion is done.
|
||||
* If set to false, uri is considered to be a pure tree uri as returned e.g. by {@link Intent#ACTION_OPEN_DOCUMENT_TREE}) and it is converted.
|
||||
*/
|
||||
public ContentResolverResourceProvider(ContentResolver contentResolver, Uri relativeRootUri, boolean isDocumentUri) {
|
||||
this.contentResolver = contentResolver;
|
||||
this.relativeRootUri = relativeRootUri;
|
||||
this.isDocumentUri = isDocumentUri;
|
||||
|
||||
refreshCache();
|
||||
}
|
||||
|
||||
/**
|
||||
* Build uri cache for one dir level (recursive function).
|
||||
*/
|
||||
private void buildCacheLevel(String prefix, Uri dirUri) {
|
||||
List<DocumentInfo> docs = queryDir(dirUri);
|
||||
for (DocumentInfo doc : docs) {
|
||||
if (doc.isDirectory) {
|
||||
buildCacheLevel(prefix + doc.name + "/", doc.uri);
|
||||
} else {
|
||||
// Store both relative urls and absolute urls
|
||||
resourceUriCache.put(CanvasAdapter.PREFIX_FILE + prefix + doc.name, doc.uri);
|
||||
resourceUriCache.put(CanvasAdapter.PREFIX_FILE + "/" + prefix + doc.name, doc.uri);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream createInputStream(String relativePath, String source) throws FileNotFoundException {
|
||||
Uri docUri = resourceUriCache.get(source);
|
||||
if (docUri != null) {
|
||||
return contentResolver.openInputStream(docUri);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Query the content of a directory using scoped storage.
|
||||
*
|
||||
* @return a list of arrays with info [0: name (String), 1: uri (Uri), 2: isDir (boolean)]
|
||||
*/
|
||||
private List<DocumentInfo> queryDir(Uri dirUri) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
if (dirUri == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
List<DocumentInfo> result = new ArrayList<>();
|
||||
Uri childrenUri = DocumentsContract.buildChildDocumentsUriUsingTree(dirUri, DocumentsContract.getDocumentId(dirUri));
|
||||
|
||||
String[] columns = new String[]{
|
||||
DocumentsContract.Document.COLUMN_DOCUMENT_ID,
|
||||
DocumentsContract.Document.COLUMN_DISPLAY_NAME,
|
||||
DocumentsContract.Document.COLUMN_MIME_TYPE
|
||||
};
|
||||
|
||||
Cursor c = null;
|
||||
try {
|
||||
c = contentResolver.query(childrenUri, columns, null, null, null);
|
||||
|
||||
while (c.moveToNext()) {
|
||||
String documentId = c.getString(0);
|
||||
String name = c.getString(1);
|
||||
String mimeType = c.getString(2);
|
||||
|
||||
Uri uri = DocumentsContract.buildDocumentUriUsingTree(dirUri, documentId);
|
||||
boolean isDir = DocumentsContract.Document.MIME_TYPE_DIR.equals(mimeType);
|
||||
result.add(new DocumentInfo(name, uri, isDir));
|
||||
}
|
||||
|
||||
return result;
|
||||
} finally {
|
||||
IOUtils.closeQuietly(c);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh the uri cache by recreating it.
|
||||
*/
|
||||
private void refreshCache() {
|
||||
resourceUriCache.clear();
|
||||
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
||||
return;
|
||||
}
|
||||
if (relativeRootUri == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Uri dirUri = relativeRootUri;
|
||||
if (!isDocumentUri) {
|
||||
// Convert "tree uri" to a "document uri"
|
||||
dirUri = DocumentsContract.buildDocumentUriUsingTree(dirUri, DocumentsContract.getTreeDocumentId(dirUri));
|
||||
}
|
||||
buildCacheLevel("", dirUri);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
* Copyright 2019 Andrea Antonello
|
||||
* Copyright 2019 devemux86
|
||||
* Copyright 2019 Kostas Tzounopoulos
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.android.tiling.source.mbtiles;
|
||||
|
||||
import android.database.Cursor;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import org.oscim.backend.CanvasAdapter;
|
||||
import org.oscim.backend.canvas.Bitmap;
|
||||
import org.oscim.core.MercatorProjection;
|
||||
import org.oscim.layers.tile.MapTile;
|
||||
import org.oscim.tiling.ITileDataSink;
|
||||
import org.oscim.tiling.QueryResult;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A tile data source for MBTiles raster databases.
|
||||
*/
|
||||
public class MBTilesBitmapTileDataSource extends MBTilesTileDataSource {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(MBTilesBitmapTileDataSource.class);
|
||||
|
||||
private static final List<String> SUPPORTED_FORMATS = Arrays.asList("png", "jpg", "jpeg");
|
||||
|
||||
private final Integer mAlpha;
|
||||
private final Integer mTransparentColor;
|
||||
|
||||
/**
|
||||
* Create a tile data source for MBTiles raster databases.
|
||||
*
|
||||
* @param path the path to the MBTiles database.
|
||||
* @param alpha an optional alpha value [0-255] to make the tiles transparent.
|
||||
* @param transparentColor an optional color that will be made transparent in the bitmap.
|
||||
*/
|
||||
public MBTilesBitmapTileDataSource(String path, Integer alpha, Integer transparentColor) {
|
||||
super(path);
|
||||
mAlpha = alpha;
|
||||
mTransparentColor = transparentColor;
|
||||
|
||||
try {
|
||||
assertDatabaseFormat();
|
||||
} catch (MBTilesUnsupportedException e) {
|
||||
log.error("Invalid MBTiles database", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel() {
|
||||
if (mDatabase != null && mDatabase.isOpen())
|
||||
mDatabase.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
if (mDatabase != null && mDatabase.isOpen())
|
||||
mDatabase.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSupportedFormats() {
|
||||
return SUPPORTED_FORMATS;
|
||||
}
|
||||
|
||||
private static android.graphics.Bitmap processAlpha(android.graphics.Bitmap bitmap, int alpha) {
|
||||
android.graphics.Bitmap newBitmap = android.graphics.Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), android.graphics.Bitmap.Config.ARGB_8888);
|
||||
Canvas canvas = new Canvas(newBitmap);
|
||||
Paint paint = new Paint();
|
||||
paint.setAlpha(alpha);
|
||||
canvas.drawBitmap(bitmap, 0, 0, paint);
|
||||
return newBitmap;
|
||||
}
|
||||
|
||||
private static android.graphics.Bitmap processTransparentColor(android.graphics.Bitmap bitmap, int colorToRemove) {
|
||||
int[] pixels = new int[bitmap.getWidth() * bitmap.getHeight()];
|
||||
bitmap.getPixels(pixels, 0, bitmap.getWidth(), 0, 0, bitmap.getWidth(), bitmap.getHeight());
|
||||
for (int i = 0; i < pixels.length; i++) {
|
||||
if (pixels[i] == colorToRemove)
|
||||
pixels[i] = Color.alpha(Color.TRANSPARENT);
|
||||
}
|
||||
android.graphics.Bitmap newBitmap = android.graphics.Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), android.graphics.Bitmap.Config.ARGB_8888);
|
||||
newBitmap.setPixels(pixels, 0, newBitmap.getWidth(), 0, 0, newBitmap.getWidth(), newBitmap.getHeight());
|
||||
return newBitmap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void query(MapTile tile, ITileDataSink sink) {
|
||||
QueryResult res = QueryResult.FAILED;
|
||||
try {
|
||||
byte[] bytes = readTile(tile.tileX, tile.tileY, tile.zoomLevel);
|
||||
|
||||
if (mTransparentColor != null || mAlpha != null) {
|
||||
android.graphics.Bitmap androidBitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
|
||||
if (mTransparentColor != null)
|
||||
androidBitmap = processTransparentColor(androidBitmap, mTransparentColor);
|
||||
if (mAlpha != null)
|
||||
androidBitmap = processAlpha(androidBitmap, mAlpha);
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
androidBitmap.compress(android.graphics.Bitmap.CompressFormat.PNG, 100, bos);
|
||||
bytes = bos.toByteArray();
|
||||
}
|
||||
|
||||
Bitmap bitmap = CanvasAdapter.decodeBitmap(new ByteArrayInputStream(bytes));
|
||||
sink.setTileImage(bitmap);
|
||||
res = QueryResult.SUCCESS;
|
||||
} catch (Exception e) {
|
||||
log.debug("{} invalid bitmap", tile);
|
||||
} finally {
|
||||
sink.completed(res);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a Tile's image bytes from the MBTiles database.
|
||||
*
|
||||
* @param tileX the x tile index.
|
||||
* @param tileY the y tile index (OSM notation).
|
||||
* @param zoomLevel the zoom level.
|
||||
* @return the tile image bytes.
|
||||
*/
|
||||
private byte[] readTile(int tileX, int tileY, byte zoomLevel) {
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
long tmsTileY = MercatorProjection.tileYToTMS(tileY, zoomLevel);
|
||||
cursor = mDatabase.rawQuery(String.format(MBTilesTileDataSource.SELECT_TILES_FORMAT, MBTilesTileDataSource.WHERE_FORMAT), new String[]{String.valueOf(zoomLevel), String.valueOf(tileX), String.valueOf(tmsTileY)});
|
||||
if (cursor.moveToFirst())
|
||||
return cursor.getBlob(cursor.getColumnIndexOrThrow("tile_data"));
|
||||
} finally {
|
||||
if (cursor != null)
|
||||
cursor.close();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright 2019 Andrea Antonello
|
||||
* Copyright 2019 devemux86
|
||||
* Copyright 2019 Kostas Tzounopoulos
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.android.tiling.source.mbtiles;
|
||||
|
||||
/**
|
||||
* A tile source for MBTiles raster databases.
|
||||
*/
|
||||
public class MBTilesBitmapTileSource extends MBTilesTileSource {
|
||||
|
||||
/**
|
||||
* Create a tile source for MBTiles raster databases.
|
||||
*
|
||||
* @param path the path to the MBTiles database.
|
||||
*/
|
||||
public MBTilesBitmapTileSource(String path) {
|
||||
this(path, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a tile source for MBTiles raster databases.
|
||||
*
|
||||
* @param path the path to the MBTiles database.
|
||||
* @param alpha an optional alpha value [0-255] to make the tiles transparent.
|
||||
* @param transparentColor an optional color that will be made transparent in the bitmap.
|
||||
*/
|
||||
public MBTilesBitmapTileSource(String path, Integer alpha, Integer transparentColor) {
|
||||
super(new MBTilesBitmapTileDataSource(path, alpha, transparentColor));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
* Copyright 2019 Andrea Antonello
|
||||
* Copyright 2019 devemux86
|
||||
* Copyright 2019 Kostas Tzounopoulos
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.android.tiling.source.mbtiles;
|
||||
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.text.TextUtils;
|
||||
import org.oscim.core.BoundingBox;
|
||||
import org.oscim.core.MapPosition;
|
||||
import org.oscim.map.Viewport;
|
||||
import org.oscim.tiling.ITileDataSource;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* A tile data source for MBTiles databases.
|
||||
*/
|
||||
public abstract class MBTilesTileDataSource implements ITileDataSource {
|
||||
|
||||
private static final String SELECT_METADATA = "SELECT name, value FROM metadata";
|
||||
protected static final String SELECT_TILES_FORMAT =
|
||||
"SELECT zoom_level, tile_column, tile_row, tile_data " +
|
||||
"FROM tiles " +
|
||||
"WHERE %s " +
|
||||
"ORDER BY zoom_level DESC " +
|
||||
"LIMIT 1";
|
||||
static final String WHERE_FORMAT = "zoom_level=? AND tile_column=? AND tile_row=?";
|
||||
|
||||
protected final SQLiteDatabase mDatabase;
|
||||
private Map<String, String> mMetadata;
|
||||
|
||||
public MBTilesTileDataSource(String path) {
|
||||
mDatabase = SQLiteDatabase.openDatabase(path, null, SQLiteDatabase.OPEN_READONLY);
|
||||
}
|
||||
|
||||
protected void assertDatabaseFormat() {
|
||||
String format = getFormat();
|
||||
|
||||
if (format == null)
|
||||
throw new RuntimeException("'metadata.format' field was not found. Is this an MBTiles database?");
|
||||
|
||||
List<String> supportedFormats = getSupportedFormats();
|
||||
if (!supportedFormats.contains(format))
|
||||
throw new MBTilesUnsupportedException(String.format("Unsupported MBTiles 'metadata.format: %s'. Supported format(s) are: %s", format, TextUtils.join(", ", supportedFormats)));
|
||||
}
|
||||
|
||||
public String getAttribution() {
|
||||
return getMetadata().get("attribution");
|
||||
}
|
||||
|
||||
public BoundingBox getBounds() {
|
||||
String bounds = getMetadata().get("bounds");
|
||||
if (bounds == null)
|
||||
return null;
|
||||
String[] split = bounds.split(",");
|
||||
double w = Double.parseDouble(split[0]);
|
||||
double s = Double.parseDouble(split[1]);
|
||||
double e = Double.parseDouble(split[2]);
|
||||
double n = Double.parseDouble(split[3]);
|
||||
return new BoundingBox(s, w, n, e);
|
||||
}
|
||||
|
||||
public MapPosition getCenter() {
|
||||
String center = getMetadata().get("center");
|
||||
if (center == null)
|
||||
return null;
|
||||
String[] split = center.split(",");
|
||||
double latitude = Double.parseDouble(split[1]);
|
||||
double longitude = Double.parseDouble(split[0]);
|
||||
int zoomLevel = Integer.parseInt(split[2]);
|
||||
return new MapPosition(latitude, longitude, 1 << zoomLevel);
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return getMetadata().get("description");
|
||||
}
|
||||
|
||||
public String getFormat() {
|
||||
return getMetadata().get("format");
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return getMetadata().get("id");
|
||||
}
|
||||
|
||||
public String getJson() {
|
||||
return getMetadata().get("json");
|
||||
}
|
||||
|
||||
public int getMaxZoom() {
|
||||
String maxZoom = getMetadata().get("maxzoom");
|
||||
return maxZoom != null ? Integer.parseInt(maxZoom) : Viewport.MAX_ZOOM_LEVEL;
|
||||
}
|
||||
|
||||
private Map<String, String> getMetadata() {
|
||||
if (mMetadata == null) {
|
||||
mMetadata = new HashMap<>();
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
cursor = mDatabase.rawQuery(SELECT_METADATA, null);
|
||||
while (cursor.moveToNext()) {
|
||||
String key = cursor.getString(0);
|
||||
String value = cursor.getString(1);
|
||||
mMetadata.put(key, value);
|
||||
}
|
||||
} finally {
|
||||
if (cursor != null)
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
return mMetadata;
|
||||
}
|
||||
|
||||
public int getMinZoom() {
|
||||
String minZoom = getMetadata().get("minzoom");
|
||||
return minZoom != null ? Integer.parseInt(minZoom) : Viewport.MIN_ZOOM_LEVEL;
|
||||
}
|
||||
|
||||
public Long getMTime() {
|
||||
String mTime = getMetadata().get("mtime");
|
||||
return mTime != null ? Long.parseLong(mTime) : null;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return getMetadata().get("name");
|
||||
}
|
||||
|
||||
public Integer getPixelScale() {
|
||||
String pixelScale = getMetadata().get("pixel_scale");
|
||||
return pixelScale != null ? Integer.parseInt(pixelScale) : null;
|
||||
}
|
||||
|
||||
abstract public List<String> getSupportedFormats();
|
||||
|
||||
public String getVersion() {
|
||||
return getMetadata().get("version");
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
/*
|
||||
* Copyright 2017-2018 devemux86
|
||||
* Copyright 2019 Andrea Antonello
|
||||
* Copyright 2019 devemux86
|
||||
* Copyright 2019 Kostas Tzounopoulos
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
@@ -12,25 +14,33 @@
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.android.test;
|
||||
package org.oscim.android.tiling.source.mbtiles;
|
||||
|
||||
import android.os.Bundle;
|
||||
import org.oscim.tiling.TileSource;
|
||||
|
||||
import org.oscim.utils.Parameters;
|
||||
/**
|
||||
* A tile source for MBTiles databases.
|
||||
*/
|
||||
public abstract class MBTilesTileSource extends TileSource {
|
||||
|
||||
public class POTTextureActivity extends SimpleMapActivity {
|
||||
private final MBTilesTileDataSource mTileDataSource;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
Parameters.POT_TEXTURES = true;
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
public MBTilesTileSource(MBTilesTileDataSource tileDataSource) {
|
||||
mTileDataSource = tileDataSource;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
public void close() {
|
||||
getDataSource().dispose();
|
||||
}
|
||||
|
||||
Parameters.POT_TEXTURES = false;
|
||||
@Override
|
||||
public MBTilesTileDataSource getDataSource() {
|
||||
return mTileDataSource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OpenResult open() {
|
||||
return OpenResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2017 devemux86
|
||||
* Copyright 2019 Kostas Tzounopoulos
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
@@ -12,17 +12,10 @@
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.test;
|
||||
package org.oscim.android.tiling.source.mbtiles;
|
||||
|
||||
import org.oscim.gdx.GdxMapApp;
|
||||
import org.oscim.utils.Parameters;
|
||||
|
||||
public class MapEventLayer2Test extends MarkerLayerTest {
|
||||
|
||||
public static void main(String[] args) {
|
||||
Parameters.MAP_EVENT_LAYER2 = true;
|
||||
|
||||
GdxMapApp.init();
|
||||
GdxMapApp.run(new MapEventLayer2Test());
|
||||
public class MBTilesUnsupportedException extends RuntimeException {
|
||||
public MBTilesUnsupportedException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
@@ -9,13 +9,13 @@
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
|
||||
<application
|
||||
android:name=".App"
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/application_name"
|
||||
android:requestLegacyExternalStorage="true"
|
||||
android:usesCleartextTraffic="true">
|
||||
|
||||
<!-- android:theme="@style/Theme.TileMap" -->
|
||||
|
||||
@@ -4,7 +4,8 @@ dependencies {
|
||||
implementation project(':vtm-android')
|
||||
implementation project(':vtm-extras')
|
||||
implementation project(':vtm-themes')
|
||||
implementation 'com.squareup.okhttp3:okhttp:3.8.0'
|
||||
// https://github.com/square/okhttp/issues/4481
|
||||
implementation 'com.squareup.okhttp3:okhttp:3.12.13'
|
||||
implementation "org.slf4j:slf4j-android:$slf4jVersion"
|
||||
}
|
||||
|
||||
@@ -18,8 +19,8 @@ android {
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
versionCode versionCode()
|
||||
versionName versionName()
|
||||
versionCode project.versionCode()
|
||||
versionName project.versionName()
|
||||
minSdkVersion androidMinSdk()
|
||||
targetSdkVersion androidTargetSdk()
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright 2013 Hannes Janetzek
|
||||
* Copyright 2016-2019 devemux86
|
||||
* Copyright 2016-2020 devemux86
|
||||
*
|
||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||
*
|
||||
@@ -19,9 +19,7 @@ package org.oscim.app;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Environment;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
import org.oscim.android.cache.TileCache;
|
||||
import org.oscim.layers.GenericLayer;
|
||||
import org.oscim.layers.Layer;
|
||||
@@ -43,6 +41,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
|
||||
public class MapLayers {
|
||||
|
||||
@@ -67,7 +66,7 @@ public class MapLayers {
|
||||
@Override
|
||||
TileSource init() {
|
||||
return new MapFileTileSource().setOption("file",
|
||||
new File(Environment.getExternalStorageDirectory(), "berlin.map").getAbsolutePath());
|
||||
new File("/sdcard/berlin.map").getAbsolutePath());
|
||||
}
|
||||
}, new Config("MAPNIK_VECTOR") {
|
||||
@Override
|
||||
@@ -185,7 +184,9 @@ public class MapLayers {
|
||||
|
||||
switch (id) {
|
||||
case R.id.menu_layer_openstreetmap:
|
||||
mBackgroundLayer = new BitmapTileLayer(App.map, DefaultSources.OPENSTREETMAP.build());
|
||||
UrlTileSource tileSource = DefaultSources.OPENSTREETMAP.build();
|
||||
tileSource.setHttpRequestHeaders(Collections.singletonMap("User-Agent", "vtm-playground"));
|
||||
mBackgroundLayer = new BitmapTileLayer(App.map, tileSource);
|
||||
break;
|
||||
|
||||
case R.id.menu_layer_naturalearth:
|
||||
|
||||
@@ -23,19 +23,14 @@ import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.oscim.android.canvas.AndroidGraphics;
|
||||
import org.oscim.core.BoundingBox;
|
||||
import org.oscim.core.GeoPoint;
|
||||
import org.oscim.layers.marker.MarkerInterface;
|
||||
import org.oscim.layers.marker.MarkerSymbol;
|
||||
import org.oscim.layers.marker.MarkerSymbol.HotspotPlace;
|
||||
import org.oscim.map.Map;
|
||||
import org.osmdroid.location.FlickrPOIProvider;
|
||||
import org.osmdroid.location.FourSquareProvider;
|
||||
import org.osmdroid.location.GeoNamesPOIProvider;
|
||||
import org.osmdroid.location.NominatimPOIProvider;
|
||||
import org.osmdroid.location.POI;
|
||||
import org.osmdroid.location.PicasaPOIProvider;
|
||||
import org.osmdroid.location.*;
|
||||
import org.osmdroid.overlays.DefaultInfoWindow;
|
||||
import org.osmdroid.overlays.ExtendedMarkerItem;
|
||||
import org.osmdroid.overlays.ItemizedOverlayWithBubble;
|
||||
@@ -45,7 +40,7 @@ import java.util.List;
|
||||
|
||||
public class POISearch {
|
||||
private final ArrayList<POI> mPOIs;
|
||||
ItemizedOverlayWithBubble<ExtendedMarkerItem> poiMarkers;
|
||||
ItemizedOverlayWithBubble poiMarkers;
|
||||
MarkerSymbol[] mMarkers;
|
||||
|
||||
private static final int MDEFAULT = 0;
|
||||
@@ -57,9 +52,9 @@ public class POISearch {
|
||||
POISearch() {
|
||||
mPOIs = new ArrayList<POI>();
|
||||
//POI markers:
|
||||
final ArrayList<ExtendedMarkerItem> poiItems = new ArrayList<ExtendedMarkerItem>();
|
||||
final ArrayList<MarkerInterface> poiItems = new ArrayList<>();
|
||||
|
||||
poiMarkers = new ItemizedOverlayWithBubble<ExtendedMarkerItem>(App.map,
|
||||
poiMarkers = new ItemizedOverlayWithBubble(App.map,
|
||||
App.activity,
|
||||
null,
|
||||
poiItems,
|
||||
|
||||
@@ -24,10 +24,10 @@ import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.oscim.android.canvas.AndroidGraphics;
|
||||
import org.oscim.core.GeoPoint;
|
||||
import org.oscim.layers.PathLayer;
|
||||
import org.oscim.layers.marker.MarkerInterface;
|
||||
import org.oscim.layers.marker.MarkerSymbol;
|
||||
import org.oscim.layers.marker.MarkerSymbol.HotspotPlace;
|
||||
import org.osmdroid.location.GeocoderNominatim;
|
||||
@@ -48,7 +48,7 @@ public class RouteSearch {
|
||||
|
||||
private final PathLayer mRouteOverlay;
|
||||
//private final ItemizedOverlayWithBubble<ExtendedOverlayItem> mRouteMarkers;
|
||||
private final ItemizedOverlayWithBubble<ExtendedMarkerItem> mItineraryMarkers;
|
||||
private final ItemizedOverlayWithBubble mItineraryMarkers;
|
||||
|
||||
private final RouteBar mRouteBar;
|
||||
|
||||
@@ -63,9 +63,9 @@ public class RouteSearch {
|
||||
mViaPoints = new ArrayList<GeoPoint>();
|
||||
|
||||
// Itinerary markers:
|
||||
ArrayList<ExtendedMarkerItem> waypointsItems = new ArrayList<ExtendedMarkerItem>();
|
||||
ArrayList<MarkerInterface> waypointsItems = new ArrayList<>();
|
||||
|
||||
mItineraryMarkers = new ItemizedOverlayWithBubble<ExtendedMarkerItem>(App.map,
|
||||
mItineraryMarkers = new ItemizedOverlayWithBubble(App.map,
|
||||
App.activity,
|
||||
null,
|
||||
waypointsItems,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Copyright 2010, 2011, 2012 mapsforge.org
|
||||
* Copyright 2012 Hannes Janetzek
|
||||
* Copyright 2016-2017 devemux86
|
||||
* Copyright 2016-2019 devemux86
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
@@ -15,11 +15,13 @@
|
||||
*/
|
||||
package org.oscim.app;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
@@ -73,6 +75,11 @@ public class TileMap extends MapActivity implements MapEventsReceiver {
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED)
|
||||
requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 0);
|
||||
}
|
||||
|
||||
setContentView(R.layout.activity_tilemap);
|
||||
App.view = (MapView) findViewById(R.id.mapView);
|
||||
registerMapView(App.view);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010, 2011, 2012 mapsforge.org
|
||||
* Copyright 2016 devemux86
|
||||
* Copyright 2016-2020 devemux86
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
@@ -15,40 +15,30 @@
|
||||
*/
|
||||
package org.oscim.app.filefilter;
|
||||
|
||||
import org.oscim.theme.ExternalRenderTheme;
|
||||
import org.oscim.theme.ThemeFile;
|
||||
import org.oscim.theme.XmlThemeBuilder;
|
||||
import org.oscim.theme.ThemeLoader;
|
||||
import org.oscim.tiling.TileSource.OpenResult;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.XMLReader;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import javax.xml.parsers.SAXParserFactory;
|
||||
|
||||
/**
|
||||
* Accepts all valid render theme XML files.
|
||||
*/
|
||||
public final class ValidRenderTheme implements ValidFileFilter {
|
||||
private OpenResult openResult;
|
||||
private OpenResult mOpenResult;
|
||||
|
||||
@Override
|
||||
public boolean accept(File file) {
|
||||
try {
|
||||
ThemeFile theme = new ExternalRenderTheme(file.getAbsolutePath());
|
||||
XmlThemeBuilder renderThemeHandler = new XmlThemeBuilder(theme);
|
||||
XMLReader xmlReader = SAXParserFactory.newInstance().newSAXParser().getXMLReader();
|
||||
xmlReader.setContentHandler(renderThemeHandler);
|
||||
xmlReader.parse(new InputSource(theme.getRenderThemeAsStream()));
|
||||
this.openResult = OpenResult.SUCCESS;
|
||||
ThemeLoader.load(file.getAbsolutePath());
|
||||
mOpenResult = OpenResult.SUCCESS;
|
||||
} catch (Exception e) {
|
||||
this.openResult = new OpenResult(e.getMessage());
|
||||
mOpenResult = new OpenResult(e.getMessage());
|
||||
}
|
||||
return this.openResult.isSuccess();
|
||||
return mOpenResult.isSuccess();
|
||||
}
|
||||
|
||||
@Override
|
||||
public OpenResult getFileOpenResult() {
|
||||
return this.openResult;
|
||||
return mOpenResult;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010, 2011, 2012 mapsforge.org
|
||||
* Copyright 2016 devemux86
|
||||
* Copyright 2016-2019 devemux86
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
@@ -24,11 +24,9 @@ import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.Editor;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.GridView;
|
||||
|
||||
import org.oscim.app.R;
|
||||
import org.oscim.app.filefilter.ValidFileFilter;
|
||||
|
||||
@@ -62,7 +60,6 @@ public class FilePicker extends Activity implements AdapterView.OnItemClickListe
|
||||
public static final String SELECTED_FILE = "selectedFile";
|
||||
|
||||
private static final String CURRENT_DIRECTORY = "currentDirectory";
|
||||
private static final String DEFAULT_DIRECTORY = Environment.getExternalStorageDirectory().getAbsolutePath();
|
||||
private static final int DIALOG_FILE_INVALID = 0;
|
||||
// private static final int DIALOG_FILE_SELECT = 1;
|
||||
private static Comparator<File> fileComparator = getDefaultFileComparator();
|
||||
@@ -125,6 +122,7 @@ public class FilePicker extends Activity implements AdapterView.OnItemClickListe
|
||||
}
|
||||
|
||||
private File currentDirectory;
|
||||
private String defaultDirectory;
|
||||
private FilePickerIconAdapter filePickerIconAdapter;
|
||||
private File[] files;
|
||||
private File[] filesWithParentFolder;
|
||||
@@ -166,7 +164,7 @@ public class FilePicker extends Activity implements AdapterView.OnItemClickListe
|
||||
}
|
||||
|
||||
// if a parent directory exists, add it at the first position
|
||||
if (this.currentDirectory.getParentFile() != null) {
|
||||
if (this.currentDirectory.getParentFile() != null && this.currentDirectory.getParentFile().canRead()) {
|
||||
this.filesWithParentFolder = new File[this.files.length + 1];
|
||||
this.filesWithParentFolder[0] = this.currentDirectory.getParentFile();
|
||||
System.arraycopy(this.files, 0, this.filesWithParentFolder, 1,
|
||||
@@ -184,6 +182,7 @@ public class FilePicker extends Activity implements AdapterView.OnItemClickListe
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_file_picker);
|
||||
|
||||
defaultDirectory = getExternalFilesDir(null) != null ? getExternalFilesDir(null).getAbsolutePath() : "/sdcard/";
|
||||
this.filePickerIconAdapter = new FilePickerIconAdapter(this);
|
||||
GridView gridView = (GridView) findViewById(R.id.filePickerView);
|
||||
gridView.setOnItemClickListener(this);
|
||||
@@ -254,10 +253,9 @@ public class FilePicker extends Activity implements AdapterView.OnItemClickListe
|
||||
// restore the current directory
|
||||
SharedPreferences preferences = getSharedPreferences(PREFERENCES_FILE,
|
||||
MODE_PRIVATE);
|
||||
this.currentDirectory = new File(preferences.getString(CURRENT_DIRECTORY,
|
||||
DEFAULT_DIRECTORY));
|
||||
this.currentDirectory = new File(preferences.getString(CURRENT_DIRECTORY, defaultDirectory));
|
||||
if (!this.currentDirectory.exists() || !this.currentDirectory.canRead()) {
|
||||
this.currentDirectory = new File(DEFAULT_DIRECTORY);
|
||||
this.currentDirectory = new File(defaultDirectory);
|
||||
}
|
||||
browseToCurrentDirectory();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Copyright 2013 Ahmad Saleem
|
||||
* Copyright 2013 Hannes Janetzek
|
||||
* Copyright 2016-2017 devemux86
|
||||
* Copyright 2016-2019 devemux86
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
@@ -24,19 +24,17 @@ import android.hardware.SensorManager;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.RotateAnimation;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import org.oscim.app.App;
|
||||
import org.oscim.app.R;
|
||||
import org.oscim.core.MapPosition;
|
||||
import org.oscim.event.Event;
|
||||
import org.oscim.layers.Layer;
|
||||
import org.oscim.map.Map;
|
||||
import org.oscim.renderer.LocationRenderer;
|
||||
import org.oscim.renderer.LocationCallback;
|
||||
import org.oscim.utils.FastMath;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class Compass extends Layer implements SensorEventListener, Map.UpdateListener,
|
||||
LocationRenderer.Callback {
|
||||
public class Compass extends Layer implements SensorEventListener, Map.UpdateListener, LocationCallback {
|
||||
|
||||
// static final Logger log = LoggerFactory.getLogger(Compass.class);
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package org.osmdroid.overlays;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import org.oscim.app.App;
|
||||
import org.oscim.core.GeoPoint;
|
||||
import org.oscim.core.MapPosition;
|
||||
@@ -10,6 +9,7 @@ import org.oscim.core.Point;
|
||||
import org.oscim.event.Event;
|
||||
import org.oscim.event.MotionEvent;
|
||||
import org.oscim.layers.marker.ItemizedLayer;
|
||||
import org.oscim.layers.marker.MarkerInterface;
|
||||
import org.oscim.layers.marker.MarkerItem;
|
||||
import org.oscim.layers.marker.MarkerSymbol;
|
||||
import org.oscim.map.Map;
|
||||
@@ -22,14 +22,12 @@ import java.util.List;
|
||||
* taps on an overlay item, and displays item attributes. <br>
|
||||
* Items must be ExtendedMarkerItem. <br>
|
||||
*
|
||||
* @param <Item> ...
|
||||
* @author M.Kergall
|
||||
* @see ExtendedMarkerItem
|
||||
* @see InfoWindow
|
||||
*/
|
||||
public class ItemizedOverlayWithBubble<Item extends MarkerItem> extends
|
||||
ItemizedLayer<Item> implements
|
||||
ItemizedLayer.OnItemGestureListener<Item>, Map.UpdateListener {
|
||||
public class ItemizedOverlayWithBubble extends ItemizedLayer
|
||||
implements ItemizedLayer.OnItemGestureListener<MarkerInterface>, Map.UpdateListener {
|
||||
|
||||
/* only one for all items of this overlay => one at a time */
|
||||
protected InfoWindow mBubble;
|
||||
@@ -40,7 +38,7 @@ public class ItemizedOverlayWithBubble<Item extends MarkerItem> extends
|
||||
static int layoutResId = 0;
|
||||
|
||||
public ItemizedOverlayWithBubble(Map map, Context context,
|
||||
MarkerSymbol marker, List<Item> list, InfoWindow bubble) {
|
||||
MarkerSymbol marker, List<MarkerInterface> list, InfoWindow bubble) {
|
||||
super(map, list, marker, null);
|
||||
|
||||
if (bubble != null) {
|
||||
@@ -66,12 +64,12 @@ public class ItemizedOverlayWithBubble<Item extends MarkerItem> extends
|
||||
}
|
||||
|
||||
public ItemizedOverlayWithBubble(Map map, Context context,
|
||||
MarkerSymbol marker, List<Item> aList) {
|
||||
MarkerSymbol marker, List<MarkerInterface> aList) {
|
||||
this(map, context, marker, aList, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemLongPress(int index, MarkerItem item) {
|
||||
public boolean onItemLongPress(int index, MarkerInterface item) {
|
||||
if (mBubble.isOpen())
|
||||
hideBubble();
|
||||
else
|
||||
@@ -80,7 +78,7 @@ public class ItemizedOverlayWithBubble<Item extends MarkerItem> extends
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemSingleTapUp(int index, MarkerItem item) {
|
||||
public boolean onItemSingleTapUp(int index, MarkerInterface item) {
|
||||
showBubble(index);
|
||||
|
||||
return true;
|
||||
@@ -121,7 +119,6 @@ public class ItemizedOverlayWithBubble<Item extends MarkerItem> extends
|
||||
*
|
||||
* @param index of the overlay item to show
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public void showBubbleOnItem(int index) {
|
||||
ExtendedMarkerItem item = (ExtendedMarkerItem) (mItemList.get(index));
|
||||
mItemWithBubble = item;
|
||||
@@ -131,7 +128,7 @@ public class ItemizedOverlayWithBubble<Item extends MarkerItem> extends
|
||||
mMap.animator().animateTo(item.geoPoint);
|
||||
|
||||
mMap.updateMap(true);
|
||||
setFocus((Item) item);
|
||||
setFocus(item);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,7 +176,7 @@ public class ItemizedOverlayWithBubble<Item extends MarkerItem> extends
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean removeItem(final Item item) {
|
||||
public synchronized boolean removeItem(final MarkerInterface item) {
|
||||
boolean result = super.removeItem(item);
|
||||
if (mItemWithBubble == item) {
|
||||
hideBubble();
|
||||
|
||||
19
vtm-desktop-lwjgl/build.gradle
Normal file
19
vtm-desktop-lwjgl/build.gradle
Normal file
@@ -0,0 +1,19 @@
|
||||
apply plugin: 'java-library'
|
||||
apply plugin: 'maven'
|
||||
|
||||
dependencies {
|
||||
api project(':vtm-desktop')
|
||||
api "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
java.srcDirs = ['src']
|
||||
}
|
||||
}
|
||||
|
||||
if (project.hasProperty("SONATYPE_USERNAME")) {
|
||||
afterEvaluate {
|
||||
project.apply from: "${rootProject.projectDir}/deploy.gradle"
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,6 @@ import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
|
||||
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
|
||||
import com.badlogic.gdx.graphics.glutils.GLVersion;
|
||||
import com.badlogic.gdx.utils.SharedLibraryLoader;
|
||||
|
||||
import org.oscim.awt.AwtGraphics;
|
||||
import org.oscim.backend.DateTime;
|
||||
import org.oscim.backend.DateTimeAdapter;
|
||||
@@ -66,7 +65,7 @@ public class GdxMapApp extends GdxMap {
|
||||
protected static LwjglApplicationConfiguration getConfig(String title) {
|
||||
LwjglApplicationConfiguration.disableAudio = true;
|
||||
LwjglApplicationConfiguration cfg = new LwjglApplicationConfiguration();
|
||||
cfg.title = title != null ? title : "vtm-gdx";
|
||||
cfg.title = title != null ? title : "vtm-gdx-lwjgl";
|
||||
|
||||
int[] sizes = new int[]{128, 64, 32, 16};
|
||||
for (int size : sizes) {
|
||||
@@ -33,23 +33,11 @@
|
||||
package org.oscim.gdx;
|
||||
|
||||
import com.badlogic.gdx.utils.GdxRuntimeException;
|
||||
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.opengl.EXTFramebufferObject;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL13;
|
||||
import org.lwjgl.opengl.GL14;
|
||||
import org.lwjgl.opengl.GL15;
|
||||
import org.lwjgl.opengl.GL20;
|
||||
import org.lwjgl.opengl.*;
|
||||
import org.oscim.backend.GL;
|
||||
|
||||
import java.nio.Buffer;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.DoubleBuffer;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
import java.nio.ShortBuffer;
|
||||
import java.nio.*;
|
||||
|
||||
/**
|
||||
* An implementation of the {@link GL20} interface based on LWJGL. Note that LWJGL shaders and OpenGL ES shaders will not be 100%
|
||||
@@ -17,32 +17,14 @@
|
||||
package org.oscim.gdx;
|
||||
|
||||
import com.badlogic.gdx.utils.GdxRuntimeException;
|
||||
import org.lwjgl.opengl.*;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
import org.lwjgl.opengl.GL15;
|
||||
import org.lwjgl.opengl.GL20;
|
||||
import org.lwjgl.opengl.GL21;
|
||||
import org.lwjgl.opengl.GL31;
|
||||
import org.lwjgl.opengl.GL32;
|
||||
import org.lwjgl.opengl.GL33;
|
||||
import org.lwjgl.opengl.GL40;
|
||||
import org.lwjgl.opengl.GL41;
|
||||
import org.lwjgl.opengl.GL43;
|
||||
import org.oscim.backend.GL30;
|
||||
|
||||
import java.nio.Buffer;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.DoubleBuffer;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
import java.nio.LongBuffer;
|
||||
import java.nio.ShortBuffer;
|
||||
import java.nio.*;
|
||||
|
||||
/**
|
||||
* See https://github.com/libgdx/libgdx/blob/master/backends/gdx-backend-lwjgl3/src/com/badlogic/gdx/backends/lwjgl3/Lwjgl3GL30.java
|
||||
* See https://github.com/libgdx/libgdx/blob/master/backends/gdx-backend-lwjgl/src/com/badlogic/gdx/backends/lwjgl/LwjglGL30.java
|
||||
*/
|
||||
public class LwjglGL30 extends LwjglGL20 implements GL30 {
|
||||
public class LwjglGL30 extends LwjglGL20 implements org.oscim.backend.GL30 {
|
||||
@Override
|
||||
public void readBuffer(int mode) {
|
||||
GL11.glReadBuffer(mode);
|
||||
@@ -222,246 +204,246 @@ public class LwjglGL30 extends LwjglGL20 implements GL30 {
|
||||
@Override
|
||||
public void blitFramebuffer(int srcX0, int srcY0, int srcX1, int srcY1, int dstX0, int dstY0, int dstX1, int dstY1,
|
||||
int mask, int filter) {
|
||||
org.lwjgl.opengl.GL30.glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
|
||||
GL30.glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindFramebuffer(int target, int framebuffer) {
|
||||
org.lwjgl.opengl.GL30.glBindFramebuffer(target, framebuffer);
|
||||
GL30.glBindFramebuffer(target, framebuffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindRenderbuffer(int target, int renderbuffer) {
|
||||
org.lwjgl.opengl.GL30.glBindRenderbuffer(target, renderbuffer);
|
||||
GL30.glBindRenderbuffer(target, renderbuffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int checkFramebufferStatus(int target) {
|
||||
return org.lwjgl.opengl.GL30.glCheckFramebufferStatus(target);
|
||||
return GL30.glCheckFramebufferStatus(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteFramebuffers(int n, IntBuffer framebuffers) {
|
||||
org.lwjgl.opengl.GL30.glDeleteFramebuffers(framebuffers);
|
||||
GL30.glDeleteFramebuffers(framebuffers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteFramebuffer(int framebuffer) {
|
||||
org.lwjgl.opengl.GL30.glDeleteFramebuffers(framebuffer);
|
||||
GL30.glDeleteFramebuffers(framebuffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteRenderbuffers(int n, IntBuffer renderbuffers) {
|
||||
org.lwjgl.opengl.GL30.glDeleteRenderbuffers(renderbuffers);
|
||||
GL30.glDeleteRenderbuffers(renderbuffers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteRenderbuffer(int renderbuffer) {
|
||||
org.lwjgl.opengl.GL30.glDeleteRenderbuffers(renderbuffer);
|
||||
GL30.glDeleteRenderbuffers(renderbuffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateMipmap(int target) {
|
||||
org.lwjgl.opengl.GL30.glGenerateMipmap(target);
|
||||
GL30.glGenerateMipmap(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void genFramebuffers(int n, IntBuffer framebuffers) {
|
||||
org.lwjgl.opengl.GL30.glGenFramebuffers(framebuffers);
|
||||
GL30.glGenFramebuffers(framebuffers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int genFramebuffer() {
|
||||
return org.lwjgl.opengl.GL30.glGenFramebuffers();
|
||||
return GL30.glGenFramebuffers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void genRenderbuffers(int n, IntBuffer renderbuffers) {
|
||||
org.lwjgl.opengl.GL30.glGenRenderbuffers(renderbuffers);
|
||||
GL30.glGenRenderbuffers(renderbuffers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int genRenderbuffer() {
|
||||
return org.lwjgl.opengl.GL30.glGenRenderbuffers();
|
||||
return GL30.glGenRenderbuffers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getRenderbufferParameteriv(int target, int pname, IntBuffer params) {
|
||||
org.lwjgl.opengl.GL30.glGetRenderbufferParameter(target, pname, params);
|
||||
GL30.glGetRenderbufferParameter(target, pname, params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFramebuffer(int framebuffer) {
|
||||
return org.lwjgl.opengl.GL30.glIsFramebuffer(framebuffer);
|
||||
return GL30.glIsFramebuffer(framebuffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRenderbuffer(int renderbuffer) {
|
||||
return org.lwjgl.opengl.GL30.glIsRenderbuffer(renderbuffer);
|
||||
return GL30.glIsRenderbuffer(renderbuffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderbufferStorage(int target, int internalformat, int width, int height) {
|
||||
org.lwjgl.opengl.GL30.glRenderbufferStorage(target, internalformat, width, height);
|
||||
GL30.glRenderbufferStorage(target, internalformat, width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderbufferStorageMultisample(int target, int samples, int internalformat, int width, int height) {
|
||||
org.lwjgl.opengl.GL30.glRenderbufferStorageMultisample(target, samples, internalformat, width, height);
|
||||
GL30.glRenderbufferStorageMultisample(target, samples, internalformat, width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void framebufferTexture2D(int target, int attachment, int textarget, int texture, int level) {
|
||||
org.lwjgl.opengl.GL30.glFramebufferTexture2D(target, attachment, textarget, texture, level);
|
||||
GL30.glFramebufferTexture2D(target, attachment, textarget, texture, level);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void framebufferRenderbuffer(int target, int attachment, int renderbuffertarget, int renderbuffer) {
|
||||
org.lwjgl.opengl.GL30.glFramebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer);
|
||||
GL30.glFramebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void framebufferTextureLayer(int target, int attachment, int texture, int level, int layer) {
|
||||
org.lwjgl.opengl.GL30.glFramebufferTextureLayer(target, attachment, texture, level, layer);
|
||||
GL30.glFramebufferTextureLayer(target, attachment, texture, level, layer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flushMappedBufferRange(int target, int offset, int length) {
|
||||
org.lwjgl.opengl.GL30.glFlushMappedBufferRange(target, offset, length);
|
||||
GL30.glFlushMappedBufferRange(target, offset, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindVertexArray(int array) {
|
||||
org.lwjgl.opengl.GL30.glBindVertexArray(array);
|
||||
GL30.glBindVertexArray(array);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteVertexArrays(int n, int[] arrays, int offset) {
|
||||
for (int i = offset; i < offset + n; i++) {
|
||||
org.lwjgl.opengl.GL30.glDeleteVertexArrays(arrays[i]);
|
||||
GL30.glDeleteVertexArrays(arrays[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteVertexArrays(int n, IntBuffer arrays) {
|
||||
org.lwjgl.opengl.GL30.glDeleteVertexArrays(arrays);
|
||||
GL30.glDeleteVertexArrays(arrays);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void genVertexArrays(int n, int[] arrays, int offset) {
|
||||
for (int i = offset; i < offset + n; i++) {
|
||||
arrays[i] = org.lwjgl.opengl.GL30.glGenVertexArrays();
|
||||
arrays[i] = GL30.glGenVertexArrays();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void genVertexArrays(int n, IntBuffer arrays) {
|
||||
org.lwjgl.opengl.GL30.glGenVertexArrays(arrays);
|
||||
GL30.glGenVertexArrays(arrays);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVertexArray(int array) {
|
||||
return org.lwjgl.opengl.GL30.glIsVertexArray(array);
|
||||
return GL30.glIsVertexArray(array);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beginTransformFeedback(int primitiveMode) {
|
||||
org.lwjgl.opengl.GL30.glBeginTransformFeedback(primitiveMode);
|
||||
GL30.glBeginTransformFeedback(primitiveMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endTransformFeedback() {
|
||||
org.lwjgl.opengl.GL30.glEndTransformFeedback();
|
||||
GL30.glEndTransformFeedback();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindBufferRange(int target, int index, int buffer, int offset, int size) {
|
||||
org.lwjgl.opengl.GL30.glBindBufferRange(target, index, buffer, offset, size);
|
||||
GL30.glBindBufferRange(target, index, buffer, offset, size);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindBufferBase(int target, int index, int buffer) {
|
||||
org.lwjgl.opengl.GL30.glBindBufferBase(target, index, buffer);
|
||||
GL30.glBindBufferBase(target, index, buffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transformFeedbackVaryings(int program, String[] varyings, int bufferMode) {
|
||||
org.lwjgl.opengl.GL30.glTransformFeedbackVaryings(program, varyings, bufferMode);
|
||||
GL30.glTransformFeedbackVaryings(program, varyings, bufferMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void vertexAttribIPointer(int index, int size, int type, int stride, int offset) {
|
||||
org.lwjgl.opengl.GL30.glVertexAttribIPointer(index, size, type, stride, offset);
|
||||
GL30.glVertexAttribIPointer(index, size, type, stride, offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getVertexAttribIiv(int index, int pname, IntBuffer params) {
|
||||
org.lwjgl.opengl.GL30.glGetVertexAttribI(index, pname, params);
|
||||
GL30.glGetVertexAttribI(index, pname, params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getVertexAttribIuiv(int index, int pname, IntBuffer params) {
|
||||
org.lwjgl.opengl.GL30.glGetVertexAttribIu(index, pname, params);
|
||||
GL30.glGetVertexAttribIu(index, pname, params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void vertexAttribI4i(int index, int x, int y, int z, int w) {
|
||||
org.lwjgl.opengl.GL30.glVertexAttribI4i(index, x, y, z, w);
|
||||
GL30.glVertexAttribI4i(index, x, y, z, w);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void vertexAttribI4ui(int index, int x, int y, int z, int w) {
|
||||
org.lwjgl.opengl.GL30.glVertexAttribI4ui(index, x, y, z, w);
|
||||
GL30.glVertexAttribI4ui(index, x, y, z, w);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getUniformuiv(int program, int location, IntBuffer params) {
|
||||
org.lwjgl.opengl.GL30.glGetUniformu(program, location, params);
|
||||
GL30.glGetUniformu(program, location, params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFragDataLocation(int program, String name) {
|
||||
return org.lwjgl.opengl.GL30.glGetFragDataLocation(program, name);
|
||||
return GL30.glGetFragDataLocation(program, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uniform1uiv(int location, int count, IntBuffer value) {
|
||||
org.lwjgl.opengl.GL30.glUniform1u(location, value);
|
||||
GL30.glUniform1u(location, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uniform3uiv(int location, int count, IntBuffer value) {
|
||||
org.lwjgl.opengl.GL30.glUniform3u(location, value);
|
||||
GL30.glUniform3u(location, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uniform4uiv(int location, int count, IntBuffer value) {
|
||||
org.lwjgl.opengl.GL30.glUniform4u(location, value);
|
||||
GL30.glUniform4u(location, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearBufferiv(int buffer, int drawbuffer, IntBuffer value) {
|
||||
org.lwjgl.opengl.GL30.glClearBuffer(buffer, drawbuffer, value);
|
||||
GL30.glClearBuffer(buffer, drawbuffer, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearBufferuiv(int buffer, int drawbuffer, IntBuffer value) {
|
||||
org.lwjgl.opengl.GL30.glClearBufferu(buffer, drawbuffer, value);
|
||||
GL30.glClearBufferu(buffer, drawbuffer, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearBufferfv(int buffer, int drawbuffer, FloatBuffer value) {
|
||||
org.lwjgl.opengl.GL30.glClearBuffer(buffer, drawbuffer, value);
|
||||
GL30.glClearBuffer(buffer, drawbuffer, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearBufferfi(int buffer, int drawbuffer, float depth, int stencil) {
|
||||
org.lwjgl.opengl.GL30.glClearBufferfi(buffer, drawbuffer, depth, stencil);
|
||||
GL30.glClearBufferfi(buffer, drawbuffer, depth, stencil);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStringi(int name, int index) {
|
||||
return org.lwjgl.opengl.GL30.glGetStringi(name, index);
|
||||
return GL30.glGetStringi(name, index);
|
||||
}
|
||||
|
||||
@Override
|
||||
19
vtm-desktop-lwjgl3/build.gradle
Normal file
19
vtm-desktop-lwjgl3/build.gradle
Normal file
@@ -0,0 +1,19 @@
|
||||
apply plugin: 'java-library'
|
||||
apply plugin: 'maven'
|
||||
|
||||
dependencies {
|
||||
api project(':vtm-desktop')
|
||||
api "com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion"
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
java.srcDirs = ['src']
|
||||
}
|
||||
}
|
||||
|
||||
if (project.hasProperty("SONATYPE_USERNAME")) {
|
||||
afterEvaluate {
|
||||
project.apply from: "${rootProject.projectDir}/deploy.gradle"
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user