Add OSM and S3DB tags (#447)
This commit is contained in:
parent
9c3f3b8a4c
commit
149353119b
@ -27,7 +27,7 @@ public class OsmBuildingJsonTileSource extends GeoJsonTileSource {
|
|||||||
super("http://tile.openstreetmap.us/vectiles-buildings");
|
super("http://tile.openstreetmap.us/vectiles-buildings");
|
||||||
}
|
}
|
||||||
|
|
||||||
Tag mTagBuilding = new Tag("building", "yes");
|
Tag mTagBuilding = new Tag(Tag.KEY_BUILDING, Tag.VALUE_YES);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void decodeTags(MapElement mapElement, Map<String, Object> properties) {
|
public void decodeTags(MapElement mapElement, Map<String, Object> properties) {
|
||||||
|
@ -27,8 +27,8 @@ public class OsmRoadLineJsonTileSource extends GeoJsonTileSource {
|
|||||||
|
|
||||||
static final Logger log = LoggerFactory.getLogger(OsmRoadLineJsonTileSource.class);
|
static final Logger log = LoggerFactory.getLogger(OsmRoadLineJsonTileSource.class);
|
||||||
|
|
||||||
Tag mTagTunnel = new Tag("tunnel", "yes");
|
Tag mTagTunnel = new Tag("tunnel", Tag.VALUE_YES);
|
||||||
Tag mTagBridge = new Tag("bridge", "yes");
|
Tag mTagBridge = new Tag("bridge", Tag.VALUE_YES);
|
||||||
|
|
||||||
public OsmRoadLineJsonTileSource() {
|
public OsmRoadLineJsonTileSource() {
|
||||||
super("http://tile.openstreetmap.us/vectiles-highroad");
|
super("http://tile.openstreetmap.us/vectiles-highroad");
|
||||||
|
@ -256,7 +256,7 @@ public class RenderTheme implements IRenderTheme {
|
|||||||
|
|
||||||
MapElement e = new MapElement();
|
MapElement e = new MapElement();
|
||||||
e.startPolygon();
|
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, 16);
|
||||||
t.matchElement(GeometryType.POLY, e.tags, 15);
|
t.matchElement(GeometryType.POLY, e.tags, 15);
|
||||||
|
@ -24,7 +24,6 @@ import org.oscim.utils.Utils;
|
|||||||
/**
|
/**
|
||||||
* A tag represents an immutable key-value pair. Keys are always intern().
|
* A tag represents an immutable key-value pair. Keys are always intern().
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class Tag {
|
public class Tag {
|
||||||
/**
|
/**
|
||||||
* The key of the house number OpenStreetMap tag.
|
* The key of the house number OpenStreetMap tag.
|
||||||
@ -46,19 +45,52 @@ public class Tag {
|
|||||||
*/
|
*/
|
||||||
public static final String KEY_ELE = "ele";
|
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_AMENITY = "amenity";
|
||||||
public static final String KEY_AREA = "area";
|
|
||||||
public static final String KEY_BUILDING = "building";
|
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_HIGHWAY = "highway";
|
||||||
public static final String KEY_LANDUSE = "landuse";
|
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_YES = "yes";
|
||||||
public static final String VALUE_NO = "no";
|
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.
|
* The key of this tag.
|
||||||
*/
|
*/
|
||||||
|
@ -38,6 +38,8 @@ import org.oscim.utils.pool.Inlist;
|
|||||||
|
|
||||||
public class BuildingLayer extends Layer implements TileLoaderThemeHook {
|
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 MIN_ZOOM = 17;
|
||||||
private final static int MAX_ZOOM = 17;
|
private final static int MAX_ZOOM = 17;
|
||||||
|
|
||||||
@ -84,7 +86,7 @@ public class BuildingLayer extends Layer implements TileLoaderThemeHook {
|
|||||||
else {
|
else {
|
||||||
// FIXME load from theme or decode tags to generalize level/height tags
|
// FIXME load from theme or decode tags to generalize level/height tags
|
||||||
if ((v = element.tags.getValue(Tag.KEY_BUILDING_LEVELS)) != null)
|
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);
|
v = element.tags.getValue(Tag.KEY_MIN_HEIGHT);
|
||||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
package org.oscim.layers.tile.buildings;
|
package org.oscim.layers.tile.buildings;
|
||||||
|
|
||||||
import org.oscim.layers.tile.MapTile;
|
import org.oscim.layers.tile.MapTile;
|
||||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
package org.oscim.layers.tile.buildings;
|
package org.oscim.layers.tile.buildings;
|
||||||
|
|
||||||
import org.oscim.backend.canvas.Color;
|
import org.oscim.backend.canvas.Color;
|
||||||
@ -19,7 +35,9 @@ public class S3DBLayer extends TileLayer {
|
|||||||
static final Logger log = LoggerFactory.getLogger(S3DBLayer.class);
|
static final Logger log = LoggerFactory.getLogger(S3DBLayer.class);
|
||||||
|
|
||||||
private final static int MAX_CACHE = 32;
|
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 */
|
/* TODO get from theme */
|
||||||
private final static double HSV_S = 0.7;
|
private final static double HSV_S = 0.7;
|
||||||
@ -31,11 +49,19 @@ public class S3DBLayer extends TileLayer {
|
|||||||
this(map, tileSource, true, false);
|
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) {
|
public S3DBLayer(Map map, TileSource tileSource, boolean fxaa, boolean ssao) {
|
||||||
super(map, new TileManager(map, MAX_CACHE));
|
super(map, new TileManager(map, MAX_CACHE));
|
||||||
setRenderer(new S3DBRenderer(fxaa, ssao));
|
setRenderer(new S3DBRenderer(fxaa, ssao));
|
||||||
|
|
||||||
mTileManager.setZoomLevel(SRC_ZOOM, SRC_ZOOM);
|
mTileManager.setZoomLevel(MIN_ZOOM, MAX_ZOOM);
|
||||||
mTileSource = tileSource;
|
mTileSource = tileSource;
|
||||||
initLoader(2);
|
initLoader(2);
|
||||||
}
|
}
|
||||||
@ -49,7 +75,7 @@ public class S3DBLayer extends TileLayer {
|
|||||||
LayerRenderer mRenderer;
|
LayerRenderer mRenderer;
|
||||||
|
|
||||||
public S3DBRenderer(boolean fxaa, boolean ssao) {
|
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) {
|
if (fxaa || ssao) {
|
||||||
Mode mode = Mode.FXAA;
|
Mode mode = Mode.FXAA;
|
||||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
package org.oscim.layers.tile.buildings;
|
package org.oscim.layers.tile.buildings;
|
||||||
|
|
||||||
import org.oscim.backend.canvas.Color;
|
import org.oscim.backend.canvas.Color;
|
||||||
@ -16,11 +33,12 @@ import org.oscim.tiling.TileSource;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import static org.oscim.layers.tile.buildings.S3DBLayer.getMaterialColor;
|
|
||||||
|
|
||||||
class S3DBTileLoader extends TileLoader {
|
class S3DBTileLoader extends TileLoader {
|
||||||
static final Logger log = LoggerFactory.getLogger(S3DBTileLoader.class);
|
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
|
* current TileDataSource used by this MapTileLoader
|
||||||
*/
|
*/
|
||||||
@ -43,7 +61,7 @@ class S3DBTileLoader extends TileLoader {
|
|||||||
0, 4096, 0,
|
0, 4096, 0,
|
||||||
4096, 4096, 0};
|
4096, 4096, 0};
|
||||||
g.index = new int[]{0, 1, 2, 2, 1, 3};
|
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) {
|
public S3DBTileLoader(TileManager tileManager, TileSource tileSource) {
|
||||||
@ -93,11 +111,6 @@ class S3DBTileLoader extends TileLoader {
|
|||||||
process(mTilePlane);
|
process(mTilePlane);
|
||||||
}
|
}
|
||||||
|
|
||||||
String COLOR_KEY = "c";
|
|
||||||
String MATERIAL_KEY = "m";
|
|
||||||
String ROOF_KEY = "roof";
|
|
||||||
String ROOF_SHAPE_KEY = "roof:shape";
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void process(MapElement element) {
|
public void process(MapElement element) {
|
||||||
|
|
||||||
@ -109,23 +122,23 @@ class S3DBTileLoader extends TileLoader {
|
|||||||
if (mParts == null)
|
if (mParts == null)
|
||||||
initTile(mTile);
|
initTile(mTile);
|
||||||
|
|
||||||
boolean isRoof = element.tags.containsKey(ROOF_KEY);
|
boolean isRoof = element.tags.containsKey(Tag.KEY_ROOF);
|
||||||
//if (isRoof)
|
//if (isRoof)
|
||||||
// log.debug(element.tags.toString());
|
// log.debug(element.tags.toString());
|
||||||
|
|
||||||
int c = 0;
|
int c = 0;
|
||||||
if (element.tags.containsKey(COLOR_KEY)) {
|
if (element.tags.containsKey(OSCIM4_KEY_COLOR)) {
|
||||||
c = S3DBLayer.getColor(element.tags.getValue(COLOR_KEY), isRoof);
|
c = S3DBLayer.getColor(element.tags.getValue(OSCIM4_KEY_COLOR), isRoof);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c == 0 && element.tags.containsKey(MATERIAL_KEY)) {
|
if (c == 0 && element.tags.containsKey(OSCIM4_KEY_MATERIAL)) {
|
||||||
c = getMaterialColor(element.tags.getValue(MATERIAL_KEY), isRoof);
|
c = S3DBLayer.getMaterialColor(element.tags.getValue(OSCIM4_KEY_MATERIAL), isRoof);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c == 0) {
|
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);
|
mRoofs.add(element);
|
||||||
else
|
else
|
||||||
mParts.add(element);
|
mParts.add(element);
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
* Copyright 2014-2015 Ludwig M Brinckmann
|
* Copyright 2014-2015 Ludwig M Brinckmann
|
||||||
* Copyright 2016-2017 devemux86
|
* Copyright 2016-2017 devemux86
|
||||||
* Copyright 2016 Andrey Novikov
|
* Copyright 2016 Andrey Novikov
|
||||||
|
* Copyright 2017 Gustl22
|
||||||
*
|
*
|
||||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||||
*
|
*
|
||||||
@ -953,7 +954,8 @@ public class MapDatabase implements ITileDataSource {
|
|||||||
mTileProjection.project(e);
|
mTileProjection.project(e);
|
||||||
|
|
||||||
// At large query zoom levels clip everything
|
// 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) {
|
|| queryParameters.queryZoomLevel > MapFileTileSource.MAX_ZOOM_LEVEL) {
|
||||||
if (!mTileClipper.clip(e)) {
|
if (!mTileClipper.clip(e)) {
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user