Skip to content

Commit

Permalink
Mapbox (Mapzen): locale option opensciencemap#57
Browse files Browse the repository at this point in the history
  • Loading branch information
devemux86 committed Dec 29, 2016
1 parent 88f3283 commit 15bc23c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@
import org.oscim.theme.VtmThemes;
import org.oscim.tiling.source.UrlTileSource;
import org.oscim.tiling.source.mvt.MapboxTileSource;
import org.oscim.tiling.source.mvt.TileDecoder;

public class MapboxMapActivity extends MapActivity {

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

TileDecoder.LOCALE = "en";
UrlTileSource tileSource = MapboxTileSource.builder()
.apiKey("mapzen-xxxxxxx") // Put a proper API key
.build();
Expand Down
2 changes: 2 additions & 0 deletions vtm-playground/src/org/oscim/test/MapboxTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@
import org.oscim.theme.VtmThemes;
import org.oscim.tiling.source.UrlTileSource;
import org.oscim.tiling.source.mvt.MapboxTileSource;
import org.oscim.tiling.source.mvt.TileDecoder;

public class MapboxTest extends GdxMapApp {

@Override
public void createLayers() {
TileDecoder.LOCALE = "en";
UrlTileSource tileSource = MapboxTileSource.builder()
.apiKey("mapzen-xxxxxxx") // Put a proper API key
.build();
Expand Down
16 changes: 10 additions & 6 deletions vtm/src/org/oscim/tiling/source/mvt/TileDecoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@
import java.util.ArrayList;

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;

Expand Down Expand Up @@ -65,7 +70,6 @@ public class TileDecoder extends PbfDecoder {
private short[] mTmpTags = new short[1024];

private Tile mTile;
private final String mLocale = "en";
private ITileDataSink mMapDataCallback;

private final static float REF_TILE_SIZE = 4096.0f;
Expand Down Expand Up @@ -115,12 +119,12 @@ private boolean decodeLayer() throws IOException {

int bytes = decodeVarint32();

ArrayList<String> keys = new ArrayList<String>();
ArrayList<String> values = new ArrayList<String>();
ArrayList<String> keys = new ArrayList<>();
ArrayList<String> values = new ArrayList<>();

String name = null;
int numFeatures = 0;
ArrayList<Feature> features = new ArrayList<Feature>();
ArrayList<Feature> features = new ArrayList<>();

int end = position() + bytes;
while (position() < end) {
Expand Down Expand Up @@ -193,7 +197,7 @@ private boolean decodeLayer() throws IOException {
continue;
}

if (mLocale.equals(key.substring(5))) {
if (LOCALE.equals(key.substring(5))) {
//log.debug("found local " + key);
matchedLocal = i;
} //else
Expand Down

0 comments on commit 15bc23c

Please sign in to comment.