Skip to content
Permalink
Browse files

OpenStreetMap Mapnik: add user agent

  • Loading branch information...
devemux86 committed May 29, 2019
1 parent 9782425 commit 6d213e51a7f66b4481f3b62fd514bc51afad13e8
@@ -1,7 +1,7 @@
/*
* Copyright 2010, 2011, 2012, 2013 mapsforge.org
* Copyright 2014 Ludwig M Brinckmann
* Copyright 2014-2018 devemux86
* Copyright 2014-2019 devemux86
*
* 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
@@ -29,6 +29,8 @@
* the OSM server sets on a newly rendered tile.
* <p/>
* Refer to {@link org.mapsforge.map.layer.download.TileDownloadLayer} for details on the TTL mechanism.
* <p/>
* Requires a valid HTTP User-Agent identifying application: https://operations.osmfoundation.org/policies/tiles/
*/
public class OpenStreetMapMapnik extends AbstractTileSource {
public static final OpenStreetMapMapnik INSTANCE = new OpenStreetMapMapnik(new String[]{
@@ -1,7 +1,7 @@
/*
* Copyright 2010, 2011, 2012, 2013 mapsforge.org
* Copyright 2013-2014 Ludwig M Brinckmann
* Copyright 2015-2018 devemux86
* Copyright 2015-2019 devemux86
* Copyright 2015 Andreas Schildbach
*
* This program is free software: you can redistribute it and/or modify it under the
@@ -34,13 +34,15 @@

@Override
protected void createLayers() {
OpenStreetMapMapnik tileSource = OpenStreetMapMapnik.INSTANCE;
tileSource.setUserAgent("mapsforge-samples-android");
this.downloadLayer = new TileDownloadLayer(this.tileCaches.get(0),
this.mapView.getModel().mapViewPosition, OpenStreetMapMapnik.INSTANCE,
this.mapView.getModel().mapViewPosition, tileSource,
AndroidGraphicFactory.INSTANCE);
mapView.getLayerManager().getLayers().add(this.downloadLayer);

mapView.setZoomLevelMin(OpenStreetMapMapnik.INSTANCE.getZoomLevelMin());
mapView.setZoomLevelMax(OpenStreetMapMapnik.INSTANCE.getZoomLevelMax());
mapView.setZoomLevelMin(tileSource.getZoomLevelMin());
mapView.setZoomLevelMax(tileSource.getZoomLevelMax());
}

@Override
@@ -1,7 +1,7 @@
/*
* Copyright 2010, 2011, 2012, 2013 mapsforge.org
* Copyright 2013-2014 Ludwig M Brinckmann
* Copyright 2015-2017 devemux86
* Copyright 2015-2019 devemux86
*
* 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
@@ -31,8 +31,10 @@

@Override
protected void createLayers2() {
OpenStreetMapMapnik tileSource = OpenStreetMapMapnik.INSTANCE;
tileSource.setUserAgent("mapsforge-samples-android");
this.downloadLayer = new TileDownloadLayer(this.tileCaches.get(1),
this.mapView2.getModel().mapViewPosition, OpenStreetMapMapnik.INSTANCE,
this.mapView2.getModel().mapViewPosition, tileSource,
AndroidGraphicFactory.INSTANCE);
this.mapView2.getLayerManager().getLayers().add(this.downloadLayer);
}
@@ -2,7 +2,7 @@
* Copyright 2010, 2011, 2012, 2013 mapsforge.org
* Copyright 2014 Christian Pesch
* Copyright 2014 Ludwig M Brinckmann
* Copyright 2014-2018 devemux86
* Copyright 2014-2019 devemux86
* Copyright 2017 usrusr
*
* This program is free software: you can redistribute it and/or modify it under the
@@ -146,7 +146,8 @@ private static BoundingBox addLayers(MapView mapView, List<File> mapFiles, Hills
if (SHOW_RASTER_MAP) {
// Raster
mapView.getModel().displayModel.setFixedTileSize(tileSize);
TileSource tileSource = OpenStreetMapMapnik.INSTANCE;
OpenStreetMapMapnik tileSource = OpenStreetMapMapnik.INSTANCE;
tileSource.setUserAgent("mapsforge-samples-awt");
TileDownloadLayer tileDownloadLayer = createTileDownloadLayer(tileCache, mapView.getModel().mapViewPosition, tileSource);
layers.add(tileDownloadLayer);
tileDownloadLayer.start();

0 comments on commit 6d213e5

Please sign in to comment.
You can’t perform that action at this time.