Mapbox (Mapzen): locale option #57
This commit is contained in:
parent
88f3283878
commit
15bc23cadf
@ -22,6 +22,7 @@ import org.oscim.layers.tile.vector.labeling.LabelLayer;
|
|||||||
import org.oscim.theme.VtmThemes;
|
import org.oscim.theme.VtmThemes;
|
||||||
import org.oscim.tiling.source.UrlTileSource;
|
import org.oscim.tiling.source.UrlTileSource;
|
||||||
import org.oscim.tiling.source.mvt.MapboxTileSource;
|
import org.oscim.tiling.source.mvt.MapboxTileSource;
|
||||||
|
import org.oscim.tiling.source.mvt.TileDecoder;
|
||||||
|
|
||||||
public class MapboxMapActivity extends MapActivity {
|
public class MapboxMapActivity extends MapActivity {
|
||||||
|
|
||||||
@ -29,6 +30,7 @@ public class MapboxMapActivity extends MapActivity {
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
TileDecoder.LOCALE = "en";
|
||||||
UrlTileSource tileSource = MapboxTileSource.builder()
|
UrlTileSource tileSource = MapboxTileSource.builder()
|
||||||
.apiKey("mapzen-xxxxxxx") // Put a proper API key
|
.apiKey("mapzen-xxxxxxx") // Put a proper API key
|
||||||
.build();
|
.build();
|
||||||
|
@ -21,11 +21,13 @@ import org.oscim.layers.tile.vector.labeling.LabelLayer;
|
|||||||
import org.oscim.theme.VtmThemes;
|
import org.oscim.theme.VtmThemes;
|
||||||
import org.oscim.tiling.source.UrlTileSource;
|
import org.oscim.tiling.source.UrlTileSource;
|
||||||
import org.oscim.tiling.source.mvt.MapboxTileSource;
|
import org.oscim.tiling.source.mvt.MapboxTileSource;
|
||||||
|
import org.oscim.tiling.source.mvt.TileDecoder;
|
||||||
|
|
||||||
public class MapboxTest extends GdxMapApp {
|
public class MapboxTest extends GdxMapApp {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createLayers() {
|
public void createLayers() {
|
||||||
|
TileDecoder.LOCALE = "en";
|
||||||
UrlTileSource tileSource = MapboxTileSource.builder()
|
UrlTileSource tileSource = MapboxTileSource.builder()
|
||||||
.apiKey("mapzen-xxxxxxx") // Put a proper API key
|
.apiKey("mapzen-xxxxxxx") // Put a proper API key
|
||||||
.build();
|
.build();
|
||||||
|
@ -33,7 +33,12 @@ import java.io.InputStream;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class TileDecoder extends PbfDecoder {
|
public class TileDecoder extends PbfDecoder {
|
||||||
static final Logger log = LoggerFactory.getLogger(TileDecoder.class);
|
private static final Logger log = LoggerFactory.getLogger(TileDecoder.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use default locale.
|
||||||
|
*/
|
||||||
|
public static String LOCALE = "";
|
||||||
|
|
||||||
private static final int TAG_TILE_LAYERS = 3;
|
private static final int TAG_TILE_LAYERS = 3;
|
||||||
|
|
||||||
@ -65,7 +70,6 @@ public class TileDecoder extends PbfDecoder {
|
|||||||
private short[] mTmpTags = new short[1024];
|
private short[] mTmpTags = new short[1024];
|
||||||
|
|
||||||
private Tile mTile;
|
private Tile mTile;
|
||||||
private final String mLocale = "en";
|
|
||||||
private ITileDataSink mMapDataCallback;
|
private ITileDataSink mMapDataCallback;
|
||||||
|
|
||||||
private final static float REF_TILE_SIZE = 4096.0f;
|
private final static float REF_TILE_SIZE = 4096.0f;
|
||||||
@ -115,12 +119,12 @@ public class TileDecoder extends PbfDecoder {
|
|||||||
|
|
||||||
int bytes = decodeVarint32();
|
int bytes = decodeVarint32();
|
||||||
|
|
||||||
ArrayList<String> keys = new ArrayList<String>();
|
ArrayList<String> keys = new ArrayList<>();
|
||||||
ArrayList<String> values = new ArrayList<String>();
|
ArrayList<String> values = new ArrayList<>();
|
||||||
|
|
||||||
String name = null;
|
String name = null;
|
||||||
int numFeatures = 0;
|
int numFeatures = 0;
|
||||||
ArrayList<Feature> features = new ArrayList<Feature>();
|
ArrayList<Feature> features = new ArrayList<>();
|
||||||
|
|
||||||
int end = position() + bytes;
|
int end = position() + bytes;
|
||||||
while (position() < end) {
|
while (position() < end) {
|
||||||
@ -193,7 +197,7 @@ public class TileDecoder extends PbfDecoder {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mLocale.equals(key.substring(5))) {
|
if (LOCALE.equals(key.substring(5))) {
|
||||||
//log.debug("found local " + key);
|
//log.debug("found local " + key);
|
||||||
matchedLocal = i;
|
matchedLocal = i;
|
||||||
} //else
|
} //else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user