add geojson example tile sources
- add OsmLanduseJsonTileSource - add layers for buildings and water areas
This commit is contained in:
parent
aee1b22c89
commit
b39f9ca003
@ -33,6 +33,11 @@ public abstract class GeoJsonTileSource extends UrlTileSource {
|
||||
setExtension(".json");
|
||||
}
|
||||
|
||||
public GeoJsonTileSource(String url, int zoomMin, int zoomMax) {
|
||||
super(url, zoomMin, zoomMax);
|
||||
setExtension(".json");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITileDataSource getDataSource() {
|
||||
Map<String, String> opt = new HashMap<String, String>();
|
||||
|
@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Copyright 2014 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.tiling.source.geojson;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.oscim.core.MapElement;
|
||||
import org.oscim.core.Tag;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class HighroadJsonTileSource extends GeoJsonTileSource {
|
||||
|
||||
static final Logger log = LoggerFactory.getLogger(HighroadJsonTileSource.class);
|
||||
|
||||
Tag mTagTunnel = new Tag("tunnel", "yes");
|
||||
Tag mTagBridge = new Tag("bridge", "yes");
|
||||
|
||||
public HighroadJsonTileSource() {
|
||||
super("http://tile.openstreetmap.us/vectiles-highroad");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decodeTags(MapElement mapElement, Map<String, Object> properties) {
|
||||
String highway = null;
|
||||
boolean isLink = false;
|
||||
|
||||
mapElement.layer = 5;
|
||||
|
||||
for (Map.Entry<String, Object> entry : properties.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
Object value = entry.getValue();
|
||||
//log.debug(key + " : " + String.valueOf(value));
|
||||
|
||||
if (value == null)
|
||||
continue;
|
||||
|
||||
if ("no".equals(value))
|
||||
continue;
|
||||
|
||||
if ("highway".equals(key) && value instanceof String) {
|
||||
highway = (String) entry.getValue();
|
||||
}
|
||||
else if ("is_link".equals(key)) {
|
||||
isLink = "yes".equals(value);
|
||||
}
|
||||
else if ("is_tunnel".equals(key)) {
|
||||
mapElement.tags.add(mTagTunnel);
|
||||
}
|
||||
else if ("is_bridge".equals(key)) {
|
||||
mapElement.tags.add(mTagBridge);
|
||||
}
|
||||
else if ("sort_key".equals(key)) {
|
||||
if (value instanceof Integer)
|
||||
mapElement.layer = 5 + (Integer) value;
|
||||
}
|
||||
else if ("railway".equals(key) && value instanceof String) {
|
||||
mapElement.tags.add(new Tag("railway", (String) value));
|
||||
}
|
||||
}
|
||||
|
||||
if (highway == null)
|
||||
return;
|
||||
|
||||
if (isLink)
|
||||
highway += "_link";
|
||||
|
||||
mapElement.tags.add(new Tag("highway", highway));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Tag rewriteTag(String key, Object value) {
|
||||
if ("kind".equals(key))
|
||||
return null;
|
||||
|
||||
if (value == null)
|
||||
return null;
|
||||
|
||||
String val = (value instanceof String) ? (String) value : String.valueOf(value);
|
||||
|
||||
return new Tag(key, val);
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2014 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.tiling.source.geojson;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.oscim.core.MapElement;
|
||||
import org.oscim.core.Tag;
|
||||
|
||||
public class OsmBuildingJsonTileSource extends GeoJsonTileSource {
|
||||
|
||||
public OsmBuildingJsonTileSource() {
|
||||
super("http://tile.openstreetmap.us/vectiles-buildings");
|
||||
}
|
||||
|
||||
Tag mTagBuilding = new Tag("building", "yes");
|
||||
|
||||
@Override
|
||||
public void decodeTags(MapElement mapElement, Map<String, Object> properties) {
|
||||
|
||||
mapElement.tags.add(mTagBuilding);
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,127 @@
|
||||
/*
|
||||
* Copyright 2014 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.tiling.source.geojson;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.oscim.core.GeometryBuffer.GeometryType;
|
||||
import org.oscim.core.MapElement;
|
||||
import org.oscim.core.Tag;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class OsmLanduseJsonTileSource extends GeoJsonTileSource {
|
||||
static final Logger log = LoggerFactory.getLogger(OsmLanduseJsonTileSource.class);
|
||||
|
||||
public OsmLanduseJsonTileSource() {
|
||||
super("http://tile.openstreetmap.us/vectiles-land-usages");
|
||||
}
|
||||
|
||||
private static LinkedHashMap<String, Tag> mappings =
|
||||
new LinkedHashMap<String, Tag>();
|
||||
|
||||
static void addMapping(String key, String val) {
|
||||
mappings.put(val, new Tag(key, val));
|
||||
}
|
||||
|
||||
static {
|
||||
addMapping("landuse", "residential");
|
||||
addMapping("landuse", "commercial");
|
||||
addMapping("landuse", "retail");
|
||||
addMapping("landuse", "railway");
|
||||
addMapping("landuse", "grass");
|
||||
addMapping("landuse", "meadow");
|
||||
addMapping("landuse", "forest");
|
||||
addMapping("landuse", "farm");
|
||||
addMapping("landuse", "allotments");
|
||||
addMapping("landuse", "cemetery");
|
||||
addMapping("landuse", "farmyard");
|
||||
addMapping("landuse", "farmland");
|
||||
addMapping("landuse", "quarry");
|
||||
addMapping("landuse", "military");
|
||||
addMapping("landuse", "industrial");
|
||||
addMapping("landuse", "greenfield");
|
||||
addMapping("landuse", "village_green");
|
||||
addMapping("landuse", "recreation_ground");
|
||||
addMapping("landuse", "conservation");
|
||||
addMapping("landuse", "landfill");
|
||||
addMapping("landuse", "construction");
|
||||
|
||||
addMapping("leisure", "common");
|
||||
addMapping("leisure", "park");
|
||||
addMapping("leisure", "pitch");
|
||||
addMapping("leisure", "garden");
|
||||
addMapping("leisure", "sports_centre");
|
||||
addMapping("leisure", "playground");
|
||||
addMapping("leisure", "nature_reserve");
|
||||
addMapping("leisure", "golf_course");
|
||||
addMapping("leisure", "stadium");
|
||||
|
||||
addMapping("amenity", "hospital");
|
||||
addMapping("amenity", "cinema");
|
||||
addMapping("amenity", "school");
|
||||
addMapping("amenity", "college");
|
||||
addMapping("amenity", "university");
|
||||
addMapping("amenity", "theatre");
|
||||
addMapping("amenity", "library");
|
||||
addMapping("amenity", "parking");
|
||||
addMapping("amenity", "place_of_worship");
|
||||
|
||||
addMapping("highway", "pedestrian");
|
||||
addMapping("highway", "footway");
|
||||
addMapping("highway", "service");
|
||||
addMapping("highway", "street");
|
||||
|
||||
addMapping("natural", "scrub");
|
||||
addMapping("natural", "wood");
|
||||
|
||||
mappings.put("urban area", new Tag("landuse", "urban"));
|
||||
mappings.put("park or protected land", new Tag("leisure", "park"));
|
||||
}
|
||||
|
||||
private final static Tag mTagArea = new Tag("area", "yes");
|
||||
|
||||
@Override
|
||||
public void decodeTags(MapElement mapElement, Map<String, Object> properties) {
|
||||
|
||||
for (Map.Entry<String, Object> entry : properties.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
|
||||
if (!"kind".equals(key))
|
||||
continue;
|
||||
|
||||
String value = (String) entry.getValue();
|
||||
|
||||
Tag tag = mappings.get(value);
|
||||
if (tag == null) {
|
||||
System.out.println("unmatched " + value);
|
||||
} else {
|
||||
mapElement.tags.add(tag);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postGeomHook(MapElement mapElement) {
|
||||
//if (mapElement.type != GeometryType.POLY) {
|
||||
mapElement.type = GeometryType.POLY;
|
||||
mapElement.tags.add(mTagArea);
|
||||
//}
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2014 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.tiling.source.geojson;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.oscim.core.MapElement;
|
||||
import org.oscim.core.Tag;
|
||||
|
||||
public class OsmWaterJsonTileSource extends GeoJsonTileSource {
|
||||
|
||||
public OsmWaterJsonTileSource() {
|
||||
super("http://tile.openstreetmap.us/vectiles-water-areas");
|
||||
}
|
||||
|
||||
Tag mTagWater = new Tag("natural", "water");
|
||||
|
||||
@Override
|
||||
public void decodeTags(MapElement mapElement, Map<String, Object> properties) {
|
||||
|
||||
mapElement.tags.add(mTagWater);
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package org.oscim.tiling.source.geojson;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.oscim.core.MapElement;
|
||||
import org.oscim.core.Tag;
|
||||
|
||||
public class RiverJsonTileSource extends GeoJsonTileSource {
|
||||
|
||||
public RiverJsonTileSource() {
|
||||
super("http://www.somebits.com:8001/rivers");
|
||||
}
|
||||
|
||||
Tag mTagWater = new Tag("waterway", "river");
|
||||
|
||||
@Override
|
||||
public void decodeTags(MapElement mapElement, Map<String, Object> properties) {
|
||||
|
||||
mapElement.tags.add(mTagWater);
|
||||
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user