/* Package GeoTools/WMS Implementation
* Copyright (C) 2001 Cameron Shorter (camerons@users.sourceforge.net)q
* Artur Hefczyc (kobit@users.sourceforge.net)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id: RemoteWMS.java,v 1.11 2001/11/18 15:57:54 kobit Exp $
* $Author: kobit $
* $Date: 2001/11/18 15:57:54 $
*/
package uk.ac.leeds.ccg.ogc;
import java.util.*;
import java.io.*;
import java.net.*;
/**
* Class RemoteWMS
provides an interface for the standard
* Web Map Server (WMS) protocols as defined by the
* Open GIS Consortium.
* It is an bridge between a remote WMS
* and GeoTools
client. Implemented methods of this
* class convert Web Map Server data representation to
* GeoTools
client data reprezentation.
* This class should be used in conjunction with WMSLayer
* @see uk.ac.leeds.ccg.ogc.WMSLayer
*
* @author Cameron Shorter
* @author Artur Hefczyc
* @version $Revision: 1.11 $
*/
public class RemoteWMS extends RemoteOGC
{
/**
* Creates a new RemoteWMS
instance. This constructor will
* trigger a GETCAPABILITIES to determine the remainder of its parameters.
*
* @param server an URL
value
* @param proxy an URL
value
*/
public RemoteWMS(URL server, URL proxy) {
super(server,proxy);
}
/**
* Creates a new RemoteWMS
instance. This constructor will
* trigger a GETCAPABILITIES to determine the remainder of its parameters.
*
* @param server an URL
value
* @param proxy an URL
value
*/
public RemoteWMS(URL server) {
super(server);
}
/**
* Creates a new RemoteWMS
instance. This constructor
* does not require a GETCAPABILITIES call to obtain remaining parameters.
*
* @param server an URL
value
* @param proxy an URL
value
* @param SRS the Spacial Reference System. See OGC Spec for description.
* @param Version the version of the OGC spec being used. See OGC Spec for
* description.
*/
public RemoteWMS(URL server, URL proxy, String SRS, String version) {
super(server,proxy,SRS,version);
}
/**
* getExternalLayers
method returns ArrayList
* with ExternalWMSLayers
objects.
*
* @return an ArrayList
with ExternalWMSLayers
* objects.
* @exception IOException if an error occurs
*/
public ArrayList getExternalLayers() throws IOException {
if(capabilities == null)
getCapabilities();
if (capabilities != null) {
return capabilities.getAvailableLayers();
} // end of if (capabilities != null)
else {
return null;
} // end of if (capabilities != null)else
}
/**
* getWMSLayer
method creates WMSLayer instance from
* data downloaded from WebMapService
. To do it
* it must build query for web server, send request and receive data.
* This method can take lonk period of time (even infinite if we don't
* read data from the network in separate thread and use better HTTP
* implementation).
* Mr Cameron prefers to use GeoRectangle
class instead
* of using x, y, w, h. I don't like this idea, becouse most of
* ogc package is GeoTools
library independent and it
* is worth to keep it that. There is only one class which must use
* GeoTools
package it is WMSLayer
.
*
* @param ext_layer an ExternalWMSLayer
value
* @param format a WMSFormat
value
* @param x a double
value
* @param y a double
value
* @param width a double
value
* @param height a double
value
* @return a WMSLayer
class instance created from data
* received from WebMapService
. I think that
* this method should better return
* uk.ac.leeds.ccg.geotools.Layer
instead of
* WMSLayer
.
*/
public WMSLayer getWMSLayer(ExternalWMSLayer [] ext_layers,
WMSFormat format,
double x, double y, double width, double height)
//throws IOException
{
//If we haven't capabilities file then we should download it
try {
if(capabilities == null) getCapabilities();
} catch(IOException ioe) { ioe.printStackTrace(); }
//if(webMap != null) {
//String file_name = new String(ext_layer.getLayerName()+"-"+
//x+"_"+y+"_"+width+"_"+height+"."+
//format.getFormatExtension());
//if(!new File(file_name).exists()) {
//String query = webMap.wmsLayerQuery(ext_layer, format, x, y, width, height);
//if(remoteConnection == null)
//remoteConnection = new RemoteConnection(server, proxy);
//int query_result = remoteConnection.sendQuery(query);
//if(query_result != RemoteConnection.RESPONSE_ERROR)
//remoteConnection.saveContent(file_name);
//}
// return webMap.getWMSLayer(ext_layers, format, x, y, width, height,
// server+"?WMTVER=1.0&REQUEST=map&SRS=EPSG%3A4326");
//}
return null;
}
}
/*
* Changes in file:
*
* $Log: RemoteWMS.java,v $
* Revision 1.11 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
*
* Revision 1.10 2001/10/24 09:42:24 kobit
* Some minor changes for working according to new design
*
*
*/