Closed ComBatVision closed 4 years ago
public class OSMLayer extends MercatorTiledImageLayer {
public static final String NAME = "OpenStreetMap";
private final Random random = new Random();
public OSMLayer() {
super(NAME, 19, 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";
}
}
public class OTMLayer extends MercatorTiledImageLayer {
public static final String NAME = "OpenTopoMap";
private final Random random = new Random();
public OTMLayer() {
super(NAME, 17,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";
}
}
public class WikiLayer extends MercatorTiledImageLayer {
public enum Type {MAP, HYBRID}
public static final String NAME = "Wiki";
private final Type type;
public WikiLayer() {
this(Type.HYBRID);
}
public WikiLayer(Type type) {
super(NAME + type.name().toLowerCase(), 19, 3, 256, Type.HYBRID.equals(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();
}
}
public class GoogleLayer extends MercatorTiledImageLayer {
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),
;
Type(String name, String lyrs, boolean overlay) {
this.name = name;
this.lyrs = lyrs;
this.overlay = overlay;
}
public String getName() {
return name;
}
private final String name;
private final String lyrs;
private final boolean overlay;
}
public GoogleLayer(Type type) {
super(type.name, 22, 3,256, type.overlay);
this.lyrs = type.lyrs;
}
@Override
protected String getImageSourceUrl(int x, int y, int z) {
return "https://mt.google.com/vt/lyrs="+lyrs+"&x="+x+"&y="+y+"&z="+z+"&hl="+Locale.getDefault().getLanguage();
}
private final String lyrs;
}
I have ported and optimized MercatorTiledImageLayer from WorldWindJava.
It requires a MercatorSector:
MercatorImageTile:
MercatorTiledSurfaceImage:
MercatorTiledImageLayer:
And modified ImageSource, ImageRetriever and RenderResourceCache: