182 Commits

Author SHA1 Message Date
Emux
e62e27cf22 0.16.0 2021-05-27 18:47:05 +03:00
Emux
76bf76a090 Update Applications.md 2021-05-27 15:46:06 +03:00
Emux
e906305910 Update changelog 2021-05-17 16:49:50 +03:00
Александр
08b94a0c42 Distant labels rendering (#844) 2021-05-17 16:46:36 +03:00
Emux
c508bde844 TileSource.OpenResult: allow null error messages (#837) 2021-05-12 14:45:20 +03:00
Emux
d4b7e34d17 Update Gradle (#835) 2021-05-05 14:28:17 +03:00
Emux
d5543bd7ef Map scale bar improvements (#828) 2021-04-13 13:52:28 +03:00
Emux
354bc16ead InputHandler: keyboard improvements (#827) 2021-04-13 12:36:54 +03:00
Emux
8889235690 Update Android Gradle plugin (#826) 2021-04-07 14:48:04 +03:00
Emux
9b43d7f498 JCenter deprecation (#825) 2021-04-07 14:02:12 +03:00
Emux
ef2d2dd197 ContentResolverResourceProvider: honor also absolute file references in theme resources (#823) 2021-03-31 15:04:26 +03:00
Emux
1245158ba3 SVG Salamander (#819) 2021-03-27 19:47:24 +02:00
Emux
ef5f7acbdf JCenter (#818) 2021-03-27 19:37:53 +02:00
Emux
e1c24ee8cf InputHandler: keyboard improvements (#817) 2021-03-24 18:10:28 +02:00
Emux
9f5ddd2381 Update docs 2021-03-17 13:09:01 +02:00
Emux
1fbc501bef Update docs 2021-03-16 19:41:43 +02:00
Emux
d7c69e12d6 Maven central (#813) 2021-03-16 18:34:31 +02:00
Emux
1fa86b5e07 GitHub Discussions 2021-03-16 17:26:09 +02:00
Emux
efed81bdeb Update ISSUE_TEMPLATE.md 2021-03-15 10:29:21 +02:00
Emux
a308eb48ac Update OkHttp (#811) 2021-03-14 15:58:53 +02:00
Emux
5926dd3e65 Render themes: add river labels (#810) 2021-03-04 15:37:39 +02:00
Emux
a11e620792 Render themes: improve lake labels (#809) 2021-03-04 14:41:33 +02:00
Emux
6850eff26c ContentResolverResourceProvider should handle document Uris correctly (#808) 2021-03-01 11:09:43 +02:00
Emux
ddf94ae2ca ZipXmlThemeResourceProvider: add method to just scan zip for xml themes (#807) 2021-02-22 14:06:03 +02:00
Emux
22ed9653ec AndroidBitmap: convert unsupported bitmap formats (#805) 2021-01-29 16:51:31 +02:00
Emux
3bb8ce00c5 Render themes: Android scoped storage, zip render theme, custom resource providers (#804) 2021-01-21 15:01:19 +02:00
Emux
b9cbd97c40 Nautical unit adapter with feet (#803) 2021-01-12 18:12:16 +02:00
Emux
6801b895e4 Mapsforge themes compatibility improvements #100 (#802) 2021-01-11 17:30:44 +02:00
Emux
c0d5f4a0ca 0.15.0 2021-01-01 18:59:48 +02:00
Emux
2859a18d72 Deploy improvements 2021-01-01 18:44:53 +02:00
Emux
869446ad13 JobQueue.clear: change log level 2020-12-31 14:06:54 +02:00
Emux
b2fd22885e Samples: reorder theme dispose 2020-12-28 14:12:01 +02:00
Meibes
7d6c623a80 Samples MapFragment: use theme dispose function (#800) 2020-12-28 13:43:56 +02:00
Emux
6bea801bf6 Samples: use theme dispose function 2020-12-28 12:12:14 +02:00
Emux
d446a3448b Samples: add theme.dispose 2020-12-28 11:56:32 +02:00
Emux
d006ba5361 VectorTileLayer: code improvements 2020-12-25 14:53:19 +02:00
Meibes
0eb4f3752f OSMUtils.isArea: reorder 'if' based on OSM stats (#799) 2020-12-24 10:33:12 +02:00
Emux
789c280fc2 OSMUtils.isArea improvements #798 2020-12-23 17:16:08 +02:00
Meibes
a881eec9b1 OSMUtils.isArea improvements (#798) 2020-12-23 13:31:41 +02:00
Meibes
1bc1d88464 Android Samples: add Fragment example (#796) 2020-12-22 11:40:34 +02:00
Emux
1c18221f05 ReadBuffer: fix docs 2020-12-13 13:26:21 +02:00
Emux
f4162acf04 Update Android build tools 2020-12-10 12:06:10 +02:00
Emux
1138978c22 Use --release=7 for compiling the non-android libraries on Java >= 9 (#795) 2020-12-03 13:30:31 +02:00
Emux
bd43baba20 TileLayer: move tileSource in parent class (#794) 2020-11-30 17:47:14 +02:00
Meibes
2e6da74af8 Color: fix parseColor javadoc (#793) 2020-11-28 12:20:09 +02:00
Meibes
f6561d2a2e OsmTileLayer: add constructor (#792) 2020-11-28 12:18:16 +02:00
Emux
45a42bb242 Samples improvements #785 2020-11-24 14:13:56 +02:00
Emux
3043173814 Symbol scale option (#790) 2020-11-15 17:20:52 +02:00
Emux
cde5d898c7 Update Integration.md 2020-11-11 10:57:48 +02:00
Emux
58f6215c0f Samples improvements #785 2020-10-21 17:57:49 +03:00
Emux
d7d6fa57ac Parameters: increase maximum buffer size for map files (Japan) (#789) 2020-10-19 13:39:22 +03:00
Emux
57bf615ab7 Update Gradle (#788) 2020-10-13 14:11:45 +03:00
Emux
9bf3161010 Update Android Gradle plugin 2020-10-08 15:18:35 +03:00
Emux
98a977ea72 Merge pull request #786 from mapsforge/xml
Render theme xml pull parser
2020-09-25 16:58:44 +03:00
Emux
661bc08bbf Render theme xml pull parser, fix #431 2020-09-25 16:57:52 +03:00
Emux
804c8c4603 Merge pull request #785 from mapsforge/storage
Android: scoped storage example
2020-09-24 14:18:41 +03:00
Emux
e103c38e3e Android: scoped storage example 2020-09-24 14:18:20 +03:00
Emux
e3b4ff502e Merge pull request #784 from mapsforge/mapsforge
Mapsforge: map stream support
2020-09-24 14:02:48 +03:00
Emux
6116ebb348 Mapsforge: map stream support 2020-09-24 14:00:49 +03:00
Emux
5c3a728d05 Merge pull request #783 from mapsforge/content
Render theme from Android content providers
2020-09-24 13:54:14 +03:00
Emux
2070145880 Render theme from Android content providers 2020-09-24 13:52:13 +03:00
Emux
e9a670f274 Update Android samples 2020-09-17 10:46:17 +03:00
Emux
e5c87ba06e Merge pull request #782 from mapsforge/android
Update Android
2020-09-09 17:57:22 +03:00
Emux
fa992b93f5 Update Android 2020-09-09 17:47:42 +03:00
Emux
bf67074cf3 Merge pull request #781 from mapsforge/cache
Android samples: use OkHttp cache
2020-09-02 17:09:48 +03:00
Emux
074320d6d2 Android samples: use OkHttp cache 2020-09-02 17:08:39 +03:00
Emux
6616c22a32 Update changelog 2020-08-30 20:24:41 +03:00
Izumi Kawashima
1ddba0fe8f Use org.gretty instead of org.akhikhl.gretty maven repository (#780) 2020-08-30 18:09:28 +03:00
Emux
0a374bc635 0.14.0 2020-08-25 18:39:22 +03:00
marq24
8602b5780a Fix issue with drawing elements with false style (#778)
When the style of the drawable has changed the level needs to adjusted before draw(...) is called - in any other case then you have the risk, that the false style will be applied to the drawable [since the false bucket (with wrong style) will be returned when calling t.buckets.get{.*}Bucket(level)]
2020-08-03 11:08:43 +03:00
Emux
ab32f25a7c Update Android Gradle plugin 2020-07-15 11:30:28 +03:00
Emux
ebfb7bd85d Merge pull request #776 from mapsforge/buffer
ReadBuffer.readFromFile: handle byte allocation
2020-07-14 15:04:45 +03:00
Emux
ed739c59f5 ReadBuffer.readFromFile: handle byte allocation 2020-07-14 15:00:49 +03:00
Emux
238a5f8f14 PointDrawable: correct constructor parameters, fix #775 2020-07-14 10:08:11 +03:00
Emux
126c47dfd7 Update samples 2020-07-03 14:22:35 +03:00
Emux
e8389e6887 LineStyle: rename constructor parameter stroke to color 2020-06-23 13:00:33 +03:00
Emux
81f526dc56 Merge pull request #773 from mapsforge/density
Android: use DisplayMetrics density
2020-06-22 15:11:33 +03:00
Emux
23ae072ed6 Android: use DisplayMetrics density 2020-06-22 14:02:06 +03:00
Emux
20f4fad7f3 Revert "Update Android build tools"
This reverts commit 1805e861
2020-06-11 11:21:38 +03:00
Emux
1805e86173 Update Android build tools 2020-06-11 11:15:00 +03:00
Emux
8acda4fbf5 Update Gradle 2020-05-29 14:35:14 +03:00
Emux
65d8bd9675 Merge pull request #771 from mapsforge/item
More mutable itemized layer
2020-05-01 10:25:13 +03:00
Emux
34ea0af92d Update changelog 2020-05-01 10:17:27 +03:00
Emux
2d64186a1a More mutable itemized layer 2020-04-28 14:15:05 +03:00
Emux
4604f07042 ItemizedLayer: fix populate in addItem 2020-04-26 16:00:29 +03:00
Emux
52f47bd797 Update docs 2020-04-24 14:45:21 +03:00
Emux
50f885b5f8 Update Android Gradle plugin 2020-04-21 11:26:58 +03:00
Emux
742405a193 Update documentation 2020-04-20 18:47:10 +03:00
Jan Lippert
18ee0a393f Update vtm-jeo module (#770) 2020-04-20 18:39:29 +03:00
Emux
29634d29b5 Update changelog 2020-04-16 18:52:12 +03:00
Andrey Novikov
635d5bacdd Render themes: symbol styles (#769) 2020-04-16 18:52:12 +03:00
Emux
1156976ea5 Disable vtm-jeo module, fix #768 2020-04-13 10:35:07 +03:00
Emux
964736d60f Update Android Gradle plugin 2020-04-01 14:52:07 +03:00
Emux
2de19ef080 Update documentation 2020-03-18 09:57:02 +02:00
Emux
0faf3eca66 InternalItem: make public 2020-03-17 12:18:46 +02:00
Emux
c239d8c1b7 Samples: set user agent for OpenStreetMap provider
https://operations.osmfoundation.org/policies/tiles/
2020-03-17 12:03:03 +02:00
Emux
c28aec5f59 MarkerRenderer: sort option 2020-03-17 11:34:53 +02:00
Emux
e0efff50a8 Update Android Gradle plugin 2020-03-02 15:51:02 +02:00
Emux
8364ff83d1 Update Mapsforge providers 2020-02-25 11:33:30 +02:00
Emux
5d7a4e0954 Update Gradle 2020-02-25 11:03:13 +02:00
Emux
2785d22a3a Update Mapsforge-Maps.md 2020-02-22 16:40:39 +02:00
Emux
2768f84a5f Update ISSUE_TEMPLATE.md 2020-02-22 14:28:34 +02:00
Emux
1ede5c5456 Update CONTRIBUTING.md 2020-02-22 14:26:10 +02:00
Emux
5778d0e74a Update Mapsforge providers 2020-02-21 14:27:41 +02:00
Emux
6672c57f05 Update Mapsforge server 2020-02-21 14:16:56 +02:00
Emux
c1fbdb42be Merge pull request #766 from zimmi/allow-clearing-event-listeners
Add EventDispatcher::clear
2020-02-10 17:50:03 +02:00
thomas
841b3af042 Add EventDispatcher::clear 2020-02-09 13:51:36 +01:00
Emux
bdd08e3486 Update Android build tools 2020-01-30 10:49:20 +02:00
Emux
68679c6dc0 Merge pull request #765 from Meibes/improvement/android/examples
android-examples: demonstrate usage of VectorTileLayer.getTileSource()
2020-01-30 10:32:59 +02:00
Stephan Brandt
9f280a41c0 ViewController: allow rotation around map view center, fix drift (#764) 2020-01-30 10:03:44 +02:00
Meibes
65c8d5199f small improvements to examples, demonstrating the new VectorTileLayer.getTileSource()-method 2020-01-28 19:42:42 +01:00
Emux
2b8326f465 Update changelog 2020-01-26 18:16:19 +02:00
Emux
488b350671 Merge pull request #763 from Meibes/feature/MapScaleBarLayer/onDetach
MapScaleBarLayer: add onDetach-method to free resources automatically
2020-01-26 18:12:58 +02:00
Emux
5285b0c272 Merge pull request #762 from Meibes/getTileSource
VectorTileLayer.getTileSource
2020-01-26 17:55:40 +02:00
Meibes
ebe98c8990 add onDetach-method to MapScaleBarLayer to free resources automatically
removed mapScaleBar.destroy() methods from onDestroy-Activity methods
changed global mapScaleBar-variables to local
2020-01-26 16:39:44 +01:00
Meibes
c30095c59d add getter for mTileSource in VectorTileLayer 2020-01-26 15:56:08 +01:00
Emux
f449a0a6fb Update Applications.md 2020-01-20 20:13:27 +02:00
Emux
74dfa07c81 Update Applications.md 2020-01-14 10:34:40 +02:00
Emux
bf6b325ce8 0.13.0 2020-01-12 15:31:31 +02:00
Emux
b43dfc53e4 Gradle: declare UTF-8 encoding for Java compile 2020-01-02 15:06:47 +02:00
Emux
883ed23272 Merge pull request #759 from mapsforge/themes
Render themes: avoid patterns and textures because of old GPU issues
2019-12-25 13:58:17 +02:00
Emux
0a0c2b3ce0 Render themes: avoid patterns and textures because of old GPU issues 2019-12-25 13:36:42 +02:00
Emux
c783255b97 Mapsforge: reduce points on-the-fly while reading from map files (except lines) #757 2019-12-17 17:54:27 +02:00
Emux
c689ad9e67 Merge pull request #758 from mapsforge/cap
Fix stroke cap line ending
2019-12-15 15:40:48 +02:00
Emux
0fabe4c738 Update changelog 2019-12-15 15:39:49 +02:00
Emux
d4a95dad19 Fix stroke cap line ending 2019-12-15 15:30:02 +02:00
Emux
4405b6235a AwtPaint: use round as default cap / join, like Mapsforge #92 2019-12-15 15:14:34 +02:00
Emux
766b0d9914 Mapsforge: reduce points on-the-fly while reading from map files (improvements) #757 2019-12-14 15:29:26 +02:00
Emux
412cacd1c2 Merge pull request #757 from mapsforge/mapsforge
Mapsforge: reduce points on-the-fly while reading from map files
2019-12-12 12:55:49 +02:00
Emux
299592d352 Update changelog 2019-12-12 12:53:30 +02:00
Emux
d512731d06 Mapsforge: reduce points on-the-fly while reading from map files 2019-12-12 12:26:19 +02:00
Emux
b2a8d3040a Render themes: area outlines as separate lines #121 2019-12-11 15:00:12 +02:00
Emux
892ea92580 Render themes: revert tessellation in water areas except sea #224 2019-12-11 12:37:03 +02:00
Emux
f7acfd9017 Samples improvements 2019-12-10 13:26:31 +02:00
Emux
701ac43746 Update Mapsforge-Maps.md 2019-12-09 14:58:18 +02:00
Emux
b926310296 Update Android Gradle plugin (#755) 2019-12-07 16:46:06 +02:00
Carlos Alberto Martínez Gadea
49d1e7bafc ItemizedLayer: Added a check that prevents Gestures from being processed if the Layer is not enabled (#754) 2019-12-04 11:18:08 +02:00
Emux
6f697ed6f8 Update changelog 2019-12-02 11:23:39 +02:00
Justus Schmidt
cdcae29ae1 Mapsforge: Move tileprojection to convert E6 int directly to tile coordinates (#752) 2019-12-02 11:10:01 +02:00
Emux
a13c4a3793 Merge pull request #753 from mapsforge/bitmap
AndroidGraphics: drawable to bitmap for Android >= 9
2019-11-30 15:43:19 +02:00
Emux
031a3bfa00 Android samples: simplify bitmap reading 2019-11-30 15:24:27 +02:00
Emux
7122e1fbc5 AndroidGraphics: drawable to bitmap for Android >= 9 2019-11-30 15:17:14 +02:00
Emux
6ed00d9a94 Style.Builder: make strokeColor public 2019-11-20 20:23:26 +02:00
Emux
327d6f1466 Animator: smooth scaling 2019-11-12 17:54:27 +02:00
Emux
17a135813b Update Android Gradle plugin 2019-11-08 10:02:55 +02:00
Emux
0dd82cb68f MapScaleBar: fix scaling 2019-11-05 15:03:18 +02:00
Emux
ae04fa83f6 MapScaleBar: minor code improvements 2019-11-04 18:26:34 +02:00
Emux
4bfcdadb76 MapScaleBar: minor optimization 2019-11-04 13:41:05 +02:00
Emux
fa5a72f20d MercatorProjection: minor code improvements 2019-11-04 13:39:45 +02:00
Emux
d81eb3d706 LocationRenderer: keep the position for which the overlay is compiled 2019-10-29 10:00:40 +02:00
Emux
97332e3e73 Merge pull request #750 from mapsforge/location
Location texture renderer: rewrite and optimize
2019-10-25 11:50:25 +03:00
Emux
e4a4857eb8 Update changelog 2019-10-25 11:50:03 +03:00
Emux
80018de754 Location texture renderer: rewrite and optimize 2019-10-25 11:43:51 +03:00
Emux
01bb7ca074 Merge pull request #749 from mapsforge/opengl
Android: OpenGL ES 2.0 default for performance / stability
2019-10-25 11:17:43 +03:00
Emux
a8f5eee505 Update changelog 2019-10-25 11:16:37 +03:00
Emux
644cf9dcb6 Android: OpenGL ES 2.0 default for performance / stability 2019-10-25 11:03:33 +03:00
Emux
cb0109ba42 Samples: use Mapsforge release version 2019-10-23 19:04:42 +03:00
Emux
2fa5afec11 Layers: make updateLayers public 2019-10-23 18:59:45 +03:00
Emux
69ea1e414a Location shader improvements 2019-10-22 18:21:43 +03:00
Emux
4866abe38e Merge pull request #748 from mapsforge/location
Location renderers: allow fixed center position
2019-10-18 14:12:33 +03:00
Emux
4c10d5848b Location renderers: allow fixed center position 2019-10-17 15:00:53 +03:00
Emux
faed3d05a5 VectorLayer: hide non usable add(Geometry, Style) method 2019-10-17 11:10:26 +03:00
Emux
88a9a9ee7f Polygon labels: use centroid position if available #734 2019-10-04 18:24:14 +03:00
Emux
3915e3343d Merge pull request #745 from Gustl22/s3db_profile
S3DB: shape profiles as constants
2019-10-04 10:10:36 +03:00
Gustl22
b22c023f1a S3DB: shape profiles as constants 2019-10-03 16:48:55 +02:00
Emux
5de7c9ec38 Update Android Gradle plugin 2019-10-03 09:39:10 +03:00
Gustl22
14c485914c S3DB: roof shape profiles (#744) 2019-10-03 09:32:57 +03:00
Emux
c20922b5f5 Tile decoders refactoring 2019-10-01 18:48:10 +03:00
Emux
1294ff9fea Symbols on lines doc improvements #743 2019-10-01 09:41:58 +03:00
Emux
992d9c8e66 Samples improvements 2019-09-30 20:03:15 +03:00
Emux
948449b3ec Fix Android samples on old Android 2019-09-29 15:09:46 +03:00
Emux
0c1c06c1bb Allow threaded system initialization 2019-09-28 22:36:17 +03:00
Emux
7ad3f4a0b1 Merge pull request #743 from mapsforge/symbol
Render themes - symbols on lines: add billboard, rotate options
2019-09-28 19:45:05 +03:00
Emux
c5836adc17 Update changelog 2019-09-28 19:44:29 +03:00
Emux
107a429517 Render themes: use symbols on lines for oneways 2019-09-28 19:38:54 +03:00
Emux
2cb0a80c47 LineStyle, SymbolStyle: use scale on repeat values 2019-09-28 19:38:22 +03:00
Emux
db9f83120a Render themes - symbols on lines: add billboard, rotate options 2019-09-28 18:50:20 +03:00
Emux
5facdb9888 XmlThemeBuilder: disable mipmap for sharper rendering 2019-09-28 18:29:47 +03:00
Emux
3f3caa1912 Update changelog 2019-09-23 19:39:33 +03:00
Emux
03b9f224b2 Render themes: improve nature park & reserve rendering 2019-09-23 19:17:52 +03:00
Emux
c013465d49 Render themes: improve nature reserve rendering 2019-09-23 18:39:52 +03:00
Emux
c91833519e Update dependencies 2019-09-18 21:11:15 +03:00
204 changed files with 6177 additions and 2277 deletions

View File

@@ -4,8 +4,8 @@ jdk:
- openjdk8 - openjdk8
env: env:
global: global:
- ANDROID=29 - ANDROID=30
- ANDROID_BUILD_TOOLS=29.0.2 - ANDROID_BUILD_TOOLS=30.0.3
- GRADLE_OPTS="-Xmx2048m" - GRADLE_OPTS="-Xmx2048m"
- secure: sW674wuFZOuoX7jHQHDbX3j8NxL8JxR07cyq+CrrqJ537dU9lxWQmMBRUpOb+p/q7sQ74PUtiKJkmFgKCSJSAKY+nr6GJ8P/q6u5TUKbmUWODSn8znehX2zualfvFwpF4PILok/wUzXBQE62jn4lUua7cMdsHRMNHbLmKqBoVL0meObDDjsaJ/RCbOPuruy3FmgvXPp0+Y4zl1GsklDSyjFzg4LBzjAk9Ryvh1O4zvJBkkyfCgurLKCnOKIPy3v5fPMS9oDfO1aarAVGoZZe416pvTW4hb8cdB6kn9XWYDob4NDFX/sP5k7XIhd/NAIn9LrKFg0sLtATaKLX+BcasF1CgDR/u6+SEeQd5QaRF7Go2Nq5Ltuu4OIFONI2qhEeVDDK6Otf2WSWj9KPno2GHuumBfbg4ypWoJgmZrMXk8JeVV/OP/0jIQz3p/7yfF21X1XBEqYaVHPAMKdEYYkCSa46KfACyOt6LfnkuCHtoTOpFo7sq0omIA2HOtpIx1u3vMBUyAbQqT6cokkKB1b6gNTFwhHc+8ybfLFPljJB8cWshI+V/b06S6fekRmvTNxvDykWNsdlkENBYqc9hMfjcT4hO4K+76SWN62mimQYODvFyfTVMC7WkQ3k/XEnmqUPV5XkbaILbS1d/tA57N148FiJ5/QXtI6Y94imubYyVqU= - secure: sW674wuFZOuoX7jHQHDbX3j8NxL8JxR07cyq+CrrqJ537dU9lxWQmMBRUpOb+p/q7sQ74PUtiKJkmFgKCSJSAKY+nr6GJ8P/q6u5TUKbmUWODSn8znehX2zualfvFwpF4PILok/wUzXBQE62jn4lUua7cMdsHRMNHbLmKqBoVL0meObDDjsaJ/RCbOPuruy3FmgvXPp0+Y4zl1GsklDSyjFzg4LBzjAk9Ryvh1O4zvJBkkyfCgurLKCnOKIPy3v5fPMS9oDfO1aarAVGoZZe416pvTW4hb8cdB6kn9XWYDob4NDFX/sP5k7XIhd/NAIn9LrKFg0sLtATaKLX+BcasF1CgDR/u6+SEeQd5QaRF7Go2Nq5Ltuu4OIFONI2qhEeVDDK6Otf2WSWj9KPno2GHuumBfbg4ypWoJgmZrMXk8JeVV/OP/0jIQz3p/7yfF21X1XBEqYaVHPAMKdEYYkCSa46KfACyOt6LfnkuCHtoTOpFo7sq0omIA2HOtpIx1u3vMBUyAbQqT6cokkKB1b6gNTFwhHc+8ybfLFPljJB8cWshI+V/b06S6fekRmvTNxvDykWNsdlkENBYqc9hMfjcT4hO4K+76SWN62mimQYODvFyfTVMC7WkQ3k/XEnmqUPV5XkbaILbS1d/tA57N148FiJ5/QXtI6Y94imubYyVqU=
- secure: AdKSZKA4gMuKXI4X4dQNJqcMv5OmPIHdN8fpy55Y9yoOQPQHZE3Zwc4QDWBh20q298jyEC854tVTPTysdZ7h+2s2FhsprYv1Bt/QNzKIrLpeIMj2quuVGMbdPuk08y55gost94KwVLJv0sIDpRlB/PEQkA7Mg/UDsT9zR8E1Ms5x+ul2C8e1ag0zzNl1wVnT5jY8WCp74uA/XXCcJl/80qT1stUERazCKwbKNo007hi7rdm4HA7YGevORq8e2r67je+WIBZUAwrHT0Zjuo4ibwUii4LdwvjuN3w0Z6e9Wf4x5bBqGgnih0T31uom2yPjNx+U/c2AWI+Nxfy/SEF2U+9bjBEZ3ZhI7F1B9ofXo2mhvvsVDiUrymMBbG2V64C9kAzeUh7xIBTqIrbdtpAEBV9FlLAtF2swVTwtCgZgcVTOt3RKXCi3X3nk3cuH7PAorFa/QGfT4xxVu2011FVAt2Rm7SD0ZWztZTSTz/4Nt/egtGBOJfrCc7oLEygLzDmLqsqCwCROITVQjWLjrtqDyLteaNiSXeNIQMKun3izApbXnHmXB+FV3R3EZocboqk3v5bmPTahnG6Ghc2zknWyyxSx+O9qIfOpHUL8JMJiT82lUQUeibtCn7DCE8wVQ/gYC5i+a+KO/d3NemSzIFlZ8aoUiEPYq18dYlsDXeLXwF0= - secure: AdKSZKA4gMuKXI4X4dQNJqcMv5OmPIHdN8fpy55Y9yoOQPQHZE3Zwc4QDWBh20q298jyEC854tVTPTysdZ7h+2s2FhsprYv1Bt/QNzKIrLpeIMj2quuVGMbdPuk08y55gost94KwVLJv0sIDpRlB/PEQkA7Mg/UDsT9zR8E1Ms5x+ul2C8e1ag0zzNl1wVnT5jY8WCp74uA/XXCcJl/80qT1stUERazCKwbKNo007hi7rdm4HA7YGevORq8e2r67je+WIBZUAwrHT0Zjuo4ibwUii4LdwvjuN3w0Z6e9Wf4x5bBqGgnih0T31uom2yPjNx+U/c2AWI+Nxfy/SEF2U+9bjBEZ3ZhI7F1B9ofXo2mhvvsVDiUrymMBbG2V64C9kAzeUh7xIBTqIrbdtpAEBV9FlLAtF2swVTwtCgZgcVTOt3RKXCi3X3nk3cuH7PAorFa/QGfT4xxVu2011FVAt2Rm7SD0ZWztZTSTz/4Nt/egtGBOJfrCc7oLEygLzDmLqsqCwCROITVQjWLjrtqDyLteaNiSXeNIQMKun3izApbXnHmXB+FV3R3EZocboqk3v5bmPTahnG6Ghc2zknWyyxSx+O9qIfOpHUL8JMJiT82lUQUeibtCn7DCE8wVQ/gYC5i+a+KO/d3NemSzIFlZ8aoUiEPYq18dYlsDXeLXwF0=

View File

@@ -12,7 +12,7 @@ VTM (Vector Tile Map) was developed within the [OpenScienceMap](https://github.c
See the **[integration guide](docs/Integration.md)** and [changelog](docs/Changelog.md). And read through [how to contribute](docs/CONTRIBUTING.md) guidelines. See the **[integration guide](docs/Integration.md)** and [changelog](docs/Changelog.md). And read through [how to contribute](docs/CONTRIBUTING.md) guidelines.
If you have any questions or problems, don't hesitate to ask our public [forum](https://groups.google.com/group/mapsforge-dev) for help. If you have any questions or problems, don't hesitate to ask the Discussions for help.
## Features ## Features
- Java map library - Java map library

View File

@@ -1,10 +1,10 @@
buildscript { buildscript {
repositories { repositories {
google() google()
jcenter() mavenCentral()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.5.0' classpath 'com.android.tools.build:gradle:4.1.3'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
} }
} }
@@ -14,10 +14,10 @@ allprojects {
version = 'master-SNAPSHOT' version = 'master-SNAPSHOT'
ext.isReleaseVersion = !version.endsWith("SNAPSHOT") ext.isReleaseVersion = !version.endsWith("SNAPSHOT")
ext.androidBuildVersionTools = "29.0.2" ext.androidBuildVersionTools = "30.0.3"
ext.gdxVersion = "1.9.10" ext.gdxVersion = "1.9.10"
ext.gwtVersion = "2.8.2" ext.gwtVersion = "2.8.2"
ext.slf4jVersion = "1.7.25" ext.slf4jVersion = "1.7.28"
if (JavaVersion.current().isJava8Compatible()) { if (JavaVersion.current().isJava8Compatible()) {
tasks.withType(Javadoc) { tasks.withType(Javadoc) {
@@ -28,12 +28,12 @@ allprojects {
} }
} }
static def androidCompileSdk() { return 29 } static def androidCompileSdk() { return 30 }
// 14 for Support Library, 16 for sqlite-android // 14 for Support Library, 16 for sqlite-android
static def androidMinSdk() { return 16 } static def androidMinSdk() { return 16 }
static def androidTargetSdk() { return 29 } static def androidTargetSdk() { return 30 }
static def versionCode() { return 1 } static def versionCode() { return 1 }
@@ -42,14 +42,19 @@ def versionName() { return version }
subprojects { subprojects {
repositories { repositories {
google() google()
maven { url 'https://repo.boundlessgeo.com/main/' } mavenCentral()
jcenter()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url 'https://jitpack.io' } maven { url 'https://jitpack.io' }
maven { url "https://plugins.gradle.org/m2/" }
} }
tasks.withType(JavaCompile) { tasks.withType(JavaCompile) {
sourceCompatibility = JavaVersion.VERSION_1_7 sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7 targetCompatibility = JavaVersion.VERSION_1_7
options.encoding = 'UTF-8'
if (JavaVersion.current().isJava9Compatible()) {
if (!project.properties.containsKey('android')) {
options.compilerArgs.addAll(['--release', '7'])
}
}
} }
} }

View File

@@ -9,6 +9,7 @@ if (project.hasProperty("android")) {
task javadoc(type: Javadoc) { task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
classpath += project.android.libraryVariants.toList().first().javaCompileProvider.get().classpath
} }
} else { } else {
task sourcesJar(type: Jar) { task sourcesJar(type: Jar) {

View File

@@ -7,8 +7,9 @@
| [Cruiser](http://wiki.openstreetmap.org/wiki/Cruiser) | Map and navigation application | Proprietary/Free | Android, Desktop | Closed | | [Cruiser](http://wiki.openstreetmap.org/wiki/Cruiser) | Map and navigation application | Proprietary/Free | Android, Desktop | Closed |
| [GCDroid](https://play.google.com/store/apps/details?id=com.gcdroid) | Geocaching App | Proprietary/Free and Commercial | Android | Closed | | [GCDroid](https://play.google.com/store/apps/details?id=com.gcdroid) | Geocaching App | Proprietary/Free and Commercial | Android | Closed |
| [GPSLogger II](https://play.google.com/store/apps/details?id=com.emacberry.gpslogger) | Map and navigation, Fitness & Cycling application | Proprietary/Free | Android | Closed | | [GPSLogger II](https://play.google.com/store/apps/details?id=com.emacberry.gpslogger) | Map and navigation, Fitness & Cycling application | Proprietary/Free | Android | Closed |
| [HabanaTrans](https://play.google.com/store/apps/details?id=cu.pabloapk.habanatrans&hl=es_419) | Public transport, map offline, gps, routing | Proprietary/Free | Android | Closed |
| [Hunt Cyprus](https://play.google.com/store/apps/developer?id=Talent+S.A.) | Map and navigation application for hunters | Proprietary/Free and Commercial | Android | Closed | | [Hunt Cyprus](https://play.google.com/store/apps/developer?id=Talent+S.A.) | Map and navigation application for hunters | Proprietary/Free and Commercial | Android | Closed |
| [Kurviger](https://kurviger.de/en) | Route planner specialized on motorcyclists | Proprietary/Free and Commercial | Android | Closed | | [Kurviger](https://kurviger.de/en) | Route planner specialized on motorcyclists | Proprietary/Free (in-app purchases) | Android | Closed |
| [MapTrek](http://maptrek.mobi) | Application for outdoor activities | GPL3/Free and Commercial | Android | Open | | [MapTrek](http://maptrek.mobi) | Application for outdoor activities | GPL3/Free and Commercial | Android | Open |
| [MyRunningApp](https://play.google.com/store/apps/details?id=it.nimarsolutions.rungpstracker) | Fitness app | Proprietary/Free | Android | Closed | | [MyRunningApp](https://play.google.com/store/apps/details?id=it.nimarsolutions.rungpstracker) | Fitness app | Proprietary/Free | Android | Closed |
| [MyTourbook](http://mytourbook.sourceforge.net/mytourbook/) | Visualize and analyze tours | GPL2/Free | Desktop | Open | | [MyTourbook](http://mytourbook.sourceforge.net/mytourbook/) | Visualize and analyze tours | GPL2/Free | Desktop | Open |
@@ -18,6 +19,5 @@
| [topoGuide](http://www.topoguide.gr/index-en.php) | Digital guides for the outdoor | Proprietary/Free and Commercial | Android | Closed | | [topoGuide](http://www.topoguide.gr/index-en.php) | Digital guides for the outdoor | Proprietary/Free and Commercial | Android | Closed |
| [Ubitrek](https://play.google.com/store/apps/details?id=ubicarta.ubitrek) | Hiking with IGN maps | Proprietary/Free | Android | Closed | | [Ubitrek](https://play.google.com/store/apps/details?id=ubicarta.ubitrek) | Hiking with IGN maps | Proprietary/Free | Android | Closed |
| [VTM with Eclipse RCP](https://github.com/wolfgang-ch/vtm-with-rcp) | VTM with an Eclipse RCP application | GPL3/Free | Desktop | Open | | [VTM with Eclipse RCP](https://github.com/wolfgang-ch/vtm-with-rcp) | VTM with an Eclipse RCP application | GPL3/Free | Desktop | Open |
| [Walkaholic](https://play.google.com/store/apps/details?id=com.walkaholic.hikeapp) | Hiking app with official routes and online/offline maps | Proprietary/Free (in-app purchases) | Android | Closed |
| [XCTrack](http://xctrack.org/) | Flight computer for paraglider pilots | Proprietary/Free | Android | Closed | | [XCTrack](http://xctrack.org/) | Flight computer for paraglider pilots | Proprietary/Free | Android | Closed |
You know an application that is missing here? Please inform us by sending a message via our public [forum](https://groups.google.com/group/mapsforge-dev).

View File

@@ -2,9 +2,7 @@
As an open source project, we welcome new contributors and appreciate your help. As an open source project, we welcome new contributors and appreciate your help.
Before you start working on an unresolved issue or try to implement a new feature, please contact us via our public [forum](https://groups.google.com/group/mapsforge-dev). Before you start working on an unresolved issue or try to implement a new feature, please contact us via the Discussions. We will then discuss the best way to realize your proposal and figure out how we can help you to get started quickly.
You may also create a new issue on [Github](https://github.com/mapsforge/vtm/issues) or comment on an existing one to describe your ideas. We will then discuss the best way to realize your proposal and figure out how we can help you to get started quickly.
If you are only requesting a small change in the code, you may attach a patch file to the corresponding issue, but it is best to create a pull request on Github. Make sure that your patch is derived from the latest version in our **master** repository, otherwise we might be unable to apply it. Important is to keep pull requests simple with one feature in each. Please follow our code and style conventions. If you are only requesting a small change in the code, you may attach a patch file to the corresponding issue, but it is best to create a pull request on Github. Make sure that your patch is derived from the latest version in our **master** repository, otherwise we might be unable to apply it. Important is to keep pull requests simple with one feature in each. Please follow our code and style conventions.

View File

@@ -1,5 +1,57 @@
# Changelog # Changelog
## New since 0.16.0
- Many other minor improvements and bug fixes
- [Solved issues](https://github.com/mapsforge/vtm/issues?q=is%3Aclosed+milestone%3A0.17.0)
## Version 0.16.0 (2021-05-27)
- Android: scoped storage map / theme example [#804](https://github.com/mapsforge/vtm/pull/804)
- Render theme from zip archive [#804](https://github.com/mapsforge/vtm/pull/804)
- Render themes: custom resource providers [#804](https://github.com/mapsforge/vtm/pull/804)
- Nautical unit adapter with feet [#803](https://github.com/mapsforge/vtm/pull/803)
- Distant labels rendering option [#844](https://github.com/mapsforge/vtm/pull/844)
- `Parameters.DISTANT_LABELS`
- Many other minor improvements and bug fixes
- [Solved issues](https://github.com/mapsforge/vtm/issues?q=is%3Aclosed+milestone%3A0.16.0)
## Version 0.15.0 (2021-01-01)
- Android: scoped storage map example [#785](https://github.com/mapsforge/vtm/pull/785)
- Mapsforge: map stream support [#784](https://github.com/mapsforge/vtm/pull/784)
- Render theme from Android content providers [#783](https://github.com/mapsforge/vtm/pull/783)
- Render theme xml pull parser [#786](https://github.com/mapsforge/vtm/pull/786)
- Symbol scale option [#790](https://github.com/mapsforge/vtm/pull/790)
- `Parameters.SYMBOL_SCALING`
- Many other minor improvements and bug fixes
- [Solved issues](https://github.com/mapsforge/vtm/issues?q=is%3Aclosed+milestone%3A0.15.0)
## Version 0.14.0 (2020-08-25)
- Render themes: symbol styles [#769](https://github.com/mapsforge/vtm/pull/769)
- More mutable itemized layer [#771](https://github.com/mapsforge/vtm/pull/771)
- Marker renderer sort option
- `Parameters.MARKER_SORT`
- Update vtm-jeo module [#770](https://github.com/mapsforge/vtm/pull/770)
- Many other minor improvements and bug fixes
- [Solved issues](https://github.com/mapsforge/vtm/issues?q=is%3Aclosed+milestone%3A0.14.0)
## Version 0.13.0 (2020-01-12)
- Render themes: symbols on lines with billboard / rotation [#743](https://github.com/mapsforge/vtm/pull/743)
- Location texture renderer: rewrite and optimize [#750](https://github.com/mapsforge/vtm/pull/750)
- Fix stroke cap line ending [#758](https://github.com/mapsforge/vtm/pull/758)
- Mapsforge: fix ways precision loss [#752](https://github.com/mapsforge/vtm/pull/752)
- Mapsforge: additional simplification [#757](https://github.com/mapsforge/vtm/pull/757)
- `Parameters.SIMPLIFICATION_TOLERANCE`
- Android: OpenGL ES 2.0 default for performance / stability [#749](https://github.com/mapsforge/vtm/pull/749)
- `MapView.OPENGL_VERSION`
- Android: threaded system initialization
- `Parameters.THREADED_INIT`
- Many other minor improvements and bug fixes
- [Solved issues](https://github.com/mapsforge/vtm/issues?q=is%3Aclosed+milestone%3A0.13.0)
## Version 0.12.0 (2019-09-17) ## Version 0.12.0 (2019-09-17)
- MBTiles vector tile source (Android) [#740](https://github.com/mapsforge/vtm/pull/740) - MBTiles vector tile source (Android) [#740](https://github.com/mapsforge/vtm/pull/740)
@@ -182,7 +234,7 @@
- Many other minor improvements and bug fixes - Many other minor improvements and bug fixes
- [Solved issues](https://github.com/mapsforge/vtm/issues?q=is%3Aclosed+milestone%3A0.7.0) - [Solved issues](https://github.com/mapsforge/vtm/issues?q=is%3Aclosed+milestone%3A0.7.0)
## Version 0.6.0 (2016-10-28) - VTM revive ## Version 0.6.0 (2016-10-28) - VTM revival
- Mapsforge maps **v4** support [#34](https://github.com/mapsforge/vtm/issues/34) - Mapsforge maps **v4** support [#34](https://github.com/mapsforge/vtm/issues/34)
- Render theme SVG resources [#60](https://github.com/mapsforge/vtm/issues/60) - Render theme SVG resources [#60](https://github.com/mapsforge/vtm/issues/60)
@@ -199,6 +251,8 @@
- libGDX layer gestures [#151](https://github.com/mapsforge/vtm/issues/151) - libGDX layer gestures [#151](https://github.com/mapsforge/vtm/issues/151)
- Render theme area tessellation option [#37](https://github.com/mapsforge/vtm/issues/37) - Render theme area tessellation option [#37](https://github.com/mapsforge/vtm/issues/37)
- Render theme resources optional location prefixes [#66](https://github.com/mapsforge/vtm/issues/66) - Render theme resources optional location prefixes [#66](https://github.com/mapsforge/vtm/issues/66)
- Render theme from input stream [#161](https://github.com/mapsforge/vtm/issues/161)
- Render theme from Android assets [#162](https://github.com/mapsforge/vtm/issues/162)
- Graphics API platform enhancements [#92](https://github.com/mapsforge/vtm/issues/92) - Graphics API platform enhancements [#92](https://github.com/mapsforge/vtm/issues/92)
- GeoPoint & BoundingBox improvements [#201](https://github.com/mapsforge/vtm/issues/201) [#200](https://github.com/mapsforge/vtm/issues/200) - GeoPoint & BoundingBox improvements [#201](https://github.com/mapsforge/vtm/issues/201) [#200](https://github.com/mapsforge/vtm/issues/200)
- vtm-jts module [#53](https://github.com/mapsforge/vtm/issues/53) - vtm-jts module [#53](https://github.com/mapsforge/vtm/issues/53)

View File

@@ -1 +1 @@
For questions, reports and discussion please always use the [forum](https://groups.google.com/group/mapsforge-dev). For questions, reports and feature requests please use the Discussions.

View File

@@ -10,7 +10,8 @@ Current version is [![Maven Central](https://img.shields.io/maven-central/v/org.
```groovy ```groovy
implementation 'org.mapsforge:vtm:[CURRENT-VERSION]' implementation 'org.mapsforge:vtm:[CURRENT-VERSION]'
implementation 'org.mapsforge:vtm-themes:[CURRENT-VERSION]' implementation 'org.mapsforge:vtm-themes:[CURRENT-VERSION]'
implementation 'org.slf4j:slf4j-api:1.7.25' implementation 'net.sf.kxml:kxml2:2.3.0'
implementation 'org.slf4j:slf4j-api:1.7.28'
``` ```
### Android ### Android
@@ -20,7 +21,7 @@ implementation 'org.mapsforge:vtm-android:[CURRENT-VERSION]:natives-armeabi-v7a'
implementation 'org.mapsforge:vtm-android:[CURRENT-VERSION]:natives-arm64-v8a' implementation 'org.mapsforge:vtm-android:[CURRENT-VERSION]:natives-arm64-v8a'
implementation 'org.mapsforge:vtm-android:[CURRENT-VERSION]:natives-x86' implementation 'org.mapsforge:vtm-android:[CURRENT-VERSION]:natives-x86'
implementation 'org.mapsforge:vtm-android:[CURRENT-VERSION]:natives-x86_64' implementation 'org.mapsforge:vtm-android:[CURRENT-VERSION]:natives-x86_64'
implementation 'com.caverock:androidsvg:1.3' implementation 'com.caverock:androidsvg:1.4'
``` ```
### Android (libGDX) ### Android (libGDX)
@@ -38,7 +39,7 @@ implementation 'org.mapsforge:vtm-android-gdx:[CURRENT-VERSION]:natives-x86'
implementation 'org.mapsforge:vtm-android-gdx:[CURRENT-VERSION]:natives-x86_64' implementation 'org.mapsforge:vtm-android-gdx:[CURRENT-VERSION]:natives-x86_64'
implementation 'com.badlogicgames.gdx:gdx:1.9.10' implementation 'com.badlogicgames.gdx:gdx:1.9.10'
implementation 'com.badlogicgames.gdx:gdx-backend-android:1.9.10' implementation 'com.badlogicgames.gdx:gdx-backend-android:1.9.10'
implementation 'com.caverock:androidsvg:1.3' implementation 'com.caverock:androidsvg:1.4'
``` ```
### iOS ### iOS
@@ -47,24 +48,20 @@ Detailed iOS instructions can be found [here](ios.md).
### Desktop ### Desktop
```groovy ```groovy
repositories {
maven { url 'https://jitpack.io' }
}
implementation 'org.mapsforge:vtm-gdx:[CURRENT-VERSION]' implementation 'org.mapsforge:vtm-gdx:[CURRENT-VERSION]'
implementation 'org.mapsforge:vtm-desktop:[CURRENT-VERSION]' implementation 'org.mapsforge:vtm-desktop:[CURRENT-VERSION]'
implementation 'org.mapsforge:vtm-desktop:[CURRENT-VERSION]:natives-linux' implementation 'org.mapsforge:vtm-desktop:[CURRENT-VERSION]:natives-linux'
implementation 'org.mapsforge:vtm-desktop:[CURRENT-VERSION]:natives-osx' implementation 'org.mapsforge:vtm-desktop:[CURRENT-VERSION]:natives-osx'
implementation 'org.mapsforge:vtm-desktop:[CURRENT-VERSION]:natives-windows' implementation 'org.mapsforge:vtm-desktop:[CURRENT-VERSION]:natives-windows'
implementation 'org.mapsforge:vtm-desktop-lwjgl:[CURRENT-VERSION]'
implementation 'com.badlogicgames.gdx:gdx:1.9.10' implementation 'com.badlogicgames.gdx:gdx:1.9.10'
implementation 'com.badlogicgames.gdx:gdx-platform:1.9.10:natives-desktop' implementation 'com.badlogicgames.gdx:gdx-platform:1.9.10:natives-desktop'
implementation 'com.badlogicgames.gdx:gdx-backend-lwjgl:1.9.10' implementation 'com.formdev:svgSalamander:1.1.2.4'
implementation 'com.github.blackears:svgSalamander:v1.1.1'
``` ```
### Desktop (LWJGL) ### Desktop (LWJGL)
```groovy ```groovy
implementation 'org.mapsforge:vtm-desktop-lwjgl:[CURRENT-VERSION]'
implementation 'com.badlogicgames.gdx:gdx-backend-lwjgl:1.9.10'
implementation 'org.lwjgl.lwjgl:lwjgl:2.9.3' implementation 'org.lwjgl.lwjgl:lwjgl:2.9.3'
implementation 'org.lwjgl.lwjgl:lwjgl-platform:2.9.3:natives-linux' implementation 'org.lwjgl.lwjgl:lwjgl-platform:2.9.3:natives-linux'
implementation 'org.lwjgl.lwjgl:lwjgl-platform:2.9.3:natives-osx' implementation 'org.lwjgl.lwjgl:lwjgl-platform:2.9.3:natives-osx'
@@ -73,25 +70,29 @@ implementation 'org.lwjgl.lwjgl:lwjgl-platform:2.9.3:natives-windows'
### Desktop (LWJGL 3) ### Desktop (LWJGL 3)
```groovy ```groovy
implementation 'org.lwjgl:lwjgl:3.2.1' implementation 'org.mapsforge:vtm-desktop-lwjgl3:[CURRENT-VERSION]'
implementation 'org.lwjgl:lwjgl:3.2.1:natives-linux' implementation 'com.badlogicgames.gdx:gdx-backend-lwjgl3:1.9.10'
implementation 'org.lwjgl:lwjgl:3.2.1:natives-macos' implementation 'org.lwjgl:lwjgl:3.2.3'
implementation 'org.lwjgl:lwjgl:3.2.1:natives-windows' implementation 'org.lwjgl:lwjgl:3.2.3:natives-linux'
implementation 'org.lwjgl:lwjgl:3.2.3:natives-macos'
implementation 'org.lwjgl:lwjgl:3.2.3:natives-windows'
``` ```
### JTS geometries ### JTS geometries
```groovy ```groovy
implementation 'org.mapsforge:vtm-jts:[CURRENT-VERSION]' implementation 'org.mapsforge:vtm-jts:[CURRENT-VERSION]'
implementation 'org.locationtech.jts:jts-core:1.15.0' // https://github.com/locationtech/jts/issues/145
implementation 'org.locationtech.jts:jts-core:1.15.1'
``` ```
### Online tiles ### Online tiles
```groovy ```groovy
implementation 'org.mapsforge:vtm-http:[CURRENT-VERSION]' implementation 'org.mapsforge:vtm-http:[CURRENT-VERSION]'
implementation 'com.squareup.okhttp3:okhttp:3.8.0' // https://github.com/square/okhttp/issues/4481
implementation 'com.squareup.okio:okio:1.13.0' implementation 'com.squareup.okhttp3:okhttp:3.12.13'
implementation 'com.squareup.okio:okio:1.15.0'
``` ```
### MBTiles (Android) ### MBTiles (Android)
@@ -99,54 +100,42 @@ implementation 'com.squareup.okio:okio:1.13.0'
```groovy ```groovy
implementation 'org.mapsforge:vtm-android-mvt:[CURRENT-VERSION]' implementation 'org.mapsforge:vtm-android-mvt:[CURRENT-VERSION]'
implementation 'org.mapsforge:vtm-mvt:[CURRENT-VERSION]' implementation 'org.mapsforge:vtm-mvt:[CURRENT-VERSION]'
implementation 'com.google.protobuf:protobuf-java:3.5.1' implementation 'com.google.protobuf:protobuf-java:3.6.1'
implementation 'com.wdtinc:mapbox-vector-tile:3.0.0' implementation 'com.wdtinc:mapbox-vector-tile:3.1.0'
implementation 'org.locationtech.jts:jts-core:1.15.0' // https://github.com/locationtech/jts/issues/145
implementation 'org.locationtech.jts:jts-core:1.15.1'
``` ```
### Mapbox vector tiles ### Mapbox vector tiles
```groovy ```groovy
implementation 'org.mapsforge:vtm-mvt:[CURRENT-VERSION]' implementation 'org.mapsforge:vtm-mvt:[CURRENT-VERSION]'
implementation 'com.google.protobuf:protobuf-java:3.5.1' implementation 'com.google.protobuf:protobuf-java:3.6.1'
implementation 'com.wdtinc:mapbox-vector-tile:3.0.0' implementation 'com.wdtinc:mapbox-vector-tile:3.1.0'
implementation 'org.locationtech.jts:jts-core:1.15.0' // https://github.com/locationtech/jts/issues/145
implementation 'org.locationtech.jts:jts-core:1.15.1'
``` ```
### GeoJSON vector tiles ### GeoJSON vector tiles
```groovy ```groovy
implementation 'org.mapsforge:vtm-json:[CURRENT-VERSION]' implementation 'org.mapsforge:vtm-json:[CURRENT-VERSION]'
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.8.4' implementation 'com.fasterxml.jackson.core:jackson-annotations:2.9.9'
implementation 'com.fasterxml.jackson.core:jackson-core:2.8.4' implementation 'com.fasterxml.jackson.core:jackson-core:2.9.9'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.8.4' implementation 'com.fasterxml.jackson.core:jackson-databind:2.9.9'
``` ```
### jeo (indoor maps) ### jeo (indoor maps)
Add _first_ the Boundless repository:
```groovy ```groovy
repositories { repositories {
maven { url 'https://repo.boundlessgeo.com/main/' } maven { url 'https://jitpack.io' }
jcenter()
...
} }
```
```groovy
implementation 'org.mapsforge:vtm-jeo:[CURRENT-VERSION]' implementation 'org.mapsforge:vtm-jeo:[CURRENT-VERSION]'
implementation('org.jeo:jeo:0-SNAPSHOT') { implementation('com.github.jeo.jeo:jeo-carto:master-SNAPSHOT') {
exclude group: 'org.slf4j', module: 'slf4j-jdk14' exclude group: 'org.slf4j', module: 'slf4j-jdk14'
} }
implementation('org.jeo:jeo-carto:0-SNAPSHOT') {
exclude group: 'org.slf4j', module: 'slf4j-jdk14'
}
implementation('org.jeo:jeo-render:0-SNAPSHOT') {
exclude group: 'org.slf4j', module: 'slf4j-jdk14'
}
implementation 'org.osgeo:proj4j:0.1.0:jeo'
implementation 'com.metaweb:lessen:1.0'
implementation 'com.vividsolutions:jts:1.13'
``` ```
## Snapshots ## Snapshots

View File

@@ -1,11 +1,10 @@
# Mapsforge map providers (in lexical order) # Mapsforge map providers (in lexical order)
- [AndroidMaps](http://www.androidmaps.co.uk/) - [AndroidMaps](https://www.androidmaps.co.uk/)
- [Freizeitkarte](http://www.freizeitkarte-osm.de/android/en/index.html) - [BBBike](https://extract.bbbike.org/?format=mapsforge-osm.zip)
- [Kurviger](https://offline-maps.kurviger.de/) - [Freizeitkarte](https://www.freizeitkarte-osm.de/android/en/index.html)
- [Locusvectormaps](http://www.locusvectormaps.com) - [Kurviger](https://download.kurviger.de/)
- [Mapsforge](http://download.mapsforge.org/) - [Mapsforge](https://download.mapsforge.org/)
- [OpenAndroMaps](http://www.openandromaps.org/en/) - [OpenAndroMaps](https://www.openandromaps.org/en/)
- [OpenMaps](http://openmaps.eu/) - [OpenMaps](https://openmaps.eu/)
- [vector.city](https://vector.city/)
You know a Mapsforge map provider that is missing here? Please inform us by sending a message via our public [forum](https://groups.google.com/group/mapsforge-dev).

View File

@@ -1,8 +1,6 @@
# RenderTheme # RenderTheme
**This article describes how to use XML-based render-themes to style maps.** This article describes how to use XML-based render-themes to style maps.
If you have any questions or problems, don't hesitate to ask our public [forum](https://groups.google.com/group/mapsforge-dev) for help. You can also report bugs and improvement requests via our [issue tracker](https://github.com/mapsforge/vtm/issues).
## Introduction ## Introduction
@@ -109,11 +107,12 @@ There are different possibilities to simplify and accelerate map styling or chan
### Style patterns ### Style patterns
If you want to use a specific style multiple times you not have to rewrite it for each text, area, or line rule. If you want to use a specific style multiple times you not have to rewrite it for each text, line, area or symbol rule.
If you define a style set an `id` and use it with `use` in your rendering instructions: If you define a style set an `id` and use it with `use` in your rendering instructions:
- `style-text` - `style-text`
- `style-line` - `style-line`
- `style-area` - `style-area`
- `style-symbol`
This example styles all areas with the_residential_ style, which haven't the `highway` or `building` key. This example styles all areas with the_residential_ style, which haven't the `highway` or `building` key.

View File

@@ -6,14 +6,12 @@
# http://www.gradle.org/docs/current/userguide/build_environment.html # http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process. # Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings. # The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode. # When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit # This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true # org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the # AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app's APK # Android operating system, and which are packaged with your app"s APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn # https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true

View File

@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

View File

@@ -233,13 +233,21 @@
<xs:complexType name="symbol"> <xs:complexType name="symbol">
<xs:attribute name="cat" type="xs:string" use="optional" /> <xs:attribute name="cat" type="xs:string" use="optional" />
<xs:attribute name="src" type="tns:src" use="required" />
<xs:attribute name="id" default="0" type="xs:string" use="optional" />
<xs:attribute name="use" default="0" type="xs:string" use="optional" />
<xs:attribute name="src" type="tns:src" use="optional" />
<xs:attribute name="symbol-width" type="xs:positiveInteger" use="optional" /> <xs:attribute name="symbol-width" type="xs:positiveInteger" use="optional" />
<xs:attribute name="symbol-height" 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="symbol-percent" type="xs:positiveInteger" use="optional" />
<!-- symbols on lines -->
<xs:attribute name="billboard" default="false" type="xs:boolean" use="optional" />
<xs:attribute name="repeat" default="false" type="xs:boolean" use="optional" /> <xs:attribute name="repeat" default="false" type="xs:boolean" use="optional" />
<xs:attribute name="repeat-gap" default="200" type="xs:float" use="optional" /> <xs:attribute name="repeat-gap" default="200" type="xs:float" use="optional" />
<xs:attribute name="repeat-start" default="30" type="xs:float" use="optional" /> <xs:attribute name="repeat-start" default="30" type="xs:float" use="optional" />
<xs:attribute name="rotate" default="true" type="xs:boolean" use="optional" />
</xs:complexType> </xs:complexType>
<xs:complexType name="extrusion"> <xs:complexType name="extrusion">
@@ -328,6 +336,7 @@
<xs:sequence maxOccurs="256" minOccurs="0"> <xs:sequence maxOccurs="256" minOccurs="0">
<xs:choice maxOccurs="unbounded" minOccurs="0"> <xs:choice maxOccurs="unbounded" minOccurs="0">
<xs:element name="style-text" type="tns:text" /> <xs:element name="style-text" type="tns:text" />
<xs:element name="style-symbol" type="tns:symbol" />
<xs:element name="style-area" type="tns:area" /> <xs:element name="style-area" type="tns:area" />
<xs:element name="style-line" type="tns:line" /> <xs:element name="style-line" type="tns:line" />
<!-- <xs:element name="style-outline" type="tns:line" /> --> <!-- <xs:element name="style-outline" type="tns:line" /> -->

View File

@@ -7,11 +7,15 @@
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission
android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="18" />
<application <application
android:allowBackup="true" android:allowBackup="true"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:label="@string/app_name" android:label="@string/app_name"
android:requestLegacyExternalStorage="true"
android:usesCleartextTraffic="true"> android:usesCleartextTraffic="true">
<activity <activity
android:name=".Samples" android:name=".Samples"
@@ -30,6 +34,9 @@
<activity <activity
android:name=".ClusterMarkerOverlayActivity" android:name=".ClusterMarkerOverlayActivity"
android:configChanges="keyboardHidden|orientation|screenSize" /> android:configChanges="keyboardHidden|orientation|screenSize" />
<activity
android:name=".FragmentActivity"
android:configChanges="keyboardHidden|orientation|screenSize" />
<activity <activity
android:name=".GettingStarted" android:name=".GettingStarted"
android:configChanges="keyboardHidden|orientation|screenSize" /> android:configChanges="keyboardHidden|orientation|screenSize" />
@@ -57,12 +64,6 @@
<activity <activity
android:name=".MapsforgeActivity" android:name=".MapsforgeActivity"
android:configChanges="keyboardHidden|orientation|screenSize" /> android:configChanges="keyboardHidden|orientation|screenSize" />
<activity
android:name=".MapsforgeActivity$MapFilePicker"
android:configChanges="keyboardHidden|orientation|screenSize" />
<activity
android:name=".MapsforgeActivity$ThemeFilePicker"
android:configChanges="keyboardHidden|orientation|screenSize" />
<activity <activity
android:name=".MapsforgeS3DBActivity" android:name=".MapsforgeS3DBActivity"
android:configChanges="keyboardHidden|orientation|screenSize" /> android:configChanges="keyboardHidden|orientation|screenSize" />

View File

@@ -1,12 +1,5 @@
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
/*
configurations.all {
// Check latest snapshot on every build
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
*/
dependencies { dependencies {
implementation project(':vtm-android') implementation project(':vtm-android')
implementation project(':vtm-android-mvt') implementation project(':vtm-android-mvt')
@@ -23,11 +16,11 @@ dependencies {
implementation project(':vtm-gdx') implementation project(':vtm-gdx')
implementation project(':vtm-gdx-poi3d') implementation project(':vtm-gdx-poi3d')
implementation 'org.mapsforge:mapsforge-poi-android:master-SNAPSHOT' implementation 'org.mapsforge:mapsforge-poi-android:0.16.0'
implementation 'org.mapsforge:sqlite-android:master-SNAPSHOT:natives-armeabi-v7a' implementation 'org.mapsforge:sqlite-android:0.16.0:natives-armeabi-v7a'
implementation 'org.mapsforge:sqlite-android:master-SNAPSHOT:natives-arm64-v8a' implementation 'org.mapsforge:sqlite-android:0.16.0:natives-arm64-v8a'
implementation 'org.mapsforge:sqlite-android:master-SNAPSHOT:natives-x86' implementation 'org.mapsforge:sqlite-android:0.16.0:natives-x86'
implementation 'org.mapsforge:sqlite-android:master-SNAPSHOT:natives-x86_64' implementation 'org.mapsforge:sqlite-android:0.16.0:natives-x86_64'
} }
android { android {

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/empty_fragment_text" />
</RelativeLayout>

View File

@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@android:color/white"> android:background="@android:color/white">
<org.oscim.android.MapView <RelativeLayout
android:id="@+id/mapView" android:id="@+id/mapView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" /> android:layout_height="match_parent" />

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/replace_fragment"
android:showAsAction="never"
android:title="@string/replace_fragment" />
</menu>

View File

@@ -20,6 +20,9 @@
<item <item
android:id="@+id/theme_newtron" android:id="@+id/theme_newtron"
android:title="@string/theme_newtron" /> android:title="@string/theme_newtron" />
<item
android:id="@+id/theme_external_archive"
android:title="@string/theme_external_archive" />
<item <item
android:id="@+id/theme_external" android:id="@+id/theme_external"
android:title="@string/theme_external" /> android:title="@string/theme_external" />

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://www.w3.org/2000/svg" height="580" width="580" version="1.0" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/">
<title>other</title>
<metadata>
<rdf:RDF>
<cc:Work rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
<dc:title>other</dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<circle opacity=".8" cx="290" cy="290" r="145" fill="#fff"/>
<circle cy="290" cx="290" r="116" fill="#0092DA"/>
</svg>

After

Width:  |  Height:  |  Size: 651 B

View File

@@ -6,7 +6,8 @@
<string name="theme_osmagray">Osmagray</string> <string name="theme_osmagray">Osmagray</string>
<string name="theme_tubes">Tubes</string> <string name="theme_tubes">Tubes</string>
<string name="theme_newtron">NewTron</string> <string name="theme_newtron">NewTron</string>
<string name="theme_external">External theme</string> <string name="theme_external">External theme (Android 5)</string>
<string name="theme_external_archive">External theme archive</string>
<string name="styler_mode_line">Line</string> <string name="styler_mode_line">Line</string>
<string name="styler_mode_area">Area</string> <string name="styler_mode_area">Area</string>
<string name="styler_mode_outline">Outline</string> <string name="styler_mode_outline">Outline</string>
@@ -15,6 +16,7 @@
<string name="style_2">Hide nature</string> <string name="style_2">Hide nature</string>
<string name="menu_gridlayer">Grid</string> <string name="menu_gridlayer">Grid</string>
<string name="dialog_reverse_geocoding_title">Reverse Geocoding</string> <string name="dialog_reverse_geocoding_title">Reverse Geocoding</string>
<string name="dialog_theme_title">Select a theme</string>
<string name="add">Add</string> <string name="add">Add</string>
<string name="cancel">Cancel</string> <string name="cancel">Cancel</string>
<string name="error">Error</string> <string name="error">Error</string>
@@ -28,5 +30,7 @@
<string name="warning">Warning</string> <string name="warning">Warning</string>
<string name="startup_message_mbtiles">To run this sample activity, you need an MBTiles database installed on storage.\n\nadb push %s %s</string> <string name="startup_message_mbtiles">To run this sample activity, you need an MBTiles database installed on storage.\n\nadb push %s %s</string>
<string name="exit">Exit</string> <string name="exit">Exit</string>
<string name="replace_fragment">Replace fragment</string>
<string name="empty_fragment_text">This is a fragment to test the back stack behaviour of the map fragment.</string>
</resources> </resources>

View File

@@ -1,6 +1,6 @@
/* /*
* Copyright 2010, 2011, 2012 mapsforge.org * Copyright 2010, 2011, 2012 mapsforge.org
* Copyright 2016-2018 devemux86 * Copyright 2016-2020 devemux86
* Copyright 2017 Longri * Copyright 2017 Longri
* *
* This program is free software: you can redistribute it and/or modify it under the * This program is free software: you can redistribute it and/or modify it under the
@@ -16,18 +16,11 @@
*/ */
package org.oscim.android.filepicker; package org.oscim.android.filepicker;
import org.oscim.theme.ExternalRenderTheme; import org.oscim.theme.ThemeLoader;
import org.oscim.theme.ThemeFile;
import org.oscim.theme.XmlThemeBuilder;
import org.oscim.tiling.TileSource.OpenResult; import org.oscim.tiling.TileSource.OpenResult;
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.DefaultHandler;
import java.io.File; import java.io.File;
import javax.xml.parsers.SAXParserFactory;
/** /**
* Accepts all valid render theme XML files. * Accepts all valid render theme XML files.
*/ */
@@ -36,13 +29,8 @@ public final class ValidRenderTheme implements ValidFileFilter {
@Override @Override
public boolean accept(File file) { public boolean accept(File file) {
try { try {
ThemeFile theme = new ExternalRenderTheme(file.getAbsolutePath()); ThemeLoader.load(file.getAbsolutePath());
DefaultHandler renderThemeHandler = new XmlThemeBuilder(theme);
XMLReader xmlReader = SAXParserFactory.newInstance().newSAXParser().getXMLReader();
xmlReader.setContentHandler(renderThemeHandler);
xmlReader.parse(new InputSource(theme.getRenderThemeAsStream()));
mOpenResult = OpenResult.SUCCESS; mOpenResult = OpenResult.SUCCESS;
} catch (Exception e) { } catch (Exception e) {
mOpenResult = new OpenResult(e.getMessage()); mOpenResult = new OpenResult(e.getMessage());

View File

@@ -1,6 +1,6 @@
/* /*
* Copyright 2014 Hannes Janetzek * Copyright 2014 Hannes Janetzek
* Copyright 2016-2018 devemux86 * Copyright 2016-2020 devemux86
* Copyright 2017 Longri * Copyright 2017 Longri
* *
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org). * This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
@@ -19,7 +19,6 @@
package org.oscim.android.test; package org.oscim.android.test;
import android.widget.Toast; import android.widget.Toast;
import org.oscim.backend.CanvasAdapter; import org.oscim.backend.CanvasAdapter;
import org.oscim.backend.canvas.Bitmap; import org.oscim.backend.canvas.Bitmap;
import org.oscim.backend.canvas.Canvas; import org.oscim.backend.canvas.Canvas;
@@ -27,18 +26,20 @@ import org.oscim.backend.canvas.Color;
import org.oscim.backend.canvas.Paint; import org.oscim.backend.canvas.Paint;
import org.oscim.core.GeoPoint; import org.oscim.core.GeoPoint;
import org.oscim.layers.marker.ItemizedLayer; import org.oscim.layers.marker.ItemizedLayer;
import org.oscim.layers.marker.MarkerInterface;
import org.oscim.layers.marker.MarkerItem; import org.oscim.layers.marker.MarkerItem;
import org.oscim.layers.marker.MarkerSymbol; import org.oscim.layers.marker.MarkerSymbol;
import org.oscim.layers.marker.MarkerSymbol.HotspotPlace; import org.oscim.layers.marker.MarkerSymbol.HotspotPlace;
import org.oscim.layers.tile.bitmap.BitmapTileLayer; import org.oscim.layers.tile.bitmap.BitmapTileLayer;
import org.oscim.renderer.atlas.TextureAtlas; import org.oscim.renderer.atlas.TextureAtlas;
import org.oscim.renderer.atlas.TextureRegion; import org.oscim.renderer.atlas.TextureRegion;
import org.oscim.tiling.TileSource;
import org.oscim.tiling.source.OkHttpEngine; import org.oscim.tiling.source.OkHttpEngine;
import org.oscim.tiling.source.UrlTileSource;
import org.oscim.tiling.source.bitmap.DefaultSources; import org.oscim.tiling.source.bitmap.DefaultSources;
import org.oscim.utils.TextureAtlasUtils; import org.oscim.utils.TextureAtlasUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
@@ -49,9 +50,10 @@ public class AtlasMultiTextureActivity extends MarkerOverlayActivity {
// Map events receiver // Map events receiver
mMap.layers().add(new MapEventsReceiver(mMap)); mMap.layers().add(new MapEventsReceiver(mMap));
TileSource tileSource = DefaultSources.OPENSTREETMAP UrlTileSource tileSource = DefaultSources.OPENSTREETMAP
.httpFactory(new OkHttpEngine.OkHttpFactory()) .httpFactory(new OkHttpEngine.OkHttpFactory())
.build(); .build();
tileSource.setHttpRequestHeaders(Collections.singletonMap("User-Agent", "vtm-android-example"));
mMap.layers().add(new BitmapTileLayer(mMap, tileSource)); mMap.layers().add(new BitmapTileLayer(mMap, tileSource));
// Create Atlas from Bitmaps // Create Atlas from Bitmaps
@@ -65,7 +67,7 @@ public class AtlasMultiTextureActivity extends MarkerOverlayActivity {
paint.setTextSize(12 * CanvasAdapter.getScale()); paint.setTextSize(12 * CanvasAdapter.getScale());
paint.setStrokeWidth(2 * CanvasAdapter.getScale()); paint.setStrokeWidth(2 * CanvasAdapter.getScale());
paint.setColor(Color.BLACK); paint.setColor(Color.BLACK);
List<MarkerItem> pts = new ArrayList<>(); List<MarkerInterface> pts = new ArrayList<>();
for (double lat = -90; lat <= 90; lat += 10) { for (double lat = -90; lat <= 90; lat += 10) {
for (double lon = -180; lon <= 180; lon += 10) { for (double lon = -180; lon <= 180; lon += 10) {
String title = lat + "/" + lon; String title = lat + "/" + lon;
@@ -85,29 +87,32 @@ public class AtlasMultiTextureActivity extends MarkerOverlayActivity {
// With iOS we must flip the Y-Axis // With iOS we must flip the Y-Axis
TextureAtlasUtils.createTextureRegions(inputMap, regionsMap, atlasList, true, false); TextureAtlasUtils.createTextureRegions(inputMap, regionsMap, atlasList, true, false);
mMarkerLayer = new ItemizedLayer<>(mMap, new ArrayList<MarkerItem>(), (MarkerSymbol) null, this); mMarkerLayer = new ItemizedLayer(mMap, new ArrayList<MarkerInterface>(), (MarkerSymbol) null, this);
mMap.layers().add(mMarkerLayer); mMap.layers().add(mMarkerLayer);
mMarkerLayer.addItems(pts); mMarkerLayer.addItems(pts);
// set all markers // set all markers
for (MarkerItem item : pts) { for (MarkerInterface item : pts) {
MarkerSymbol markerSymbol = new MarkerSymbol(regionsMap.get(item.getTitle()), HotspotPlace.BOTTOM_CENTER); MarkerItem markerItem = (MarkerItem) item;
item.setMarker(markerSymbol); MarkerSymbol markerSymbol = new MarkerSymbol(regionsMap.get(markerItem.getTitle()), HotspotPlace.BOTTOM_CENTER);
markerItem.setMarker(markerSymbol);
} }
Toast.makeText(this, "Atlas count: " + atlasList.size(), Toast.LENGTH_SHORT).show(); Toast.makeText(this, "Atlas count: " + atlasList.size(), Toast.LENGTH_SHORT).show();
} }
@Override @Override
public boolean onItemSingleTapUp(int index, MarkerItem item) { public boolean onItemSingleTapUp(int index, MarkerInterface item) {
Toast.makeText(this, "Marker tap\n" + item.getTitle(), Toast.LENGTH_SHORT).show(); MarkerItem markerItem = (MarkerItem) item;
Toast.makeText(this, "Marker tap\n" + markerItem.getTitle(), Toast.LENGTH_SHORT).show();
return true; return true;
} }
@Override @Override
public boolean onItemLongPress(int index, MarkerItem item) { public boolean onItemLongPress(int index, MarkerInterface item) {
Toast.makeText(this, "Marker long press\n" + item.getTitle(), Toast.LENGTH_SHORT).show(); MarkerItem markerItem = (MarkerItem) item;
Toast.makeText(this, "Marker long press\n" + markerItem.getTitle(), Toast.LENGTH_SHORT).show();
return true; return true;
} }
} }

View File

@@ -1,6 +1,6 @@
/* /*
* Copyright 2013 Hannes Janetzek * Copyright 2013 Hannes Janetzek
* Copyright 2016-2018 devemux86 * Copyright 2016-2020 devemux86
* *
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org). * This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
* *
@@ -20,8 +20,8 @@ package org.oscim.android.test;
import android.os.Bundle; import android.os.Bundle;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import okhttp3.Cache;
import org.oscim.android.cache.TileCache; import okhttp3.OkHttpClient;
import org.oscim.core.MapPosition; import org.oscim.core.MapPosition;
import org.oscim.layers.TileGridLayer; import org.oscim.layers.TileGridLayer;
import org.oscim.layers.tile.vector.VectorTileLayer; import org.oscim.layers.tile.vector.VectorTileLayer;
@@ -29,11 +29,10 @@ import org.oscim.theme.VtmThemes;
import org.oscim.tiling.TileSource; import org.oscim.tiling.TileSource;
import org.oscim.tiling.source.OkHttpEngine; import org.oscim.tiling.source.OkHttpEngine;
import org.oscim.tiling.source.oscimap4.OSciMap4TileSource; import org.oscim.tiling.source.oscimap4.OSciMap4TileSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import java.io.File;
public class BaseMapActivity extends MapActivity { public class BaseMapActivity extends MapActivity {
static final Logger log = LoggerFactory.getLogger(BaseMapActivity.class);
static final boolean USE_CACHE = false; static final boolean USE_CACHE = false;
@@ -41,8 +40,6 @@ public class BaseMapActivity extends MapActivity {
TileSource mTileSource; TileSource mTileSource;
TileGridLayer mGridLayer; TileGridLayer mGridLayer;
private TileCache mCache;
public BaseMapActivity(int contentView) { public BaseMapActivity(int contentView) {
super(contentView); super(contentView);
} }
@@ -54,15 +51,19 @@ public class BaseMapActivity extends MapActivity {
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
OkHttpClient.Builder builder = new OkHttpClient.Builder();
if (USE_CACHE) {
// Cache the tiles into file system
File cacheDirectory = new File(getExternalCacheDir(), "tiles");
int cacheSize = 10 * 1024 * 1024; // 10 MB
Cache cache = new Cache(cacheDirectory, cacheSize);
builder.cache(cache);
}
mTileSource = OSciMap4TileSource.builder() mTileSource = OSciMap4TileSource.builder()
.httpFactory(new OkHttpEngine.OkHttpFactory()) .httpFactory(new OkHttpEngine.OkHttpFactory(builder))
.build(); .build();
if (USE_CACHE) {
mCache = new TileCache(this, null, "tile.db");
mCache.setCacheSize(512 * (1 << 10));
mTileSource.setCache(mCache);
}
mBaseLayer = mMap.setBaseMap(mTileSource); mBaseLayer = mMap.setBaseMap(mTileSource);
/* set initial position on first run */ /* set initial position on first run */
@@ -72,14 +73,6 @@ public class BaseMapActivity extends MapActivity {
mMap.setMapPosition(53.08, 8.83, Math.pow(2, 16)); mMap.setMapPosition(53.08, 8.83, Math.pow(2, 16));
} }
@Override
protected void onDestroy() {
super.onDestroy();
if (mCache != null)
mCache.dispose();
}
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {

View File

@@ -1,6 +1,6 @@
/* /*
* Copyright 2014 Hannes Janetzek * Copyright 2014 Hannes Janetzek
* Copyright 2017-2018 devemux86 * Copyright 2017-2020 devemux86
* *
* This program is free software: you can redistribute it and/or modify it under the * 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 * terms of the GNU Lesser General Public License as published by the Free Software
@@ -16,21 +16,21 @@
package org.oscim.android.test; package org.oscim.android.test;
import android.os.Bundle; import android.os.Bundle;
import okhttp3.Cache;
import org.oscim.android.cache.TileCache; import okhttp3.OkHttpClient;
import org.oscim.core.MapPosition; import org.oscim.core.MapPosition;
import org.oscim.core.MercatorProjection; import org.oscim.core.MercatorProjection;
import org.oscim.layers.tile.bitmap.BitmapTileLayer; import org.oscim.layers.tile.bitmap.BitmapTileLayer;
import org.oscim.renderer.MapRenderer; import org.oscim.renderer.MapRenderer;
import org.oscim.tiling.source.OkHttpEngine;
import org.oscim.tiling.source.bitmap.BitmapTileSource; import org.oscim.tiling.source.bitmap.BitmapTileSource;
import org.oscim.tiling.source.bitmap.DefaultSources; import org.oscim.tiling.source.bitmap.DefaultSources;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import java.io.File;
import java.util.Collections;
public class BitmapTileActivity extends MapActivity { public class BitmapTileActivity extends MapActivity {
static final Logger log = LoggerFactory.getLogger(BitmapTileActivity.class);
private static final boolean USE_CACHE = false; private static final boolean USE_CACHE = false;
private final BitmapTileSource mTileSource; private final BitmapTileSource mTileSource;
@@ -45,8 +45,6 @@ public class BitmapTileActivity extends MapActivity {
mTileSource = tileSource; mTileSource = tileSource;
} }
private TileCache mCache;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@@ -56,31 +54,24 @@ public class BitmapTileActivity extends MapActivity {
if (mTileSource == null) if (mTileSource == null)
return; return;
OkHttpClient.Builder builder = new OkHttpClient.Builder();
if (USE_CACHE) { if (USE_CACHE) {
String cacheFile = mTileSource.getUrl() // Cache the tiles into file system
.toString() File cacheDirectory = new File(getExternalCacheDir(), "tiles");
.replaceFirst("https?://", "") int cacheSize = 10 * 1024 * 1024; // 10 MB
.replaceAll("/", "-"); Cache cache = new Cache(cacheDirectory, cacheSize);
builder.cache(cache);
log.debug("use bitmap cache {}", cacheFile);
mCache = new TileCache(this, null, cacheFile);
mCache.setCacheSize(512 * (1 << 10));
mTileSource.setCache(mCache);
} }
mTileSource.setHttpEngine(new OkHttpEngine.OkHttpFactory(builder));
mTileSource.setHttpRequestHeaders(Collections.singletonMap("User-Agent", "vtm-android-example"));
mBitmapLayer = new BitmapTileLayer(mMap, mTileSource); mBitmapLayer = new BitmapTileLayer(mMap, mTileSource);
mMap.layers().add(mBitmapLayer); mMap.layers().add(mBitmapLayer);
//loooop(1); //loooop(1);
} }
@Override
protected void onDestroy() {
super.onDestroy();
if (mCache != null)
mCache.dispose();
}
// Stress testing // Stress testing
void loooop(final int i) { void loooop(final int i) {
final long time = (long) (500 + Math.random() * 1000); final long time = (long) (500 + Math.random() * 1000);

View File

@@ -0,0 +1,38 @@
/*
* Copyright 2020 Meibes
*
* This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.oscim.android.test;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@SuppressWarnings("deprecation")
public class BlankFragment extends Fragment {
static BlankFragment newInstance() {
BlankFragment instance = new BlankFragment();
Bundle args = new Bundle();
instance.setArguments(args);
return instance;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_blank, container, false);
}
}

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2016-2018 devemux86 * Copyright 2016-2020 devemux86
* Copyright 2017 nebular * Copyright 2017 nebular
* *
* This program is free software: you can redistribute it and/or modify it under the * This program is free software: you can redistribute it and/or modify it under the
@@ -15,26 +15,21 @@
*/ */
package org.oscim.android.test; package org.oscim.android.test;
import android.graphics.BitmapFactory;
import org.oscim.android.canvas.AndroidBitmap;
import org.oscim.backend.canvas.Bitmap; import org.oscim.backend.canvas.Bitmap;
import org.oscim.backend.canvas.Color; import org.oscim.backend.canvas.Color;
import org.oscim.core.GeoPoint; import org.oscim.core.GeoPoint;
import org.oscim.layers.marker.ClusterMarkerRenderer; import org.oscim.layers.marker.*;
import org.oscim.layers.marker.ItemizedLayer;
import org.oscim.layers.marker.MarkerItem;
import org.oscim.layers.marker.MarkerLayer;
import org.oscim.layers.marker.MarkerRenderer;
import org.oscim.layers.marker.MarkerRendererFactory;
import org.oscim.layers.marker.MarkerSymbol;
import org.oscim.layers.tile.bitmap.BitmapTileLayer; import org.oscim.layers.tile.bitmap.BitmapTileLayer;
import org.oscim.tiling.TileSource;
import org.oscim.tiling.source.OkHttpEngine; import org.oscim.tiling.source.OkHttpEngine;
import org.oscim.tiling.source.UrlTileSource;
import org.oscim.tiling.source.bitmap.DefaultSources; import org.oscim.tiling.source.bitmap.DefaultSources;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
import static org.oscim.android.canvas.AndroidGraphics.drawableToBitmap;
public class ClusterMarkerOverlayActivity extends MarkerOverlayActivity { public class ClusterMarkerOverlayActivity extends MarkerOverlayActivity {
private static final int COUNT = 5; private static final int COUNT = 5;
@@ -45,12 +40,13 @@ public class ClusterMarkerOverlayActivity extends MarkerOverlayActivity {
// Map events receiver // Map events receiver
mMap.layers().add(new MapEventsReceiver(mMap)); mMap.layers().add(new MapEventsReceiver(mMap));
TileSource tileSource = DefaultSources.OPENSTREETMAP UrlTileSource tileSource = DefaultSources.OPENSTREETMAP
.httpFactory(new OkHttpEngine.OkHttpFactory()) .httpFactory(new OkHttpEngine.OkHttpFactory())
.build(); .build();
tileSource.setHttpRequestHeaders(Collections.singletonMap("User-Agent", "vtm-android-example"));
mMap.layers().add(new BitmapTileLayer(mMap, tileSource)); mMap.layers().add(new BitmapTileLayer(mMap, tileSource));
Bitmap bitmapPoi = drawableToBitmap(getResources().getDrawable(R.drawable.marker_poi)); Bitmap bitmapPoi = new AndroidBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.marker_poi));
final MarkerSymbol symbol; final MarkerSymbol symbol;
if (BILLBOARDS) if (BILLBOARDS)
symbol = new MarkerSymbol(bitmapPoi, MarkerSymbol.HotspotPlace.BOTTOM_CENTER); symbol = new MarkerSymbol(bitmapPoi, MarkerSymbol.HotspotPlace.BOTTOM_CENTER);
@@ -69,15 +65,15 @@ public class ClusterMarkerOverlayActivity extends MarkerOverlayActivity {
}; };
} }
}; };
mMarkerLayer = new ItemizedLayer<>( mMarkerLayer = new ItemizedLayer(
mMap, mMap,
new ArrayList<MarkerItem>(), new ArrayList<MarkerInterface>(),
markerRendererFactory, markerRendererFactory,
this); this);
mMap.layers().add(mMarkerLayer); mMap.layers().add(mMarkerLayer);
// Create some markers spaced STEP degrees // Create some markers spaced STEP degrees
List<MarkerItem> pts = new ArrayList<>(); List<MarkerInterface> pts = new ArrayList<>();
mMap.setMapPosition(53.08, 8.83, 1 << 15); mMap.setMapPosition(53.08, 8.83, 1 << 15);
GeoPoint center = mMap.getMapPosition().getGeoPoint(); GeoPoint center = mMap.getMapPosition().getGeoPoint();
for (int x = -COUNT; x < COUNT; x++) { for (int x = -COUNT; x < COUNT; x++) {

View File

@@ -0,0 +1,60 @@
/*
* Copyright 2020 Meibes
*
* This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.oscim.android.test;
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
public class FragmentActivity extends Activity {
@SuppressWarnings("deprecation")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_map_fragment);
setTitle(getClass().getSimpleName());
if (savedInstanceState == null) {
Fragment mapFragment = MapFragment.newInstance();
FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.add(R.id.fragment_container, mapFragment).commit();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.fragment_menu, menu);
return true;
}
@SuppressWarnings("deprecation")
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.replace_fragment) {
Fragment blankFragment = BlankFragment.newInstance();
FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.replace(R.id.fragment_container, blankFragment);
ft.addToBackStack(null);
ft.commit();
return true;
}
return super.onOptionsItemSelected(item);
}
}

View File

@@ -1,6 +1,6 @@
/* /*
* Copyright 2013 Hannes Janetzek * Copyright 2013 Hannes Janetzek
* Copyright 2016-2018 devemux86 * Copyright 2016-2020 devemux86
* Copyright 2018-2019 Gustl22 * Copyright 2018-2019 Gustl22
* *
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org). * This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
@@ -71,7 +71,7 @@ public class GdxActivity extends AndroidApplication {
DateTimeAdapter.init(new DateTime()); DateTimeAdapter.init(new DateTime());
DisplayMetrics metrics = getResources().getDisplayMetrics(); DisplayMetrics metrics = getResources().getDisplayMetrics();
CanvasAdapter.dpi = (int) (metrics.scaledDensity * CanvasAdapter.DEFAULT_DPI); CanvasAdapter.dpi = (int) (metrics.density * CanvasAdapter.DEFAULT_DPI);
Tile.SIZE = Tile.calculateTileSize(); Tile.SIZE = Tile.calculateTileSize();
AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration(); AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration();

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2018-2019 devemux86 * Copyright 2018-2020 devemux86
* *
* This program is free software: you can redistribute it and/or modify it under the * 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 * terms of the GNU Lesser General Public License as published by the Free Software
@@ -15,6 +15,9 @@
package org.oscim.android.test; package org.oscim.android.test;
import android.app.Activity; import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import org.oscim.android.MapView; import org.oscim.android.MapView;
import org.oscim.backend.CanvasAdapter; import org.oscim.backend.CanvasAdapter;
@@ -25,24 +28,24 @@ import org.oscim.renderer.GLViewport;
import org.oscim.scalebar.DefaultMapScaleBar; import org.oscim.scalebar.DefaultMapScaleBar;
import org.oscim.scalebar.MapScaleBar; import org.oscim.scalebar.MapScaleBar;
import org.oscim.scalebar.MapScaleBarLayer; import org.oscim.scalebar.MapScaleBarLayer;
import org.oscim.theme.IRenderTheme;
import org.oscim.theme.VtmThemes; import org.oscim.theme.VtmThemes;
import org.oscim.tiling.source.mapfile.MapFileTileSource; import org.oscim.tiling.source.mapfile.MapFileTileSource;
import java.io.File; import java.io.FileInputStream;
/** /**
* A very basic Android app example. * A very basic Android app example.
* <p> * <p>
* You'll need a map with filename berlin.map from download.mapsforge.org in device storage: * You'll need a map with filename berlin.map from download.mapsforge.org in device storage.
* /sdcard/Android/data/org.oscim.android.test/files/
*/ */
public class GettingStarted extends Activity { public class GettingStarted extends Activity {
// Name of the map file in device storage // Request code for selecting a map file
private static final String MAP_FILE = "berlin.map"; private static final int SELECT_MAP_FILE = 0;
private MapView mapView; private MapView mapView;
private MapScaleBar mapScaleBar; private IRenderTheme theme;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
@@ -52,10 +55,30 @@ public class GettingStarted extends Activity {
mapView = new MapView(this); mapView = new MapView(this);
setContentView(mapView); setContentView(mapView);
// Tile source // Open map
MapFileTileSource tileSource = new MapFileTileSource(); Intent intent = new Intent(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT ? Intent.ACTION_OPEN_DOCUMENT : Intent.ACTION_GET_CONTENT);
String mapPath = new File(getExternalFilesDir(null), MAP_FILE).getAbsolutePath(); intent.addCategory(Intent.CATEGORY_OPENABLE);
if (tileSource.setMapFile(mapPath)) { intent.setType("*/*");
startActivityForResult(intent, SELECT_MAP_FILE);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == SELECT_MAP_FILE && resultCode == Activity.RESULT_OK) {
if (data != null) {
Uri uri = data.getData();
openMap(uri);
}
}
}
private void openMap(Uri uri) {
try {
// Tile source
MapFileTileSource tileSource = new MapFileTileSource();
FileInputStream fis = (FileInputStream) getContentResolver().openInputStream(uri);
tileSource.setMapFileInputStream(fis);
// Vector layer // Vector layer
VectorTileLayer tileLayer = mapView.map().setBaseMap(tileSource); VectorTileLayer tileLayer = mapView.map().setBaseMap(tileSource);
@@ -66,10 +89,10 @@ public class GettingStarted extends Activity {
mapView.map().layers().add(new LabelLayer(mapView.map(), tileLayer)); mapView.map().layers().add(new LabelLayer(mapView.map(), tileLayer));
// Render theme // Render theme
mapView.map().setTheme(VtmThemes.DEFAULT); theme = mapView.map().setTheme(VtmThemes.DEFAULT);
// Scale bar // Scale bar
mapScaleBar = new DefaultMapScaleBar(mapView.map()); MapScaleBar mapScaleBar = new DefaultMapScaleBar(mapView.map());
MapScaleBarLayer mapScaleBarLayer = new MapScaleBarLayer(mapView.map(), mapScaleBar); MapScaleBarLayer mapScaleBarLayer = new MapScaleBarLayer(mapView.map(), mapScaleBar);
mapScaleBarLayer.getRenderer().setPosition(GLViewport.Position.BOTTOM_LEFT); mapScaleBarLayer.getRenderer().setPosition(GLViewport.Position.BOTTOM_LEFT);
mapScaleBarLayer.getRenderer().setOffset(5 * CanvasAdapter.getScale(), 0); mapScaleBarLayer.getRenderer().setOffset(5 * CanvasAdapter.getScale(), 0);
@@ -77,6 +100,11 @@ public class GettingStarted extends Activity {
// Note: this map position is specific to Berlin area // Note: this map position is specific to Berlin area
mapView.map().setMapPosition(52.517037, 13.38886, 1 << 12); mapView.map().setMapPosition(52.517037, 13.38886, 1 << 12);
} catch (Exception e) {
/*
* In case of map file errors avoid crash, but developers should handle these cases!
*/
e.printStackTrace();
} }
} }
@@ -94,9 +122,8 @@ public class GettingStarted extends Activity {
@Override @Override
protected void onDestroy() { protected void onDestroy() {
if (mapScaleBar != null)
mapScaleBar.destroy();
mapView.onDestroy(); mapView.onDestroy();
theme.dispose();
super.onDestroy(); super.onDestroy();
} }
} }

View File

@@ -22,9 +22,8 @@ import android.os.Bundle;
import android.view.View; import android.view.View;
import android.widget.Toast; import android.widget.Toast;
import android.widget.ToggleButton; import android.widget.ToggleButton;
import io.jeo.map.Style;
import org.jeo.map.Style; import io.jeo.vector.VectorDataset;
import org.jeo.vector.VectorDataset;
import org.oscim.backend.CanvasAdapter; import org.oscim.backend.CanvasAdapter;
import org.oscim.backend.canvas.Color; import org.oscim.backend.canvas.Color;
import org.oscim.layers.OSMIndoorLayer; import org.oscim.layers.OSMIndoorLayer;

View File

@@ -48,7 +48,7 @@ public class LineTexActivity extends BitmapTileActivity {
TextureItem tex = null; TextureItem tex = null;
try { try {
tex = new TextureItem(CanvasAdapter.getBitmapAsset("", "patterns/pike.png")); tex = new TextureItem(CanvasAdapter.getBitmapAsset("", "patterns/pike.png"));
tex.mipmap = true; //tex.mipmap = true;
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }

View File

@@ -24,8 +24,10 @@ import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import org.oscim.core.MapPosition; import org.oscim.core.MapPosition;
import org.oscim.layers.LocationLayer; import org.oscim.layers.LocationLayer;
import org.oscim.renderer.LocationCallback;
public class LocationActivity extends BitmapTileActivity implements LocationListener { public class LocationActivity extends BitmapTileActivity implements LocationListener {
private Location location;
private LocationLayer locationLayer; private LocationLayer locationLayer;
private LocationManager locationManager; private LocationManager locationManager;
private final MapPosition mapPosition = new MapPosition(); private final MapPosition mapPosition = new MapPosition();
@@ -37,7 +39,17 @@ public class LocationActivity extends BitmapTileActivity implements LocationList
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
locationLayer = new LocationLayer(mMap); locationLayer = new LocationLayer(mMap);
locationLayer.locationRenderer.setShader("location_1_reverse"); locationLayer.locationRenderer.setCallback(new LocationCallback() {
@Override
public boolean hasRotation() {
return location != null && location.hasBearing();
}
@Override
public float getRotation() {
return location != null && location.hasBearing() ? location.getBearing() : 0;
}
});
locationLayer.setEnabled(false); locationLayer.setEnabled(false);
mMap.layers().add(locationLayer); mMap.layers().add(locationLayer);
} }
@@ -66,6 +78,7 @@ public class LocationActivity extends BitmapTileActivity implements LocationList
@Override @Override
public void onLocationChanged(Location location) { public void onLocationChanged(Location location) {
this.location = location;
locationLayer.setEnabled(true); locationLayer.setEnabled(true);
locationLayer.setPosition(location.getLatitude(), location.getLongitude(), location.getAccuracy()); locationLayer.setPosition(location.getLatitude(), location.getLongitude(), location.getAccuracy());

View File

@@ -25,18 +25,16 @@ import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import org.oscim.backend.CanvasAdapter; import org.oscim.backend.CanvasAdapter;
import org.oscim.backend.canvas.Bitmap; import org.oscim.backend.canvas.Bitmap;
import org.oscim.backend.canvas.Color;
import org.oscim.core.MapPosition; import org.oscim.core.MapPosition;
import org.oscim.layers.LocationTextureLayer; import org.oscim.layers.LocationTextureLayer;
import org.oscim.renderer.atlas.TextureAtlas; import org.oscim.renderer.LocationCallback;
import org.oscim.renderer.atlas.TextureRegion;
import org.oscim.renderer.bucket.TextureItem;
import org.oscim.utils.IOUtils; import org.oscim.utils.IOUtils;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
public class LocationTextureActivity extends BitmapTileActivity implements LocationListener { public class LocationTextureActivity extends BitmapTileActivity implements LocationListener {
private Location location;
private LocationTextureLayer locationLayer; private LocationTextureLayer locationLayer;
private LocationManager locationManager; private LocationManager locationManager;
private final MapPosition mapPosition = new MapPosition(); private final MapPosition mapPosition = new MapPosition();
@@ -47,34 +45,41 @@ public class LocationTextureActivity extends BitmapTileActivity implements Locat
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
// load a Bitmap/SVG from resources
InputStream is = null; InputStream is = null;
Bitmap bmp = null; Bitmap bitmapArrow = null;
try { try {
is = getResources().openRawResource(R.raw.arrow); is = getResources().openRawResource(R.raw.arrow);
float scale = CanvasAdapter.getScale(); bitmapArrow = CanvasAdapter.decodeSvgBitmap(is, (int) (48 * CanvasAdapter.getScale()), (int) (48 * CanvasAdapter.getScale()), 100);
bmp = CanvasAdapter.decodeSvgBitmap(is, (int) (60 * scale), (int) (60 * scale), 100);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} finally { } finally {
IOUtils.closeQuietly(is); IOUtils.closeQuietly(is);
} }
// create TextureRegion from Bitmap Bitmap bitmapMarker = null;
TextureRegion textureRegion = new TextureRegion(new TextureItem(bmp), new TextureAtlas.Rect(0, 0, bmp.getWidth(), bmp.getHeight())); try {
is = getResources().openRawResource(R.raw.marker);
bitmapMarker = CanvasAdapter.decodeSvgBitmap(is, (int) (48 * CanvasAdapter.getScale()), (int) (48 * CanvasAdapter.getScale()), 100);
} catch (IOException e) {
e.printStackTrace();
} finally {
IOUtils.closeQuietly(is);
}
// create LocationTextureLayer with created/loaded TextureRegion locationLayer = new LocationTextureLayer(mMap);
locationLayer = new LocationTextureLayer(mMap, textureRegion); locationLayer.locationRenderer.setBitmapArrow(bitmapArrow);
locationLayer.locationRenderer.setBitmapMarker(bitmapMarker);
// set color of accuracy circle (Color.BLUE is default) locationLayer.locationRenderer.setCallback(new LocationCallback() {
locationLayer.locationRenderer.setAccuracyColor(Color.get(50, 50, 255)); @Override
public boolean hasRotation() {
// set color of indicator circle (Color.RED is default) return location != null && location.hasBearing();
locationLayer.locationRenderer.setIndicatorColor(Color.MAGENTA); }
// set billboard rendering for TextureRegion (false is default)
locationLayer.locationRenderer.setBillboard(false);
@Override
public float getRotation() {
return location != null && location.hasBearing() ? location.getBearing() : 0;
}
});
locationLayer.setEnabled(false); locationLayer.setEnabled(false);
mMap.layers().add(locationLayer); mMap.layers().add(locationLayer);
} }
@@ -103,8 +108,9 @@ public class LocationTextureActivity extends BitmapTileActivity implements Locat
@Override @Override
public void onLocationChanged(Location location) { public void onLocationChanged(Location location) {
this.location = location;
locationLayer.setEnabled(true); locationLayer.setEnabled(true);
locationLayer.setPosition(location.getLatitude(), location.getLongitude(), location.getBearing(), location.getAccuracy()); locationLayer.setPosition(location.getLatitude(), location.getLongitude(), location.getAccuracy());
// Follow location // Follow location
mMap.getMapPosition(mapPosition); mMap.getMapPosition(mapPosition);

View File

@@ -0,0 +1,125 @@
/*
* Copyright 2018-2020 devemux86
* Copyright 2020 Meibes
*
* This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.oscim.android.test;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import org.oscim.android.MapView;
import org.oscim.backend.CanvasAdapter;
import org.oscim.layers.tile.buildings.BuildingLayer;
import org.oscim.layers.tile.vector.VectorTileLayer;
import org.oscim.layers.tile.vector.labeling.LabelLayer;
import org.oscim.renderer.GLViewport;
import org.oscim.scalebar.DefaultMapScaleBar;
import org.oscim.scalebar.MapScaleBar;
import org.oscim.scalebar.MapScaleBarLayer;
import org.oscim.theme.IRenderTheme;
import org.oscim.theme.VtmThemes;
import org.oscim.tiling.source.mapfile.MapFileTileSource;
import java.io.File;
/**
* You'll need a map with filename berlin.map from download.mapsforge.org in device storage.
*/
@SuppressWarnings("deprecation")
public class MapFragment extends Fragment {
private MapView mapView;
private IRenderTheme theme;
public static MapFragment newInstance() {
MapFragment instance = new MapFragment();
Bundle args = new Bundle();
instance.setArguments(args);
return instance;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_map, container, false);
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
mapView = new MapView(getActivity());
RelativeLayout relativeLayout = view.findViewById(R.id.mapView);
relativeLayout.addView(mapView);
// Tile source
MapFileTileSource tileSource = new MapFileTileSource();
File file = new File(getActivity().getExternalFilesDir(null), "berlin.map");
tileSource.setMapFile(file.getAbsolutePath());
// Vector layer
VectorTileLayer tileLayer = mapView.map().setBaseMap(tileSource);
// Building layer
mapView.map().layers().add(new BuildingLayer(mapView.map(), tileLayer));
// Label layer
mapView.map().layers().add(new LabelLayer(mapView.map(), tileLayer));
// Render theme
theme = mapView.map().setTheme(VtmThemes.DEFAULT);
// Scale bar
MapScaleBar mapScaleBar = new DefaultMapScaleBar(mapView.map());
MapScaleBarLayer mapScaleBarLayer = new MapScaleBarLayer(mapView.map(), mapScaleBar);
mapScaleBarLayer.getRenderer().setPosition(GLViewport.Position.BOTTOM_LEFT);
mapScaleBarLayer.getRenderer().setOffset(5 * CanvasAdapter.getScale(), 0);
mapView.map().layers().add(mapScaleBarLayer);
// Note: this map position is specific to Berlin area
mapView.map().setMapPosition(52.517037, 13.38886, 1 << 12);
}
@Override
public void onResume() {
super.onResume();
if (mapView != null) {
mapView.onResume();
}
}
@Override
public void onPause() {
if (mapView != null) {
mapView.onPause();
}
super.onPause();
}
@Override
public void onDestroyView() {
if (mapView != null) {
mapView.onDestroy();
mapView = null;
}
if (theme != null) {
theme.dispose();
theme = null;
}
super.onDestroyView();
}
}

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2018-2019 devemux86 * Copyright 2018-2020 devemux86
* *
* This program is free software: you can redistribute it and/or modify it under the * 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 * terms of the GNU Lesser General Public License as published by the Free Software
@@ -14,9 +14,12 @@
*/ */
package org.oscim.android.test; package org.oscim.android.test;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import okhttp3.Cache;
import org.oscim.android.cache.TileCache; import okhttp3.CipherSuite;
import okhttp3.ConnectionSpec;
import okhttp3.OkHttpClient;
import org.oscim.layers.tile.bitmap.BitmapTileLayer; import org.oscim.layers.tile.bitmap.BitmapTileLayer;
import org.oscim.layers.tile.buildings.BuildingLayer; import org.oscim.layers.tile.buildings.BuildingLayer;
import org.oscim.layers.tile.vector.VectorTileLayer; import org.oscim.layers.tile.vector.VectorTileLayer;
@@ -27,6 +30,11 @@ import org.oscim.tiling.source.UrlTileSource;
import org.oscim.tiling.source.bitmap.DefaultSources; import org.oscim.tiling.source.bitmap.DefaultSources;
import org.oscim.tiling.source.mvt.MapilionMvtTileSource; import org.oscim.tiling.source.mvt.MapilionMvtTileSource;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class MapilionMvtActivity extends MapActivity { public class MapilionMvtActivity extends MapActivity {
// Metered API key for demonstration purposes // Metered API key for demonstration purposes
@@ -34,13 +42,34 @@ public class MapilionMvtActivity extends MapActivity {
private static final boolean USE_CACHE = false; private static final boolean USE_CACHE = false;
private TileCache mCache;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
OkHttpEngine.OkHttpFactory factory = new OkHttpEngine.OkHttpFactory(); OkHttpClient.Builder builder = new OkHttpClient.Builder();
if (USE_CACHE) {
// Cache the tiles into file system
File cacheDirectory = new File(getExternalCacheDir(), "tiles");
int cacheSize = 10 * 1024 * 1024; // 10 MB
Cache cache = new Cache(cacheDirectory, cacheSize);
builder.cache(cache);
}
// https://github.com/square/okhttp/issues/4053
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
List<CipherSuite> cipherSuites = new ArrayList<>();
List<CipherSuite> modernTlsCipherSuites = ConnectionSpec.MODERN_TLS.cipherSuites();
if (modernTlsCipherSuites != null)
cipherSuites.addAll(modernTlsCipherSuites);
cipherSuites.add(CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA);
cipherSuites.add(CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA);
ConnectionSpec legacyTls = new ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS)
.cipherSuites(cipherSuites.toArray(new CipherSuite[0]))
.build();
builder.connectionSpecs(Arrays.asList(legacyTls, ConnectionSpec.CLEARTEXT));
}
OkHttpEngine.OkHttpFactory factory = new OkHttpEngine.OkHttpFactory(builder);
UrlTileSource tileSource = MapilionMvtTileSource.builder() UrlTileSource tileSource = MapilionMvtTileSource.builder()
.apiKey(API_KEY) .apiKey(API_KEY)
@@ -48,13 +77,6 @@ public class MapilionMvtActivity extends MapActivity {
//.locale("en") //.locale("en")
.build(); .build();
if (USE_CACHE) {
// Cache the tiles into a local SQLite database
mCache = new TileCache(this, null, "tile.db");
mCache.setCacheSize(512 * (1 << 10));
tileSource.setCache(mCache);
}
VectorTileLayer l = mMap.setBaseMap(tileSource); VectorTileLayer l = mMap.setBaseMap(tileSource);
mMap.setTheme(VtmThemes.OPENMAPTILES); mMap.setTheme(VtmThemes.OPENMAPTILES);
@@ -68,12 +90,4 @@ public class MapilionMvtActivity extends MapActivity {
mMap.layers().add(new BuildingLayer(mMap, l)); mMap.layers().add(new BuildingLayer(mMap, l));
mMap.layers().add(new LabelLayer(mMap, l)); mMap.layers().add(new LabelLayer(mMap, l));
} }
@Override
protected void onDestroy() {
super.onDestroy();
if (mCache != null)
mCache.dispose();
}
} }

View File

@@ -1,8 +1,9 @@
/* /*
* Copyright 2014 Hannes Janetzek * Copyright 2014 Hannes Janetzek
* Copyright 2016-2018 devemux86 * Copyright 2016-2021 devemux86
* Copyright 2017 Longri * Copyright 2017 Longri
* Copyright 2018 Gustl22 * Copyright 2018 Gustl22
* Copyright 2021 eddiemuc
* *
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org). * This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
* *
@@ -19,15 +20,18 @@
*/ */
package org.oscim.android.test; package org.oscim.android.test;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.provider.DocumentsContract;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import org.oscim.android.theme.ContentRenderTheme;
import org.oscim.android.filepicker.FilePicker; import org.oscim.android.theme.ContentResolverResourceProvider;
import org.oscim.android.filepicker.FilterByFileExtension;
import org.oscim.android.filepicker.ValidMapFile;
import org.oscim.android.filepicker.ValidRenderTheme;
import org.oscim.backend.CanvasAdapter; import org.oscim.backend.CanvasAdapter;
import org.oscim.core.MapElement; import org.oscim.core.MapElement;
import org.oscim.core.MapPosition; import org.oscim.core.MapPosition;
@@ -42,34 +46,40 @@ import org.oscim.layers.tile.vector.labeling.LabelLayer;
import org.oscim.renderer.BitmapRenderer; import org.oscim.renderer.BitmapRenderer;
import org.oscim.renderer.GLViewport; import org.oscim.renderer.GLViewport;
import org.oscim.renderer.bucket.RenderBuckets; import org.oscim.renderer.bucket.RenderBuckets;
import org.oscim.scalebar.DefaultMapScaleBar; import org.oscim.scalebar.*;
import org.oscim.scalebar.ImperialUnitAdapter; import org.oscim.theme.*;
import org.oscim.scalebar.MapScaleBar;
import org.oscim.scalebar.MapScaleBarLayer;
import org.oscim.scalebar.MetricUnitAdapter;
import org.oscim.theme.ExternalRenderTheme;
import org.oscim.theme.ThemeUtils;
import org.oscim.theme.VtmThemes;
import org.oscim.theme.styles.AreaStyle; import org.oscim.theme.styles.AreaStyle;
import org.oscim.theme.styles.RenderStyle; import org.oscim.theme.styles.RenderStyle;
import org.oscim.tiling.source.mapfile.MapFileTileSource; import org.oscim.tiling.source.mapfile.MapFileTileSource;
import org.oscim.tiling.source.mapfile.MapInfo; import org.oscim.tiling.source.mapfile.MapInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.List;
import java.util.zip.ZipInputStream;
public class MapsforgeActivity extends MapActivity { public class MapsforgeActivity extends MapActivity {
private static final Logger log = LoggerFactory.getLogger(MapsforgeActivity.class);
static final int SELECT_MAP_FILE = 0; static final int SELECT_MAP_FILE = 0;
static final int SELECT_THEME_FILE = SELECT_MAP_FILE + 1; private static final int SELECT_THEME_ARCHIVE = 1;
private static final int SELECT_THEME_DIR = 2;
static final int SELECT_THEME_FILE = 3;
private static final Tag ISSEA_TAG = new Tag("natural", "issea"); private static final Tag ISSEA_TAG = new Tag("natural", "issea");
private static final Tag NOSEA_TAG = new Tag("natural", "nosea"); private static final Tag NOSEA_TAG = new Tag("natural", "nosea");
private static final Tag SEA_TAG = new Tag("natural", "sea"); private static final Tag SEA_TAG = new Tag("natural", "sea");
private TileGridLayer mGridLayer; private TileGridLayer mGridLayer;
private DefaultMapScaleBar mMapScaleBar;
private Menu mMenu; private Menu mMenu;
private boolean mS3db; private final boolean mS3db;
private VectorTileLayer mTileLayer; IRenderTheme mTheme;
MapFileTileSource mTileSource; VectorTileLayer mTileLayer;
private Uri mThemeDirUri;
public MapsforgeActivity() { public MapsforgeActivity() {
this(false); this(false);
@@ -89,30 +99,10 @@ public class MapsforgeActivity extends MapActivity {
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
startActivityForResult(new Intent(this, MapFilePicker.class), Intent intent = new Intent(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT ? Intent.ACTION_OPEN_DOCUMENT : Intent.ACTION_GET_CONTENT);
SELECT_MAP_FILE); intent.addCategory(Intent.CATEGORY_OPENABLE);
} intent.setType("*/*");
startActivityForResult(intent, SELECT_MAP_FILE);
@Override
protected void onDestroy() {
if (mMapScaleBar != null)
mMapScaleBar.destroy();
super.onDestroy();
}
public static class MapFilePicker extends FilePicker {
public MapFilePicker() {
setFileDisplayFilter(new FilterByFileExtension(".map"));
setFileSelectFilter(new ValidMapFile());
}
}
public static class ThemeFilePicker extends FilePicker {
public ThemeFilePicker() {
setFileDisplayFilter(new FilterByFileExtension(".xml"));
setFileSelectFilter(new ValidRenderTheme());
}
} }
@Override @Override
@@ -127,33 +117,53 @@ public class MapsforgeActivity extends MapActivity {
switch (item.getItemId()) { switch (item.getItemId()) {
case R.id.theme_default: case R.id.theme_default:
mMap.setTheme(VtmThemes.DEFAULT); if (mTheme != null)
mTheme.dispose();
mTheme = mMap.setTheme(VtmThemes.DEFAULT);
item.setChecked(true); item.setChecked(true);
return true; return true;
case R.id.theme_osmarender: case R.id.theme_osmarender:
mMap.setTheme(VtmThemes.OSMARENDER); if (mTheme != null)
mTheme.dispose();
mTheme = mMap.setTheme(VtmThemes.OSMARENDER);
item.setChecked(true); item.setChecked(true);
return true; return true;
case R.id.theme_osmagray: case R.id.theme_osmagray:
mMap.setTheme(VtmThemes.OSMAGRAY); if (mTheme != null)
mTheme.dispose();
mTheme = mMap.setTheme(VtmThemes.OSMAGRAY);
item.setChecked(true); item.setChecked(true);
return true; return true;
case R.id.theme_tubes: case R.id.theme_tubes:
mMap.setTheme(VtmThemes.TRONRENDER); if (mTheme != null)
mTheme.dispose();
mTheme = mMap.setTheme(VtmThemes.TRONRENDER);
item.setChecked(true); item.setChecked(true);
return true; return true;
case R.id.theme_newtron: case R.id.theme_newtron:
mMap.setTheme(VtmThemes.NEWTRON); if (mTheme != null)
mTheme.dispose();
mTheme = mMap.setTheme(VtmThemes.NEWTRON);
item.setChecked(true); item.setChecked(true);
return true; return true;
case R.id.theme_external_archive:
Intent intent = new Intent(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT ? Intent.ACTION_OPEN_DOCUMENT : Intent.ACTION_GET_CONTENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("*/*");
startActivityForResult(intent, SELECT_THEME_ARCHIVE);
return true;
case R.id.theme_external: case R.id.theme_external:
startActivityForResult(new Intent(this, ThemeFilePicker.class), if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
SELECT_THEME_FILE); return false;
intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivityForResult(intent, SELECT_THEME_DIR);
return true; return true;
case R.id.gridlayer: case R.id.gridlayer:
@@ -175,20 +185,23 @@ public class MapsforgeActivity extends MapActivity {
} }
@Override @Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) { protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == SELECT_MAP_FILE) { if (requestCode == SELECT_MAP_FILE) {
if (resultCode != RESULT_OK || intent == null || intent.getStringExtra(FilePicker.SELECTED_FILE) == null) { if (resultCode != Activity.RESULT_OK || data == null) {
finish(); finish();
return; return;
} }
mTileSource = new MapFileTileSource(); try {
//mTileSource.setPreferredLanguage("en"); Uri uri = data.getData();
String file = intent.getStringExtra(FilePicker.SELECTED_FILE);
if (mTileSource.setMapFile(file)) {
mTileLayer = mMap.setBaseMap(mTileSource); MapFileTileSource tileSource = new MapFileTileSource();
//tileSource.setPreferredLanguage("en");
FileInputStream fis = (FileInputStream) getContentResolver().openInputStream(uri);
tileSource.setMapFileInputStream(fis);
mTileLayer = mMap.setBaseMap(tileSource);
loadTheme(null); loadTheme(null);
if (mS3db) if (mS3db)
@@ -197,58 +210,114 @@ public class MapsforgeActivity extends MapActivity {
mMap.layers().add(new BuildingLayer(mMap, mTileLayer)); mMap.layers().add(new BuildingLayer(mMap, mTileLayer));
mMap.layers().add(new LabelLayer(mMap, mTileLayer)); mMap.layers().add(new LabelLayer(mMap, mTileLayer));
mMapScaleBar = new DefaultMapScaleBar(mMap); DefaultMapScaleBar mapScaleBar = new DefaultMapScaleBar(mMap);
mMapScaleBar.setScaleBarMode(DefaultMapScaleBar.ScaleBarMode.BOTH); mapScaleBar.setScaleBarMode(DefaultMapScaleBar.ScaleBarMode.BOTH);
mMapScaleBar.setDistanceUnitAdapter(MetricUnitAdapter.INSTANCE); mapScaleBar.setDistanceUnitAdapter(MetricUnitAdapter.INSTANCE);
mMapScaleBar.setSecondaryDistanceUnitAdapter(ImperialUnitAdapter.INSTANCE); mapScaleBar.setSecondaryDistanceUnitAdapter(ImperialUnitAdapter.INSTANCE);
mMapScaleBar.setScaleBarPosition(MapScaleBar.ScaleBarPosition.BOTTOM_LEFT); mapScaleBar.setScaleBarPosition(MapScaleBar.ScaleBarPosition.BOTTOM_LEFT);
MapScaleBarLayer mapScaleBarLayer = new MapScaleBarLayer(mMap, mMapScaleBar); MapScaleBarLayer mapScaleBarLayer = new MapScaleBarLayer(mMap, mapScaleBar);
BitmapRenderer renderer = mapScaleBarLayer.getRenderer(); BitmapRenderer renderer = mapScaleBarLayer.getRenderer();
renderer.setPosition(GLViewport.Position.BOTTOM_LEFT); renderer.setPosition(GLViewport.Position.BOTTOM_LEFT);
renderer.setOffset(5 * CanvasAdapter.getScale(), 0); renderer.setOffset(5 * CanvasAdapter.getScale(), 0);
mMap.layers().add(mapScaleBarLayer); mMap.layers().add(mapScaleBarLayer);
MapInfo info = mTileSource.getMapInfo(); MapInfo info = tileSource.getMapInfo();
if (!info.boundingBox.contains(mMap.getMapPosition().getGeoPoint())) { if (!info.boundingBox.contains(mMap.getMapPosition().getGeoPoint())) {
MapPosition pos = new MapPosition(); MapPosition pos = new MapPosition();
pos.setByBoundingBox(info.boundingBox, Tile.SIZE * 4, Tile.SIZE * 4); pos.setByBoundingBox(info.boundingBox, Tile.SIZE * 4, Tile.SIZE * 4);
mMap.setMapPosition(pos); mMap.setMapPosition(pos);
mPrefs.clear(); mPrefs.clear();
} }
} catch (Exception e) {
log.error(e.getMessage());
finish();
} }
} else if (requestCode == SELECT_THEME_FILE) { } else if (requestCode == SELECT_THEME_ARCHIVE) {
if (resultCode != RESULT_OK || intent == null || intent.getStringExtra(FilePicker.SELECTED_FILE) == null) { if (resultCode != Activity.RESULT_OK || data == null)
return; return;
}
String file = intent.getStringExtra(FilePicker.SELECTED_FILE); try {
ExternalRenderTheme externalRenderTheme = new ExternalRenderTheme(file); final Uri uri = data.getData();
// Use tessellation with sea and land for Mapsforge themes final List<String> xmlThemes = ZipXmlThemeResourceProvider.scanXmlThemes(new ZipInputStream(new BufferedInputStream(getContentResolver().openInputStream(uri))));
if (ThemeUtils.isMapsforgeTheme(externalRenderTheme)) { if (xmlThemes.isEmpty())
mTileLayer.addHook(new VectorTileLayer.TileLoaderThemeHook() { return;
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.dialog_theme_title);
builder.setSingleChoiceItems(xmlThemes.toArray(new String[0]), -1, new DialogInterface.OnClickListener() {
@Override @Override
public boolean process(MapTile tile, RenderBuckets buckets, MapElement element, RenderStyle style, int level) { public void onClick(DialogInterface dialog, int which) {
if (element.tags.contains(ISSEA_TAG) || element.tags.contains(SEA_TAG) || element.tags.contains(NOSEA_TAG)) { try {
if (style instanceof AreaStyle) dialog.dismiss();
((AreaStyle) style).mesh = true; ThemeFile theme = new ZipRenderTheme(xmlThemes.get(which), new ZipXmlThemeResourceProvider(new ZipInputStream(new BufferedInputStream(getContentResolver().openInputStream(uri)))));
if (mTheme != null)
mTheme.dispose();
mTheme = mMap.setTheme(theme);
mapsforgeTheme(mTheme);
mMenu.findItem(R.id.theme_external_archive).setChecked(true);
} catch (IOException e) {
e.printStackTrace();
} }
return false;
}
@Override
public void complete(MapTile tile, boolean success) {
} }
}); });
builder.show();
} catch (IOException e) {
e.printStackTrace();
} }
} else if (requestCode == SELECT_THEME_DIR) {
if (resultCode != Activity.RESULT_OK || data == null)
return;
mMap.setTheme(externalRenderTheme); mThemeDirUri = data.getData();
// Now we have the directory for resources, but we need to let the user also select a theme file
Intent intent = new Intent(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT ? Intent.ACTION_OPEN_DOCUMENT : Intent.ACTION_GET_CONTENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("*/*");
intent.putExtra(DocumentsContract.EXTRA_INITIAL_URI, mThemeDirUri);
startActivityForResult(intent, SELECT_THEME_FILE);
} else if (requestCode == SELECT_THEME_FILE) {
if (resultCode != Activity.RESULT_OK || data == null)
return;
Uri uri = data.getData();
ThemeFile theme = new ContentRenderTheme(getContentResolver(), uri);
theme.setResourceProvider(new ContentResolverResourceProvider(getContentResolver(), mThemeDirUri));
if (mTheme != null)
mTheme.dispose();
mTheme = mMap.setTheme(theme);
mapsforgeTheme(mTheme);
mMenu.findItem(R.id.theme_external).setChecked(true); mMenu.findItem(R.id.theme_external).setChecked(true);
} }
} }
protected void loadTheme(final String styleId) { protected void loadTheme(final String styleId) {
mMap.setTheme(VtmThemes.DEFAULT); if (mTheme != null)
mTheme.dispose();
mTheme = mMap.setTheme(VtmThemes.DEFAULT);
}
private void mapsforgeTheme(IRenderTheme theme) {
if (!theme.isMapsforgeTheme())
return;
// Use tessellation with sea and land for Mapsforge themes
mTileLayer.addHook(new VectorTileLayer.TileLoaderThemeHook() {
@Override
public boolean process(MapTile tile, RenderBuckets buckets, MapElement element, RenderStyle style, int level) {
if (element.tags.contains(ISSEA_TAG) || element.tags.contains(SEA_TAG) || element.tags.contains(NOSEA_TAG)) {
if (style instanceof AreaStyle)
((AreaStyle) style).mesh = true;
}
return false;
}
@Override
public void complete(MapTile tile, boolean success) {
}
});
} }
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2016-2017 devemux86 * Copyright 2016-2020 devemux86
* *
* This program is free software: you can redistribute it and/or modify it under the * 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 * terms of the GNU Lesser General Public License as published by the Free Software
@@ -17,7 +17,6 @@ package org.oscim.android.test;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.widget.Toast; import android.widget.Toast;
import org.oscim.android.theme.AssetsRenderTheme; import org.oscim.android.theme.AssetsRenderTheme;
import org.oscim.theme.XmlRenderThemeMenuCallback; import org.oscim.theme.XmlRenderThemeMenuCallback;
import org.oscim.theme.XmlRenderThemeStyleLayer; import org.oscim.theme.XmlRenderThemeStyleLayer;
@@ -58,7 +57,9 @@ public class MapsforgeStyleActivity extends MapsforgeActivity {
@Override @Override
protected void loadTheme(final String styleId) { protected void loadTheme(final String styleId) {
mMap.setTheme(new AssetsRenderTheme(getAssets(), "", "vtm/stylemenu.xml", new XmlRenderThemeMenuCallback() { if (mTheme != null)
mTheme.dispose();
mTheme = mMap.setTheme(new AssetsRenderTheme(getAssets(), "", "vtm/stylemenu.xml", new XmlRenderThemeMenuCallback() {
@Override @Override
public Set<String> getCategories(XmlRenderThemeStyleMenu renderThemeStyleMenu) { public Set<String> getCategories(XmlRenderThemeStyleMenu renderThemeStyleMenu) {
// Use the selected style or the default // Use the selected style or the default

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2017-2018 devemux86 * Copyright 2017-2020 devemux86
* *
* This program is free software: you can redistribute it and/or modify it under the * 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 * terms of the GNU Lesser General Public License as published by the Free Software
@@ -15,8 +15,8 @@
package org.oscim.android.test; package org.oscim.android.test;
import android.os.Bundle; import android.os.Bundle;
import okhttp3.Cache;
import org.oscim.android.cache.TileCache; import okhttp3.OkHttpClient;
import org.oscim.layers.tile.buildings.BuildingLayer; import org.oscim.layers.tile.buildings.BuildingLayer;
import org.oscim.layers.tile.vector.VectorTileLayer; import org.oscim.layers.tile.vector.VectorTileLayer;
import org.oscim.layers.tile.vector.labeling.LabelLayer; import org.oscim.layers.tile.vector.labeling.LabelLayer;
@@ -25,41 +25,35 @@ import org.oscim.tiling.source.OkHttpEngine;
import org.oscim.tiling.source.UrlTileSource; import org.oscim.tiling.source.UrlTileSource;
import org.oscim.tiling.source.geojson.MapzenGeojsonTileSource; import org.oscim.tiling.source.geojson.MapzenGeojsonTileSource;
import java.io.File;
public class MapzenGeojsonActivity extends MapActivity { public class MapzenGeojsonActivity extends MapActivity {
private static final boolean USE_CACHE = false; private static final boolean USE_CACHE = false;
private TileCache mCache;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
OkHttpClient.Builder builder = new OkHttpClient.Builder();
if (USE_CACHE) {
// Cache the tiles into file system
File cacheDirectory = new File(getExternalCacheDir(), "tiles");
int cacheSize = 10 * 1024 * 1024; // 10 MB
Cache cache = new Cache(cacheDirectory, cacheSize);
builder.cache(cache);
}
UrlTileSource tileSource = MapzenGeojsonTileSource.builder() UrlTileSource tileSource = MapzenGeojsonTileSource.builder()
.apiKey("xxxxxxx") // Put a proper API key .apiKey("xxxxxxx") // Put a proper API key
.httpFactory(new OkHttpEngine.OkHttpFactory()) .httpFactory(new OkHttpEngine.OkHttpFactory(builder))
//.locale("en") //.locale("en")
.build(); .build();
if (USE_CACHE) {
// Cache the tiles into a local SQLite database
mCache = new TileCache(this, null, "tile.db");
mCache.setCacheSize(512 * (1 << 10));
tileSource.setCache(mCache);
}
VectorTileLayer l = mMap.setBaseMap(tileSource); VectorTileLayer l = mMap.setBaseMap(tileSource);
mMap.setTheme(VtmThemes.MAPZEN); mMap.setTheme(VtmThemes.MAPZEN);
mMap.layers().add(new BuildingLayer(mMap, l)); mMap.layers().add(new BuildingLayer(mMap, l));
mMap.layers().add(new LabelLayer(mMap, l)); mMap.layers().add(new LabelLayer(mMap, l));
} }
@Override
protected void onDestroy() {
super.onDestroy();
if (mCache != null)
mCache.dispose();
}
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2016-2018 devemux86 * Copyright 2016-2020 devemux86
* Copyright 2017 Mathieu De Brito * Copyright 2017 Mathieu De Brito
* *
* This program is free software: you can redistribute it and/or modify it under the * This program is free software: you can redistribute it and/or modify it under the
@@ -16,8 +16,8 @@
package org.oscim.android.test; package org.oscim.android.test;
import android.os.Bundle; import android.os.Bundle;
import okhttp3.Cache;
import org.oscim.android.cache.TileCache; import okhttp3.OkHttpClient;
import org.oscim.layers.tile.buildings.BuildingLayer; import org.oscim.layers.tile.buildings.BuildingLayer;
import org.oscim.layers.tile.vector.VectorTileLayer; import org.oscim.layers.tile.vector.VectorTileLayer;
import org.oscim.layers.tile.vector.labeling.LabelLayer; import org.oscim.layers.tile.vector.labeling.LabelLayer;
@@ -26,41 +26,35 @@ import org.oscim.tiling.source.OkHttpEngine;
import org.oscim.tiling.source.UrlTileSource; import org.oscim.tiling.source.UrlTileSource;
import org.oscim.tiling.source.mvt.MapzenMvtTileSource; import org.oscim.tiling.source.mvt.MapzenMvtTileSource;
import java.io.File;
public class MapzenMvtActivity extends MapActivity { public class MapzenMvtActivity extends MapActivity {
private static final boolean USE_CACHE = false; private static final boolean USE_CACHE = false;
private TileCache mCache;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
OkHttpClient.Builder builder = new OkHttpClient.Builder();
if (USE_CACHE) {
// Cache the tiles into file system
File cacheDirectory = new File(getExternalCacheDir(), "tiles");
int cacheSize = 10 * 1024 * 1024; // 10 MB
Cache cache = new Cache(cacheDirectory, cacheSize);
builder.cache(cache);
}
UrlTileSource tileSource = MapzenMvtTileSource.builder() UrlTileSource tileSource = MapzenMvtTileSource.builder()
.apiKey("xxxxxxx") // Put a proper API key .apiKey("xxxxxxx") // Put a proper API key
.httpFactory(new OkHttpEngine.OkHttpFactory()) .httpFactory(new OkHttpEngine.OkHttpFactory(builder))
//.locale("en") //.locale("en")
.build(); .build();
if (USE_CACHE) {
// Cache the tiles into a local SQLite database
mCache = new TileCache(this, null, "tile.db");
mCache.setCacheSize(512 * (1 << 10));
tileSource.setCache(mCache);
}
VectorTileLayer l = mMap.setBaseMap(tileSource); VectorTileLayer l = mMap.setBaseMap(tileSource);
mMap.setTheme(VtmThemes.MAPZEN); mMap.setTheme(VtmThemes.MAPZEN);
mMap.layers().add(new BuildingLayer(mMap, l)); mMap.layers().add(new BuildingLayer(mMap, l));
mMap.layers().add(new LabelLayer(mMap, l)); mMap.layers().add(new LabelLayer(mMap, l));
} }
@Override
protected void onDestroy() {
super.onDestroy();
if (mCache != null)
mCache.dispose();
}
} }

View File

@@ -1,6 +1,6 @@
/* /*
* Copyright 2014 Hannes Janetzek * Copyright 2014 Hannes Janetzek
* Copyright 2016-2018 devemux86 * Copyright 2016-2020 devemux86
* *
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org). * This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
* *
@@ -17,9 +17,10 @@
*/ */
package org.oscim.android.test; package org.oscim.android.test;
import android.graphics.BitmapFactory;
import android.os.Bundle; import android.os.Bundle;
import android.widget.Toast; import android.widget.Toast;
import org.oscim.android.canvas.AndroidBitmap;
import org.oscim.backend.canvas.Bitmap; import org.oscim.backend.canvas.Bitmap;
import org.oscim.core.GeoPoint; import org.oscim.core.GeoPoint;
import org.oscim.event.Gesture; import org.oscim.event.Gesture;
@@ -27,26 +28,25 @@ import org.oscim.event.GestureListener;
import org.oscim.event.MotionEvent; import org.oscim.event.MotionEvent;
import org.oscim.layers.Layer; import org.oscim.layers.Layer;
import org.oscim.layers.marker.ItemizedLayer; import org.oscim.layers.marker.ItemizedLayer;
import org.oscim.layers.marker.MarkerInterface;
import org.oscim.layers.marker.MarkerItem; import org.oscim.layers.marker.MarkerItem;
import org.oscim.layers.marker.MarkerSymbol; import org.oscim.layers.marker.MarkerSymbol;
import org.oscim.layers.marker.MarkerSymbol.HotspotPlace; import org.oscim.layers.marker.MarkerSymbol.HotspotPlace;
import org.oscim.layers.tile.bitmap.BitmapTileLayer; import org.oscim.layers.tile.bitmap.BitmapTileLayer;
import org.oscim.map.Map; import org.oscim.map.Map;
import org.oscim.tiling.TileSource;
import org.oscim.tiling.source.OkHttpEngine; import org.oscim.tiling.source.OkHttpEngine;
import org.oscim.tiling.source.UrlTileSource;
import org.oscim.tiling.source.bitmap.DefaultSources; import org.oscim.tiling.source.bitmap.DefaultSources;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
import static org.oscim.android.canvas.AndroidGraphics.drawableToBitmap; public class MarkerOverlayActivity extends MapActivity implements ItemizedLayer.OnItemGestureListener<MarkerInterface> {
public class MarkerOverlayActivity extends MapActivity
implements ItemizedLayer.OnItemGestureListener<MarkerItem> {
static final boolean BILLBOARDS = true; static final boolean BILLBOARDS = true;
MarkerSymbol mFocusMarker; MarkerSymbol mFocusMarker;
ItemizedLayer<MarkerItem> mMarkerLayer; ItemizedLayer mMarkerLayer;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
@@ -59,28 +59,29 @@ public class MarkerOverlayActivity extends MapActivity
// Map events receiver // Map events receiver
mMap.layers().add(new MapEventsReceiver(mMap)); mMap.layers().add(new MapEventsReceiver(mMap));
TileSource tileSource = DefaultSources.OPENSTREETMAP UrlTileSource tileSource = DefaultSources.OPENSTREETMAP
.httpFactory(new OkHttpEngine.OkHttpFactory()) .httpFactory(new OkHttpEngine.OkHttpFactory())
.build(); .build();
tileSource.setHttpRequestHeaders(Collections.singletonMap("User-Agent", "vtm-android-example"));
mMap.layers().add(new BitmapTileLayer(mMap, tileSource)); mMap.layers().add(new BitmapTileLayer(mMap, tileSource));
Bitmap bitmapPoi = drawableToBitmap(getResources().getDrawable(R.drawable.marker_poi)); Bitmap bitmapPoi = new AndroidBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.marker_poi));
MarkerSymbol symbol; MarkerSymbol symbol;
if (BILLBOARDS) if (BILLBOARDS)
symbol = new MarkerSymbol(bitmapPoi, HotspotPlace.BOTTOM_CENTER); symbol = new MarkerSymbol(bitmapPoi, HotspotPlace.BOTTOM_CENTER);
else else
symbol = new MarkerSymbol(bitmapPoi, HotspotPlace.CENTER, false); symbol = new MarkerSymbol(bitmapPoi, HotspotPlace.CENTER, false);
Bitmap bitmapFocus = drawableToBitmap(getResources().getDrawable(R.drawable.marker_focus)); Bitmap bitmapFocus = new AndroidBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.marker_focus));
if (BILLBOARDS) if (BILLBOARDS)
mFocusMarker = new MarkerSymbol(bitmapFocus, HotspotPlace.BOTTOM_CENTER); mFocusMarker = new MarkerSymbol(bitmapFocus, HotspotPlace.BOTTOM_CENTER);
else else
mFocusMarker = new MarkerSymbol(bitmapFocus, HotspotPlace.CENTER, false); mFocusMarker = new MarkerSymbol(bitmapFocus, HotspotPlace.CENTER, false);
mMarkerLayer = new ItemizedLayer<>(mMap, new ArrayList<MarkerItem>(), symbol, this); mMarkerLayer = new ItemizedLayer(mMap, new ArrayList<MarkerInterface>(), symbol, this);
mMap.layers().add(mMarkerLayer); mMap.layers().add(mMarkerLayer);
List<MarkerItem> pts = new ArrayList<>(); List<MarkerInterface> pts = new ArrayList<>();
for (double lat = -90; lat <= 90; lat += 5) { for (double lat = -90; lat <= 90; lat += 5) {
for (double lon = -180; lon <= 180; lon += 5) for (double lon = -180; lon <= 180; lon += 5)
@@ -99,24 +100,26 @@ public class MarkerOverlayActivity extends MapActivity
} }
@Override @Override
public boolean onItemSingleTapUp(int index, MarkerItem item) { public boolean onItemSingleTapUp(int index, MarkerInterface item) {
if (item.getMarker() == null) MarkerItem markerItem = (MarkerItem) item;
item.setMarker(mFocusMarker); if (markerItem.getMarker() == null)
markerItem.setMarker(mFocusMarker);
else else
item.setMarker(null); markerItem.setMarker(null);
Toast.makeText(this, "Marker tap\n" + item.getTitle(), Toast.LENGTH_SHORT).show(); Toast.makeText(this, "Marker tap\n" + markerItem.getTitle(), Toast.LENGTH_SHORT).show();
return true; return true;
} }
@Override @Override
public boolean onItemLongPress(int index, MarkerItem item) { public boolean onItemLongPress(int index, MarkerInterface item) {
if (item.getMarker() == null) MarkerItem markerItem = (MarkerItem) item;
item.setMarker(mFocusMarker); if (markerItem.getMarker() == null)
markerItem.setMarker(mFocusMarker);
else else
item.setMarker(null); markerItem.setMarker(null);
Toast.makeText(this, "Marker long press\n" + item.getTitle(), Toast.LENGTH_SHORT).show(); Toast.makeText(this, "Marker long press\n" + markerItem.getTitle(), Toast.LENGTH_SHORT).show();
return true; return true;
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2018 devemux86 * Copyright 2018-2020 devemux86
* *
* This program is free software: you can redistribute it and/or modify it under the * 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 * terms of the GNU Lesser General Public License as published by the Free Software
@@ -15,8 +15,8 @@
package org.oscim.android.test; package org.oscim.android.test;
import android.os.Bundle; import android.os.Bundle;
import okhttp3.Cache;
import org.oscim.android.cache.TileCache; import okhttp3.OkHttpClient;
import org.oscim.layers.tile.buildings.BuildingLayer; import org.oscim.layers.tile.buildings.BuildingLayer;
import org.oscim.layers.tile.vector.VectorTileLayer; import org.oscim.layers.tile.vector.VectorTileLayer;
import org.oscim.layers.tile.vector.labeling.LabelLayer; import org.oscim.layers.tile.vector.labeling.LabelLayer;
@@ -25,41 +25,35 @@ import org.oscim.tiling.source.OkHttpEngine;
import org.oscim.tiling.source.UrlTileSource; import org.oscim.tiling.source.UrlTileSource;
import org.oscim.tiling.source.geojson.NextzenGeojsonTileSource; import org.oscim.tiling.source.geojson.NextzenGeojsonTileSource;
import java.io.File;
public class NextzenGeojsonActivity extends MapActivity { public class NextzenGeojsonActivity extends MapActivity {
private static final boolean USE_CACHE = false; private static final boolean USE_CACHE = false;
private TileCache mCache;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
OkHttpClient.Builder builder = new OkHttpClient.Builder();
if (USE_CACHE) {
// Cache the tiles into file system
File cacheDirectory = new File(getExternalCacheDir(), "tiles");
int cacheSize = 10 * 1024 * 1024; // 10 MB
Cache cache = new Cache(cacheDirectory, cacheSize);
builder.cache(cache);
}
UrlTileSource tileSource = NextzenGeojsonTileSource.builder() UrlTileSource tileSource = NextzenGeojsonTileSource.builder()
.apiKey("xxxxxxx") // Put a proper API key .apiKey("xxxxxxx") // Put a proper API key
.httpFactory(new OkHttpEngine.OkHttpFactory()) .httpFactory(new OkHttpEngine.OkHttpFactory(builder))
//.locale("en") //.locale("en")
.build(); .build();
if (USE_CACHE) {
// Cache the tiles into a local SQLite database
mCache = new TileCache(this, null, "tile.db");
mCache.setCacheSize(512 * (1 << 10));
tileSource.setCache(mCache);
}
VectorTileLayer l = mMap.setBaseMap(tileSource); VectorTileLayer l = mMap.setBaseMap(tileSource);
mMap.setTheme(VtmThemes.MAPZEN); mMap.setTheme(VtmThemes.MAPZEN);
mMap.layers().add(new BuildingLayer(mMap, l)); mMap.layers().add(new BuildingLayer(mMap, l));
mMap.layers().add(new LabelLayer(mMap, l)); mMap.layers().add(new LabelLayer(mMap, l));
} }
@Override
protected void onDestroy() {
super.onDestroy();
if (mCache != null)
mCache.dispose();
}
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2018 devemux86 * Copyright 2018-2020 devemux86
* *
* This program is free software: you can redistribute it and/or modify it under the * 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 * terms of the GNU Lesser General Public License as published by the Free Software
@@ -15,8 +15,8 @@
package org.oscim.android.test; package org.oscim.android.test;
import android.os.Bundle; import android.os.Bundle;
import okhttp3.Cache;
import org.oscim.android.cache.TileCache; import okhttp3.OkHttpClient;
import org.oscim.layers.tile.buildings.BuildingLayer; import org.oscim.layers.tile.buildings.BuildingLayer;
import org.oscim.layers.tile.vector.VectorTileLayer; import org.oscim.layers.tile.vector.VectorTileLayer;
import org.oscim.layers.tile.vector.labeling.LabelLayer; import org.oscim.layers.tile.vector.labeling.LabelLayer;
@@ -25,41 +25,35 @@ import org.oscim.tiling.source.OkHttpEngine;
import org.oscim.tiling.source.UrlTileSource; import org.oscim.tiling.source.UrlTileSource;
import org.oscim.tiling.source.mvt.NextzenMvtTileSource; import org.oscim.tiling.source.mvt.NextzenMvtTileSource;
import java.io.File;
public class NextzenMvtActivity extends MapActivity { public class NextzenMvtActivity extends MapActivity {
private static final boolean USE_CACHE = false; private static final boolean USE_CACHE = false;
private TileCache mCache;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
OkHttpClient.Builder builder = new OkHttpClient.Builder();
if (USE_CACHE) {
// Cache the tiles into file system
File cacheDirectory = new File(getExternalCacheDir(), "tiles");
int cacheSize = 10 * 1024 * 1024; // 10 MB
Cache cache = new Cache(cacheDirectory, cacheSize);
builder.cache(cache);
}
UrlTileSource tileSource = NextzenMvtTileSource.builder() UrlTileSource tileSource = NextzenMvtTileSource.builder()
.apiKey("xxxxxxx") // Put a proper API key .apiKey("xxxxxxx") // Put a proper API key
.httpFactory(new OkHttpEngine.OkHttpFactory()) .httpFactory(new OkHttpEngine.OkHttpFactory(builder))
//.locale("en") //.locale("en")
.build(); .build();
if (USE_CACHE) {
// Cache the tiles into a local SQLite database
mCache = new TileCache(this, null, "tile.db");
mCache.setCacheSize(512 * (1 << 10));
tileSource.setCache(mCache);
}
VectorTileLayer l = mMap.setBaseMap(tileSource); VectorTileLayer l = mMap.setBaseMap(tileSource);
mMap.setTheme(VtmThemes.MAPZEN); mMap.setTheme(VtmThemes.MAPZEN);
mMap.layers().add(new BuildingLayer(mMap, l)); mMap.layers().add(new BuildingLayer(mMap, l));
mMap.layers().add(new LabelLayer(mMap, l)); mMap.layers().add(new LabelLayer(mMap, l));
} }
@Override
protected void onDestroy() {
super.onDestroy();
if (mCache != null)
mCache.dispose();
}
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2016-2018 devemux86 * Copyright 2016-2020 devemux86
* *
* This program is free software: you can redistribute it and/or modify it under the * 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 * terms of the GNU Lesser General Public License as published by the Free Software
@@ -15,8 +15,8 @@
package org.oscim.android.test; package org.oscim.android.test;
import android.os.Bundle; import android.os.Bundle;
import okhttp3.Cache;
import org.oscim.android.cache.TileCache; import okhttp3.OkHttpClient;
import org.oscim.layers.tile.buildings.BuildingLayer; import org.oscim.layers.tile.buildings.BuildingLayer;
import org.oscim.layers.tile.vector.VectorTileLayer; import org.oscim.layers.tile.vector.VectorTileLayer;
import org.oscim.layers.tile.vector.labeling.LabelLayer; import org.oscim.layers.tile.vector.labeling.LabelLayer;
@@ -25,41 +25,35 @@ import org.oscim.tiling.source.OkHttpEngine;
import org.oscim.tiling.source.UrlTileSource; import org.oscim.tiling.source.UrlTileSource;
import org.oscim.tiling.source.mvt.OpenMapTilesMvtTileSource; import org.oscim.tiling.source.mvt.OpenMapTilesMvtTileSource;
import java.io.File;
public class OpenMapTilesMvtActivity extends MapActivity { public class OpenMapTilesMvtActivity extends MapActivity {
private static final boolean USE_CACHE = false; private static final boolean USE_CACHE = false;
private TileCache mCache;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
OkHttpClient.Builder builder = new OkHttpClient.Builder();
if (USE_CACHE) {
// Cache the tiles into file system
File cacheDirectory = new File(getExternalCacheDir(), "tiles");
int cacheSize = 10 * 1024 * 1024; // 10 MB
Cache cache = new Cache(cacheDirectory, cacheSize);
builder.cache(cache);
}
UrlTileSource tileSource = OpenMapTilesMvtTileSource.builder() UrlTileSource tileSource = OpenMapTilesMvtTileSource.builder()
.apiKey("xxxxxxx") // Put a proper API key .apiKey("xxxxxxx") // Put a proper API key
.httpFactory(new OkHttpEngine.OkHttpFactory()) .httpFactory(new OkHttpEngine.OkHttpFactory(builder))
//.locale("en") //.locale("en")
.build(); .build();
if (USE_CACHE) {
// Cache the tiles into a local SQLite database
mCache = new TileCache(this, null, "tile.db");
mCache.setCacheSize(512 * (1 << 10));
tileSource.setCache(mCache);
}
VectorTileLayer l = mMap.setBaseMap(tileSource); VectorTileLayer l = mMap.setBaseMap(tileSource);
mMap.setTheme(VtmThemes.OPENMAPTILES); mMap.setTheme(VtmThemes.OPENMAPTILES);
mMap.layers().add(new BuildingLayer(mMap, l)); mMap.layers().add(new BuildingLayer(mMap, l));
mMap.layers().add(new LabelLayer(mMap, l)); mMap.layers().add(new LabelLayer(mMap, l));
} }
@Override
protected void onDestroy() {
super.onDestroy();
if (mCache != null)
mCache.dispose();
}
} }

View File

@@ -1,5 +1,6 @@
/* /*
* Copyright 2019 Gustl22 * Copyright 2019 Gustl22
* Copyright 2020 devemux86
* *
* This program is free software: you can redistribute it and/or modify it under the * 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 * terms of the GNU Lesser General Public License as published by the Free Software
@@ -15,7 +16,6 @@
package org.oscim.android.test; package org.oscim.android.test;
import android.os.Bundle; import android.os.Bundle;
import org.oscim.layers.tile.bitmap.BitmapTileLayer; import org.oscim.layers.tile.bitmap.BitmapTileLayer;
import org.oscim.layers.tile.buildings.BuildingLayer; import org.oscim.layers.tile.buildings.BuildingLayer;
import org.oscim.layers.tile.buildings.S3DBLayer; import org.oscim.layers.tile.buildings.S3DBLayer;
@@ -25,9 +25,12 @@ import org.oscim.map.Viewport;
import org.oscim.theme.VtmThemes; import org.oscim.theme.VtmThemes;
import org.oscim.tiling.TileSource; import org.oscim.tiling.TileSource;
import org.oscim.tiling.source.OkHttpEngine; import org.oscim.tiling.source.OkHttpEngine;
import org.oscim.tiling.source.UrlTileSource;
import org.oscim.tiling.source.bitmap.DefaultSources; import org.oscim.tiling.source.bitmap.DefaultSources;
import org.oscim.tiling.source.overpass.OverpassTileSource; import org.oscim.tiling.source.overpass.OverpassTileSource;
import java.util.Collections;
/** /**
* Use Overpass API data for vector layer. * Use Overpass API data for vector layer.
* Only for developing as can be error-prone. * Only for developing as can be error-prone.
@@ -46,7 +49,7 @@ public class OverpassActivity extends MapActivity {
.build(); .build();
VectorTileLayer l = mMap.setBaseMap(tileSource); VectorTileLayer l = mMap.setBaseMap(tileSource);
TileSource bitmapTileSource = DefaultSources.OPENSTREETMAP UrlTileSource bitmapTileSource = DefaultSources.OPENSTREETMAP
.httpFactory(new OkHttpEngine.OkHttpFactory()) .httpFactory(new OkHttpEngine.OkHttpFactory())
.zoomMax(15) .zoomMax(15)
.fadeSteps(new BitmapTileLayer.FadeStep[]{ .fadeSteps(new BitmapTileLayer.FadeStep[]{
@@ -54,6 +57,7 @@ public class OverpassActivity extends MapActivity {
new BitmapTileLayer.FadeStep(16, Viewport.MAX_ZOOM_LEVEL, 0f, 0f) new BitmapTileLayer.FadeStep(16, Viewport.MAX_ZOOM_LEVEL, 0f, 0f)
}) })
.build(); .build();
bitmapTileSource.setHttpRequestHeaders(Collections.singletonMap("User-Agent", "vtm-android-example"));
mMap.layers().add(new BitmapTileLayer(mMap, bitmapTileSource)); mMap.layers().add(new BitmapTileLayer(mMap, bitmapTileSource));
BuildingLayer.RAW_DATA = true; BuildingLayer.RAW_DATA = true;

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2017-2018 devemux86 * Copyright 2017-2020 devemux86
* Copyright 2018 Gustl22 * Copyright 2018 Gustl22
* *
* This program is free software: you can redistribute it and/or modify it under the * This program is free software: you can redistribute it and/or modify it under the
@@ -17,6 +17,7 @@ package org.oscim.android.test;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.graphics.BitmapFactory;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.text.Editable; import android.text.Editable;
@@ -25,20 +26,11 @@ import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ArrayAdapter; import android.widget.*;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.Toast;
import android.widget.ToggleButton;
import org.mapsforge.core.model.Tag; import org.mapsforge.core.model.Tag;
import org.mapsforge.poi.android.storage.AndroidPoiPersistenceManagerFactory; import org.mapsforge.poi.android.storage.AndroidPoiPersistenceManagerFactory;
import org.mapsforge.poi.storage.ExactMatchPoiCategoryFilter; import org.mapsforge.poi.storage.*;
import org.mapsforge.poi.storage.PoiCategoryFilter; import org.oscim.android.canvas.AndroidBitmap;
import org.mapsforge.poi.storage.PoiCategoryManager;
import org.mapsforge.poi.storage.PoiPersistenceManager;
import org.mapsforge.poi.storage.PointOfInterest;
import org.oscim.android.filepicker.FilePicker; import org.oscim.android.filepicker.FilePicker;
import org.oscim.android.filepicker.FilterByFileExtension; import org.oscim.android.filepicker.FilterByFileExtension;
import org.oscim.backend.canvas.Bitmap; import org.oscim.backend.canvas.Bitmap;
@@ -49,6 +41,7 @@ import org.oscim.event.GestureListener;
import org.oscim.event.MotionEvent; import org.oscim.event.MotionEvent;
import org.oscim.layers.Layer; import org.oscim.layers.Layer;
import org.oscim.layers.marker.ItemizedLayer; import org.oscim.layers.marker.ItemizedLayer;
import org.oscim.layers.marker.MarkerInterface;
import org.oscim.layers.marker.MarkerItem; import org.oscim.layers.marker.MarkerItem;
import org.oscim.layers.marker.MarkerSymbol; import org.oscim.layers.marker.MarkerSymbol;
import org.oscim.map.Map; import org.oscim.map.Map;
@@ -60,21 +53,19 @@ import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import static org.oscim.android.canvas.AndroidGraphics.drawableToBitmap;
/** /**
* POI search.<br/> * POI search.<br/>
* Long press on map to search inside visible bounding box.<br/> * Long press on map to search inside visible bounding box.<br/>
* Tap on POIs to show their name (in default locale). * Tap on POIs to show their name (in default locale).
*/ */
public class PoiSearchActivity extends MapsforgeActivity implements ItemizedLayer.OnItemGestureListener<MarkerItem> { public class PoiSearchActivity extends MapsforgeActivity implements ItemizedLayer.OnItemGestureListener<MarkerInterface> {
private static final Logger log = LoggerFactory.getLogger(PoiSearchActivity.class); private static final Logger log = LoggerFactory.getLogger(PoiSearchActivity.class);
private static final String POI_CATEGORY = "Restaurants"; private static final String POI_CATEGORY = "Restaurants";
private static final int SELECT_POI_FILE = MapsforgeActivity.SELECT_THEME_FILE + 1; private static final int SELECT_POI_FILE = MapsforgeActivity.SELECT_THEME_FILE + 1;
private ItemizedLayer<MarkerItem> mMarkerLayer; private ItemizedLayer mMarkerLayer;
private PoiPersistenceManager mPersistenceManager; private PoiPersistenceManager mPersistenceManager;
public static class PoiFilePicker extends FilePicker { public static class PoiFilePicker extends FilePicker {
@@ -148,7 +139,7 @@ public class PoiSearchActivity extends MapsforgeActivity implements ItemizedLaye
super.onActivityResult(requestCode, resultCode, intent); super.onActivityResult(requestCode, resultCode, intent);
if (requestCode == SELECT_MAP_FILE) { if (requestCode == SELECT_MAP_FILE) {
if (mTileSource != null) if (mTileLayer.getTileSource() != null)
startActivityForResult(new Intent(this, PoiFilePicker.class), startActivityForResult(new Intent(this, PoiFilePicker.class),
SELECT_POI_FILE); SELECT_POI_FILE);
else else
@@ -162,21 +153,22 @@ public class PoiSearchActivity extends MapsforgeActivity implements ItemizedLaye
String file = intent.getStringExtra(FilePicker.SELECTED_FILE); String file = intent.getStringExtra(FilePicker.SELECTED_FILE);
mPersistenceManager = AndroidPoiPersistenceManagerFactory.getPoiPersistenceManager(file); mPersistenceManager = AndroidPoiPersistenceManagerFactory.getPoiPersistenceManager(file);
Bitmap bitmap = drawableToBitmap(getResources().getDrawable(R.drawable.marker_green)); Bitmap bitmap = new AndroidBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.marker_green));
MarkerSymbol symbol = new MarkerSymbol(bitmap, MarkerSymbol.HotspotPlace.BOTTOM_CENTER); MarkerSymbol symbol = new MarkerSymbol(bitmap, MarkerSymbol.HotspotPlace.BOTTOM_CENTER);
mMarkerLayer = new ItemizedLayer<>(mMap, new ArrayList<MarkerItem>(), symbol, this); mMarkerLayer = new ItemizedLayer(mMap, new ArrayList<MarkerInterface>(), symbol, this);
mMap.layers().add(mMarkerLayer); mMap.layers().add(mMarkerLayer);
} }
} }
@Override @Override
public boolean onItemSingleTapUp(int index, MarkerItem item) { public boolean onItemSingleTapUp(int index, MarkerInterface item) {
Toast.makeText(this, item.getTitle(), Toast.LENGTH_SHORT).show(); MarkerItem markerItem = (MarkerItem) item;
Toast.makeText(this, markerItem.getTitle(), Toast.LENGTH_SHORT).show();
return true; return true;
} }
@Override @Override
public boolean onItemLongPress(int index, MarkerItem item) { public boolean onItemLongPress(int index, MarkerInterface item) {
return false; return false;
} }
@@ -325,7 +317,7 @@ public class PoiSearchActivity extends MapsforgeActivity implements ItemizedLaye
} }
// Overlay POI // Overlay POI
List<MarkerItem> pts = new ArrayList<>(); List<MarkerInterface> pts = new ArrayList<>();
for (PointOfInterest pointOfInterest : pointOfInterests) for (PointOfInterest pointOfInterest : pointOfInterests)
pts.add(new MarkerItem(pointOfInterest.getName(), "", new GeoPoint(pointOfInterest.getLatitude(), pointOfInterest.getLongitude()))); pts.add(new MarkerItem(pointOfInterest.getName(), "", new GeoPoint(pointOfInterest.getLatitude(), pointOfInterest.getLongitude())));
mMarkerLayer.addItems(pts); mMarkerLayer.addItems(pts);

View File

@@ -97,7 +97,7 @@ public class ReverseGeocodeActivity extends MapsforgeActivity {
int tileYMax = MercatorProjection.pixelYToTileY(pixelY + touchRadius, (byte) mMap.getMapPosition().getZoomLevel()); int tileYMax = MercatorProjection.pixelYToTileY(pixelY + touchRadius, (byte) mMap.getMapPosition().getZoomLevel());
Tile upperLeft = new Tile(tileXMin, tileYMin, (byte) mMap.getMapPosition().getZoomLevel()); Tile upperLeft = new Tile(tileXMin, tileYMin, (byte) mMap.getMapPosition().getZoomLevel());
Tile lowerRight = new Tile(tileXMax, tileYMax, (byte) mMap.getMapPosition().getZoomLevel()); Tile lowerRight = new Tile(tileXMax, tileYMax, (byte) mMap.getMapPosition().getZoomLevel());
MapReadResult mapReadResult = ((MapDatabase) ((OverzoomTileDataSource) mTileSource.getDataSource()).getDataSource()).readLabels(upperLeft, lowerRight); MapReadResult mapReadResult = ((MapDatabase) ((OverzoomTileDataSource) mTileLayer.getTileSource().getDataSource()).getDataSource()).readLabels(upperLeft, lowerRight);
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();

View File

@@ -1,7 +1,7 @@
/* /*
* Copyright 2010, 2011, 2012, 2013 mapsforge.org * Copyright 2010, 2011, 2012, 2013 mapsforge.org
* Copyright 2013 Hannes Janetzek * Copyright 2013 Hannes Janetzek
* Copyright 2016-2019 devemux86 * Copyright 2016-2020 devemux86
* Copyright 2016 mar-v-in * Copyright 2016 mar-v-in
* Copyright 2016 Mathieu de Brito * Copyright 2016 Mathieu de Brito
* Copyright 2017-2018 Longri * Copyright 2017-2018 Longri
@@ -28,7 +28,6 @@ package org.oscim.android.test;
import android.app.Activity; import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.view.Gravity; import android.view.Gravity;
@@ -87,8 +86,8 @@ public class Samples extends Activity {
LinearLayout linearLayout = findViewById(R.id.samples); LinearLayout linearLayout = findViewById(R.id.samples);
linearLayout.addView(createButton(GettingStarted.class)); linearLayout.addView(createButton(GettingStarted.class));
linearLayout.addView(createLabel(null)); linearLayout.addView(createLabel(null));
linearLayout.addView(createButton(SimpleMapActivity.class));
linearLayout.addView(createButton(MapsforgeActivity.class)); linearLayout.addView(createButton(MapsforgeActivity.class));
linearLayout.addView(createButton(SimpleMapActivity.class));
linearLayout.addView(createButton(MBTilesMvtActivity.class)); linearLayout.addView(createButton(MBTilesMvtActivity.class));
linearLayout.addView(createButton(MapilionMvtActivity.class)); linearLayout.addView(createButton(MapilionMvtActivity.class));
/*linearLayout.addView(createButton(MapzenMvtActivity.class)); /*linearLayout.addView(createButton(MapzenMvtActivity.class));
@@ -99,12 +98,6 @@ public class Samples extends Activity {
linearLayout.addView(createButton(GdxActivity.class)); linearLayout.addView(createButton(GdxActivity.class));
linearLayout.addView(createLabel("Features")); linearLayout.addView(createLabel("Features"));
linearLayout.addView(createButton(null, "GraphHopper Routing", new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/graphhopper/graphhopper/tree/master/android")));
}
}));
linearLayout.addView(createButton(LocationActivity.class)); linearLayout.addView(createButton(LocationActivity.class));
linearLayout.addView(createButton(LocationTextureActivity.class)); linearLayout.addView(createButton(LocationTextureActivity.class));
linearLayout.addView(createButton(PoiSearchActivity.class)); linearLayout.addView(createButton(PoiSearchActivity.class));
@@ -132,5 +125,6 @@ public class Samples extends Activity {
linearLayout.addView(createButton(GdxPoi3DActivity.class)); linearLayout.addView(createButton(GdxPoi3DActivity.class));
linearLayout.addView(createButton(OverpassActivity.class)); linearLayout.addView(createButton(OverpassActivity.class));
linearLayout.addView(createButton(ClusterMarkerOverlayActivity.class)); linearLayout.addView(createButton(ClusterMarkerOverlayActivity.class));
linearLayout.addView(createButton(FragmentActivity.class));
} }
} }

View File

@@ -38,7 +38,6 @@ import org.oscim.theme.ThemeLoader;
import org.oscim.theme.VtmThemes; import org.oscim.theme.VtmThemes;
public class SimpleMapActivity extends BaseMapActivity { public class SimpleMapActivity extends BaseMapActivity {
private DefaultMapScaleBar mapScaleBar;
BuildingLayer mBuildingLayer; BuildingLayer mBuildingLayer;
private boolean mShadow; private boolean mShadow;
@@ -71,7 +70,7 @@ public class SimpleMapActivity extends BaseMapActivity {
groupLayer.layers.add(new LabelLayer(mMap, mBaseLayer)); groupLayer.layers.add(new LabelLayer(mMap, mBaseLayer));
mMap.layers().add(groupLayer); mMap.layers().add(groupLayer);
mapScaleBar = new DefaultMapScaleBar(mMap); DefaultMapScaleBar mapScaleBar = new DefaultMapScaleBar(mMap);
mapScaleBar.setScaleBarMode(DefaultMapScaleBar.ScaleBarMode.BOTH); mapScaleBar.setScaleBarMode(DefaultMapScaleBar.ScaleBarMode.BOTH);
mapScaleBar.setDistanceUnitAdapter(MetricUnitAdapter.INSTANCE); mapScaleBar.setDistanceUnitAdapter(MetricUnitAdapter.INSTANCE);
mapScaleBar.setSecondaryDistanceUnitAdapter(ImperialUnitAdapter.INSTANCE); mapScaleBar.setSecondaryDistanceUnitAdapter(ImperialUnitAdapter.INSTANCE);
@@ -86,14 +85,6 @@ public class SimpleMapActivity extends BaseMapActivity {
mMap.setTheme(VtmThemes.DEFAULT); mMap.setTheme(VtmThemes.DEFAULT);
} }
@Override
protected void onDestroy() {
if (mapScaleBar != null)
mapScaleBar.destroy();
super.onDestroy();
}
void runTheMonkey() { void runTheMonkey() {
themes[0] = ThemeLoader.load(VtmThemes.DEFAULT); themes[0] = ThemeLoader.load(VtmThemes.DEFAULT);
themes[1] = ThemeLoader.load(VtmThemes.OSMARENDER); themes[1] = ThemeLoader.load(VtmThemes.OSMARENDER);

View File

@@ -22,7 +22,7 @@ import org.oscim.layers.tile.MapTile;
import org.oscim.tiling.ITileDataSink; import org.oscim.tiling.ITileDataSink;
import org.oscim.tiling.OverzoomDataSink; import org.oscim.tiling.OverzoomDataSink;
import org.oscim.tiling.QueryResult; import org.oscim.tiling.QueryResult;
import org.oscim.tiling.source.mvt.MvtTileDecoder; import org.oscim.tiling.source.mvt.TileDecoder;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -45,10 +45,10 @@ public class MBTilesMvtTileDataSource extends MBTilesTileDataSource {
private final String mLanguage; private final String mLanguage;
private final ThreadLocal<MvtTileDecoder> mThreadLocalDecoders = new ThreadLocal<MvtTileDecoder>() { private final ThreadLocal<TileDecoder> mThreadLocalDecoders = new ThreadLocal<TileDecoder>() {
@Override @Override
protected MvtTileDecoder initialValue() { protected TileDecoder initialValue() {
return new MvtTileDecoder(mLanguage); return new TileDecoder(mLanguage);
} }
}; };

View File

@@ -3,7 +3,7 @@ apply plugin: 'com.github.dcendents.android-maven'
dependencies { dependencies {
api project(':vtm') api project(':vtm')
api 'com.caverock:androidsvg:1.3' api 'com.caverock:androidsvg:1.4'
} }
android { android {

View File

@@ -1,6 +1,6 @@
/* /*
* Copyright 2012 Hannes Janetzek * Copyright 2012 Hannes Janetzek
* Copyright 2016-2019 devemux86 * Copyright 2016-2020 devemux86
* Copyright 2018-2019 Gustl22 * Copyright 2018-2019 Gustl22
* *
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org). * This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
@@ -65,12 +65,21 @@ public class MapView extends GLSurfaceView {
private static final Pattern GL_PATTERN = Pattern.compile("OpenGL ES (\\d(\\.\\d){0,2})"); private static final Pattern GL_PATTERN = Pattern.compile("OpenGL ES (\\d(\\.\\d){0,2})");
/** /**
* Target OpenGL ES version, if not available fall back to OpenGL ES 2.0 * OpenGL ES 2.0 default on Android for performance / stability.
* Any larger not available versions fall back to OpenGL ES 2.0.
*/ */
public static double targetGLESVersion = 3.0; public static double OPENGL_VERSION = 2.0;
private static void init() { private static void init() {
System.loadLibrary("vtm-jni"); if (Parameters.THREADED_INIT)
new Thread(new Runnable() {
@Override
public void run() {
System.loadLibrary("vtm-jni");
}
}).start();
else
System.loadLibrary("vtm-jni");
} }
protected AndroidMap mMap; protected AndroidMap mMap;
@@ -103,7 +112,7 @@ public class MapView extends GLSurfaceView {
DateTimeAdapter.init(new DateTime()); DateTimeAdapter.init(new DateTime());
DisplayMetrics metrics = getResources().getDisplayMetrics(); DisplayMetrics metrics = getResources().getDisplayMetrics();
CanvasAdapter.dpi = (int) (metrics.scaledDensity * CanvasAdapter.DEFAULT_DPI); CanvasAdapter.dpi = (int) (metrics.density * CanvasAdapter.DEFAULT_DPI);
if (!Parameters.CUSTOM_TILE_SIZE) if (!Parameters.CUSTOM_TILE_SIZE)
Tile.SIZE = Tile.calculateTileSize(); Tile.SIZE = Tile.calculateTileSize();
@@ -125,16 +134,20 @@ public class MapView extends GLSurfaceView {
mMap = new AndroidMap(this); mMap = new AndroidMap(this);
/* Initialize Renderer */ /* Initialize Renderer */
// OpenGL ES 3.0 is supported with Android 4.3 (API level 18) and higher if (OPENGL_VERSION == 2.0)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
try {
setEGLContextFactory(new GlContextFactory());
} catch (Throwable t) {
log.error("Falling back to GLES 2", t);
setEGLContextClientVersion(2);
}
} else
setEGLContextClientVersion(2); setEGLContextClientVersion(2);
else {
// OpenGL ES 3.0 is supported with Android 4.3 (API level 18) and higher
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
try {
setEGLContextFactory(new GlContextFactory());
} catch (Throwable t) {
log.error("Falling back to GLES 2", t);
setEGLContextClientVersion(2);
}
} else
setEGLContextClientVersion(2);
}
setEGLConfigChooser(new GlConfigChooser()); setEGLConfigChooser(new GlConfigChooser());
if (GLAdapter.debug) if (GLAdapter.debug)
@@ -346,23 +359,27 @@ public class MapView extends GLSurfaceView {
@Override @Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) { public void onSurfaceCreated(GL10 gl, EGLConfig config) {
try { if (OPENGL_VERSION == 2.0)
// Create a minimum supported OpenGL ES context, then check:
String versionString = gl.glGetString(GL10.GL_VERSION);
log.info("Version: " + versionString);
// The version format is displayed as: "OpenGL ES <major>.<minor>"
// followed by optional content provided by the implementation.
// OpenGL<space>ES<space><version number><space><vendor-specific information>.
int[] version = extractVersion(versionString);
int majorVersion = version[0];
if (majorVersion >= 3)
GLAdapter.init(new AndroidGL30());
else
GLAdapter.init(new AndroidGL());
} catch (Throwable t) {
log.error("Falling back to GLES 2", t);
GLAdapter.init(new AndroidGL()); GLAdapter.init(new AndroidGL());
else {
try {
// Create a minimum supported OpenGL ES context, then check:
String versionString = gl.glGetString(GL10.GL_VERSION);
log.info("Version: " + versionString);
// The version format is displayed as: "OpenGL ES <major>.<minor>"
// followed by optional content provided by the implementation.
// OpenGL<space>ES<space><version number><space><vendor-specific information>.
int[] version = extractVersion(versionString);
int majorVersion = Math.min(version[0], (int) OPENGL_VERSION);
if (majorVersion >= 3)
GLAdapter.init(new AndroidGL30());
else
GLAdapter.init(new AndroidGL());
} catch (Throwable t) {
log.error("Falling back to GLES 2", t);
GLAdapter.init(new AndroidGL());
}
} }
super.onSurfaceCreated(); super.onSurfaceCreated();

View File

@@ -1,7 +1,7 @@
/* /*
* Copyright 2013 Hannes Janetzek * Copyright 2013 Hannes Janetzek
* Copyright 2016 Longri * Copyright 2016 Longri
* Copyright 2016-2018 devemux86 * Copyright 2016-2021 devemux86
* *
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org). * This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
* *
@@ -22,7 +22,6 @@ import android.graphics.Bitmap;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import android.opengl.GLES20; import android.opengl.GLES20;
import android.opengl.GLUtils; import android.opengl.GLUtils;
import org.oscim.backend.CanvasAdapter; import org.oscim.backend.CanvasAdapter;
import org.oscim.utils.GraphicUtils; import org.oscim.utils.GraphicUtils;
import org.oscim.utils.IOUtils; import org.oscim.utils.IOUtils;
@@ -39,6 +38,7 @@ public class AndroidBitmap implements org.oscim.backend.canvas.Bitmap {
Bitmap bitmap = BitmapFactory.decodeStream(inputStream); Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
try { try {
GLUtils.getType(bitmap); GLUtils.getType(bitmap);
GLUtils.getInternalFormat(bitmap);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
bitmap = bitmap.copy(ARGB_8888, false); bitmap = bitmap.copy(ARGB_8888, false);
} }
@@ -95,6 +95,9 @@ public class AndroidBitmap implements org.oscim.backend.canvas.Bitmap {
@Override @Override
public void uploadToTexture(boolean replace) { public void uploadToTexture(boolean replace) {
if (mBitmap.isRecycled())
return;
int format = GLUtils.getInternalFormat(mBitmap); int format = GLUtils.getInternalFormat(mBitmap);
int type = GLUtils.getType(mBitmap); int type = GLUtils.getType(mBitmap);

View File

@@ -1,6 +1,6 @@
/* /*
* Copyright 2010, 2011, 2012 mapsforge.org * Copyright 2010, 2011, 2012 mapsforge.org
* Copyright 2016-2018 devemux86 * Copyright 2016-2019 devemux86
* Copyright 2017 Longri * Copyright 2017 Longri
* *
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org). * This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
@@ -22,7 +22,7 @@ import android.content.res.Resources;
import android.graphics.Bitmap.Config; import android.graphics.Bitmap.Config;
import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Build;
import org.oscim.backend.CanvasAdapter; import org.oscim.backend.CanvasAdapter;
import org.oscim.backend.Platform; import org.oscim.backend.Platform;
import org.oscim.backend.canvas.Bitmap; import org.oscim.backend.canvas.Bitmap;
@@ -30,6 +30,7 @@ import org.oscim.backend.canvas.Canvas;
import org.oscim.backend.canvas.Paint; import org.oscim.backend.canvas.Paint;
import org.oscim.layers.marker.MarkerSymbol; import org.oscim.layers.marker.MarkerSymbol;
import org.oscim.layers.marker.MarkerSymbol.HotspotPlace; import org.oscim.layers.marker.MarkerSymbol.HotspotPlace;
import org.oscim.theme.XmlThemeResourceProvider;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@@ -69,8 +70,8 @@ public final class AndroidGraphics extends CanvasAdapter {
} }
@Override @Override
public Bitmap loadBitmapAssetImpl(String relativePathPrefix, String src, int width, int height, int percent) throws IOException { public Bitmap loadBitmapAssetImpl(String relativePathPrefix, String src, XmlThemeResourceProvider resourceProvider, int width, int height, int percent) throws IOException {
return createBitmap(relativePathPrefix, src, width, height, percent); return createBitmap(relativePathPrefix, src, resourceProvider, width, height, percent);
} }
@Override @Override
@@ -90,7 +91,7 @@ public final class AndroidGraphics extends CanvasAdapter {
//------------------------------------- //-------------------------------------
public static Bitmap drawableToBitmap(Drawable drawable) { public static Bitmap drawableToBitmap(Drawable drawable) {
if (drawable instanceof BitmapDrawable) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P && drawable instanceof BitmapDrawable) {
return new AndroidBitmap(((BitmapDrawable) drawable).getBitmap()); return new AndroidBitmap(((BitmapDrawable) drawable).getBitmap());
} }

View File

@@ -28,7 +28,6 @@
package org.oscim.android.gl; package org.oscim.android.gl;
import android.opengl.GLSurfaceView; import android.opengl.GLSurfaceView;
import org.oscim.android.MapView; import org.oscim.android.MapView;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -51,18 +50,18 @@ public class GlContextFactory implements GLSurfaceView.EGLContextFactory {
@Override @Override
public EGLContext createContext(EGL10 egl, EGLDisplay display, EGLConfig eglConfig) { public EGLContext createContext(EGL10 egl, EGLDisplay display, EGLConfig eglConfig) {
log.info("creating OpenGL ES " + MapView.targetGLESVersion + " context"); log.info("creating OpenGL ES " + MapView.OPENGL_VERSION + " context");
checkEglError("Before eglCreateContext " + MapView.targetGLESVersion, egl); checkEglError("Before eglCreateContext " + MapView.OPENGL_VERSION, egl);
int[] attrib_list = {EGL_CONTEXT_CLIENT_VERSION, (int) MapView.targetGLESVersion, EGL10.EGL_NONE}; int[] attrib_list = {EGL_CONTEXT_CLIENT_VERSION, (int) MapView.OPENGL_VERSION, EGL10.EGL_NONE};
EGLContext context = egl.eglCreateContext(display, eglConfig, EGL10.EGL_NO_CONTEXT, attrib_list); EGLContext context = egl.eglCreateContext(display, eglConfig, EGL10.EGL_NO_CONTEXT, attrib_list);
boolean success = checkEglError("After eglCreateContext " + MapView.targetGLESVersion, egl); boolean success = checkEglError("After eglCreateContext " + MapView.OPENGL_VERSION, egl);
if ((!success || context == null) && MapView.targetGLESVersion > 2) { if ((!success || context == null) && MapView.OPENGL_VERSION > 2) {
log.warn("Falling back to GLES 2"); log.warn("Falling back to GLES 2");
MapView.targetGLESVersion = 2.0; MapView.OPENGL_VERSION = 2.0;
return createContext(egl, display, eglConfig); return createContext(egl, display, eglConfig);
} }
log.info("Returning a GLES " + MapView.targetGLESVersion + " context"); log.info("Returning a GLES " + MapView.OPENGL_VERSION + " context");
return context; return context;
} }

View File

@@ -1,7 +1,8 @@
/* /*
* Copyright 2010, 2011, 2012 mapsforge.org * Copyright 2010, 2011, 2012 mapsforge.org
* Copyright 2016-2017 devemux86 * Copyright 2016-2021 devemux86
* Copyright 2017 Andrey Novikov * Copyright 2017 Andrey Novikov
* Copyright 2021 eddiemuc
* *
* This program is free software: you can redistribute it and/or modify it under the * 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 * terms of the GNU Lesser General Public License as published by the Free Software
@@ -18,11 +19,10 @@ package org.oscim.android.theme;
import android.content.res.AssetManager; import android.content.res.AssetManager;
import android.text.TextUtils; import android.text.TextUtils;
import org.oscim.theme.IRenderTheme.ThemeException; import org.oscim.theme.IRenderTheme.ThemeException;
import org.oscim.theme.ThemeFile; import org.oscim.theme.ThemeFile;
import org.oscim.theme.ThemeUtils;
import org.oscim.theme.XmlRenderThemeMenuCallback; import org.oscim.theme.XmlRenderThemeMenuCallback;
import org.oscim.theme.XmlThemeResourceProvider;
import org.oscim.utils.Utils; import org.oscim.utils.Utils;
import java.io.IOException; import java.io.IOException;
@@ -37,8 +37,10 @@ public class AssetsRenderTheme implements ThemeFile {
private final AssetManager mAssetManager; private final AssetManager mAssetManager;
private final String mFileName; private final String mFileName;
private boolean mMapsforgeTheme;
private XmlRenderThemeMenuCallback mMenuCallback; private XmlRenderThemeMenuCallback mMenuCallback;
private final String mRelativePathPrefix; private final String mRelativePathPrefix;
private XmlThemeResourceProvider mResourceProvider;
/** /**
* @param assetManager the Android asset manager. * @param assetManager the Android asset manager.
@@ -100,13 +102,28 @@ public class AssetsRenderTheme implements ThemeFile {
} }
} }
@Override
public XmlThemeResourceProvider getResourceProvider() {
return mResourceProvider;
}
@Override @Override
public boolean isMapsforgeTheme() { public boolean isMapsforgeTheme() {
return ThemeUtils.isMapsforgeTheme(this); return mMapsforgeTheme;
}
@Override
public void setMapsforgeTheme(boolean mapsforgeTheme) {
mMapsforgeTheme = mapsforgeTheme;
} }
@Override @Override
public void setMenuCallback(XmlRenderThemeMenuCallback menuCallback) { public void setMenuCallback(XmlRenderThemeMenuCallback menuCallback) {
mMenuCallback = menuCallback; mMenuCallback = menuCallback;
} }
@Override
public void setResourceProvider(XmlThemeResourceProvider resourceProvider) {
mResourceProvider = resourceProvider;
}
} }

View File

@@ -0,0 +1,119 @@
/*
* Copyright 2020-2021 devemux86
* Copyright 2021 eddiemuc
*
* This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.oscim.android.theme;
import android.content.ContentResolver;
import android.net.Uri;
import org.oscim.theme.IRenderTheme.ThemeException;
import org.oscim.theme.ThemeFile;
import org.oscim.theme.XmlRenderThemeMenuCallback;
import org.oscim.theme.XmlThemeResourceProvider;
import java.io.IOException;
import java.io.InputStream;
/**
* An ContentRenderTheme allows for customizing the rendering style of the map
* via an XML from the Android content providers.
*/
public class ContentRenderTheme implements ThemeFile {
private static final long serialVersionUID = 1L;
private final ContentResolver mContentResolver;
private boolean mMapsforgeTheme;
private XmlRenderThemeMenuCallback mMenuCallback;
private XmlThemeResourceProvider mResourceProvider;
private final Uri mUri;
/**
* @param contentResolver the Android content resolver.
* @param uri the XML render theme URI.
* @throws ThemeException if an error occurs while reading the render theme XML.
*/
public ContentRenderTheme(ContentResolver contentResolver, Uri uri) throws ThemeException {
this(contentResolver, uri, null);
}
/**
* @param contentResolver the Android content resolver.
* @param uri the XML render theme URI.
* @param menuCallback the interface callback to create a settings menu on the fly.
* @throws ThemeException if an error occurs while reading the render theme XML.
*/
public ContentRenderTheme(ContentResolver contentResolver, Uri uri, XmlRenderThemeMenuCallback menuCallback) throws ThemeException {
mContentResolver = contentResolver;
mUri = uri;
mMenuCallback = menuCallback;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
} else if (!(obj instanceof ContentRenderTheme)) {
return false;
}
ContentRenderTheme other = (ContentRenderTheme) obj;
if (getRenderThemeAsStream() != other.getRenderThemeAsStream()) {
return false;
}
return true;
}
@Override
public XmlRenderThemeMenuCallback getMenuCallback() {
return mMenuCallback;
}
@Override
public String getRelativePathPrefix() {
return "";
}
@Override
public InputStream getRenderThemeAsStream() throws ThemeException {
try {
return mContentResolver.openInputStream(mUri);
} catch (IOException e) {
throw new ThemeException(e.getMessage());
}
}
@Override
public XmlThemeResourceProvider getResourceProvider() {
return mResourceProvider;
}
@Override
public boolean isMapsforgeTheme() {
return mMapsforgeTheme;
}
@Override
public void setMapsforgeTheme(boolean mapsforgeTheme) {
mMapsforgeTheme = mapsforgeTheme;
}
@Override
public void setMenuCallback(XmlRenderThemeMenuCallback menuCallback) {
mMenuCallback = menuCallback;
}
@Override
public void setResourceProvider(XmlThemeResourceProvider resourceProvider) {
mResourceProvider = resourceProvider;
}
}

View File

@@ -0,0 +1,179 @@
/*
* Copyright 2021 eddiemuc
*
* This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.oscim.android.theme;
import android.content.ContentResolver;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Build;
import android.provider.DocumentsContract;
import org.oscim.backend.CanvasAdapter;
import org.oscim.theme.XmlThemeResourceProvider;
import org.oscim.utils.IOUtils;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.*;
/**
* An xml theme resource provider resolving resources using Android scoped storage (document framework).
* <p>
* Implementation note: these methods do not use DocumentFile internally,
* but query directly for document info due to vastly better performance.
* Also for better performance, this implementation caches resource uris.
* <p>
* Note: this implementation requires minimum Android 5.0 (API 21)
*/
public class ContentResolverResourceProvider implements XmlThemeResourceProvider {
private final ContentResolver contentResolver;
private final Uri relativeRootUri;
private final boolean isDocumentUri;
private final Map<String, Uri> resourceUriCache = new HashMap<>();
private static class DocumentInfo {
private final String name;
private final Uri uri;
private final boolean isDirectory;
private DocumentInfo(String name, Uri uri, boolean isDirectory) {
this.name = name;
this.uri = uri;
this.isDirectory = isDirectory;
}
}
/**
* Creates a new content resolver resource provider.
*
* @param contentResolver content resolver used to read content.
* @param relativeRootUri uri pointing to a directory.
* Uri is assumed to be a pure tree Uri (as e.g. returned by {@link Intent#ACTION_OPEN_DOCUMENT_TREE}).
*/
public ContentResolverResourceProvider(ContentResolver contentResolver, Uri relativeRootUri) {
this(contentResolver, relativeRootUri, false);
}
/**
* Creates a new content resolver resource provider.
*
* @param contentResolver content resolver used to read content.
* @param relativeRootUri uri pointing to a directory.
* @param isDocumentUri Uris as returned e.g. by {@link Intent#ACTION_OPEN_DOCUMENT_TREE}) cannot directly be used to scan directories and read content.
* They must be converted to document uris first using {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}.
* However, in some situations this conversion was done previously by caller (e.g. if root dir should be subdirectory of a directory returned by {@link Intent#ACTION_OPEN_DOCUMENT_TREE}).
* In these cases, converted Uri will point to original root directory which is not always the wanted behaviour.
* Thus, this parameter allows caller to control whether conversion should be done or not.
* If set to true, then given Uri is considered to be a document uri already and no conversion is done.
* If set to false, uri is considered to be a pure tree uri as returned e.g. by {@link Intent#ACTION_OPEN_DOCUMENT_TREE}) and it is converted.
*/
public ContentResolverResourceProvider(ContentResolver contentResolver, Uri relativeRootUri, boolean isDocumentUri) {
this.contentResolver = contentResolver;
this.relativeRootUri = relativeRootUri;
this.isDocumentUri = isDocumentUri;
refreshCache();
}
/**
* Build uri cache for one dir level (recursive function).
*/
private void buildCacheLevel(String prefix, Uri dirUri) {
List<DocumentInfo> docs = queryDir(dirUri);
for (DocumentInfo doc : docs) {
if (doc.isDirectory) {
buildCacheLevel(prefix + doc.name + "/", doc.uri);
} else {
// Store both relative urls and absolute urls
resourceUriCache.put(CanvasAdapter.PREFIX_FILE + prefix + doc.name, doc.uri);
resourceUriCache.put(CanvasAdapter.PREFIX_FILE + "/" + prefix + doc.name, doc.uri);
}
}
}
@Override
public InputStream createInputStream(String relativePath, String source) throws FileNotFoundException {
Uri docUri = resourceUriCache.get(source);
if (docUri != null) {
return contentResolver.openInputStream(docUri);
}
return null;
}
/**
* Query the content of a directory using scoped storage.
*
* @return a list of arrays with info [0: name (String), 1: uri (Uri), 2: isDir (boolean)]
*/
private List<DocumentInfo> queryDir(Uri dirUri) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
return Collections.emptyList();
}
if (dirUri == null) {
return Collections.emptyList();
}
List<DocumentInfo> result = new ArrayList<>();
Uri childrenUri = DocumentsContract.buildChildDocumentsUriUsingTree(dirUri, DocumentsContract.getDocumentId(dirUri));
String[] columns = new String[]{
DocumentsContract.Document.COLUMN_DOCUMENT_ID,
DocumentsContract.Document.COLUMN_DISPLAY_NAME,
DocumentsContract.Document.COLUMN_MIME_TYPE
};
Cursor c = null;
try {
c = contentResolver.query(childrenUri, columns, null, null, null);
while (c.moveToNext()) {
String documentId = c.getString(0);
String name = c.getString(1);
String mimeType = c.getString(2);
Uri uri = DocumentsContract.buildDocumentUriUsingTree(dirUri, documentId);
boolean isDir = DocumentsContract.Document.MIME_TYPE_DIR.equals(mimeType);
result.add(new DocumentInfo(name, uri, isDir));
}
return result;
} finally {
IOUtils.closeQuietly(c);
}
}
/**
* Refresh the uri cache by recreating it.
*/
private void refreshCache() {
resourceUriCache.clear();
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
return;
}
if (relativeRootUri == null) {
return;
}
Uri dirUri = relativeRootUri;
if (!isDocumentUri) {
// Convert "tree uri" to a "document uri"
dirUri = DocumentsContract.buildDocumentUriUsingTree(dirUri, DocumentsContract.getTreeDocumentId(dirUri));
}
buildCacheLevel("", dirUri);
}
}

View File

@@ -15,6 +15,7 @@
android:allowBackup="true" android:allowBackup="true"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:label="@string/application_name" android:label="@string/application_name"
android:requestLegacyExternalStorage="true"
android:usesCleartextTraffic="true"> android:usesCleartextTraffic="true">
<!-- android:theme="@style/Theme.TileMap" --> <!-- android:theme="@style/Theme.TileMap" -->

View File

@@ -4,7 +4,8 @@ dependencies {
implementation project(':vtm-android') implementation project(':vtm-android')
implementation project(':vtm-extras') implementation project(':vtm-extras')
implementation project(':vtm-themes') implementation project(':vtm-themes')
implementation 'com.squareup.okhttp3:okhttp:3.8.0' // https://github.com/square/okhttp/issues/4481
implementation 'com.squareup.okhttp3:okhttp:3.12.13'
implementation "org.slf4j:slf4j-android:$slf4jVersion" implementation "org.slf4j:slf4j-android:$slf4jVersion"
} }

View File

@@ -1,6 +1,6 @@
/* /*
* Copyright 2013 Hannes Janetzek * Copyright 2013 Hannes Janetzek
* Copyright 2016-2019 devemux86 * Copyright 2016-2020 devemux86
* *
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org). * This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
* *
@@ -41,6 +41,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.File; import java.io.File;
import java.util.Collections;
public class MapLayers { public class MapLayers {
@@ -183,7 +184,9 @@ public class MapLayers {
switch (id) { switch (id) {
case R.id.menu_layer_openstreetmap: case R.id.menu_layer_openstreetmap:
mBackgroundLayer = new BitmapTileLayer(App.map, DefaultSources.OPENSTREETMAP.build()); UrlTileSource tileSource = DefaultSources.OPENSTREETMAP.build();
tileSource.setHttpRequestHeaders(Collections.singletonMap("User-Agent", "vtm-playground"));
mBackgroundLayer = new BitmapTileLayer(App.map, tileSource);
break; break;
case R.id.menu_layer_naturalearth: case R.id.menu_layer_naturalearth:

View File

@@ -23,19 +23,14 @@ import android.view.View;
import android.widget.Button; import android.widget.Button;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.Toast; import android.widget.Toast;
import org.oscim.android.canvas.AndroidGraphics; import org.oscim.android.canvas.AndroidGraphics;
import org.oscim.core.BoundingBox; import org.oscim.core.BoundingBox;
import org.oscim.core.GeoPoint; import org.oscim.core.GeoPoint;
import org.oscim.layers.marker.MarkerInterface;
import org.oscim.layers.marker.MarkerSymbol; import org.oscim.layers.marker.MarkerSymbol;
import org.oscim.layers.marker.MarkerSymbol.HotspotPlace; import org.oscim.layers.marker.MarkerSymbol.HotspotPlace;
import org.oscim.map.Map; import org.oscim.map.Map;
import org.osmdroid.location.FlickrPOIProvider; import org.osmdroid.location.*;
import org.osmdroid.location.FourSquareProvider;
import org.osmdroid.location.GeoNamesPOIProvider;
import org.osmdroid.location.NominatimPOIProvider;
import org.osmdroid.location.POI;
import org.osmdroid.location.PicasaPOIProvider;
import org.osmdroid.overlays.DefaultInfoWindow; import org.osmdroid.overlays.DefaultInfoWindow;
import org.osmdroid.overlays.ExtendedMarkerItem; import org.osmdroid.overlays.ExtendedMarkerItem;
import org.osmdroid.overlays.ItemizedOverlayWithBubble; import org.osmdroid.overlays.ItemizedOverlayWithBubble;
@@ -45,7 +40,7 @@ import java.util.List;
public class POISearch { public class POISearch {
private final ArrayList<POI> mPOIs; private final ArrayList<POI> mPOIs;
ItemizedOverlayWithBubble<ExtendedMarkerItem> poiMarkers; ItemizedOverlayWithBubble poiMarkers;
MarkerSymbol[] mMarkers; MarkerSymbol[] mMarkers;
private static final int MDEFAULT = 0; private static final int MDEFAULT = 0;
@@ -57,9 +52,9 @@ public class POISearch {
POISearch() { POISearch() {
mPOIs = new ArrayList<POI>(); mPOIs = new ArrayList<POI>();
//POI markers: //POI markers:
final ArrayList<ExtendedMarkerItem> poiItems = new ArrayList<ExtendedMarkerItem>(); final ArrayList<MarkerInterface> poiItems = new ArrayList<>();
poiMarkers = new ItemizedOverlayWithBubble<ExtendedMarkerItem>(App.map, poiMarkers = new ItemizedOverlayWithBubble(App.map,
App.activity, App.activity,
null, null,
poiItems, poiItems,

View File

@@ -24,10 +24,10 @@ import android.widget.Button;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.RelativeLayout; import android.widget.RelativeLayout;
import android.widget.TextView; import android.widget.TextView;
import org.oscim.android.canvas.AndroidGraphics; import org.oscim.android.canvas.AndroidGraphics;
import org.oscim.core.GeoPoint; import org.oscim.core.GeoPoint;
import org.oscim.layers.PathLayer; import org.oscim.layers.PathLayer;
import org.oscim.layers.marker.MarkerInterface;
import org.oscim.layers.marker.MarkerSymbol; import org.oscim.layers.marker.MarkerSymbol;
import org.oscim.layers.marker.MarkerSymbol.HotspotPlace; import org.oscim.layers.marker.MarkerSymbol.HotspotPlace;
import org.osmdroid.location.GeocoderNominatim; import org.osmdroid.location.GeocoderNominatim;
@@ -48,7 +48,7 @@ public class RouteSearch {
private final PathLayer mRouteOverlay; private final PathLayer mRouteOverlay;
//private final ItemizedOverlayWithBubble<ExtendedOverlayItem> mRouteMarkers; //private final ItemizedOverlayWithBubble<ExtendedOverlayItem> mRouteMarkers;
private final ItemizedOverlayWithBubble<ExtendedMarkerItem> mItineraryMarkers; private final ItemizedOverlayWithBubble mItineraryMarkers;
private final RouteBar mRouteBar; private final RouteBar mRouteBar;
@@ -63,9 +63,9 @@ public class RouteSearch {
mViaPoints = new ArrayList<GeoPoint>(); mViaPoints = new ArrayList<GeoPoint>();
// Itinerary markers: // Itinerary markers:
ArrayList<ExtendedMarkerItem> waypointsItems = new ArrayList<ExtendedMarkerItem>(); ArrayList<MarkerInterface> waypointsItems = new ArrayList<>();
mItineraryMarkers = new ItemizedOverlayWithBubble<ExtendedMarkerItem>(App.map, mItineraryMarkers = new ItemizedOverlayWithBubble(App.map,
App.activity, App.activity,
null, null,
waypointsItems, waypointsItems,

View File

@@ -1,6 +1,6 @@
/* /*
* Copyright 2010, 2011, 2012 mapsforge.org * Copyright 2010, 2011, 2012 mapsforge.org
* Copyright 2016 devemux86 * Copyright 2016-2020 devemux86
* *
* This program is free software: you can redistribute it and/or modify it under the * 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 * terms of the GNU Lesser General Public License as published by the Free Software
@@ -15,40 +15,30 @@
*/ */
package org.oscim.app.filefilter; package org.oscim.app.filefilter;
import org.oscim.theme.ExternalRenderTheme; import org.oscim.theme.ThemeLoader;
import org.oscim.theme.ThemeFile;
import org.oscim.theme.XmlThemeBuilder;
import org.oscim.tiling.TileSource.OpenResult; import org.oscim.tiling.TileSource.OpenResult;
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
import java.io.File; import java.io.File;
import javax.xml.parsers.SAXParserFactory;
/** /**
* Accepts all valid render theme XML files. * Accepts all valid render theme XML files.
*/ */
public final class ValidRenderTheme implements ValidFileFilter { public final class ValidRenderTheme implements ValidFileFilter {
private OpenResult openResult; private OpenResult mOpenResult;
@Override @Override
public boolean accept(File file) { public boolean accept(File file) {
try { try {
ThemeFile theme = new ExternalRenderTheme(file.getAbsolutePath()); ThemeLoader.load(file.getAbsolutePath());
XmlThemeBuilder renderThemeHandler = new XmlThemeBuilder(theme); mOpenResult = OpenResult.SUCCESS;
XMLReader xmlReader = SAXParserFactory.newInstance().newSAXParser().getXMLReader();
xmlReader.setContentHandler(renderThemeHandler);
xmlReader.parse(new InputSource(theme.getRenderThemeAsStream()));
this.openResult = OpenResult.SUCCESS;
} catch (Exception e) { } catch (Exception e) {
this.openResult = new OpenResult(e.getMessage()); mOpenResult = new OpenResult(e.getMessage());
} }
return this.openResult.isSuccess(); return mOpenResult.isSuccess();
} }
@Override @Override
public OpenResult getFileOpenResult() { public OpenResult getFileOpenResult() {
return this.openResult; return mOpenResult;
} }
} }

View File

@@ -1,7 +1,7 @@
/* /*
* Copyright 2013 Ahmad Saleem * Copyright 2013 Ahmad Saleem
* Copyright 2013 Hannes Janetzek * Copyright 2013 Hannes Janetzek
* Copyright 2016-2017 devemux86 * Copyright 2016-2019 devemux86
* *
* This program is free software: you can redistribute it and/or modify it under the * 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 * terms of the GNU Lesser General Public License as published by the Free Software
@@ -24,19 +24,17 @@ import android.hardware.SensorManager;
import android.view.animation.Animation; import android.view.animation.Animation;
import android.view.animation.RotateAnimation; import android.view.animation.RotateAnimation;
import android.widget.ImageView; import android.widget.ImageView;
import org.oscim.app.App; import org.oscim.app.App;
import org.oscim.app.R; import org.oscim.app.R;
import org.oscim.core.MapPosition; import org.oscim.core.MapPosition;
import org.oscim.event.Event; import org.oscim.event.Event;
import org.oscim.layers.Layer; import org.oscim.layers.Layer;
import org.oscim.map.Map; import org.oscim.map.Map;
import org.oscim.renderer.LocationRenderer; import org.oscim.renderer.LocationCallback;
import org.oscim.utils.FastMath; import org.oscim.utils.FastMath;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public class Compass extends Layer implements SensorEventListener, Map.UpdateListener, public class Compass extends Layer implements SensorEventListener, Map.UpdateListener, LocationCallback {
LocationRenderer.Callback {
// static final Logger log = LoggerFactory.getLogger(Compass.class); // static final Logger log = LoggerFactory.getLogger(Compass.class);

View File

@@ -2,7 +2,6 @@ package org.osmdroid.overlays;
import android.content.Context; import android.content.Context;
import android.util.Log; import android.util.Log;
import org.oscim.app.App; import org.oscim.app.App;
import org.oscim.core.GeoPoint; import org.oscim.core.GeoPoint;
import org.oscim.core.MapPosition; import org.oscim.core.MapPosition;
@@ -10,6 +9,7 @@ import org.oscim.core.Point;
import org.oscim.event.Event; import org.oscim.event.Event;
import org.oscim.event.MotionEvent; import org.oscim.event.MotionEvent;
import org.oscim.layers.marker.ItemizedLayer; import org.oscim.layers.marker.ItemizedLayer;
import org.oscim.layers.marker.MarkerInterface;
import org.oscim.layers.marker.MarkerItem; import org.oscim.layers.marker.MarkerItem;
import org.oscim.layers.marker.MarkerSymbol; import org.oscim.layers.marker.MarkerSymbol;
import org.oscim.map.Map; import org.oscim.map.Map;
@@ -22,14 +22,12 @@ import java.util.List;
* taps on an overlay item, and displays item attributes. <br> * taps on an overlay item, and displays item attributes. <br>
* Items must be ExtendedMarkerItem. <br> * Items must be ExtendedMarkerItem. <br>
* *
* @param <Item> ...
* @author M.Kergall * @author M.Kergall
* @see ExtendedMarkerItem * @see ExtendedMarkerItem
* @see InfoWindow * @see InfoWindow
*/ */
public class ItemizedOverlayWithBubble<Item extends MarkerItem> extends public class ItemizedOverlayWithBubble extends ItemizedLayer
ItemizedLayer<Item> implements implements ItemizedLayer.OnItemGestureListener<MarkerInterface>, Map.UpdateListener {
ItemizedLayer.OnItemGestureListener<Item>, Map.UpdateListener {
/* only one for all items of this overlay => one at a time */ /* only one for all items of this overlay => one at a time */
protected InfoWindow mBubble; protected InfoWindow mBubble;
@@ -40,7 +38,7 @@ public class ItemizedOverlayWithBubble<Item extends MarkerItem> extends
static int layoutResId = 0; static int layoutResId = 0;
public ItemizedOverlayWithBubble(Map map, Context context, public ItemizedOverlayWithBubble(Map map, Context context,
MarkerSymbol marker, List<Item> list, InfoWindow bubble) { MarkerSymbol marker, List<MarkerInterface> list, InfoWindow bubble) {
super(map, list, marker, null); super(map, list, marker, null);
if (bubble != null) { if (bubble != null) {
@@ -66,12 +64,12 @@ public class ItemizedOverlayWithBubble<Item extends MarkerItem> extends
} }
public ItemizedOverlayWithBubble(Map map, Context context, public ItemizedOverlayWithBubble(Map map, Context context,
MarkerSymbol marker, List<Item> aList) { MarkerSymbol marker, List<MarkerInterface> aList) {
this(map, context, marker, aList, null); this(map, context, marker, aList, null);
} }
@Override @Override
public boolean onItemLongPress(int index, MarkerItem item) { public boolean onItemLongPress(int index, MarkerInterface item) {
if (mBubble.isOpen()) if (mBubble.isOpen())
hideBubble(); hideBubble();
else else
@@ -80,7 +78,7 @@ public class ItemizedOverlayWithBubble<Item extends MarkerItem> extends
} }
@Override @Override
public boolean onItemSingleTapUp(int index, MarkerItem item) { public boolean onItemSingleTapUp(int index, MarkerInterface item) {
showBubble(index); showBubble(index);
return true; return true;
@@ -121,7 +119,6 @@ public class ItemizedOverlayWithBubble<Item extends MarkerItem> extends
* *
* @param index of the overlay item to show * @param index of the overlay item to show
*/ */
@SuppressWarnings("unchecked")
public void showBubbleOnItem(int index) { public void showBubbleOnItem(int index) {
ExtendedMarkerItem item = (ExtendedMarkerItem) (mItemList.get(index)); ExtendedMarkerItem item = (ExtendedMarkerItem) (mItemList.get(index));
mItemWithBubble = item; mItemWithBubble = item;
@@ -131,7 +128,7 @@ public class ItemizedOverlayWithBubble<Item extends MarkerItem> extends
mMap.animator().animateTo(item.geoPoint); mMap.animator().animateTo(item.geoPoint);
mMap.updateMap(true); mMap.updateMap(true);
setFocus((Item) item); setFocus(item);
} }
} }
@@ -179,7 +176,7 @@ public class ItemizedOverlayWithBubble<Item extends MarkerItem> extends
} }
@Override @Override
public synchronized boolean removeItem(final Item item) { public synchronized boolean removeItem(final MarkerInterface item) {
boolean result = super.removeItem(item); boolean result = super.removeItem(item);
if (mItemWithBubble == item) { if (mItemWithBubble == item) {
hideBubble(); hideBubble();

View File

@@ -3,7 +3,7 @@ apply plugin: 'maven'
dependencies { dependencies {
api project(':vtm-gdx') api project(':vtm-gdx')
api 'com.github.blackears:svgSalamander:v1.1.1' api 'com.formdev:svgSalamander:1.1.2.4'
} }
sourceSets { sourceSets {

View File

@@ -23,11 +23,9 @@ import org.oscim.backend.Platform;
import org.oscim.backend.canvas.Bitmap; import org.oscim.backend.canvas.Bitmap;
import org.oscim.backend.canvas.Canvas; import org.oscim.backend.canvas.Canvas;
import org.oscim.backend.canvas.Paint; import org.oscim.backend.canvas.Paint;
import org.oscim.theme.XmlThemeResourceProvider;
import java.awt.Font; import java.awt.*;
import java.awt.FontMetrics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@@ -119,7 +117,7 @@ public class AwtGraphics extends CanvasAdapter {
} }
@Override @Override
public Bitmap loadBitmapAssetImpl(String relativePathPrefix, String src, int width, int height, int percent) throws IOException { public Bitmap loadBitmapAssetImpl(String relativePathPrefix, String src, XmlThemeResourceProvider resourceProvider, int width, int height, int percent) throws IOException {
return createBitmap(relativePathPrefix, src, width, height, percent); return createBitmap(relativePathPrefix, src, resourceProvider, width, height, percent);
} }
} }

View File

@@ -1,7 +1,7 @@
/* /*
* Copyright 2010, 2011, 2012, 2013 mapsforge.org * Copyright 2010, 2011, 2012, 2013 mapsforge.org
* Copyright 2013 Hannes Janetzek * Copyright 2013 Hannes Janetzek
* Copyright 2016-2017 devemux86 * Copyright 2016-2019 devemux86
* Copyright 2017 nebular * Copyright 2017 nebular
* Copyright 2018 Gustl22 * Copyright 2018 Gustl22
* *
@@ -22,12 +22,7 @@ package org.oscim.awt;
import org.oscim.backend.canvas.Paint; import org.oscim.backend.canvas.Paint;
import java.awt.BasicStroke; import java.awt.*;
import java.awt.Color;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics2D;
import java.awt.Stroke;
import java.awt.font.TextAttribute; import java.awt.font.TextAttribute;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.text.AttributedCharacterIterator.Attribute; import java.text.AttributedCharacterIterator.Attribute;
@@ -125,8 +120,8 @@ public class AwtPaint implements Paint {
Font font = DEFAULT_FONT; // new Font("Default", Font.PLAIN, 13); Font font = DEFAULT_FONT; // new Font("Default", Font.PLAIN, 13);
Stroke stroke; Stroke stroke;
Style style = Style.FILL; Style style = Style.FILL;
private int cap = getCap(Cap.BUTT); private int cap = getCap(Cap.ROUND);
private int join = getJoin(Join.MITER); private int join = getJoin(Join.ROUND);
private float strokeWidth; private float strokeWidth;
private float textSize = DEFAULT_FONT.getSize(); private float textSize = DEFAULT_FONT.getSize();

View File

@@ -3,9 +3,10 @@ apply plugin: 'maven'
dependencies { dependencies {
api project(':vtm') api project(':vtm')
api 'com.fasterxml.jackson.core:jackson-core:2.8.4' api 'com.fasterxml.jackson.core:jackson-core:2.9.9'
api 'org.locationtech.jts:jts-core:1.15.0' // https://github.com/locationtech/jts/issues/145
api 'org.openstreetmap.osmosis:osmosis-osm-binary:0.46' api 'org.locationtech.jts:jts-core:1.15.1'
api 'org.openstreetmap.osmosis:osmosis-osm-binary:0.47'
} }
sourceSets { sourceSets {

View File

@@ -78,6 +78,6 @@ public class OverpassTileSource extends UrlTileSource {
@Override @Override
public ITileDataSource getDataSource() { public ITileDataSource getDataSource() {
return new OverzoomTileDataSource(new UrlTileDataSource(this, new OverpassTileDecoder(), getHttpEngine()), mOverZoom); return new OverzoomTileDataSource(new UrlTileDataSource(this, new TileDecoder(), getHttpEngine()), mOverZoom);
} }
} }

View File

@@ -39,14 +39,14 @@ import java.io.InputStream;
import static org.oscim.core.MercatorProjection.latitudeToY; import static org.oscim.core.MercatorProjection.latitudeToY;
import static org.oscim.core.MercatorProjection.longitudeToX; import static org.oscim.core.MercatorProjection.longitudeToX;
public class OverpassTileDecoder implements ITileDecoder { public class TileDecoder implements ITileDecoder {
private final MapElement mMapElement; private final MapElement mMapElement;
private ITileDataSink mTileDataSink; private ITileDataSink mTileDataSink;
private double mTileY, mTileX, mTileScale; private double mTileY, mTileX, mTileScale;
public OverpassTileDecoder() { public TileDecoder() {
mMapElement = new MapElement(); mMapElement = new MapElement();
mMapElement.layer = 5; mMapElement.layer = 5;
} }

View File

@@ -1,6 +1,6 @@
/* /*
* Copyright 2013 Hannes Janetzek * Copyright 2013 Hannes Janetzek
* Copyright 2016-2017 devemux86 * Copyright 2016-2021 devemux86
* Copyright 2017 Longri * Copyright 2017 Longri
* *
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org). * This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
@@ -22,7 +22,6 @@ import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input; import com.badlogic.gdx.Input;
import com.badlogic.gdx.Input.Buttons; import com.badlogic.gdx.Input.Buttons;
import com.badlogic.gdx.InputProcessor; import com.badlogic.gdx.InputProcessor;
import org.oscim.layers.GenericLayer; import org.oscim.layers.GenericLayer;
import org.oscim.layers.GroupLayer; import org.oscim.layers.GroupLayer;
import org.oscim.layers.Layer; import org.oscim.layers.Layer;
@@ -79,19 +78,19 @@ public class InputHandler implements InputProcessor {
break; break;
case Input.Keys.UP: case Input.Keys.UP:
mViewport.moveMap(0, -50);
mMap.updateMap(true);
break;
case Input.Keys.DOWN:
mViewport.moveMap(0, 50); mViewport.moveMap(0, 50);
mMap.updateMap(true); mMap.updateMap(true);
break; break;
case Input.Keys.DOWN:
mViewport.moveMap(0, -50);
mMap.updateMap(true);
break;
case Input.Keys.LEFT: case Input.Keys.LEFT:
mViewport.moveMap(-50, 0); mViewport.moveMap(50, 0);
mMap.updateMap(true); mMap.updateMap(true);
break; break;
case Input.Keys.RIGHT: case Input.Keys.RIGHT:
mViewport.moveMap(50, 0); mViewport.moveMap(-50, 0);
mMap.updateMap(true); mMap.updateMap(true);
break; break;
case Input.Keys.D: case Input.Keys.D:
@@ -110,6 +109,15 @@ public class InputHandler implements InputProcessor {
mMap.animator().animateZoom(500, 2, 0, 0); mMap.animator().animateZoom(500, 2, 0, 0);
mMap.updateMap(false); mMap.updateMap(false);
break; break;
case Input.Keys.MINUS:
mMap.animator().animateZoom(500, 0.5, 0, 0);
mMap.updateMap(true);
break;
case Input.Keys.PLUS:
case Input.Keys.EQUALS:
mMap.animator().animateZoom(500, 2, 0, 0);
mMap.updateMap(true);
break;
case Input.Keys.NUM_1: case Input.Keys.NUM_1:
mMap.setTheme(VtmThemes.DEFAULT); mMap.setTheme(VtmThemes.DEFAULT);

View File

@@ -3,7 +3,8 @@ apply plugin: 'maven'
dependencies { dependencies {
api project(':vtm') api project(':vtm')
api 'com.squareup.okhttp3:okhttp:3.8.0' // https://github.com/square/okhttp/issues/4481
api 'com.squareup.okhttp3:okhttp:3.12.13'
} }
sourceSets { sourceSets {

View File

@@ -1,6 +1,6 @@
buildscript { buildscript {
repositories { repositories {
jcenter() mavenCentral()
} }
dependencies { dependencies {
classpath 'com.mobidevelop.robovm:robovm-gradle-plugin:2.3.7' classpath 'com.mobidevelop.robovm:robovm-gradle-plugin:2.3.7'

View File

@@ -19,7 +19,6 @@
package org.oscim.ios.test; package org.oscim.ios.test;
import com.badlogic.gdx.graphics.glutils.GLVersion; import com.badlogic.gdx.graphics.glutils.GLVersion;
import org.oscim.backend.GLAdapter; import org.oscim.backend.GLAdapter;
import org.oscim.backend.canvas.Color; import org.oscim.backend.canvas.Color;
import org.oscim.core.GeoPoint; import org.oscim.core.GeoPoint;
@@ -74,7 +73,7 @@ public class IOSPathLayerTest extends GdxMap {
mMap.setMapPosition(0, 0, 1 << 2); mMap.setMapPosition(0, 0, 1 << 2);
tex = Utils.loadTexture("", "patterns/pike.png", 0, 0, 100); tex = Utils.loadTexture("", "patterns/pike.png", null, 0, 0, 100);
// tex = new TextureItem(CanvasAdapter.getBitmapAsset("", "patterns/pike.png")); // tex = new TextureItem(CanvasAdapter.getBitmapAsset("", "patterns/pike.png"));
tex.mipmap = true; tex.mipmap = true;

View File

@@ -1,6 +1,6 @@
buildscript { buildscript {
repositories { repositories {
jcenter() mavenCentral()
} }
dependencies { dependencies {
classpath 'com.mobidevelop.robovm:robovm-gradle-plugin:2.3.7' classpath 'com.mobidevelop.robovm:robovm-gradle-plugin:2.3.7'

View File

@@ -21,6 +21,7 @@ import org.oscim.backend.Platform;
import org.oscim.backend.canvas.Bitmap; import org.oscim.backend.canvas.Bitmap;
import org.oscim.backend.canvas.Canvas; import org.oscim.backend.canvas.Canvas;
import org.oscim.backend.canvas.Paint; import org.oscim.backend.canvas.Paint;
import org.oscim.theme.XmlThemeResourceProvider;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -70,7 +71,7 @@ public class IosGraphics extends CanvasAdapter {
} }
@Override @Override
protected Bitmap loadBitmapAssetImpl(String relativePathPrefix, String src, int width, int height, int percent) throws IOException { protected Bitmap loadBitmapAssetImpl(String relativePathPrefix, String src, XmlThemeResourceProvider resourceProvider, int width, int height, int percent) throws IOException {
return createBitmap(relativePathPrefix, src, width, height, percent); return createBitmap(relativePathPrefix, src, resourceProvider, width, height, percent);
} }
} }

View File

@@ -3,10 +3,7 @@ apply plugin: 'maven'
dependencies { dependencies {
api project(':vtm') api project(':vtm')
api('org.jeo:jeo:0-SNAPSHOT') { api('com.github.jeo.jeo:jeo-carto:master-SNAPSHOT') {
exclude group: 'org.slf4j', module: 'slf4j-jdk14'
}
api('org.jeo:jeo-carto:0-SNAPSHOT') {
exclude group: 'org.slf4j', module: 'slf4j-jdk14' exclude group: 'org.slf4j', module: 'slf4j-jdk14'
} }
} }

View File

@@ -1,6 +1,6 @@
package org.oscim.jeo; package org.oscim.jeo;
import org.jeo.map.RGB; import io.jeo.map.RGB;
public class JeoUtils { public class JeoUtils {
public static int color(RGB rgb) { public static int color(RGB rgb) {

View File

@@ -16,8 +16,8 @@
*/ */
package org.oscim.layers; package org.oscim.layers;
import org.jeo.tile.Tile; import io.jeo.tile.Tile;
import org.jeo.tile.TileDataset; import io.jeo.tile.TileDataset;
import org.oscim.backend.CanvasAdapter; import org.oscim.backend.CanvasAdapter;
import org.oscim.backend.canvas.Bitmap; import org.oscim.backend.canvas.Bitmap;
import org.oscim.layers.tile.MapTile; import org.oscim.layers.tile.MapTile;
@@ -30,9 +30,7 @@ import org.slf4j.LoggerFactory;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.IOException; import java.io.IOException;
import static org.oscim.tiling.QueryResult.FAILED; import static org.oscim.tiling.QueryResult.*;
import static org.oscim.tiling.QueryResult.SUCCESS;
import static org.oscim.tiling.QueryResult.TILE_NOT_FOUND;
public class JeoTileSource extends TileSource { public class JeoTileSource extends TileSource {
static final Logger log = LoggerFactory.getLogger(JeoTileSource.class); static final Logger log = LoggerFactory.getLogger(JeoTileSource.class);

View File

@@ -19,16 +19,11 @@ package org.oscim.layers;
import com.vividsolutions.jts.geom.Envelope; import com.vividsolutions.jts.geom.Envelope;
import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.LineString; import com.vividsolutions.jts.geom.LineString;
import io.jeo.geom.Geom;
import org.jeo.geom.Geom; import io.jeo.map.*;
import org.jeo.map.CartoCSS; import io.jeo.vector.Feature;
import org.jeo.map.RGB; import io.jeo.vector.VectorDataset;
import org.jeo.map.Rule; import io.jeo.vector.VectorQuery;
import org.jeo.map.RuleList;
import org.jeo.map.Style;
import org.jeo.vector.Feature;
import org.jeo.vector.VectorDataset;
import org.jeo.vector.VectorQuery;
import org.oscim.jeo.JeoUtils; import org.oscim.jeo.JeoUtils;
import org.oscim.map.Map; import org.oscim.map.Map;
import org.oscim.renderer.bucket.LineBucket; import org.oscim.renderer.bucket.LineBucket;
@@ -77,7 +72,7 @@ public class JeoVectorLayer extends JtsLayer {
VectorQuery q = new VectorQuery().bounds(b); VectorQuery q = new VectorQuery().bounds(b);
if (dbg) if (dbg)
log.debug("query {}", b); log.debug("query {}", b);
for (Feature f : mDataset.cursor(q)) { for (Feature f : mDataset.read(q)) {
if (dbg) if (dbg)
log.debug("feature {}", f); log.debug("feature {}", f);

View File

@@ -21,13 +21,8 @@ package org.oscim.layers;
import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.Envelope; import com.vividsolutions.jts.geom.Envelope;
import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.Geometry;
import io.jeo.geom.CoordinatePath;
import org.jeo.geom.CoordinatePath; import org.oscim.core.*;
import org.oscim.core.Box;
import org.oscim.core.GeometryBuffer;
import org.oscim.core.MapPosition;
import org.oscim.core.MercatorProjection;
import org.oscim.core.Tile;
import org.oscim.layers.vector.AbstractVectorLayer; import org.oscim.layers.vector.AbstractVectorLayer;
import org.oscim.map.Map; import org.oscim.map.Map;
import org.oscim.renderer.bucket.LineBucket; import org.oscim.renderer.bucket.LineBucket;

View File

@@ -21,13 +21,12 @@ package org.oscim.layers;
import com.vividsolutions.jts.geom.Envelope; import com.vividsolutions.jts.geom.Envelope;
import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.LineString; import com.vividsolutions.jts.geom.LineString;
import io.jeo.map.CartoCSS;
import org.jeo.map.CartoCSS; import io.jeo.map.RGB;
import org.jeo.map.RGB; import io.jeo.map.Rule;
import org.jeo.map.Rule; import io.jeo.map.Style;
import org.jeo.map.Style; import io.jeo.vector.Feature;
import org.jeo.vector.Feature; import io.jeo.vector.VectorDataset;
import org.jeo.vector.VectorDataset;
import org.oscim.backend.canvas.Color; import org.oscim.backend.canvas.Color;
import org.oscim.jeo.JeoUtils; import org.oscim.jeo.JeoUtils;
import org.oscim.map.Map; import org.oscim.map.Map;

View File

@@ -18,21 +18,15 @@
package org.oscim.test; package org.oscim.test;
import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.Geometry;
import io.jeo.carto.Carto;
import org.jeo.carto.Carto; import io.jeo.data.Dataset;
import org.jeo.data.Dataset; import io.jeo.data.mem.MemVectorDataset;
import org.jeo.data.mem.MemVector; import io.jeo.data.mem.MemWorkspace;
import org.jeo.data.mem.MemWorkspace; import io.jeo.geojson.GeoJSONDataset;
import org.jeo.geojson.GeoJSONDataset; import io.jeo.geojson.GeoJSONReader;
import org.jeo.geojson.GeoJSONReader; import io.jeo.geom.GeomBuilder;
import org.jeo.geom.GeomBuilder; import io.jeo.map.Style;
import org.jeo.map.Style; import io.jeo.vector.*;
import org.jeo.vector.Feature;
import org.jeo.vector.Features;
import org.jeo.vector.Schema;
import org.jeo.vector.SchemaBuilder;
import org.jeo.vector.VectorDataset;
import org.jeo.vector.VectorQuery;
import org.oscim.backend.canvas.Color; import org.oscim.backend.canvas.Color;
import org.oscim.layers.OSMIndoorLayer; import org.oscim.layers.OSMIndoorLayer;
import org.oscim.layers.tile.buildings.BuildingLayer; import org.oscim.layers.tile.buildings.BuildingLayer;
@@ -42,11 +36,7 @@ import org.oscim.renderer.MapRenderer;
import org.oscim.theme.styles.TextStyle; import org.oscim.theme.styles.TextStyle;
import org.oscim.tiling.source.oscimap4.OSciMap4TileSource; import org.oscim.tiling.source.oscimap4.OSciMap4TileSource;
import java.io.File; import java.io.*;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
public class JeoTest { public class JeoTest {
@@ -101,13 +91,13 @@ public class JeoTest {
GeoJSONReader r = new GeoJSONReader(); GeoJSONReader r = new GeoJSONReader();
@SuppressWarnings("resource") @SuppressWarnings("resource")
MemWorkspace mem = new MemWorkspace(); MemWorkspace mem = new MemWorkspace("");
//mem.put("layer", data); //mem.put("layer", data);
try { try {
Schema s = new SchemaBuilder("way").schema(); Schema s = new SchemaBuilder("way").schema();
MemVector memData = mem.create(s); MemVectorDataset memData = mem.create(s);
for (Feature f : r.features(is)) { for (Feature f : r.features(is)) {
//System.out.println("loaded: " + f); //System.out.println("loaded: " + f);
@@ -133,7 +123,7 @@ public class JeoTest {
if (memory) { if (memory) {
@SuppressWarnings("resource") @SuppressWarnings("resource")
MemWorkspace mem = new MemWorkspace(); MemWorkspace mem = new MemWorkspace("");
//mem.put("layer", data); //mem.put("layer", data);
try { try {
@@ -141,9 +131,9 @@ public class JeoTest {
Schema s = data.schema(); Schema s = data.schema();
VectorQuery q = new VectorQuery(); VectorQuery q = new VectorQuery();
MemVector memData = mem.create(s); MemVectorDataset memData = mem.create(s);
for (Feature f : data.cursor(q)) { for (Feature f : data.read(q)) {
memData.add(f); memData.add(f);
} }
@@ -160,14 +150,14 @@ public class JeoTest {
GeomBuilder gb = new GeomBuilder(4326); GeomBuilder gb = new GeomBuilder(4326);
@SuppressWarnings("resource") @SuppressWarnings("resource")
MemWorkspace mem = new MemWorkspace(); MemWorkspace mem = new MemWorkspace("");
Schema schema = new SchemaBuilder(layer) Schema schema = new SchemaBuilder(layer)
.field("geometry", Geometry.class) .field("geometry", Geometry.class)
.field("id", Integer.class) .field("id", Integer.class)
.field("name", String.class) .field("name", String.class)
.field("cost", Double.class).schema(); .field("cost", Double.class).schema();
MemVector data; MemVectorDataset data;
try { try {
data = mem.create(schema); data = mem.create(schema);
} catch (UnsupportedOperationException e) { } catch (UnsupportedOperationException e) {
@@ -181,15 +171,16 @@ public class JeoTest {
Geometry g = gb.point(0, 0).toPoint(); Geometry g = gb.point(0, 0).toPoint();
//g.setSRID(4326); //g.setSRID(4326);
data.add(Features.create(null, data.schema(),
data.add(new ListFeature(data.schema(),
g, 1, "anvil", g, 1, "anvil",
10.99)); 10.99));
data.add(Features.create(null, data.schema(), data.add(new ListFeature(data.schema(),
gb.points(10, 10, 20, 20).toLineString(), gb.points(10, 10, 20, 20).toLineString(),
2, "bomb", 11.99)); 2, "bomb", 11.99));
data.add(Features.create(null, data.schema(), data.add(new ListFeature(data.schema(),
gb.point(100, 10).toPoint().buffer(10), gb.point(100, 10).toPoint().buffer(10),
3, "dynamite", 12.99)); 3, "dynamite", 12.99));

View File

@@ -0,0 +1,452 @@
/* Copyright 2013 The jeo project. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.oscim.theme.carto;
import com.vividsolutions.jts.geom.Geometry;
import io.jeo.util.Util;
import io.jeo.vector.Feature;
import io.jeo.vector.Field;
import io.jeo.vector.Schema;
import io.jeo.vector.SchemaBuilder;
import org.osgeo.proj4j.CoordinateReferenceSystem;
import java.util.*;
/**
* Basic feature implementation.
*
* @author Justin Deoliveira, Boundless
* <p>
* Adapted by Jan Lippert to the changes made in https://github.com/jeo/jeo/commit/e28695ccc8530ae6d1a2dff1fbd1e11449ef949f
*/
public class BasicFeature implements Feature {
/**
* feature identifier
*/
protected String id;
/**
* Underlying feature storage.
*/
protected Storage storage;
/**
* Constructor taking a feature identifier.
*
* @param id The feature id, if <code>null</code> an identifier will be generated.
*/
public BasicFeature(String id) {
this(id, (Schema) null);
}
/**
* Constructor taking a feature identifier and an explicit schema object.
*
* @param id The feature id, if <code>null</code> an identifier will be generated.
* @param schema The feature schema, if <code>null</code> the schema will be always be derived
*/
public BasicFeature(String id, Schema schema) {
this(id, (Storage)
(schema != null ? new ListStorage(null, schema) : new MapStorage(null, schema)));
}
/**
* Constructs a feature from an identifier and a list of values.
*
* @param id The feature id, if <code>null</code> an identifier will be generated.
* @param values The feature values.
*/
public BasicFeature(String id, List<Object> values) {
this(id, values, null);
}
/**
* Constructs a feature from an identifier, a list of values, and a schema.
*
* @param id The feature id, if <code>null</code> an identifier will be generated.
* @param values The feature values.
* @param schema The feature schema, if <code>null</code> the schema will be always be derived
*/
public BasicFeature(String id, List<Object> values, Schema schema) {
this(id, new ListStorage(values, schema));
}
/**
* Constructs a feature from an identifier and a map of values.
*
* @param id The feature id, if <code>null</code> an identifier will be generated.
* @param values The feature values.
*/
public BasicFeature(String id, Map<String, Object> values) {
this(id, values, null);
}
/**
* Constructs a feature from an identifier, a map of values, and a schema.
*
* @param id The feature id, if <code>null</code> an identifier will be generated.
* @param values The feature values.
* @param schema The feature schema, if <code>null</code> the schema will be always be derived
*/
public BasicFeature(String id, Map<String, Object> values, Schema schema) {
this(id, new MapStorage(values, schema));
}
/**
* Constructor taking an identifier and feature storage object directly.
* <p>
* This constructor is typically only used for subclasses that need to implement custom feature
* storage.
* </p>
*/
protected BasicFeature(String id, Storage storage) {
this.id = id != null ? id : Util.uuid();
this.storage = storage;
}
@Override
public String id() {
return id;
}
/*@Override
public CoordinateReferenceSystem getCRS() {
return crs;
}*/
public BasicFeature crs(CoordinateReferenceSystem crs) {
storage.crs(crs);
return this;
}
@Override
public boolean has(String key) {
return storage.has(key);
}
@Override
public Object get(String key) {
return storage.get(key);
}
@Override
public BasicFeature put(String key, Object val) {
storage.put(key, val);
return this;
}
@Override
public BasicFeature put(Geometry g) {
//TODO:optimize before triggering schema creation
Field gf = storage.schema(true).geometry();
if (gf == null) {
throw new IllegalArgumentException("Feature schema has no geometry");
}
return put(gf.name(), g);
}
@Override
public Geometry geometry() {
return storage.geometry();
}
@Override
public Map<String, Object> map() {
return storage.map();
}
@Override
public String toString() {
return new StringBuilder(id).append(map()).toString();
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result + ((storage == null) ? 0 : storage.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
BasicFeature other = (BasicFeature) obj;
if (id == null) {
return other.id == null;
}
return id.equals(other.id);
}
protected static abstract class Storage {
Schema schema;
CoordinateReferenceSystem crs;
protected Storage(Schema schema) {
this.schema = schema;
}
protected Storage crs(CoordinateReferenceSystem crs) {
this.crs = crs;
return this;
}
protected Schema schema() {
return schema(true);
}
protected Schema schema(boolean derive) {
if (schema == null && derive) {
schema = buildSchema();
// hack to apply crs override
if (crs != null && schema.crs() == null) {
schema = SchemaBuilder.crs(schema, crs);
}
}
return schema;
}
protected Geometry geometry() {
if (schema != null) {
Field f = schema.geometry();
if (f != null) {
return (Geometry) get(f.name());
}
}
return findGeometry();
}
protected CoordinateReferenceSystem crs() {
if (crs != null) {
return crs;
}
if (schema != null) {
return schema.crs();
}
return null;
}
/**
* Method for subclasses to implement to build a schema for the feature from its underlying
* attributes.
*/
protected abstract Schema buildSchema();
/**
* Method for subclasses to implement in order to find a geometry object when no schema
* information is available.
*/
protected abstract Geometry findGeometry();
protected abstract Object get(String key);
protected abstract Object get(int index);
protected abstract void put(String key, Object value);
protected abstract void set(int index, Object value);
protected abstract List<Object> list();
protected abstract Map<String, Object> map();
protected abstract boolean has(String key);
}
static class ListStorage extends Storage {
List<Object> list;
ListStorage(List<Object> values, Schema schema) {
super(schema);
this.list = pad(values, schema);
}
List<Object> pad(List<Object> values, Schema schema) {
//copy list passed in
values = values != null ? new ArrayList<Object>(values) : new ArrayList<Object>();
//expand up to size of schema if necessary
if (schema != null) {
while (values.size() < schema.size()) {
values.add(null);
}
}
return values;
}
@Override
protected Geometry findGeometry() {
for (Object o : list) {
if (o instanceof Geometry) {
return (Geometry) o;
}
}
return null;
}
@Override
protected Schema buildSchema() {
List<Field> fields = new ArrayList<Field>();
int i = 0;
boolean g = false;
for (Object o : list) {
if (o instanceof Geometry && !g) {
//first geometry
fields.add(new Field("geometry", o.getClass()));
g = true;
} else {
//regular field
fields.add(new Field(String.format(Locale.ROOT, "field%d", i++), o != null ? o.getClass() : null));
}
}
return new Schema("feature", fields);
}
@Override
protected boolean has(String key) {
return schema().indexOf(key) >= 0;
}
@Override
protected Object get(int i) {
return list.get(i);
}
@Override
protected void set(int i, Object value) {
list.set(i, value);
}
@Override
protected Object get(String key) {
int i = schema().indexOf(key);
return i != -1 ? get(i) : null;
}
@Override
protected void put(String key, Object val) {
int i = schema().indexOf(key);
if (i == -1) {
throw new IllegalArgumentException("No such key " + key);
}
set(i, val);
}
@Override
protected List<Object> list() {
return Collections.unmodifiableList(list);
}
@Override
protected Map<String, Object> map() {
LinkedHashMap<String, Object> map = new LinkedHashMap<String, Object>();
for (Field f : schema()) {
map.put(f.name(), get(f.name()));
}
return map;
}
}
static class MapStorage extends Storage {
Map<String, Object> map;
MapStorage(Map<String, Object> values, Schema schema) {
super(schema);
this.map = values != null ?
new LinkedHashMap<String, Object>(values) : new LinkedHashMap<String, Object>();
}
@Override
protected Schema buildSchema() {
List<Field> fields = new ArrayList<Field>();
for (Map.Entry<String, Object> e : map.entrySet()) {
fields.add(new Field(e.getKey(), e.getValue() != null ? e.getValue().getClass() : null));
}
return new Schema("feature", fields);
}
@Override
protected Geometry findGeometry() {
for (Object obj : map.values()) {
if (obj instanceof Geometry) {
return (Geometry) obj;
}
}
return null;
}
@Override
protected boolean has(String key) {
return map.containsKey(key);
}
@Override
protected Object get(String key) {
return map.get(key);
}
@Override
protected void put(String key, Object val) {
if (!map.containsKey(key)) {
//new field, clear cached schema
schema = null;
}
map.put(key, val);
}
@Override
protected Object get(int index) {
return Util.get(map, index);
}
@Override
protected void set(int index, Object value) {
Util.set(map, index, value);
}
@Override
protected List<Object> list() {
List<Object> list = new ArrayList<Object>();
for (Field f : schema()) {
list.add(get(f.name()));
}
return list;
}
@Override
protected Map<String, Object> map() {
return Collections.unmodifiableMap(map);
}
}
}

View File

@@ -16,11 +16,9 @@
*/ */
package org.oscim.theme.carto; package org.oscim.theme.carto;
import org.jeo.vector.BasicFeature;
import org.oscim.core.Tag; import org.oscim.core.Tag;
import org.oscim.core.TagSet; import org.oscim.core.TagSet;
import java.util.List;
import java.util.Map; import java.util.Map;
import static java.lang.System.out; import static java.lang.System.out;
@@ -64,27 +62,10 @@ class MatcherFeature extends BasicFeature {
return null; return null;
} }
@Override
public List<Object> list() {
out.println("EEEK list()");
return null;
}
@Override @Override
public Map<String, Object> map() { public Map<String, Object> map() {
out.println("EEEK map()"); out.println("EEEK map()");
return null; return null;
} }
@Override
public Object get(int arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public BasicFeature set(int arg0, Object arg1) {
// TODO Auto-generated method stub
return null;
}
} }

View File

@@ -1,11 +1,7 @@
package org.oscim.theme.carto; package org.oscim.theme.carto;
import org.jeo.carto.Carto; import io.jeo.carto.Carto;
import org.jeo.map.CartoCSS; import io.jeo.map.*;
import org.jeo.map.RGB;
import org.jeo.map.Rule;
import org.jeo.map.RuleList;
import org.jeo.map.Style;
import org.oscim.core.GeometryBuffer.GeometryType; import org.oscim.core.GeometryBuffer.GeometryType;
import org.oscim.core.MapElement; import org.oscim.core.MapElement;
import org.oscim.core.Tag; import org.oscim.core.Tag;
@@ -19,9 +15,9 @@ import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import static io.jeo.map.CartoCSS.BACKGROUND_COLOR;
import static io.jeo.map.CartoCSS.OPACITY;
import static java.lang.System.out; import static java.lang.System.out;
import static org.jeo.map.CartoCSS.BACKGROUND_COLOR;
import static org.jeo.map.CartoCSS.OPACITY;
public class RenderTheme implements IRenderTheme { public class RenderTheme implements IRenderTheme {

View File

@@ -3,7 +3,7 @@ apply plugin: 'maven'
dependencies { dependencies {
api project(':vtm') api project(':vtm')
api 'com.fasterxml.jackson.core:jackson-core:2.8.4' api 'com.fasterxml.jackson.core:jackson-core:2.9.9'
} }
sourceSets { sourceSets {

View File

@@ -3,7 +3,8 @@ apply plugin: 'maven'
dependencies { dependencies {
api project(':vtm') api project(':vtm')
api 'org.locationtech.jts:jts-core:1.15.0' // https://github.com/locationtech/jts/issues/145
api 'org.locationtech.jts:jts-core:1.15.1'
} }
sourceSets { sourceSets {

View File

@@ -1,6 +1,7 @@
/* /*
* Copyright 2014 Hannes Janetzek * Copyright 2014 Hannes Janetzek
* Copyright 2016-2018 devemux86 * Copyright 2016-2019 devemux86
* Copyright 2020 marq24
* *
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org). * This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
* *
@@ -17,18 +18,11 @@
*/ */
package org.oscim.layers.vector; package org.oscim.layers.vector;
import org.locationtech.jts.geom.Envelope;
import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.geom.LineString;
import org.locationtech.jts.geom.Point; import org.locationtech.jts.geom.Point;
import org.locationtech.jts.geom.Polygon; import org.locationtech.jts.geom.*;
import org.locationtech.jts.simplify.DouglasPeuckerSimplifier; import org.locationtech.jts.simplify.DouglasPeuckerSimplifier;
import org.oscim.backend.canvas.Color; import org.oscim.backend.canvas.Color;
import org.oscim.core.Box; import org.oscim.core.*;
import org.oscim.core.GeoPoint;
import org.oscim.core.GeometryBuffer;
import org.oscim.core.MapPosition;
import org.oscim.core.Tile;
import org.oscim.event.Gesture; import org.oscim.event.Gesture;
import org.oscim.event.GestureListener; import org.oscim.event.GestureListener;
import org.oscim.event.MotionEvent; import org.oscim.event.MotionEvent;
@@ -124,7 +118,7 @@ public class VectorLayer extends AbstractVectorLayer<Drawable> implements Gestur
* *
* @param drawable * @param drawable
*/ */
public void add(Drawable drawable) { public synchronized void add(Drawable drawable) {
mDrawables.insert(bbox(drawable.getGeometry(), drawable.getStyle()), drawable); mDrawables.insert(bbox(drawable.getGeometry(), drawable.getStyle()), drawable);
} }
@@ -135,7 +129,7 @@ public class VectorLayer extends AbstractVectorLayer<Drawable> implements Gestur
* @param geometry * @param geometry
* @param style * @param style
*/ */
public synchronized void add(Geometry geometry, Style style) { synchronized void add(Geometry geometry, Style style) {
mDrawables.insert(bbox(geometry, style), new GeometryWithStyle(geometry, style)); mDrawables.insert(bbox(geometry, style), new GeometryWithStyle(geometry, style));
} }
@@ -208,11 +202,11 @@ public class VectorLayer extends AbstractVectorLayer<Drawable> implements Gestur
for (Drawable d : tmpDrawables) { for (Drawable d : tmpDrawables) {
Style style = d.getStyle(); Style style = d.getStyle();
draw(t, level, d, style);
if (style != lastStyle) if (lastStyle != null && lastStyle != style)
level += 2; level += 2;
draw(t, level, d, style);
lastStyle = style; lastStyle = style;
} }
} }

View File

@@ -26,7 +26,7 @@ public class PointDrawable extends JtsDrawable {
} }
public PointDrawable(GeoPoint point, Style style) { public PointDrawable(GeoPoint point, Style style) {
this(point.getLongitude(), point.getLatitude(), style); this(point.getLatitude(), point.getLongitude(), style);
} }
public PointDrawable(double lat, double lon, Style style) { public PointDrawable(double lat, double lon, Style style) {

View File

@@ -1,6 +1,6 @@
/* /*
* Copyright 2014 Hannes Janetzek * Copyright 2014 Hannes Janetzek
* Copyright 2016-2018 devemux86 * Copyright 2016-2019 devemux86
* *
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org). * This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
* *
@@ -94,7 +94,7 @@ public class Style {
public static class Builder { public static class Builder {
private float strokeWidth = 1f; private float strokeWidth = 1f;
private int strokeColor = Color.GRAY; public int strokeColor = Color.GRAY;
private int fillColor = Color.GRAY; private int fillColor = Color.GRAY;
private float fillAlpha = 0.25f; private float fillAlpha = 0.25f;

View File

@@ -3,7 +3,7 @@ apply plugin: 'maven'
dependencies { dependencies {
api project(':vtm') api project(':vtm')
api 'com.wdtinc:mapbox-vector-tile:3.0.0' api 'com.wdtinc:mapbox-vector-tile:3.1.0'
} }
sourceSets { sourceSets {

View File

@@ -65,6 +65,6 @@ public class MapilionMvtTileSource extends UrlTileSource {
@Override @Override
public ITileDataSource getDataSource() { public ITileDataSource getDataSource() {
return new OverzoomTileDataSource(new UrlTileDataSource(this, new MvtTileDecoder(locale), getHttpEngine()), mOverZoom); return new OverzoomTileDataSource(new UrlTileDataSource(this, new TileDecoder(locale), getHttpEngine()), mOverZoom);
} }
} }

View File

@@ -69,6 +69,6 @@ public class MapzenMvtTileSource extends UrlTileSource {
@Override @Override
public ITileDataSource getDataSource() { public ITileDataSource getDataSource() {
return new OverzoomTileDataSource(new UrlTileDataSource(this, new MvtTileDecoder(locale), getHttpEngine()), mOverZoom); return new OverzoomTileDataSource(new UrlTileDataSource(this, new TileDecoder(locale), getHttpEngine()), mOverZoom);
} }
} }

View File

@@ -66,6 +66,6 @@ public class NextzenMvtTileSource extends UrlTileSource {
@Override @Override
public ITileDataSource getDataSource() { public ITileDataSource getDataSource() {
return new OverzoomTileDataSource(new UrlTileDataSource(this, new MvtTileDecoder(locale), getHttpEngine()), mOverZoom); return new OverzoomTileDataSource(new UrlTileDataSource(this, new TileDecoder(locale), getHttpEngine()), mOverZoom);
} }
} }

View File

@@ -69,6 +69,6 @@ public class OpenMapTilesMvtTileSource extends UrlTileSource {
@Override @Override
public ITileDataSource getDataSource() { public ITileDataSource getDataSource() {
return new OverzoomTileDataSource(new UrlTileDataSource(this, new MvtTileDecoder(locale), getHttpEngine()), mOverZoom); return new OverzoomTileDataSource(new UrlTileDataSource(this, new TileDecoder(locale), getHttpEngine()), mOverZoom);
} }
} }

View File

@@ -42,7 +42,7 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.Map; import java.util.Map;
public class MvtTileDecoder implements ITileDecoder { public class TileDecoder implements ITileDecoder {
private final String mLocale; private final String mLocale;
private static final float REF_TILE_SIZE = 4096.0f; private static final float REF_TILE_SIZE = 4096.0f;
@@ -52,11 +52,11 @@ public class MvtTileDecoder implements ITileDecoder {
private final MapElement mMapElement; private final MapElement mMapElement;
private ITileDataSink mTileDataSink; private ITileDataSink mTileDataSink;
public MvtTileDecoder() { public TileDecoder() {
this(""); this("");
} }
public MvtTileDecoder(String locale) { public TileDecoder(String locale) {
mLocale = locale; mLocale = locale;
mGeomFactory = new GeometryFactory(); mGeomFactory = new GeometryFactory();
mMapElement = new MapElement(); mMapElement = new MapElement();

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