From dabf6af05857ccbb993fc9a6b10b807496e88c1d Mon Sep 17 00:00:00 2001 From: Eugene Maksymenko Date: Sun, 7 Aug 2022 22:33:09 +0300 Subject: [PATCH] Add Google, OpenStreetMap, OpenTogographicMap and WikiMap layers support. --- .../layer/mercator/google/GoogleLayer.java | 39 +++++++++++++++++++ .../layer/mercator/osm/OSMLayer.java | 23 +++++++++++ .../layer/mercator/osm/OTMLayer.java | 23 +++++++++++ .../layer/mercator/wiki/WikiLayer.java | 24 ++++++++++++ 4 files changed, 109 insertions(+) create mode 100644 worldwind/src/main/java/gov/nasa/worldwind/layer/mercator/google/GoogleLayer.java create mode 100644 worldwind/src/main/java/gov/nasa/worldwind/layer/mercator/osm/OSMLayer.java create mode 100644 worldwind/src/main/java/gov/nasa/worldwind/layer/mercator/osm/OTMLayer.java create mode 100644 worldwind/src/main/java/gov/nasa/worldwind/layer/mercator/wiki/WikiLayer.java diff --git a/worldwind/src/main/java/gov/nasa/worldwind/layer/mercator/google/GoogleLayer.java b/worldwind/src/main/java/gov/nasa/worldwind/layer/mercator/google/GoogleLayer.java new file mode 100644 index 00000000..03d79820 --- /dev/null +++ b/worldwind/src/main/java/gov/nasa/worldwind/layer/mercator/google/GoogleLayer.java @@ -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"; + } +} \ No newline at end of file diff --git a/worldwind/src/main/java/gov/nasa/worldwind/layer/mercator/osm/OSMLayer.java b/worldwind/src/main/java/gov/nasa/worldwind/layer/mercator/osm/OSMLayer.java new file mode 100644 index 00000000..a76549cf --- /dev/null +++ b/worldwind/src/main/java/gov/nasa/worldwind/layer/mercator/osm/OSMLayer.java @@ -0,0 +1,23 @@ +package gov.nasa.worldwind.layer.mercator.osm; + +import java.util.Random; + +import gov.nasa.worldwind.layer.mercator.MercatorTiledImageLayer; + +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"; + } + +} \ No newline at end of file diff --git a/worldwind/src/main/java/gov/nasa/worldwind/layer/mercator/osm/OTMLayer.java b/worldwind/src/main/java/gov/nasa/worldwind/layer/mercator/osm/OTMLayer.java new file mode 100644 index 00000000..a91916ce --- /dev/null +++ b/worldwind/src/main/java/gov/nasa/worldwind/layer/mercator/osm/OTMLayer.java @@ -0,0 +1,23 @@ +package gov.nasa.worldwind.layer.mercator.osm; + +import java.util.Random; + +import gov.nasa.worldwind.layer.mercator.MercatorTiledImageLayer; + +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"; + } + +} \ No newline at end of file diff --git a/worldwind/src/main/java/gov/nasa/worldwind/layer/mercator/wiki/WikiLayer.java b/worldwind/src/main/java/gov/nasa/worldwind/layer/mercator/wiki/WikiLayer.java new file mode 100644 index 00000000..48c03515 --- /dev/null +++ b/worldwind/src/main/java/gov/nasa/worldwind/layer/mercator/wiki/WikiLayer.java @@ -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(); + } + +} \ No newline at end of file