Revision 4181

View differences:

org.gvsig.raster.wms/trunk/org.gvsig.raster.wms/pom.xml
11 11
	<parent>
12 12
      <groupId>org.gvsig</groupId>
13 13
      <artifactId>org.gvsig.desktop</artifactId>
14
      <version>2.0.111</version>
14
      <version>2.0.112</version>
15 15
  </parent>
16 16

  
17 17
        <properties>
18 18
            <!-- El plugin versions:use-latest-versions falla con scope import -->
19 19
            <!-- asi que toca usar el versions:update-properties que si que funciona -->
20
            <org.gvsig.raster.version>2.2.21</org.gvsig.raster.version>
20
            <org.gvsig.raster.version>2.2.22</org.gvsig.raster.version>
21 21
        </properties>
22 22
    
23 23
    <repositories>
org.gvsig.raster.wms/trunk/org.gvsig.raster.wms/org.gvsig.raster.wms.app.wmsclient/src/main/java/org/gvsig/raster/wms/app/wmsclient/gui/panel/WMSParamsPanel.java
2 2
*
3 3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4 4
* of the Valencian Government (CIT)
5
* 
5
*
6 6
* This program is free software; you can redistribute it and/or
7 7
* modify it under the terms of the GNU General Public License
8 8
* as published by the Free Software Foundation; either version 2
9 9
* of the License, or (at your option) any later version.
10
* 
10
*
11 11
* This program is distributed in the hope that it will be useful,
12 12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13 13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 14
* GNU General Public License for more details.
15
* 
15
*
16 16
* You should have received a copy of the GNU General Public License
17 17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 19
* MA  02110-1301, USA.
20
* 
20
*
21 21
*/
22
 
22

  
23 23
package org.gvsig.raster.wms.app.wmsclient.gui.panel;
24 24

  
25 25
import java.awt.Component;
......
30 30
import java.awt.event.MouseAdapter;
31 31
import java.awt.event.MouseEvent;
32 32
import java.lang.reflect.InvocationTargetException;
33
import java.net.URI;
34
import java.net.URISyntaxException;
33 35
import java.util.AbstractCollection;
34 36
import java.util.ArrayList;
35 37
import java.util.Hashtable;
......
201 203
		this.setBounds(0, 0, 510, 427);
202 204
		this.add(getJTabbedPane(), null);
203 205
	}
204
	
206

  
205 207
	public boolean isUpdatingCache() {
206 208
		return updating;
207 209
	}
......
372 374

  
373 375
		return jTxtNomCapa;
374 376
	}
375
	
377

  
376 378
	/**
377 379
	 * This method initializes jPanel1
378 380
	 *
......
413 415
		}
414 416
		return jPanelSrsSelection;
415 417
	}
416
	
418

  
417 419
	/**
418 420
	 * This method initializes jPanel6
419 421
	 *
......
472 474
		}
473 475
		return chkTransparency;
474 476
	}
475
	
477

  
476 478
	/**
477 479
	 * This method initializes jScrollPane2
478 480
	 *
......
488 490

  
489 491
		return jScrollPane2;
490 492
	}
491
	
493

  
492 494
	/**
493 495
	 * This method initializes jScrollPane3
494 496
	 *
......
535 537
						public void valueChanged(
536 538
								javax.swing.event.TreeSelectionEvent e) {
537 539

  
538
							boolean isGetMapable = false; 
540
							boolean isGetMapable = false;
539 541
							TreePath[] selecciones = getTreeLayers()
540 542
									.getSelectionPaths();
541 543
							if (selecciones != null) {
......
567 569

  
568 570
		boolean b;
569 571
		this.repaint();
570
		boolean infoFormatOk = ((getLstInfoFormats().getModel().getSize()!= 0 && 
571
								getLstInfoFormats().getSelectedIndex() != -1) || 
572
		boolean infoFormatOk = ((getLstInfoFormats().getModel().getSize()!= 0 &&
573
								getLstInfoFormats().getSelectedIndex() != -1) ||
572 574
								getLstInfoFormats().getModel().getSize() == 0);
573 575
		if ((getLstSRSs().getSelectedIndex() != -1)
574 576
				&& (getLstFormats().getSelectedIndex() != -1)
......
853 855
		}
854 856
		return lstSRSs;
855 857
	}
856
	
858

  
857 859
	/**
858 860
	 * This method initializes lstSRSs
859 861
	 *
......
958 960
	public String getFormat() {
959 961
		return (String) getLstFormats().getSelectedValue();
960 962
	}
961
	
963

  
962 964
	public String getInfoFormat() {
963 965
		return (String) getLstInfoFormats().getSelectedValue();
964 966
	}
......
1087 1089
		}
1088 1090
		return -1;
1089 1091
	}
1090
	
1092

  
1091 1093
	/**
1092 1094
	 * Returns the index of the format within the formats list.
1093 1095
	 *
......
1291 1293
	public void setTransparent(boolean b) {
1292 1294
		getChkTransparency().setSelected(b);
1293 1295
	}
1294
	
1295
	
1296

  
1297

  
1296 1298
	/**
1297 1299
	 * Returns true if the WMS protocol version in use is
1298 1300
	 * >= 1.3.0, and false otherwise.
......
1333 1335
		WMSLayerNode[] layers = selectedLayersToArray();
1334 1336
		Vector<RemoteWMSStyle> v = new Vector<RemoteWMSStyle>(layers.length);
1335 1337
		int posInsertion = 0;
1336
		
1338

  
1337 1339
		for (int i = layers.length - 1; i >= 0; i--) {
1338 1340
			RemoteWMSStyle sty = layers[i].getSelectedStyle();
1339 1341
			if(sty != null)
......
1478 1480
			par.setFixedSize(getFixedSize());
1479 1481
			par.setQueryable(explorer.isQueryable());
1480 1482
			par.setName(node.getTitle());
1481
			par.setURI(explorer.getHost());
1482
			par.deleteCache(updating);			
1483
			try {
1484
                par.setURI(new URI(explorer.getHost()));
1485
            } catch (URISyntaxException e1) {
1486
                throw new LoadLayerException("Can't create URI from "+explorer.getHost(), e1);
1487
            }
1488
			par.deleteCache(updating);
1483 1489
			par.setXyAxisOrder(getXYAxisorder());
1484
			
1490

  
1485 1491
			FLyrWMS layer = new FLyrWMS();
1486 1492
			try {
1487 1493
				layer.setParameters(parameters);
......
1512 1518
			return getLayerPlain(cached);
1513 1519
		}
1514 1520
	}
1515
	
1521

  
1516 1522
	public FLayer getLayer() throws InitializeException {
1517 1523
		return getLayer(lastCached);
1518 1524
	}
......
1522 1528
	 * layer tree in WMS
1523 1529
	 *
1524 1530
	 * @return
1525
	 * @throws LoadLayerException 
1531
	 * @throws LoadLayerException
1526 1532
	 */
