Revision 4181 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
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); |
Also available in: Unified diff