s3db: add building material and colors

This commit is contained in:
Hannes Janetzek 2014-03-13 02:00:17 +01:00
parent bcaaa0637a
commit 6b388c12d1
2 changed files with 95 additions and 18 deletions

View File

@ -53,9 +53,6 @@ public class S3DBLayer extends TileLayer {
}
}
/**
* Colors from OSM2World, except roof-red
*/
static int getColor(String color, boolean roof) {
try {
@ -65,37 +62,107 @@ public class S3DBLayer extends TileLayer {
}
if (roof) {
if ("brown".equals(color))
if ("brown" == color)
return Color.get(120, 110, 110);
if ("red".equals(color))
if ("red" == color)
return Color.get(255, 87, 69);
if ("green".equals(color))
if ("green" == color)
return Color.get(150, 200, 130);
if ("blue".equals(color))
if ("blue" == color)
return Color.get(100, 50, 200);
}
if ("white".equals(color))
if ("white" == color)
return Color.get(240, 240, 240);
if ("black".equals(color))
if ("black" == color)
return Color.get(76, 76, 76);
if ("grey".equals(color))
if ("grey" == color || "gray" == color)
return Color.get(100, 100, 100);
if ("red".equals(color))
if ("red" == color)
return Color.get(255, 190, 190);
if ("green".equals(color))
if ("green" == color)
return Color.get(190, 255, 190);
if ("blue".equals(color))
if ("blue" == color)
return Color.get(190, 190, 255);
if ("yellow".equals(color))
if ("yellow" == color)
return Color.get(255, 255, 175);
if ("pink".equals(color))
if ("pink" == color)
return Color.get(225, 175, 225);
if ("orange".equals(color))
if ("orange" == color)
return Color.get(255, 225, 150);
if ("brown".equals(color))
if ("brown" == color)
return Color.get(170, 130, 80);
if ("silver" == color)
return Color.get(153, 157, 160);
if ("gold" == color)
return Color.get(255, 215, 0);
if ("darkgray" == color || "darkgrey" == color)
return Color.DKGRAY;
if ("lightgray" == color || "lightgrey" == color)
return Color.LTGRAY;
if ("lightblue" == color)
return Color.get(173, 216, 230);
if ("beige" == color)
return Color.get(245, 245, 220);
if ("darkblue" == color)
return Color.get(50, 50, 189);
if ("transparent" == color)
return Color.get(64, 64, 64, 64);
log.debug("unknown color:{}", color);
return 0;
}
static int getMaterialColor(String material, boolean roof) {
if (roof) {
if ("glass" == material)
return Color.fade(Color.get(130, 224, 255), 0.9f);
}
if ("roof_tiles" == material)
return Color.get(216, 167, 111);
if ("tile" == material)
return Color.get(216, 167, 111);
if ("concrete" == material ||
"cement_block" == material)
return Color.get(210, 212, 212);
if ("metal" == material)
return Color.get(170, 130, 80);
if ("tar_paper" == material)
return Color.get(170, 130, 80);
if ("eternit" == material)
return Color.get(216, 167, 111);
if ("tin" == material)
return Color.get(170, 130, 80);
if ("asbestos" == material)
return Color.get(160, 152, 141);
if ("glass" == material)
return Color.get(130, 224, 255);
if ("slate" == material)
return Color.get(170, 130, 80);
if ("zink" == material)
return Color.get(180, 180, 180);
if ("gravel" == material)
return Color.get(170, 130, 80);
if ("copper" == material)
// same as roof color:green
return Color.get(150, 200, 130);
if ("wood" == material)
return Color.get(170, 130, 80);
if ("grass" == material)
return Color.get(170, 130, 80);
if ("stone" == material)
return Color.get(206, 207, 181);
if ("plaster" == material)
return Color.get(236, 237, 181);
if ("brick" == material)
return Color.get(255, 217, 191);
if ("stainless_steel" == material)
return Color.get(153, 157, 160);
log.debug("unknown material:{}", material);
return 0;
}
}

View File

@ -1,5 +1,7 @@
package org.oscim.layers.tile.s3db;
import static org.oscim.layers.tile.s3db.S3DBLayer.getMaterialColor;
import org.oscim.backend.canvas.Color;
import org.oscim.core.GeometryBuffer.GeometryType;
import org.oscim.core.MapElement;
@ -64,6 +66,7 @@ class S3DBTileLoader extends TileLoader {
}
String COLOR_KEY = "c";
String MATERIAL_KEY = "m";
String ROOF_KEY = "roof";
String ROOF_SHAPE_KEY = "roof:shape";
@ -74,13 +77,20 @@ class S3DBTileLoader extends TileLoader {
log.debug("wrong type " + element.type);
return;
}
boolean isRoof = element.tags.containsKey(ROOF_KEY);
//if (isRoof)
// log.debug(element.tags.toString());
int c = 0;
if (element.tags.containsKey(COLOR_KEY)) {
c = S3DBLayer.getColor(element.tags.getValue(COLOR_KEY), isRoof);
}
if (c == 0 && element.tags.containsKey(MATERIAL_KEY)) {
c = getMaterialColor(element.tags.getValue(MATERIAL_KEY), isRoof);
}
if (c == 0) {
String roofShape = element.tags.getValue(ROOF_SHAPE_KEY);