Revision 3430
trunk/extensions/extWMS/src/com/iver/cit/gvsig/fmap/layers/FLyrWMS.java | ||
---|---|---|
50 | 50 |
import java.io.ByteArrayInputStream; |
51 | 51 |
import java.io.IOException; |
52 | 52 |
import java.net.MalformedURLException; |
53 |
import java.net.NoRouteToHostException; |
|
53 | 54 |
import java.net.URL; |
54 | 55 |
|
55 | 56 |
import javax.imageio.ImageIO; |
... | ... | |
58 | 59 |
|
59 | 60 |
import com.iver.cit.gvsig.fmap.DriverException; |
60 | 61 |
import com.iver.cit.gvsig.fmap.ViewPort; |
62 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
|
61 | 63 |
import com.iver.cit.gvsig.fmap.drivers.WMSException; |
62 | 64 |
import com.iver.cit.gvsig.fmap.layers.layerOperations.InfoByPoint; |
63 | 65 |
import com.iver.cit.gvsig.fmap.operations.Cancellable; |
... | ... | |
283 | 285 |
* com.iver.cit.gvsig.fmap.operations.Cancellable) |
284 | 286 |
*/ |
285 | 287 |
public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort, |
286 |
Cancellable cancel,double scale) throws DriverException { |
|
288 |
Cancellable cancel,double scale) throws DriverException {
|
|
287 | 289 |
if (isWithinScale(scale)){ |
288 |
try { |
|
289 |
MapQuery mapQuery = getWmsClient().createQuery(); |
|
290 |
mapQuery.setBBOX(viewPort.getAdjustedExtent()); |
|
291 |
mapQuery.setFormat(m_Format); |
|
292 |
mapQuery.setHeight(viewPort.getImageHeight()); |
|
293 |
|
|
294 |
// System.err.println("m_Mapa.getHeight() = " + m_Mapa.getHeight()); |
|
295 |
mapQuery.setLayers(layerQuery); |
|
296 |
mapQuery.setSRS(m_SRS); |
|
297 |
mapQuery.setStyles(""); |
|
298 |
mapQuery.setWidth(viewPort.getImageWidth()); |
|
299 |
mapQuery.setExceptions("application/vnd.ogc.se_xml"); |
|
300 |
|
|
301 |
byte[] bytes; |
|
302 |
lastMapQuery = mapQuery; |
|
303 |
bytes = getWmsClient().doMapQuery(lastMapQuery); |
|
304 |
|
|
305 |
ByteArrayInputStream inbytes = new ByteArrayInputStream(bytes); |
|
306 |
BufferedImage tempImg = ImageIO.read(inbytes); |
|
307 |
// LWS Cambio de estrategia en el posicionado para la impresi?n. |
|
308 |
Point2D p2=new Point2D.Double(viewPort.getAdjustedExtent().getX(), viewPort.getAdjustedExtent().getMaxY()); //viewPort.getOffset(); |
|
309 |
viewPort.getAffineTransform().transform(p2, p2); |
|
310 |
g.drawImage(tempImg,(int)p2.getX(),(int)p2.getY(), null); |
|
311 |
} catch (ValidationException e) { |
|
312 |
throw new DriverException("No se reconoce el formato de la respuesta", |
|
313 |
e); |
|
314 |
} catch (UnsupportedVersionException e) { |
|
315 |
throw new DriverException("Conflicto de versiones", e); |
|
316 |
} catch (IOException e) { |
|
317 |
throw new DriverException("Error en la conexi?n", e); |
|
318 |
} catch (com.iver.wmsclient.WMSException e) { |
|
319 |
throw new DriverException(e.getMessage(), e); |
|
320 |
} catch (NoSuchFieldException e) { |
|
321 |
throw new RuntimeException( |
|
290 |
try { |
|
291 |
MapQuery mapQuery = getWmsClient().createQuery(); |
|
292 |
mapQuery.setBBOX(viewPort.getAdjustedExtent()); |
|
293 |
mapQuery.setFormat(m_Format); |
|
294 |
mapQuery.setHeight(viewPort.getImageHeight()); |
|
295 |
|
|
296 |
// System.err.println("m_Mapa.getHeight() = " + m_Mapa.getHeight()); |
|
297 |
mapQuery.setLayers(layerQuery); |
|
298 |
mapQuery.setSRS(m_SRS); |
|
299 |
mapQuery.setStyles(""); |
|
300 |
mapQuery.setWidth(viewPort.getImageWidth()); |
|
301 |
mapQuery.setExceptions("application/vnd.ogc.se_xml"); |
|
302 |
|
|
303 |
byte[] bytes; |
|
304 |
lastMapQuery = mapQuery; |
|
305 |
bytes = getWmsClient().doMapQuery(lastMapQuery); |
|
306 |
|
|
307 |
ByteArrayInputStream inbytes = new ByteArrayInputStream(bytes); |
|
308 |
BufferedImage tempImg = ImageIO.read(inbytes); |
|
309 |
// LWS Cambio de estrategia en el posicionado para la impresi?n. |
|
310 |
Point2D p2=new Point2D.Double(viewPort.getAdjustedExtent().getX(), viewPort.getAdjustedExtent().getMaxY()); //viewPort.getOffset(); |
|
311 |
viewPort.getAffineTransform().transform(p2, p2); |
|
312 |
g.drawImage(tempImg,(int)p2.getX(),(int)p2.getY(), null); |
|
313 |
} catch (ValidationException e) { |
|
314 |
throw new DriverException("No se reconoce el formato de la respuesta", |
|
315 |
e); |
|
316 |
} catch (UnsupportedVersionException e) { |
|
317 |
throw new DriverException("Conflicto de versiones", e); |
|
318 |
} catch (IOException e) { |
|
319 |
this.setActive(false); |
|
320 |
this.setVisible(false); |
|
321 |
throw new DriverException("Error en la conexi?n", e); |
|
322 |
} catch (com.iver.wmsclient.WMSException e) { |
|
323 |
throw new DriverException(e.getMessage(), e); |
|
324 |
} catch (NoSuchFieldException e) { |
|
325 |
throw new RuntimeException( |
|
322 | 326 |
"No se rellenaron todos los campos de la petici?n"); |
327 |
} catch (RuntimeException e) { |
|
328 |
this.setActive(false); |
|
329 |
this.setVisible(false); |
|
330 |
throw new DriverException("Error en la conexi?n", e); |
|
331 |
} |
|
323 | 332 |
} |
324 |
} |
|
325 | 333 |
} |
326 | 334 |
|
327 | 335 |
/** |
Also available in: Unified diff