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.wms;
14 import java.awt.geom.Rectangle2D;
15 import java.net.MalformedURLException;
18 * @author Tuukka Lehtonen
20 public class WMSGetMapQuery {
22 String srs = "EPSG:4326";
36 public WMSGetMapQuery(int width, int height, Rectangle2D bbox, 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 String toString() {
58 if (layers.length == 0)
59 throw new IllegalStateException("0 layers defined");
61 StringBuilder sb = new StringBuilder(200);
63 // request=GetMap&layers=global_mosaic&srs=EPSG:4326&width=512&height=512
64 // &bbox=-180,-38,-52,90
65 // &format=image/jpeg&version=1.1.1&styles=visual
67 sb.append("request=GetMap");
68 sb.append("&service=WMS");
69 sb.append("&layers=");
71 for (int i = 1; i < layers.length; ++i) {
79 sb.append("&height=");
82 sb.append(bbox.getMinX());
84 sb.append(bbox.getMinY());
86 sb.append(bbox.getMaxX());
88 sb.append(bbox.getMaxY());
89 sb.append("&format=");
91 sb.append("&version=1.1.1");
92 sb.append("&styles=");
93 if (styles != null && styles.length > 0) {
95 for (int i = 1; i < layers.length; ++i) {
101 return sb.toString();