1527 1533
	protected FLayer getLayerTree() throws InitializeException {
1528 1534
		LayerTree layerTree = getLayerStructure();
......
1552 1558
		if (node.getChildren().size() > 0) {
1553 1559
			FLayers l = null;
1554 1560
			if (this.getMapCtrl() == null) {
1555
				AbstractViewPanel v = 
1561
				AbstractViewPanel v =
1556 1562
						(AbstractViewPanel) PluginServices.getMDIManager().getActiveWindow();
1557 1563
				l = new FLayers();
1558 1564
				l.setMapContext(v.getMapControl().getMapContext());
......
1573 1579
			return l;
1574 1580
		} else {
1575 1581
			if (nodeSelected(selection, node)) {
1576
				
1582

  
1577 1583
				DataStoreParameters parameters = explorer.getStoredParameters();
1578 1584
				WMSDataParameters par = null;
1579 1585
				if(parameters instanceof WMSDataParameters) {
......
1596 1602
				par.setFixedSize(getFixedSize());
1597 1603
				par.setQueryable(node.isQueryable());
1598 1604
				par.setName(node.getTitle());
1599
				par.setURI(explorer.getHost());
1605
	            try {
1606
	                par.setURI(new URI(explorer.getHost()));
1607
	            } catch (URISyntaxException e1) {
1608
	                throw new InitializeException("Can't create URI from "+explorer.getHost(), e1);
1609
	            }
1600 1610
				par.deleteCache(updating);
1601 1611
				par.setXyAxisOrder(getXYAxisorder());
1602
				
1612

  
1603 1613
				FLyrWMS layer = new FLyrWMS();
1604 1614
				layer.setParameters(parameters);
1605 1615
				layer.setName(node.getName());
......
1630 1640
	protected FLayer getLayerPlain(boolean cached) throws InitializeException {
1631 1641
		WMSDataParameters par = (WMSDataParameters)explorer.getStoredParameters();
1632 1642
		DataStoreParameters parameters = par;
1633
		
1643

  
1634 1644
		if(cached) {
1635 1645
			DataManager manager = DALLocator.getDataManager();
1636 1646
			TileDataParameters tileParams = null;
......
1642 1652
			tileParams.setDataParameters(par);
1643 1653
			parameters = tileParams;
1644 1654
		}
1645
		
1655

  
1646 1656
		par.setFormat(getFormat());
1647 1657
		par.setInfoFormat(getInfoFormat());
1648 1658
		par.setLayerQuery(getLayersQuery());
......
1655 1665
		par.setFixedSize(getFixedSize());
1656 1666
		par.setQueryable(explorer.isQueryable());
1657 1667
		par.setName(getLayerName());
1658
		par.setURI(explorer.getHost());
1659
		par.deleteCache(updating);
1668
        try {
1669
            par.setURI(new URI(explorer.getHost()));
1670
        } catch (URISyntaxException e1) {
1671
            throw new InitializeException("Can't create URI from "+explorer.getHost(), e1);
1672
        }		par.deleteCache(updating);
1660 1673
		par.setXyAxisOrder(getXYAxisorder());
1661
		
1674

  
1662 1675
		FLyrWMS layer = new FLyrWMS();
1663 1676
		layer.setParameters(parameters);
1664 1677
		layer.setExplorer(explorer);
......
1667 1680
	}
1668 1681

  
1669 1682
	/**
1670
	 * Gets the <code>RasterDriverException</code> message. The message 
1683
	 * Gets the <code>RasterDriverException</code> message. The message
1671 1684
	 * of this exception is returned by the server
1672 1685
	 * @param e
1673 1686
	 * @return
......
1684 1697
				t = ex.getCause();
1685 1698
			} else if(ex instanceof InvocationTargetException) {
1686 1699
				t = ((InvocationTargetException)ex).getTargetException();
1687
			} 
1700
			}
1688 1701
			if(t == null)
1689 1702
				return null;
1690 1703
			else
......
1840 1853
	public void close() {
1841 1854
		// Nothing to do
1842 1855
	}
1843
	
1856

  
1844 1857
	public WMSServerExplorer getExplorer() {
1845 1858
		return explorer;
1846 1859
	}
org.gvsig.raster.wms/trunk/org.gvsig.raster.wms/org.gvsig.raster.wms.app.wmsclient/src/main/java/org/gvsig/raster/wms/app/wmsclient/wmc/ImportWebMapContextExtension.java
2 2
*
3 3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4 4
* of the Valencian Government (CIT)
5
* 
5
*
6 6
* This program is free software; you can redistribute it and/or
7 7
* modify it under the terms of the GNU General Public License
8 8
* as published by the Free Software Foundation; either version 2
9 9
* of the License, or (at your option) any later version.
10
* 
10
*
11 11
* This program is distributed in the hope that it will be useful,
12 12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13 13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 14
* GNU General Public License for more details.
15
* 
15
*
16 16
* You should have received a copy of the GNU General Public License
17 17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 19
* MA  02110-1301, USA.
20
* 
20
*
21 21
*/
22
 
22

  
23 23
package org.gvsig.raster.wms.app.wmsclient.wmc;
24 24

  
25 25
import java.awt.Component;
......
160 160
			// the project.
161 161
//			dstView = ProjectFactory.createView(null);
162 162
			dstView = (DefaultViewDocument) ProjectManager.getInstance().createDocument(ViewManager.TYPENAME);
163
			
163

  
164 164
			dstView.setName(wmc.title);
165 165
			dstView.setComment("Created from WebMapContext file: " + wmcFile.getName());
166 166

  
......
181 181
			if (wmc.layerList.get(i) instanceof FLyrWMS) {
182 182
				FLyrWMS layer = wmc.layerList.get(i);
183 183
				WMSDataParameters params = wmc.paramsList.get(i);
184
				
184

  
185 185
				DataManager datamanager = DALLocator.getDataManager();
186
				
186

  
187 187
				/*
188 188
				 * will connect to get the online resources defined by
189 189
				 * server, because WMC only defines the original URL for
......
191 191
				 */
192 192
				try {
193 193
					WMSServerExplorerParameters explorerParams = (WMSServerExplorerParameters) datamanager.createServerExplorerParameters(WMSServerExplorer.NAME);
194
					explorerParams.setHost(params.getURI());
195
					
194
					explorerParams.setHost(params.getURI().getPath());
195

  
196 196
					WMSServerExplorer explorer = (WMSServerExplorer) datamanager.createServerExplorer(explorerParams);
197
					
197

  
198 198
					layer.setExplorer(explorer);
199 199
					params.setOverrideHost(false);
200 200
					explorer.connect(null, true);
201
					
201

  
202 202
					params.setOnlineResources(explorer.getOnlineResources());
203 203
					layer.setParameters(params);
204
					
204

  
205 205
					Rectangle2D rec = wmc.bBox;
206 206
					Envelope envelope = GeometryLocator.getGeometryManager().createEnvelope(rec.getX(),rec.getY(),rec.getMaxX(),rec.getMaxY(), Geometry.SUBTYPES.GEOM2D);
207 207
					dstView.getMapContext().getViewPort().setEnvelope(envelope);
......
211 211
					" ["+new Date(System.currentTimeMillis()).toString()+"]",
212 212
					e);
213 213
				}
214
				
214

  
215 215
				dstView.getMapContext().getLayers().addLayer(layer);
216 216
			}
217 217
		}
org.gvsig.raster.wms/trunk/org.gvsig.raster.wms/org.gvsig.raster.wms.app.wmsclient/src/main/java/org/gvsig/raster/wms/app/wmsclient/wmc/WebMapContext.java
2 2
*
3 3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4 4
* of the Valencian Government (CIT)
5
* 
5
*
6 6
* This program is free software; you can redistribute it and/or
7 7
* modify it under the terms of the GNU General Public License
8 8
* as published by the Free Software Foundation; either version 2
9 9
* of the License, or (at your option) any later version.
10
* 
10
*
11 11
* This program is distributed in the hope that it will be useful,
12 12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13 13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 14
* GNU General Public License for more details.
15
* 
15
*
16 16
* You should have received a copy of the GNU General Public License
17 17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 19
* MA  02110-1301, USA.
20
* 
20
*
21 21
*/
22
 
22

  
23 23
package org.gvsig.raster.wms.app.wmsclient.wmc;
24 24

  
25 25
import java.awt.Dimension;
......
30 30
import java.io.FileNotFoundException;
31 31
import java.io.FileReader;
32 32
import java.io.IOException;
33
import java.net.URI;
34
import java.net.URISyntaxException;
33 35
import java.util.ArrayList;
34 36
import java.util.Arrays;
35 37
import java.util.HashMap;
......
40 42

  
41 43
import org.cresques.cts.ICoordTrans;
42 44
import org.cresques.cts.IProjection;
45

  
43 46
import org.gvsig.app.ApplicationLocator;
44 47
import org.gvsig.app.project.documents.view.DefaultViewDocument;
45 48
import org.gvsig.fmap.crs.CRSFactory;
......
52 55
import org.gvsig.raster.wms.io.RemoteWMSStyle;
53 56
import org.gvsig.raster.wms.io.WMSDataParameters;
54 57
import org.gvsig.raster.wms.io.WMSDataParametersImpl;
58

  
55 59
import org.kxml2.io.KXmlParser;
56 60
import org.slf4j.Logger;
57 61
import org.slf4j.LoggerFactory;
......
74 78
 */
75 79
public class WebMapContext {
76 80
	public final static String FILE_EXTENSION = ".cml";
77
	private Logger  log = LoggerFactory.getLogger(WebMapContext.class); 
81
	private Logger  log = LoggerFactory.getLogger(WebMapContext.class);
78 82
	static final ArrayList<String> supportedVersions = new ArrayList<String>();
79 83
	static public final ArrayList<String> exportVersions    = new ArrayList<String>();
80 84
	static private HashSet supportedLayers = new HashSet();
......
119 123
	List<WMSDataParameters>  paramsList = null;
120 124

  
121 125
	Hashtable<Object, String[]>  srsList = null;
122
	
126

  
123 127
	/**
124 128
	 * key: server URL (URL)
125 129
	 * value: server title (String)
......
235 239
		}
236 240
		return fileVersion;
237 241
	}
238
	
242

  
239 243
	private void readEnconding(File file) {
240 244
		FileReader fr = null;
241 245
		try {
......
524 528
	@SuppressWarnings("unchecked")
525 529
	private void parseLayer1_1_0(KXmlParser parser, FLyrWMS layer, WMSDataParameters dataParameters) throws XmlPullParserException, IOException {
526 530
		boolean end = false;
527
		
531

  
528 532
		String queryable = parser.getAttributeValue("", WebMapContextTags.QUERYABLE);
529 533
		dataParameters.setQueryable(queryable!=null && (queryable.equals("1") || queryable.toLowerCase().equals("true")));
530 534
		List<RemoteWMSStyle> styles = new ArrayList<RemoteWMSStyle>();
531
		
535

  
532 536
		String hidden = parser.getAttributeValue("", WebMapContextTags.HIDDEN);
533 537
		layer.setVisible(hidden == null || !hidden.equals("1") || !hidden.toLowerCase().equals("true"));
534 538
    	int tag = parser.next();
......
539 543
        				String serverTitle = parser.getAttributeValue("", WebMapContextTags.TITLE.toLowerCase());
540 544
        				parser.nextTag();
541 545
        				if (parser.getName().compareTo(WebMapContextTags.ONLINE_RESOURCE) == 0) {
542
        					dataParameters.setURI(parser.getAttributeValue("", WebMapContextTags.XLINK_HREF));
546
        				    URI uri;
547
                            String uriStr = parser.getAttributeValue("", WebMapContextTags.XLINK_HREF);
548
                            try {
549
                                uri = new URI(uriStr);
550
                            } catch (URISyntaxException e) {
551
                                throw new IOException("Can't create URI from "+uriStr, e);
552
                            }
553

  
554
        					dataParameters.setURI(uri);
543 555
        					if (serverTitles == null) {
544 556
								serverTitles = new Hashtable<String, String>();
545 557
							}
546
            				serverTitles.put(parser.getAttributeValue("", WebMapContextTags.XLINK_HREF), serverTitle);
558
            				serverTitles.put(uriStr, serverTitle);
547 559
        				}
548 560
        			} else if (parser.getName().compareTo(WebMapContextTags.TITLE) == 0) {
549 561
        				layer.setName(parser.nextText());
......
713 725
    		}
714 726
    		tag = parser.next();
715 727
    	}
716
    	
728

  
717 729
    	RemoteWMSStyle sty = new RemoteWMSStyle();
718 730
    	sty.setName(styleName);
719 731
    	sty.setTitle(styleTitle);
org.gvsig.raster.wms/trunk/org.gvsig.raster.wms/org.gvsig.raster.wms.app.wmsclient/src/main/java/org/gvsig/raster/wms/app/wmsclient/layer/FLyrWMS.java
2 2
*
3 3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4 4
* of the Valencian Government (CIT)
5
* 
5
*
6 6
* This program is free software; you can redistribute it and/or
7 7
* modify it under the terms of the GNU General Public License
8 8
* as published by the Free Software Foundation; either version 2
9 9
* of the License, or (at your option) any later version.
10
* 
10
*
11 11
* This program is distributed in the hope that it will be useful,
12 12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13 13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 14
* GNU General Public License for more details.
15
* 
15
*
16 16
* You should have received a copy of the GNU General Public License
17 17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 19
* MA  02110-1301, USA.
20
* 
20
*
21 21
*/
22
 
22

  
23 23
package org.gvsig.raster.wms.app.wmsclient.layer;
24 24

  
25 25
import java.awt.Dimension;
......
33 33
import java.awt.geom.Rectangle2D;
34 34
import java.awt.image.BufferedImage;
35 35
import java.lang.ref.WeakReference;
36
import java.net.URI;
37
import java.net.URISyntaxException;
36 38
import java.util.ArrayList;
37 39
import java.util.HashMap;
38 40
import java.util.Iterator;
......
45 47

  
46 48
import org.cresques.cts.ICoordTrans;
47 49
import org.cresques.cts.IProjection;
50

  
48 51
import org.gvsig.andami.PluginServices;
49 52
import org.gvsig.fmap.dal.DALLocator;
50 53
import org.gvsig.fmap.dal.DataManager;
......
104 107
import org.gvsig.tools.task.Cancellable;
105 108
import org.gvsig.tools.task.SimpleTaskStatus;
106 109
import org.gvsig.tools.task.TaskStatusManager;
110

  
107 111
import org.slf4j.Logger;
108 112
import org.slf4j.LoggerFactory;
109 113

  
......
139 143
public class FLyrWMS extends DefaultFLyrRaster {
140 144
	public static final String           PERSISTENT_NAME           = "FLyrWMS_Persistent";
141 145
	public static final String           PERSISTENT_DESCRIPTION    = "FLyrWMS Persistent Definition";
142
	
146

  
143 147
	private static final GeometryManager geomManager               = GeometryLocator.getGeometryManager();
144 148
	private static final Logger          logger                    = LoggerFactory.getLogger(FLyrWMS.class);
145 149
	private boolean 					 mustSplitRequest          = false;
......
163 167
			logger.error("Fallo el estado de open. Closed=" + isClosed() + " Awake=" + isAwake(), this, e);
164 168
		}
165 169
	}
166
	
170

  
167 171
   public FLyrWMS(DataStoreParameters dataStoreParameters) throws Exception {
168 172
        this();
169 173
        //Create the explorer and connect
170 174
        DataManager dataManager = DALLocator.getDataManager();
171
        WMSServerExplorerParameters explorerParams = (WMSServerExplorerParameters) 
175
        WMSServerExplorerParameters explorerParams = (WMSServerExplorerParameters)
172 176
               dataManager.createServerExplorerParameters(WMSServerExplorer.NAME);
173
        explorerParams.setHost((String)dataStoreParameters.getDynValue("uri"));        
174
        WMSServerExplorer wmsServerExplorer = 
177
        explorerParams.setHost((String)dataStoreParameters.getDynValue("uri"));
178
        WMSServerExplorer wmsServerExplorer =
175 179
            (WMSServerExplorer) dataManager.openServerExplorer(WMSServerExplorer.NAME, explorerParams);
176 180
        wmsServerExplorer.connect(null, ((RemoteStoreParameters)dataStoreParameters).isDeletingCache());
177
        
181

  
178 182
        //Set the parameters
179 183
        setParameters((WMSDataParameters)dataStoreParameters);
180 184
        setExplorer(wmsServerExplorer);
181 185
    }
182
	
186

  
183 187
	public static DataStore createDataStore(String host, IProjection srs) throws InitializeException {
184 188
		DataManagerProviderServices dataman = (DataManagerProviderServices) DALLocator.getDataManager();
185 189
		RasterDataParameters params = null;
......
190 194
		} catch (ProviderNotRegisteredException e) {
191 195
			return null;
192 196
		}
193
		params.setURI(host);
197
		try {
198
            params.setURI(new URI(host));
199
        } catch (URISyntaxException e1) {
200
            throw new InitializeException("Can't create URI from "+host, e1);
201
        }
194 202
		params.setSRS(srs);
195
		
203

  
196 204
		try {
197 205
			return dataman.openStore(params.getDataStoreName(), params);
198 206
		} catch (ValidateDataParametersException e) {
......
235 243
		}
236 244
		return (String)formats.get(0);
237 245
	}
238
	
246

  
239 247
	public static void registerPersistent() {
240 248
		PersistenceManager manager = ToolsLocator.getPersistenceManager();
241 249
		DynStruct definition = manager.getDefinition("FLyrWMS_Persistent");
......
248 256
					FLyrWMS.class,
249 257
					"FLyrWMS_Persistent",
250 258
					"FLyrWMS Persistent Definition",
251
					null, 
259
					null,
252 260
					null
253 261
			);
254
			
262

  
255 263
			definition.extend(PersistenceManager.PERSISTENCE_NAMESPACE, DefaultFLyrRaster.PERSISTENT_NAME);
256 264
		}
257 265

  
258 266
		DefaultFLyrRaster.registerPersistence(definition);
259 267
	}
