Merge pull request #757 from mapsforge/mapsforge

Mapsforge: reduce points on-the-fly while reading from map files
This commit is contained in:
Emux 2019-12-12 12:55:49 +02:00 committed by GitHub
commit 412cacd1c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 43 additions and 17 deletions

View File

@ -5,6 +5,8 @@
- 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)
- 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`
- Android: OpenGL ES 2.0 default for performance / stability [#749](https://github.com/mapsforge/vtm/pull/749)
- `MapView.OPENGL_VERSION`
- Android: threaded system initialization

View File

@ -52,7 +52,7 @@ import static org.oscim.tiling.QueryResult.SUCCESS;
/**
* A class for reading binary map files.
*
* @see <a href="http://code.google.com/p/mapsforge/wiki/SpecificationBinaryMapFile">Specification</a>
* @see <a href="https://github.com/mapsforge/mapsforge/blob/master/docs/Specification-Binary-Map-File.md">Specification</a>
*/
public class MapDatabase implements ITileDataSource {
/**
@ -187,6 +187,19 @@ public class MapDatabase implements ITileDataSource {
public static boolean wayFilterEnabled = true;
public static int wayFilterDistance = 20;
/**
* Reduce points on-the-fly while reading from map files.
*/
public static int SIMPLIFICATION_MIN_ZOOM = 8;
public static int SIMPLIFICATION_MAX_ZOOM = 11;
/**
* Mapsforge artificial tags for land/sea areas.
*/
private static final Tag TAG_ISSEA = new Tag("natural", "issea");
private static final Tag TAG_NOSEA = new Tag("natural", "nosea");
private static final Tag TAG_SEA = new Tag("natural", "sea");
private long mFileSize;
private boolean mDebugFile;
private RandomAccessFile mInputFile;
@ -250,20 +263,25 @@ public class MapDatabase implements ITileDataSource {
mTileProjection.setTile(tile);
//mTile = tile;
/* size of tile in map coordinates; */
double size = 1.0 / (1 << tile.zoomLevel);
if (tile.zoomLevel < SIMPLIFICATION_MIN_ZOOM || tile.zoomLevel > SIMPLIFICATION_MAX_ZOOM) {
minDeltaLat = 0;
minDeltaLon = 0;
} else {
/* size of tile in map coordinates; */
double size = 1.0 / (1 << tile.zoomLevel);
/* simplification tolerance */
int pixel = (tile.zoomLevel > 11) ? 1 : 2;
/* simplification tolerance */
int pixel = 2;
int simplify = Tile.SIZE / pixel;
int simplify = Tile.SIZE / pixel;
/* translate screen pixel for tile to latitude and longitude
* tolerance for point reduction before projection. */
minDeltaLat = (int) (Math.abs(MercatorProjection.toLatitude(tile.y + size)
- MercatorProjection.toLatitude(tile.y)) * 1e6) / simplify;
minDeltaLon = (int) (Math.abs(MercatorProjection.toLongitude(tile.x + size)
- MercatorProjection.toLongitude(tile.x)) * 1e6) / simplify;
/* translate screen pixel for tile to latitude and longitude
* tolerance for point reduction before projection. */
minDeltaLat = (int) (Math.abs(MercatorProjection.toLatitude(tile.y + size)
- MercatorProjection.toLatitude(tile.y)) * 1e6) / simplify;
minDeltaLon = (int) (Math.abs(MercatorProjection.toLongitude(tile.x + size)
- MercatorProjection.toLongitude(tile.x)) * 1e6) / simplify;
}
QueryParameters queryParameters = new QueryParameters();
queryParameters.queryZoomLevel =
@ -797,11 +815,12 @@ public class MapDatabase implements ITileDataSource {
} else if (lat == pLat && lon == pLon) {
/* drop small distance intermediate nodes */
//log.debug("drop zero delta ");
} else /*if ((deltaLon > minDeltaLon || deltaLon < -minDeltaLon
|| deltaLat > minDeltaLat || deltaLat < -minDeltaLat)
|| e.tags.contains("natural", "nosea"))*/ {
// Avoid additional simplification
// https://github.com/mapsforge/vtm/issues/39
} else if (!Parameters.SIMPLIFICATION
|| (e.tags.contains(TAG_ISSEA)
|| e.tags.contains(TAG_SEA)
|| e.tags.contains(TAG_NOSEA)
|| deltaLon > minDeltaLon || deltaLon < -minDeltaLon
|| deltaLat > minDeltaLat || deltaLat < -minDeltaLat)) {
outBuffer[outPos++] = pLon = lon;
outBuffer[outPos++] = pLat = lat;
cnt += 2;

View File

@ -62,6 +62,11 @@ public final class Parameters {
*/
public static boolean POT_TEXTURES = false;
/**
* Reduce points on-the-fly while reading from map files.
*/
public static boolean SIMPLIFICATION = false;
/**
* Texture atlas in themes.
*/