145 Commits

Author SHA1 Message Date
Emux
d60e2ef575 0.7.0-rc1 2017-02-16 14:53:42 +02:00
Emux
58ecf60d9d vtm-web: fix javadoc 2017-02-16 11:45:04 +02:00
Emux
17356e5a2b vtm-web: add in Maven deploy 2017-02-16 10:52:08 +02:00
Emux
296fdd3c13 Update Mapsforge-Maps.md 2017-02-14 10:27:07 +02:00
Emux
735acc520a Android MapView: add onDestroy method 2017-02-13 10:14:53 +02:00
Emux
ac115b1f0f TileSource: add name parameter 2017-02-12 21:09:38 +02:00
Emux
d2ba6647ea OkHttp: catch exceptions #138 2017-02-11 23:30:08 +02:00
Emux
0180c40855 Mapbox (Mapzen): use OkHttp engine #57 2017-02-11 22:33:35 +02:00
Emux
817bd13d7b OkHttp 3 engine, closes #138 2017-02-11 22:33:23 +02:00
Emux
d22dc79655 Fix readme 2017-02-07 12:48:51 +02:00
Emux
fc9ef062c0 Update readme 2017-02-07 12:37:19 +02:00
Emux
f2dda7c8eb vtm-web-app: include theme with texture atlas symbols #51 2017-02-06 20:07:55 +02:00
Emux
fdc793d9ec Samples: fix location layer visibility #32 2017-02-06 14:18:43 +02:00
Emux
3d24aade21 Samples: skip z-order in fragment #32 2017-02-06 14:17:47 +02:00
Emux
6d93aaf57f Update vtm-web-js build 2017-02-06 10:57:27 +02:00
Schedul Xor
8fc354c96a libGDX1.9.5, GWT2.8.0 applied to vtm-web (#290) 2017-02-06 10:48:19 +02:00
Emux
e30f3f7cc3 Update integration guide 2017-02-01 10:29:13 +02:00
Emux
aff2c77267 Update Android support library 2017-01-31 10:03:55 +02:00
Emux
33365b3f7d Mapbox (Mapzen) theme: cities improvements #287 #57 2017-01-29 11:43:06 +02:00
Robin
33fdc938fa Render capital cities early (#287)
Mapbox (Mapzen): Render capital cities early
2017-01-29 11:15:55 +02:00
Emux
8397d5a3be Platform identification improvements #286, closes #285 2017-01-27 20:09:33 +02:00
Longri
980e9d5e54 Add platform identification (#286) 2017-01-27 20:02:17 +02:00
Emux
bc7c55b1f8 Update readme 2017-01-27 12:01:55 +02:00
Longri
120182ec15 Texture atlas with marker overlays example (#284) 2017-01-27 11:58:27 +02:00
Emux
945b84f04f Update changelog 2017-01-26 20:54:48 +02:00
Andre Höpfner
f67c457006 Create TextureAtlas with TextureRegions from bitmaps (#283) 2017-01-26 20:53:40 +02:00
Emux
a2852b0761 Update integration guide 2017-01-22 16:38:08 +02:00
Emux
ebf5d408bc Add Mapsforge map providers list doc 2017-01-21 15:19:33 +02:00
Longri
75719eae29 iOS: improve upload texture for IosBitmap (#282) 2017-01-21 14:30:12 +02:00
Emux
5c825ea9eb Mapbox (Mapzen): locale improvements #57 2016-12-29 18:16:27 +02:00
Emux
15bc23cadf Mapbox (Mapzen): locale option #57 2016-12-29 17:56:23 +02:00
Emux
88f3283878 Render themes improvements #41 2016-12-29 17:17:48 +02:00
Emux
80848f9d2d Mapbox (Mapzen) vector tiles improvements #57 2016-12-29 16:40:49 +02:00
boldtrn
f1f5726457 Mapbox (Mapzen) vector tiles (#279), #57, fixes #271 2016-12-29 14:43:38 +02:00
Emux
2ccf3e4c64 Map limit via bounding box, closes #277 2016-12-27 12:39:31 +02:00
Emux
c8cbf8e0ce Oneway arrows in themes, closes #275 2016-12-24 16:07:43 +02:00
Emux
6544cc1081 Update changelog 2016-12-22 16:11:34 +02:00
Emux
4c72831336 Update applications list 2016-12-22 16:11:24 +02:00
Emux
06ac5142f7 Render theme callback, closes #274 2016-12-20 21:55:53 +02:00
Emux
feae45f78b Update libGDX to 1.9.5 #270 2016-12-14 15:33:26 +02:00
Emux
61b8233b97 Circles (GL points) stroke #268 2016-12-14 13:01:11 +02:00
Emux
7acbea88cc Update Android support library 2016-12-14 09:48:04 +02:00
Emux
19109516ae Circles (GL points) anti-aliasing #268 2016-12-13 19:56:44 +02:00
Emux
c1a5ad7e74 Update Android build tools 2016-12-13 09:38:24 +02:00
Emux
1a93e4ae13 TextStyle improvements 2016-12-12 12:22:15 +02:00
Emux
1de6ca8fb7 Render styles improvements 2016-12-11 15:17:42 +02:00
Emux
02db7ca08d ExtrusionStyle: add StyleBuilder interface 2016-12-11 11:42:48 +02:00
Emux
e9bb7aaae4 Render buckets improvements 2016-12-09 20:36:48 +02:00
Emux
989e9c2ae8 Update readme 2016-12-09 20:00:05 +02:00
Emux
e8f41cd339 Update applications list 2016-12-09 19:43:23 +02:00
Emux
eabd90d14c Applications list: update an app's license 2016-12-09 10:48:56 +02:00
Emux
3e4aad4d51 LocationLayer: move lazy enable to application #171 2016-12-08 20:26:50 +02:00
Emux
b6dc72bbb6 Circle map style: use GL quads or GL points #122 2016-12-08 14:30:05 +02:00
Emux
4cd11462da SVG resources scaling, closes #214 2016-12-08 12:06:14 +02:00
Emux
6344542b10 SymbolStyle: add style builder #214 2016-12-07 20:16:11 +02:00
Emux
e0031ae8aa CircleStyle fix #122 2016-12-07 15:57:36 +02:00
Emux
229ea0b350 CircleStyle: add style builder #122 2016-12-07 15:12:50 +02:00
Emux
0a5d08a908 Update Gradle Android plugin 2016-12-07 09:40:11 +02:00
Emux
aed54c9a49 Update changelog 2016-12-06 21:38:49 +02:00
Emux
1a3bf4e4fe Render theme improvements #41 2016-12-06 21:16:38 +02:00
Emux
591ae03667 GL shader version, closes #265 2016-12-06 21:07:53 +02:00
Emux
3a191fb513 Circle map style #122 2016-12-06 21:07:53 +02:00
Andrey Novikov
2821d8ddb8 Circle map style rendering (#202) #122 2016-12-04 11:26:12 +02:00
Emux
71d7b71035 Map.getMapPosition at animation end option 2016-12-02 19:25:36 +02:00
Emux
85858911fa MapPosition animation sample with queue 2016-12-02 13:04:02 +02:00
Emux
0a92c84668 GDX double tap zoom, closes #263 2016-12-02 10:48:55 +02:00
Emux
c21d7b4390 Android example for render theme styles #93, closes #255 2016-12-01 21:08:12 +02:00
Emux
38a9c71bc2 MapPosition animation sample improvements #252 2016-12-01 19:59:43 +02:00
Mathieu De Brito
2573e458d5 Add sample showing MapPosition animations not merge (#252) 2016-12-01 19:57:13 +02:00
Emux
25a9891133 Samples reorganization #32 2016-11-28 21:10:07 +02:00
Andrey Novikov
8ee4e5fb8c OSMUtils: Treat amenity as area in heuristic (#262) 2016-11-28 20:14:33 +02:00
Emux
a38b054228 OSMUtils: include correct copyrights #35 2016-11-28 20:03:12 +02:00
Andrey Novikov
d9bf94da99 Fix zoom animation not executed sometimes (#261) 2016-11-28 15:42:44 +02:00
Longri
77653096f9 Add events for scale / rotate / tilt by user (#256) 2016-11-28 15:02:06 +02:00
Andrey Novikov
5f534656ea Improved gestures: use VTM Task for asynchronous calls (#260) #253 2016-11-28 14:41:32 +02:00
Emux
ba93445259 Improved gestures: parallel system and samples #253 2016-11-28 14:41:32 +02:00
Andrey Novikov
71f7c45b21 Improved gestures (#249) #253 2016-11-28 14:28:44 +02:00
Emux
ca5e34e1fb Render themes new SVG resources, closes #251 2016-11-27 17:06:55 +02:00
Emux
d937f3516c Samples: add map events in desktop marker example #32 2016-11-25 09:50:18 +02:00
Emux
a8909fca08 GDX: improve keyboard shortcuts 2016-11-24 16:20:30 +02:00
Emux
b39feae045 Samples cleanup 2016-11-24 10:37:27 +02:00
Emux
9f4ef47b95 Gradle: enhance clean tasks in vtm web apps 2016-11-24 10:19:35 +02:00
Emux
25e79bac55 Update Android build tools 2016-11-23 09:41:05 +02:00
Emux
311f4c7929 Samples: map events improvements #32 2016-11-22 21:07:28 +02:00
Emux
557e1858a7 Android: fix quick scale vs long press, fixes #250 2016-11-22 20:39:47 +02:00
Emux
16fa42d462 Marker examples: add (map) long press events #32 2016-11-22 20:37:05 +02:00
Emux
1133edb83d vtm-app: fix location layer 2016-11-22 12:55:52 +02:00
Izumi Kawashima
f6dbeba3d8 Check and clamp bearing range each time it's set (#248) 2016-11-21 20:01:34 +02:00
Emux
bf8f0745a6 Fix Travis build 2016-11-21 12:59:07 +02:00
Emux
829e45224f Animator easing: improvements and backwards API compatibility (#242) #246 2016-11-21 12:42:48 +02:00
Schedul Xor
acde5d565d Added easing functions which currently works with Animator (#242) 2016-11-21 12:38:01 +02:00
Emux
f0a652faf3 vtm-web modules: minor cleanup #51 2016-11-21 11:20:31 +02:00
Schedul Xor
41867344e2 Support TextureRegion to be used for MarkerSymbol (#245) 2016-11-21 10:49:04 +02:00
Izumi Kawashima
0c39ff8be0 Made {X},{Y},{Z} customizable in derived tile sources for tile URL (#244) 2016-11-21 10:25:43 +02:00
Emux
6f78f08a04 vtm-web: update documentation 2016-11-20 19:40:44 +02:00
Emux
3388e1401f Improve code / xml formatting #54 2016-11-20 19:26:38 +02:00
Izumi Kawashima
308497ffa6 Update vtm-web modules (#240) #51 2016-11-20 19:13:00 +02:00
Izumi Kawashima
bfa5a095f0 UrlTileSource: use StringBuilder instead of String concatenation (#241) 2016-11-20 19:03:57 +02:00
Emux
96be36edb8 Update badges 2016-11-19 17:28:31 +02:00
Emux
7c9c3732fb Osmarender theme: fix 'scrub' overlap without tessellation '#41 2016-11-16 21:08:01 +02:00
Emux
add62c9fe8 Location layer: lazy rendering start for performance #171 2016-11-16 14:18:14 +02:00
Emux
4aaa1ce620 AwtPaint: fix getColor 2016-11-16 10:57:13 +02:00
Emux
aa63b49e5a Render themes improvements #41 2016-11-16 10:04:19 +02:00
Emux
1f1d91202c Update Android support lib 2016-11-15 09:26:03 +02:00
Emux
51eae28926 MapDatabase: use TileClipper buffer based on dpi, #231 2016-11-13 17:19:13 +02:00
Emux
58b5f2741b Use baseline 160dpi in scaling, closes #236 2016-11-13 16:52:29 +02:00
Emux
d82faad435 Render themes improvements #41 2016-11-13 16:52:29 +02:00
Emux
fc8223bfc8 Tile grid enhance color #238 2016-11-13 16:52:22 +02:00
Emux
3584c4be1e Tile grid layer scaling, closes #238 2016-11-13 11:45:44 +02:00
Emux
001dbe8447 House numbers (nodes) mix with symbols, fixes #234 2016-11-12 16:19:29 +02:00
Emux
54feb7a25e MapDatabase: clear tags with each element read, #234, fixes #235 2016-11-12 16:17:39 +02:00
Emux
ea2a94f76b Update changelog 2016-11-10 21:58:35 +02:00
Emux
b6bfbc612a Render themes improvements #41 2016-11-10 21:25:17 +02:00
Emux
1d545fd804 Mapbox vector tiles: use tessellation in water #57 2016-11-10 15:09:31 +02:00
Emux
3acf77c102 Render themes improvements #41 2016-11-10 14:22:59 +02:00
Emux
6dfe2df2fb Update Travis 2016-11-09 13:00:12 +02:00
Mathieu De Brito
6cb40e1c15 Android samples: add fragment example (#233) 2016-11-09 13:00:02 +02:00
Emux
afd03809e8 Render theme styles sample improvements #93 2016-11-09 11:44:45 +02:00
Emux
efa3cb0231 Render theme styles sample #93 2016-11-08 12:16:02 +02:00
Emux
a709bd2623 MapDatabase: use TileClipper buffer as half the tile size, #231 2016-11-07 21:53:53 +02:00
Emux
439f2b20ff Fix house numbers (nodes) visibility (with new maps), fixes #168 2016-11-05 17:49:28 +02:00
Emux
877d217f31 Update dependencies 2016-11-05 13:53:05 +02:00
Emux
885264ad8c Gradle: declare compile time only dependencies with Java plugin #229 2016-11-04 22:06:32 +02:00
Emux
e224a7cf5b Samples: minor improvements #32 2016-11-02 14:06:36 +02:00
Emux
e10a223ea6 Mapsforge: multiple map files with zoom levels, #208 2016-11-02 13:54:31 +02:00
Emux
f85453e60c Render themes: use tessellation in sea #208 2016-11-02 10:40:25 +02:00
Emux
a6b3d7b0c2 Mapsforge: multiple map files, closes #208 2016-11-02 10:32:30 +02:00
Emux
dc15ba5f34 Update documentation 2016-11-02 10:02:34 +02:00
pedrop
1d7afaf8de ItemizedLayer: API enhancements for adding Collection of any MarkerInterface implementation (#211) 2016-10-31 20:29:22 +02:00
pedrop
422d81d665 PathLayer: API enhancements for adding Collection of any GeoPoint extension (#211) 2016-10-31 19:58:13 +02:00
Emux
4b55043dcc MercatorProjection.latitudeToY not work at > ±85.05113°, fixes #222 2016-10-31 15:13:31 +02:00
Emux
7885529fff Update changelog #108 2016-10-30 17:43:02 +02:00
Emux
2c610f5e0b PathLayer: draw line improvements by @Bezzu, fixes #108 2016-10-30 17:31:22 +02:00
Emux
64a586dde8 MapFileTileSource: zoom level improvements, closes #219 2016-10-30 16:14:54 +02:00
Emux
c1f65144df Mapbox tile source: use new Mapzen production url #57 2016-10-29 22:12:56 +03:00
Emux
ad2ee3f40e Mapzem .mvt theme: update with SVG and various improvements #57 2016-10-29 21:46:16 +03:00
Emux
01365686fa Fix render theme schema 'src' regular expression 2016-10-29 21:18:22 +03:00
Emux
dece13ddc9 Mapbox vector tiles improvements and example #57 2016-10-29 20:56:01 +03:00
Emux
05e9e0cdc8 Mapbox vector tiles by @hjanetzek #57 2016-10-29 18:53:52 +03:00
Emux
a9283dd408 Render theme improvements #41 2016-10-28 20:43:16 +03:00
Emux
53ca77d18a Update changelog 2016-10-28 17:39:11 +03:00
Andrey Novikov
97654f0670 Polygon label position (#204), #80
- Fix infinite recursion on invalid polygons
- Allow setting area-size for text styles
- Skip unnecessary calculations if label is outside of visible area
2016-10-28 17:36:10 +03:00
Emux
cbd0ac01df Polygon label position (minor improvements) (#204), #80 2016-10-28 17:35:50 +03:00
Andrey Novikov
ca841f5181 Polygon label position enhancements (#204), closes #80 2016-10-28 17:34:53 +03:00
Emux
a322768f8a 0.6.0 2016-10-28 12:26:13 +03:00
606 changed files with 13122 additions and 5449 deletions

View File

@@ -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"

View File

@@ -1,36 +1,37 @@
[![Maven Central](https://img.shields.io/maven-central/v/org.mapsforge/vtm.svg)](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.mapsforge%22)
[![Build Status](https://travis-ci.org/mapsforge/vtm.svg?branch=master)](https://travis-ci.org/mapsforge/vtm)
[![GitHub license](https://img.shields.io/badge/license-LGPL3-blue.svg)](COPYING.LESSER)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.mapsforge/vtm/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.mapsforge/vtm)
[![License: LGPL v3](https://img.shields.io/badge/License-LGPL%20v3-blue.svg)](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
![Screenshot Samples App Bremen 1](docs/images/screenshot-bremen-1.png)
![Screenthot Samples App Bremen 2](docs/images/screenshot-bremen-2.png)
### Android
![Android](docs/images/android.png)
### iOS
![iOS](docs/images/ios.png)
### Desktop
![Desktop](docs/images/desktop.png)
### Browser
![Browser](docs/images/browser.png)

View File

@@ -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) {

View File

@@ -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).

View File

@@ -1,19 +1,44 @@
# Changelog
## Version 0.6.X
### Version 0.7.0-rc1 (2017-02-16)
**Version 0.6.0-rc3 (2016-10-22)**
- 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 +60,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)

View File

@@ -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 [![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.mapsforge/vtm/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.mapsforge/vtm)
Current version is [![Maven Central](https://img.shields.io/maven-central/v/org.mapsforge/vtm.svg)](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
View 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

Binary file not shown.

After

Width:  |  Height:  |  Size: 717 KiB

BIN
docs/images/browser.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 791 KiB

BIN
docs/images/desktop.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 580 KiB

BIN
docs/images/ios.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 450 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 827 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

7
docs/web.md Normal file
View 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.

View File

@@ -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">

View File

@@ -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'

View File

@@ -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" />

View 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>

View File

@@ -3,10 +3,12 @@ apply plugin: 'com.android.application'
dependencies {
compile project(':vtm-android')
compile project(':vtm-extras')
compile project(':vtm-http')
compile project(':vtm-jeo')
compile project(':vtm-jts')
compile project(':vtm-themes')
compile 'com.noveogroup.android:android-logger:1.3.6'
compile 'com.android.support:support-v4:25.1.1'
}
android {

View 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>

View 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>

View File

@@ -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>

View 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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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));
}
}

View File

@@ -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);
}

View File

@@ -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);

View File

@@ -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

View File

@@ -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();
}
}

View File

@@ -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());
}
}
}

View File

@@ -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);
}
}

View File

@@ -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));
}
}

View File

@@ -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);
}
}

View File

@@ -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;
}
}));
}
}

View File

@@ -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;
}
}
}

View File

@@ -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;
}
}

View File

@@ -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));
}