260
	
268

  
261 269
	public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort,
262 270
			Cancellable cancel, double scale) throws ReadException {
263 271
		TaskStatusManager manager = ToolsLocator.getTaskStatusManager();
......
265 273
		manager.add(taskStatus);
266 274
		taskStatus.setAutoremove(true);
267 275
		splitRequestCalculation(viewPort.getImageWidth(), viewPort.getImageHeight());
268
		
276

  
269 277
		if(!firstLoad) {
270 278
			try {
271 279
				initFilters();
......
280 288
			}
281 289
			firstLoad = true;
282 290
		}
283
		
291

  
284 292
		enableStopped();
285
		
293

  
286 294
		if(recalcLevel) {
287 295
			double pixelSize = viewPort.getEnvelope().getLength(0) / (double)viewPort.getImageWidth();
288 296
			zoomLevel = dataStore.getNearestLevel(pixelSize);
......
319 327
		}
320 328
		disableStopped();
321 329
	}
322
	
323
		
330

  
331

  
324 332
	/**
325 333
	 * This is the method used to draw a tile in a WMS mosaic layer.
326 334
	 * @throws LoadLayerException
......
339 347
			Rectangle2D vpRect = getRectable2DFromEnvelope(vpEnv);
340 348
			Rectangle2D layerRect = getRectable2DFromEnvelope(layerEnv);
341 349
			// 2. Intersect layer and viewport extents to get the area of interest
342
			Rectangle2D requestedRect = new Rectangle2D.Double(); 
350
			Rectangle2D requestedRect = new Rectangle2D.Double();
343 351
			Rectangle2D.intersect(layerRect, vpRect, requestedRect);
344 352

  
345 353
			// 3. Compute image size in pixels from the requested Extent
......
350 358
			if ((wImg <= 0) || (hImg <= 0)) {
351 359
				return;
352 360
			}
353
			
361

  
354 362
			// 4. compute exactly the requested extent (from the rounded image size)
355 363
			// ensuring we are still within the layer extent
356 364
			double worldWidth = Math.abs((double)wImg/scalex);
......
370 378
			else {
371 379
				worldY = requestedRect.getMinY();
372 380
			}
373
			
374
			requestedRect.setRect(worldX, worldY, worldWidth, worldHeigh); 
381

  
382
			requestedRect.setRect(worldX, worldY, worldWidth, worldHeigh);
375 383
			Envelope requestedEnvelope = geomManager.createEnvelope(requestedRect.getMinX(),
376 384
					requestedRect.getMinY(),
377 385
					requestedRect.getMaxX(),
378 386
					requestedRect.getMaxY(),
379 387
					SUBTYPES.GEOM2D);
380 388
			Extent requestedExtent = rManager.getDataStructFactory().createExtent(
381
					requestedEnvelope.getMinimum(0), 
382
					requestedEnvelope.getMaximum(1), 
383
					requestedEnvelope.getMaximum(0), 
389
					requestedEnvelope.getMinimum(0),
390
					requestedEnvelope.getMaximum(1),
391
					requestedEnvelope.getMaximum(0),
384 392
					requestedEnvelope.getMinimum(1));
385 393

  
386 394
			// 5. compute the new AffineTransform (ViewPort class can do it for us
......
390 398
			auxVp.setImageSize(sz);
391 399
			auxVp.setEnvelope(requestedEnvelope);
392 400

  
393
			
401

  
394 402
			// 6. compute tile offeset. It is the sum of the original viewport offset
395 403
			// plus the offset introduced by intersecting layer and viewport extents
396 404
			double offsetX = vp.getOffset().getX();
......
440 448
		} catch (CreateEnvelopeException e) {
441 449
			drawingError(e);
442 450
		} finally {
443
			taskStatus.terminate();				
451
			taskStatus.terminate();
444 452
		}
445 453
	}
446
	
454

  
447 455
	private void drawingError(Exception e) {
448 456
		setAvailable(false);
449 457
		JOptionPane.showMessageDialog(null, "Problems drawing this layer:" + e.getMessage(), Messages.getText("Error"), JOptionPane.ERROR_MESSAGE);
450 458
		logger.info("Problems drawing this layer:" + e.getMessage(), e);
451
	}	
459
	}
452 460

  
453 461
	/**
454 462
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#print(java.awt.Graphics2D,
......
526 534
	@SuppressWarnings({ "unchecked", "rawtypes" })
527 535
	public String toMapContext(String mapContextVersion) {
528 536
		XmlBuilder xml = new XmlBuilder();
529
		
537

  
530 538
		String query = getParameters().getLayerQuery();
531 539
		String[] layerNames = query.split(",");
532 540
		List<RemoteWMSStyle> styleList = getParameters().getStyles();
......
672 680
	public boolean isTiled() {
673 681
		return mustSplitRequest;
674 682
	}
675
	
683

  
676 684
	private void splitRequestCalculation(int width, int height) {
677 685
            RasterDataStore store = this.getDataStore();
678 686
            if( store == null ) {
......
720 728
		if (!getParameters().getURI().equals(aLayer.getParameters().getURI())) {
721 729
			return false;
722 730
		}
723
		
724
		WMSDataParameters p = getWMSParameters(getDataStore().getParameters()); 
725
				
731

  
732
		WMSDataParameters p = getWMSParameters(getDataStore().getParameters());
733

  
726 734
		if (!p.getFormat().equals(aLayer.getParameters().getFormat())) {
727 735
			return false;
728 736
		}
......
799 807
		}
800 808
		return null;
801 809
	}
802
	
810

  
803 811
	public boolean isRemote() {
804 812
		return true;
805 813
	}
......
872 880
		}
873 881
		return null;
874 882
	}*/
