OpenMapTiles theme (#468)

This commit is contained in:
Robin 2018-01-04 14:45:30 +11:00 committed by Emux
parent 1d8cdd7feb
commit 5fc42268a4
No known key found for this signature in database
GPG Key ID: 89C6921D7AF2BDD0
2 changed files with 203 additions and 1145 deletions

View File

@ -1,5 +1,6 @@
/*
* Copyright 2017 devemux86
* Copyright 2017 Gustl22
*
* 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
@ -17,13 +18,14 @@ package org.oscim.tiling.source.geojson;
import org.oscim.core.MapElement;
import org.oscim.core.Tag;
import org.oscim.tiling.source.UrlTileSource;
import org.oscim.utils.math.MathUtils;
import java.util.LinkedHashMap;
import java.util.Map;
public class OpenMapTilesGeojsonTileSource extends GeojsonTileSource {
private final static String DEFAULT_URL = "https://free-0.tilehosting.com/data/v3";
private final static String DEFAULT_URL = "https://free.tilehosting.com/data/v3";
private final static String DEFAULT_PATH = "/{Z}/{X}/{Y}.geojson";
public static class Builder<T extends Builder<T>> extends UrlTileSource.Builder<T> {
@ -104,5 +106,18 @@ public class OpenMapTilesGeojsonTileSource extends GeojsonTileSource {
if (!hasName && fallbackName != null)
mapElement.tags.add(new Tag(Tag.KEY_NAME, fallbackName, false));
// Calculate height of building parts
if (!properties.containsKey(Tag.KEY_HEIGHT)) {
if (properties.containsKey(Tag.KEY_VOLUME) && properties.containsKey(Tag.KEY_AREA)) {
Object volume = properties.get(Tag.KEY_VOLUME);
String volumeStr = (volume instanceof String) ? (String) volume : String.valueOf(volume);
Object area = properties.get(Tag.KEY_AREA);
String areaStr = (area instanceof String) ? (String) area : String.valueOf(area);
float height = Float.parseFloat(volumeStr) / Float.parseFloat(areaStr);
String heightStr = String.valueOf(MathUtils.round2(height));
mapElement.tags.add(new Tag(Tag.KEY_HEIGHT, heightStr, false));
}
}
}
}

File diff suppressed because it is too large Load Diff