From: Artur H. <ko...@us...> - 2001-11-20 17:01:48
|
Update of /cvsroot/geotools/geotools/src/uk/ac/leeds/ccg/ogc In directory usw-pr-cvs1:/tmp/cvs-serv21444/uk/ac/leeds/ccg/ogc Modified Files: WMSLayer.java RemoteOGC.java RemoteConnection.java Log Message: Added byte[] getContentData() support Index: WMSLayer.java =================================================================== RCS file: /cvsroot/geotools/geotools/src/uk/ac/leeds/ccg/ogc/WMSLayer.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** WMSLayer.java 2001/10/24 09:40:18 1.24 --- WMSLayer.java 2001/11/20 17:01:45 1.25 *************** *** 121,125 **** GeoGraphics gg) { ! ImageLayer imageLayer; URL url; GeoRectangle extent = gg.getScale().getMapExtent(); --- 121,125 ---- GeoGraphics gg) { ! // ImageLayer imageLayer; URL url; GeoRectangle extent = gg.getScale().getMapExtent(); *************** *** 137,143 **** "EXCEPTIONS",this.exceptionFormat }; ! url = this.remoteWMS.getURL(params); ! imageLayer = new ImageLayer(url,extent); ! return imageLayer; } --- 137,153 ---- "EXCEPTIONS",this.exceptionFormat }; ! byte[] imageData = remoteWMS.getImageData(params); ! if (imageData != null) { ! System.out.println("Image data size is: "+imageData.length); ! Image img = Toolkit.getDefaultToolkit().createImage(imageData); ! return new ImageLayer(img, extent); ! } // end of if (imageData != null) ! else { ! return null; ! } // end of if (imageData != null)else ! // Image img = Toolkit.getDefaultToolkit().createImage(remoteWMS.getURL(params)); ! // return new ImageLayer(img, extent); ! // url = this.remoteWMS.getURL(params); ! // return new ImageLayer(url,extent); } *************** *** 158,164 **** * * $Log$ * Revision 1.24 2001/10/24 09:40:18 kobit * Added LOG cvs keyword to the end of file - * * */ --- 168,176 ---- * * $Log$ + * Revision 1.25 2001/11/20 17:01:45 kobit + * Added byte[] getContentData() support + * * Revision 1.24 2001/10/24 09:40:18 kobit * Added LOG cvs keyword to the end of file * */ Index: RemoteOGC.java =================================================================== RCS file: /cvsroot/geotools/geotools/src/uk/ac/leeds/ccg/ogc/RemoteOGC.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** RemoteOGC.java 2001/11/19 10:03:33 1.14 --- RemoteOGC.java 2001/11/20 17:01:45 1.15 *************** *** 130,133 **** --- 130,141 ---- } + protected void initConnection() + { + if(proxy!=null) + remoteConnection = new RemoteConnection(server.toString(), proxy.toString()); + else + remoteConnection = new RemoteConnection(server.toString(), null); + } + /** * <code>getURL</code> method builds a URL based on the proxy, the OGC *************** *** 170,173 **** --- 178,198 ---- } + public byte[] getImageData(String[] params) + { + URL url = this.getURL(params); + byte[] data = null; + try { + if (remoteConnection == null) { + initConnection(); + } // end of if (remoteConnection == null) + + int res = remoteConnection.sendRequest(url); + data = remoteConnection.getByteData(); + } catch (IOException e) { + data = null; + } // end of try-catch + return data; + } + /* ********* <code>WebMapService</code> proxy methods START *********** */ *************** *** 239,248 **** if(capabilities == null) { if(remoteConnection == null) ! if(proxy!=null) ! remoteConnection = new RemoteConnection( ! server.toString(), proxy.toString()); ! else ! remoteConnection = new RemoteConnection( ! server.toString(), null); try { query_result = --- 264,268 ---- if(capabilities == null) { if(remoteConnection == null) ! initConnection(); try { query_result = *************** *** 336,339 **** --- 356,362 ---- * * $Log$ + * Revision 1.15 2001/11/20 17:01:45 kobit + * Added byte[] getContentData() support + * * Revision 1.14 2001/11/19 10:03:33 kobit * *** empty log message *** Index: RemoteConnection.java =================================================================== RCS file: /cvsroot/geotools/geotools/src/uk/ac/leeds/ccg/ogc/RemoteConnection.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** RemoteConnection.java 2001/11/18 15:57:54 1.7 --- RemoteConnection.java 2001/11/20 17:01:45 1.8 *************** *** 100,103 **** --- 100,111 ---- } + protected void initConnection(URI uri) + throws IOException + { + url = uri; + connection = ProtocolFactory.createProtocol(uri, DEBUG); + connection.setStreamReadTimeout(60*1000); + } + public int sendQuery(String query) throws IOException, MalformedURLException *************** *** 107,118 **** else url = new URI(server+"&"+query); prln("URL="+url.toString()); ! connection = ProtocolFactory.createProtocol(url, DEBUG); ! connection.setStreamReadTimeout(60*1000); return identifyResponse(connection); } ! public InputStream getInputStream() ! throws IOException { if(connection != null) --- 115,134 ---- else url = new URI(server+"&"+query); + return sendRequest(new URL(url.toString())); + } + + public int sendRequest(URL url) throws IOException + { prln("URL="+url.toString()); ! if (connection == null) { ! initConnection(new URI(url)); ! } // end of if (connection == null) ! else { ! connection.setURI(new URI(url)); ! } // end of else of if (connection == null) return identifyResponse(connection); } ! public InputStream getInputStream() throws IOException { if(connection != null) *************** *** 121,124 **** --- 137,150 ---- } + public byte[] getByteData() throws IOException + { + if (connection != null) { + return connection.getContentData(); + } // end of if (connection != null) + else { + return null; + } // end of if (connection != null)else + } + public void saveContent(String fileName) throws IOException *************** *** 178,181 **** --- 204,210 ---- * * $Log$ + * Revision 1.8 2001/11/20 17:01:45 kobit + * Added byte[] getContentData() support + * * Revision 1.7 2001/11/18 15:57:54 kobit * Use of simple-jprotocols package instead of java.net, DTD validating switched OFF, default version if WMS implementation is set to 1.0.0 |