Source Code Cross Referenced for GmlFeatureInfoResponse.java in  » GIS » GeoServer » org » vfny » geoserver » wms » responses » featureInfo » 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 » GeoServer » org.vfny.geoserver.wms.responses.featureInfo 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Copyright (c) 2001 - 2007 TOPP - www.openplans.org.  All rights reserved.
002:         * This code is licensed under the GPL 2.0 license, availible at the root
003:         * application directory.
004:         */
005:        package org.vfny.geoserver.wms.responses.featureInfo;
006:
007:        import net.opengis.wfs.FeatureCollectionType;
008:        import net.opengis.wfs.GetFeatureType;
009:        import net.opengis.wfs.QueryType;
010:        import net.opengis.wfs.WfsFactory;
011:
012:        import org.geoserver.platform.Operation;
013:        import org.geoserver.platform.Service;
014:        import org.geoserver.wfs.WFS;
015:        import org.geoserver.wfs.WebFeatureService;
016:        import org.geoserver.wfs.xml.GML2OutputFormat;
017:        import org.geotools.feature.FeatureCollection;
018:        import org.geotools.gml2.bindings.GML2EncodingUtils;
019:        import org.vfny.geoserver.ServiceException;
020:        import org.vfny.geoserver.global.Data;
021:        import org.vfny.geoserver.global.FeatureTypeInfo;
022:        import org.vfny.geoserver.global.GeoServer;
023:        import org.vfny.geoserver.global.WMS;
024:        import org.vfny.geoserver.servlets.AbstractService;
025:        import org.vfny.geoserver.wms.requests.GetFeatureInfoRequest;
026:        import org.vfny.geoserver.wms.servlets.WMService;
027:        import java.io.IOException;
028:        import java.io.OutputStream;
029:        import java.math.BigInteger;
030:        import java.net.URI;
031:        import java.net.URISyntaxException;
032:        import java.util.ArrayList;
033:        import java.util.Collections;
034:        import java.util.HashMap;
035:        import java.util.Iterator;
036:        import java.util.List;
037:
038:        /**
039:         * A GetFeatureInfo response handler specialized in producing GML data for a
040:         * GetFeatureInfo request.
041:         *
042:         * <p>
043:         * This class does not deals directly with GML encoding. Instead, it works by
044:         * taking the FeatureResults produced in <code>execute()</code> and constructs
045:         * a <code>GetFeaturesResult</code> wich is passed to a
046:         * <code>GML2FeatureResponseDelegate</code>, as if it where the result of a
047:         * GetFeature WFS request.
048:         * </p>
049:         *
050:         * @author Gabriel Roldan, Axios Engineering
051:         */
052:        public class GmlFeatureInfoResponse extends AbstractFeatureInfoResponse {
053:            /**
054:             * The MIME type of the format this response produces:
055:             * <code>"application/vnd.ogc.gml"</code>
056:             */
057:            private static final String FORMAT = "application/vnd.ogc.gml";
058:
059:            /**
060:             * Default constructor, sets up the supported output format string.
061:             */
062:            public GmlFeatureInfoResponse() {
063:                super .supportedFormats = Collections.singletonList(FORMAT);
064:            }
065:
066:            /**
067:             * Returns any extra headers that this service might want to set in the HTTP
068:             * response object.
069:             *
070:             * @see org.vfny.geoserver.Response#getResponseHeaders()
071:             */
072:            public HashMap getResponseHeaders() {
073:                return new HashMap();
074:            }
075:
076:            /**
077:             * Takes the <code>FeatureResult</code>s generated by the
078:             * <code>execute</code> method in the superclass and constructs a
079:             * <code>GetFeaturesResult</code> wich is passed to a
080:             * <code>GML2FeatureResponseDelegate</code>.
081:             *
082:             * @param out
083:             *            DOCUMENT ME!
084:             *
085:             * @throws ServiceException
086:             *             DOCUMENT ME!
087:             * @throws IOException
088:             *             DOCUMENT ME!
089:             */
090:            public void writeTo(OutputStream out) throws ServiceException,
091:                    IOException {
092:                GetFeatureInfoRequest fInfoReq = (GetFeatureInfoRequest) getRequest();
093:                WMS wms = (WMS) fInfoReq.getServiceRef().getServiceRef();
094:                WFS wfs = wms.getWFS();
095:                GeoServer gs = wms.getGeoServer();
096:
097:                Data catalog = fInfoReq.getServiceRef().getCatalog();
098:
099:                //the 'response' object we'll pass to our OutputFormat
100:                FeatureCollectionType features = WfsFactory.eINSTANCE
101:                        .createFeatureCollectionType();
102:
103:                //the 'request' object we'll pass to our OutputFormat
104:                GetFeatureType gfreq = WfsFactory.eINSTANCE
105:                        .createGetFeatureType();
106:                gfreq.setBaseUrl(fInfoReq.getBaseUrl());
107:
108:                for (Iterator i = results.iterator(); i.hasNext();) {
109:                    FeatureCollection fc = (FeatureCollection) i.next();
110:                    features.getFeature().add(fc);
111:
112:                    QueryType qt = WfsFactory.eINSTANCE.createQueryType();
113:                    String crs = GML2EncodingUtils.epsgCode(fc.getSchema()
114:                            .getDefaultGeometry().getCoordinateSystem());
115:                    if (crs != null) {
116:                        final String srsName = "EPSG:" + crs;
117:                        try {
118:                            qt.setSrsName(new URI(srsName));
119:                        } catch (URISyntaxException e) {
120:                            throw new ServiceException(
121:                                    "Unable to determite coordinate system for featureType "
122:                                            + fc.getSchema().getTypeName()
123:                                            + ".  Schema told us '" + srsName
124:                                            + "'", e);
125:                        }
126:                    }
127:                    gfreq.getQuery().add(qt);
128:
129:                }
130:
131:                //this is a dummy wrapper around our 'request' object so that the new Dispatcher will accept it.
132:                Service serviceDesc = new Service("wms", null, null);
133:                Operation opDescriptor = new Operation("", serviceDesc, null,
134:                        new Object[] { gfreq });
135:
136:                GML2OutputFormat format = new GML2OutputFormat(wfs, gs, catalog);
137:                format.write(features, out, opDescriptor);
138:            }
139:
140:            public String getContentDisposition() {
141:                // TODO Auto-generated method stub
142:                return null;
143:            }
144:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.