S3DB: handle building/roof:color tag
This commit is contained in:
parent
8064dda6ac
commit
aeff737250
@ -3,6 +3,7 @@ package org.oscim.layers.tile.s3db;
|
|||||||
import java.util.concurrent.CancellationException;
|
import java.util.concurrent.CancellationException;
|
||||||
|
|
||||||
import org.oscim.backend.canvas.Bitmap;
|
import org.oscim.backend.canvas.Bitmap;
|
||||||
|
import org.oscim.backend.canvas.Color;
|
||||||
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.MercatorProjection;
|
import org.oscim.core.MercatorProjection;
|
||||||
@ -47,7 +48,7 @@ public class S3DBLayer extends TileLayer {
|
|||||||
ExtrusionRenderer mExtRenderer;
|
ExtrusionRenderer mExtRenderer;
|
||||||
|
|
||||||
public S3DBRenderer() {
|
public S3DBRenderer() {
|
||||||
mExtRenderer = new ExtrusionRenderer(this, 16);
|
mExtRenderer = new ExtrusionRenderer(this, 16, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -70,7 +71,10 @@ public class S3DBLayer extends TileLayer {
|
|||||||
/** current TileDataSource used by this MapTileLoader */
|
/** current TileDataSource used by this MapTileLoader */
|
||||||
private ITileDataSource mTileDataSource;
|
private ITileDataSource mTileDataSource;
|
||||||
|
|
||||||
private ExtrusionLayer mExtrusionLayer;
|
private ExtrusionLayer mLayers;
|
||||||
|
private ExtrusionLayer mRoofs;
|
||||||
|
|
||||||
|
private float mGroundScale;
|
||||||
|
|
||||||
public S3DBLoader(TileManager tileManager) {
|
public S3DBLoader(TileManager tileManager) {
|
||||||
super(tileManager);
|
super(tileManager);
|
||||||
@ -87,12 +91,15 @@ public class S3DBLayer extends TileLayer {
|
|||||||
mTile = tile;
|
mTile = tile;
|
||||||
|
|
||||||
double lat = MercatorProjection.toLatitude(tile.y);
|
double lat = MercatorProjection.toLatitude(tile.y);
|
||||||
float groundScale = (float) MercatorProjection
|
mGroundScale = (float) MercatorProjection
|
||||||
.groundResolution(lat, 1 << mTile.zoomLevel);
|
.groundResolution(lat, 1 << mTile.zoomLevel);
|
||||||
|
|
||||||
mExtrusionLayer = new ExtrusionLayer(0, groundScale, null);
|
mLayers = new ExtrusionLayer(0, mGroundScale, Color.get(255, 255, 250));
|
||||||
|
mRoofs = new ExtrusionLayer(0, mGroundScale, Color.get(218, 220, 220));
|
||||||
|
mLayers.next = mRoofs;
|
||||||
|
|
||||||
ElementLayers layers = new ElementLayers();
|
ElementLayers layers = new ElementLayers();
|
||||||
layers.setExtrusionLayers(mExtrusionLayer);
|
layers.setExtrusionLayers(mLayers);
|
||||||
tile.data = layers;
|
tile.data = layers;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -109,16 +116,47 @@ public class S3DBLayer extends TileLayer {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String COLOR_KEY = "c";
|
||||||
|
String ROOF_KEY = "roof";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void process(MapElement element) {
|
public void process(MapElement element) {
|
||||||
if (element.type == GeometryType.TRIS) {
|
//log.debug("TAG {}", element.tags);
|
||||||
mExtrusionLayer.add(element);
|
if (element.type != GeometryType.TRIS) {
|
||||||
|
log.debug("wrong type " + element.type);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
boolean isRoof = element.tags.containsKey(ROOF_KEY);
|
||||||
|
|
||||||
|
int c = 0;
|
||||||
|
if (element.tags.containsKey(COLOR_KEY)) {
|
||||||
|
c = getColor(element.tags.getValue(COLOR_KEY), isRoof);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c == 0) {
|
||||||
|
if (isRoof)
|
||||||
|
mRoofs.add(element);
|
||||||
|
else
|
||||||
|
mLayers.add(element);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ExtrusionLayer l = mLayers; l != null; l = (ExtrusionLayer) l.next) {
|
||||||
|
if (l.color == c) {
|
||||||
|
l.add(element);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ExtrusionLayer l = new ExtrusionLayer(0, mGroundScale, c);
|
||||||
|
|
||||||
|
l.next = mRoofs.next;
|
||||||
|
mRoofs.next = l;
|
||||||
|
|
||||||
|
l.add(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void completed(QueryResult result) {
|
public void completed(QueryResult result) {
|
||||||
mExtrusionLayer = null;
|
|
||||||
super.completed(result);
|
super.completed(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,4 +165,50 @@ public class S3DBLayer extends TileLayer {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Colors from OSM2World, except roof-red
|
||||||
|
*/
|
||||||
|
private int getColor(String color, boolean roof) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
return Color.parseColor(color);
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (roof) {
|
||||||
|
if ("brown".equals(color))
|
||||||
|
return Color.get(120, 110, 110);
|
||||||
|
if ("red".equals(color))
|
||||||
|
return Color.get(255, 87, 69);
|
||||||
|
if ("green".equals(color))
|
||||||
|
return Color.get(150, 200, 130);
|
||||||
|
if ("blue".equals(color))
|
||||||
|
return Color.get(100, 50, 200);
|
||||||
|
}
|
||||||
|
if ("white".equals(color))
|
||||||
|
return Color.get(240, 240, 240);
|
||||||
|
if ("black".equals(color))
|
||||||
|
return Color.get(76, 76, 76);
|
||||||
|
if ("grey".equals(color))
|
||||||
|
return Color.get(100, 100, 100);
|
||||||
|
if ("red".equals(color))
|
||||||
|
return Color.get(255, 190, 190);
|
||||||
|
if ("green".equals(color))
|
||||||
|
return Color.get(190, 255, 190);
|
||||||
|
if ("blue".equals(color))
|
||||||
|
return Color.get(190, 190, 255);
|
||||||
|
if ("yellow".equals(color))
|
||||||
|
return Color.get(255, 255, 175);
|
||||||
|
if ("pink".equals(color))
|
||||||
|
return Color.get(225, 175, 225);
|
||||||
|
if ("orange".equals(color))
|
||||||
|
return Color.get(255, 225, 150);
|
||||||
|
if ("brown".equals(color))
|
||||||
|
return Color.get(170, 130, 80);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user