Revision 2849 trunk/libraries/libCq CMS for java.old/src/org/cresques/io/GdalFile.java
GdalFile.java | ||
---|---|---|
56 | 56 |
class GdalNative extends Gdal { |
57 | 57 |
static boolean WITH_OVERVIEWS = true; |
58 | 58 |
// Polilinea con extent |
59 |
class Contour extends Vector { |
|
59 |
public class Contour extends Vector {
|
|
60 | 60 |
final private static long serialVersionUID = -3370601314380922368L; |
61 | 61 |
public double minX = Double.MAX_VALUE, minY = Double.MAX_VALUE; |
62 | 62 |
public double maxX = -Double.MAX_VALUE, maxY = -Double.MAX_VALUE; |
... | ... | |
99 | 99 |
if (true) { //ext.compareTo("sid") == 0) { |
100 | 100 |
String [] metadata = getMetadata(); |
101 | 101 |
double ox=0D, oy=0D, resx=0D, resy=0D; |
102 |
|
|
103 |
GeoTransform trans = getGeoTransform(); |
|
104 |
ox = trans.adfgeotransform[0]; |
|
105 |
oy = trans.adfgeotransform[3]; |
|
106 |
resx = trans.adfgeotransform[1]; |
|
107 |
resy = trans.adfgeotransform[5]; |
|
108 |
|
|
109 |
System.out.println("Origin = ("+ox+","+oy+")"); |
|
110 |
System.out.println("Pixel Size = ("+resx+","+resy+")"); |
|
111 |
esq.add(new Point2D.Double(ox, oy)); |
|
112 |
esq.add(new Point2D.Double(ox+resx*width, oy)); |
|
113 |
esq.add(new Point2D.Double(ox, oy+resy*height)); |
|
114 |
esq.add(new Point2D.Double(ox+resx*width, oy+resy*height)); |
|
102 |
try{ |
|
103 |
GeoTransform trans = getGeoTransform(); |
|
104 |
ox = trans.adfgeotransform[0]; |
|
105 |
oy = trans.adfgeotransform[3]; |
|
106 |
resx = trans.adfgeotransform[1]; |
|
107 |
resy = trans.adfgeotransform[5]; |
|
108 |
|
|
109 |
System.out.println("Origin = ("+ox+","+oy+")"); |
|
110 |
System.out.println("Pixel Size = ("+resx+","+resy+")"); |
|
111 |
esq.add(new Point2D.Double(ox, oy)); |
|
112 |
esq.add(new Point2D.Double(ox+resx*width, oy)); |
|
113 |
esq.add(new Point2D.Double(ox, oy+resy*height)); |
|
114 |
esq.add(new Point2D.Double(ox+resx*width, oy+resy*height)); |
|
115 |
}catch(GdalException exc){ |
|
116 |
esq = null; |
|
117 |
} |
|
115 | 118 |
} else { //version.startsWith("1")) { |
116 | 119 |
//double [] transParam = getGeoTransform(); |
117 | 120 |
esq.add(new Point2D.Double(0D,height)); |
... | ... | |
385 | 388 |
System.out.println(metadata[i]); |
386 | 389 |
} |
387 | 390 |
} catch (GdalException e) { |
388 |
// TODO Auto-generated catch block |
|
389 |
e.printStackTrace(); |
|
391 |
|
|
390 | 392 |
} |
391 | 393 |
|
392 | 394 |
} |
... | ... | |
445 | 447 |
setDataType(DataBuffer.TYPE_USHORT); |
446 | 448 |
} |
447 | 449 |
|
450 |
/** |
|
451 |
* Obtenemos o calculamos el extent de la imagen. |
|
452 |
*/ |
|
448 | 453 |
public GeoFile load() { |
449 |
/*double minX, minY, maxX, maxY; |
|
450 |
minX = minY = 0D; |
|
451 |
maxX = (double) width; |
|
452 |
maxY = (double) height;*/ |
|
453 |
extent = new Extent(file.esq.minX, file.esq.minY, file.esq.maxX, file.esq.maxY); |
|
454 |
|
|
455 |
//Si el extent temporal tiene alg?n valor usamos este para calcular el de la imagen |
|
456 |
if(this.getTempExtent()!=null){ |
|
457 |
extent = this.calcTempExtent(file.width, file.height); |
|
458 |
file.esq = file.new Contour(); |
|
459 |
file.esq.add(new Point2D.Double(extent.minX(), extent.minY())); |
|
460 |
file.esq.add(new Point2D.Double(extent.minX()+(extent.maxX() - extent.minX()), extent.minY())); |
|
461 |
file.esq.add(new Point2D.Double(extent.minX(), extent.minY()+(extent.maxY() - extent.minY()))); |
|
462 |
file.esq.add(new Point2D.Double(extent.minX()+(extent.maxX() - extent.minX()), extent.minY()+(extent.maxY() - extent.minY()))); |
|
463 |
}else{ //usamos el de la imagen |
|
464 |
|
|
465 |
//Si la imagen est? georreferenciada obtenemos el extent |
|
466 |
if(file.esq != null) |
|
467 |
extent = new Extent(file.esq.minX, file.esq.minY, file.esq.maxX, file.esq.maxY); |
|
468 |
else{//Si no est? georreferenciada nos inventamos el extent |
|
469 |
extent = new Extent(0, 0, file.width, file.height); |
|
470 |
file.esq = file.new Contour(); |
|
471 |
file.esq.add(new Point2D.Double(0, 0)); |
|
472 |
file.esq.add(new Point2D.Double(file.width, 0)); |
|
473 |
file.esq.add(new Point2D.Double(0, file.height)); |
|
474 |
file.esq.add(new Point2D.Double(file.width, file.height)); |
|
475 |
} |
|
476 |
} |
|
454 | 477 |
return this; |
455 | 478 |
} |
456 | 479 |
|
... | ... | |
687 | 710 |
// TODO Auto-generated catch block |
688 | 711 |
e.printStackTrace(); |
689 | 712 |
} |
690 |
file.pintaInfo(); |
|
713 |
//file.pintaInfo();
|
|
691 | 714 |
file.pintaPaleta(); |
692 | 715 |
|
693 | 716 |
} |
Also available in: Unified diff