875
	
883

  
876 884
	@Override
877 885
	public String getFileFormat() {
878 886
		return "WMS";
879 887
	}
880
	
888

  
881 889
	@Override
882 890
	public FLayer getFileLayer() throws RasterDriverException {
883 891
		/*if(getDataStore() instanceof DefaultRemoteRasterStore) {
884 892
			RemoteRasterProvider prov = (RemoteRasterProvider)((DefaultRemoteRasterStore)getDataStore()).getProvider(0);
885 893
			File file = null;
886
			
894

  
887 895
			if(getParameters().isSizeFixed()) {
888 896
				file = prov.getFileLayer();
889 897
			} else {
890 898
				file = prov.getLastRequest();
891 899
			}
892
				
900

  
893 901
			if(file == null)
894 902
				return null;
895
			
903

  
896 904
			try {
897 905
				return DefaultFLyrRaster.createLayer("tmp", file);
898 906
			} catch (LoadLayerException e) {
......
944 952
		return rAux;
945 953

  
946 954
	}
947
	
955

  
948 956
	public Extent getFullRasterExtent() {
949 957
		return getExtentFromEnvelope(getFullEnvelope());
950 958
	}
951
	
959

  
952 960
	public DynObjectSet getInfo(org.gvsig.fmap.geom.primitive.Point p, double tolerance) throws LoadLayerException, DataException {
953 961
		Point p1 = new Point((int)p.getX(), (int)p.getY());
954 962
		return getInfo(p1, tolerance, null, false);
......
969 977
			getParameters().setWidth(viewPort.getImageWidth());
970 978
			getParameters().setHeight(viewPort.getImageHeight());
971 979
		}
972
		
980

  
973 981
		CancelTaskImpl cancellable = new CancelTaskImpl(cancel);
974 982
		getParameters().setCancellable(cancellable);
975
		
983

  
976 984
		String fInfo;
977 985
		try {
978 986
			//Point2D pt = new Point2D.Double();
......
981 989
			/*} catch (NoninvertibleTransformException e) {
982 990
				return null;
983 991
			}*/
984
			
992

  
985 993
			Extent bbox = getExtentFromEnvelope(viewPort.getAdjustedEnvelope());
986
			fInfo = getDataStore().getInfoByPoint(p.getX(), 
987
					p.getY(), 
988
					bbox, 
989
					viewPort.getImageWidth(), 
990
					viewPort.getImageHeight(), 
994
			fInfo = getDataStore().getInfoByPoint(p.getX(),
995
					p.getY(),
996
					bbox,
997
					viewPort.getImageWidth(),
998
					viewPort.getImageHeight(),
991 999
					cancellable);
992 1000
		} catch (InfoByPointException e) {
993 1001
			throw new LoadLayerException("Error in getInfoByPoint", e);
994 1002
		}
995 1003
		return new DynObjectSetWMSInfo(fInfo, getParameters().getInfoFormat());
996 1004
	}
