Skip to content

Commit

Permalink
Add Google, OpenStreetMap, OpenTogographicMap and WikiMap layers supp…
Browse files Browse the repository at this point in the history
…ort.
  • Loading branch information
ComBatVision committed Aug 7, 2022
1 parent 06ee66c commit c21702a
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package gov.nasa.worldwind.layer.mercator.google;

import gov.nasa.worldwind.layer.mercator.MercatorTiledImageLayer;

public class GoogleLayer extends MercatorTiledImageLayer {

public GoogleLayer(Type type) {
super(type.layerName, 22, 0, 256, type.overlay);
this.lyrs = type.lyrs;
}

private final String lyrs;

public enum Type {
ROADMAP("Google road map", "m", false),
ROADMAP2("Google road map 2", "r", false),
TERRAIN("Google map w/ terrain", "p", false),
TERRAIN_ONLY("Google terrain only", "t", false),
HYBRID("Google hybrid", "y", false),
SATELLITE("Google satellite", "s", false),
ROADS("Google roads", "h", true),
TRAFFIC("Google traffic", "h,traffic&style=15", true);

private final String layerName;
private final String lyrs;
private final boolean overlay;

Type(String layerName, String lyrs, boolean overlay) {
this.layerName = layerName;
this.lyrs = lyrs;
this.overlay = overlay;
}
}

@Override
public String getImageSourceUrl(int x, int y, int z) {
return "https://mt.google.com/vt/lyrs="+lyrs+"&x="+x+"&y="+y+"&z="+z+"&hl=ru";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package gov.nasa.worldwind.layer.mercator.osm;

import gov.nasa.worldwind.layer.mercator.MercatorTiledImageLayer;
import java.util.*;

public class OSMLayer extends MercatorTiledImageLayer {

public static final String NAME = "OpenStreetMap";

private final Random random = new Random();

public OSMLayer() {
super(NAME, 20, 3, 256, false);
}

@Override
protected String getImageSourceUrl(int x, int y, int z) {
char abc = "abc".charAt(random.nextInt(2));
return "https://"+abc+".tile.openstreetmap.org/"+z+"/"+x+"/"+y+".png";
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package gov.nasa.worldwind.layer.mercator.osm;

import gov.nasa.worldwind.layer.mercator.MercatorTiledImageLayer;
import java.util.*;

public class OTMLayer extends MercatorTiledImageLayer {

public static final String NAME = "OpenTopoMap";

private final Random random = new Random();

public OTMLayer() {
super(NAME, 18, 3, 256, false);
}

@Override
protected String getImageSourceUrl(int x, int y, int z) {
char abc = "abc".charAt(random.nextInt(2));
return "https://"+abc+".tile.opentopomap.org/"+z+"/"+x+"/"+y+".png";
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package gov.nasa.worldwind.layer.mercator.wiki;

import gov.nasa.worldwind.layer.mercator.MercatorTiledImageLayer;

public class WikiLayer extends MercatorTiledImageLayer {

public enum Type { MAP, HYBRID }

public static final String NAME = "Wiki";

private final Type type;

public WikiLayer(Type type) {
super(NAME + type.name().toLowerCase(), 23, 3, 256, Type.HYBRID == type);
this.type = type;
}

@Override
protected String getImageSourceUrl(int x, int y, int z) {
int i = x % 4 + y % 4 * 4;
return "http://i"+i+".wikimapia.org/?lng=1&x="+x+"&y="+y+"&zoom="+z+"&type="+type.name().toLowerCase();
}

}

0 comments on commit c21702a

Please sign in to comment.