diff --git a/vtm-extras/src/org/oscim/tiling/source/geojson/OsmBuildingJsonTileSource.java b/vtm-extras/src/org/oscim/tiling/source/geojson/OsmBuildingJsonTileSource.java index da50e959..cbb3f5ed 100644 --- a/vtm-extras/src/org/oscim/tiling/source/geojson/OsmBuildingJsonTileSource.java +++ b/vtm-extras/src/org/oscim/tiling/source/geojson/OsmBuildingJsonTileSource.java @@ -27,7 +27,7 @@ public class OsmBuildingJsonTileSource extends GeoJsonTileSource { super("http://tile.openstreetmap.us/vectiles-buildings"); } - Tag mTagBuilding = new Tag("building", "yes"); + Tag mTagBuilding = new Tag(Tag.KEY_BUILDING, Tag.VALUE_YES); @Override public void decodeTags(MapElement mapElement, Map properties) { diff --git a/vtm-extras/src/org/oscim/tiling/source/geojson/OsmRoadLineJsonTileSource.java b/vtm-extras/src/org/oscim/tiling/source/geojson/OsmRoadLineJsonTileSource.java index c33e17f7..48587aca 100644 --- a/vtm-extras/src/org/oscim/tiling/source/geojson/OsmRoadLineJsonTileSource.java +++ b/vtm-extras/src/org/oscim/tiling/source/geojson/OsmRoadLineJsonTileSource.java @@ -27,8 +27,8 @@ public class OsmRoadLineJsonTileSource extends GeoJsonTileSource { static final Logger log = LoggerFactory.getLogger(OsmRoadLineJsonTileSource.class); - Tag mTagTunnel = new Tag("tunnel", "yes"); - Tag mTagBridge = new Tag("bridge", "yes"); + Tag mTagTunnel = new Tag("tunnel", Tag.VALUE_YES); + Tag mTagBridge = new Tag("bridge", Tag.VALUE_YES); public OsmRoadLineJsonTileSource() { super("http://tile.openstreetmap.us/vectiles-highroad"); diff --git a/vtm-jeo/src/org/oscim/theme/carto/RenderTheme.java b/vtm-jeo/src/org/oscim/theme/carto/RenderTheme.java index eb945659..86c7d30d 100644 --- a/vtm-jeo/src/org/oscim/theme/carto/RenderTheme.java +++ b/vtm-jeo/src/org/oscim/theme/carto/RenderTheme.java @@ -256,7 +256,7 @@ public class RenderTheme implements IRenderTheme { MapElement e = new MapElement(); e.startPolygon(); - e.tags.add(new Tag("building", "yes")); + e.tags.add(new Tag(Tag.KEY_BUILDING, Tag.VALUE_YES)); t.matchElement(GeometryType.POLY, e.tags, 16); t.matchElement(GeometryType.POLY, e.tags, 15); diff --git a/vtm/src/org/oscim/core/Tag.java b/vtm/src/org/oscim/core/Tag.java index ba4a67b9..631cbd36 100644 --- a/vtm/src/org/oscim/core/Tag.java +++ b/vtm/src/org/oscim/core/Tag.java @@ -24,7 +24,6 @@ import org.oscim.utils.Utils; /** * A tag represents an immutable key-value pair. Keys are always intern(). */ - public class Tag { /** * The key of the house number OpenStreetMap tag. @@ -46,19 +45,52 @@ public class Tag { */ public static final String KEY_ELE = "ele"; + /** + * The key of the id tag. + */ + public static final String KEY_ID = "id"; + public static final String KEY_AMENITY = "amenity"; - public static final String KEY_AREA = "area"; public static final String KEY_BUILDING = "building"; - public static final String KEY_BUILDING_LEVELS = "building:levels"; public static final String KEY_HIGHWAY = "highway"; public static final String KEY_LANDUSE = "landuse"; - public static final String KEY_HEIGHT = "height"; - public static final String KEY_MIN_HEIGHT = "min_height"; - public static final String KEY_VOLUME = "volume"; public static final String VALUE_YES = "yes"; public static final String VALUE_NO = "no"; + // S3DB + public static final String KEY_AREA = "area"; + public static final String KEY_BUILDING_COLOR = "building:colour"; + public static final String KEY_BUILDING_LEVELS = "building:levels"; + public static final String KEY_BUILDING_MATERIAL = "building:material"; + public static final String KEY_BUILDING_MIN_LEVEL = "building:min_level"; + public static final String KEY_BUILDING_PART = "building:part"; + public static final String KEY_COLOR = "colour"; + public static final String KEY_HEIGHT = "height"; + public static final String KEY_MATERIAL = "material"; + public static final String KEY_MIN_HEIGHT = "min_height"; + public static final String KEY_ROOF = "roof"; + public static final String KEY_ROOF_COLOR = "roof:colour"; + public static final String KEY_ROOF_HEIGHT = "roof:height"; + public static final String KEY_ROOF_LEVELS = "roof:levels"; + public static final String KEY_ROOF_MATERIAL = "roof:material"; + public static final String KEY_ROOF_SHAPE = "roof:shape"; + public static final String KEY_VOLUME = "volume"; + + // Roof shape values + public static final String VALUE_DOME = "dome"; + public static final String VALUE_FLAT = "flat"; + public static final String VALUE_GABLED = "gabled"; + public static final String VALUE_GAMBREL = "gambrel"; + public static final String VALUE_HALF_HIPPED = "half_hipped"; + public static final String VALUE_HIPPED = "hipped"; + public static final String VALUE_MANSARD = "mansard"; + public static final String VALUE_ONION = "onion"; + public static final String VALUE_PYRAMIDAL = "pyramidal"; + public static final String VALUE_ROUND = "round"; + public static final String VALUE_SALTBOX = "saltbox"; + public static final String VALUE_SKILLON = "skillion"; + /** * The key of this tag. */ diff --git a/vtm/src/org/oscim/layers/tile/buildings/BuildingLayer.java b/vtm/src/org/oscim/layers/tile/buildings/BuildingLayer.java index 402ba257..9ada4383 100644 --- a/vtm/src/org/oscim/layers/tile/buildings/BuildingLayer.java +++ b/vtm/src/org/oscim/layers/tile/buildings/BuildingLayer.java @@ -38,6 +38,8 @@ import org.oscim.utils.pool.Inlist; public class BuildingLayer extends Layer implements TileLoaderThemeHook { + private final static int BUILDING_LEVEL_HEIGHT = 280; // cm + private final static int MIN_ZOOM = 17; private final static int MAX_ZOOM = 17; @@ -84,7 +86,7 @@ public class BuildingLayer extends Layer implements TileLoaderThemeHook { else { // FIXME load from theme or decode tags to generalize level/height tags if ((v = element.tags.getValue(Tag.KEY_BUILDING_LEVELS)) != null) - height = (int) (Float.parseFloat(v) * 280); // 2.8m level height + height = (int) (Float.parseFloat(v) * BUILDING_LEVEL_HEIGHT); } v = element.tags.getValue(Tag.KEY_MIN_HEIGHT); diff --git a/vtm/src/org/oscim/layers/tile/buildings/BuildingRenderer.java b/vtm/src/org/oscim/layers/tile/buildings/BuildingRenderer.java index 4e538cba..705d5579 100644 --- a/vtm/src/org/oscim/layers/tile/buildings/BuildingRenderer.java +++ b/vtm/src/org/oscim/layers/tile/buildings/BuildingRenderer.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013 Hannes Janetzek + * + * This file is part of the OpenScienceMap project (http://www.opensciencemap.org). + * + * This program is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with + * this program. If not, see . + */ package org.oscim.layers.tile.buildings; import org.oscim.layers.tile.MapTile; diff --git a/vtm/src/org/oscim/layers/tile/buildings/S3DBLayer.java b/vtm/src/org/oscim/layers/tile/buildings/S3DBLayer.java index 7613bd9a..e91d0899 100644 --- a/vtm/src/org/oscim/layers/tile/buildings/S3DBLayer.java +++ b/vtm/src/org/oscim/layers/tile/buildings/S3DBLayer.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013 Hannes Janetzek + * + * This file is part of the OpenScienceMap project (http://www.opensciencemap.org). + * + * This program is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with + * this program. If not, see . + */ package org.oscim.layers.tile.buildings; import org.oscim.backend.canvas.Color; @@ -19,7 +35,9 @@ public class S3DBLayer extends TileLayer { static final Logger log = LoggerFactory.getLogger(S3DBLayer.class); private final static int MAX_CACHE = 32; - private final static int SRC_ZOOM = 16; + + private final static int MIN_ZOOM = 16; + private final static int MAX_ZOOM = 16; /* TODO get from theme */ private final static double HSV_S = 0.7; @@ -31,11 +49,19 @@ public class S3DBLayer extends TileLayer { this(map, tileSource, true, false); } + /** + * Simple-3D-Buildings OSCIM4 Tile Layer + * + * @param map Stored map workaround + * @param tileSource Source of loaded tiles in {@link org.oscim.layers.tile.vector.VectorTileLayer} + * @param fxaa Switch on Fast Approximate Anti-Aliasing + * @param ssao Switch on Screen Space Ambient Occlusion + */ public S3DBLayer(Map map, TileSource tileSource, boolean fxaa, boolean ssao) { super(map, new TileManager(map, MAX_CACHE)); setRenderer(new S3DBRenderer(fxaa, ssao)); - mTileManager.setZoomLevel(SRC_ZOOM, SRC_ZOOM); + mTileManager.setZoomLevel(MIN_ZOOM, MAX_ZOOM); mTileSource = tileSource; initLoader(2); } @@ -49,7 +75,7 @@ public class S3DBLayer extends TileLayer { LayerRenderer mRenderer; public S3DBRenderer(boolean fxaa, boolean ssao) { - mRenderer = new BuildingRenderer(this, SRC_ZOOM, SRC_ZOOM, true, false); + mRenderer = new BuildingRenderer(this, MIN_ZOOM, MAX_ZOOM, true, false); if (fxaa || ssao) { Mode mode = Mode.FXAA; diff --git a/vtm/src/org/oscim/layers/tile/buildings/S3DBTileLoader.java b/vtm/src/org/oscim/layers/tile/buildings/S3DBTileLoader.java index 7b4f1621..7c888d4d 100644 --- a/vtm/src/org/oscim/layers/tile/buildings/S3DBTileLoader.java +++ b/vtm/src/org/oscim/layers/tile/buildings/S3DBTileLoader.java @@ -1,3 +1,20 @@ +/* + * Copyright 2013 Hannes Janetzek + * + * This file is part of the OpenScienceMap project (http://www.opensciencemap.org). + * + * This program is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with + * this program. If not, see . + */ + package org.oscim.layers.tile.buildings; import org.oscim.backend.canvas.Color; @@ -16,11 +33,12 @@ import org.oscim.tiling.TileSource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import static org.oscim.layers.tile.buildings.S3DBLayer.getMaterialColor; - class S3DBTileLoader extends TileLoader { static final Logger log = LoggerFactory.getLogger(S3DBTileLoader.class); + private static final String OSCIM4_KEY_COLOR = "c"; + private static final String OSCIM4_KEY_MATERIAL = "m"; + /** * current TileDataSource used by this MapTileLoader */ @@ -43,7 +61,7 @@ class S3DBTileLoader extends TileLoader { 0, 4096, 0, 4096, 4096, 0}; g.index = new int[]{0, 1, 2, 2, 1, 3}; - mTilePlane.tags.add(new Tag("c", "transparent")); + mTilePlane.tags.add(new Tag(OSCIM4_KEY_COLOR, "transparent")); } public S3DBTileLoader(TileManager tileManager, TileSource tileSource) { @@ -93,11 +111,6 @@ class S3DBTileLoader extends TileLoader { process(mTilePlane); } - String COLOR_KEY = "c"; - String MATERIAL_KEY = "m"; - String ROOF_KEY = "roof"; - String ROOF_SHAPE_KEY = "roof:shape"; - @Override public void process(MapElement element) { @@ -109,23 +122,23 @@ class S3DBTileLoader extends TileLoader { if (mParts == null) initTile(mTile); - boolean isRoof = element.tags.containsKey(ROOF_KEY); + boolean isRoof = element.tags.containsKey(Tag.KEY_ROOF); //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 (element.tags.containsKey(OSCIM4_KEY_COLOR)) { + c = S3DBLayer.getColor(element.tags.getValue(OSCIM4_KEY_COLOR), isRoof); } - if (c == 0 && element.tags.containsKey(MATERIAL_KEY)) { - c = getMaterialColor(element.tags.getValue(MATERIAL_KEY), isRoof); + if (c == 0 && element.tags.containsKey(OSCIM4_KEY_MATERIAL)) { + c = S3DBLayer.getMaterialColor(element.tags.getValue(OSCIM4_KEY_MATERIAL), isRoof); } if (c == 0) { - String roofShape = element.tags.getValue(ROOF_SHAPE_KEY); + String roofShape = element.tags.getValue(Tag.KEY_ROOF_SHAPE); - if (isRoof && (roofShape == null || "flat".equals(roofShape))) + if (isRoof && (roofShape == null || Tag.VALUE_FLAT.equals(roofShape))) mRoofs.add(element); else mParts.add(element); diff --git a/vtm/src/org/oscim/tiling/source/mapfile/MapDatabase.java b/vtm/src/org/oscim/tiling/source/mapfile/MapDatabase.java index f1b1e050..4198b8ff 100644 --- a/vtm/src/org/oscim/tiling/source/mapfile/MapDatabase.java +++ b/vtm/src/org/oscim/tiling/source/mapfile/MapDatabase.java @@ -4,6 +4,7 @@ * Copyright 2014-2015 Ludwig M Brinckmann * Copyright 2016-2017 devemux86 * Copyright 2016 Andrey Novikov + * Copyright 2017 Gustl22 * * This file is part of the OpenScienceMap project (http://www.opensciencemap.org). * @@ -953,7 +954,8 @@ public class MapDatabase implements ITileDataSource { mTileProjection.project(e); // At large query zoom levels clip everything - if (!e.tags.containsKey("building") + if ((!e.tags.containsKey(Tag.KEY_BUILDING) + && !e.tags.containsKey(Tag.KEY_BUILDING_PART)) || queryParameters.queryZoomLevel > MapFileTileSource.MAX_ZOOM_LEVEL) { if (!mTileClipper.clip(e)) { continue;