997
	
1005

  
998 1006
	private Extent getExtentFromEnvelope(Envelope env) {
999 1007
		double minx = env.getMinimum(0);
1000 1008
		double miny = env.getMinimum(1);
......
1006 1014
		Point2D lr = new Point2D.Double(maxx, miny);
1007 1015
		return rManager.getDataStructFactory().createExtent(ul, lr, ur, ll);
1008 1016
	}
1009
    
1017

  
1010 1018
    /**
1011 1019
     * Sets the data store parameters
1012 1020
     * @param params
......
1016 1024
    	if(params instanceof TileDataParameters) {
1017 1025
			((TileDataParameters)params).deleteCache(deleteCache);
1018 1026
		}
1019
    	
1027

  
1020 1028
    	DataManagerProviderServices dataman = (DataManagerProviderServices) DALLocator.getDataManager();
1021 1029
		try {
1022 1030
			DataStore dStore = dataman.openStore(params.getDataStoreName(), params);
1023 1031
			this.setDataStore(dStore);
1024
			
1032

  
1025 1033
			if(params instanceof WMSDataParameters) {
1026
				this.setName(((WMSDataParameters)params).getURI());
1034
				this.setName(((WMSDataParameters)params).getURI().getPath());
1027 1035
			}
1028
			
1036

  
1029 1037
			if(params instanceof TileDataParameters) {
1030 1038
				DataParameters p = ((TileDataParameters) params).getDataParameters();
1031 1039
				if(p instanceof WMSDataParameters) {
1032
					this.setName(((WMSDataParameters) p).getURI());
1040
					this.setName(((WMSDataParameters) p).getURI().getPath());
1033 1041
				}
1034 1042
			}
1035 1043
		} catch (ValidateDataParametersException e) {
......
1040 1048
			throw new InitializeException(e);
1041 1049
		}
1042 1050
    }
1043
    
1051

  
1044 1052
	public WMSDataParameters getParameters() {
1045 1053
		return getWMSParameters(getDataStore().getParameters());
1046 1054
    }
1047
    
1055

  
1048 1056
    /**
1049 1057
     * Gets <code>WMSDataParameters</code>
1050 1058
     * @param parameters
......
1055 1063
    	if(parameters instanceof WMSDataParameters) {
1056 1064
			params = (WMSDataParameters) parameters;
1057 1065
		}
1058
		
1066

  
1059 1067
		if(parameters instanceof TileDataParameters) {
1060 1068
			DataParameters p = ((TileDataParameters) parameters).getDataParameters();
1061 1069
			if(p instanceof WMSDataParameters) {
......
1064 1072
		}
1065 1073
		return params;
1066 1074
    }
1067
    
1075

  
1068 1076
    /**
1069 1077
	 * Assigns the flag to delete this layer from the cache
1070 1078
	 * @param selected
......
1072 1080
	public void deleteCache(boolean deleteCache) {
1073 1081
		this.deleteCache = deleteCache;
1074 1082
	}
1075
    
1083

  
1076 1084
    /**
1077 1085
     * Sets the explorer
1078 1086
     * @param explorer
......
1081 1089
    	if(getDataStore() != null)
1082 1090
    		getDataStore().setExplorer(explorer);
1083 1091
    }
1084
    
1092

  
1085 1093
    /**
1086 1094
     * Gets the explorer
1087 1095
     * @return
......
1096 1104
		}
1097 1105
    	return null;
1098 1106
    }
1099
    
1107

  
1100 1108
	public FLayer cloneLayer() throws Exception {
1101 1109
		RasterDataStore  ds = dataStore.cloneDataStore();
1102 1110
		FLyrWMS newLayer = new FLyrWMS();
......
1104 1112
		newLayer.setOpenRasterStore(ds);
1105 1113
		//newLayer.firstLoad = firstLoad;
1106 1114
		newLayer.setExplorer(getExplorer());
1107
		
1115

  
1108 1116
		List<RasterFilter> filters = getRender().getFilterList().getStatusCloned();
1109 1117

  
1110 1118
		//Hacemos una copia de las bandas a renderizar
......
1124 1132
		if(dataStore.getNoDataValue().isDefined())
1125 1133
			newLayer.setNoDataTransparent(true);
1126 1134
		newLayer.enableOpen();
1127
		
1135

  
1128 1136
		return newLayer;
1129 1137
	}
1130
	
1138

  
1131 1139
	@Override
1132 1140
	public boolean isInside(Point2D p) {
1133 1141
		// Don't call the data store isInside method, as the data store
org.gvsig.raster.wms/trunk/org.gvsig.raster.wms/org.gvsig.raster.wms.io/src/main/java/org/gvsig/raster/wms/io/WMSServerExplorer.java
31 31
import java.io.IOException;
32 32
import java.io.InputStream;
33 33
import java.net.MalformedURLException;
34
import java.net.URI;
35
import java.net.URISyntaxException;
34 36
import java.net.URL;
35 37
import java.net.URLConnection;
36 38
import java.util.ArrayList;
......
53 55
import org.gvsig.fmap.dal.spi.DataServerExplorerProvider;
54 56
import org.gvsig.fmap.dal.spi.DataServerExplorerProviderServices;
55 57
import org.gvsig.i18n.Messages;
58

  
56 59
import org.slf4j.Logger;
57 60
import org.slf4j.LoggerFactory;
58 61

  
......
65 68
	private WMSConnector                connector                = null;
66 69
	private WMSServerExplorerParameters parameters               = null;
67 70
	private Logger                      log                      = LoggerFactory.getLogger(WMSServerExplorer.class);
68
	
71

  
69 72
	public WMSServerExplorer(
70 73
			WMSServerExplorerParameters parameters,
71 74
			DataServerExplorerProviderServices services)
72 75
			throws InitializeException {
73 76
		this.parameters = parameters;
74 77
	}
75
	
78

  
76 79
	/**
77 80
	 * Gets the provider's name
78 81
	 * @return
......
80 83
	public String getDataStoreProviderName() {
81 84
		return WMSProvider.NAME;
82 85
	}
83
	
86

  
84 87
	public String getDescription() {
85 88
		return WMSProvider.DESCRIPTION;
86 89
	}
87
	
90

  
88 91
	public boolean add(String provider, NewDataStoreParameters parameters,
89 92
			boolean overwrite) throws DataException {
90 93
		return false;
......
120 123
	}
121 124

  
122 125
	public void remove(DataStoreParameters parameters) throws DataException {
123
		
126

  
124 127
	}
125 128

  
126 129
	public void dispose() {
127
		
130

  
128 131
	}
129 132

  
130 133
	public String getProviderName() {
131 134
		return null;
132 135
	}
133
	
136

  
134 137
	//**********************************************
135 138
	//Connector
136 139
	//**********************************************
137
	
140

  
138 141
	public DataStoreParameters getStoredParameters() {
139 142
		DataManager manager = DALLocator.getDataManager();
140 143
		WMSDataParameters params = null;
141 144
		try {
142 145
			params = (WMSDataParameters) manager.createStoreParameters(this.getDataStoreProviderName());
143
			params.setURI(parameters.getHost());
144
			
146
			params.setURI(new URI(parameters.getHost()));
147

  
145 148
			/*if(WMSProvider.TILED) {
146 149
				TileDataParameters tileParams = (TileDataParameters) manager.createStoreParameters("Tile Store");
147 150
				tileParams.setDataParameters(params);
......
151 154
			log.debug("Error initializating parameters", e);
152 155
		} catch (ProviderNotRegisteredException e) {
153 156
			log.debug("Error getting parameters", e);
154
		}
155
		
157
		} catch (URISyntaxException e) {
158
            log.debug("Can't create URI from "+parameters.getHost(), e);
159
        }
160

  
156 161
		return params;
157 162
	}
158 163

  
......
161 166
	}
162 167

  
163 168
	/**
164
	 * Connects to the server and throws a getCapabilities. This loads 
169
	 * Connects to the server and throws a getCapabilities. This loads
165 170
	 * the basic information to make requests.
166
	 * @throws RemoteServiceException 
171
	 * @throws RemoteServiceException
167 172
	 */
