-
Notifications
You must be signed in to change notification settings - Fork 341
Expand file tree
/
Copy pathOSMMapnikLayer.java
More file actions
64 lines (55 loc) · 2.04 KB
/
OSMMapnikLayer.java
File metadata and controls
64 lines (55 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
* Copyright (C) 2012 United States Government as represented by the Administrator of the
* National Aeronautics and Space Administration.
* All Rights Reserved.
*/
package gov.nasa.worldwind.layers.Earth;
import gov.nasa.worldwind.avlist.*;
import gov.nasa.worldwind.geom.*;
import gov.nasa.worldwind.layers.mercator.*;
import gov.nasa.worldwind.util.*;
import java.net.*;
/**
* @version $Id: OSMMapnikLayer.java 1171 2013-02-11 21:45:02Z dcollins $
*/
public class OSMMapnikLayer extends BasicMercatorTiledImageLayer
{
static final double DEFAULT_OPACITY = 0.5d;
public OSMMapnikLayer()
{
super(makeLevels());
setOpacity(DEFAULT_OPACITY);
}
private static LevelSet makeLevels()
{
AVList params = new AVListImpl();
params.setValue(AVKey.TILE_WIDTH, 256);
params.setValue(AVKey.TILE_HEIGHT, 256);
params.setValue(AVKey.DATA_CACHE_NAME, "Earth/OSM-Mercator/OpenStreetMap Mapnik");
params.setValue(AVKey.SERVICE, "http://a.tile.openstreetmap.org/");
params.setValue(AVKey.DATASET_NAME, "h");
params.setValue(AVKey.FORMAT_SUFFIX, ".png");
params.setValue(AVKey.NUM_LEVELS, 16);
params.setValue(AVKey.NUM_EMPTY_LEVELS, 0);
params.setValue(AVKey.LEVEL_ZERO_TILE_DELTA, new LatLon(Angle
.fromDegrees(22.5d), Angle.fromDegrees(45d)));
params.setValue(AVKey.SECTOR, new MercatorSector(-1.0, 1.0, Angle.NEG180, Angle.POS180));
params.setValue(AVKey.TILE_URL_BUILDER, new URLBuilder());
return new LevelSet(params);
}
private static class URLBuilder implements TileUrlBuilder
{
public URL getURL(Tile tile, String imageFormat)
throws MalformedURLException
{
return new URL(tile.getLevel().getService()
+ (tile.getLevelNumber() + 3) + "/" + tile.getColumn() + "/"
+ ((1 << (tile.getLevelNumber()) + 3) - 1 - tile.getRow()) + ".png");
}
}
@Override
public String toString()
{
return "OpenStreetMap";
}
}