1 /*******************************************************************************
2 * Copyright (c) 2012 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.maps.osm;
14 import java.awt.geom.Rectangle2D;
15 import java.net.MalformedURLException;
18 * @author Tuukka Lehtonen
20 public class OSMGetMapQuery {
22 String srs = "EPSG:4326";
36 public OSMGetMapQuery(int width, int height, Rectangle2D bbox,
37 String format, String... layers) throws MalformedURLException {
45 public void setSpatialReferenceSystem(String srs) {
49 public void setStyles(String... styles) {
53 public void setLayers(String... layers) {
57 public static String getTileNumber(final double lat, final double lon,
59 int xtile = (int) Math.floor((lon + 180) / 360 * (1 << zoom));
60 int ytile = (int) Math.floor((1 - Math.log(
61 Math.tan(Math.toRadians(lat))
62 + 1 / Math.cos(Math.toRadians(lat)))
65 return ("" + zoom + "/" + xtile + "/" + ytile+".png");
68 public String toString() {
69 return getTileNumber(bbox.getMinX(), bbox.getMinY(), 16);