168 173
	public void connect(ICancellable cancellable, boolean updateCache) throws ConnectException {
169 174
		URL url = null;
170
		
175

  
171 176
		try {
172 177
			url = new URL(parameters.getHost());
173 178
		} catch (Exception e) {
......
180 185
        } catch (IOException e) {
181 186
			throw new ConnectException(Messages.getText("error_connecting"), e);
182 187
		}
183
		
188

  
184 189
	}
185
	
190

  
186 191
	/**
187 192
	 * Checks if the network and host are reachable
188 193
	 * @param timeout for the host
......
204 209
		} catch (IOException e) {
205 210
			return false;
206 211
		}
207
		
212

  
208 213
		return true;
209 214
	}
210 215

  
......
253 258
		}
254 259
		return null;
255 260
	}
256
	
261

  
257 262
	/**
258 263
	 * Gets the list of raster information formats supported by the server
259 264
	 * @return
......
287 292
	 * @return
288 293
	 */
289 294
	public String getServerType() {
290
		if (getVersion() == null) 
295
		if (getVersion() == null)
291 296
			return "WMS";
292 297
        return "WMS "+ getVersion();
293 298
	}
294
	
299

  
295 300
	/**
296 301
	 * Gets the online resources
297 302
	 * @return
......
313 318
		}
314 319
		return null;
315 320
	}
316
	
321

  
317 322
    public Rectangle2D getLayersExtent(String[] layerName, String srs) {
318 323
    	return connector.getLayersExtent(layerName, srs);
319 324
    }
320
    
325

  
321 326
    /**
322 327
	 * Gets a layer using its name
323 328
	 * @param layerName
......
334 339
	public String getHost() {
335 340
		return parameters.getHost();
336 341
	}
337
	
342

  
338 343
	public Rectangle2D getBoundingBox(String[] layerNames, String srs) {
339 344
		return connector.getLayersExtent(layerNames, srs);
340 345
    }
341
	
346

  
342 347
	public boolean isQueryable() {
343 348
    	return connector.isQueryable();
344 349
    }
345
	
350

  
346 351
	/**
347 352
	 * Gets the title
348 353
	 * @return
......
350 355
	public String getTitle() {
351 356
		return null;
352 357
	}
353
	
358

  
354 359
    /**
355 360
     * @return The title of the service offered by the WMS server.
356 361
     */
