14 Commits

Author SHA1 Message Date
Emux
ae7c7b1910 0.18.0 2022-06-18 14:49:11 +03:00
Emux
cf234cd7ca Update android.yml 2022-06-11 12:33:50 +03:00
Emux
4fb99aaf28 Update Gradle (#928) 2022-05-10 14:46:42 +03:00
Emux
7e09e4f2e8 CanvasAdapter: add method getDeviceScale (#925) 2022-05-08 15:14:45 +03:00
Emux
d428b689ba Update README.md 2022-04-01 16:37:39 +03:00
Emux
3c0ca26b67 Update changelog 2022-03-05 14:40:42 +02:00
Wolfgang Schramm
84ccf9d1bc [2.5D Map] PR for fixing vtm-jni64.dll (#911) 2022-03-05 14:28:55 +02:00
Emux
5442e67518 Mapsforge: overlapping map region improvements #905 (#907) 2022-02-22 18:42:10 +02:00
Emux
6fb02ec055 Mapsforge: simplification exceptions (#906) 2022-02-22 17:54:16 +02:00
Emux
825cd05150 Mapsforge: improve overlapping map regions (#905) 2022-02-22 14:08:38 +02:00
Emux
9357cf380b Update android.yml 2022-02-08 16:46:15 +02:00
Emux
670883701d Update SVG Salamander (#904) 2022-02-08 15:12:10 +02:00
Emux
86794c8838 Mapsforge: deduplicate maps, fix overlapping map regions (#903) 2022-02-08 14:33:40 +02:00
Emux
c4003bab33 Update Gradle (#902) 2022-01-26 17:49:33 +02:00
26 changed files with 408 additions and 105 deletions

View File

@@ -2,9 +2,9 @@ name: Android CI
on:
push:
branches: [ master ]
branches: [ "master" ]
pull_request:
branches: [ master ]
branches: [ "master" ]
jobs:
build:
@@ -12,12 +12,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: set up JDK 11
uses: actions/setup-java@v2
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
distribution: 'temurin'
cache: gradle
- name: Grant execute permission for gradlew

View File

@@ -29,6 +29,7 @@ If you have any questions or problems, don't hesitate to ask the Discussions for
- iOS (libGDX/RoboVM, [instructions](docs/ios.md))
- Desktop (libGDX/LWJGL, [instructions](docs/desktop.md))
- HTML5/WebGL (libGDX/GWT, [instructions](docs/web.md))
- Building VTM: set `ANDROID_HOME` environment variable with the Android SDK installation directory
### Projects
- **vtm** core library

View File

@@ -1,11 +1,5 @@
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.4'
}
plugins {
id 'com.android.application' version '7.0.4' apply false
}
allprojects {
@@ -37,13 +31,6 @@ static def versionCode() { return 1 }
def versionName() { return version }
subprojects {
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
maven { url "https://plugins.gradle.org/m2/" }
}
tasks.withType(JavaCompile) {
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7

View File

@@ -1,7 +1,17 @@
# Changelog
## New since 0.17.0
## New since 0.18.0
- Minor improvements and bug fixes
- [Solved issues](https://github.com/mapsforge/vtm/issues?q=is%3Aclosed+milestone%3A0.19.0)
## Version 0.18.0 (2022-06-18)
- Mapsforge: deduplicate maps [#903](https://github.com/mapsforge/vtm/pull/903)
- Fix overlapping map regions [#903](https://github.com/mapsforge/vtm/pull/903) [#905](https://github.com/mapsforge/vtm/pull/905)
- Fix `vtm-jni64.dll` [#911](https://github.com/mapsforge/vtm/pull/911)
- Mapsforge: simplification exceptions [#906](https://github.com/mapsforge/vtm/pull/906)
- `Parameters.SIMPLIFICATION_EXCEPTIONS`
- Minor improvements and bug fixes
- [Solved issues](https://github.com/mapsforge/vtm/issues?q=is%3Aclosed+milestone%3A0.18.0)

View File

@@ -55,7 +55,7 @@ implementation 'org.mapsforge:vtm-desktop:[CURRENT-VERSION]:natives-osx'
implementation 'org.mapsforge:vtm-desktop:[CURRENT-VERSION]:natives-windows'
implementation 'com.badlogicgames.gdx:gdx:1.9.10'
implementation 'com.badlogicgames.gdx:gdx-platform:1.9.10:natives-desktop'
implementation 'com.formdev:svgSalamander:1.1.2.4'
implementation 'com.formdev:svgSalamander:1.1.3'
```
### Desktop (LWJGL)

View File

@@ -15,5 +15,7 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
# Android operating system, and which are packaged with your app"s APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
# Enables namespacing of each library's R class so that its R class includes only the
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true

View File

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

203
jni/jni/build-windows64.xml Normal file
View File

@@ -0,0 +1,203 @@
<project name="vtm-jni-Windows-64" basedir="." default="postcompile">
<!-- include the environment -->
<property environment="env"/>
<!-- output directory for temporary object files -->
<property name="buildDir" value="target/windows64" />
<!-- output directory for the shared library -->
<property name="libsDir" value="../libs/windows64" />
<!-- the name of the shared library -->
<property name="libName" value="vtm-jni64.dll"/>
<!-- the jni header jniPlatform to use -->
<property name="jniPlatform" value="win32"/>
<!-- the compiler to use when compiling c files -->
<property name="cCompiler" value="gcc"/>
<!-- the compiler to use when compiling c++ files -->
<property name="cppCompiler" value="g++"/>
<!-- the command to use when archiving files -->
<property name="archiver" value="ar"/>
<!-- the compilerPrefix for the C & C++ compilers -->
<property name="compilerPrefix" value="x86_64-w64-mingw32-"/>
<!-- the compilerSuffix for the C & C++ compilers -->
<property name="compilerSuffix" value=".exe" />
<!-- define gcc compiler, options and files to compile -->
<property name="gcc" value="${compilerPrefix}${cCompiler}${compilerSuffix}"/>
<property name="gcc-opts" value="-c -Wall -O2 -mfpmath=sse -msse2 -fmessage-length=0 -m64 -Wall -std=c99 -O2 -ffast-math -DNDEBUG"/>
<fileset id="gcc-files" dir="./">
<exclude name="target/"/>
<include name="memcpy_wrap.c"/>
<include name="gl/utils.c"/>
<include name="libtess2/Source/bucketalloc.c"/>
<include name="libtess2/Source/dict.c"/>
<include name="libtess2/Source/geom.c"/>
<include name="libtess2/Source/mesh.c"/>
<include name="libtess2/Source/priorityq.c"/>
<include name="libtess2/Source/sweep.c"/>
<include name="libtess2/Source/tess.c"/>
</fileset>
<!-- define g++ compiler, options and files to compile -->
<property name="g++" value="${compilerPrefix}${cppCompiler}${compilerSuffix}"/>
<property name="g++-opts" value="-c -Wall -O2 -mfpmath=sse -msse2 -fmessage-length=0 -m64 -Wall -std=c99 -O2 -ffast-math -DNDEBUG -fpermissive"/>
<fileset id="g++-files" dir="./">
<exclude name="target/"/>
<include name="**/*.cpp"/>
</fileset>
<!-- define linker and options -->
<property name="linker" value="${compilerPrefix}${cppCompiler}${compilerSuffix}"/>
<property name="linker-opts" value="-Wl,--kill-at -shared -static -static-libgcc -static-libstdc++ -m64"/>
<property name="libraries" value=""/>
<!-- define stripper -->
<property name="stripper" value="${compilerPrefix}strip${compilerSuffix}"/>
<!-- cleans the build directory, removes all object files and shared libs -->
<target name="clean">
<delete includeemptydirs="true" quiet="true">
<fileset dir="${buildDir}"/>
<fileset dir="${libsDir}" includes="**/*"/>
</delete>
</target>
<target name="precompile" depends="clean">
<condition property="compiler-found">
<and>
<or>
<!-- Include both b/c Windows might be either -->
<available file="${g++}" filepath="${env.PATH}"/>
<available file="${g++}" filepath="${env.Path}"/>
</or>
<or>
<!-- Include both b/c Windows might be either -->
<available file="${gcc}" filepath="${env.PATH}"/>
<available file="${gcc}" filepath="${env.Path}"/>
</or>
</and>
</condition>
<condition property="has-compiler">
<equals arg1="${compiler-found}" arg2="true"/>
</condition>
<condition property="stripper-found">
<or>
<!-- Include both b/c Windows might be either -->
<available file="${stripper}" filepath="${env.PATH}"/>
<available file="${stripper}" filepath="${env.Path}"/>
</or>
</condition>
<condition property="should-strip">
<and>
<equals arg1="${stripper-found}" arg2="true"/>
<equals arg1="${release}" arg2="true"/>
<!-- Don't strip mac osx libs -->
<not>
<contains string="${libName}" substring="dylib"/>
</not>
</and>
</condition>
</target>
<target name="create-build-dir" depends="precompile" if="has-compiler">
<!-- FIXME this is pretty nasty :/ -->
<copy todir="${buildDir}">
<fileset refid="g++-files"/>
<fileset refid="gcc-files"/>
</copy>
<delete>
<fileset dir="${buildDir}">
<include name="*"/>
<exclude name="*.o"/>
</fileset>
</delete>
</target>
<!-- compiles all C and C++ files to object files in the build directory -->
<target name="compile" depends="create-build-dir" if="has-compiler">
<mkdir dir="${buildDir}"/>
<apply failonerror="true" executable="${g++}" dest="${buildDir}" verbose="true">
<arg line="${g++-opts}"/>
<arg value="-Ijni-headers"/>
<arg value="-Ijni-headers/${jniPlatform}"/>
<arg value="-I."/>
<arg value="-I."/>
<arg value="-Ilibtess2/Include"/>
<srcfile/>
<arg value="-o"/>
<targetfile/>
<fileset refid="g++-files"/>
<compositemapper>
<mapper type="glob" from="*.cpp" to="*.o"/>
<mapper type="glob" from="*.mm" to="*.o"/>
</compositemapper>
</apply>
<apply failonerror="true" executable="${gcc}" dest="${buildDir}" verbose="true">
<arg line="${gcc-opts}"/>
<arg value="-Ijni-headers"/>
<arg value="-Ijni-headers/${jniPlatform}"/>
<arg value="-I."/>
<arg value="-I."/>
<arg value="-Ilibtess2/Include"/>
<arg value="-Ilibtess2/Source"/>
<srcfile/>
<arg value="-o"/>
<targetfile/>
<fileset refid="gcc-files"/>
<compositemapper>
<mapper type="glob" from="*.c" to="*.o"/>
<mapper type="glob" from="*.m" to="*.o"/>
</compositemapper>
</apply>
</target>
<!-- links the shared library based on the previously compiled object files -->
<target name="link" depends="compile" if="has-compiler">
<fileset dir="${buildDir}" id="objFileSet">
<patternset>
<include name="**/*.o" />
</patternset>
</fileset>
<pathconvert pathsep=" " property="objFiles" refid="objFileSet" />
<mkdir dir="${libsDir}" />
<exec executable="${linker}" failonerror="true" dir="${buildDir}">
<arg line="${linker-opts}" />
<arg value="-o" />
<arg path="${libsDir}/${libName}" />
<arg line="${objFiles}"/>
<arg line="${libraries}" />
</exec>
</target>
<!-- strips the shared library of debug symbols -->
<target name="strip" depends="link" if="should-strip">
<exec executable="${stripper}" failonerror="true" dir="${buildDir}">
<arg value="--strip-unneeded"/>
<arg path="${libsDir}/${libName}" />
</exec>
</target>
<!-- copy dll into dev environment
<target name="copyDLL" depends="link">
<copy
file ="${libsDir}/${libName}"
todir ="C:/DAT/MT/mytourbook/bundles/net.tourbook.ext.vtm.windows/natives"
/>
</target>
-->
<target name="postcompile" depends="strip">
</target>
</project>

View File

@@ -102,7 +102,7 @@ matrix4_proj2D(float* mat, float* vec, float *out);
jlong JNI(alloc)(JNIEnv *env, jclass* clazz)
{
return (long) calloc(16, sizeof(float));
return (jlong) calloc(16, sizeof(float));
}
jobject JNI(getBuffer)(JNIEnv *env, jclass* clazz,jlong ptr){

View File

@@ -23,7 +23,7 @@
//@line:131
{
if (size <= 0)
return (long)tessNewTess(0);
return (jlong)tessNewTess(0);
if (size > 10)
size = 10;
TESSalloc ma;
@@ -39,7 +39,7 @@
ma.regionBucketSize = 1 << size; // 256
ma.extraVertices = 8;
//ma.extraVertices = 256;
return (long)tessNewTess(&ma);
return (jlong)tessNewTess(&ma);
}
}

View File

@@ -1,3 +1,18 @@
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
rootProject.name = 'vtm-parent'
include ':vtm'
include ':vtm-android'

View File

@@ -16,11 +16,11 @@ dependencies {
implementation project(':vtm-gdx')
implementation project(':vtm-gdx-poi3d')
implementation 'org.mapsforge:mapsforge-poi-android:0.17.0'
implementation 'org.mapsforge:sqlite-android:0.17.0:natives-armeabi-v7a'
implementation 'org.mapsforge:sqlite-android:0.17.0:natives-arm64-v8a'
implementation 'org.mapsforge:sqlite-android:0.17.0:natives-x86'
implementation 'org.mapsforge:sqlite-android:0.17.0:natives-x86_64'
implementation 'org.mapsforge:mapsforge-poi-android:0.18.0'
implementation 'org.mapsforge:sqlite-android:0.18.0:natives-armeabi-v7a'
implementation 'org.mapsforge:sqlite-android:0.18.0:natives-arm64-v8a'
implementation 'org.mapsforge:sqlite-android:0.18.0:natives-x86'
implementation 'org.mapsforge:sqlite-android:0.18.0:natives-x86_64'
}
android {

View File

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

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 devemux86
* Copyright 2016-2022 devemux86
* Copyright 2018-2019 Gustl22
*
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
@@ -67,6 +67,7 @@ public class MapsforgeTest extends GdxMapApp {
mapFileTileSource.setMapFile(mapFile.getAbsolutePath());
tileSource.add(mapFileTileSource);
}
//tileSource.setDeduplicate(true);
//tileSource.setPreferredLanguage("en");
VectorTileLayer l = mMap.setBaseMap(tileSource);
@@ -139,13 +140,13 @@ public class MapsforgeTest extends GdxMapApp {
for (String arg : args) {
File mapFile = new File(arg);
if (!mapFile.exists()) {
throw new IllegalArgumentException("file does not exist: " + mapFile);
System.err.println("file does not exist: " + mapFile);
} else if (!mapFile.isFile()) {
throw new IllegalArgumentException("not a file: " + mapFile);
System.err.println("not a file: " + mapFile);
} else if (!mapFile.canRead()) {
throw new IllegalArgumentException("cannot read file: " + mapFile);
}
result.add(mapFile);
System.err.println("cannot read file: " + mapFile);
} else
result.add(mapFile);
}
return result;
}

View File

@@ -10,11 +10,11 @@ dependencies {
implementation 'com.fifesoft:rsyntaxtextarea:2.6.1'
implementation 'com.jtattoo:JTattoo:1.6.11'
implementation 'org.mapsforge:mapsforge-core:0.17.0'
implementation 'org.mapsforge:mapsforge-map:0.17.0'
implementation 'org.mapsforge:mapsforge-map-awt:0.17.0'
implementation 'org.mapsforge:mapsforge-map-reader:0.17.0'
implementation 'org.mapsforge:mapsforge-themes:0.17.0'
implementation 'org.mapsforge:mapsforge-core:0.18.0'
implementation 'org.mapsforge:mapsforge-map:0.18.0'
implementation 'org.mapsforge:mapsforge-map-awt:0.18.0'
implementation 'org.mapsforge:mapsforge-map-reader:0.18.0'
implementation 'org.mapsforge:mapsforge-themes:0.18.0'
implementation 'net.sf.kxml:kxml2:2.3.0'
}

View File

@@ -1,6 +1,6 @@
/*
* Copyright 2013 Hannes Janetzek
* Copyright 2016-2021 devemux86
* Copyright 2016-2022 devemux86
* Copyright 2017 Longri
* Copyright 2021 eddiemuc
*
@@ -250,8 +250,12 @@ public abstract class CanvasAdapter {
return new File(parentPath, pathName);
}
public static float getDeviceScale() {
return CanvasAdapter.dpi / CanvasAdapter.DEFAULT_DPI;
}
public static float getScale() {
return (CanvasAdapter.dpi / CanvasAdapter.DEFAULT_DPI) * userScale;
return getDeviceScale() * userScale;
}
protected static void init(CanvasAdapter adapter) {

View File

@@ -2,7 +2,7 @@
* Copyright 2012 Hannes Janetzek
* Copyright 2016 Andrey Novikov
* Copyright 2017-2019 Gustl22
* Copyright 2018-2019 devemux86
* Copyright 2018-2022 devemux86
* Copyright 2019 marq24
*
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
@@ -38,6 +38,8 @@ public class MapElement extends GeometryBuffer {
*/
public int layer;
public int level;
public final TagSet tags = new TagSet();
public MapElement() {
@@ -61,6 +63,7 @@ public class MapElement extends GeometryBuffer {
this.centroidPosition = element.centroidPosition;
this.labelPosition = element.labelPosition;
this.setLayer(element.layer);
this.level = element.level;
}
/**
@@ -121,6 +124,7 @@ public class MapElement extends GeometryBuffer {
@Override
public MapElement clear() {
layer = 5;
level = 0;
super.clear();
return this;
}

View File

@@ -1,7 +1,7 @@
/*
* Copyright 2013 Hannes Janetzek
* Copyright 2016 Andrey Novikov
* Copyright 2016 devemux86
* Copyright 2016-2022 devemux86
* Copyright 2017-2019 Gustl22
*
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
@@ -22,6 +22,7 @@ package org.oscim.core;
import org.oscim.utils.Utils;
import java.util.Arrays;
import java.util.Collection;
/**
* The Class TagSet holds a set of Tags.
@@ -219,6 +220,20 @@ public class TagSet {
return false;
}
/**
* Checks if any tag is contained in TagSet.
*
* @param tags the tags
* @return true, iff any tag is in TagSet
*/
public boolean contains(Collection<Tag> tags) {
for (Tag tag : tags) {
if (contains(tag))
return true;
}
return false;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();

View File

@@ -1,6 +1,6 @@
/*
* Copyright 2012-2014 Hannes Janetzek
* Copyright 2016-2019 devemux86
* Copyright 2016-2022 devemux86
*
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
*
@@ -18,28 +18,13 @@
package org.oscim.layers.tile.vector;
import org.oscim.core.GeometryBuffer.GeometryType;
import org.oscim.core.MapElement;
import org.oscim.core.MercatorProjection;
import org.oscim.core.Tag;
import org.oscim.core.TagSet;
import org.oscim.core.Tile;
import org.oscim.core.*;
import org.oscim.layers.tile.MapTile;
import org.oscim.layers.tile.TileLoader;
import org.oscim.renderer.bucket.CircleBucket;
import org.oscim.renderer.bucket.LineBucket;
import org.oscim.renderer.bucket.LineTexBucket;
import org.oscim.renderer.bucket.MeshBucket;
import org.oscim.renderer.bucket.PolygonBucket;
import org.oscim.renderer.bucket.RenderBuckets;
import org.oscim.renderer.bucket.*;
import org.oscim.theme.IRenderTheme;
import org.oscim.theme.RenderTheme;
import org.oscim.theme.styles.AreaStyle;
import org.oscim.theme.styles.CircleStyle;
import org.oscim.theme.styles.ExtrusionStyle;
import org.oscim.theme.styles.LineStyle;
import org.oscim.theme.styles.RenderStyle;
import org.oscim.theme.styles.SymbolStyle;
import org.oscim.theme.styles.TextStyle;
import org.oscim.theme.styles.*;
import org.oscim.tiling.ITileDataSource;
import org.oscim.tiling.QueryResult;
import org.slf4j.Logger;
@@ -209,7 +194,7 @@ public class VectorTileLoader extends TileLoader implements RenderStyle.Callback
if (element.type == GeometryType.POINT) {
renderNode(renderTheme.matchElement(element.type, tags, mTile.zoomLevel));
} else {
mCurBucket = getValidLayer(element.layer) * renderTheme.getLevels();
mCurBucket = getValidLayer(element.layer) * renderTheme.getLevels() * (element.level > 0 ? element.level : 1);
renderWay(renderTheme.matchElement(element.type, tags, mTile.zoomLevel));
}
clearState();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2018 devemux86
* Copyright 2016-2022 devemux86
*
* This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
@@ -17,8 +17,15 @@ package org.oscim.tiling;
import org.oscim.backend.canvas.Bitmap;
import org.oscim.core.MapElement;
import java.util.HashSet;
import java.util.Set;
public class TileDataSink implements ITileDataSink {
public final Set<Integer> hashPois = new HashSet<>();
public final Set<Integer> hashWays = new HashSet<>();
public int level, levels;
private QueryResult result;
private final ITileDataSink sink;

View File

@@ -2,7 +2,7 @@
* Copyright 2010, 2011, 2012 mapsforge.org
* Copyright 2013, 2014 Hannes Janetzek
* Copyright 2014-2015 Ludwig M Brinckmann
* Copyright 2016-2020 devemux86
* Copyright 2016-2022 devemux86
* Copyright 2016 Andrey Novikov
* Copyright 2017-2018 Gustl22
* Copyright 2018 Bezzu
@@ -31,6 +31,7 @@ import org.oscim.layers.tile.MapTile;
import org.oscim.layers.tile.buildings.BuildingLayer;
import org.oscim.tiling.ITileDataSink;
import org.oscim.tiling.ITileDataSource;
import org.oscim.tiling.TileDataSink;
import org.oscim.tiling.source.mapfile.header.SubFileParameter;
import org.oscim.utils.Parameters;
import org.oscim.utils.geom.TileClipper;
@@ -224,6 +225,8 @@ public class MapDatabase implements ITileDataSource {
private int zoomLevelMin = 0;
private int zoomLevelMax = Byte.MAX_VALUE;
private boolean deduplicate;
public MapDatabase(MapFileTileSource tileSource) throws IOException {
mTileSource = tileSource;
try {
@@ -306,7 +309,10 @@ public class MapDatabase implements ITileDataSource {
QueryCalculations.calculateBaseTiles(queryParameters, tile, subFileParameter);
QueryCalculations.calculateBlocks(queryParameters, subFileParameter);
processBlocks(sink, queryParameters, subFileParameter);
if (deduplicate)
processBlocks(sink, queryParameters, subFileParameter, tile.getBoundingBox(), Selector.ALL, new MapReadResult());
else
processBlocks(sink, queryParameters, subFileParameter);
} catch (IOException e) {
log.error(e.getMessage());
sink.completed(FAILED);
@@ -424,6 +430,10 @@ public class MapDatabase implements ITileDataSource {
}
}
void setDeduplicate(boolean deduplicate) {
this.deduplicate = deduplicate;
}
private void setTileClipping(QueryParameters queryParameters, SubFileParameter subFileParameter,
long currentRow, long currentCol) {
long numRows = queryParameters.toBlockY - queryParameters.fromBlockY;
@@ -694,6 +704,7 @@ public class MapDatabase implements ITileDataSource {
e.setLayer(layer);
PointOfInterest poi = null;
if (pois != null) {
List<Tag> tags = new ArrayList<>();
for (int i = 0; i < e.tags.size(); i++)
@@ -702,12 +713,15 @@ public class MapDatabase implements ITileDataSource {
// depending on the zoom level configuration the poi can lie outside
// the tile requested, we filter them out here
if (!filterRequired || boundingBox.contains(position)) {
pois.add(new PointOfInterest(layer, tags, position));
poi = new PointOfInterest(layer, tags, position);
pois.add(poi);
}
}
if (mapDataSink != null)
mapDataSink.process(e);
if (mapDataSink != null) {
if (!deduplicate || poi == null || (mapDataSink instanceof TileDataSink && ((TileDataSink) mapDataSink).hashPois.add(poi.hashCode())))
mapDataSink.process(e);
}
}
return true;
@@ -822,6 +836,7 @@ public class MapDatabase implements ITileDataSource {
|| e.tags.contains(TAG_ISSEA)
|| e.tags.contains(TAG_SEA)
|| e.tags.contains(TAG_NOSEA)
|| e.tags.contains(Parameters.SIMPLIFICATION_EXCEPTIONS)
|| deltaLon > minDeltaLon || deltaLon < -minDeltaLon
|| deltaLat > minDeltaLat || deltaLat < -minDeltaLat)) {
// Point reduction except lines and land/sea polygons
@@ -1047,6 +1062,7 @@ public class MapDatabase implements ITileDataSource {
e.setLayer(layer);
Way way = null;
if (ways != null) {
BoundingBox wayFilterBbox = boundingBox.extendMeters(wayFilterDistance);
GeoPoint[][] wayNodesArray = wayNodes.toArray(new GeoPoint[wayNodes.size()][]);
@@ -1056,13 +1072,19 @@ public class MapDatabase implements ITileDataSource {
tags.add(e.tags.get(i));
if (Selector.ALL == selector || hasName || hasHouseNr || hasRef || wayAsLabelTagFilter(tags)) {
GeoPoint labelPos = labelPosition != null ? new GeoPoint(labelPosition[1] / 1E6, labelPosition[0] / 1E6) : null;
ways.add(new Way(layer, tags, wayNodesArray, labelPos, e.type));
way = new Way(layer, tags, wayNodesArray, labelPos, e.type);
ways.add(way);
}
}
}
if (mapDataSink != null)
mapDataSink.process(e);
if (mapDataSink != null) {
if (!deduplicate || way == null || (mapDataSink instanceof TileDataSink && ((TileDataSink) mapDataSink).hashWays.add(way.hashCode()))) {
if (mapDataSink instanceof TileDataSink)
e.level = e.isLine() ? ((TileDataSink) mapDataSink).levels : ((TileDataSink) mapDataSink).level;
mapDataSink.process(e);
}
}
}
}

View File

@@ -1,7 +1,7 @@
/*
* Copyright 2010, 2011, 2012, 2013 mapsforge.org
* Copyright 2014-2015 Ludwig M Brinckmann
* Copyright 2017 devemux86
* Copyright 2015-2022 devemux86
*
* This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
@@ -17,13 +17,21 @@
package org.oscim.tiling.source.mapfile;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* An immutable container for the data returned from a MapDataStore.
*/
public class MapReadResult {
/**
* Hash codes.
*/
private final Set<Integer> hashPois = new HashSet<>();
private final Set<Integer> hashWays = new HashSet<>();
/**
* True if the read area is completely covered by water, false otherwise.
*/
@@ -50,8 +58,8 @@ public class MapReadResult {
}
/**
* Adds other MapReadResult by combining pois and ways. Optionally, deduplication can
* be requested (much more expensive).
* Adds other MapReadResult by combining pois and ways.
* Optionally deduplication can be requested (more expensive).
*
* @param other the MapReadResult to add to this.
* @param deduplicate true if check for duplicates is required.
@@ -59,12 +67,12 @@ public class MapReadResult {
public void add(MapReadResult other, boolean deduplicate) {
if (deduplicate) {
for (PointOfInterest poi : other.pointOfInterests) {
if (!this.pointOfInterests.contains(poi)) {
if (this.hashPois.add(poi.hashCode())) {
this.pointOfInterests.add(poi);
}
}
for (Way way : other.ways) {
if (!this.ways.contains(way)) {
if (this.hashWays.add(way.hashCode())) {
this.ways.add(way);
}
}
@@ -73,5 +81,4 @@ public class MapReadResult {
this.ways.addAll(other.ways);
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2018 devemux86
* Copyright 2016-2022 devemux86
*
* This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
@@ -18,6 +18,7 @@ import org.oscim.core.Tile;
import org.oscim.layers.tile.MapTile;
import org.oscim.tiling.ITileDataSink;
import org.oscim.tiling.ITileDataSource;
import org.oscim.tiling.QueryResult;
import org.oscim.tiling.TileDataSink;
import java.util.ArrayList;
@@ -25,9 +26,15 @@ import java.util.List;
public class MultiMapDatabase implements ITileDataSource {
private final boolean deduplicate;
private final List<MapDatabase> mapDatabases = new ArrayList<>();
public MultiMapDatabase() {
this(false);
}
public MultiMapDatabase(boolean deduplicate) {
this.deduplicate = deduplicate;
}
public boolean add(MapDatabase mapDatabase) {
@@ -39,12 +46,30 @@ public class MultiMapDatabase implements ITileDataSource {
@Override
public void query(MapTile tile, ITileDataSink sink) {
TileDataSink dataSink = new TileDataSink(sink);
for (MapDatabase mapDatabase : mapDatabases) {
if (mapDatabase.supportsTile(tile))
mapDatabase.query(tile, dataSink);
boolean deduplicate = this.deduplicate;
if (deduplicate) {
int n = 0;
for (MapDatabase mapDatabase : mapDatabases) {
if (mapDatabase.supportsTile(tile)) {
if (++n > 1) {
break;
}
}
}
deduplicate = n > 1;
}
sink.completed(dataSink.getResult());
TileDataSink dataSink = new TileDataSink(sink);
for (int i = 0, n = mapDatabases.size(); i < n; i++) {
MapDatabase mapDatabase = mapDatabases.get(i);
if (mapDatabase.supportsTile(tile)) {
mapDatabase.setDeduplicate(deduplicate);
dataSink.level = i + 1;
dataSink.levels = n;
mapDatabase.query(tile, dataSink);
}
}
sink.completed(QueryResult.SUCCESS);
}
@Override
@@ -61,7 +86,7 @@ public class MultiMapDatabase implements ITileDataSource {
}
}
public MapReadResult readLabels(Tile tile) {
public MapReadResult readLabels(Tile tile, boolean deduplicate) {
MapReadResult mapReadResult = new MapReadResult();
for (MapDatabase mdb : mapDatabases) {
if (mdb.supportsTile(tile)) {
@@ -71,13 +96,13 @@ public class MultiMapDatabase implements ITileDataSource {
}
boolean isWater = mapReadResult.isWater & result.isWater;
mapReadResult.isWater = isWater;
mapReadResult.add(result, false);
mapReadResult.add(result, deduplicate);
}
}
return mapReadResult;
}
public MapReadResult readLabels(Tile upperLeft, Tile lowerRight) {
public MapReadResult readLabels(Tile upperLeft, Tile lowerRight, boolean deduplicate) {
MapReadResult mapReadResult = new MapReadResult();
for (MapDatabase mdb : mapDatabases) {
if (mdb.supportsTile(upperLeft)) {
@@ -87,13 +112,13 @@ public class MultiMapDatabase implements ITileDataSource {
}
boolean isWater = mapReadResult.isWater & result.isWater;
mapReadResult.isWater = isWater;
mapReadResult.add(result, false);
mapReadResult.add(result, deduplicate);
}
}
return mapReadResult;
}
public MapReadResult readMapData(Tile tile) {
public MapReadResult readMapData(Tile tile, boolean deduplicate) {
MapReadResult mapReadResult = new MapReadResult();
for (MapDatabase mdb : mapDatabases) {
if (mdb.supportsTile(tile)) {
@@ -103,13 +128,13 @@ public class MultiMapDatabase implements ITileDataSource {
}
boolean isWater = mapReadResult.isWater & result.isWater;
mapReadResult.isWater = isWater;
mapReadResult.add(result, false);
mapReadResult.add(result, deduplicate);
}
}
return mapReadResult;
}
public MapReadResult readMapData(Tile upperLeft, Tile lowerRight) {
public MapReadResult readMapData(Tile upperLeft, Tile lowerRight, boolean deduplicate) {
MapReadResult mapReadResult = new MapReadResult();
for (MapDatabase mdb : mapDatabases) {
if (mdb.supportsTile(upperLeft)) {
@@ -119,13 +144,13 @@ public class MultiMapDatabase implements ITileDataSource {
}
boolean isWater = mapReadResult.isWater & result.isWater;
mapReadResult.isWater = isWater;
mapReadResult.add(result, false);
mapReadResult.add(result, deduplicate);
}
}
return mapReadResult;
}
public MapReadResult readPoiData(Tile tile) {
public MapReadResult readPoiData(Tile tile, boolean deduplicate) {
MapReadResult mapReadResult = new MapReadResult();
for (MapDatabase mdb : mapDatabases) {
if (mdb.supportsTile(tile)) {
@@ -135,13 +160,13 @@ public class MultiMapDatabase implements ITileDataSource {
}
boolean isWater = mapReadResult.isWater & result.isWater;
mapReadResult.isWater = isWater;
mapReadResult.add(result, false);
mapReadResult.add(result, deduplicate);
}
}
return mapReadResult;
}
public MapReadResult readPoiData(Tile upperLeft, Tile lowerRight) {
public MapReadResult readPoiData(Tile upperLeft, Tile lowerRight, boolean deduplicate) {
MapReadResult mapReadResult = new MapReadResult();
for (MapDatabase mdb : mapDatabases) {
if (mdb.supportsTile(upperLeft)) {
@@ -151,7 +176,7 @@ public class MultiMapDatabase implements ITileDataSource {
}
boolean isWater = mapReadResult.isWater & result.isWater;
mapReadResult.isWater = isWater;
mapReadResult.add(result, false);
mapReadResult.add(result, deduplicate);
}
}
return mapReadResult;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2018 devemux86
* Copyright 2016-2022 devemux86
*
* This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
@@ -33,6 +33,7 @@ public class MultiMapFileTileSource extends TileSource implements IMapFileTileSo
private static final Logger log = LoggerFactory.getLogger(MultiMapFileTileSource.class);
private boolean deduplicate;
private final List<MapFileTileSource> mapFileTileSources = new ArrayList<>();
private final Map<MapFileTileSource, int[]> zoomsByTileSource = new HashMap<>();
@@ -72,7 +73,7 @@ public class MultiMapFileTileSource extends TileSource implements IMapFileTileSo
@Override
public ITileDataSource getDataSource() {
MultiMapDatabase multiMapDatabase = new MultiMapDatabase();
MultiMapDatabase multiMapDatabase = new MultiMapDatabase(deduplicate);
for (MapFileTileSource mapFileTileSource : mapFileTileSources) {
try {
MapDatabase mapDatabase = new MapDatabase(mapFileTileSource);
@@ -112,6 +113,10 @@ public class MultiMapFileTileSource extends TileSource implements IMapFileTileSo
}
}
public void setDeduplicate(boolean deduplicate) {
this.deduplicate = deduplicate;
}
@Override
public void setPreferredLanguage(String preferredLanguage) {
for (MapFileTileSource mapFileTileSource : mapFileTileSources) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017-2020 devemux86
* Copyright 2017-2022 devemux86
*
* This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
@@ -14,6 +14,11 @@
*/
package org.oscim.utils;
import org.oscim.core.Tag;
import java.util.HashSet;
import java.util.Set;
public final class Parameters {
public enum SymbolScaling {ALL, POI}
@@ -74,6 +79,11 @@ public final class Parameters {
*/
public static boolean POT_TEXTURES = false;
/**
* Simplification exceptions.
*/
public static final Set<Tag> SIMPLIFICATION_EXCEPTIONS = new HashSet<>();
/**
* Reduce points on-the-fly while reading from map files.
* e.g. 0 (no simplification), 2, 4, ...