Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/config/worldwind.layers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@
<Layer href="config/Earth/USGSTopoLowResLayer.xml" actuate="onRequest"/>
<Layer href="config/Earth/USGSTopoMedResLayer.xml" actuate="onRequest"/>
<Layer href="config/Earth/USGSTopoHighResLayer.xml" actuate="onRequest"/>
<!--<Layer className="gov.nasa.worldwind.layers.Earth.OpenTopoMapLayer" actuate="onRequest"/>-->
<!--<Layer className="gov.nasa.worldwind.layers.Earth.OSMMapnikLayer" actuate="onRequest"/>-->
<!--<Layer className="gov.nasa.worldwind.layers.Earth.OSMCycleMapLayer" actuate="onRequest"/>-->
<!--<Layer className="gov.nasa.worldwind.layers.Earth.WikimapiaLayer" actuate="onRequest"/>-->
<Layer className="gov.nasa.worldwind.layers.Earth.CountryBoundariesLayer" actuate="onRequest"/>
<Layer href="config/Earth/OpenStreetMap.xml" actuate="onRequest"/>
<!--<Layer href="config/Earth/WorldBordersShapefile.xml" actuate="onRequest"/>-->
Expand Down
74 changes: 32 additions & 42 deletions src/gov/nasa/worldwind/layers/Earth/OSMCycleMapLayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
*/
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.*;

Expand All @@ -17,45 +14,38 @@
*/
public class OSMCycleMapLayer extends BasicMercatorTiledImageLayer
{
public OSMCycleMapLayer()
{
super(makeLevels());
public OSMCycleMapLayer()
{
super("h", "Earth/OSM-Mercator/OpenStreetMap Cycle", 19, 256, false, ".png", new URLBuilder());
}

private static class URLBuilder extends MercatorTileUrlBuilder
{
private String apiKey;

@Override
protected URL getMercatorURL(int x, int y, int z) throws MalformedURLException
{
String urlPostfix = (this.apiKey != null) ? "?apikey=" + this.apiKey : "";
return new URL("https://a.tile.thunderforest.com/cycle/" + z + "/" + x + "/" + y + ".png" + urlPostfix);
}
}

public void setAPIKey(String apiKey)
{
URLBuilder urlBuilder = (URLBuilder)getURLBuilder();
urlBuilder.apiKey = apiKey;
}

public String getAPIKey()
{
URLBuilder urlBuilder = (URLBuilder)getURLBuilder();
return urlBuilder.apiKey;
}

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 Cycle");
params.setValue(AVKey.SERVICE, "http://b.andy.sandbox.cloudmade.com/tiles/cycle/");
params.setValue(AVKey.DATASET_NAME, "*");
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 Cycle";
}
@Override
public String toString()
{
return "OpenStreetMap Cycle";
}
}
35 changes: 5 additions & 30 deletions src/gov/nasa/worldwind/layers/Earth/OSMMapnikLayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
*/
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.*;

Expand All @@ -19,37 +16,15 @@ public class OSMMapnikLayer extends BasicMercatorTiledImageLayer
{
public OSMMapnikLayer()
{
super(makeLevels());
super("h", "Earth/OSM-Mercator/OpenStreetMap Mapnik", 19, 256, false, ".png", new URLBuilder());
}

private static LevelSet makeLevels()
private static class URLBuilder extends MercatorTileUrlBuilder
{
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
@Override
protected URL getMercatorURL(int x, int y, int z) throws MalformedURLException
{
return new URL(tile.getLevel().getService()
+ (tile.getLevelNumber() + 3) + "/" + tile.getColumn() + "/"
+ ((1 << (tile.getLevelNumber()) + 3) - 1 - tile.getRow()) + ".png");
return new URL("https://a.tile.openstreetmap.org/" + z + "/" + x + "/" + y + ".png");
}
}

Expand Down
36 changes: 36 additions & 0 deletions src/gov/nasa/worldwind/layers/Earth/OpenTopoMapLayer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* 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.layers.mercator.*;

import java.net.*;

/**
* @author Sufaev
*/
public class OpenTopoMapLayer extends BasicMercatorTiledImageLayer
{
public OpenTopoMapLayer()
{
super("otm", "Earth/OpenTopoMap", 17, 256, false, ".png", new URLBuilder());
}

private static class URLBuilder extends MercatorTileUrlBuilder
{
@Override
protected URL getMercatorURL(int x, int y, int z) throws MalformedURLException
{
return new URL("https://a.tile.opentopomap.org/" + z + "/" + x + "/" + y + ".png");
}
}

@Override
public String toString()
{
return "OpenTopoMap";
}
}
62 changes: 62 additions & 0 deletions src/gov/nasa/worldwind/layers/Earth/WikimapiaLayer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* 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.layers.mercator.*;

import java.net.*;

/**
* @author Sufaev
*/
public class WikimapiaLayer extends BasicMercatorTiledImageLayer
{
public enum Type {MAP, HYBRID}

public WikimapiaLayer()
{
super("wm", "Earth/Wikimapia", 19, 256, true, ".png", new URLBuilder());
}

private static class URLBuilder extends MercatorTileUrlBuilder
{
private Type type;

private URLBuilder()
{
this.type = Type.HYBRID;
}

@Override
protected URL getMercatorURL(int x, int y, int z) throws MalformedURLException
{
int i = x % 4 + (y % 4) * 4;
return new URL("http://i" + i + ".wikimapia.org/?lng=0&x=" + x + "&y=" + y + "&zoom=" + z + "&type=" + this.type.name().toLowerCase());
}
}

public void setType(String type)
{
URLBuilder urlBuilder = (URLBuilder)getURLBuilder();
urlBuilder.type = Type.valueOf(type);

// Toggle overlay based on whether it is a hybrid map or not.
boolean isHybrid = urlBuilder.type.equals(Type.HYBRID);
setUseTransparentTextures(isHybrid);
}

public String getType()
{
URLBuilder urlBuilder = (URLBuilder)getURLBuilder();
return urlBuilder.type.name();
}

@Override
public String toString()
{
return "Wikimapia";
}
}
Loading