org.jxmapviewer.WMSTileFactoryInfo Maven / Gradle / Ivy
package org.jxmapviewer;
import org.jxmapviewer.viewer.TileFactoryInfo;
import org.jxmapviewer.viewer.util.MercatorUtils;
/**
* @author Georgios Migdos
*/
public class WMSTileFactoryInfo extends TileFactoryInfo
{
private String layers;
private String styles;
private String tileBgColor;
private String tileFormat;
private String srs;
public WMSTileFactoryInfo(int minZoom, int maxZoom, int totalMapZoom, String baseURL, String layers, String styles, String defaultBgColor, String tileFormat, String srs, int tileSize)
{
super(minZoom, maxZoom, totalMapZoom, tileSize, true, true, baseURL, "x", "y", "zoom");
this.layers = layers;
this.styles = styles;
this.tileBgColor = defaultBgColor;
this.tileFormat = tileFormat;
this.srs = srs;
}
public WMSTileFactoryInfo(int minZoom, int maxZoom, int totalMapZoom, String baseURL, String layers, String styles, String defaultBgColor){
this(minZoom, maxZoom, totalMapZoom, baseURL, layers, styles, defaultBgColor, "image/jpeg", "EPSG:4326", 255);
}
public WMSTileFactoryInfo(int minZoom, int maxZoom, int totalMapZoom, String baseURL, String layers, String defaultBgColor){
this(minZoom, maxZoom, totalMapZoom, baseURL, layers, "", defaultBgColor);
}
public WMSTileFactoryInfo(int minZoom, int maxZoom, int totalMapZoom, String baseURL, String layers){
this(minZoom, maxZoom, totalMapZoom, baseURL, layers, "0xAFDAF6");
}
@Override
public String getTileUrl(int x, int y, int zoom)
{
int tileSize = getTileSize(zoom);
zoom = getTotalMapZoom() - zoom;
int z = (int) Math.pow(2, (double) zoom - 1);
int m = x - z;
int n = z - 1 - y;
int tilesPerDimension = (int) Math.pow(2, zoom);
double radius = (tileSize * tilesPerDimension) / (2 * Math.PI);
double ulx = MercatorUtils.xToLong(m * tileSize, radius);
double uly = MercatorUtils.yToLat(n * tileSize, radius);
double lrx = MercatorUtils.xToLong((m + 1) * tileSize, radius);
double lry = MercatorUtils.yToLat((n + 1) * tileSize, radius);
if(lrx
© 2015 - 2024 Weber Informatics LLC | Privacy Policy