Source Code Cross Referenced for SetWmcFromURL.java in  » GIS » geonetwork » org » wfp » vam » intermap » services » wmc » 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 » geonetwork » org.wfp.vam.intermap.services.wmc 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //=============================================================================
002:        //===	Copyright (C) 2001-2007 Food and Agriculture Organization of the
003:        //===	United Nations (FAO-UN), United Nations World Food Programme (WFP)
004:        //===	and United Nations Environment Programme (UNEP)
005:        //===
006:        //===	This program is free software; you can redistribute it and/or modify
007:        //===	it under the terms of the GNU General Public License as published by
008:        //===	the Free Software Foundation; either version 2 of the License, or (at
009:        //===	your option) any later version.
010:        //===
011:        //===	This program is distributed in the hope that it will be useful, but
012:        //===	WITHOUT ANY WARRANTY; without even the implied warranty of
013:        //===	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014:        //===	General Public License for more details.
015:        //===
016:        //===	You should have received a copy of the GNU General Public License
017:        //===	along with this program; if not, write to the Free Software
018:        //===	Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
019:        //===
020:        //===	Contact: Jeroen Ticheler - FAO - Viale delle Terme di Caracalla 2,
021:        //===	Rome - Italy. email: geonetwork@osgeo.org
022:        //==============================================================================
023:
024:        package org.wfp.vam.intermap.services.wmc;
025:
026:        import java.io.BufferedInputStream;
027:        import java.net.HttpURLConnection;
028:        import java.net.URL;
029:        import jeeves.interfaces.Service;
030:        import jeeves.server.ServiceConfig;
031:        import jeeves.server.context.ServiceContext;
032:        import jeeves.utils.Xml;
033:        import org.jdom.Element;
034:        import org.wfp.vam.intermap.Constants;
035:        import org.wfp.vam.intermap.kernel.map.MapMerger;
036:        import org.wfp.vam.intermap.kernel.map.mapServices.wmc.GeoRSSCodec;
037:        import org.wfp.vam.intermap.kernel.map.mapServices.wmc.schema.impl.WMCFactory;
038:        import org.wfp.vam.intermap.kernel.map.mapServices.wmc.schema.type.WMCExtension;
039:        import org.wfp.vam.intermap.kernel.map.mapServices.wmc.schema.type.WMCViewContext;
040:        import org.wfp.vam.intermap.kernel.map.mapServices.wmc.schema.type.WMCWindow;
041:        import org.wfp.vam.intermap.kernel.map.mapServices.wms.schema.impl.Utils;
042:        import org.wfp.vam.intermap.kernel.marker.MarkerSet;
043:        import org.wfp.vam.intermap.services.map.MapUtil;
044:
045:        /**
046:         * Set the WMC from an URL-retrieved document
047:         *
048:         * @author ETj
049:         */
050:        public class SetWmcFromURL implements  Service {
051:            public void init(String appPath, ServiceConfig config)
052:                    throws Exception {
053:            }
054:
055:            //--------------------------------------------------------------------------
056:            //---
057:            //--- Service
058:            //---
059:            //--------------------------------------------------------------------------
060:
061:            public Element exec(Element params, ServiceContext context)
062:                    throws Exception {
063:                String url = params.getChildText("url");
064:
065:                URL u = new URL(url);
066:                HttpURLConnection conn = (HttpURLConnection) u.openConnection();
067:                BufferedInputStream is = new BufferedInputStream(conn
068:                        .getInputStream());
069:                Element mapContext = Xml.loadStream(is);
070:                conn.disconnect();
071:
072:                //		XMLOutputter xo = new XMLOutputter(Format.getPrettyFormat());
073:                //		System.out.println(" ============= wmc is:\n\n" +xo.outputString(mapContext));
074:
075:                // Create a new MapMerger object
076:                String sreplace = params.getChildText("clear");
077:                boolean breplace = Utils.getBooleanAttrib(sreplace, true);
078:
079:                MapMerger mm = breplace ? new MapMerger() : MapUtil
080:                        .getMapMerger(context);
081:
082:                WMCViewContext vc = WMCFactory.parseViewContext(mapContext);
083:                WMCWindow win = vc.getGeneral().getWindow();
084:
085:                String imgurl = MapUtil.setContext(mm, vc);
086:
087:                // Update the user session
088:                context.getUserSession().setProperty(Constants.SESSION_MAP, mm);
089:
090:                // load markerset, if any, from context
091:                WMCExtension ext = vc.getGeneral().getExtension();
092:                if (ext != null) {
093:                    Element georss = ext.getChild("georss");
094:                    if (georss != null) {
095:                        Element feed = (Element) georss.getChildren().get(0);
096:                        MarkerSet ms = GeoRSSCodec.parseGeoRSS(feed);
097:                        context.getUserSession().setProperty(
098:                                Constants.SESSION_MARKERSET, ms);
099:                    }
100:                }
101:
102:                // Prepare response
103:                Element response = new Element("response").addContent(
104:                        new Element("imgUrl").setText(url)).addContent(
105:                        new Element("scale").setText(mm.getDistScale()))
106:                        .addContent(mm.getBoundingBox().toElement())
107:                        .addContent(
108:                                new Element("width").setText(""
109:                                        + win.getWidth())).addContent(
110:                                new Element("height").setText(""
111:                                        + win.getHeight()));
112:
113:                MarkerSet ms = (MarkerSet) context.getUserSession()
114:                        .getProperty(Constants.SESSION_MARKERSET);
115:                if (ms != null)
116:                    response.addContent(ms.select(mm.getBoundingBox())
117:                            .toElement());
118:
119:                return response;
120:            }
121:        }
122:
123:        //
124:        // 2007 11 22 ETj : following there is the old version of this service.
125:        // It handles some non-standard elements, and is deprecated.
126:        // I leave it here in case we need to restore it in a hurry, but it has to be removed entirely.
127:        //
128:
129:        //=============================================================================
130:
131:        /** main.result service. shows search results
132:         */
133:
134:        //public class SetWmcFromURL implements Service
135:        //{
136:        //	public void init(String appPath, ServiceConfig config) throws Exception {}
137:        //
138:        //	//--------------------------------------------------------------------------
139:        //	//---
140:        //	//--- Service
141:        //	//---
142:        //	//--------------------------------------------------------------------------
143:        //
144:        //	/**
145:        //	 * Method exec
146:        //	 *
147:        //	 * @param    params              an Element
148:        //	 * @param    context             a  ServiceContext
149:        //	 *
150:        //	 * @return   an Element
151:        //	 *
152:        //	 * @exception   Exception
153:        //	 *
154:        //	 */
155:        //	public Element exec(Element params, ServiceContext context) throws Exception
156:        //	{
157:        //		String url = params.getChildText("url");
158:        //
159:        //		URL u = new URL(url);
160:        //		HttpURLConnection conn = (HttpURLConnection)u.openConnection();
161:        //		BufferedInputStream is = new BufferedInputStream(conn.getInputStream());
162:        //		Element mapContext = Xml.loadStream(is);
163:        //		conn.disconnect();
164:        //
165:        //		String stContext = mapContext.getText();
166:        //		String decoded = URLDecoder.decode(stContext);
167:        //
168:        //		mapContext = Xml.loadString(decoded, false);
169:        //
170:        //		// Create a new MapMerger object
171:        //		MapMerger mm = addContextLayers(mapContext); // DEBUG
172:        //
173:        //		// Set image size if not set
174:        //		String size = (String)context.getUserSession().getProperty(Constants.SESSION_SIZE);
175:        //		if (size == null)
176:        //			context.getUserSession().setProperty(Constants.SESSION_SIZE, "small");
177:        //
178:        //		// Update the user session
179:        //		context.getUserSession().setProperty(Constants.SESSION_MAP, mm);
180:        //
181:        //		return new Element("response");
182:        //	}
183:        //
184:        //	public static MapMerger addContextLayers(Element context) throws Exception
185:        //	{
186:        //		MapMerger mm = new MapMerger();
187:        //
188:        //		// Add each layer in the context to the map
189:        //		Namespace ns = org.jdom.Namespace.getNamespace("http://www.opengeospatial.net/context");
190:        //		List layers = context.getChild("LayerList", ns).getChildren("Layer", ns);
191:        //
192:        //		for (Iterator i = layers.iterator(); i.hasNext(); )
193:        //		{
194:        //			Element layer = (Element)i.next();
195:        //
196:        //			int serverType = 2;
197:        //			Element olr = layer.getChild("Server", ns).getChild("OnlineResource", ns);
198:        //
199:        //			Namespace linkNs = Namespace.getNamespace("xlink", "http://www.w3.org/1999/xlink");
200:        //			String serverUrl = olr.getAttributeValue("href", linkNs);
201:        //			String serviceName = layer.getChildText("Name", ns);
202:        //			String vsp = layer.getChildText("vendor_spec_par"); // vendor specific parameters
203:        //
204:        //			try {
205:        //				MapUtil.addService(serverType, serverUrl, serviceName, vsp, mm);
206:        //			} catch (Exception e) { e.printStackTrace(); } // DEBUG
207:        //		}
208:        //
209:        //		mm.setBoundingBox(new BoundingBox());
210:        //		return mm;
211:        //	}
212:        //
213:        //}
214:        //=============================================================================
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.