(File f)
| 97 | } |
| 98 | |
| 99 | public BufferedImage openFile(File f) { |
| 100 | Dataset poDataset = null; |
| 101 | try { |
| 102 | poDataset = (Dataset) gdal.Open(f.getAbsolutePath(), |
| 103 | gdalconst.GA_ReadOnly); |
| 104 | if (poDataset == null) { |
| 105 | System.out.println("The image could not be read."); |
| 106 | printLastError(); |
| 107 | return null; |
| 108 | } |
| 109 | } catch(Exception e) { |
| 110 | System.err.println("Exception caught."); |
| 111 | System.err.println(e.getMessage()); |
| 112 | e.printStackTrace(); |
| 113 | return null; |
| 114 | } |
| 115 | double[] adfGeoTransform = new double[6]; |
| 116 | |
| 117 | System.out.println("Driver: " + poDataset.GetDriver().GetDescription()); |
| 118 | |
| 119 | System.out.println("Size is: " + poDataset.getRasterXSize() + "x" |
| 120 | + poDataset.getRasterYSize() + " bands:" |
| 121 | + poDataset.getRasterCount()); |
| 122 | |
| 123 | if (poDataset.GetProjectionRef() != null) |
| 124 | System.out.println("Projection is `" + poDataset.GetProjectionRef() |
| 125 | + "'"); |
| 126 | |
| 127 | Hashtable dict = poDataset.GetMetadata_Dict(""); |
| 128 | Enumeration keys = dict.keys(); |
| 129 | System.out.println(dict.size() + " items of metadata found (via Hashtable dict):"); |
| 130 | while(keys.hasMoreElements()) { |
| 131 | String key = (String)keys.nextElement(); |
| 132 | System.out.println(" :" + key + ":==:" + dict.get(key) + ":"); |
| 133 | } |
| 134 | |
| 135 | Vector list = poDataset.GetMetadata_List(""); |
| 136 | Enumeration enumerate = list.elements(); |
| 137 | System.out.println(list.size() + " items of metadata found (via Vector list):"); |
| 138 | while(enumerate.hasMoreElements()) { |
| 139 | String s = (String)enumerate.nextElement(); |
| 140 | System.out.println(" " + s); |
| 141 | } |
| 142 | |
| 143 | Vector GCPs = new Vector(); |
| 144 | poDataset.GetGCPs(GCPs); |
| 145 | System.out.println("Got " + GCPs.size() + " GCPs"); |
| 146 | Enumeration e = GCPs.elements(); |
| 147 | while(e.hasMoreElements()) { |
| 148 | GCP gcp = (GCP)e.nextElement(); |
| 149 | System.out.println(" x:" + gcp.getGCPX() + |
| 150 | " y:" + gcp.getGCPY() + |
| 151 | " z:" + gcp.getGCPZ() + |
| 152 | " pixel:" + gcp.getGCPPixel() + |
| 153 | " line:" + gcp.getGCPLine() + |
| 154 | " line:" + gcp.getInfo()); |
| 155 | } |
| 156 |
no test coverage detected