Revision 1431 org.gvsig.raster.wcs/trunk/org.gvsig.raster.wcs/org.gvsig.raster.wcs.io/src/main/java/org/gvsig/raster/wcs/io/WCSProvider.java
WCSProvider.java | ||
---|---|---|
511 | 511 |
*/ |
512 | 512 |
public Object getData(int x, int y, int band) |
513 | 513 |
throws InvalidSetViewException, FileNotOpenException, RasterDriverException { |
514 |
int w = 25; |
|
515 |
int h = 25; |
|
516 |
|
|
517 |
Point2D p1 = rasterToWorld(new Point2D.Double(x, y)); |
|
518 |
Point2D p2 = rasterToWorld(new Point2D.Double(x + w, y + h)); |
|
519 |
Rectangle2D bBox = new Rectangle2D.Double(p1.getX(), p1.getY(), Math.abs(p1.getX() - p2.getX()), Math.abs(p1.getY() - p2.getY())); |
|
520 |
|
|
521 |
WCSDataParametersImpl p = (WCSDataParametersImpl)parameters; |
|
522 |
WCSStatus wcsStatus = new WCSStatus(); |
|
523 |
wcsStatus.setCoveraName(p.getCoverageName()); |
|
524 |
wcsStatus.setSrs(p.getSRSCode()); |
|
525 |
wcsStatus.setFormat(p.getFormat()); |
|
526 |
wcsStatus.setOnlineResource(p.getOnlineResource() != null ? (String) p.getOnlineResource().get("GetCoverage") : null); |
|
527 |
wcsStatus.setExtent(bBox); |
|
528 |
wcsStatus.setHeight(h); |
|
529 |
wcsStatus.setWidth(w); |
|
530 |
wcsStatus.setDepth(p.getDepth()); |
|
531 |
wcsStatus.setParameters(p.getParameter()); |
|
532 |
wcsStatus.setTime(p.getTime()); |
|
533 |
|
|
534 |
lastRequest = downloadFile(wcsStatus, p1.getX(), p1.getY(), p2.getX(), p2.getY(), w, h); |
|
535 |
|
|
536 |
DefaultRasterProvider driver = null; |
|
537 |
try { |
|
538 |
driver = DefaultProviderServices.loadProvider(new File(lastRequest.getPath())); |
|
539 |
Buffer buf = DefaultRasterManager.getInstance().createBuffer(getDataType()[0], w, h, getBandCount(), true); |
|
540 |
BandList bandList = new BandListImpl(); |
|
541 |
int[] drawable = new int[getBandCount()]; |
|
542 |
for (int i = 0; i < getBandCount(); i++) { |
|
543 |
try { |
|
544 |
bandList.addBand(new DatasetBandImpl(lastRequest.getPath(), i, getDataType()[i], getBandCount()), i); |
|
545 |
drawable[i] = i; |
|
546 |
} catch (BandNotFoundInListException e1) { |
|
547 |
} |
|
548 |
} |
|
549 |
bandList.setDrawableBands(drawable); |
|
550 |
|
|
551 |
DefaultRasterQuery q = (DefaultRasterQuery)RasterLocator.getManager().createQuery(); |
|
552 |
q.setAreaOfInterest(0, 0, 25, 25); |
|
553 |
q.setBandList(bandList); |
|
554 |
q.setBuffer(buf); |
|
555 |
buf = driver.getDataSet(q); |
|
556 |
driver.close(); |
|
557 |
if(buf.getDataType() == Buffer.TYPE_BYTE) { |
|
558 |
return new Integer(buf.getElemByte(0, 0, band)); |
|
559 |
} |
|
560 |
if(buf.getDataType() == Buffer.TYPE_SHORT) { |
|
561 |
return new Integer(buf.getElemShort(0, 0, band)); |
|
562 |
} |
|
563 |
if(buf.getDataType() == Buffer.TYPE_INT) { |
|
564 |
return new Integer(buf.getElemInt(0, 0, band)); |
|
565 |
} |
|
566 |
if(buf.getDataType() == Buffer.TYPE_FLOAT) { |
|
567 |
return new Float(buf.getElemFloat(0, 0, band)); |
|
568 |
} |
|
569 |
if(buf.getDataType() == Buffer.TYPE_DOUBLE) { |
|
570 |
return new Double(buf.getElemDouble(0, 0, band)); |
|
571 |
} |
|
572 |
} catch(InitializeException e) { |
|
573 |
throw new RasterDriverException("", e); |
|
574 |
} catch (ProviderNotRegisteredException e) { |
|
575 |
throw new RasterDriverException("", e); |
|
576 |
} catch (ProcessInterruptedException e) { |
|
577 |
} |
|
514 | 578 |
return null; |
515 | 579 |
} |
516 | 580 |
|
... | ... | |
945 | 1009 |
BandList bandList, Buffer rasterBuf, TaskStatus status) throws ProcessInterruptedException, RasterDriverException { |
946 | 1010 |
Point2D p1 = rasterToWorld(new Point2D.Double(x, y)); |
947 | 1011 |
Point2D p2 = rasterToWorld(new Point2D.Double(x + w, y + h)); |
948 |
Rectangle2D bBox = new Rectangle2D.Double(p1.getX(), p1.getY(), Math.abs(p1.getX() - p1.getX()), Math.abs(p1.getY() - p2.getY()));
|
|
1012 |
Rectangle2D bBox = new Rectangle2D.Double(p1.getX(), p1.getY(), Math.abs(p1.getX() - p2.getX()), Math.abs(p1.getY() - p2.getY()));
|
|
949 | 1013 |
WCSStatus wcsStatus = loadWCSStatus(bBox); |
950 | 1014 |
|
951 | 1015 |
lastRequest = downloadFile(wcsStatus, p1.getX(), p1.getY(), p2.getX(), p2.getY(), rasterBuf.getWidth(), rasterBuf.getHeight()); |
Also available in: Unified diff