Source Code Cross Referenced for AbstractGetMapRequest.java in  » GIS » GeoTools-2.4.1 » org » geotools » data » wms » request » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » GIS » GeoTools 2.4.1 » org.geotools.data.wms.request 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *    GeoTools - OpenSource mapping toolkit
003:         *    http://geotools.org
004:         *    (C) 2004-2006, Geotools Project Managment Committee (PMC)
005:         *    
006:         *    This library is free software; you can redistribute it and/or
007:         *    modify it under the terms of the GNU Lesser General Public
008:         *    License as published by the Free Software Foundation; either
009:         *    version 2.1 of the License, or (at your option) any later version.
010:         *
011:         *    This library is distributed in the hope that it will be useful,
012:         *    but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         *    Lesser General Public License for more details.
015:         */
016:        package org.geotools.data.wms.request;
017:
018:        import java.io.UnsupportedEncodingException;
019:        import java.net.URL;
020:        import java.net.URLEncoder;
021:        import java.util.ListIterator;
022:        import java.util.Properties;
023:        import java.util.Stack;
024:
025:        import org.apache.commons.lang.StringUtils;
026:        import org.geotools.data.ows.AbstractRequest;
027:        import org.geotools.data.ows.CRSEnvelope;
028:        import org.geotools.data.ows.Layer;
029:        import org.opengis.layer.Style;
030:
031:        /**
032:         * @author Richard Gould
033:         *
034:         * TODO To change the template for this generated type comment go to
035:         * Window - Preferences - Java - Code Style - Code Templates
036:         * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/plugin/wms/src/main/java/org/geotools/data/wms/request/AbstractGetMapRequest.java $
037:         */
038:        public abstract class AbstractGetMapRequest extends AbstractWMSRequest
039:                implements  GetMapRequest {
040:
041:            Stack layers = new Stack();
042:            Stack styles = new Stack();
043:
044:            /**
045:             * Constructs a GetMapRequest. The data passed in represents valid values 
046:             * that can be used.
047:             * 
048:             * @param onlineResource the location that the request should be applied to
049:             * @param properties pre-set properties to be used. Can be null.
050:             */
051:            public AbstractGetMapRequest(URL onlineResource,
052:                    Properties properties) {
053:                super (onlineResource, properties);
054:            }
055:
056:            public URL getFinalURL() {
057:                if (!layers.isEmpty()) {
058:                    String layerString = ""; //$NON-NLS-1$
059:                    String styleString = ""; //$NON-NLS-1$
060:
061:                    ListIterator layerIter = layers.listIterator(layers.size());
062:                    ListIterator styleIter = styles.listIterator(styles.size());
063:                    while (layerIter.hasPrevious()) {
064:
065:                        String layerName = (String) layerIter.previous();
066:                        String styleName = (String) styleIter.previous();
067:
068:                        try {
069:                            layerString = layerString
070:                                    + URLEncoder.encode(layerName, "UTF-8");
071:                        } catch (UnsupportedEncodingException e) {
072:                            layerString = layerString + layerName;
073:                        }
074:                        try {
075:                            styleString = styleString
076:                                    + URLEncoder.encode(StringUtils
077:                                            .defaultString(styleName), "UTF-8");
078:                        } catch (UnsupportedEncodingException e1) {
079:                            styleString = styleString
080:                                    + StringUtils.defaultString(styleName);
081:                        }
082:
083:                        if (layerIter.hasPrevious()) {
084:                            layerString = layerString + ","; //$NON-NLS-1$
085:                            styleString = styleString + ","; //$NON-NLS-1$
086:                        }
087:                    }
088:
089:                    setProperty(LAYERS, layerString);
090:                    setProperty(STYLES, styleString);
091:                }
092:
093:                return super .getFinalURL();
094:            }
095:
096:            protected abstract void initVersion();
097:
098:            protected void initRequest() {
099:                setProperty(REQUEST, "GetMap"); //$NON-NLS-1$
100:            }
101:
102:            /**
103:             * Sets the version number of the request.
104:             *
105:             * @param version A String indicting a WMS Version ("1.0.0", "1.1.0",
106:             *        "1.1.1", or "1.3.0")
107:             */
108:            public void setVersion(String version) {
109:                properties.setProperty(VERSION, version);
110:            }
111:
112:            public void addLayer(Layer layer, String style) {
113:                addLayer(layer.getName(), style);
114:            }
115:
116:            public void addLayer(Layer layer) {
117:                addLayer(layer, "");
118:            }
119:
120:            public void addLayer(String layerName, String style) {
121:                layers.push(layerName);
122:                if (style == null) {
123:                    style = ""; //$NON-NLS-1$
124:                }
125:                styles.push(style);
126:            }
127:
128:            public void addLayer(Layer layer, Style style) {
129:                if (style == null) {
130:                    addLayer(layer.getName(), "");
131:                    return;
132:                }
133:                addLayer(layer.getName(), style.getName());
134:            }
135:
136:            public void addLayer(String layerName, Style style) {
137:                if (style == null) {
138:                    addLayer(layerName, "");
139:                    return;
140:                }
141:                addLayer(layerName, style.getName());
142:            }
143:
144:            /**
145:             * From the Web Map Service Implementation Specification: "The required SRS
146:             * parameter states which Spatial Reference System applies to the values
147:             * in the BBOX parameter. The value of the SRS parameter shall be on of
148:             * the values defined in the character data section of an <SRS> element
149:             * defined or inherited by the requested layer. The same SRS applies to
150:             * all layers in a single request. If the WMS has declared SRS=NONE for a
151:             * Layer, then the Layer does not have a well-defined spatial reference
152:             * system and should not be shown in conjunction with other layers. The
153:             * client shall specify SRS as "none" in the GetMap request and the Server
154:             * may issue a Service Exception otherwise."
155:             *
156:             * @param srs A String indicating the Spatial Reference System to render
157:             *        the layers in.
158:             */
159:            public void setSRS(String srs) {
160:                properties.setProperty(SRS, srs);
161:            }
162:
163:            /**
164:             * From the Web Map Service Implementation Specification: "The required
165:             * BBOX parameter allows a Client to request a particular Bounding Box.
166:             * The value of the BBOX parameter in a GetMap request is a list of
167:             * comma-separated numbers of the form "minx,miny,maxx,maxy". If the WMS
168:             * server has declared that a Layer is not subsettable, then the Client
169:             * shall specify exactly the declared Bounding Box values in the GetMap
170:             * request and the Server may issue a Service Exception otherwise."
171:             *
172:             * @param bbox A string representing a bounding box in the format
173:             *        "minx,miny,maxx,maxy"
174:             */
175:            public void setBBox(String bbox) {
176:                //TODO enforce non-subsettable layers
177:                properties.setProperty(BBOX, bbox);
178:            }
179:
180:            public void setBBox(CRSEnvelope box) {
181:                StringBuffer sb = new StringBuffer();
182:                sb.append(box.getMinX());
183:                sb.append(",");
184:                sb.append(box.getMinY() + ",");
185:                sb.append(box.getMaxX() + ",");
186:                sb.append(box.getMaxY());
187:                setBBox(sb.toString());
188:            }
189:
190:            /**
191:             * From the Web Map Service Implementation Specification: "The required
192:             * FORMAT parameter states the desired format of the response to an
193:             * operation. Supported values for a GetMap request on a WMS instance are
194:             * listed in one or more <Format> elements in the
195:             * &;ltRequest><GetMap> element of its Capabilities XML. The entire
196:             * MIME type string in <Format> is used as the value of the FORMAT
197:             * parameter."
198:             *
199:             * @param format The desired format for the GetMap response
200:             */
201:            public void setFormat(String format) {
202:                properties.setProperty(FORMAT, format);
203:            }
204:
205:            /**
206:             * From the Web Map Service Implementation Specification: "The required
207:             * WIDTH and HEIGHT parameters specify the size in integer pixels of the
208:             * map image to be produced. WIDTH specifies the number of pixels to be
209:             * used between the minimum and maximum X values (inclusive) in the BBOX
210:             * parameter, while HEIGHT specifies the number of pixels between the
211:             * minimum and maximum Y values. If the WMS server has declared that a
212:             * Layer has fixed width and height, then the Client shall specify exactly
213:             * those WIDTH and HEIGHT values in the GetMap request and the Server may
214:             * issue a Service Exception otherwise."
215:             *
216:             * @param width
217:             * @param height
218:             */
219:            public void setDimensions(String width, String height) {
220:                properties.setProperty(HEIGHT, height);
221:                properties.setProperty(WIDTH, width);
222:            }
223:
224:            // End required parameters, being optional ones.
225:            //TODO Implement optional parameters.
226:
227:            /**
228:             * From the Web Map Service Implementation Specification: "The optional
229:             * TRANSPARENT parameter specifies whether the map background is to be
230:             * made transparent or not. The default value is false if the parameter is
231:             * absent from the request."
232:             *
233:             * @param transparent true for transparency, false otherwise
234:             */
235:            public void setTransparent(boolean transparent) {
236:                String value = "FALSE"; //$NON-NLS-1$
237:
238:                if (transparent) {
239:                    value = "TRUE"; //$NON-NLS-1$
240:                }
241:
242:                properties.setProperty(TRANSPARENT, value);
243:            }
244:
245:            /**
246:             * Specifies the colour, in hexidecimal format, to be used as the
247:             * background of the map. It is a String representing RGB values in
248:             * hexidecimal format, prefixed by "0x". The format is: 0xRRGGBB. The
249:             * default value is 0xFFFFFF (white)
250:             *
251:             * @param bgColour the background colour of the map, in the format 0xRRGGBB
252:             */
253:            public void setBGColour(String bgColour) {
254:                properties.setProperty(BGCOLOR, bgColour);
255:            }
256:
257:            /**
258:             * The exceptions type specifies what format the server should return
259:             * exceptions in.
260:             * 
261:             * <p>
262:             * Valid values are:
263:             * 
264:             * <ul>
265:             * <li>
266:             * "application/vnd.ogc.se_xml" (the default)
267:             * </li>
268:             * <li>
269:             * "application/vnd.ogc.se_inimage"
270:             * </li>
271:             * <li>
272:             * "application/vnd.ogc.se_blank"
273:             * </li>
274:             * </ul>
275:             * </p>
276:             *
277:             * @param exceptions
278:             */
279:            public void setExceptions(String exceptions) {
280:                properties.setProperty(EXCEPTIONS, exceptions);
281:            }
282:
283:            /**
284:             * See the Web Map Server Implementation Specification 1.1.1, Annexes B and
285:             * C
286:             *
287:             * @param time See the Web Map Server Implementation Specification 1.1.1,
288:             *        Annexes B and C
289:             */
290:            public void setTime(String time) {
291:                properties.setProperty(TIME, time);
292:            }
293:
294:            /**
295:             * See the Web Map Server Implementation Specification 1.1.1, Annex C, in
296:             * particular section C.4
297:             *
298:             * @param elevation See the Web Map Server Implementation Specification
299:             *        1.1.1, Annex C
300:             */
301:            public void setElevation(String elevation) {
302:                properties.setProperty(ELEVATION, elevation);
303:            }
304:
305:            /**
306:             * See the Web Map Server Implementation Specification 1.1.1, Annex C, in
307:             * particular section C.4.2
308:             * 
309:             * <p>
310:             * Example use: <code>request.setSampleDimensionValue("DIM_WAVELENGTH",
311:             * "4000");</code>
312:             * </p>
313:             *
314:             * @param name the request parameter name to set (usually with 'dim_' as
315:             *        prefix)
316:             * @param value the value of the request parameter (value, interval or
317:             *        comma-separated list)
318:             */
319:            public void setSampleDimensionValue(String name, String value) {
320:                properties.setProperty(name, value);
321:            }
322:
323:            /**
324:             * Used to implement vendor specific parameters. Entirely optional.
325:             *
326:             * @param name a request parameter name
327:             * @param value a value to accompany the name
328:             */
329:            public void setVendorSpecificParameter(String name, String value) {
330:                properties.setProperty(name, value);
331:            }
332:
333:            public void setDimensions(int width, int height) {
334:                setDimensions("" + width, "" + height);
335:            }
336:
337:            public void setProperties(Properties p) {
338:                properties = p;
339:            }
340:
341:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.