/* determine defaults for building type */
int defaultLevels = 3;
double defaultHeightPerLevel = 2.5;
Material defaultMaterialWall = Materials.BUILDING_DEFAULT;
Material defaultMaterialRoof = Materials.ROOF_DEFAULT;
Material defaultMaterialWindows = Materials.BUILDING_WINDOWS;
String defaultRoofShape = "flat";
String buildingValue = getValue("building");
if ("greenhouse".equals(buildingValue)) {
defaultLevels = 1;
defaultMaterialWall = Materials.GLASS;
defaultMaterialRoof = Materials.GLASS_ROOF;
defaultMaterialWindows = null;
} else if ("garage".equals(buildingValue)
|| "garages".equals(buildingValue)) {
defaultLevels = 1;
defaultMaterialWall = Materials.CONCRETE;
defaultMaterialRoof = Materials.CONCRETE;
defaultMaterialWindows = Materials.GARAGE_DOORS;
} else if ("hut".equals(buildingValue)
|| "shed".equals(buildingValue)) {
defaultLevels = 1;
} else if ("cabin".equals(buildingValue)) {
defaultLevels = 1;
defaultMaterialWall = Materials.WOOD_WALL;
defaultMaterialRoof = Materials.WOOD;
} else if ("roof".equals(buildingValue)) {
defaultLevels = 1;
defaultMaterialWindows = null;
} else if ("church".equals(buildingValue)
|| "hangar".equals(buildingValue)
|| "industrial".equals(buildingValue)) {
defaultMaterialWindows = null;
} else {
if (getValue("building:levels") == null) {
defaultMaterialWindows = null;
}
}
/* determine levels */
buildingLevels = defaultLevels;
Float parsedLevels = null;
if (getValue("building:levels") != null) {
parsedLevels = parseOsmDecimal(
getValue("building:levels"), false);
}
if (parsedLevels != null) {
buildingLevels = (int)(float)parsedLevels;
} else if (parseHeight(tags, parseHeight(buildingTags, -1)) > 0) {
buildingLevels = max(1, (int)(parseHeight(tags, parseHeight(
buildingTags, -1)) / defaultHeightPerLevel));
}
minLevel = 0;
if (getValue("building:min_level") != null) {
Float parsedMinLevel = parseOsmDecimal(
getValue("building:min_level"), false);
if (parsedMinLevel != null) {
minLevel = (int)(float)parsedMinLevel;
}
}
/* determine roof shape */
boolean explicitRoofTagging = true;
if (!("no".equals(area.getTags().getValue("roof:lines"))) && hasComplexRoof(area)) {
roof = new ComplexRoof();
} else {
String roofShape = getValue("roof:shape");
if (roofShape == null) { roofShape = getValue("building:roof:shape"); }
if (roofShape == null) {
roofShape = defaultRoofShape;
explicitRoofTagging = false;
}
try {
if ("pyramidal".equals(roofShape)) {
roof = new PyramidalRoof();
} else if ("onion".equals(roofShape)) {
roof = new OnionRoof();
} else if ("skillion".equals(roofShape)) {
roof = new SkillionRoof();
} else if ("gabled".equals(roofShape)) {
roof = new GabledRoof();
} else if ("hipped".equals(roofShape)) {
roof = new HippedRoof();
} else if ("half-hipped".equals(roofShape)) {
roof = new HalfHippedRoof();
} else if ("gambrel".equals(roofShape)) {
roof = new GambrelRoof();
} else if ("mansard".equals(roofShape)) {
roof = new MansardRoof();
} else if ("dome".equals(roofShape)) {
roof = new DomeRoof();
} else if ("round".equals(roofShape)) {
roof = new RoundRoof();
} else {
roof = new FlatRoof();
}
} catch (InvalidGeometryException e) {
System.err.println("falling back to FlatRoof: " + e);
roof = new FlatRoof();
explicitRoofTagging = false;
}
}
/* determine height */
double fallbackHeight = buildingLevels * defaultHeightPerLevel;
fallbackHeight += roof.getRoofHeight();
fallbackHeight = parseHeight(buildingTags, (float)fallbackHeight);
double height = parseHeight(tags, (float)fallbackHeight);
heightWithoutRoof = height - roof.getRoofHeight();
/* determine materials */
if (defaultMaterialRoof == Materials.ROOF_DEFAULT
&& explicitRoofTagging && roof instanceof FlatRoof) {
defaultMaterialRoof = Materials.CONCRETE;
}
if (useBuildingColors) {
materialWall = buildMaterial(
getValue("building:material"),
getValue("building:colour"),
defaultMaterialWall, false);
materialRoof = buildMaterial(
getValue("roof:material"),
getValue("roof:colour"),
defaultMaterialRoof, true);
} else {
materialWall = defaultMaterialWall;
materialRoof = defaultMaterialRoof;
}
if (materialWall == Materials.GLASS) {
// avoid placing windows into a glass front
// TODO: the == currently only works if GLASS is not colorable
defaultMaterialWindows = null;
}
materialWallWithWindows = materialWall;
if (drawBuildingWindows) {
Material materialWindows = defaultMaterialWindows;
if (materialWindows != null) {
materialWallWithWindows = materialWallWithWindows.
withAddedLayers(materialWindows.getTextureDataList());
}
}