Revision 5292
branches/MULTITHREADING_DEVELOPMENT/libraries/libRemoteServices/src/org/gvsig/remoteClient/wms/WMSProtocolHandler.java | ||
---|---|---|
105 | 105 |
if (type == RetrieveEvent.REQUEST_FINISHED) { |
106 | 106 |
|
107 | 107 |
// TODO revisar no estic segur de que a?? haja d'estar ac? |
108 |
System.out.println(event.getFileName()); |
|
108 | 109 |
|
109 | 110 |
File f = new File(event.getFileName()); |
110 | 111 |
if (Utilities.isTextFile(f)) { |
111 |
FileInputStream fis;
|
|
112 |
FileInputStream fis;
|
|
112 | 113 |
try { |
113 | 114 |
fis = new FileInputStream(f); |
114 |
FileChannel fc = fis.getChannel(); |
|
115 |
byte[] data = new byte[(int)fc.size()]; // fc.size returns the size of the file which backs the channel |
|
116 |
ByteBuffer bb = ByteBuffer.wrap(data); |
|
117 |
fc.read(bb); |
|
118 |
|
|
119 |
WMSException wmsEx = null; |
|
120 |
|
|
121 |
String exceptionMessage = parseException(data); |
|
122 |
if (exceptionMessage==null) |
|
123 |
{ |
|
124 |
String error = new String(data); |
|
125 |
int pos = error.indexOf("<?xml"); |
|
126 |
if (pos!= -1) |
|
127 |
{ |
|
128 |
String xml = error.substring(pos,error.length()); |
|
129 |
exceptionMessage = parseException(xml.getBytes()); |
|
130 |
} |
|
131 |
if (exceptionMessage == null) |
|
132 |
exceptionMessage = new String(data); |
|
133 |
|
|
134 |
} |
|
135 |
wmsEx = new WMSException(exceptionMessage); |
|
136 |
wmsEx.setWMSMessage(new String(data)); |
|
137 |
|
|
138 |
// Since it is an error file, It must be deleted from the cache |
|
139 |
RequestManager.getInstance().removeURLRequest(mapRequest); |
|
140 |
} catch (FileNotFoundException e) { |
|
141 |
// TODO Auto-generated catch block |
|
115 |
FileChannel fc = fis.getChannel(); |
|
116 |
byte[] data = new byte[(int)fc.size()]; // fc.size returns the size of the file which backs the channel |
|
117 |
ByteBuffer bb = ByteBuffer.wrap(data); |
|
118 |
fc.read(bb); |
|
119 |
String exceptionMessage = parseException(data); |
|
120 |
if (exceptionMessage==null) |
|
121 |
{ |
|
122 |
String error = new String(data); |
|
123 |
int pos = error.indexOf("<?xml"); |
|
124 |
if (pos!= -1) |
|
125 |
{ |
|
126 |
String xml = error.substring(pos,error.length()); |
|
127 |
exceptionMessage = parseException(xml.getBytes()); |
|
128 |
} |
|
129 |
if (exceptionMessage == null) |
|
130 |
exceptionMessage = new String(data); |
|
131 |
|
|
132 |
} |
|
133 |
event.setType(RetrieveEvent.ERROR); |
|
134 |
event.setMessage(exceptionMessage); |
|
135 |
|
|
136 |
// Since it is an error file, It must be deleted from the cache |
|
137 |
RequestManager.getInstance().removeURLRequest(mapRequest); |
|
138 |
} catch (Exception e) { |
|
142 | 139 |
e.printStackTrace(); |
143 |
} catch (IOException e) { |
|
144 |
// TODO Auto-generated catch block |
|
145 |
e.printStackTrace(); |
|
146 |
} |
|
147 |
|
|
140 |
} |
|
141 |
|
|
142 |
|
|
148 | 143 |
} |
144 |
if (theListener!=null) { |
|
145 |
System.err.println("comunique al driver que la capa ja ha arribat"); |
|
146 |
theListener.newEvent(WMSEventListener.MAP, event); |
|
147 |
} |
|
149 | 148 |
} |
150 | 149 |
} |
151 | 150 |
|
branches/MULTITHREADING_DEVELOPMENT/libraries/libRemoteServices/src/org/gvsig/remoteClient/taskplanning/retrieving/RequestManager.java | ||
---|---|---|
61 | 61 |
if (debug) |
62 | 62 |
System.err.println("done job found ("+request.getFileName()+")"); |
63 | 63 |
RetrieveEvent event = new RetrieveEvent(); |
64 |
event.setFileName(request.getFileName()); |
|
64 | 65 |
event.setType(RetrieveEvent.REQUEST_FINISHED); |
65 | 66 |
listener.transferEventReceived(event); |
66 | 67 |
} else { |
branches/MULTITHREADING_DEVELOPMENT/libraries/libRemoteServices/src/org/gvsig/remoteClient/taskplanning/retrieving/RetrieveEvent.java | ||
---|---|---|
52 | 52 |
private String fileName; |
53 | 53 |
private String message; |
54 | 54 |
|
55 |
protected void setType(int type) {
|
|
55 |
public void setType(int type) {
|
|
56 | 56 |
eventType = type; |
57 | 57 |
} |
58 | 58 |
|
branches/MULTITHREADING_DEVELOPMENT/extensions/extWMS/src/com/iver/cit/gvsig/fmap/drivers/wms/FMapWMSDriverFactory.java | ||
---|---|---|
10 | 10 |
private FMapWMSDriverFactory() {} // Avoid instantiation |
11 | 11 |
|
12 | 12 |
public static FMapWMSDriver getDriverForHost(URL host) { |
13 |
FMapWMSDriver drv = (FMapWMSDriver) drivers.get(host); |
|
14 |
if (drv == null) { |
|
15 |
drv = new FMapWMSDriver(host); |
|
16 |
drivers.put(host, drv); |
|
17 |
} |
|
18 |
return drv; |
|
13 |
// FMapWMSDriver drv = (FMapWMSDriver) drivers.get(host); |
|
14 |
// if (drv == null) { |
|
15 |
// drv = new FMapWMSDriver(host); |
|
16 |
// drivers.put(host, drv); |
|
17 |
// } |
|
18 |
// return drv; |
|
19 |
return new FMapWMSDriver(host); |
|
19 | 20 |
} |
20 | 21 |
} |
branches/MULTITHREADING_DEVELOPMENT/extensions/extWMS/src/com/iver/cit/gvsig/fmap/drivers/wms/ExperimentalAsynchronousFMapWMSDriver.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
|
|
42 |
/* CVS MESSAGES: |
|
43 |
* |
|
44 |
* $Id$ |
|
45 |
* $Log$ |
|
46 |
* Revision 1.1.2.1 2006-05-19 12:50:31 jaume |
|
47 |
* *** empty log message *** |
|
48 |
* |
|
49 |
* |
|
50 |
*/ |
|
51 |
package com.iver.cit.gvsig.fmap.drivers.wms; |
|
52 |
|
|
53 |
import java.net.URL; |
|
54 |
|
|
55 |
import org.gvsig.remoteClient.taskplanning.retrieving.RetrieveEvent; |
|
56 |
import org.gvsig.remoteClient.wms.WMSEventListener; |
|
57 |
|
|
58 |
public class ExperimentalAsynchronousFMapWMSDriver extends FMapWMSDriver implements Runnable, |
|
59 |
WMSEventListener { |
|
60 |
|
|
61 |
protected ExperimentalAsynchronousFMapWMSDriver(URL host) { |
|
62 |
super(host); |
|
63 |
// TODO Auto-generated constructor stub |
|
64 |
} |
|
65 |
|
|
66 |
public void run() { |
|
67 |
// TODO Auto-generated method stub |
|
68 |
|
|
69 |
} |
|
70 |
|
|
71 |
public void newEvent(int idRequest, RetrieveEvent event) { |
|
72 |
// TODO Auto-generated method stub |
|
73 |
|
|
74 |
} |
|
75 |
|
|
76 |
} |
|
0 | 77 |
branches/MULTITHREADING_DEVELOPMENT/extensions/extWMS/src/com/iver/cit/gvsig/fmap/drivers/wms/FMapWMSDriver.java | ||
---|---|---|
92 | 92 |
} |
93 | 93 |
} else if (idRequest == WMSOperations.GET_MAP) { |
94 | 94 |
String fileName = event.getFileName(); |
95 |
System.out.println("GetMap al driver"); |
|
96 | 95 |
for (int i = 0; i < listeners.size(); i++) { |
97 |
System.out.println("getMap enviat al listener: "+i); |
|
98 | 96 |
WMSOperations l = (WMSOperations) listeners.get(i); |
99 | 97 |
l.getMap(eventType, new File(fileName), event.getMessage()); |
100 | 98 |
} |
101 | 99 |
} |
102 | 100 |
} |
103 | 101 |
|
104 |
FMapWMSDriver(URL host) { |
|
102 |
protected FMapWMSDriver(URL host) {
|
|
105 | 103 |
try { |
106 | 104 |
client = new WMSClient(host.toString(), this); |
107 | 105 |
} catch (ConnectException e) { |
... | ... | |
319 | 317 |
} |
320 | 318 |
|
321 | 319 |
public void addListener(WMSOperations listener) { |
322 |
if (!listeners.contains(listener)) |
|
320 |
if (!listeners.contains(listener)) { |
|
321 |
System.out.println("Listener afegit al driver"); |
|
323 | 322 |
listeners.add(listener); |
323 |
} |
|
324 | 324 |
} |
325 | 325 |
|
326 | 326 |
public void cancel(int opCode) { |
branches/MULTITHREADING_DEVELOPMENT/extensions/extWMS/src/com/iver/cit/gvsig/fmap/layers/FLyrWMS.java | ||
---|---|---|
66 | 66 |
import java.util.Vector; |
67 | 67 |
|
68 | 68 |
import javax.swing.JOptionPane; |
69 |
import javax.swing.SwingUtilities; |
|
69 | 70 |
|
70 | 71 |
import org.cresques.geo.ViewPortData; |
71 | 72 |
import org.cresques.io.GdalFile; |
... | ... | |
120 | 121 |
private String m_SRS; |
121 | 122 |
private String layerQuery; |
122 | 123 |
private String infoLayerQuery; |
123 |
private FMapWMSDriver wms;
|
|
124 |
// private FMapWMSDriver wms = null;
|
|
124 | 125 |
private WMSStatus wmsStatus = new WMSStatus(); |
125 | 126 |
private Rectangle2D fullExtent; |
126 | 127 |
private boolean wmsTransparency; |
... | ... | |
587 | 588 |
dProperties.graphics = g; |
588 | 589 |
dProperties.sz = fixedSize; |
589 | 590 |
dProperties.viewPort = vp; |
591 |
|
|
590 | 592 |
getDriver().getMap(wmsStatus); |
591 | 593 |
// String nameWorldFile = f.getPath() + getExtensionWorldFile(); |
592 | 594 |
// com.iver.andami.Utilities.createTemp(nameWorldFile, this.getDataWorldFile(bBox, fixedSize)); |
... | ... | |
825 | 827 |
private FMapWMSDriver getDriver() |
826 | 828 |
throws IllegalStateException, ValidationException, |
827 | 829 |
UnsupportedVersionException, IOException { |
828 |
if (wms == null) { |
|
829 |
wms = FMapWMSDriverFactory.getDriverForHost(host); |
|
830 |
wms.addListener(this); |
|
831 |
} |
|
832 |
|
|
833 |
return wms; |
|
830 |
FMapWMSDriver drv = FMapWMSDriverFactory.getDriverForHost(host); |
|
831 |
drv.addListener(this); |
|
832 |
System.err.println("********** capa afegeix el listener"); |
|
833 |
// if (wms == null) { |
|
834 |
// wms = FMapWMSDriverFactory.getDriverForHost(host); |
|
835 |
// System.out.println("********** capa afegeix el listener"); |
|
836 |
// wms.addListener(this); |
|
837 |
// } |
|
838 |
// |
|
839 |
// return wms; |
|
840 |
return drv; |
|
834 | 841 |
} |
835 | 842 |
|
836 | 843 |
/** |
... | ... | |
843 | 850 |
* @throws UnsupportedVersionException |
844 | 851 |
* @throws IOException |
845 | 852 |
*/ |
846 |
public void setDriver(FMapWMSDriver drv) { |
|
847 |
wms = drv; |
|
848 |
} |
|
853 |
// public void setDriver(FMapWMSDriver drv) {
|
|
854 |
// wms = drv;
|
|
855 |
// }
|
|
849 | 856 |
|
850 | 857 |
/** |
851 | 858 |
* Devuelve el URL. |
... | ... | |
953 | 960 |
try { |
954 | 961 |
if(getDriver().connect()){ |
955 | 962 |
for (int i = 0; i < layerNames.length; i++) { |
956 |
layers.add(i, wms.getLayer(layerNames[i]));
|
|
963 |
layers.add(i, getDriver().getLayer(layerNames[i]));
|
|
957 | 964 |
} |
958 | 965 |
info.put("name", getName()); |
959 | 966 |
info.put("selectedLayers", layers); |
... | ... | |
1421 | 1428 |
public void getCapabilities(int eventType, String message) { /* Nothing */ } |
1422 | 1429 |
public void getFeatureInfo(int eventType, String message) { /* Nothing */ } |
1423 | 1430 |
public void getMap(int eventType, File mapFile, String message) { |
1424 |
System.out.println("getMap at the layer"); |
|
1425 | 1431 |
File f = mapFile; |
1426 | 1432 |
Graphics2D g = dProperties.graphics; |
1427 | 1433 |
ViewPort vp = dProperties.viewPort; |
1428 | 1434 |
Rectangle2D bBox = dProperties.bBox; |
1429 |
|
|
1435 |
Dimension sz = dProperties.sz; |
|
1430 | 1436 |
String nameWorldFile = f.getPath() + getExtensionWorldFile(); |
1431 | 1437 |
try { |
1432 |
com.iver.andami.Utilities.createTemp(nameWorldFile, this.getDataWorldFile(bBox, fixedSize));
|
|
1438 |
com.iver.andami.Utilities.createTemp(nameWorldFile, this.getDataWorldFile(bBox, sz));
|
|
1433 | 1439 |
} catch (IOException e) { |
1440 |
e.printStackTrace(); |
|
1434 | 1441 |
NotificationManager.addError(PluginServices.getText(this, "failed_creating_world_file"), e); |
1435 | 1442 |
} |
1436 | 1443 |
|
branches/MULTITHREADING_DEVELOPMENT/extensions/extWMS/src/com/iver/cit/gvsig/gui/panels/WMSParamsPanel.java | ||
---|---|---|
1336 | 1336 |
layer.setWmsTransparency(getTransparency()); |
1337 | 1337 |
layer.setStyles(getStyles()); |
1338 | 1338 |
layer.setDimensions(getDimensions()); |
1339 |
layer.setDriver(getDriver()); |
|
1339 |
// layer.setDriver(getDriver());
|
|
1340 | 1340 |
layer.setOnlineResources(getOnlineResources()); |
1341 | 1341 |
layer.setFixedSize(getFixedSize()); |
1342 | 1342 |
//layer.setQueryable(isQueryable()); |
... | ... | |
1376 | 1376 |
layer.setWmsTransparency(getTransparency()); |
1377 | 1377 |
layer.setStyles(getStyles()); |
1378 | 1378 |
layer.setDimensions(getDimensions()); |
1379 |
layer.setDriver(getDriver()); |
|
1379 |
// layer.setDriver(getDriver());
|
|
1380 | 1380 |
layer.setOnlineResources(getOnlineResources()); |
1381 | 1381 |
layer.setFixedSize(getFixedSize()); |
1382 | 1382 |
//layer.setQueryable(isQueryable()); |
branches/MULTITHREADING_DEVELOPMENT/extensions/extWMS/src/com/iver/cit/gvsig/gui/wizards/WMSWizard.java | ||
---|---|---|
848 | 848 |
layer.setWmsTransparency(getTransparency()); |
849 | 849 |
layer.setStyles(getStyles()); |
850 | 850 |
layer.setDimensions(getDimensions()); |
851 |
layer.setDriver(getDriver()); |
|
852 | 851 |
layer.setOnlineResources(getOnlineResources()); |
853 | 852 |
layer.setFixedSize(getFixedSize()); |
854 | 853 |
layer.setQueryable(isQueryable()); |
... | ... | |
885 | 884 |
layer.setWmsTransparency(getTransparency()); |
886 | 885 |
layer.setStyles(getStyles()); |
887 | 886 |
layer.setDimensions(getDimensions()); |
888 |
layer.setDriver(getDriver()); |
|
887 |
// layer.setDriver(getDriver());
|
|
889 | 888 |
layer.setOnlineResources(getOnlineResources()); |
890 | 889 |
layer.setFixedSize(getFixedSize()); |
891 | 890 |
layer.setQueryable(isQueryable()); |
branches/MULTITHREADING_DEVELOPMENT/extensions/extWMS/src/com/iver/cit/gvsig/wmc/ExportWebMapContextExtension.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.3 2006-05-12 07:47:39 jaume |
|
46 |
* Revision 1.3.2.1 2006-05-19 12:50:31 jaume |
|
47 |
* *** empty log message *** |
|
48 |
* |
|
49 |
* Revision 1.3 2006/05/12 07:47:39 jaume |
|
47 | 50 |
* removed unnecessary imports |
48 | 51 |
* |
49 | 52 |
* Revision 1.2 2006/05/03 11:10:54 jaume |
... | ... | |
115 | 118 |
public class ExportWebMapContextExtension extends Extension { |
116 | 119 |
private static ArrayList supportedVersions; |
117 | 120 |
private View viewToExport; |
118 |
private File dstFile; |
|
119 | 121 |
private WebMapContextSettingsPanel mc; |
120 | 122 |
private static IExtension thisExtension; |
121 | 123 |
|
Also available in: Unified diff