View File

@@ -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;
}
}

View File

@@ -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);

View File

@@ -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);
}
}
}

View File

@@ -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;
}

View File

@@ -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();
}

View File

@@ -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);

View File

@@ -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));
}
}

View File

@@ -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();

View File

@@ -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;
}

View File

@@ -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 {

View File

@@ -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();
}
/**

View File

@@ -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 {

View File

@@ -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;

View File

@@ -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);
}
}

View File

@@ -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;
}
/**

View File

@@ -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 {

View File

@@ -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();
}

View File

@@ -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();

View File

@@ -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));
}
}

View File

@@ -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);
}
}

View File

@@ -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.fasterxml.jackson.core:jackson-core:2.8.4'
compile 'com.google.protobuf:protobuf-java:2.6.1'
compile 'com.vividsolutions:jts:1.13'
compile 'org.openstreetmap.osmosis:osmosis-osm-binary:0.44.1'
compile 'org.openstreetmap.osmosis:osmosis-osm-binary:0.45'
}
sourceSets {

View File

@@ -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);

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -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 {

View File

@@ -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

View File

@@ -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
}

View File

@@ -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

View File

@@ -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;

View File

@@ -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;

View File

@@ -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));
}
}

View File

@@ -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) {

View File

@@ -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 {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 675 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 692 B

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 118 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 73 KiB

View 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>

View File

@@ -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());

View 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());
}
}

View 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());
}
}

View 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());
}
}

View 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)));
}
}

View 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());
}
}

View File

@@ -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;
}
}
}

View 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());
}
}

View File

@@ -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'
}

View File

@@ -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() {
}
}
}

View File

@@ -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);
}
}

View File

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 40 KiB

Some files were not shown because too many files have changed in this diff Show More