|
From: Artur H. <ko...@us...> - 2001-11-20 17:01:48
|
Update of /cvsroot/geotools/geotools/src/utils
In directory usw-pr-cvs1:/tmp/cvs-serv21444/utils
Modified Files:
WMSExample.java
Log Message:
Added byte[] getContentData() support
Index: WMSExample.java
===================================================================
RCS file: /cvsroot/geotools/geotools/src/utils/WMSExample.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** WMSExample.java 2001/11/10 12:14:41 1.11
--- WMSExample.java 2001/11/20 17:01:45 1.12
***************
*** 25,465 ****
implements ActionListener, ScaleChangedListener
{
! /** WMS server list for testing purpose.
! * Because of applet security restrctions you can use it only
! * when you run this class from command line as standalone application */
! String[] serverList = {
! "file:capabilities_1_1_0.xml",
! "http://usl.cubewerx.com/gfst/cubeserv/cubeserv.cgi",
! "http://usl.cubewerx.com/cubestor/cubeserv/cubeserv.cgi",
! "http://edcnts1.cr.usgs.gov:8080/servlet/com.esri.wms.Esrimap?servicename=USGSnhd",
! "http://edcnts1.cr.usgs.gov:8080/servlet/com.esri.wms.Esrimap?servicename=USGSned",
! "http://globe.digitalearth.gov/cgi-bin/wmt.cgi",
! "http://alpha.skylinesoft.com/services/ogc/wms/wms3d.asp",
! "http://wmt.laser-scan.com/servlets/WestminsterMapServlet",
! "http://wmt.laser-scan.com/servlets/GIJEMapServlet",
! "http://wmt.laser-scan.com/servlets/SLDMapServlet",
! "http://ogc.intergraph.com/mobile/request.asp",
! "http://maps.intergraph.com/wms/london/Request.asp",
! "http://www2.dmsolutions.ca:8099/cgi-bin/mswms_mpp1"
! };
! /** Mapping WMS addreses to shorter names */
! String[] serverNames = {
! "file:capabilities_1_1_0.xml",
! "usl.cubewerx.com 1",
! "usl.cubewerx.com 2",
! "edcnts1.cr.usgs.gov:8080 1",
! "edcnts1.cr.usgs.gov:8080 2",
! "globe.digitalearth.gov",
! "alpha.skylinesoft.com",
! "wmt.laser-scan.com 1",
! "wmt.laser-scan.com 2",
! "wmt.laser-scan.com 3",
! "ogc.intergraph.com",
! "maps.intergraph.com",
! "www2.dmsolutions.ca:8099"
! };
!
! private final static boolean DEBUG=true;
! /** Visual component displaing WMS Server list */
! Choice serverChoice = new Choice();
! /** After presing this button, capabilities from the server will be downloaded */
! Button bGetLayers = new Button("Connect");
! Button bGetMap = new Button("Get Map");
! ImageLayer imgLayer;
! URL currentUrl;
! String layers =null;
! /** Tool bar containing all controls */
! ToolBar tools = null;
! /** Right side panel with services list and layers list */
! Panel sideBar = null;
! /** Panel keeping layerList */
! Panel layerNames = new Panel();
! /** List with available layers on remote WMS server */
! List layerList = new List(12, true);
! /** Panel keeping WMS layers list title */
! Panel lay_tit_pan = new Panel();
! /** Title of list with WMS layers */
! TextField lay_tit_tex = new TextField(" Layer names: ");
! /** Panel keeping formatList */
! Panel formatNames = new Panel();
! /** List with available formats on remote WMS server */
! List formatList = new List(6, false);
! /** Panel keeping WMS formats list title */
! Panel for_tit_pan = new Panel();
! /** Title of list with WMS formats */
! TextField for_tit_tex = new TextField(" Available formats: ");
! /** Text with layer name info */
! TextField lay_name = new TextField(" No layers downloaded ");
! /** Text with layer title info */
! TextField lay_title = new TextField(" No layers downloaded ");
! /** Text with layer abstract info */
! TextField lay_abstract = new TextField(" No layers downloaded ");
! /** Text with layer name info */
! TextField lay_latlon = new TextField(" No layers downloaded ");
! Viewer view = new Viewer();
! /** List with WMS external layers */
! java.util.ArrayList ext_layers = null;
! /** Not used yet. */
! WMSLayer layer = null;
! Theme th;
! /** it is something similiar to geotools-ShapefileReader */
! RemoteWMS remoteWMS = null;
! String server_url = null;
! String proxy_url = null;
- /**
- * <code>init</code> method initalizes all needed graphics
- *
- */
- public void init(){
- for(int i = 0; i < serverNames.length; i++)
- serverChoice.addItem(serverNames[i]);
- serverChoice.addItemListener(new BGetLayers());
! this.setBackground(Color.white);
! setLayout(new BorderLayout(5,5));
! sideBar = new Panel();
! GridBagLayout gbl = new GridBagLayout();
! GridBagConstraints gbc = new GridBagConstraints();
! sideBar.setLayout(gbl);
! add(view,"Center");
! //view.getScale().addScaleChangedListener(this);
! tools = new ToolBar(view);
! tools.add(new ZoomLevelPicker(view));
! //bGetLayers.addActionListener(new BGetLayers());
! tools.add(serverChoice);
! //tools.add(bGetLayers);
! tools.add(bGetMap);
! bGetMap.addActionListener(this);
! add(tools, "South");
! lay_tit_tex.setEditable(false);
! layerList.addItemListener(new LayerListListener());
! layerList.add(" No layers downloaded yet ");
! for_tit_tex.setEditable(false);
! formatList.add(" No formats downloaded yet ");
! for_tit_pan.add(for_tit_tex);
! formatNames.add(formatList);
! lay_tit_pan.add(lay_tit_tex);
! layerNames.add(layerList);
! gbc.fill = GridBagConstraints.VERTICAL;
! // gbc.weightx = 1.0;
! gbc.gridwidth = GridBagConstraints.REMAINDER;
! gbl.setConstraints(lay_tit_pan, gbc);
! sideBar.add(lay_tit_pan);
! gbl.setConstraints(layerNames, gbc);
! sideBar.add(layerNames);
! gbl.setConstraints(for_tit_pan, gbc);
! sideBar.add(for_tit_pan);
! gbl.setConstraints(formatNames, gbc);
! sideBar.add(formatNames);
! gbl.setConstraints(lay_name, gbc);
! sideBar.add(lay_name);
! gbl.setConstraints(lay_title, gbc);
! sideBar.add(lay_title);
! gbl.setConstraints(lay_abstract, gbc);
! sideBar.add(lay_abstract);
! gbl.setConstraints(lay_latlon, gbc);
! sideBar.add(lay_latlon);
! add(sideBar, "East");
! }
! public void start(){
! }
! /**
! * Fill the display with a list of options provided by the capabilities
! * document of the WMS.
! * @exception Exception if an error occurs
! */
! public void loadCapabilities() throws Exception
! {
! String url = server_url;
! String proxy = null;
! /*
! try {
! url = getParameter("sampleurl");
! proxy = getParameter("proxyurl");
! } catch(NullPointerException npe) {
! url = server_url;
! }
! */
! deb("Sample url is: "+url);
! if (server_url==null) {
! System.out.println("server_url not defined yet");
! return;
! }
! if (remoteWMS==null) {
! deb("Creating WMSLayer...");
! // Create the 'interface' to WMS server and trigger getCapabilities
! // To do: SRS and version should be extracted from the
! // capabilities document. -Cameron.
! remoteWMS = new RemoteWMS(
! new URL(url), // WMS url
! null, // null proxy URL
! "EPSG:4326", // SRS
! "1.0.0"); // version
! }
! // Get all available layers on WMS - can take long time
! ext_layers = remoteWMS.getExternalLayers();
! if(ext_layers != null && ext_layers.size() > 0) {
! layerList.removeAll();
! for(int i = 0; i < ext_layers.size(); i++) {
! deb(""+(i+1)+". Layer: "+ext_layers.get(i));
! layerList.add(((ExternalWMSLayer)ext_layers.get(i)).toString());
! }
! }
! // Get formats available on WMS
! java.util.ArrayList formats = remoteWMS.getAvailableFormats("GetMap");
! if(formats != null && formats.size() > 0) {
! formatList.removeAll();
! for(int i = 0; i < formats.size(); i++) {
! deb(""+(i+1)+". Format: "+formats.get(i).toString());
! formatList.add(formats.get(i).toString());
! }
! }
}
! /**
! * Extract the options selected by the user and load a map from the WMS.
! */
! public void loadMap()
! {
! if (remoteWMS==null) {
! deb("remoteWMS not defined when calling loadMap()");
! } else {
! // build the layers string in the format:
! // "layer1,layer2,layer3"
! String layers="";
! // To do: Need to set extent to the aggregate extent of the
! // layers.
! GeoRectangle extent=new GeoRectangle(0,0,80,80);
! String[] selectedLayers = layerList.getSelectedItems();
! for(int i =0;i<selectedLayers.length;i++){
! layers=layers.concat(selectedLayers[i]);
! if (i<selectedLayers.length-1) {
! layers=layers.concat(",");
! }
! }
! WMSLayer wmsLayer=new WMSLayer(
! remoteWMS,
! layers,
! "", // style
! extent,
! OGCConstants.GIF,
! true,
! "0xFFFFFF",
! "INIMAGE");
! Theme wmsTheme= new Theme(wmsLayer);
! view.addTheme(wmsTheme);
! view.setMapExtent(extent);
}
}
! /**
! * Class <code>LayerListListener</code> event listener displays
! * <code>ExternalWMSLayer</code> details.
! *
! * @author <a href="mailto:art...@nu...">Artur Hefczyc</a>
! */
! class LayerListListener implements ItemListener {
! public void itemStateChanged(ItemEvent ie) {
! if(ext_layers != null) {
! int i = ((Integer)ie.getItem()).intValue();
! ExternalWMSLayer ewmsl = (ExternalWMSLayer)ext_layers.get(i);
! lay_name.setText(ewmsl.getLayerName());
! lay_title.setText(ewmsl.getLayerTitle());
! lay_abstract.setText(ewmsl.getLayerAbstract());
! lay_latlon.setText(ewmsl.llBBToString());
! }
! layer=null; // we need to fetch a new map
! }
}
! public void actionPerformed(ActionEvent ae)
! {
! String cmd = ae.getActionCommand();
! if(cmd.equalsIgnoreCase("get map")){
! if(ext_layers != null){
! loadMap();
! /*
! GeoRectangle b= new GeoRectangle();
! int[] idx = layerList.getSelectedIndexes();
! ExternalWMSLayer [] layers = new ExternalWMSLayer[idx.length];
! for(int i =0;i<idx.length;i++){
! layers[i] = (ExternalWMSLayer)ext_layers.get(idx[i]);
! b.add(layers[i].getBounds());
! }
! int i = formatList.getSelectedIndex();
! String imgType;
! if(i== -1){
! System.out.println("No Image format Selected - chosing gif");
! imgType ="image/gif";
! }else{
! imgType=formatList.getItem(i);
! //int k = imgType.lastIndexOf("/");
! //imgType = imgType.substring(k+1);
! }
! if(layer==null){ // new map
! layer=remoteWMS.getWMSLayer(layers,new
! WMSFormat(imgType),b.x,b.y,b.width,b.height);
! System.out.println("layer "+layer);
! if(th==null){
! th = new Theme(layer);
! view.addTheme(th);
! }else{
! th.setLayer(layer);
! }
! */
! }
! }
! }
! public void scaleChanged(ScaleChangedEvent sce){
! if(ext_layers != null) {
! try{
! int w,h;
! GeoRectangle b=view.scale.getMapExtent();
! w=view.getScale().toGraphics(b.width);
! h=view.getScale().toGraphics(b.height);
! String imgType;
! int i = formatList.getSelectedIndex();
! if(i== -1){
! System.out.println("No Image format Selected - chosing gif");
! imgType ="gif";
! }else{
! imgType=formatList.getItem(i);
! int k = imgType.lastIndexOf("/");
! imgType = imgType.substring(k+1);
! }
! currentUrl = new URL(server_url+"?WMTVER=1.0&REQUEST=map&SRS=EPSG%3A4326&format="+imgType+"&BBOX="+b.x+","+b.y+","+(b.x+b.width)+","+(b.y+b.height)+"&WIDTH="+w+"&HEIGHT="+h+"&LAYERS="+layers);
! imgLayer.changeImage(currentUrl,b);
! if(th==null){
! th = new Theme(imgLayer);
! view.addTheme(th);
! }
! }catch(MalformedURLException e){
! System.out.println("Whoops error building url");
! return;
! }
! }
! }
! /**
! * Class <code>BGetLayers</code> start connection to new remote WMS.
! *
! * @author <a href="mailto:art...@nu...">Artur Hefczyc</a>
! */
! class BGetLayers implements ActionListener,ItemListener {
! public void itemStateChanged(ItemEvent e){
! actionPerformed(new ActionEvent(e.getSource(),e.getID(),"Item"));
! }
! public void actionPerformed(ActionEvent ae) {
! int idx = serverChoice.getSelectedIndex();
! server_url = serverList[idx];
! try {
! loadCapabilities();
! layer=null; // need to fetch new map
! } catch(Exception e) {
! e.printStackTrace();
! }
! }
}
!
! /**
! * A Standard Applet method
! * @return String description of applet perameters.
! */
! public String getAppletInfo()
! {
! String info = "WMSLayer sample - Artur Hefczyc";
! return info;
}
! /**
! * A Standard Applet method
! * @return String description of applet perameters.
! */
! public String[][] getParameterInfo()
! {
! String pinfo[][] = {
! {"sampleurl", "relative url",
! "location of WMS Server or capabilities file."},
! {"proxyurl", "relative url",
! "not required and not used and sample, WMSLayer require two parameters"}
! };
! return pinfo;
! }
! public static void main(String[] argc)
! {
! WMSExample sample = new WMSExample();
! Frame frame = new Frame("WMS Example");
! frame.addWindowListener(new
! WindowAdapter() {
! public void windowClosing(WindowEvent we) {
! System.exit(0);
! }
! });
! frame.add(sample, BorderLayout.CENTER);
! frame.setSize(800, 600);
! sample.init();
! sample.start();
! frame.setVisible(true);
! }
! protected void deb(String str)
! {
! if (DEBUG)System.err.println("WMSExample-->"+str);
! }
! }
! /*
! * Changes in file:
! *
! * $Log$
! * Revision 1.11 2001/11/10 12:14:41 camerons
! * clean up formatting
! *
! * Revision 1.10 2001/11/10 12:05:51 camerons
! * Have got a WMSExample working, gets capabilities, and now gets maps using WMSLayer
! *
! * Revision 1.9 2001/10/28 21:43:41 camerons
! * Changed default tabspace from 2 to 4, only effects formatting
! *
! * Revision 1.8 2001/10/28 21:42:22 camerons
! * Added some more functionality to build a map (using WMSLayer) but it does not have all params yet
! *
! * Revision 1.7 2001/10/24 09:43:32 kobit
! * Some changes to work with OGC in new ogc-design, now again parse capabilities and displays capabilities info
! *
! *
! */
--- 25,468 ----
implements ActionListener, ScaleChangedListener
{
! /** WMS server list for testing purpose.
! * Because of applet security restrctions you can use it only
! * when you run this class from command line as standalone application */
! String[] serverList = {
! "file:capabilities_1_1_0.xml",
! "http://usl.cubewerx.com/gfst/cubeserv/cubeserv.cgi",
! "http://usl.cubewerx.com/cubestor/cubeserv/cubeserv.cgi",
! "http://edcnts1.cr.usgs.gov:8080/servlet/com.esri.wms.Esrimap?servicename=USGSnhd",
! "http://edcnts1.cr.usgs.gov:8080/servlet/com.esri.wms.Esrimap?servicename=USGSned",
! "http://globe.digitalearth.gov/cgi-bin/wmt.cgi",
! "http://alpha.skylinesoft.com/services/ogc/wms/wms3d.asp",
! "http://wmt.laser-scan.com/servlets/WestminsterMapServlet",
! "http://wmt.laser-scan.com/servlets/GIJEMapServlet",
! "http://wmt.laser-scan.com/servlets/SLDMapServlet",
! "http://ogc.intergraph.com/mobile/request.asp",
! "http://maps.intergraph.com/wms/london/Request.asp",
! "http://www2.dmsolutions.ca:8099/cgi-bin/mswms_mpp1"
! };
! /** Mapping WMS addreses to shorter names */
! String[] serverNames = {
! "file:capabilities_1_1_0.xml",
! "usl.cubewerx.com 1",
! "usl.cubewerx.com 2",
! "edcnts1.cr.usgs.gov:8080 1",
! "edcnts1.cr.usgs.gov:8080 2",
! "globe.digitalearth.gov",
! "alpha.skylinesoft.com",
! "wmt.laser-scan.com 1",
! "wmt.laser-scan.com 2",
! "wmt.laser-scan.com 3",
! "ogc.intergraph.com",
! "maps.intergraph.com",
! "www2.dmsolutions.ca:8099"
! };
! private final static boolean DEBUG=true;
! /** Visual component displaing WMS Server list */
! Choice serverChoice = new Choice();
! /** After presing this button, capabilities from the server will be downloaded */
! Button bGetLayers = new Button("Connect");
! Button bGetMap = new Button("Get Map");
! ImageLayer imgLayer;
! URL currentUrl;
! String layers =null;
! /** Tool bar containing all controls */
! ToolBar tools = null;
! /** Right side panel with services list and layers list */
! Panel sideBar = null;
! /** Panel keeping layerList */
! Panel layerNames = new Panel();
! /** List with available layers on remote WMS server */
! List layerList = new List(12, true);
! /** Panel keeping WMS layers list title */
! Panel lay_tit_pan = new Panel();
! /** Title of list with WMS layers */
! TextField lay_tit_tex = new TextField(" Layer names: ");
! /** Panel keeping formatList */
! Panel formatNames = new Panel();
! /** List with available formats on remote WMS server */
! List formatList = new List(6, false);
! /** Panel keeping WMS formats list title */
! Panel for_tit_pan = new Panel();
! /** Title of list with WMS formats */
! TextField for_tit_tex = new TextField(" Available formats: ");
! /** Text with layer name info */
! TextField lay_name = new TextField(" No layers downloaded ");
! /** Text with layer title info */
! TextField lay_title = new TextField(" No layers downloaded ");
! /** Text with layer abstract info */
! TextField lay_abstract = new TextField(" No layers downloaded ");
! /** Text with layer name info */
! TextField lay_latlon = new TextField(" No layers downloaded ");
! Viewer view = new Viewer();
+ /** List with WMS external layers */
+ java.util.ArrayList ext_layers = null;
+ /** Not used yet. */
+ WMSLayer layer = null;
+ Theme th;
+ /** it is something similiar to geotools-ShapefileReader */
+ RemoteWMS remoteWMS = null;
+ String server_url = null;
+ String proxy_url = null;
! /**
! * <code>init</code> method initalizes all needed graphics
! *
! */
! public void init(){
! for(int i = 0; i < serverNames.length; i++)
! serverChoice.addItem(serverNames[i]);
! serverChoice.addItemListener(new BGetLayers());
! this.setBackground(Color.white);
! setLayout(new BorderLayout(5,5));
! sideBar = new Panel();
! GridBagLayout gbl = new GridBagLayout();
! GridBagConstraints gbc = new GridBagConstraints();
! sideBar.setLayout(gbl);
! add(view,"Center");
! //view.getScale().addScaleChangedListener(this);
! tools = new ToolBar(view);
! tools.add(new ZoomLevelPicker(view));
! //bGetLayers.addActionListener(new BGetLayers());
! tools.add(serverChoice);
! //tools.add(bGetLayers);
! tools.add(bGetMap);
! bGetMap.addActionListener(this);
! add(tools, "South");
! lay_tit_tex.setEditable(false);
! layerList.addItemListener(new LayerListListener());
! layerList.add(" No layers downloaded yet ");
! for_tit_tex.setEditable(false);
! formatList.add(" No formats downloaded yet ");
! for_tit_pan.add(for_tit_tex);
! formatNames.add(formatList);
! lay_tit_pan.add(lay_tit_tex);
! layerNames.add(layerList);
! gbc.fill = GridBagConstraints.VERTICAL;
! // gbc.weightx = 1.0;
! gbc.gridwidth = GridBagConstraints.REMAINDER;
! gbl.setConstraints(lay_tit_pan, gbc);
! sideBar.add(lay_tit_pan);
! gbl.setConstraints(layerNames, gbc);
! sideBar.add(layerNames);
! gbl.setConstraints(for_tit_pan, gbc);
! sideBar.add(for_tit_pan);
! gbl.setConstraints(formatNames, gbc);
! sideBar.add(formatNames);
! gbl.setConstraints(lay_name, gbc);
! sideBar.add(lay_name);
! gbl.setConstraints(lay_title, gbc);
! sideBar.add(lay_title);
! gbl.setConstraints(lay_abstract, gbc);
! sideBar.add(lay_abstract);
! gbl.setConstraints(lay_latlon, gbc);
! sideBar.add(lay_latlon);
! add(sideBar, "East");
! }
! public void start(){
! }
! /**
! * Fill the display with a list of options provided by the capabilities
! * document of the WMS.
! * @exception Exception if an error occurs
! */
! public void loadCapabilities() throws Exception
! {
! String url = server_url;
! String proxy = null;
! /*
! try {
! url = getParameter("sampleurl");
! proxy = getParameter("proxyurl");
! } catch(NullPointerException npe) {
! url = server_url;
! }
! */
! deb("Sample url is: "+url);
! if (server_url==null) {
! System.out.println("server_url not defined yet");
! return;
! }
! if (remoteWMS==null) {
! deb("Creating WMSLayer...");
! // Create the 'interface' to WMS server and trigger getCapabilities
! // To do: SRS and version should be extracted from the
! // capabilities document. -Cameron.
! remoteWMS = new RemoteWMS(
! new URL(url), // WMS url
! null, // null proxy URL
! "EPSG:4326", // SRS
! "1.0.0"); // version
}
! // Get all available layers on WMS - can take long time
! ext_layers = remoteWMS.getExternalLayers();
! if(ext_layers != null && ext_layers.size() > 0) {
! layerList.removeAll();
! for(int i = 0; i < ext_layers.size(); i++) {
! deb(""+(i+1)+". Layer: "+ext_layers.get(i));
! layerList.add(((ExternalWMSLayer)ext_layers.get(i)).toString());
! }
! }
! // Get formats available on WMS
! java.util.ArrayList formats = remoteWMS.getAvailableFormats("GetMap");
! if(formats != null && formats.size() > 0) {
! formatList.removeAll();
! for(int i = 0; i < formats.size(); i++) {
! deb(""+(i+1)+". Format: "+formats.get(i).toString());
! formatList.add(formats.get(i).toString());
! }
! }
! }
! /**
! * Extract the options selected by the user and load a map from the WMS.
! */
! public void loadMap()
! {
! if (remoteWMS==null) {
! deb("remoteWMS not defined when calling loadMap()");
! } else {
! // build the layers string in the format:
! // "layer1,layer2,layer3"
! String layers="";
! // To do: Need to set extent to the aggregate extent of the
! // layers.
! GeoRectangle extent=new GeoRectangle(0,0,80,80);
! String[] selectedLayers = layerList.getSelectedItems();
! for(int i =0;i<selectedLayers.length;i++){
! layers=layers.concat(selectedLayers[i]);
! if (i<selectedLayers.length-1) {
! layers=layers.concat(",");
}
+ }
+
+ WMSLayer wmsLayer=new WMSLayer(
+ remoteWMS,
+ layers,
+ "", // style
+ extent,
+ OGCConstants.GIF,
+ true,
+ "0xFFFFFF",
+ "INIMAGE");
+ Theme wmsTheme= new Theme(wmsLayer);
+ view.addTheme(wmsTheme);
+ view.setMapExtent(extent);
}
+ }
! /**
! * Class <code>LayerListListener</code> event listener displays
! * <code>ExternalWMSLayer</code> details.
! *
! * @author <a href="mailto:art...@nu...">Artur Hefczyc</a>
! */
! class LayerListListener implements ItemListener {
! public void itemStateChanged(ItemEvent ie) {
! if(ext_layers != null) {
! int i = ((Integer)ie.getItem()).intValue();
! ExternalWMSLayer ewmsl = (ExternalWMSLayer)ext_layers.get(i);
! lay_name.setText(ewmsl.getLayerName());
! lay_title.setText(ewmsl.getLayerTitle());
! lay_abstract.setText(ewmsl.getLayerAbstract());
! lay_latlon.setText(ewmsl.llBBToString());
! }
! layer=null; // we need to fetch a new map
}
+ }
! public void actionPerformed(ActionEvent ae)
! {
! String cmd = ae.getActionCommand();
! if(cmd.equalsIgnoreCase("get map")){
! if(ext_layers != null){
! loadMap();
! /*
! GeoRectangle b= new GeoRectangle();
! int[] idx = layerList.getSelectedIndexes();
! ExternalWMSLayer [] layers = new ExternalWMSLayer[idx.length];
! for(int i =0;i<idx.length;i++){
! layers[i] = (ExternalWMSLayer)ext_layers.get(idx[i]);
! b.add(layers[i].getBounds());
! }
! int i = formatList.getSelectedIndex();
! String imgType;
! if(i== -1){
! System.out.println("No Image format Selected - chosing gif");
! imgType ="image/gif";
! }else{
! imgType=formatList.getItem(i);
! //int k = imgType.lastIndexOf("/");
! //imgType = imgType.substring(k+1);
! }
! if(layer==null){ // new map
! layer=remoteWMS.getWMSLayer(layers,new
! WMSFormat(imgType),b.x,b.y,b.width,b.height);
! System.out.println("layer "+layer);
! if(th==null){
! th = new Theme(layer);
! view.addTheme(th);
! }else{
! th.setLayer(layer);
! }
! */
! }
! }
! }
! public void scaleChanged(ScaleChangedEvent sce){
! if(ext_layers != null) {
! try{
! int w,h;
! GeoRectangle b=view.scale.getMapExtent();
! w=view.getScale().toGraphics(b.width);
! h=view.getScale().toGraphics(b.height);
! String imgType;
! int i = formatList.getSelectedIndex();
! if(i== -1){
! System.out.println("No Image format Selected - chosing gif");
! imgType ="gif";
! }else{
! imgType=formatList.getItem(i);
! int k = imgType.lastIndexOf("/");
! imgType = imgType.substring(k+1);
}
! currentUrl = new URL(server_url+"?WMTVER=1.0&REQUEST=map&SRS=EPSG%3A4326&format="+imgType+"&BBOX="+b.x+","+b.y+","+(b.x+b.width)+","+(b.y+b.height)+"&WIDTH="+w+"&HEIGHT="+h+"&LAYERS="+layers);
! imgLayer.changeImage(currentUrl,b);
! if(th==null){
! th = new Theme(imgLayer);
! view.addTheme(th);
}
+ }catch(MalformedURLException e){
+ System.out.println("Whoops error building url");
+ return;
+ }
+ }
+ }
+ /**
+ * Class <code>BGetLayers</code> start connection to new remote WMS.
+ *
+ * @author <a href="mailto:art...@nu...">Artur Hefczyc</a>
+ */
+ class BGetLayers implements ActionListener,ItemListener {
+ public void itemStateChanged(ItemEvent e){
+ actionPerformed(new ActionEvent(e.getSource(),e.getID(),"Item"));
+ }
+ public void actionPerformed(ActionEvent ae) {
+ int idx = serverChoice.getSelectedIndex();
+ server_url = serverList[idx];
+ try {
+ loadCapabilities();
+ layer=null; // need to fetch new map
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
! /**
! * A Standard Applet method
! * @return String description of applet perameters.
! */
! public String getAppletInfo()
! {
! String info = "WMSLayer sample - Artur Hefczyc";
! return info;
! }
! /**
! * A Standard Applet method
! * @return String description of applet perameters.
! */
! public String[][] getParameterInfo()
! {
! String pinfo[][] = {
! {"sampleurl", "relative url",
! "location of WMS Server or capabilities file."},
! {"proxyurl", "relative url",
! "not required and not used and sample, WMSLayer require two parameters"}
! };
! return pinfo;
! }
! public static void main(String[] argc)
! {
! WMSExample sample = new WMSExample();
! Frame frame = new Frame("WMS Example");
! frame.addWindowListener(new
! WindowAdapter() {
! public void windowClosing(WindowEvent we) {
! System.exit(0);
! }
! });
! frame.add(sample, BorderLayout.CENTER);
! frame.setSize(800, 600);
! sample.init();
! sample.start();
! frame.setVisible(true);
! }
! protected void deb(String str)
! {
! if (DEBUG)System.err.println("WMSExample-->"+str);
! }
!
! }
! /*
! * Changes in file:
! *
! * $Log$
! * Revision 1.12 2001/11/20 17:01:45 kobit
! * Added byte[] getContentData() support
! *
! * Revision 1.11 2001/11/10 12:14:41 camerons
! * clean up formatting
! *
! * Revision 1.10 2001/11/10 12:05:51 camerons
! * Have got a WMSExample working, gets capabilities, and now gets maps using WMSLayer
! *
! * Revision 1.9 2001/10/28 21:43:41 camerons
! * Changed default tabspace from 2 to 4, only effects formatting
! *
! * Revision 1.8 2001/10/28 21:42:22 camerons
! * Added some more functionality to build a map (using WMSLayer) but it does not have all params yet
! *
! * Revision 1.7 2001/10/24 09:43:32 kobit
! * Some changes to work with OGC in new ogc-design, now again parse capabilities and displays capabilities info
! *
! *
! */
|