org.gvsig.raster.wms/trunk/org.gvsig.raster.wms/org.gvsig.raster.wms.io/src/main/java/org/gvsig/raster/wms/io/downloader/WMSTileServer.java
37 37
import org.slf4j.Logger;
38 38
import org.slf4j.LoggerFactory;
39 39

  
40
/** 
41
* Data server for the tile cache in a WMSProvider 
40
/**
41
* Data server for the tile cache in a WMSProvider
42 42
* @author Nacho Brodin (nachobrodin@gmail.com)
43 43
*/
44 44
public class WMSTileServer implements TileServer {
......
47 47
	private Downloader                 downloader           = null;
48 48
	private RasterDataStore            store                = null;
49 49
	private String                     suffix               = ".tif";
50
	
50

  
51 51
	public WMSTileServer(RasterDataStore store) {
52 52
		this.store = store;
53 53
		this.suffix = ((RasterProvider)store.getProvider()).getFileSuffix();
54 54
	}
55
	
55

  
56 56
	public Downloader getDownloader() {
57 57
		if(downloader == null ||
58 58
		   ((TileDownloaderForWMS)downloader).getTileSize()[0] != TileCacheLibrary.ALTERNATIVE_TILESIZE ||
59 59
		   ((TileDownloaderForWMS)downloader).getTileSize()[1] != TileCacheLibrary.ALTERNATIVE_TILESIZE) {
60 60
			try {
61 61
				downloader = new TileDownloaderForWMS(
62
						store, 
63
						TileCacheLibrary.ALTERNATIVE_TILESIZE, 
62
						store,
63
						TileCacheLibrary.ALTERNATIVE_TILESIZE,
64 64
						TileCacheLibrary.ALTERNATIVE_TILESIZE);
65 65
			} catch (RemoteServiceException e) {
66 66
				return null;
......
72 72
	public CacheStruct getStruct() {
73 73
		if(struct == null) {
74 74
			TileCacheManager  manager = TileCacheLocator.getManager();
75
			
75

  
76 76
			int coordinates = CacheStruct.FLAT;
77 77
			if(store.getProjection() != null)
78 78
				coordinates = (store.getProjection() != null && store.getProjection().isProjected()) ? CacheStruct.FLAT : CacheStruct.GEOGRAFIC;
79 79
			else {
80 80
				Extent e = store.getExtent();
81
				if(e.getULX() >= -180 && e.getULX() <= 180 && e.getLRX() >= -180 && e.getLRX() <= 180 && 
81
				if(e.getULX() >= -180 && e.getULX() <= 180 && e.getLRX() >= -180 && e.getLRX() <= 180 &&
82 82
					e.getULY() >= -90 && e.getULY() <= 90 && e.getLRY() >= -90 && e.getLRY() <= 90) {
83 83
					coordinates = CacheStruct.GEOGRAFIC;
84 84
				}
85 85
			}
86
			
86

  
87 87
			String epsg = null;
88 88
			IProjection proj = store.getProjection();
89 89
			if(proj != null)
90 90
				epsg = proj.getAbrev();
91
			
92
			struct = manager.createCacheStructure(coordinates, 
93
					TileCacheLibrary.DEFAULT_LEVELS, 
94
					store.getExtent().toRectangle2D(), 
95
					Double.POSITIVE_INFINITY,//provider.getCellSize(), 
96
					TileCacheLibrary.ALTERNATIVE_TILESIZE, 
91

  
92
			struct = manager.createCacheStructure(coordinates,
93
					TileCacheLibrary.DEFAULT_LEVELS,
94
					store.getExtent().toRectangle2D(),
95
					Double.POSITIVE_INFINITY,//provider.getCellSize(),
97 96
					TileCacheLibrary.ALTERNATIVE_TILESIZE,
98
					((RasterProvider)store.getProvider()).getURIOfFirstProvider(),
97
					TileCacheLibrary.ALTERNATIVE_TILESIZE,
98
					((RasterProvider)store.getProvider()).getURIOfFirstProvider().getPath(),
99 99
					((WMSProvider)store.getProvider()).getParameters().getLayerQuery(),
100 100
					TileCacheLibrary.DEFAULT_STRUCTURE,
101 101
					RasterLibrary.pathTileCache,
......
105 105
		}
106 106
		return struct;
107 107
	}
108
	
108

  
109 109
	public void setStruct(CacheStruct struct) {
110 110
		if(struct != null) {
111 111
			this.struct = struct;
112 112
			if(struct.getTileSizeByLevel(0) != null) {
113 113
				try {
114
					downloader = new TileDownloaderForWMS(store, 
115
							struct.getTileSizeByLevel(0)[0], 
114
					downloader = new TileDownloaderForWMS(store,
115
							struct.getTileSizeByLevel(0)[0],
116 116
							struct.getTileSizeByLevel(0)[1]);
117 117
				} catch (RemoteServiceException ex) {
118 118
					logger.error("Constructing TileDownloaderForWCS: " + ex.getMessage());
......
120 120
			}
121 121
		}
122 122
	}
123
	
123

  
124 124
	public String getFileSuffix() {
125 125
		return suffix;
126 126
	}
127
	
127

  
128 128
	public void setFileSuffix(String extension) {
129 129
		this.suffix = extension;
130 130
	}
org.gvsig.raster.wms/trunk/org.gvsig.raster.wms/org.gvsig.raster.wms.io/src/main/java/org/gvsig/raster/wms/io/WMSProvider.java
28 28
import java.awt.geom.Rectangle2D;
29 29
import java.io.File;
30 30
import java.io.IOException;
31
import java.net.URI;
32
import java.net.URISyntaxException;
31 33
import java.net.URL;
32 34
import java.util.Hashtable;
33 35
import java.util.List;
......
35 37

  
36 38
import javax.swing.ImageIcon;
37 39

  
40
import org.apache.commons.io.FilenameUtils;
38 41
import org.cresques.cts.ICoordTrans;
39 42
import org.cresques.cts.IProjection;
43

  
40 44
import org.gvsig.compat.net.ICancellable;
41 45
import org.gvsig.fmap.crs.CRSFactory;
42 46
import org.gvsig.fmap.dal.DALLocator;
......
51 55
import org.gvsig.fmap.dal.coverage.exception.FileNotOpenException;
52 56
import org.gvsig.fmap.dal.coverage.exception.InfoByPointException;
53 57
import org.gvsig.fmap.dal.coverage.exception.InvalidSetViewException;
58
import org.gvsig.fmap.dal.coverage.exception.InvalidSourceException;
54 59
import org.gvsig.fmap.dal.coverage.exception.NotSupportedExtensionException;
55 60
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException;
56 61
import org.gvsig.fmap.dal.coverage.exception.QueryException;
......
61 66
import org.gvsig.fmap.dal.coverage.store.props.HistogramComputer;
62 67
import org.gvsig.fmap.dal.coverage.store.props.Transparency;
63 68
import org.gvsig.fmap.dal.exception.InitializeException;
69
import org.gvsig.fmap.dal.exception.OpenException;
64 70
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException;
65 71
import org.gvsig.fmap.dal.spi.DataManagerProviderServices;
66 72
import org.gvsig.fmap.dal.spi.DataStoreProviderServices;
......
83 89
import org.gvsig.remoteclient.utils.Utilities;
84 90
import org.gvsig.remoteclient.wms.WMSStatus;
85 91
import org.gvsig.tools.ToolsLocator;
92

  
86 93
import org.slf4j.Logger;
87 94
import org.slf4j.LoggerFactory;
88 95
/**
......
97 104
	private static final Logger         logger                    = LoggerFactory.getLogger(WMSProvider.class);
98 105
	private static final int            FIXED_SIZE               = 800;
99 106
	private Extent                      viewRequest              = null;
100
	private static Hashtable<String, WMSConnector>    
107
	private static Hashtable<String, WMSConnector>
101 108
	                                    drivers                  = new Hashtable<String, WMSConnector> ();
102 109
	private boolean                     open                     = false;
103 110
	private DataStoreTransparency       fileTransparency         = null;
......
110 117
	private File                        fileLayerPixelSize       = null;
111 118
	private File                        lastRequest              = null;
112 119
	private AbstractRasterProvider       lastRequestProvider      = null;
113
	
120

  
114 121
	public static void register() {
115 122
		DataManagerProviderServices dataman = (DataManagerProviderServices) DALLocator.getDataManager();
116 123
		if (dataman != null && !dataman.getStoreProviders().contains(NAME)) {
......
123 130
		}
124 131
		dataman.registerStoreFactory(NAME, DefaultStoreFactory.class);
125 132
	}
126
	
133

  
127 134
	public WMSProvider() throws NotSupportedExtensionException {
128 135
		super();
129 136
	}
130
	
137

  
131 138
	public void registerTileProviderFormats(Class<RasterProvider> c) {
132 139

  
133 140
	}
134
	
141

  
135 142
	/**
136 143
	 * Constructor. Abre el dataset.
137 144
	 * @param proj Proyecci?n
138 145
	 * @param fName Nombre del fichero
146
	 * @throws OpenException
139 147
	 * @throws NotSupportedExtensionException
148
     * @deprecated use {@link #WMSProvider(URI)}, this constructor will be removed in gvSIG 2.5
140 149
	 */
141
	public WMSProvider(String params) throws InitializeException {
142
		super(params);
143
		if(params instanceof String) {
144
			WMSDataParameters p = new WMSDataParametersImpl();
145
			p.setURI((String)params);
146
			super.init(p, null, ToolsLocator.getDynObjectManager()
147
					.createDynObject(
148
							MetadataLocator.getMetadataManager().getDefinition(
149
									DataStore.METADATA_DEFINITION_NAME)));
150
			init(p, null);
151
		}
152
	}
153
	
150
    public WMSProvider(String params) throws InitializeException, OpenException {
151
        super(params);
152
        logger.info("Deprecated use of WMSProvider constructor");
153
        if (params instanceof String) {
154
            WMSDataParameters p = new WMSDataParametersImpl();
155
            try {
156
                p.setURI(new URI((String) params));
157
            } catch (URISyntaxException e) {
158
                throw new OpenException("Can't create URI from" + (String) params, e);
159
            }
160
            super.init(
161
                p,
162
                null,
163
                ToolsLocator.getDynObjectManager().createDynObject(
164
                    MetadataLocator.getMetadataManager().getDefinition(DataStore.METADATA_DEFINITION_NAME)));
165
            init(p, null);
166
        }
167
    }
168

  
169
    /**
170
     * Constructor. Abre el dataset.
171
     * @param fName Nombre del fichero
172
     * @throws OpenException
173
     * @throws NotSupportedExtensionException
174
     * @deprecated use {@link #WMSProvider(URI)}, this constructor will be removed in gvSIG 2.5
175
     */
176
    public WMSProvider(URI uri) throws InitializeException {
177
        super(uri);
178
        logger.info("Deprecated use of ErmapperProvider constructor");
179
        WMSDataParameters p = new WMSDataParametersImpl();
180
        p.setURI(uri);
181
        super.init(
182
            p,
183
            null,
184
            ToolsLocator.getDynObjectManager().createDynObject(
185
                MetadataLocator.getMetadataManager().getDefinition(DataStore.METADATA_DEFINITION_NAME)));
186
        init(p, null);
187
    }
188

  
154 189
	public WMSProvider(WMSDataParameters params,
155 190
			DataStoreProviderServices storeServices) throws InitializeException {
156 191
		super(params, storeServices, ToolsLocator.getDynObjectManager()
......
159 194
								DataStore.METADATA_DEFINITION_NAME)));
160 195
		init(params, storeServices);
161 196
	}
162
	
197

  
163 198
	/**
164 199
	 * Gets the connector from the URL
165 200
	 * @return
......
169 204
		WMSDataParameters p = (WMSDataParameters)parameters;
170 205
		URL url = null;
171 206
		try {
172
			url = new URL(p.getURI());
207
			url =p.getURI().toURL();
173 208
		} catch (Exception e) {
174 209
			throw new RemoteServiceException("Malformed URL",e);
175 210
		}
......
179 214
			throw new RemoteServiceException("Error getting the connector",e);
180 215
		}
181 216
	}
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff