Merge pull request #757 from mapsforge/mapsforge
Mapsforge: reduce points on-the-fly while reading from map files
This commit is contained in:
@@ -5,6 +5,8 @@
|
|||||||
- Render themes: symbols on lines with billboard / rotation [#743](https://github.com/mapsforge/vtm/pull/743)
|
- 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)
|
- 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: 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)
|
- Android: OpenGL ES 2.0 default for performance / stability [#749](https://github.com/mapsforge/vtm/pull/749)
|
||||||
- `MapView.OPENGL_VERSION`
|
- `MapView.OPENGL_VERSION`
|
||||||
- Android: threaded system initialization
|
- Android: threaded system initialization
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ import static org.oscim.tiling.QueryResult.SUCCESS;
|
|||||||
/**
|
/**
|
||||||
* A class for reading binary map files.
|
* 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 {
|
public class MapDatabase implements ITileDataSource {
|
||||||
/**
|
/**
|
||||||
@@ -187,6 +187,19 @@ public class MapDatabase implements ITileDataSource {
|
|||||||
public static boolean wayFilterEnabled = true;
|
public static boolean wayFilterEnabled = true;
|
||||||
public static int wayFilterDistance = 20;
|
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 long mFileSize;
|
||||||
private boolean mDebugFile;
|
private boolean mDebugFile;
|
||||||
private RandomAccessFile mInputFile;
|
private RandomAccessFile mInputFile;
|
||||||
@@ -250,20 +263,25 @@ public class MapDatabase implements ITileDataSource {
|
|||||||
mTileProjection.setTile(tile);
|
mTileProjection.setTile(tile);
|
||||||
//mTile = tile;
|
//mTile = tile;
|
||||||
|
|
||||||
/* size of tile in map coordinates; */
|
if (tile.zoomLevel < SIMPLIFICATION_MIN_ZOOM || tile.zoomLevel > SIMPLIFICATION_MAX_ZOOM) {
|
||||||
double size = 1.0 / (1 << tile.zoomLevel);
|
minDeltaLat = 0;
|
||||||
|
minDeltaLon = 0;
|
||||||
|
} else {
|
||||||
|
/* size of tile in map coordinates; */
|
||||||
|
double size = 1.0 / (1 << tile.zoomLevel);
|
||||||
|
|
||||||
/* simplification tolerance */
|
/* simplification tolerance */
|
||||||
int pixel = (tile.zoomLevel > 11) ? 1 : 2;
|
int pixel = 2;
|
||||||
|
|
||||||
int simplify = Tile.SIZE / pixel;
|
int simplify = Tile.SIZE / pixel;
|
||||||
|
|
||||||
/* translate screen pixel for tile to latitude and longitude
|
/* translate screen pixel for tile to latitude and longitude
|
||||||
* tolerance for point reduction before projection. */
|
* tolerance for point reduction before projection. */
|
||||||
minDeltaLat = (int) (Math.abs(MercatorProjection.toLatitude(tile.y + size)
|
minDeltaLat = (int) (Math.abs(MercatorProjection.toLatitude(tile.y + size)
|
||||||
- MercatorProjection.toLatitude(tile.y)) * 1e6) / simplify;
|
- MercatorProjection.toLatitude(tile.y)) * 1e6) / simplify;
|
||||||
minDeltaLon = (int) (Math.abs(MercatorProjection.toLongitude(tile.x + size)
|
minDeltaLon = (int) (Math.abs(MercatorProjection.toLongitude(tile.x + size)
|
||||||
- MercatorProjection.toLongitude(tile.x)) * 1e6) / simplify;
|
- MercatorProjection.toLongitude(tile.x)) * 1e6) / simplify;
|
||||||
|
}
|
||||||
|
|
||||||
QueryParameters queryParameters = new QueryParameters();
|
QueryParameters queryParameters = new QueryParameters();
|
||||||
queryParameters.queryZoomLevel =
|
queryParameters.queryZoomLevel =
|
||||||
@@ -797,11 +815,12 @@ public class MapDatabase implements ITileDataSource {
|
|||||||
} else if (lat == pLat && lon == pLon) {
|
} else if (lat == pLat && lon == pLon) {
|
||||||
/* drop small distance intermediate nodes */
|
/* drop small distance intermediate nodes */
|
||||||
//log.debug("drop zero delta ");
|
//log.debug("drop zero delta ");
|
||||||
} else /*if ((deltaLon > minDeltaLon || deltaLon < -minDeltaLon
|
} else if (!Parameters.SIMPLIFICATION
|
||||||
|| deltaLat > minDeltaLat || deltaLat < -minDeltaLat)
|
|| (e.tags.contains(TAG_ISSEA)
|
||||||
|| e.tags.contains("natural", "nosea"))*/ {
|
|| e.tags.contains(TAG_SEA)
|
||||||
// Avoid additional simplification
|
|| e.tags.contains(TAG_NOSEA)
|
||||||
// https://github.com/mapsforge/vtm/issues/39
|
|| deltaLon > minDeltaLon || deltaLon < -minDeltaLon
|
||||||
|
|| deltaLat > minDeltaLat || deltaLat < -minDeltaLat)) {
|
||||||
outBuffer[outPos++] = pLon = lon;
|
outBuffer[outPos++] = pLon = lon;
|
||||||
outBuffer[outPos++] = pLat = lat;
|
outBuffer[outPos++] = pLat = lat;
|
||||||
cnt += 2;
|
cnt += 2;
|
||||||
|
|||||||
@@ -62,6 +62,11 @@ public final class Parameters {
|
|||||||
*/
|
*/
|
||||||
public static boolean POT_TEXTURES = false;
|
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.
|
* Texture atlas in themes.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user