adapt building height to ground resolution
This commit is contained in:
parent
1d2fea48cc
commit
d3c31199f1
@ -106,6 +106,7 @@ public class TileGenerator implements IRenderCallback, IMapDatabaseCallback {
|
|||||||
|
|
||||||
private float mStrokeScale = 1.0f;
|
private float mStrokeScale = 1.0f;
|
||||||
private float mLatScaleFactor;
|
private float mLatScaleFactor;
|
||||||
|
private float mGroundResolution;
|
||||||
|
|
||||||
// replacement for variable value tags that should not be matched by RenderTheme
|
// replacement for variable value tags that should not be matched by RenderTheme
|
||||||
private final static Tag mTagEmptyName = new Tag(Tag.TAG_KEY_NAME, null, false);
|
private final static Tag mTagEmptyName = new Tag(Tag.TAG_KEY_NAME, null, false);
|
||||||
@ -150,8 +151,15 @@ public class TileGenerator implements IRenderCallback, IMapDatabaseCallback {
|
|||||||
setScaleStrokeWidth(mTile.zoomLevel);
|
setScaleStrokeWidth(mTile.zoomLevel);
|
||||||
|
|
||||||
// account for area changes with latitude
|
// account for area changes with latitude
|
||||||
mLatScaleFactor = 0.5f + 0.5f * ((float) Math.sin(Math.abs(MercatorProjection
|
double latitude = MercatorProjection.pixelYToLatitude(mTile.pixelY + (Tile.TILE_SIZE >> 1),
|
||||||
.pixelYToLatitude(mTile.pixelY, mTile.zoomLevel)) * (Math.PI / 180)));
|
mTile.zoomLevel);
|
||||||
|
mLatScaleFactor = 0.5f + 0.5f * ((float) Math.sin(Math.abs(latitude) * (Math.PI / 180)));
|
||||||
|
|
||||||
|
mGroundResolution = (float) (Math.cos(latitude * (Math.PI / 180))
|
||||||
|
* MercatorProjection.EARTH_CIRCUMFERENCE
|
||||||
|
/ ((long) Tile.TILE_SIZE << mTile.zoomLevel));
|
||||||
|
|
||||||
|
Log.d(TAG, mTile + " " + mGroundResolution);
|
||||||
|
|
||||||
mTile.layers = new Layers();
|
mTile.layers = new Layers();
|
||||||
|
|
||||||
@ -409,7 +417,7 @@ public class TileGenerator implements IRenderCallback, IMapDatabaseCallback {
|
|||||||
if (mRenderBuildingModel) {
|
if (mRenderBuildingModel) {
|
||||||
//Log.d(TAG, "add buildings: " + mTile + " " + mPriority);
|
//Log.d(TAG, "add buildings: " + mTile + " " + mPriority);
|
||||||
if (mTile.layers.extrusionLayers == null)
|
if (mTile.layers.extrusionLayers == null)
|
||||||
mTile.layers.extrusionLayers = new ExtrusionLayer(0);
|
mTile.layers.extrusionLayers = new ExtrusionLayer(0, mGroundResolution);
|
||||||
|
|
||||||
((ExtrusionLayer) mTile.layers.extrusionLayers).addBuildings(mWay);
|
((ExtrusionLayer) mTile.layers.extrusionLayers).addBuildings(mWay);
|
||||||
|
|
||||||
|
|||||||
@ -58,11 +58,13 @@ public class ExtrusionLayer extends Layer {
|
|||||||
private final static int IND_OUTLINE = 3;
|
private final static int IND_OUTLINE = 3;
|
||||||
|
|
||||||
public boolean compiled = false;
|
public boolean compiled = false;
|
||||||
|
private final float mGroundResolution;
|
||||||
|
|
||||||
public ExtrusionLayer(int level) {
|
public ExtrusionLayer(int level, float groundResolution) {
|
||||||
this.type = Layer.EXTRUSION;
|
this.type = Layer.EXTRUSION;
|
||||||
this.level = level;
|
this.level = level;
|
||||||
|
|
||||||
|
mGroundResolution = groundResolution;
|
||||||
mVertices = mCurVertices = VertexPool.get();
|
mVertices = mCurVertices = VertexPool.get();
|
||||||
|
|
||||||
mIndices = new VertexPoolItem[4];
|
mIndices = new VertexPoolItem[4];
|
||||||
@ -89,11 +91,20 @@ public class ExtrusionLayer extends Layer {
|
|||||||
if (height == 0)
|
if (height == 0)
|
||||||
height = 12 * 100;
|
height = 12 * 100;
|
||||||
|
|
||||||
// 5 cm steps
|
// 10 cm steps
|
||||||
float sfactor = (400f / Tile.TILE_SIZE) / 5f;
|
float sfactor = 1 / 10f;
|
||||||
height *= sfactor;
|
height *= sfactor;
|
||||||
minHeight *= sfactor;
|
minHeight *= sfactor;
|
||||||
|
|
||||||
|
// match height with ground resultion
|
||||||
|
// (meter per pixel)
|
||||||
|
height /= mGroundResolution;
|
||||||
|
minHeight /= mGroundResolution;
|
||||||
|
|
||||||
|
// my preference
|
||||||
|
height *= 0.85;
|
||||||
|
minHeight *= 0.85;
|
||||||
|
|
||||||
int length = 0;
|
int length = 0;
|
||||||
for (int ipos = 0, ppos = 0, n = way.geom.index.length; ipos < n; ipos++, ppos += length) {
|
for (int ipos = 0, ppos = 0, n = way.geom.index.length; ipos < n; ipos++, ppos += length) {
|
||||||
length = way.geom.index[ipos];
|
length = way.geom.index[ipos];
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user