Compare commits
151 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b3e2385ba5 | ||
|
|
03821e1f51 | ||
|
|
77dc06d650 | ||
|
|
0cd6c48b16 | ||
|
|
8a595fd37f | ||
|
|
967875d6b8 | ||
|
|
d60e2ef575 | ||
|
|
58ecf60d9d | ||
|
|
17356e5a2b | ||
|
|
296fdd3c13 | ||
|
|
735acc520a | ||
|
|
ac115b1f0f | ||
|
|
d2ba6647ea | ||
|
|
0180c40855 | ||
|
|
817bd13d7b | ||
|
|
d22dc79655 | ||
|
|
fc9ef062c0 | ||
|
|
f2dda7c8eb | ||
|
|
fdc793d9ec | ||
|
|
3d24aade21 | ||
|
|
6d93aaf57f | ||
|
|
8fc354c96a | ||
|
|
e30f3f7cc3 | ||
|
|
aff2c77267 | ||
|
|
33365b3f7d | ||
|
|
33fdc938fa | ||
|
|
8397d5a3be | ||
|
|
980e9d5e54 | ||
|
|
bc7c55b1f8 | ||
|
|
120182ec15 | ||
|
|
945b84f04f | ||
|
|
f67c457006 | ||
|
|
a2852b0761 | ||
|
|
ebf5d408bc | ||
|
|
75719eae29 | ||
|
|
5c825ea9eb | ||
|
|
15bc23cadf | ||
|
|
88f3283878 | ||
|
|
80848f9d2d | ||
|
|
f1f5726457 | ||
|
|
2ccf3e4c64 | ||
|
|
c8cbf8e0ce | ||
|
|
6544cc1081 | ||
|
|
4c72831336 | ||
|
|
06ac5142f7 | ||
|
|
feae45f78b | ||
|
|
61b8233b97 | ||
|
|
7acbea88cc | ||
|
|
19109516ae | ||
|
|
c1a5ad7e74 | ||
|
|
1a93e4ae13 | ||
|
|
1de6ca8fb7 | ||
|
|
02db7ca08d | ||
|
|
e9bb7aaae4 | ||
|
|
989e9c2ae8 | ||
|
|
e8f41cd339 | ||
|
|
eabd90d14c | ||
|
|
3e4aad4d51 | ||
|
|
b6dc72bbb6 | ||
|
|
4cd11462da | ||
|
|
6344542b10 | ||
|
|
e0031ae8aa | ||
|
|
229ea0b350 | ||
|
|
0a5d08a908 | ||
|
|
aed54c9a49 | ||
|
|
1a3bf4e4fe | ||
|
|
591ae03667 | ||
|
|
3a191fb513 | ||
|
|
2821d8ddb8 | ||
|
|
71d7b71035 | ||
|
|
85858911fa | ||
|
|
0a92c84668 | ||
|
|
c21d7b4390 | ||
|
|
38a9c71bc2 | ||
|
|
2573e458d5 | ||
|
|
25a9891133 | ||
|
|
8ee4e5fb8c | ||
|
|
a38b054228 | ||
|
|
d9bf94da99 | ||
|
|
77653096f9 | ||
|
|
5f534656ea | ||
|
|
ba93445259 | ||
|
|
71f7c45b21 | ||
|
|
ca5e34e1fb | ||
|
|
d937f3516c | ||
|
|
a8909fca08 | ||
|
|
b39feae045 | ||
|
|
9f4ef47b95 | ||
|
|
25e79bac55 | ||
|
|
311f4c7929 | ||
|
|
557e1858a7 | ||
|
|
16fa42d462 | ||
|
|
1133edb83d | ||
|
|
f6dbeba3d8 | ||
|
|
bf8f0745a6 | ||
|
|
829e45224f | ||
|
|
acde5d565d | ||
|
|
f0a652faf3 | ||
|
|
41867344e2 | ||
|
|
0c39ff8be0 | ||
|
|
6f78f08a04 | ||
|
|
3388e1401f | ||
|
|
308497ffa6 | ||
|
|
bfa5a095f0 | ||
|
|
96be36edb8 | ||
|
|
7c9c3732fb | ||
|
|
add62c9fe8 | ||
|
|
4aaa1ce620 | ||
|
|
aa63b49e5a | ||
|
|
1f1d91202c | ||
|
|
51eae28926 | ||
|
|
58b5f2741b | ||
|
|
d82faad435 | ||
|
|
fc8223bfc8 | ||
|
|
3584c4be1e | ||
|
|
001dbe8447 | ||
|
|
54feb7a25e | ||
|
|
ea2a94f76b | ||
|
|
b6bfbc612a | ||
|
|
1d545fd804 | ||
|
|
3acf77c102 | ||
|
|
6dfe2df2fb | ||
|
|
6cb40e1c15 | ||
|
|
afd03809e8 | ||
|
|
efa3cb0231 | ||
|
|
a709bd2623 | ||
|
|
439f2b20ff | ||
|
|
877d217f31 | ||
|
|
885264ad8c | ||
|
|
e224a7cf5b | ||
|
|
e10a223ea6 | ||
|
|
f85453e60c | ||
|
|
a6b3d7b0c2 | ||
|
|
dc15ba5f34 | ||
|
|
1d7afaf8de | ||
|
|
422d81d665 | ||
|
|
4b55043dcc | ||
|
|
7885529fff | ||
|
|
2c610f5e0b | ||
|
|
64a586dde8 | ||
|
|
c1f65144df | ||
|
|
ad2ee3f40e | ||
|
|
01365686fa | ||
|
|
dece13ddc9 | ||
|
|
05e9e0cdc8 | ||
|
|
a9283dd408 | ||
|
|
53ca77d18a | ||
|
|
97654f0670 | ||
|
|
cbd0ac01df | ||
|
|
ca841f5181 | ||
|
|
a322768f8a |
@@ -6,8 +6,9 @@ android:
|
||||
components:
|
||||
- platform-tools
|
||||
- tools
|
||||
- build-tools-25.0.0
|
||||
- build-tools-25.0.2
|
||||
- android-25
|
||||
- extra-android-m2repository
|
||||
env:
|
||||
global:
|
||||
- GRADLE_OPTS="-Xmx2048m"
|
||||
|
||||
56
README.md
@@ -1,36 +1,37 @@
|
||||
[](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.mapsforge%22)
|
||||
[](https://travis-ci.org/mapsforge/vtm)
|
||||
[](COPYING.LESSER)
|
||||
[](https://maven-badges.herokuapp.com/maven-central/org.mapsforge/vtm)
|
||||
[](http://www.gnu.org/licenses/lgpl-3.0)
|
||||
|
||||
# V™
|
||||
|
||||
VTM was developed within the [OpenScienceMap](http://opensciencemap.org) project.
|
||||
VTM 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).**
|
||||
|
||||
If you have any questions or problems, don't hesitate to ask our public [mailing list](https://groups.google.com/group/mapsforge-dev) for help.
|
||||
See the **[integration guide](docs/Integration.md)** and [changelog](docs/Changelog.md). And read through [how to contribute](.github/CONTRIBUTING.md) guidelines.
|
||||
|
||||
See the [integration guide](docs/Integration.md) and [changelog](docs/Changelog.md). And read through [how to contribute](.github/CONTRIBUTING.md) guidelines.
|
||||
If you have any questions or problems, don't hesitate to ask our public [mailing list](https://groups.google.com/group/mapsforge-dev) for help.
|
||||
|
||||
## Features
|
||||
- Java map library
|
||||
- OpenGL vector-tile rendering
|
||||
- Themeable vector layers
|
||||
- Support for multiple tile sources:
|
||||
- primary opensciencemap (.vtm)
|
||||
- mapsforge files
|
||||
- OpenScienceMap (.vtm)
|
||||
- Mapsforge (.map)
|
||||
- Mapbox tiles (.mvt)
|
||||
- GeoJSON tiles
|
||||
- bitmap: any quadtree-scheme tiles as texture
|
||||
- Raster tiles: any quadtree-scheme tiles as texture
|
||||
- Backends:
|
||||
- Android (optional libGDX)
|
||||
- iOS (using libGDX/RoboVM, [instructions](docs/ios.md))
|
||||
- Desktop (using libGDX/LWJGL)
|
||||
- HTML5/WebGL (using libGDX/GWT)
|
||||
- HTML5/WebGL (using libGDX/GWT, [instructions](docs/web.md))
|
||||
|
||||
### Projects
|
||||
- **vtm** contains the core library
|
||||
- **vtm-android** Android backend (no libGDX required)
|
||||
- **vtm-android-example** provides examples using **vtm-android**
|
||||
- **vtm-android-example** provides examples using vtm-android
|
||||
- **vtm-gdx** common libGDX backend
|
||||
- **vtm-android-gdx** Android backend (with libGDX)
|
||||
- **vtm-desktop** Desktop backend
|
||||
@@ -38,23 +39,34 @@ See the [integration guide](docs/Integration.md) and [changelog](docs/Changelog.
|
||||
- **vtm-web** HTML5/GWT backend
|
||||
- **vtm-web-app** HTML5/GWT application
|
||||
|
||||
The libGDX backend for GWT is experimental.
|
||||
|
||||
## Applications
|
||||
- VTM is used by many [applications](docs/Applications.md).
|
||||
|
||||
## WebGL Demo
|
||||
[OpenScienceMap](http://opensciencemap.org/s3db/#scale=17,rot=61,tilt=51,lat=53.075,lon=8.807) view of Bremen.
|
||||
- Hold right mouse button to change view direction.
|
||||
|
||||
## Applications
|
||||
- VTM is used by many [applications](docs/Applications.md).
|
||||
|
||||
## Maps
|
||||
- Mapsforge [map providers](docs/Mapsforge-Maps.md).
|
||||
|
||||
## Credits
|
||||
This library contains code from several projects:
|
||||
- **Android**: some Matrix code, TimSort (http://source.android.com)
|
||||
- **libGDX**: AsyncTask, MathUtils and Interpolation classes (https://github.com/libgdx)
|
||||
- **mapsforge**: based on 0.2.4 (https://github.com/mapsforge/mapsforge)
|
||||
- **osmdroid**: some overlay classes (https://github.com/osmdroid/osmdroid)
|
||||
- **tessellate**: (https://github.com/cscheid/tessellate)
|
||||
- **Android** (Apache 2.0): some Matrix code, TimSort (http://source.android.com)
|
||||
- **libGDX** (Apache 2.0): AsyncTask, MathUtils and Interpolation classes (https://github.com/libgdx)
|
||||
- **mapsforge** (LGPL3): based on 0.2.4 (https://github.com/mapsforge/mapsforge)
|
||||
- **osmdroid** (Apache 2.0): some overlay classes (https://github.com/osmdroid/osmdroid)
|
||||
- **tessellate** (SGI Free Software License B 2.0): (https://github.com/cscheid/tessellate)
|
||||
|
||||
## Screenshots
|
||||

|
||||

|
||||
|
||||
### Android
|
||||

|
||||
|
||||
### iOS
|
||||

|
||||
|
||||
### Desktop
|
||||

|
||||
|
||||
### Browser
|
||||

|
||||
|
||||
@@ -3,7 +3,7 @@ buildscript {
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:2.2.2'
|
||||
classpath 'com.android.tools.build:gradle:2.2.3'
|
||||
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
|
||||
}
|
||||
}
|
||||
@@ -13,8 +13,9 @@ allprojects {
|
||||
version = 'master-SNAPSHOT'
|
||||
ext.isReleaseVersion = !version.endsWith("SNAPSHOT")
|
||||
|
||||
ext.androidBuildVersionTools = "25.0.0"
|
||||
ext.gdxVersion = "1.9.4"
|
||||
ext.androidBuildVersionTools = "25.0.2"
|
||||
ext.gdxVersion = "1.9.5"
|
||||
ext.gwtVersion = "2.8.0"
|
||||
|
||||
if (JavaVersion.current().isJava8Compatible()) {
|
||||
tasks.withType(Javadoc) {
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
# Applications using VTM software (in lexical order)
|
||||
|
||||
|**Name**|**Type**|**License/Cost**|**Sources**|
|
||||
|--------|--------|----------------|-----------|
|
||||
| [Cachebox 3.0](https://github.com/Longri/cachebox3.0) | Android / Desktop / iOS geocaching application | GPL/Free | Open |
|
||||
| [Cruiser](http://wiki.openstreetmap.org/wiki/Cruiser) | Android / Desktop map and navigation application | Proprietary/Free | Closed |
|
||||
|**Name**|**Type**|**License/Cost**|**Platforms**|**Sources**|
|
||||
|--------|--------|----------------|-------------|-----------|
|
||||
| [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 |
|
||||
| [Hunt Cyprus](https://play.google.com/store/apps/details?id=gr.talent.hunt.cy17) | Map and navigation application for hunters | Proprietary/Commercial | Android | Closed |
|
||||
| [MapTrek](http://maptrek.mobi) | Application for outdoor activities | GPL3/Free and Commercial | Android | Open |
|
||||
|
||||
You know an application that is missing here? Please inform us by sending a message via our public [mailing list](https://groups.google.com/group/mapsforge-dev).
|
||||
|
||||
@@ -1,19 +1,52 @@
|
||||
# Changelog
|
||||
|
||||
## Version 0.6.X
|
||||
## Version 0.7.0 (2017-02-26)
|
||||
|
||||
**Version 0.6.0-rc3 (2016-10-22)**
|
||||
- Same as 0.7.0-rc2
|
||||
|
||||
### Version 0.7.0-rc2 (2017-02-20)
|
||||
|
||||
- Fix theme parsing in non-Latin locales [#297](https://github.com/mapsforge/vtm/issues/297)
|
||||
|
||||
### Version 0.7.0-rc1 (2017-02-16)
|
||||
|
||||
- Mapsforge multiple map files [#208](https://github.com/mapsforge/vtm/issues/208)
|
||||
- Improved gestures implementation [#253](https://github.com/mapsforge/vtm/issues/253)
|
||||
- Polygon label position enhancements [#80](https://github.com/mapsforge/vtm/issues/80)
|
||||
- vtm-web modules update [#51](https://github.com/mapsforge/vtm/issues/51)
|
||||
- Mapbox (Mapzen) vector tiles [#57](https://github.com/mapsforge/vtm/issues/57)
|
||||
- SVG resources scaling in themes [#214](https://github.com/mapsforge/vtm/issues/214)
|
||||
- Circle map style [#122](https://github.com/mapsforge/vtm/issues/122)
|
||||
- Oneway arrows in themes [#275](https://github.com/mapsforge/vtm/issues/275)
|
||||
- Texture atlas from bitmaps [#283](https://github.com/mapsforge/vtm/pull/283)
|
||||
- PathLayer (vtm) fix disappearing segments [#108](https://github.com/mapsforge/vtm/issues/108)
|
||||
- House numbers (nodes) fix visibility [#168](https://github.com/mapsforge/vtm/issues/168)
|
||||
- Android fix quick scale vs long press [#250](https://github.com/mapsforge/vtm/issues/250)
|
||||
- Use baseline 160dpi in scaling [#236](https://github.com/mapsforge/vtm/issues/236)
|
||||
- OkHttp3 update [#138](https://github.com/mapsforge/vtm/issues/138)
|
||||
- libGDX double tap zoom [#263](https://github.com/mapsforge/vtm/issues/263)
|
||||
- MapFileTileSource zoom level API enhancements [#219](https://github.com/mapsforge/vtm/issues/219)
|
||||
- Animator enhancements with easing functions [#246](https://github.com/mapsforge/vtm/issues/246)
|
||||
- Tile grid layer scaling [#238](https://github.com/mapsforge/vtm/issues/238)
|
||||
- Internal render themes new SVG resources [#251](https://github.com/mapsforge/vtm/issues/251)
|
||||
- Internal render themes various improvements [#41](https://github.com/mapsforge/vtm/issues/41)
|
||||
- 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
|
||||
|
||||
- Same as 0.6.0-rc3
|
||||
|
||||
### Version 0.6.0-rc3 (2016-10-22)
|
||||
|
||||
- Minor improvements and bug fixes
|
||||
|
||||
**Version 0.6.0-rc2 (2016-10-16)**
|
||||
### Version 0.6.0-rc2 (2016-10-16)
|
||||
|
||||
- Location layer [#171](https://github.com/mapsforge/vtm/issues/171)
|
||||
- Minor improvements and bug fixes
|
||||
|
||||
**Version 0.6.0-rc1 (2016-10-08)**
|
||||
|
||||
**Revive of VTM vector map library**
|
||||
### Version 0.6.0-rc1 (2016-10-08)
|
||||
|
||||
- Render theme SVG resources [#60](https://github.com/mapsforge/vtm/issues/60)
|
||||
- Mapsforge multilingual maps [#34](https://github.com/mapsforge/vtm/issues/34)
|
||||
@@ -35,4 +68,4 @@
|
||||
- LWJGL desktop libGDX backend [#129](https://github.com/mapsforge/vtm/issues/129)
|
||||
- SNAPSHOT builds publish to Sonatype OSSRH [#165](https://github.com/mapsforge/vtm/issues/165)
|
||||
- Many other minor improvements and bug fixes
|
||||
- [Solved issues](https://github.com/mapsforge/vtm/issues?q=is%3Aissue+is%3Aclosed+milestone%3A0.6.0)
|
||||
- [Solved issues](https://github.com/mapsforge/vtm/issues?q=is%3Aclosed+milestone%3A0.6.0)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# Integration guide
|
||||
|
||||
This article describes how to integrate the library in your project.
|
||||
This article describes how to integrate the library in your project, with Gradle / Maven / Jars or SNAPSHOT builds.
|
||||
|
||||
Current version is [](https://maven-badges.herokuapp.com/maven-central/org.mapsforge/vtm)
|
||||
Current version is [](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.mapsforge%22)
|
||||
|
||||
## Gradle
|
||||
|
||||
@@ -33,14 +33,14 @@ compile 'org.mapsforge:vtm-desktop:[CURRENT-VERSION]'
|
||||
compile 'org.mapsforge:vtm-desktop:[CURRENT-VERSION]:natives-linux'
|
||||
compile 'org.mapsforge:vtm-desktop:[CURRENT-VERSION]:natives-osx'
|
||||
compile 'org.mapsforge:vtm-desktop:[CURRENT-VERSION]:natives-windows'
|
||||
compile 'com.badlogicgames.gdx:gdx:1.9.4'
|
||||
compile 'com.badlogicgames.gdx:gdx-platform:1.9.4:natives-desktop'
|
||||
compile 'com.badlogicgames.gdx:gdx-backend-lwjgl:1.9.4'
|
||||
compile 'com.badlogicgames.gdx:gdx:1.9.5'
|
||||
compile 'com.badlogicgames.gdx:gdx-platform:1.9.5:natives-desktop'
|
||||
compile 'com.badlogicgames.gdx:gdx-backend-lwjgl:1.9.5'
|
||||
compile 'org.lwjgl.lwjgl:lwjgl:2.9.3'
|
||||
compile 'org.lwjgl.lwjgl:lwjgl-platform:2.9.3:natives-linux'
|
||||
compile 'org.lwjgl.lwjgl:lwjgl-platform:2.9.3:natives-osx'
|
||||
compile 'org.lwjgl.lwjgl:lwjgl-platform:2.9.3:natives-windows'
|
||||
compile 'com.kitfox.svg:svg-salamander:1.0'
|
||||
compile 'com.metsci.ext.com.kitfox.svg:svg-salamander:0.1.19'
|
||||
```
|
||||
|
||||
## Snapshots
|
||||
@@ -49,6 +49,11 @@ We publish regularly SNAPSHOT builds to Sonatype OSS Repository Hosting.
|
||||
|
||||
You need to add the repository:
|
||||
```groovy
|
||||
configurations.all {
|
||||
// check for latest snapshot on every build
|
||||
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
|
||||
}
|
||||
@@ -74,6 +79,6 @@ The dependencies for Maven are declared in a similar way. For example:
|
||||
|
||||
## Jars
|
||||
|
||||
You can find jars (regular and with dependencies) in Maven Central or Snapshots repositories.
|
||||
You can find release and snapshot jars (regular and with dependencies) in [Maven Central](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.mapsforge%22) and [Sonatype OSS Repository Hosting](https://oss.sonatype.org/content/repositories/snapshots/org/mapsforge/).
|
||||
|
||||
Third party jars can be found at their respective sites or in Maven Central repository.
|
||||
|
||||
9
docs/Mapsforge-Maps.md
Normal file
@@ -0,0 +1,9 @@
|
||||
# Mapsforge map providers (in lexical order)
|
||||
|
||||
- [AndroidMaps](http://www.androidmaps.co.uk/)
|
||||
- [Freizeitkarte](http://www.freizeitkarte-osm.de/android/en/index.html)
|
||||
- [Locusvectormaps](http://www.locusvectormaps.com)
|
||||
- [Mapsforge](http://download.mapsforge.org/)
|
||||
- [OpenAndroMaps](http://www.openandromaps.org/en/)
|
||||
|
||||
You know a Mapsforge map provider that is missing here? Please inform us by sending a message via our public [mailing list](https://groups.google.com/group/mapsforge-dev).
|
||||
BIN
docs/images/android.png
Normal file
|
After Width: | Height: | Size: 717 KiB |
BIN
docs/images/browser.png
Normal file
|
After Width: | Height: | Size: 791 KiB |
BIN
docs/images/desktop.png
Normal file
|
After Width: | Height: | Size: 580 KiB |
BIN
docs/images/ios.png
Normal file
|
After Width: | Height: | Size: 450 KiB |
|
Before Width: | Height: | Size: 827 KiB |
|
Before Width: | Height: | Size: 1.1 MiB |
7
docs/web.md
Normal file
@@ -0,0 +1,7 @@
|
||||
### Web implementation
|
||||
|
||||
`./gradlew :vtm-web-app:jettyDraftWar` will run standalone Jetty server at port 8080.
|
||||
|
||||
Then go to `http://localhost:8080/vtm-web-app` in the web browser to see the map.
|
||||
|
||||
Hold right mouse button to change view direction.
|
||||
@@ -69,7 +69,7 @@
|
||||
|
||||
<xs:simpleType name="src">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:pattern value="(file|assets):.+" />
|
||||
<xs:pattern value="((file|assets):)?.+" />
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
|
||||
@@ -124,6 +124,9 @@
|
||||
<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" />
|
||||
<xs:attribute name="fill" default="#000000" type="tns:color" use="optional" />
|
||||
<xs:attribute name="stroke" default="#00000000" type="tns:color" use="optional" />
|
||||
<xs:attribute name="stroke-width" default="0" type="tns:nonNegativeFloat" use="optional" />
|
||||
@@ -143,11 +146,15 @@
|
||||
<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" />
|
||||
<!-- polygon area expressed as a ratio to tile area, e.g. 0.1 for 10% of tile area -->
|
||||
<xs:attribute name="area-size" default="0" type="tns:nonNegativeFloat" use="optional" />
|
||||
<!-- priority for label placement, 0 = highest priority -->
|
||||
<xs:attribute name="priority" default="0" type="xs:integer" use="optional" />
|
||||
|
||||
<!-- symbol src name in atlas -->
|
||||
<!-- symbol src name -->
|
||||
<xs:attribute name="symbol" 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" />
|
||||
</xs:complexType>
|
||||
|
||||
<xs:complexType name="circle">
|
||||
@@ -169,6 +176,9 @@
|
||||
<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" />
|
||||
<xs:attribute name="stroke" default="#000000" type="tns:color" use="optional" />
|
||||
<xs:attribute name="width" default="0" type="xs:float" use="optional" />
|
||||
<!-- minimum scaled width to draw outline -->
|
||||
@@ -193,6 +203,9 @@
|
||||
<xs:attribute name="cat" type="xs:string" use="optional" />
|
||||
<xs:attribute name="name" 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" />
|
||||
<xs:attribute name="stroke" default="#000000" type="tns:color" use="optional" />
|
||||
<xs:attribute name="stroke-width" default="0" type="tns:nonNegativeFloat" use="optional" />
|
||||
</xs:complexType>-->
|
||||
@@ -200,6 +213,9 @@
|
||||
<xs:complexType name="lineSymbol">
|
||||
<xs:attribute name="cat" type="xs:string" use="optional" />
|
||||
<xs:attribute name="src" type="tns:src" use="required" />
|
||||
<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" />
|
||||
<xs:attribute name="align-center" default="false" type="xs:boolean" use="optional" />
|
||||
<xs:attribute name="repeat" default="false" type="xs:boolean" use="optional" />
|
||||
</xs:complexType>
|
||||
@@ -219,6 +235,8 @@
|
||||
<xs:attribute name="stroke" default="#000000" type="tns:color" use="optional" />
|
||||
<xs:attribute name="stroke-width" default="0" type="tns:nonNegativeFloat" use="optional" />
|
||||
<xs:attribute name="caption" default="false" type="xs:boolean" use="optional" />
|
||||
<!-- polygon area expressed as a ratio to tile area, e.g. 0.1 for 10% of tile area -->
|
||||
<xs:attribute name="area-size" default="0" type="tns:nonNegativeFloat" use="optional" />
|
||||
<!-- priority for label placement, 0 = highest priority -->
|
||||
<xs:attribute name="priority" default="0" type="xs:integer" use="optional" />
|
||||
</xs:complexType>
|
||||
@@ -226,6 +244,9 @@
|
||||
<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="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" />
|
||||
</xs:complexType>
|
||||
|
||||
<xs:complexType name="extrusion">
|
||||
|
||||
@@ -10,8 +10,8 @@ include ':vtm-themes'
|
||||
include ':vtm-gdx'
|
||||
include ':vtm-desktop'
|
||||
include ':vtm-android-gdx'
|
||||
//include ':vtm-web'
|
||||
//include ':vtm-web-app'
|
||||
include ':vtm-web'
|
||||
include ':vtm-web-app'
|
||||
//include ':vtm-web-js'
|
||||
include ':vtm-jeo'
|
||||
include ':vtm-playground'
|
||||
|
||||
@@ -26,6 +26,9 @@
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".AtlasMarkerOverlayActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||
<activity
|
||||
android:name=".BitmapTileMapActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||
@@ -41,18 +44,33 @@
|
||||
<activity
|
||||
android:name=".LocationActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||
<activity
|
||||
android:name=".MapboxMapActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||
<activity
|
||||
android:name=".MapFragmentActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||
<activity
|
||||
android:name=".MapPositionActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||
<activity
|
||||
android:name=".MapsforgeMapActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||
<activity
|
||||
android:name=".MapsforgeMapActivity$MapFilePicker"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||
<activity
|
||||
android:name=".MapsforgeStyleActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||
<activity
|
||||
android:name=".MarkerOverlayActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||
<activity
|
||||
android:name=".MultiMapActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||
<activity
|
||||
android:name=".NewGesturesActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||
<activity
|
||||
android:name=".OsmJsonMapActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||
|
||||
50
vtm-android-example/assets/vtm/stylemenu.xml
Normal file
@@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<rendertheme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" map-background="#fffcfa"
|
||||
version="1" xmlns="http://opensciencemap.org/rendertheme"
|
||||
xsi:schemaLocation="http://opensciencemap.org/rendertheme https://raw.githubusercontent.com/mapsforge/vtm/master/resources/rendertheme.xsd">
|
||||
|
||||
<stylemenu defaultlang="en" defaultvalue="1" id="menu">
|
||||
<layer enabled="true" id="nature">
|
||||
<name lang="de" value="Natur" />
|
||||
<name lang="en" value="Nature" />
|
||||
<name lang="es" value="Naturaleza" />
|
||||
<name lang="fr" value="Nature" />
|
||||
<cat id="nature" />
|
||||
</layer>
|
||||
|
||||
<layer id="base">
|
||||
<cat id="sea" />
|
||||
<cat id="land" />
|
||||
</layer>
|
||||
|
||||
<!-- Show nature layers (enabled by default) -->
|
||||
<layer id="1" parent="base" visible="true">
|
||||
<name lang="de" value="1" />
|
||||
<name lang="en" value="1" />
|
||||
<name lang="es" value="1" />
|
||||
<name lang="fr" value="1" />
|
||||
<overlay id="nature" />
|
||||
</layer>
|
||||
|
||||
<!-- Don't show nature layers -->
|
||||
<layer id="2" parent="base" visible="true">
|
||||
<name lang="de" value="2" />
|
||||
<name lang="en" value="2" />
|
||||
<name lang="es" value="2" />
|
||||
<name lang="fr" value="2" />
|
||||
</layer>
|
||||
</stylemenu>
|
||||
|
||||
<m cat="sea" e="way" k="natural" v="issea|sea">
|
||||
<area fill="#b5d6f1" mesh="true" />
|
||||
</m>
|
||||
|
||||
<m cat="land" e="way" k="natural" v="nosea">
|
||||
<area fill="#f8f8f8" mesh="true" />
|
||||
</m>
|
||||
|
||||
<m cat="nature" e="way" k="natural|landuse" v="forest|wood">
|
||||
<area fill="#83aa5b" />
|
||||
</m>
|
||||
|
||||
</rendertheme>
|
||||
@@ -3,10 +3,14 @@ apply plugin: 'com.android.application'
|
||||
dependencies {
|
||||
compile project(':vtm-android')
|
||||
compile project(':vtm-extras')
|
||||
compile project(':vtm-jeo')
|
||||
compile project(':vtm-http')
|
||||
compile(project(':vtm-jeo')) {
|
||||
exclude group: 'com.vividsolutions', module: 'jts'
|
||||
}
|
||||
compile project(':vtm-jts')
|
||||
compile project(':vtm-themes')
|
||||
compile 'com.noveogroup.android:android-logger:1.3.6'
|
||||
compile 'com.android.support:support-v4:25.2.0'
|
||||
}
|
||||
|
||||
android {
|
||||
|
||||
11
vtm-android-example/res/layout/activity_map_fragment.xml
Normal file
@@ -0,0 +1,11 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/fragment_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</LinearLayout>
|
||||
11
vtm-android-example/res/layout/fragment_map.xml
Normal file
@@ -0,0 +1,11 @@
|
||||
<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
|
||||
android:id="@+id/mapView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</RelativeLayout>
|
||||
@@ -1,7 +0,0 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:id="@+id/menu_settings"
|
||||
android:title="@string/menu_settings"
|
||||
android:orderInCategory="100"
|
||||
android:showAsAction="never" />
|
||||
</menu>
|
||||
16
vtm-android-example/res/menu/style_menu.xml
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<group
|
||||
android:id="@+id/styles"
|
||||
android:checkableBehavior="single">
|
||||
<item
|
||||
android:id="@+id/style_1"
|
||||
android:checked="true"
|
||||
android:title="@string/style_1" />
|
||||
<item
|
||||
android:id="@+id/style_2"
|
||||
android:title="@string/style_2" />
|
||||
</group>
|
||||
|
||||
</menu>
|
||||
@@ -7,26 +7,21 @@
|
||||
<item
|
||||
android:id="@+id/theme_default"
|
||||
android:checked="true"
|
||||
android:showAsAction="never"
|
||||
android:title="@string/theme_default"></item>
|
||||
android:title="@string/theme_default" />
|
||||
<item
|
||||
android:id="@+id/theme_tubes"
|
||||
android:showAsAction="never"
|
||||
android:title="@string/theme_tubes"></item>
|
||||
android:title="@string/theme_tubes" />
|
||||
<item
|
||||
android:id="@+id/theme_osmarender"
|
||||
android:showAsAction="never"
|
||||
android:title="@string/theme_osmarender"></item>
|
||||
android:title="@string/theme_osmarender" />
|
||||
<item
|
||||
android:id="@+id/theme_newtron"
|
||||
android:showAsAction="never"
|
||||
android:title="@string/theme_newtron"></item>
|
||||
android:title="@string/theme_newtron" />
|
||||
</group>
|
||||
|
||||
<item
|
||||
android:id="@+id/gridlayer"
|
||||
android:showAsAction="never"
|
||||
android:checkable="true"
|
||||
android:title="@string/menu_gridlayer"></item>
|
||||
android:title="@string/menu_gridlayer" />
|
||||
|
||||
</menu>
|
||||
</menu>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<resources>
|
||||
|
||||
<string name="app_name">VTM Samples</string>
|
||||
<string name="menu_settings">Settings</string>
|
||||
<string name="theme_default">Default</string>
|
||||
<string name="theme_tubes">Tubes</string>
|
||||
<string name="theme_osmarender">Osmarender</string>
|
||||
@@ -14,6 +13,8 @@
|
||||
<string name="styler_mode_area">Area</string>
|
||||
<string name="styler_mode_outline">Outline</string>
|
||||
<string name="styler_controls_toggle">Controls</string>
|
||||
<string name="menu_gridlayer">Gridlayer</string>
|
||||
<string name="style_1">Show nature</string>
|
||||
<string name="style_2">Hide nature</string>
|
||||
<string name="menu_gridlayer">Grid</string>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright 2014 Hannes Janetzek
|
||||
* Copyright 2016 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.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
|
||||
import org.oscim.backend.canvas.Bitmap;
|
||||
import org.oscim.core.GeoPoint;
|
||||
import org.oscim.layers.TileGridLayer;
|
||||
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.renderer.atlas.TextureAtlas;
|
||||
import org.oscim.renderer.atlas.TextureRegion;
|
||||
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
|
||||
implements ItemizedLayer.OnItemGestureListener<MarkerItem> {
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
mBitmapLayer.tileRenderer().setBitmapAlpha(0.5f);
|
||||
|
||||
// Map events receiver
|
||||
mMap.layers().add(new MapEventsReceiver(mMap));
|
||||
|
||||
/* directly load bitmap from resources */
|
||||
Bitmap bitmapPoi = drawableToBitmap(getResources(), R.drawable.marker_poi);
|
||||
|
||||
/* another option: use some bitmap drawable */
|
||||
Drawable d = getResources().getDrawable(R.drawable.marker_focus);
|
||||
Bitmap bitmapFocus = drawableToBitmap(d);
|
||||
|
||||
// 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);
|
||||
|
||||
ItemizedLayer<MarkerItem> markerLayer =
|
||||
new ItemizedLayer<>(mMap, new ArrayList<MarkerItem>(),
|
||||
symbol, this);
|
||||
|
||||
mMap.layers().add(markerLayer);
|
||||
|
||||
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)));
|
||||
}
|
||||
|
||||
markerLayer.addItems(pts);
|
||||
|
||||
mMap.layers().add(new TileGridLayer(mMap, getResources().getDisplayMetrics().density));
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright 2013 Hannes Janetzek
|
||||
* Copyright 2016 devemux86
|
||||
*
|
||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||
*
|
||||
@@ -107,7 +108,7 @@ public class BaseMapActivity extends MapActivity {
|
||||
} else {
|
||||
item.setChecked(true);
|
||||
if (mGridLayer == null)
|
||||
mGridLayer = new TileGridLayer(mMap);
|
||||
mGridLayer = new TileGridLayer(mMap, getResources().getDisplayMetrics().density);
|
||||
|
||||
mMap.layers().add(mGridLayer);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ 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;
|
||||
@@ -53,7 +52,7 @@ public class LayerGroupActivity extends BaseMapActivity {
|
||||
layers.addGroup(GROUP_LABELS);
|
||||
layers.add(new LabelLayer(mMap, mBaseLayer), GROUP_LABELS);
|
||||
|
||||
mapScaleBar = new DefaultMapScaleBar(mMap, CanvasAdapter.dpi / 160);
|
||||
mapScaleBar = new DefaultMapScaleBar(mMap);
|
||||
mapScaleBar.setScaleBarMode(DefaultMapScaleBar.ScaleBarMode.BOTH);
|
||||
mapScaleBar.setDistanceUnitAdapter(MetricUnitAdapter.INSTANCE);
|
||||
mapScaleBar.setSecondaryDistanceUnitAdapter(ImperialUnitAdapter.INSTANCE);
|
||||
@@ -62,7 +61,7 @@ public class LayerGroupActivity extends BaseMapActivity {
|
||||
MapScaleBarLayer mapScaleBarLayer = new MapScaleBarLayer(mMap, mapScaleBar);
|
||||
BitmapRenderer renderer = mapScaleBarLayer.getRenderer();
|
||||
renderer.setPosition(GLViewport.Position.BOTTOM_LEFT);
|
||||
renderer.setOffset(5 * CanvasAdapter.dpi / 160, 0);
|
||||
renderer.setOffset(5 * getResources().getDisplayMetrics().density, 0);
|
||||
|
||||
layers.addGroup(GROUP_OVERLAYS);
|
||||
layers.add(mapScaleBarLayer, GROUP_OVERLAYS);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 devemux86
|
||||
* 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
|
||||
@@ -35,6 +35,7 @@ public class LocationActivity extends SimpleMapActivity implements LocationListe
|
||||
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
|
||||
|
||||
locationLayer = new LocationLayer(mMap);
|
||||
locationLayer.setEnabled(false);
|
||||
mMap.layers().add(locationLayer);
|
||||
}
|
||||
|
||||
@@ -43,7 +44,6 @@ public class LocationActivity extends SimpleMapActivity implements LocationListe
|
||||
super.onResume();
|
||||
|
||||
enableAvailableProviders();
|
||||
locationLayer.setEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -51,11 +51,11 @@ public class LocationActivity extends SimpleMapActivity implements LocationListe
|
||||
super.onPause();
|
||||
|
||||
locationManager.removeUpdates(this);
|
||||
locationLayer.setEnabled(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocationChanged(Location location) {
|
||||
locationLayer.setEnabled(true);
|
||||
locationLayer.setPosition(location.getLatitude(), location.getLongitude(), location.getAccuracy());
|
||||
|
||||
// Follow location
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 devemux86
|
||||
* Copyright 2016-2017 devemux86
|
||||
*
|
||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||
*
|
||||
@@ -61,9 +61,16 @@ public class MapActivity extends Activity {
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
|
||||
mMapView.onPause();
|
||||
mPrefs.save(mMapView.map());
|
||||
mMapView.onPause();
|
||||
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
mMapView.onDestroy();
|
||||
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* Copyright 2016 Mathieu De Brito
|
||||
* Copyright 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 android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import org.oscim.android.MapPreferences;
|
||||
import org.oscim.android.MapView;
|
||||
import org.oscim.core.MapPosition;
|
||||
import org.oscim.core.Tile;
|
||||
import org.oscim.layers.GroupLayer;
|
||||
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 org.oscim.tiling.source.oscimap4.OSciMap4TileSource;
|
||||
|
||||
public class MapFragmentActivity extends FragmentActivity {
|
||||
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
Tile.SIZE = Tile.calculateTileSize(getResources().getDisplayMetrics().scaledDensity);
|
||||
setContentView(R.layout.activity_map_fragment);
|
||||
|
||||
setTitle(getClass().getSimpleName());
|
||||
|
||||
MapFragment newFragment = new MapFragment();
|
||||
getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
.add(R.id.fragment_container, newFragment)
|
||||
.commit();
|
||||
}
|
||||
|
||||
public static class MapFragment extends Fragment {
|
||||
|
||||
private MapView mMapView;
|
||||
private MapPreferences mPrefs;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
View contentView = super.onCreateView(inflater, container, savedInstanceState);
|
||||
if (contentView == null) {
|
||||
contentView = inflater.inflate(R.layout.fragment_map, container, false);
|
||||
}
|
||||
return contentView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
mMapView = (MapView) view.findViewById(R.id.mapView);
|
||||
mPrefs = new MapPreferences(MapFragment.class.getName(), getContext());
|
||||
|
||||
VectorTileLayer l = mMapView.map().setBaseMap(new OSciMap4TileSource());
|
||||
|
||||
GroupLayer groupLayer = new GroupLayer(mMapView.map());
|
||||
groupLayer.layers.add(new BuildingLayer(mMapView.map(), l));
|
||||
groupLayer.layers.add(new LabelLayer(mMapView.map(), l));
|
||||
mMapView.map().layers().add(groupLayer);
|
||||
|
||||
mMapView.map().setTheme(VtmThemes.DEFAULT);
|
||||
|
||||
// set initial position on first run
|
||||
MapPosition pos = new MapPosition();
|
||||
mMapView.map().getMapPosition(pos);
|
||||
if (pos.x == 0.5 && pos.y == 0.5)
|
||||
mMapView.map().setMapPosition(53.08, 8.83, Math.pow(2, 16));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
mPrefs.load(mMapView.map());
|
||||
mMapView.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
|
||||
mMapView.onPause();
|
||||
mPrefs.save(mMapView.map());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright 2016 Mathieu De Brito
|
||||
* Copyright 2016 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 android.os.Bundle;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.oscim.core.MapPosition;
|
||||
import org.oscim.core.MercatorProjection;
|
||||
|
||||
/**
|
||||
* Test consecutive map position animations.
|
||||
*/
|
||||
public class MapPositionActivity extends SimpleMapActivity {
|
||||
|
||||
// Reuse MapPosition instance
|
||||
private final MapPosition mapPosition = new MapPosition();
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
runTest();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
/* ignore saved position */
|
||||
mMap.setMapPosition(0, 0, 1 << 2);
|
||||
}
|
||||
|
||||
private void animateToBearing(final float bearing) {
|
||||
mMap.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mMap.getMapPosition(mapPosition);
|
||||
mapPosition.setBearing(bearing);
|
||||
mMap.animator().animateTo(1000, mapPosition);
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
|
||||
private void animateToLocation(final double latitude, final double longitude) {
|
||||
mMap.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mMap.getMapPosition(true, mapPosition);
|
||||
mapPosition.setPosition(latitude, longitude);
|
||||
mMap.animator().animateTo(1000, mapPosition);
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
private void runTest() {
|
||||
// 1 - ask for a bearing
|
||||
final float bearing = 180;
|
||||
animateToBearing(bearing);
|
||||
|
||||
// 2 - ask for a new location
|
||||
double latitude = Math.random() * MercatorProjection.LATITUDE_MAX;
|
||||
double longitude = Math.random() * MercatorProjection.LONGITUDE_MAX;
|
||||
animateToLocation(latitude, longitude);
|
||||
|
||||
// If animations were merged, final bearing should be 180°
|
||||
mMap.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mMap.getMapPosition(mapPosition);
|
||||
Toast.makeText(MapPositionActivity.this, "Bearing expected: " + bearing + ", got: " + mapPosition.getBearing(), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}, 3000);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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 android.os.Bundle;
|
||||
|
||||
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 org.oscim.tiling.source.OkHttpEngine;
|
||||
import org.oscim.tiling.source.UrlTileSource;
|
||||
import org.oscim.tiling.source.mvt.MapboxTileSource;
|
||||
|
||||
public class MapboxMapActivity extends MapActivity {
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
UrlTileSource tileSource = MapboxTileSource.builder()
|
||||
.apiKey("mapzen-xxxxxxx") // Put a proper API key
|
||||
.httpFactory(new OkHttpEngine.OkHttpFactory())
|
||||
//.locale("en")
|
||||
.build();
|
||||
|
||||
VectorTileLayer l = mMap.setBaseMap(tileSource);
|
||||
mMap.setTheme(VtmThemes.MAPZEN);
|
||||
|
||||
mMap.layers().add(new BuildingLayer(mMap, l));
|
||||
mMap.layers().add(new LabelLayer(mMap, l));
|
||||
}
|
||||
}
|
||||
@@ -92,7 +92,7 @@ public class MapsforgeMapActivity extends MapActivity {
|
||||
} else {
|
||||
item.setChecked(true);
|
||||
if (mGridLayer == null)
|
||||
mGridLayer = new TileGridLayer(mMap);
|
||||
mGridLayer = new TileGridLayer(mMap, getResources().getDisplayMetrics().density);
|
||||
|
||||
mMap.layers().add(mGridLayer);
|
||||
}
|
||||
@@ -118,7 +118,7 @@ public class MapsforgeMapActivity extends MapActivity {
|
||||
if (tileSource.setMapFile(file)) {
|
||||
|
||||
VectorTileLayer l = mMap.setBaseMap(tileSource);
|
||||
mMap.setTheme(VtmThemes.DEFAULT);
|
||||
loadTheme(null);
|
||||
|
||||
mMap.layers().add(new BuildingLayer(mMap, l));
|
||||
mMap.layers().add(new LabelLayer(mMap, l));
|
||||
@@ -132,4 +132,8 @@ public class MapsforgeMapActivity extends MapActivity {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void loadTheme(final String styleId) {
|
||||
mMap.setTheme(VtmThemes.DEFAULT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright 2016 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 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;
|
||||
import org.oscim.theme.XmlRenderThemeStyleMenu;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Load render theme from Android assets folder and show a configuration menu based on stylemenu.
|
||||
*/
|
||||
public class MapsforgeStyleActivity extends MapsforgeMapActivity {
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.style_menu, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.style_1:
|
||||
item.setChecked(true);
|
||||
loadTheme("1");
|
||||
mMap.clearMap();
|
||||
Toast.makeText(this, "Show nature layers", Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
case R.id.style_2:
|
||||
item.setChecked(true);
|
||||
loadTheme("2");
|
||||
mMap.clearMap();
|
||||
Toast.makeText(this, "Hide nature layers", Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadTheme(final String styleId) {
|
||||
mMap.setTheme(new AssetsRenderTheme(this, "", "vtm/stylemenu.xml", new XmlRenderThemeMenuCallback() {
|
||||
@Override
|
||||
public Set<String> getCategories(XmlRenderThemeStyleMenu renderThemeStyleMenu) {
|
||||
// Use the selected style or the default
|
||||
String style = styleId != null ? styleId : renderThemeStyleMenu.getDefaultValue();
|
||||
|
||||
// Retrieve the layer from the style id
|
||||
XmlRenderThemeStyleLayer renderThemeStyleLayer = renderThemeStyleMenu.getLayer(style);
|
||||
if (renderThemeStyleLayer == null) {
|
||||
System.err.println("Invalid style " + style);
|
||||
return null;
|
||||
}
|
||||
|
||||
// First get the selected layer's categories that are enabled together
|
||||
Set<String> categories = renderThemeStyleLayer.getCategories();
|
||||
|
||||
// Then add the selected layer's overlays that are enabled individually
|
||||
// Here we use the style menu, but users can use their own preferences
|
||||
for (XmlRenderThemeStyleLayer overlay : renderThemeStyleLayer.getOverlays()) {
|
||||
if (overlay.isEnabled())
|
||||
categories.addAll(overlay.getCategories());
|
||||
}
|
||||
|
||||
// This is the whole categories set to be enabled
|
||||
return categories;
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -23,11 +23,16 @@ import android.widget.Toast;
|
||||
|
||||
import org.oscim.backend.canvas.Bitmap;
|
||||
import org.oscim.core.GeoPoint;
|
||||
import org.oscim.event.Gesture;
|
||||
import org.oscim.event.GestureListener;
|
||||
import org.oscim.event.MotionEvent;
|
||||
import org.oscim.layers.Layer;
|
||||
import org.oscim.layers.TileGridLayer;
|
||||
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.map.Map;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -38,8 +43,8 @@ import static org.oscim.tiling.source.bitmap.DefaultSources.STAMEN_TONER;
|
||||
public class MarkerOverlayActivity extends BitmapTileMapActivity
|
||||
implements ItemizedLayer.OnItemGestureListener<MarkerItem> {
|
||||
|
||||
private static final boolean BILLBOARDS = true;
|
||||
private MarkerSymbol mFocusMarker;
|
||||
protected static final boolean BILLBOARDS = true;
|
||||
protected MarkerSymbol mFocusMarker;
|
||||
|
||||
public MarkerOverlayActivity() {
|
||||
super(STAMEN_TONER.build());
|
||||
@@ -50,6 +55,9 @@ public class MarkerOverlayActivity extends BitmapTileMapActivity
|
||||
super.onCreate(savedInstanceState);
|
||||
mBitmapLayer.tileRenderer().setBitmapAlpha(0.5f);
|
||||
|
||||
// Map events receiver
|
||||
mMap.layers().add(new MapEventsReceiver(mMap));
|
||||
|
||||
/* directly load bitmap from resources */
|
||||
Bitmap bitmap = drawableToBitmap(getResources(), R.drawable.marker_poi);
|
||||
|
||||
@@ -81,7 +89,7 @@ public class MarkerOverlayActivity extends BitmapTileMapActivity
|
||||
|
||||
markerLayer.addItems(pts);
|
||||
|
||||
mMap.layers().add(new TileGridLayer(mMap));
|
||||
mMap.layers().add(new TileGridLayer(mMap, getResources().getDisplayMetrics().density));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -99,13 +107,40 @@ public class MarkerOverlayActivity extends BitmapTileMapActivity
|
||||
else
|
||||
item.setMarker(null);
|
||||
|
||||
Toast toast = Toast.makeText(this, item.getTitle(), Toast.LENGTH_SHORT);
|
||||
toast.show();
|
||||
Toast.makeText(this, "Marker tap\n" + item.getTitle(), Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemLongPress(int index, MarkerItem item) {
|
||||
return false;
|
||||
if (item.getMarker() == null)
|
||||
item.setMarker(mFocusMarker);
|
||||
else
|
||||
item.setMarker(null);
|
||||
|
||||
Toast.makeText(this, "Marker long press\n" + item.getTitle(), Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
}
|
||||
|
||||
protected class MapEventsReceiver extends Layer implements GestureListener {
|
||||
|
||||
MapEventsReceiver(Map map) {
|
||||
super(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onGesture(Gesture g, MotionEvent e) {
|
||||
if (g instanceof Gesture.Tap) {
|
||||
GeoPoint p = mMap.viewport().fromScreenPoint(e.getX(), e.getY());
|
||||
Toast.makeText(MarkerOverlayActivity.this, "Map tap\n" + p, Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
}
|
||||
if (g instanceof Gesture.LongPress) {
|
||||
GeoPoint p = mMap.viewport().fromScreenPoint(e.getX(), e.getY());
|
||||
Toast.makeText(MarkerOverlayActivity.this, "Map long press\n" + p, Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013 Hannes Janetzek
|
||||
*
|
||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||
* Copyright 2016 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,23 +12,22 @@
|
||||
* 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.event;
|
||||
package org.oscim.android.test;
|
||||
|
||||
import org.oscim.map.Map;
|
||||
|
||||
public class GestureDetector {
|
||||
public class NewGesturesActivity extends MarkerOverlayActivity {
|
||||
|
||||
private final Map mMap;
|
||||
|
||||
public GestureDetector(Map map) {
|
||||
mMap = map;
|
||||
public NewGesturesActivity() {
|
||||
super();
|
||||
Map.NEW_GESTURES = true;
|
||||
}
|
||||
|
||||
public boolean onTouchEvent(MotionEvent e) {
|
||||
if (e.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
return mMap.handleGesture(Gesture.PRESS, e);
|
||||
}
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
return false;
|
||||
// Revert gestures for other activities
|
||||
Map.NEW_GESTURES = false;
|
||||
}
|
||||
}
|
||||
@@ -65,7 +65,7 @@ public class OsmJsonMapActivity extends MapActivity {
|
||||
mMap.layers().add(l);
|
||||
mMap.layers().add(new LabelLayer(mMap, l));
|
||||
|
||||
mMap.layers().add(new TileGridLayer(mMap));
|
||||
mMap.layers().add(new TileGridLayer(mMap, getResources().getDisplayMetrics().density));
|
||||
|
||||
mMap.setMapPosition(53.08, 8.83, Math.pow(2, 16));
|
||||
}
|
||||
|
||||
@@ -21,10 +21,12 @@ package org.oscim.android.test;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
/**
|
||||
* A simple start screen for the sample activities.
|
||||
@@ -38,19 +40,35 @@ public class Samples extends Activity {
|
||||
setContentView(R.layout.activity_samples);
|
||||
LinearLayout linearLayout = (LinearLayout) findViewById(R.id.samples);
|
||||
linearLayout.addView(createButton(SimpleMapActivity.class));
|
||||
linearLayout.addView(createButton(BitmapTileMapActivity.class));
|
||||
linearLayout.addView(createButton(MapsforgeMapActivity.class));
|
||||
linearLayout.addView(createButton(MapsforgeStyleActivity.class));
|
||||
linearLayout.addView(createButton(MapboxMapActivity.class));
|
||||
linearLayout.addView(createButton(OsmJsonMapActivity.class));
|
||||
|
||||
linearLayout.addView(createLabel("Raster Maps"));
|
||||
linearLayout.addView(createButton(BitmapTileMapActivity.class));
|
||||
|
||||
linearLayout.addView(createLabel("Overlays"));
|
||||
linearLayout.addView(createButton(MarkerOverlayActivity.class));
|
||||
linearLayout.addView(createButton(AtlasMarkerOverlayActivity.class));
|
||||
linearLayout.addView(createButton(PathOverlayActivity.class));
|
||||
linearLayout.addView(createButton(LineTexActivity.class));
|
||||
linearLayout.addView(createButton(LayerGroupActivity.class));
|
||||
linearLayout.addView(createButton(LocationActivity.class));
|
||||
linearLayout.addView(createButton(ThemeStylerActivity.class));
|
||||
linearLayout.addView(createButton(S3DBMapActivity.class));
|
||||
linearLayout.addView(createButton(JeoIndoorMapActivity.class));
|
||||
linearLayout.addView(createButton(OsmJsonMapActivity.class));
|
||||
linearLayout.addView(createButton(VectorLayerMapActivity.class));
|
||||
linearLayout.addView(createButton(LocationActivity.class));
|
||||
|
||||
linearLayout.addView(createLabel("User Interaction"));
|
||||
linearLayout.addView(createButton(NewGesturesActivity.class));
|
||||
linearLayout.addView(createButton(LayerGroupActivity.class));
|
||||
linearLayout.addView(createButton(MapFragmentActivity.class));
|
||||
|
||||
linearLayout.addView(createLabel("Dual Map Views"));
|
||||
linearLayout.addView(createButton(MultiMapActivity.class));
|
||||
|
||||
linearLayout.addView(createLabel("Experiments"));
|
||||
linearLayout.addView(createButton(MapPositionActivity.class));
|
||||
linearLayout.addView(createButton(S3DBMapActivity.class));
|
||||
linearLayout.addView(createButton(ThemeStylerActivity.class));
|
||||
linearLayout.addView(createButton(JeoIndoorMapActivity.class));
|
||||
}
|
||||
|
||||
private Button createButton(final Class<?> clazz) {
|
||||
@@ -72,4 +90,15 @@ public class Samples extends Activity {
|
||||
});
|
||||
return button;
|
||||
}
|
||||
|
||||
private TextView createLabel(String text) {
|
||||
TextView textView = new TextView(this);
|
||||
textView.setGravity(Gravity.CENTER);
|
||||
if (text == null) {
|
||||
textView.setText("---------------");
|
||||
} else {
|
||||
textView.setText(text);
|
||||
}
|
||||
return textView;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.oscim.android.test;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import org.oscim.backend.CanvasAdapter;
|
||||
import org.oscim.core.MapPosition;
|
||||
import org.oscim.core.MercatorProjection;
|
||||
import org.oscim.layers.GroupLayer;
|
||||
@@ -48,7 +47,7 @@ public class SimpleMapActivity extends BaseMapActivity {
|
||||
groupLayer.layers.add(new LabelLayer(mMap, mBaseLayer));
|
||||
mMap.layers().add(groupLayer);
|
||||
|
||||
mapScaleBar = new DefaultMapScaleBar(mMap, CanvasAdapter.dpi / 160);
|
||||
mapScaleBar = new DefaultMapScaleBar(mMap);
|
||||
mapScaleBar.setScaleBarMode(DefaultMapScaleBar.ScaleBarMode.BOTH);
|
||||
mapScaleBar.setDistanceUnitAdapter(MetricUnitAdapter.INSTANCE);
|
||||
mapScaleBar.setSecondaryDistanceUnitAdapter(ImperialUnitAdapter.INSTANCE);
|
||||
@@ -57,7 +56,7 @@ public class SimpleMapActivity extends BaseMapActivity {
|
||||
MapScaleBarLayer mapScaleBarLayer = new MapScaleBarLayer(mMap, mapScaleBar);
|
||||
BitmapRenderer renderer = mapScaleBarLayer.getRenderer();
|
||||
renderer.setPosition(GLViewport.Position.BOTTOM_LEFT);
|
||||
renderer.setOffset(5 * CanvasAdapter.dpi / 160, 0);
|
||||
renderer.setOffset(5 * getResources().getDisplayMetrics().density, 0);
|
||||
mMap.layers().add(mapScaleBarLayer);
|
||||
|
||||
mMap.setTheme(VtmThemes.DEFAULT);
|
||||
|
||||
@@ -58,7 +58,7 @@ public class MainActivity extends AndroidApplication {
|
||||
@Override
|
||||
public void createLayers() {
|
||||
TileSource ts = new OSciMap4TileSource();
|
||||
initDefaultLayers(ts, true, true, true);
|
||||
initDefaultLayers(ts, true, true, true, getResources().getDisplayMetrics().density);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright 2012 Hannes Janetzek
|
||||
* Copyright 2016-2017 devemux86
|
||||
*
|
||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||
*
|
||||
@@ -53,7 +54,7 @@ public class MapView extends GLSurfaceView {
|
||||
}
|
||||
|
||||
protected final AndroidMap mMap;
|
||||
protected final GestureDetector mGestureDetector;
|
||||
protected GestureDetector mGestureDetector;
|
||||
protected final AndroidMotionEvent mMotionEvent;
|
||||
|
||||
public MapView(Context context) {
|
||||
@@ -94,15 +95,17 @@ public class MapView extends GLSurfaceView {
|
||||
mMap.clearMap();
|
||||
mMap.updateMap(false);
|
||||
|
||||
GestureHandler gestureHandler = new GestureHandler(mMap);
|
||||
mGestureDetector = new GestureDetector(context, gestureHandler);
|
||||
mGestureDetector.setOnDoubleTapListener(gestureHandler);
|
||||
if (!Map.NEW_GESTURES) {
|
||||
GestureHandler gestureHandler = new GestureHandler(mMap);
|
||||
mGestureDetector = new GestureDetector(context, gestureHandler);
|
||||
mGestureDetector.setOnDoubleTapListener(gestureHandler);
|
||||
}
|
||||
|
||||
mMotionEvent = new AndroidMotionEvent();
|
||||
}
|
||||
|
||||
public void onStop() {
|
||||
|
||||
public void onDestroy() {
|
||||
mMap.destroy();
|
||||
}
|
||||
|
||||
public void onPause() {
|
||||
@@ -116,14 +119,16 @@ public class MapView extends GLSurfaceView {
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
@Override
|
||||
public boolean onTouchEvent(android.view.MotionEvent motionEvent) {
|
||||
|
||||
if (!isClickable())
|
||||
return false;
|
||||
|
||||
if (mGestureDetector.onTouchEvent(motionEvent))
|
||||
return true;
|
||||
if (mGestureDetector != null) {
|
||||
if (mGestureDetector.onTouchEvent(motionEvent))
|
||||
return true;
|
||||
}
|
||||
|
||||
mMap.input.fire(null, mMotionEvent.wrap(motionEvent));
|
||||
mMotionEvent.recycle();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Copyright 2010, 2011, 2012 mapsforge.org
|
||||
* Copyright 2016 devemux86
|
||||
* Copyright 2017 Longri
|
||||
*
|
||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||
*
|
||||
@@ -23,6 +24,7 @@ import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
import org.oscim.backend.CanvasAdapter;
|
||||
import org.oscim.backend.Platform;
|
||||
import org.oscim.backend.canvas.Bitmap;
|
||||
import org.oscim.backend.canvas.Canvas;
|
||||
import org.oscim.backend.canvas.Paint;
|
||||
@@ -36,6 +38,7 @@ public final class AndroidGraphics extends CanvasAdapter {
|
||||
|
||||
public static void init() {
|
||||
CanvasAdapter.init(new AndroidGraphics());
|
||||
CanvasAdapter.platform = Platform.ANDROID;
|
||||
}
|
||||
|
||||
public static android.graphics.Paint getAndroidPaint(Paint paint) {
|
||||
@@ -56,9 +59,9 @@ public final class AndroidGraphics extends CanvasAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bitmap decodeSvgBitmapImpl(InputStream inputStream) {
|
||||
public Bitmap decodeSvgBitmapImpl(InputStream inputStream, int width, int height, int percent) {
|
||||
try {
|
||||
return new AndroidSvgBitmap(inputStream);
|
||||
return new AndroidSvgBitmap(inputStream, width, height, percent);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
@@ -66,9 +69,9 @@ public final class AndroidGraphics extends CanvasAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bitmap loadBitmapAssetImpl(String relativePathPrefix, String src) {
|
||||
public Bitmap loadBitmapAssetImpl(String relativePathPrefix, String src, int width, int height, int percent) {
|
||||
try {
|
||||
return createBitmap(relativePathPrefix, src);
|
||||
return createBitmap(relativePathPrefix, src, width, height, percent);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -134,6 +134,11 @@ class AndroidPaint implements Paint {
|
||||
return Math.abs(fm.bottom);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getStrokeWidth() {
|
||||
return mPaint.getStrokeWidth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getTextHeight(String text) {
|
||||
mPaint.getTextBounds(text, 0, text.length(), rect);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
/*
|
||||
* Copyright 2016 devemux86
|
||||
* Copyright 2010, 2011, 2012 mapsforge.org
|
||||
* Copyright 2013-2014 Ludwig M Brinckmann
|
||||
* Copyright 2014-2016 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
|
||||
@@ -74,13 +76,13 @@ public class AndroidSvgBitmap extends AndroidBitmap {
|
||||
}
|
||||
}
|
||||
|
||||
private static android.graphics.Bitmap getResourceBitmapImpl(InputStream inputStream) throws IOException {
|
||||
private static android.graphics.Bitmap getResourceBitmapImpl(InputStream inputStream, int width, int height, int percent) throws IOException {
|
||||
synchronized (SVG.getVersion()) {
|
||||
return getResourceBitmap(inputStream, CanvasAdapter.dpi / 160, DEFAULT_SIZE, 0, 0, 100);
|
||||
return getResourceBitmap(inputStream, CanvasAdapter.dpi / CanvasAdapter.DEFAULT_DPI, DEFAULT_SIZE, width, height, percent);
|
||||
}
|
||||
}
|
||||
|
||||
public AndroidSvgBitmap(InputStream inputStream) throws IOException {
|
||||
super(getResourceBitmapImpl(inputStream));
|
||||
public AndroidSvgBitmap(InputStream inputStream, int width, int height, int percent) throws IOException {
|
||||
super(getResourceBitmapImpl(inputStream, width, height, percent));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright 2013 Hannes Janetzek
|
||||
* Copyright 2016 Andrey Novikov
|
||||
*
|
||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||
*
|
||||
@@ -20,10 +21,10 @@ import org.oscim.event.MotionEvent;
|
||||
|
||||
public class AndroidMotionEvent extends MotionEvent {
|
||||
|
||||
android.view.MotionEvent mEvent;
|
||||
private android.view.MotionEvent mEvent;
|
||||
|
||||
public MotionEvent wrap(android.view.MotionEvent e) {
|
||||
mEvent = e;
|
||||
mEvent = android.view.MotionEvent.obtain(e);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -57,6 +58,16 @@ public class AndroidMotionEvent extends MotionEvent {
|
||||
return mEvent.getPointerCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MotionEvent copy() {
|
||||
return new AndroidMotionEvent().wrap(mEvent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recycle() {
|
||||
mEvent.recycle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTime() {
|
||||
return mEvent.getEventTime();
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* Copyright 2013 Hannes Janetzek
|
||||
* Copyright 2016 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.input;
|
||||
|
||||
import android.view.GestureDetector.OnDoubleTapListener;
|
||||
@@ -11,16 +28,18 @@ public class GestureHandler implements OnGestureListener, OnDoubleTapListener {
|
||||
private final AndroidMotionEvent mMotionEvent;
|
||||
private final Map mMap;
|
||||
|
||||
// Quick scale (double tap + swipe)
|
||||
protected boolean quickScale;
|
||||
|
||||
public GestureHandler(Map map) {
|
||||
mMotionEvent = new AndroidMotionEvent();
|
||||
mMap = map;
|
||||
}
|
||||
|
||||
/* GesturListener */
|
||||
/* OnGestureListener */
|
||||
|
||||
@Override
|
||||
public boolean onSingleTapUp(MotionEvent e) {
|
||||
// return mMap.handleGesture(Gesture.TAP, mMotionEvent.wrap(e));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -35,6 +54,10 @@ public class GestureHandler implements OnGestureListener, OnDoubleTapListener {
|
||||
|
||||
@Override
|
||||
public void onLongPress(MotionEvent e) {
|
||||
// Quick scale (no long press)
|
||||
if (quickScale)
|
||||
return;
|
||||
|
||||
mMap.handleGesture(Gesture.LONG_PRESS, mMotionEvent.wrap(e));
|
||||
}
|
||||
|
||||
@@ -45,10 +68,13 @@ public class GestureHandler implements OnGestureListener, OnDoubleTapListener {
|
||||
|
||||
@Override
|
||||
public boolean onDown(MotionEvent e) {
|
||||
quickScale = false;
|
||||
|
||||
return mMap.handleGesture(Gesture.PRESS, mMotionEvent.wrap(e));
|
||||
}
|
||||
|
||||
/* DoubleTapListener */
|
||||
/* OnDoubleTapListener */
|
||||
|
||||
@Override
|
||||
public boolean onSingleTapConfirmed(MotionEvent e) {
|
||||
return mMap.handleGesture(Gesture.TAP, mMotionEvent.wrap(e));
|
||||
@@ -56,6 +82,11 @@ public class GestureHandler implements OnGestureListener, OnDoubleTapListener {
|
||||
|
||||
@Override
|
||||
public boolean onDoubleTapEvent(MotionEvent e) {
|
||||
int action = e.getActionMasked();
|
||||
|
||||
// Quick scale
|
||||
quickScale = (action == MotionEvent.ACTION_MOVE);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ dependencies {
|
||||
compile project(':vtm-themes')
|
||||
compile project(':vtm-extras')
|
||||
compile 'com.noveogroup.android:android-logger:1.3.6'
|
||||
compile 'com.squareup.okhttp:okhttp:2.6.0'
|
||||
compile 'com.squareup.okhttp3:okhttp:3.6.0'
|
||||
}
|
||||
|
||||
android {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Copyright 2010, 2011, 2012 mapsforge.org
|
||||
* Copyright 2013 Hannes Janetzek
|
||||
* Copyright 2017 devemux86
|
||||
*
|
||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||
*
|
||||
@@ -60,14 +61,12 @@ public abstract class MapActivity extends Activity {
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
mMapView.onDestroy();
|
||||
super.onDestroy();
|
||||
mMap.destroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
|
||||
Editor editor = getSharedPreferences(PREFERENCES_FILE, MODE_PRIVATE).edit();
|
||||
editor.clear();
|
||||
|
||||
@@ -82,7 +81,9 @@ public abstract class MapActivity extends Activity {
|
||||
editor.putInt(KEY_LONGITUDE, geoPoint.longitudeE6);
|
||||
editor.putFloat(KEY_MAP_SCALE, (float) mapPosition.scale);
|
||||
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -93,8 +94,8 @@ public abstract class MapActivity extends Activity {
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
mMapView.onPause();
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -148,13 +148,13 @@ public class MapLayers {
|
||||
|
||||
}
|
||||
|
||||
void enableGridOverlay(boolean enable) {
|
||||
void enableGridOverlay(Context context, boolean enable) {
|
||||
if (mGridEnabled == enable)
|
||||
return;
|
||||
|
||||
if (enable) {
|
||||
if (mGridOverlay == null)
|
||||
mGridOverlay = new TileGridLayer(App.map);
|
||||
mGridOverlay = new TileGridLayer(App.map, context.getResources().getDisplayMetrics().density);
|
||||
|
||||
App.map.layers().add(mGridOverlay);
|
||||
} else {
|
||||
|
||||
@@ -205,7 +205,7 @@ public class TileMap extends MapActivity implements MapEventsReceiver {
|
||||
break;
|
||||
|
||||
case R.id.menu_layer_grid:
|
||||
mMapLayers.enableGridOverlay(!mMapLayers.isGridEnabled());
|
||||
mMapLayers.enableGridOverlay(this, !mMapLayers.isGridEnabled());
|
||||
mMap.updateMap(true);
|
||||
break;
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ class LocationLayerImpl extends LocationLayer {
|
||||
public void setEnabled(boolean enabled) {
|
||||
super.setEnabled(enabled);
|
||||
|
||||
mCompass.setEnabled(enabled);
|
||||
if (mCompass != null)
|
||||
mCompass.setEnabled(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,25 +2,26 @@ package org.osmdroid.utils;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.squareup.okhttp.OkHttpClient;
|
||||
import com.squareup.okhttp.Request;
|
||||
import com.squareup.okhttp.Response;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.OkHttpClient.Builder;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
|
||||
/**
|
||||
* A "very very simple to use" class for performing http get and post requests.
|
||||
* So many ways to do that, and potential subtle issues.
|
||||
* If complexity should be added to handle even more issues, complexity should be put here and only here.
|
||||
* <p/>
|
||||
* <p>
|
||||
* Typical usage:
|
||||
* <pre>HttpConnection connection = new HttpConnection();
|
||||
* connection.doGet("http://www.google.com");
|
||||
* InputStream stream = connection.getStream();
|
||||
* if (stream != null) {
|
||||
* //use this stream, for buffer reading, or XML SAX parsing, or whatever...
|
||||
* //use this stream, for buffer reading, or XML SAX parsing, or whatever...
|
||||
* }
|
||||
* connection.close();</pre>
|
||||
*/
|
||||
@@ -35,9 +36,14 @@ public class HttpConnection {
|
||||
|
||||
private static OkHttpClient getOkHttpClient() {
|
||||
if (client == null) {
|
||||
client = new OkHttpClient();
|
||||
Builder b = new Builder();
|
||||
b.connectTimeout(TIMEOUT_CONNECTION, TimeUnit.MILLISECONDS);
|
||||
b.readTimeout(TIMEOUT_SOCKET, TimeUnit.MILLISECONDS);
|
||||
client = b.build();
|
||||
/*
|
||||
client.setConnectTimeout(TIMEOUT_CONNECTION, TimeUnit.MILLISECONDS);
|
||||
client.setReadTimeout(TIMEOUT_SOCKET, TimeUnit.MILLISECONDS);
|
||||
*/
|
||||
}
|
||||
return client;
|
||||
}
|
||||
@@ -73,15 +79,10 @@ public class HttpConnection {
|
||||
* @return the opened InputStream, or null if creation failed for any reason.
|
||||
*/
|
||||
public InputStream getStream() {
|
||||
try {
|
||||
if (response == null)
|
||||
return null;
|
||||
stream = response.body().byteStream();
|
||||
return stream;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
if (response == null)
|
||||
return null;
|
||||
}
|
||||
stream = response.body().byteStream();
|
||||
return stream;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,7 +8,7 @@ dependencies {
|
||||
}
|
||||
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
|
||||
compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
|
||||
compile 'com.kitfox.svg:svg-salamander:1.0'
|
||||
compile 'com.metsci.ext.com.kitfox.svg:svg-salamander:0.1.19'
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Copyright 2013 Hannes Janetzek
|
||||
* Copyright 2016 devemux86
|
||||
* Copyright 2017 Longri
|
||||
*
|
||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||
*
|
||||
@@ -18,6 +19,7 @@
|
||||
package org.oscim.awt;
|
||||
|
||||
import org.oscim.backend.CanvasAdapter;
|
||||
import org.oscim.backend.Platform;
|
||||
import org.oscim.backend.canvas.Bitmap;
|
||||
import org.oscim.backend.canvas.Canvas;
|
||||
import org.oscim.backend.canvas.Paint;
|
||||
@@ -29,11 +31,20 @@ import java.awt.RenderingHints;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Locale;
|
||||
|
||||
public class AwtGraphics extends CanvasAdapter {
|
||||
|
||||
public static void init() {
|
||||
CanvasAdapter.init(new AwtGraphics());
|
||||
|
||||
String os = System.getProperty("os.name").toLowerCase(Locale.ENGLISH);
|
||||
if (os.contains("win"))
|
||||
CanvasAdapter.platform = Platform.WINDOWS;
|
||||
else if (os.contains("mac"))
|
||||
CanvasAdapter.platform = Platform.MACOS;
|
||||
else
|
||||
CanvasAdapter.platform = Platform.LINUX;
|
||||
}
|
||||
|
||||
public static BufferedImage getBitmap(Bitmap bitmap) {
|
||||
@@ -103,9 +114,9 @@ public class AwtGraphics extends CanvasAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bitmap decodeSvgBitmapImpl(InputStream inputStream) {
|
||||
public Bitmap decodeSvgBitmapImpl(InputStream inputStream, int width, int height, int percent) {
|
||||
try {
|
||||
return new AwtSvgBitmap(inputStream);
|
||||
return new AwtSvgBitmap(inputStream, width, height, percent);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
@@ -113,9 +124,9 @@ public class AwtGraphics extends CanvasAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bitmap loadBitmapAssetImpl(String relativePathPrefix, String src) {
|
||||
public Bitmap loadBitmapAssetImpl(String relativePathPrefix, String src, int width, int height, int percent) {
|
||||
try {
|
||||
return createBitmap(relativePathPrefix, src);
|
||||
return createBitmap(relativePathPrefix, src, width, height, percent);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -91,32 +91,32 @@ public class AwtPaint implements Paint {
|
||||
throw new IllegalArgumentException("unknown cap: " + join);
|
||||
}
|
||||
|
||||
static final Font defaultFont;
|
||||
private static final Map<Attribute, Object> textAttributes = new HashMap<>();
|
||||
private static final Font DEFAULT_FONT;
|
||||
private static final Map<Attribute, Object> TEXT_ATTRIBUTES = new HashMap<>();
|
||||
|
||||
static {
|
||||
textAttributes.put(TextAttribute.KERNING, TextAttribute.KERNING_ON);
|
||||
TEXT_ATTRIBUTES.put(TextAttribute.KERNING, TextAttribute.KERNING_ON);
|
||||
|
||||
defaultFont = new Font("Arial", Font.PLAIN, 14).deriveFont(textAttributes);
|
||||
DEFAULT_FONT = new Font("Arial", Font.PLAIN, 14).deriveFont(TEXT_ATTRIBUTES);
|
||||
}
|
||||
|
||||
Color color = new Color(0.1f, 0.1f, 0.1f, 1);
|
||||
FontMetrics fm;
|
||||
Font font = defaultFont; // new Font("Default", Font.PLAIN, 13);
|
||||
Font font = DEFAULT_FONT; // new Font("Default", Font.PLAIN, 13);
|
||||
Stroke stroke;
|
||||
Style style = Style.FILL;
|
||||
private int cap = getCap(Cap.BUTT);
|
||||
private String fontName = defaultFont.getFontName();
|
||||
private int fontStyle = defaultFont.getStyle();
|
||||
private String fontName = DEFAULT_FONT.getFontName();
|
||||
private int fontStyle = DEFAULT_FONT.getStyle();
|
||||
private int join = getJoin(Join.MITER);
|
||||
private float strokeWidth;
|
||||
private float textSize = defaultFont.getSize();
|
||||
private float textSize = DEFAULT_FONT.getSize();
|
||||
|
||||
private final BufferedImage bufferedImage = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
|
||||
|
||||
@Override
|
||||
public int getColor() {
|
||||
return 0;
|
||||
return color.getRGB();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -169,7 +169,7 @@ public class AwtPaint implements Paint {
|
||||
public void setTypeface(FontFamily fontFamily, FontStyle fontStyle) {
|
||||
this.fontName = getFontName(fontFamily);
|
||||
this.fontStyle = getFontStyle(fontStyle);
|
||||
this.font = new Font(this.fontName, this.fontStyle, (int) this.textSize).deriveFont(this.textAttributes);
|
||||
this.font = new Font(this.fontName, this.fontStyle, (int) this.textSize).deriveFont(this.TEXT_ATTRIBUTES);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -212,6 +212,11 @@ public class AwtPaint implements Paint {
|
||||
stroke = new BasicStroke(strokeWidth, cap, join, join == BasicStroke.JOIN_MITER ? 1.0f : 0, null, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getStrokeWidth() {
|
||||
return strokeWidth;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getTextHeight(String text) {
|
||||
Graphics2D graphics2d = bufferedImage.createGraphics();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 devemux86
|
||||
* Copyright 2015-2016 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
|
||||
@@ -28,7 +28,7 @@ import java.net.URI;
|
||||
|
||||
public class AwtSvgBitmap extends AwtBitmap {
|
||||
/**
|
||||
* Default size is 20x20px (400px) at 240dpi.
|
||||
* Default size is 20x20px (400px) at 160dpi.
|
||||
*/
|
||||
public static float DEFAULT_SIZE = 400f;
|
||||
|
||||
@@ -77,13 +77,13 @@ public class AwtSvgBitmap extends AwtBitmap {
|
||||
}
|
||||
}
|
||||
|
||||
private static BufferedImage getResourceBitmapImpl(InputStream inputStream) throws IOException {
|
||||
private static BufferedImage getResourceBitmapImpl(InputStream inputStream, int width, int height, int percent) throws IOException {
|
||||
synchronized (SVGCache.getSVGUniverse()) {
|
||||
return getResourceBitmap(inputStream, CanvasAdapter.dpi / 240, DEFAULT_SIZE, 0, 0, 100);
|
||||
return getResourceBitmap(inputStream, CanvasAdapter.dpi / CanvasAdapter.DEFAULT_DPI, DEFAULT_SIZE, width, height, percent);
|
||||
}
|
||||
}
|
||||
|
||||
public AwtSvgBitmap(InputStream inputStream) throws IOException {
|
||||
super(getResourceBitmapImpl(inputStream));
|
||||
public AwtSvgBitmap(InputStream inputStream, int width, int height, int percent) throws IOException {
|
||||
super(getResourceBitmapImpl(inputStream, width, height, percent));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright 2013 Hannes Janetzek
|
||||
* Copyright 2016 devemux86
|
||||
* Copyright 2016-2017 devemux86
|
||||
*
|
||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||
*
|
||||
@@ -41,12 +41,11 @@ public class GdxMapApp extends GdxMap {
|
||||
AwtGraphics.init();
|
||||
GdxAssets.init("assets/");
|
||||
GLAdapter.init(new LwjglGL20());
|
||||
GLAdapter.GDX_DESKTOP_QUIRKS = true;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
init();
|
||||
new LwjglApplication(new GdxMapApp(), getConfig());
|
||||
new LwjglApplication(new GdxMapApp(), getConfig(null));
|
||||
}
|
||||
|
||||
public static void run(GdxMap map) {
|
||||
@@ -56,13 +55,13 @@ public class GdxMapApp extends GdxMap {
|
||||
public static void run(GdxMap map, LwjglApplicationConfiguration config, int tileSize) {
|
||||
Tile.SIZE = FastMath.clamp(tileSize, 128, 512);
|
||||
|
||||
new LwjglApplication(map, (config == null ? getConfig() : config));
|
||||
new LwjglApplication(map, (config == null ? getConfig(map.getClass().getSimpleName()) : config));
|
||||
}
|
||||
|
||||
static protected LwjglApplicationConfiguration getConfig() {
|
||||
protected static LwjglApplicationConfiguration getConfig(String title) {
|
||||
LwjglApplicationConfiguration.disableAudio = true;
|
||||
LwjglApplicationConfiguration cfg = new LwjglApplicationConfiguration();
|
||||
cfg.title = "vtm-gdx";
|
||||
cfg.title = title != null ? title : "vtm-gdx";
|
||||
cfg.width = 800;
|
||||
cfg.height = 600;
|
||||
cfg.stencil = 8;
|
||||
@@ -76,15 +75,8 @@ public class GdxMapApp extends GdxMap {
|
||||
public void createLayers() {
|
||||
TileSource tileSource = new OSciMap4TileSource();
|
||||
|
||||
// TileSource tileSource = new MapFileTileSource();
|
||||
// tileSource.setOption("file", "/home/jeff/germany.map");
|
||||
|
||||
initDefaultLayers(tileSource, false, true, true);
|
||||
|
||||
//mMap.getLayers().add(new BitmapTileLayer(mMap, new ImagicoLandcover(), 20));
|
||||
//mMap.getLayers().add(new BitmapTileLayer(mMap, new OSMTileSource(), 20));
|
||||
//mMap.getLayers().add(new BitmapTileLayer(mMap, new ArcGISWorldShaded(), 20));
|
||||
|
||||
mMap.setMapPosition(0, 0, 1 << 2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,10 +3,10 @@ apply plugin: 'maven'
|
||||
|
||||
dependencies {
|
||||
compile project(':vtm')
|
||||
compile 'com.fasterxml.jackson.core:jackson-core:2.3.0'
|
||||
compile 'com.google.protobuf:protobuf-java:2.4.1'
|
||||
compile 'com.vividsolutions:jts:1.13'
|
||||
compile 'org.openstreetmap.osmosis:osmosis-osm-binary:0.44.1'
|
||||
compile 'com.fasterxml.jackson.core:jackson-core:2.8.4'
|
||||
compile 'com.google.protobuf:protobuf-java:2.6.1'
|
||||
compile 'com.vividsolutions:jts-core:1.14.0'
|
||||
compile 'org.openstreetmap.osmosis:osmosis-osm-binary:0.45'
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
|
||||
@@ -47,6 +47,11 @@ public abstract class GdxMap implements ApplicationListener {
|
||||
|
||||
protected void initDefaultLayers(TileSource tileSource, boolean tileGrid, boolean labels,
|
||||
boolean buildings) {
|
||||
initDefaultLayers(tileSource, tileGrid, labels, buildings, 1);
|
||||
}
|
||||
|
||||
protected void initDefaultLayers(TileSource tileSource, boolean tileGrid, boolean labels,
|
||||
boolean buildings, float scale) {
|
||||
Layers layers = mMap.layers();
|
||||
|
||||
if (tileSource != null) {
|
||||
@@ -61,7 +66,7 @@ public abstract class GdxMap implements ApplicationListener {
|
||||
}
|
||||
|
||||
if (tileGrid)
|
||||
layers.add(new TileGridLayer(mMap));
|
||||
layers.add(new TileGridLayer(mMap, scale));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -80,11 +85,11 @@ public abstract class GdxMap implements ApplicationListener {
|
||||
mMapRenderer.onSurfaceChanged(w, h);
|
||||
|
||||
InputMultiplexer mux = new InputMultiplexer();
|
||||
mGestureDetector = new GestureDetector(new LayerHandler(mMap));
|
||||
mux.addProcessor(mGestureDetector);
|
||||
if (!Map.NEW_GESTURES) {
|
||||
mGestureDetector = new GestureDetector(new GestureHandlerImpl(mMap));
|
||||
mux.addProcessor(mGestureDetector);
|
||||
}
|
||||
mux.addProcessor(new InputHandler(this));
|
||||
//mux.addProcessor(new GestureDetector(20, 0.5f, 2, 0.05f,
|
||||
// new MapController(mMap)));
|
||||
mux.addProcessor(new MotionHandler(mMap));
|
||||
|
||||
Gdx.input.setInputProcessor(mux);
|
||||
|
||||
@@ -49,6 +49,15 @@ public class GdxMotionEvent extends MotionEvent {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MotionEvent copy() {
|
||||
return new GdxMotionEvent(action, x, y, button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recycle() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTime() {
|
||||
return 0;
|
||||
|
||||
@@ -14,28 +14,42 @@
|
||||
*/
|
||||
package org.oscim.gdx;
|
||||
|
||||
import com.badlogic.gdx.Input;
|
||||
import com.badlogic.gdx.input.GestureDetector;
|
||||
|
||||
import org.oscim.event.Gesture;
|
||||
import org.oscim.event.MotionEvent;
|
||||
import org.oscim.map.Map;
|
||||
|
||||
public class LayerHandler extends GestureDetector.GestureAdapter {
|
||||
public class GestureHandlerImpl extends GestureDetector.GestureAdapter {
|
||||
|
||||
private final Map map;
|
||||
|
||||
public LayerHandler(Map map) {
|
||||
public GestureHandlerImpl(Map map) {
|
||||
this.map = map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean longPress(float x, float y) {
|
||||
// Handle gesture on layers
|
||||
map.handleGesture(Gesture.LONG_PRESS, new GdxMotionEvent(MotionEvent.ACTION_DOWN, x, y));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean tap(float x, float y, int count, int button) {
|
||||
// Handle double tap zoom
|
||||
if (button == Input.Buttons.LEFT) {
|
||||
if (count == 2) {
|
||||
float pivotX = x - map.getWidth() / 2;
|
||||
float pivotY = y - map.getHeight() / 2;
|
||||
map.animator().animateZoom(300, 2, pivotX, pivotY);
|
||||
map.updateMap(true);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Handle gesture on layers
|
||||
map.handleGesture(Gesture.TAP, new GdxMotionEvent(MotionEvent.ACTION_UP, x, y, button));
|
||||
return false;
|
||||
}
|
||||
@@ -26,6 +26,7 @@ import org.oscim.layers.TileGridLayer;
|
||||
import org.oscim.map.Map;
|
||||
import org.oscim.map.ViewController;
|
||||
import org.oscim.theme.VtmThemes;
|
||||
import org.oscim.utils.Easing;
|
||||
|
||||
public class InputHandler implements InputProcessor {
|
||||
|
||||
@@ -86,35 +87,40 @@ public class InputHandler implements InputProcessor {
|
||||
mViewport.moveMap(50, 0);
|
||||
mMap.updateMap(true);
|
||||
break;
|
||||
case Input.Keys.M:
|
||||
case Input.Keys.D:
|
||||
mViewport.scaleMap(1.05f, 0, 0);
|
||||
mMap.updateMap(true);
|
||||
break;
|
||||
case Input.Keys.N:
|
||||
case Input.Keys.A:
|
||||
mViewport.scaleMap(0.95f, 0, 0);
|
||||
mMap.updateMap(true);
|
||||
break;
|
||||
case Input.Keys.NUM_1:
|
||||
case Input.Keys.S:
|
||||
mMap.animator().animateZoom(500, 0.5, 0, 0);
|
||||
mMap.updateMap(false);
|
||||
break;
|
||||
case Input.Keys.NUM_2:
|
||||
case Input.Keys.W:
|
||||
mMap.animator().animateZoom(500, 2, 0, 0);
|
||||
mMap.updateMap(false);
|
||||
break;
|
||||
|
||||
case Input.Keys.D:
|
||||
case Input.Keys.NUM_1:
|
||||
mMap.setTheme(VtmThemes.DEFAULT);
|
||||
mMap.updateMap(false);
|
||||
break;
|
||||
|
||||
case Input.Keys.T:
|
||||
case Input.Keys.NUM_2:
|
||||
mMap.setTheme(VtmThemes.OSMARENDER);
|
||||
mMap.updateMap(false);
|
||||
break;
|
||||
|
||||
case Input.Keys.NUM_3:
|
||||
mMap.setTheme(VtmThemes.TRONRENDER);
|
||||
mMap.updateMap(false);
|
||||
break;
|
||||
|
||||
case Input.Keys.R:
|
||||
mMap.setTheme(VtmThemes.OSMARENDER);
|
||||
case Input.Keys.NUM_4:
|
||||
mMap.setTheme(VtmThemes.NEWTRON);
|
||||
mMap.updateMap(false);
|
||||
break;
|
||||
|
||||
@@ -227,7 +233,7 @@ public class InputHandler implements InputProcessor {
|
||||
public boolean scrolled(int amount) {
|
||||
float fx = mPosX - mMap.getWidth() / 2;
|
||||
float fy = mPosY - mMap.getHeight() / 2;
|
||||
mMap.animator().animateZoom(250, amount > 0 ? 0.75f : 1.333f, fx, fy);
|
||||
mMap.animator().animateZoom(250, amount > 0 ? 0.75f : 1.333f, fx, fy, Easing.Type.LINEAR);
|
||||
mMap.updateMap(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,8 @@ import com.badlogic.gdx.InputProcessor;
|
||||
import org.oscim.event.MotionEvent;
|
||||
import org.oscim.map.Map;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class MotionHandler extends MotionEvent implements InputProcessor {
|
||||
private final Map mMap;
|
||||
|
||||
@@ -77,6 +79,25 @@ public class MotionHandler extends MotionEvent implements InputProcessor {
|
||||
return mPointerDown;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MotionEvent copy() {
|
||||
MotionHandler handler = new MotionHandler(mMap);
|
||||
handler.mPointerDown = mPointerDown;
|
||||
handler.mDownTime = mDownTime;
|
||||
handler.mType = mType;
|
||||
handler.mPointer = mPointer;
|
||||
handler.mCurX = mCurX;
|
||||
handler.mCurY = mCurY;
|
||||
handler.mPointerX = Arrays.copyOf(mPointerX, 10);
|
||||
handler.mPointerY = Arrays.copyOf(mPointerY, 10);
|
||||
handler.mTime = mTime;
|
||||
return handler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recycle() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTime() {
|
||||
return (long) (mTime / 1000000d);
|
||||
|
||||
@@ -3,7 +3,7 @@ apply plugin: 'maven'
|
||||
|
||||
dependencies {
|
||||
compile project(':vtm')
|
||||
compile 'com.squareup.okhttp:okhttp:1.5.2'
|
||||
compile 'com.squareup.okhttp3:okhttp:3.6.0'
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Copyright 2014 Charles Greb
|
||||
* Copyright 2014 Hannes Janetzek
|
||||
* Copyright 2017 devemux86
|
||||
*
|
||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||
*
|
||||
@@ -17,24 +18,25 @@
|
||||
*/
|
||||
package org.oscim.tiling.source;
|
||||
|
||||
import com.squareup.okhttp.HttpResponseCache;
|
||||
import com.squareup.okhttp.OkHttpClient;
|
||||
|
||||
import org.oscim.core.Tile;
|
||||
import org.oscim.utils.IOUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import okhttp3.Cache;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
|
||||
public class OkHttpEngine implements HttpEngine {
|
||||
static final Logger log = LoggerFactory.getLogger(OkHttpEngine.class);
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(OkHttpEngine.class);
|
||||
|
||||
private final OkHttpClient mClient;
|
||||
private final UrlTileSource mTileSource;
|
||||
@@ -46,9 +48,10 @@ public class OkHttpEngine implements HttpEngine {
|
||||
mClient = new OkHttpClient();
|
||||
}
|
||||
|
||||
public OkHttpFactory(HttpResponseCache responseCache) {
|
||||
mClient = new OkHttpClient();
|
||||
mClient.setResponseCache(responseCache);
|
||||
public OkHttpFactory(Cache cache) {
|
||||
mClient = new OkHttpClient.Builder()
|
||||
.cache(cache)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -74,17 +77,17 @@ public class OkHttpEngine implements HttpEngine {
|
||||
if (tile == null) {
|
||||
throw new IllegalArgumentException("Tile cannot be null.");
|
||||
}
|
||||
URL url = new URL(mTileSource.getTileUrl(tile));
|
||||
HttpURLConnection conn = mClient.open(url);
|
||||
|
||||
for (Entry<String, String> opt : mTileSource.getRequestHeader().entrySet())
|
||||
conn.addRequestProperty(opt.getKey(), opt.getValue());
|
||||
|
||||
try {
|
||||
inputStream = conn.getInputStream();
|
||||
} catch (FileNotFoundException e) {
|
||||
throw new IOException("ERROR " + conn.getResponseCode()
|
||||
+ ": " + conn.getResponseMessage());
|
||||
URL url = new URL(mTileSource.getTileUrl(tile));
|
||||
Request.Builder builder = new Request.Builder()
|
||||
.url(url);
|
||||
for (Entry<String, String> opt : mTileSource.getRequestHeader().entrySet())
|
||||
builder.addHeader(opt.getKey(), opt.getValue());
|
||||
Request request = builder.build();
|
||||
Response response = mClient.newCall(request).execute();
|
||||
inputStream = response.body().byteStream();
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,9 +106,11 @@ public class OkHttpEngine implements HttpEngine {
|
||||
}).start();
|
||||
}
|
||||
|
||||
/**
|
||||
* OkHttp cache implemented through {@link OkHttpClient.Builder#cache(Cache)}.
|
||||
*/
|
||||
@Override
|
||||
public void setCache(OutputStream os) {
|
||||
// OkHttp cache implented through tileSource setResponseCache
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,7 +3,7 @@ buildscript {
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.mobidevelop.robovm:robovm-gradle-plugin:2.1.0'
|
||||
classpath 'com.mobidevelop.robovm:robovm-gradle-plugin:2.2.0'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,13 +13,12 @@ apply plugin: 'robovm'
|
||||
|
||||
sourceSets.main.java.srcDirs = ["src/"]
|
||||
|
||||
sourceCompatibility = '1.7'
|
||||
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
|
||||
|
||||
ext {
|
||||
// Configure your application main class
|
||||
mainClassName = "org.oscim.ios.RoboVmLauncher"
|
||||
roboVMVersion = "2.1.0"
|
||||
roboVMVersion = "2.3.0"
|
||||
}
|
||||
|
||||
launchIPhoneSimulator.dependsOn build
|
||||
@@ -47,11 +46,11 @@ task copyVtmThemesResources(type: Copy) {
|
||||
}
|
||||
|
||||
|
||||
tasks.withType(org.gradle.api.tasks.compile.JavaCompile) {
|
||||
tasks.withType(JavaCompile) {
|
||||
compileTask -> compileTask.dependsOn copyVtmResources
|
||||
}
|
||||
|
||||
tasks.withType(org.gradle.api.tasks.compile.JavaCompile) {
|
||||
tasks.withType(JavaCompile) {
|
||||
compileTask -> compileTask.dependsOn copyVtmThemesResources
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 Longri
|
||||
* Copyright 2016-2017 Longri
|
||||
*
|
||||
* 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
|
||||
@@ -37,6 +37,7 @@ import org.slf4j.LoggerFactory;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.Buffer;
|
||||
|
||||
/**
|
||||
* iOS specific implementation of {@link Bitmap}.
|
||||
@@ -48,7 +49,10 @@ public class IosBitmap implements Bitmap {
|
||||
final CGBitmapContext cgBitmapContext;
|
||||
final int width;
|
||||
final int height;
|
||||
Pixmap pixmap;
|
||||
private int glInternalFormat = Integer.MIN_VALUE;
|
||||
private int glFormat = Integer.MIN_VALUE;
|
||||
private int glType = Integer.MIN_VALUE;
|
||||
private Buffer directPixelBuffer;
|
||||
|
||||
/**
|
||||
* Constructor<br>
|
||||
@@ -155,7 +159,10 @@ public class IosBitmap implements Bitmap {
|
||||
@Override
|
||||
public void recycle() {
|
||||
if (this.cgBitmapContext != null) this.cgBitmapContext.release();
|
||||
if (this.pixmap != null) this.pixmap.dispose();
|
||||
if (this.directPixelBuffer != null) {
|
||||
//cgBitmapContext.release() will also release the directPixelBuffer
|
||||
this.directPixelBuffer = null; //only hint for GC
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -180,27 +187,26 @@ public class IosBitmap implements Bitmap {
|
||||
@Override
|
||||
public void uploadToTexture(boolean replace) {
|
||||
|
||||
//create Pixmap from cgBitmapContext
|
||||
UIImage uiImage = new UIImage(cgBitmapContext.toImage());
|
||||
NSData data = uiImage.toPNGData();
|
||||
byte[] encodedData = data.getBytes();
|
||||
//create a pixel buffer for upload from direct memory pointer
|
||||
if (directPixelBuffer == null) {
|
||||
|
||||
if (pixmap != null) {
|
||||
// release outdated native pixel buffer
|
||||
//create Pixmap from cgBitmapContext for extract glFormat info's
|
||||
UIImage uiImage = new UIImage(cgBitmapContext.toImage());
|
||||
NSData data = uiImage.toPNGData();
|
||||
byte[] encodedData = data.getBytes();
|
||||
Pixmap pixmap = new Pixmap(encodedData, 0, encodedData.length);
|
||||
|
||||
glInternalFormat = pixmap.getGLInternalFormat();
|
||||
glFormat = pixmap.getGLFormat();
|
||||
glType = pixmap.getGLType();
|
||||
|
||||
directPixelBuffer = cgBitmapContext.getData().asIntBuffer(encodedData.length / 4);
|
||||
pixmap.dispose();
|
||||
|
||||
}
|
||||
|
||||
pixmap = new Pixmap(encodedData, 0, encodedData.length);
|
||||
|
||||
Gdx.gl.glTexImage2D(GL.TEXTURE_2D, 0, pixmap.getGLInternalFormat(),
|
||||
pixmap.getWidth(), pixmap.getHeight(), 0,
|
||||
pixmap.getGLFormat(), pixmap.getGLType(),
|
||||
pixmap.getPixels());
|
||||
|
||||
data.dispose();
|
||||
uiImage.dispose();
|
||||
encodedData = null;
|
||||
|
||||
Gdx.gl.glTexImage2D(GL.TEXTURE_2D, 0, glInternalFormat, this.width, this.height, 0
|
||||
, glFormat, glType, directPixelBuffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Copyright 2016 Longri
|
||||
* Copyright 2016 devemux86
|
||||
* Copyright 2017 Longri
|
||||
*
|
||||
* 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,6 +17,7 @@
|
||||
package org.oscim.ios.backend;
|
||||
|
||||
import org.oscim.backend.CanvasAdapter;
|
||||
import org.oscim.backend.Platform;
|
||||
import org.oscim.backend.canvas.Bitmap;
|
||||
import org.oscim.backend.canvas.Canvas;
|
||||
import org.oscim.backend.canvas.Paint;
|
||||
@@ -30,10 +32,11 @@ import java.io.InputStream;
|
||||
*/
|
||||
public class IosGraphics extends CanvasAdapter {
|
||||
|
||||
static final Logger log = LoggerFactory.getLogger(IosGraphics.class);
|
||||
private static final Logger log = LoggerFactory.getLogger(IosGraphics.class);
|
||||
|
||||
public static void init() {
|
||||
CanvasAdapter.init(new IosGraphics());
|
||||
CanvasAdapter.platform = Platform.IOS;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -62,9 +65,9 @@ public class IosGraphics extends CanvasAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Bitmap decodeSvgBitmapImpl(InputStream inputStream) {
|
||||
protected Bitmap decodeSvgBitmapImpl(InputStream inputStream, int width, int height, int percent) {
|
||||
try {
|
||||
return new IosSvgBitmap(inputStream);
|
||||
return new IosSvgBitmap(inputStream, width, height, percent);
|
||||
} catch (IOException e) {
|
||||
log.error("decodeSvgBitmapImpl", e);
|
||||
return null;
|
||||
@@ -72,9 +75,9 @@ public class IosGraphics extends CanvasAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Bitmap loadBitmapAssetImpl(String relativePathPrefix, String src) {
|
||||
protected Bitmap loadBitmapAssetImpl(String relativePathPrefix, String src, int width, int height, int percent) {
|
||||
try {
|
||||
return createBitmap(relativePathPrefix, src);
|
||||
return createBitmap(relativePathPrefix, src, width, height, percent);
|
||||
} catch (IOException e) {
|
||||
log.error("loadBitmapAssetImpl", e);
|
||||
return null;
|
||||
|
||||
@@ -337,6 +337,11 @@ public class IosPaint implements Paint {
|
||||
return descent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getStrokeWidth() {
|
||||
return strokeWidth;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getTextHeight(String text) {
|
||||
return this.fontHeight;
|
||||
|
||||
@@ -34,7 +34,7 @@ public class IosSvgBitmap extends IosBitmap {
|
||||
private static final Logger log = LoggerFactory.getLogger(IosSvgBitmap.class);
|
||||
|
||||
/**
|
||||
* Default size is 20x20px (400px) at 240dpi.
|
||||
* Default size is 20x20px (400px) at 160dpi.
|
||||
*/
|
||||
public static float DEFAULT_SIZE = 400f;
|
||||
|
||||
@@ -89,11 +89,11 @@ public class IosSvgBitmap extends IosBitmap {
|
||||
return renderer.asImageWithSize(new CGSize(bitmapWidth, bitmapHeight), 1);
|
||||
}
|
||||
|
||||
private static UIImage getResourceBitmapImpl(InputStream inputStream) {
|
||||
return getResourceBitmap(inputStream, CanvasAdapter.dpi / 240, DEFAULT_SIZE, 0, 0, 100);
|
||||
private static UIImage getResourceBitmapImpl(InputStream inputStream, int width, int height, int percent) {
|
||||
return getResourceBitmap(inputStream, CanvasAdapter.dpi / CanvasAdapter.DEFAULT_DPI, DEFAULT_SIZE, width, height, percent);
|
||||
}
|
||||
|
||||
public IosSvgBitmap(InputStream inputStream) throws IOException {
|
||||
super(getResourceBitmapImpl(inputStream));
|
||||
public IosSvgBitmap(InputStream inputStream, int width, int height, int percent) throws IOException {
|
||||
super(getResourceBitmapImpl(inputStream, width, height, percent));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ apply plugin: 'maven'
|
||||
|
||||
dependencies {
|
||||
compile project(':vtm')
|
||||
compile 'com.vividsolutions:jts:1.13'
|
||||
compile 'com.vividsolutions:jts-core:1.14.0'
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
* Copyright 2012 osmdroid authors: Viesturs Zarins, Martin Pearman
|
||||
* Copyright 2012 Hannes Janetzek
|
||||
* Copyright 2016 devemux86
|
||||
* Copyright 2016 Pedinel
|
||||
*
|
||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||
*
|
||||
@@ -27,6 +28,7 @@ import org.oscim.map.Map;
|
||||
import org.oscim.utils.geom.GeomBuilder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -68,7 +70,7 @@ public class PathLayer extends VectorLayer {
|
||||
updatePoints();
|
||||
}
|
||||
|
||||
public void setPoints(List<GeoPoint> pts) {
|
||||
public void setPoints(Collection<? extends GeoPoint> pts) {
|
||||
mPoints.clear();
|
||||
mPoints.addAll(pts);
|
||||
updatePoints();
|
||||
@@ -84,6 +86,11 @@ public class PathLayer extends VectorLayer {
|
||||
updatePoints();
|
||||
}
|
||||
|
||||
public void addPoints(Collection<? extends GeoPoint> pts) {
|
||||
mPoints.addAll(pts);
|
||||
updatePoints();
|
||||
}
|
||||
|
||||
private void updatePoints() {
|
||||
synchronized (this) {
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ dependencies {
|
||||
compile project(':vtm-jeo')
|
||||
compile project(':vtm-jts')
|
||||
compile 'org.slf4j:slf4j-simple:1.7.21'
|
||||
runtime 'com.squareup.okhttp:okhttp:1.5.2'
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
|
||||
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 675 B |
|
Before Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 692 B |
|
Before Width: | Height: | Size: 44 KiB |
|
Before Width: | Height: | Size: 118 KiB |
|
Before Width: | Height: | Size: 73 KiB |
50
vtm-playground/resources/assets/vtm/stylemenu.xml
Normal file
@@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<rendertheme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" map-background="#fffcfa"
|
||||
version="1" xmlns="http://opensciencemap.org/rendertheme"
|
||||
xsi:schemaLocation="http://opensciencemap.org/rendertheme https://raw.githubusercontent.com/mapsforge/vtm/master/resources/rendertheme.xsd">
|
||||
|
||||
<stylemenu defaultlang="en" defaultvalue="1" id="menu">
|
||||
<layer enabled="true" id="nature">
|
||||
<name lang="de" value="Natur" />
|
||||
<name lang="en" value="Nature" />
|
||||
<name lang="es" value="Naturaleza" />
|
||||
<name lang="fr" value="Nature" />
|
||||
<cat id="nature" />
|
||||
</layer>
|
||||
|
||||
<layer id="base">
|
||||
<cat id="sea" />
|
||||
<cat id="land" />
|
||||
</layer>
|
||||
|
||||
<!-- Show nature layers (enabled by default) -->
|
||||
<layer id="1" parent="base" visible="true">
|
||||
<name lang="de" value="1" />
|
||||
<name lang="en" value="1" />
|
||||
<name lang="es" value="1" />
|
||||
<name lang="fr" value="1" />
|
||||
<overlay id="nature" />
|
||||
</layer>
|
||||
|
||||
<!-- Don't show nature layers -->
|
||||
<layer id="2" parent="base" visible="true">
|
||||
<name lang="de" value="2" />
|
||||
<name lang="en" value="2" />
|
||||
<name lang="es" value="2" />
|
||||
<name lang="fr" value="2" />
|
||||
</layer>
|
||||
</stylemenu>
|
||||
|
||||
<m cat="sea" e="way" k="natural" v="issea|sea">
|
||||
<area fill="#b5d6f1" mesh="true" />
|
||||
</m>
|
||||
|
||||
<m cat="land" e="way" k="natural" v="nosea">
|
||||
<area fill="#f8f8f8" mesh="true" />
|
||||
</m>
|
||||
|
||||
<m cat="nature" e="way" k="natural|landuse" v="forest|wood">
|
||||
<area fill="#83aa5b" />
|
||||
</m>
|
||||
|
||||
</rendertheme>
|
||||
@@ -16,43 +16,26 @@
|
||||
*/
|
||||
package org.oscim.stuff;
|
||||
|
||||
import com.badlogic.gdx.Input;
|
||||
|
||||
import org.oscim.gdx.GdxMap;
|
||||
import org.oscim.gdx.GdxMapApp;
|
||||
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.IRenderTheme.ThemeException;
|
||||
import org.oscim.theme.StreamRenderTheme;
|
||||
import org.oscim.theme.ThemeLoader;
|
||||
import org.oscim.tiling.source.OkHttpEngine;
|
||||
import org.oscim.theme.VtmThemes;
|
||||
import org.oscim.tiling.source.UrlTileSource;
|
||||
import org.oscim.tiling.source.oscimap4.OSciMap4TileSource;
|
||||
|
||||
public class MapzenTest extends GdxMap {
|
||||
|
||||
@Override
|
||||
protected boolean onKeyDown(int keycode) {
|
||||
if (keycode == Input.Keys.A) {
|
||||
loadTheme();
|
||||
}
|
||||
|
||||
return super.onKeyDown(keycode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createLayers() {
|
||||
UrlTileSource tileSource = OSciMap4TileSource.builder()
|
||||
.url("https://vector.mapzen.com/osm/v0.8/all")
|
||||
.apiKey("vector-tiles-xxxxxxx") // Put a proper API key
|
||||
.zoomMax(18)
|
||||
.httpFactory(new OkHttpEngine.OkHttpFactory())
|
||||
.build();
|
||||
|
||||
VectorTileLayer l = mMap.setBaseMap(tileSource);
|
||||
|
||||
loadTheme();
|
||||
mMap.setTheme(VtmThemes.DEFAULT);
|
||||
|
||||
mMap.layers().add(new BuildingLayer(mMap, l));
|
||||
mMap.layers().add(new LabelLayer(mMap, l));
|
||||
@@ -60,14 +43,6 @@ public class MapzenTest extends GdxMap {
|
||||
mMap.setMapPosition(53.08, 8.82, 1 << 17);
|
||||
}
|
||||
|
||||
private void loadTheme() {
|
||||
try {
|
||||
mMap.setTheme(ThemeLoader.load(new StreamRenderTheme("", getClass().getResourceAsStream("/assets/styles/mapzen.xml"))));
|
||||
} catch (ThemeException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
GdxMapApp.init();
|
||||
GdxMapApp.run(new MapzenTest());
|
||||
|
||||
94
vtm-playground/src/org/oscim/test/AtlasMarkerLayerTest.java
Normal file
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Copyright 2016 devemux86
|
||||
* Copyright 2017 Longri
|
||||
*
|
||||
* 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.test;
|
||||
|
||||
import org.oscim.backend.CanvasAdapter;
|
||||
import org.oscim.backend.canvas.Bitmap;
|
||||
import org.oscim.core.GeoPoint;
|
||||
import org.oscim.gdx.GdxMapApp;
|
||||
import org.oscim.layers.TileGridLayer;
|
||||
import org.oscim.layers.marker.ItemizedLayer;
|
||||
import org.oscim.layers.marker.MarkerItem;
|
||||
import org.oscim.layers.marker.MarkerSymbol;
|
||||
import org.oscim.layers.tile.bitmap.BitmapTileLayer;
|
||||
import org.oscim.renderer.atlas.TextureAtlas;
|
||||
import org.oscim.renderer.atlas.TextureRegion;
|
||||
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.layers.marker.MarkerSymbol.HotspotPlace;
|
||||
|
||||
public class AtlasMarkerLayerTest extends MarkerLayerTest implements ItemizedLayer.OnItemGestureListener<MarkerItem> {
|
||||
|
||||
@Override
|
||||
public void createLayers() {
|
||||
BitmapTileLayer bitmapLayer = new BitmapTileLayer(mMap, DefaultSources.STAMEN_TONER.build());
|
||||
bitmapLayer.tileRenderer().setBitmapAlpha(0.5f);
|
||||
mMap.setBaseMap(bitmapLayer);
|
||||
|
||||
// Map events receiver
|
||||
mMap.layers().add(new MapEventsReceiver(mMap));
|
||||
|
||||
mMap.setMapPosition(0, 0, 1 << 2);
|
||||
|
||||
Bitmap bitmapPoi = CanvasAdapter.decodeBitmap(getClass().getResourceAsStream("/res/marker_poi.png"));
|
||||
Bitmap bitmapFocus = CanvasAdapter.decodeBitmap(getClass().getResourceAsStream("/res/marker_focus.png"));
|
||||
|
||||
// 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);
|
||||
|
||||
ItemizedLayer<MarkerItem> markerLayer = new ItemizedLayer<>(mMap, new ArrayList<MarkerItem>(), symbol, this);
|
||||
mMap.layers().add(markerLayer);
|
||||
|
||||
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)));
|
||||
}
|
||||
markerLayer.addItems(pts);
|
||||
|
||||
mMap.layers().add(new TileGridLayer(mMap));
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
GdxMapApp.init();
|
||||
GdxMapApp.run(new AtlasMarkerLayerTest());
|
||||
}
|
||||
}
|
||||
85
vtm-playground/src/org/oscim/test/CircleTest.java
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright 2016 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.test;
|
||||
|
||||
import org.oscim.backend.GLAdapter;
|
||||
import org.oscim.backend.canvas.Color;
|
||||
import org.oscim.core.GeometryBuffer;
|
||||
import org.oscim.gdx.GdxMap;
|
||||
import org.oscim.gdx.GdxMapApp;
|
||||
import org.oscim.layers.GenericLayer;
|
||||
import org.oscim.renderer.BucketRenderer;
|
||||
import org.oscim.renderer.GLViewport;
|
||||
import org.oscim.renderer.MapRenderer;
|
||||
import org.oscim.renderer.bucket.CircleBucket;
|
||||
import org.oscim.theme.styles.CircleStyle;
|
||||
|
||||
public class CircleTest extends GdxMap {
|
||||
|
||||
private final GeometryBuffer geom = new GeometryBuffer(2, 1);
|
||||
private final Renderer renderer = new Renderer();
|
||||
|
||||
private void addCircle(float x, float y, CircleBucket cb) {
|
||||
geom.clear();
|
||||
geom.startPoints();
|
||||
geom.addPoint(x, y);
|
||||
cb.addCircle(geom);
|
||||
}
|
||||
|
||||
private class Renderer extends BucketRenderer {
|
||||
|
||||
Renderer() {
|
||||
mMapPosition.scale = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(GLViewport v) {
|
||||
if (mMapPosition.scale == 0)
|
||||
mMapPosition.copy(v.pos);
|
||||
|
||||
if (!isReady())
|
||||
compile();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createLayers() {
|
||||
MapRenderer.setBackgroundColor(Color.BLACK);
|
||||
|
||||
mMap.setMapPosition(0, 0, 1 << 4);
|
||||
|
||||
CircleStyle cs = CircleStyle.builder()
|
||||
.radius(30)
|
||||
.color(Color.MAGENTA)
|
||||
.strokeWidth(6)
|
||||
.strokeColor(Color.WHITE)
|
||||
.build();
|
||||
CircleBucket cb = renderer.buckets.addCircleBucket(0, cs);
|
||||
addCircle(200, -200, cb);
|
||||
addCircle(-200, -200, cb);
|
||||
addCircle(-200, 200, cb);
|
||||
addCircle(200, 200, cb);
|
||||
|
||||
mMap.layers().add(new GenericLayer(mMap, renderer));
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
// Draw circles with quads or points
|
||||
GLAdapter.CIRCLE_QUADS = false;
|
||||
|
||||
GdxMapApp.init();
|
||||
GdxMapApp.run(new CircleTest());
|
||||
}
|
||||
}
|
||||
47
vtm-playground/src/org/oscim/test/MapboxTest.java
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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.test;
|
||||
|
||||
import org.oscim.gdx.GdxMapApp;
|
||||
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 org.oscim.tiling.source.OkHttpEngine;
|
||||
import org.oscim.tiling.source.UrlTileSource;
|
||||
import org.oscim.tiling.source.mvt.MapboxTileSource;
|
||||
|
||||
public class MapboxTest extends GdxMapApp {
|
||||
|
||||
@Override
|
||||
public void createLayers() {
|
||||
UrlTileSource tileSource = MapboxTileSource.builder()
|
||||
.apiKey("mapzen-xxxxxxx") // Put a proper API key
|
||||
.httpFactory(new OkHttpEngine.OkHttpFactory())
|
||||
//.locale("en")
|
||||
.build();
|
||||
|
||||
VectorTileLayer l = mMap.setBaseMap(tileSource);
|
||||
mMap.setTheme(VtmThemes.MAPZEN);
|
||||
|
||||
mMap.layers().add(new BuildingLayer(mMap, l));
|
||||
mMap.layers().add(new LabelLayer(mMap, l));
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
GdxMapApp.init();
|
||||
GdxMapApp.run(new MapboxTest());
|
||||
}
|
||||
}
|
||||
85
vtm-playground/src/org/oscim/test/MapsforgeMultiTest.java
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright 2016 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.test;
|
||||
|
||||
import org.oscim.core.MapPosition;
|
||||
import org.oscim.core.Tile;
|
||||
import org.oscim.gdx.GdxMap;
|
||||
import org.oscim.gdx.GdxMapApp;
|
||||
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 org.oscim.tiling.source.mapfile.MapFileTileSource;
|
||||
import org.oscim.tiling.source.mapfile.MultiMapFileTileSource;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MapsforgeMultiTest extends GdxMap {
|
||||
|
||||
private final List<File> mapFiles;
|
||||
|
||||
private MapsforgeMultiTest(List<File> mapFiles) {
|
||||
this.mapFiles = mapFiles;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createLayers() {
|
||||
MultiMapFileTileSource tileSource = new MultiMapFileTileSource();
|
||||
for (File mapFile : mapFiles) {
|
||||
MapFileTileSource mapFileTileSource = new MapFileTileSource();
|
||||
mapFileTileSource.setMapFile(mapFile.getAbsolutePath());
|
||||
tileSource.add(mapFileTileSource);
|
||||
}
|
||||
tileSource.setPreferredLanguage("en");
|
||||
|
||||
VectorTileLayer l = mMap.setBaseMap(tileSource);
|
||||
mMap.setTheme(VtmThemes.DEFAULT);
|
||||
|
||||
mMap.layers().add(new BuildingLayer(mMap, l));
|
||||
mMap.layers().add(new LabelLayer(mMap, l));
|
||||
|
||||
MapPosition pos = new MapPosition();
|
||||
pos.setByBoundingBox(tileSource.getBoundingBox(), Tile.SIZE * 4, Tile.SIZE * 4);
|
||||
mMap.setMapPosition(pos);
|
||||
}
|
||||
|
||||
private static List<File> getMapFiles(String[] args) {
|
||||
if (args.length == 0) {
|
||||
throw new IllegalArgumentException("missing argument: <mapFile>");
|
||||
}
|
||||
|
||||
List<File> result = new ArrayList<>();
|
||||
for (String arg : args) {
|
||||
File mapFile = new File(arg);
|
||||
if (!mapFile.exists()) {
|
||||
throw new IllegalArgumentException("file does not exist: " + mapFile);
|
||||
} else if (!mapFile.isFile()) {
|
||||
throw new IllegalArgumentException("not a file: " + mapFile);
|
||||
} else if (!mapFile.canRead()) {
|
||||
throw new IllegalArgumentException("cannot read file: " + mapFile);
|
||||
}
|
||||
result.add(mapFile);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
GdxMapApp.init();
|
||||
GdxMapApp.run(new MapsforgeMultiTest(getMapFiles(args)));
|
||||
}
|
||||
}
|
||||
126
vtm-playground/src/org/oscim/test/MapsforgeStyleTest.java
Normal file
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
* Copyright 2016 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.test;
|
||||
|
||||
import com.badlogic.gdx.Input;
|
||||
|
||||
import org.oscim.core.MapPosition;
|
||||
import org.oscim.core.Tile;
|
||||
import org.oscim.gdx.GdxMap;
|
||||
import org.oscim.gdx.GdxMapApp;
|
||||
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.StreamRenderTheme;
|
||||
import org.oscim.theme.XmlRenderThemeMenuCallback;
|
||||
import org.oscim.theme.XmlRenderThemeStyleLayer;
|
||||
import org.oscim.theme.XmlRenderThemeStyleMenu;
|
||||
import org.oscim.tiling.source.mapfile.MapFileTileSource;
|
||||
import org.oscim.tiling.source.mapfile.MapInfo;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Set;
|
||||
|
||||
public class MapsforgeStyleTest extends GdxMap {
|
||||
|
||||
private static File mapFile;
|
||||
|
||||
@Override
|
||||
public void createLayers() {
|
||||
MapFileTileSource tileSource = new MapFileTileSource();
|
||||
tileSource.setMapFile(mapFile.getAbsolutePath());
|
||||
tileSource.setPreferredLanguage("en");
|
||||
|
||||
VectorTileLayer l = mMap.setBaseMap(tileSource);
|
||||
loadTheme(null);
|
||||
|
||||
mMap.layers().add(new BuildingLayer(mMap, l));
|
||||
mMap.layers().add(new LabelLayer(mMap, l));
|
||||
|
||||
MapInfo info = tileSource.getMapInfo();
|
||||
MapPosition pos = new MapPosition();
|
||||
pos.setByBoundingBox(info.boundingBox, Tile.SIZE * 4, Tile.SIZE * 4);
|
||||
mMap.setMapPosition(pos);
|
||||
}
|
||||
|
||||
private static File getMapFile(String[] args) {
|
||||
if (args.length == 0) {
|
||||
throw new IllegalArgumentException("missing argument: <mapFile>");
|
||||
}
|
||||
|
||||
File file = new File(args[0]);
|
||||
if (!file.exists()) {
|
||||
throw new IllegalArgumentException("file does not exist: " + file);
|
||||
} else if (!file.isFile()) {
|
||||
throw new IllegalArgumentException("not a file: " + file);
|
||||
} else if (!file.canRead()) {
|
||||
throw new IllegalArgumentException("cannot read file: " + file);
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
private void loadTheme(final String styleId) {
|
||||
mMap.setTheme(new StreamRenderTheme("", getClass().getResourceAsStream("/assets/vtm/stylemenu.xml"), new XmlRenderThemeMenuCallback() {
|
||||
@Override
|
||||
public Set<String> getCategories(XmlRenderThemeStyleMenu renderThemeStyleMenu) {
|
||||
// Use the selected style or the default
|
||||
String style = styleId != null ? styleId : renderThemeStyleMenu.getDefaultValue();
|
||||
|
||||
// Retrieve the layer from the style id
|
||||
XmlRenderThemeStyleLayer renderThemeStyleLayer = renderThemeStyleMenu.getLayer(style);
|
||||
if (renderThemeStyleLayer == null) {
|
||||
System.err.println("Invalid style " + style);
|
||||
return null;
|
||||
}
|
||||
|
||||
// First get the selected layer's categories that are enabled together
|
||||
Set<String> categories = renderThemeStyleLayer.getCategories();
|
||||
|
||||
// Then add the selected layer's overlays that are enabled individually
|
||||
// Here we use the style menu, but users can use their own preferences
|
||||
for (XmlRenderThemeStyleLayer overlay : renderThemeStyleLayer.getOverlays()) {
|
||||
if (overlay.isEnabled())
|
||||
categories.addAll(overlay.getCategories());
|
||||
}
|
||||
|
||||
// This is the whole categories set to be enabled
|
||||
return categories;
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onKeyDown(int keycode) {
|
||||
switch (keycode) {
|
||||
case Input.Keys.NUM_1:
|
||||
loadTheme("1");
|
||||
mMap.clearMap();
|
||||
return true;
|
||||
case Input.Keys.NUM_2:
|
||||
loadTheme("2");
|
||||
mMap.clearMap();
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onKeyDown(keycode);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
mapFile = getMapFile(args);
|
||||
|
||||
GdxMapApp.init();
|
||||
GdxMapApp.run(new MapsforgeStyleTest());
|
||||
}
|
||||
}
|
||||
@@ -17,12 +17,17 @@ package org.oscim.test;
|
||||
import org.oscim.backend.CanvasAdapter;
|
||||
import org.oscim.backend.canvas.Bitmap;
|
||||
import org.oscim.core.GeoPoint;
|
||||
import org.oscim.event.Gesture;
|
||||
import org.oscim.event.GestureListener;
|
||||
import org.oscim.event.MotionEvent;
|
||||
import org.oscim.gdx.GdxMapApp;
|
||||
import org.oscim.layers.Layer;
|
||||
import org.oscim.layers.TileGridLayer;
|
||||
import org.oscim.layers.marker.ItemizedLayer;
|
||||
import org.oscim.layers.marker.MarkerItem;
|
||||
import org.oscim.layers.marker.MarkerSymbol;
|
||||
import org.oscim.layers.tile.bitmap.BitmapTileLayer;
|
||||
import org.oscim.map.Map;
|
||||
import org.oscim.tiling.source.bitmap.DefaultSources;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -32,8 +37,8 @@ import static org.oscim.layers.marker.MarkerSymbol.HotspotPlace;
|
||||
|
||||
public class MarkerLayerTest extends GdxMapApp implements ItemizedLayer.OnItemGestureListener<MarkerItem> {
|
||||
|
||||
private static final boolean BILLBOARDS = true;
|
||||
private MarkerSymbol mFocusMarker;
|
||||
protected static final boolean BILLBOARDS = true;
|
||||
protected MarkerSymbol mFocusMarker;
|
||||
|
||||
@Override
|
||||
public void createLayers() {
|
||||
@@ -41,6 +46,9 @@ public class MarkerLayerTest extends GdxMapApp implements ItemizedLayer.OnItemGe
|
||||
bitmapLayer.tileRenderer().setBitmapAlpha(0.5f);
|
||||
mMap.setBaseMap(bitmapLayer);
|
||||
|
||||
// Map events receiver
|
||||
mMap.layers().add(new MapEventsReceiver(mMap));
|
||||
|
||||
mMap.setMapPosition(0, 0, 1 << 2);
|
||||
|
||||
Bitmap bitmapPoi = CanvasAdapter.decodeBitmap(getClass().getResourceAsStream("/res/marker_poi.png"));
|
||||
@@ -76,17 +84,45 @@ public class MarkerLayerTest extends GdxMapApp implements ItemizedLayer.OnItemGe
|
||||
else
|
||||
item.setMarker(null);
|
||||
|
||||
System.out.println(item.getTitle());
|
||||
System.out.println("Marker tap " + item.getTitle());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemLongPress(int index, MarkerItem item) {
|
||||
return false;
|
||||
if (item.getMarker() == null)
|
||||
item.setMarker(mFocusMarker);
|
||||
else
|
||||
item.setMarker(null);
|
||||
|
||||
System.out.println("Marker long press " + item.getTitle());
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
GdxMapApp.init();
|
||||
GdxMapApp.run(new MarkerLayerTest());
|
||||
}
|
||||
|
||||
protected class MapEventsReceiver extends Layer implements GestureListener {
|
||||
|
||||
MapEventsReceiver(Map map) {
|
||||
super(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onGesture(Gesture g, MotionEvent e) {
|
||||
if (g instanceof Gesture.Tap) {
|
||||
GeoPoint p = mMap.viewport().fromScreenPoint(e.getX(), e.getY());
|
||||
System.out.println("Map tap " + p);
|
||||
return true;
|
||||
}
|
||||
if (g instanceof Gesture.LongPress) {
|
||||
GeoPoint p = mMap.viewport().fromScreenPoint(e.getX(), e.getY());
|
||||
System.out.println("Map long press " + p);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
28
vtm-playground/src/org/oscim/test/NewGesturesTest.java
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2016 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.test;
|
||||
|
||||
import org.oscim.gdx.GdxMapApp;
|
||||
import org.oscim.map.Map;
|
||||
|
||||
public class NewGesturesTest extends MarkerLayerTest {
|
||||
|
||||
public static void main(String[] args) {
|
||||
Map.NEW_GESTURES = true;
|
||||
|
||||
GdxMapApp.init();
|
||||
GdxMapApp.run(new NewGesturesTest());
|
||||
}
|
||||
}
|
||||
@@ -2,11 +2,11 @@ apply plugin: 'java'
|
||||
|
||||
dependencies {
|
||||
compile project(':vtm-http')
|
||||
compile 'com.squareup.okhttp:okhttp:1.5.2'
|
||||
testCompile 'com.squareup.okhttp:mockwebserver:1.5.2'
|
||||
testCompile 'junit:junit:4.11'
|
||||
compile 'com.squareup.okhttp3:okhttp:3.6.0'
|
||||
testCompile 'com.squareup.okhttp3:mockwebserver:3.6.0'
|
||||
testCompile 'junit:junit:4.12'
|
||||
testCompile 'org.easytesting:fest-assert-core:2.0M10'
|
||||
testCompile 'org.mockito:mockito-all:1.9.5'
|
||||
testCompile 'org.mockito:mockito-all:1.10.19'
|
||||
testCompile 'org.slf4j:slf4j-simple:1.7.21'
|
||||
}
|
||||
|
||||
|
||||
@@ -18,14 +18,13 @@ import static org.mockito.Mockito.when;
|
||||
|
||||
public class MapEventLayerTest {
|
||||
private MapEventLayer layer;
|
||||
private Map mockMap;
|
||||
private ViewController mockViewport;
|
||||
private Animator mockAnimator;
|
||||
private ArgumentCaptor<Float> argumentCaptor;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
mockMap = Mockito.mock(Map.class);
|
||||
Map mockMap = Mockito.mock(Map.class);
|
||||
mockViewport = Mockito.mock(ViewController.class);
|
||||
mockAnimator = Mockito.mock(Animator.class);
|
||||
layer = new MapEventLayer(mockMap);
|
||||
@@ -94,12 +93,12 @@ public class MapEventLayerTest {
|
||||
layer.onTouchEvent(new TestMotionEvent(MotionEvent.ACTION_UP, 1, 2));
|
||||
}
|
||||
|
||||
class TestMotionEvent extends MotionEvent {
|
||||
private class TestMotionEvent extends MotionEvent {
|
||||
final int action;
|
||||
final float x;
|
||||
final float y;
|
||||
|
||||
public TestMotionEvent(int action, float x, float y) {
|
||||
TestMotionEvent(int action, float x, float y) {
|
||||
this.action = action;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
@@ -139,5 +138,14 @@ public class MapEventLayerTest {
|
||||
public int getPointerCount() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MotionEvent copy() {
|
||||
return new TestMotionEvent(action, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recycle() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
package org.oscim.tiling.source;
|
||||
|
||||
import com.squareup.okhttp.HttpResponseCache;
|
||||
import com.squareup.okhttp.mockwebserver.MockResponse;
|
||||
import com.squareup.okhttp.mockwebserver.MockWebServer;
|
||||
import com.squareup.okhttp.mockwebserver.RecordedRequest;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -16,23 +11,26 @@ import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
import okhttp3.Cache;
|
||||
import okhttp3.mockwebserver.MockResponse;
|
||||
import okhttp3.mockwebserver.MockWebServer;
|
||||
import okhttp3.mockwebserver.RecordedRequest;
|
||||
|
||||
import static org.fest.assertions.api.Assertions.assertThat;
|
||||
|
||||
public class OkHttpEngineTest {
|
||||
private OkHttpEngine engine;
|
||||
private MockWebServer server;
|
||||
private MockResponse mockResponse;
|
||||
private HttpResponseCache cache;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
mockResponse = new MockResponse();
|
||||
mockResponse.setBody("TEST RESPONSE".getBytes());
|
||||
MockResponse mockResponse = new MockResponse();
|
||||
mockResponse.setBody("TEST RESPONSE");
|
||||
server = new MockWebServer();
|
||||
server.enqueue(mockResponse);
|
||||
server.play();
|
||||
server.start();
|
||||
engine = (OkHttpEngine) new OkHttpEngine.OkHttpFactory()
|
||||
.create(new OSciMap4TileSource(server.getUrl("/tiles/vtm").toString()));
|
||||
.create(new OSciMap4TileSource(server.url("/tiles/vtm").toString()));
|
||||
}
|
||||
|
||||
@After
|
||||
@@ -52,7 +50,7 @@ public class OkHttpEngineTest {
|
||||
|
||||
@Test
|
||||
public void sendRequest_shouldAppendXYZToPath() throws Exception {
|
||||
engine.sendRequest(new Tile(1, 2, new Integer(3).byteValue()));
|
||||
engine.sendRequest(new Tile(1, 2, (byte) 3));
|
||||
|
||||
RecordedRequest request = server.takeRequest();
|
||||
assertThat(request.getPath()).isEqualTo("/tiles/vtm/3/1/2.vtm");
|
||||
@@ -60,7 +58,7 @@ public class OkHttpEngineTest {
|
||||
|
||||
@Test
|
||||
public void read_shouldReturnResponseStream() throws Exception {
|
||||
engine.sendRequest(new Tile(1, 2, new Integer(3).byteValue()));
|
||||
engine.sendRequest(new Tile(1, 2, (byte) 3));
|
||||
|
||||
InputStream responseStream = engine.read();
|
||||
String response = new BufferedReader(new InputStreamReader(responseStream)).readLine();
|
||||
@@ -93,12 +91,12 @@ public class OkHttpEngineTest {
|
||||
|
||||
@Test
|
||||
public void create_shouldUseTileSourceCache() throws Exception {
|
||||
cache = new HttpResponseCache(new File("tmp"), 1024);
|
||||
Cache cache = new Cache(new File("tmp"), 1024);
|
||||
OSciMap4TileSource tileSource =
|
||||
new OSciMap4TileSource(server.getUrl("/tiles/vtm").toString());
|
||||
new OSciMap4TileSource(server.url("/tiles/vtm").toString());
|
||||
engine = (OkHttpEngine) new OkHttpEngine.OkHttpFactory(cache).create(tileSource);
|
||||
engine.sendRequest(new Tile(1, 2, new Integer(3).byteValue()));
|
||||
engine.sendRequest(new Tile(1, 2, (byte) 3));
|
||||
engine.requestCompleted(true);
|
||||
assertThat(cache.getRequestCount()).isEqualTo(1);
|
||||
assertThat(cache.requestCount()).isEqualTo(1);
|
||||
}
|
||||
}
|
||||
|
||||