Revision 361
branches/org.gvsig.gdal-2018a/org.gvsig.gdal.prov/org.gvsig.gdal.prov.ogr/pom.xml | ||
---|---|---|
3 | 3 |
<parent> |
4 | 4 |
<groupId>org.gvsig</groupId> |
5 | 5 |
<artifactId>org.gvsig.gdal.prov</artifactId> |
6 |
<version>1.0.55-SNAPSHOT</version>
|
|
6 |
<version>3.0.0-SNAPSHOT</version>
|
|
7 | 7 |
</parent> |
8 | 8 |
<artifactId>org.gvsig.gdal.prov.ogr</artifactId> |
9 | 9 |
<name>org.gvsig.gdal.prov.ogr</name> |
... | ... | |
32 | 32 |
</dependency> |
33 | 33 |
|
34 | 34 |
</dependencies> |
35 |
</project> |
|
35 |
</project> |
branches/org.gvsig.gdal-2018a/org.gvsig.gdal.prov/org.gvsig.gdal.raster/pom.xml | ||
---|---|---|
1 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|
2 |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
3 |
<modelVersion>4.0.0</modelVersion> |
|
4 |
<parent> |
|
5 |
<groupId>org.gvsig</groupId> |
|
6 |
<artifactId>org.gvsig.gdal.prov</artifactId> |
|
7 |
<version>3.0.0-SNAPSHOT</version> |
|
8 |
</parent> |
|
9 |
<artifactId>org.gvsig.gdal.raster</artifactId> |
|
10 |
<packaging>pom</packaging> |
|
11 |
<name>${project.artifactId}</name> |
|
12 |
|
|
13 |
<modules> |
|
14 |
<module>org.gvsig.gdal.raster.provider</module> |
|
15 |
<module>org.gvsig.gdal.raster.provider.legend</module> |
|
16 |
</modules> |
|
17 |
|
|
18 |
</project> |
branches/org.gvsig.gdal-2018a/org.gvsig.gdal.prov/org.gvsig.gdal.raster/org.gvsig.gdal.raster.provider.legend/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.raster.gdal.provider.legend.RasterGdalLegendLibrary |
branches/org.gvsig.gdal-2018a/org.gvsig.gdal.prov/org.gvsig.gdal.raster/org.gvsig.gdal.raster.provider.legend/src/main/java/org/gvsig/raster/gdal/provider/legend/RasterGdalGetLegend.java | ||
---|---|---|
1 |
package org.gvsig.raster.gdal.provider.legend; |
|
2 |
|
|
3 |
import org.gvsig.fmap.dal.raster.api.RasterStore; |
|
4 |
import org.gvsig.raster.gdal.provider.AbstractRasterGdalStoreProvider; |
|
5 |
import org.gvsig.raster.lib.legend.api.RasterLegend; |
|
6 |
import org.gvsig.raster.lib.legend.api.RasterLegendLocator; |
|
7 |
import org.gvsig.raster.lib.legend.api.RasterLegendManager; |
|
8 |
import org.gvsig.raster.lib.legend.api.colorinterpretation.ColorInterpretation; |
|
9 |
import org.gvsig.raster.lib.legend.api.colortable.ColorTable; |
|
10 |
import org.gvsig.tools.ToolsLocator; |
|
11 |
import org.gvsig.tools.dynobject.DynClass; |
|
12 |
import org.gvsig.tools.dynobject.DynMethod; |
|
13 |
import org.gvsig.tools.dynobject.DynObject; |
|
14 |
import org.gvsig.tools.dynobject.exception.DynMethodException; |
|
15 |
import org.gvsig.tools.dynobject.exception.DynMethodNotSupportedException; |
|
16 |
|
|
17 |
/** |
|
18 |
* Dynamic method to add a get Legend funcionality |
|
19 |
* @author dmartinezizquierdo |
|
20 |
* |
|
21 |
*/ |
|
22 |
public class RasterGdalGetLegend implements DynMethod { |
|
23 |
|
|
24 |
private static Integer code = null; |
|
25 |
|
|
26 |
|
|
27 |
static void register(DynClass storeClass) { |
|
28 |
if (code != null) { |
|
29 |
return; |
|
30 |
} |
|
31 |
code = ToolsLocator.getDynObjectManager() |
|
32 |
.registerDynMethod(storeClass, new RasterGdalGetLegend()); |
|
33 |
|
|
34 |
} |
|
35 |
|
|
36 |
@Override |
|
37 |
public int getCode() throws DynMethodNotSupportedException { |
|
38 |
return code; |
|
39 |
} |
|
40 |
|
|
41 |
@Override |
|
42 |
public String getDescription() { |
|
43 |
return "Raster GDAL Legend"; |
|
44 |
} |
|
45 |
|
|
46 |
@Override |
|
47 |
public String getName() { |
|
48 |
return RasterStore.DYNMETHOD_GETLEGEND_NAME; |
|
49 |
} |
|
50 |
|
|
51 |
@Override |
|
52 |
public Object invoke(DynObject self, Object[] args) |
|
53 |
throws DynMethodException { |
|
54 |
try { |
|
55 |
AbstractRasterGdalStoreProvider rasterGdalProvider=(AbstractRasterGdalStoreProvider)self; |
|
56 |
RasterLegendManager legendManager=RasterLegendLocator.getRasterLegendManager(); |
|
57 |
|
|
58 |
ColorInterpretation colorInterpretation =(ColorInterpretation)rasterGdalProvider. |
|
59 |
invokeDynMethod(RasterStore.DYNMETHOD_GETCOLORINTERPRETATION_NAME, null); |
|
60 |
|
|
61 |
RasterLegend legend= legendManager.createLegend(colorInterpretation); |
|
62 |
// if ( !( colorInterpretation.isBGR() || colorInterpretation.isRGB() || colorInterpretation.isRGBA() ) ){ |
|
63 |
// ColorTable colorTable=(ColorTable)rasterGdalProvider. |
|
64 |
// invokeDynMethod(RasterStore.DYNMETHOD_GETCOLORTABLE_NAME, null); |
|
65 |
// legend.setColorTable(colorTable); |
|
66 |
// } |
|
67 |
|
|
68 |
return legend; |
|
69 |
|
|
70 |
} catch (DynMethodNotSupportedException e) { |
|
71 |
//FIXME |
|
72 |
throw new RuntimeException(e); |
|
73 |
} |
|
74 |
} |
|
75 |
|
|
76 |
@Override |
|
77 |
public Object clone() throws CloneNotSupportedException { |
|
78 |
return super.clone(); |
|
79 |
} |
|
80 |
} |
branches/org.gvsig.gdal-2018a/org.gvsig.gdal.prov/org.gvsig.gdal.raster/org.gvsig.gdal.raster.provider.legend/src/main/java/org/gvsig/raster/gdal/provider/legend/RasterGdalLegendLibrary.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2008 IVER T.I. S.A. {{Task}} |
|
26 |
*/ |
|
27 |
|
|
28 |
/** |
|
29 |
* |
|
30 |
*/ |
|
31 |
package org.gvsig.raster.gdal.provider.legend; |
|
32 |
|
|
33 |
import org.gvsig.fmap.dal.DALLibrary; |
|
34 |
import org.gvsig.metadata.MetadataLibrary; |
|
35 |
import org.gvsig.metadata.MetadataLocator; |
|
36 |
import org.gvsig.raster.gdal.provider.RasterGdalLibrary; |
|
37 |
import org.gvsig.raster.gdal.provider.AbstractFileRasterGdalStoreProvider; |
|
38 |
import org.gvsig.raster.gdal.provider.AbstractRasterGdalStoreProvider; |
|
39 |
import org.gvsig.tools.dynobject.DynClass; |
|
40 |
import org.gvsig.tools.library.AbstractLibrary; |
|
41 |
import org.gvsig.tools.library.LibraryException; |
|
42 |
|
|
43 |
/** |
|
44 |
* @author dmartinez |
|
45 |
* |
|
46 |
*/ |
|
47 |
public class RasterGdalLegendLibrary extends AbstractLibrary { |
|
48 |
|
|
49 |
@Override |
|
50 |
public void doRegistration() { |
|
51 |
registerAsServiceOf(DALLibrary.class); |
|
52 |
require(RasterGdalLibrary.class); |
|
53 |
require(MetadataLibrary.class); |
|
54 |
require(DALLibrary.class); |
|
55 |
} |
|
56 |
|
|
57 |
@Override |
|
58 |
protected void doInitialize() throws LibraryException { |
|
59 |
} |
|
60 |
|
|
61 |
@Override |
|
62 |
protected void doPostInitialize() throws LibraryException { |
|
63 |
DynClass metadataDefinition = (DynClass) MetadataLocator.getMetadataManager() |
|
64 |
.getDefinition(AbstractRasterGdalStoreProvider.METADATA_DEFINITION_NAME); |
|
65 |
RasterGdalGetLegend.register(metadataDefinition); |
|
66 |
RasterGdalGetColorInterpretation.register(metadataDefinition); |
|
67 |
} |
|
68 |
} |
branches/org.gvsig.gdal-2018a/org.gvsig.gdal.prov/org.gvsig.gdal.raster/org.gvsig.gdal.raster.provider.legend/src/main/java/org/gvsig/raster/gdal/provider/legend/RasterGdalGetColorInterpretation.java | ||
---|---|---|
1 |
package org.gvsig.raster.gdal.provider.legend; |
|
2 |
|
|
3 |
import java.awt.Color; |
|
4 |
import java.util.ArrayList; |
|
5 |
import java.util.List; |
|
6 |
|
|
7 |
import org.gdal.gdal.Band; |
|
8 |
import org.gdal.gdal.Dataset; |
|
9 |
import org.gdal.gdal.gdal; |
|
10 |
|
|
11 |
import org.gvsig.fmap.dal.raster.api.RasterStore; |
|
12 |
import org.gvsig.raster.gdal.provider.AbstractRasterGdalStoreProvider; |
|
13 |
import org.gvsig.raster.gdal.provider.DisposableGdalDataSet; |
|
14 |
import org.gvsig.raster.lib.legend.api.RasterLegendLocator; |
|
15 |
import org.gvsig.raster.lib.legend.api.RasterLegendManager; |
|
16 |
import org.gvsig.raster.lib.legend.api.colorinterpretation.ColorInterpretation; |
|
17 |
import org.gvsig.raster.lib.legend.api.colortable.ColorTable; |
|
18 |
import org.gvsig.raster.lib.legend.api.colortable.colortableclass.ColorTableClass; |
|
19 |
import org.gvsig.tools.ToolsLocator; |
|
20 |
import org.gvsig.tools.dynobject.DynClass; |
|
21 |
import org.gvsig.tools.dynobject.DynMethod; |
|
22 |
import org.gvsig.tools.dynobject.DynObject; |
|
23 |
import org.gvsig.tools.dynobject.exception.DynMethodException; |
|
24 |
import org.gvsig.tools.dynobject.exception.DynMethodNotSupportedException; |
|
25 |
|
|
26 |
/** |
|
27 |
* @author dmartinezizquierdo |
|
28 |
* |
|
29 |
*/ |
|
30 |
public class RasterGdalGetColorInterpretation implements DynMethod { |
|
31 |
|
|
32 |
private static Integer code = null; |
|
33 |
|
|
34 |
static void register(DynClass storeClass) { |
|
35 |
if (code != null) { |
|
36 |
return; |
|
37 |
} |
|
38 |
code = ToolsLocator.getDynObjectManager() |
|
39 |
.registerDynMethod(storeClass, new RasterGdalGetColorInterpretation()); |
|
40 |
|
|
41 |
} |
|
42 |
|
|
43 |
@Override |
|
44 |
public int getCode() throws DynMethodNotSupportedException { |
|
45 |
return code; |
|
46 |
} |
|
47 |
|
|
48 |
@Override |
|
49 |
public String getDescription() { |
|
50 |
return "Raster GDAL Color Interpretation"; |
|
51 |
} |
|
52 |
|
|
53 |
@Override |
|
54 |
public String getName() { |
|
55 |
return RasterStore.DYNMETHOD_GETCOLORINTERPRETATION_NAME; |
|
56 |
} |
|
57 |
|
|
58 |
@Override |
|
59 |
public Object invoke(DynObject self, Object[] args) |
|
60 |
throws DynMethodException { |
|
61 |
ColorInterpretation colorInterpretation = null; |
|
62 |
|
|
63 |
AbstractRasterGdalStoreProvider rasterGdalProvider = |
|
64 |
(AbstractRasterGdalStoreProvider) self; |
|
65 |
|
|
66 |
RasterLegendManager legendManager = |
|
67 |
RasterLegendLocator.getRasterLegendManager(); |
|
68 |
DisposableGdalDataSet gdalDataSet = rasterGdalProvider.getGdalDataSet(); |
|
69 |
|
|
70 |
String[] bandColorInterpretations = |
|
71 |
new String[gdalDataSet.getRasterCount()]; |
|
72 |
for (int i = 0; i < gdalDataSet.getRasterCount(); i++) { |
|
73 |
// Bands begin in 1 instead of 0 |
|
74 |
int bandNumber = i + 1; |
|
75 |
Band gdalBand = gdalDataSet.GetRasterBand(bandNumber); |
|
76 |
String bandColorInterpretion = |
|
77 |
colorInterpretationFromGdal(gdalBand.GetRasterColorInterpretation()); |
|
78 |
bandColorInterpretations[i] = bandColorInterpretion; |
|
79 |
} |
|
80 |
//FIXME:Intenta suponer cual es la forma correcta de interpretar los colores en funcion del numero de bandas |
|
81 |
//Seguramente haya que arreglarlo cuando haya GUI para que el usuario pueda especificar la forma correcta. |
|
82 |
guessingColorInterpretation(bandColorInterpretations); |
|
83 |
|
|
84 |
colorInterpretation = |
|
85 |
legendManager.createColorInterpretation(bandColorInterpretations); |
|
86 |
|
|
87 |
|
|
88 |
for (int bandNumber = 1; bandNumber <= gdalDataSet.getRasterCount(); bandNumber++) { |
|
89 |
//Band in GDAL begins in 1, meanwhile we begin in 0 |
|
90 |
int indexColorInterpretation=bandNumber-1; |
|
91 |
if (ColorInterpretation.PALETTE_BAND.equals(colorInterpretation.get(indexColorInterpretation))) { |
|
92 |
ColorTable colorTable = null; |
|
93 |
Band gdalBand = gdalDataSet.GetRasterBand(bandNumber); |
|
94 |
org.gdal.gdal.ColorTable gdalBandColorTable = gdalBand.GetColorTable(); |
|
95 |
if (gdalBandColorTable != null) { |
|
96 |
List<ColorTableClass> colorTableClasses = new ArrayList<ColorTableClass>(); |
|
97 |
|
|
98 |
for (int i = 0; i < gdalBandColorTable.GetCount(); i++) { |
|
99 |
String className = i + ""; |
|
100 |
double value = ((byte) i); |
|
101 |
double interpolation = 50.0; |
|
102 |
Color color = gdalBandColorTable.GetColorEntry(i); |
|
103 |
ColorTableClass colorTableClass = |
|
104 |
legendManager.createColorTableClass(className, value, interpolation, color); |
|
105 |
colorTableClasses.add(colorTableClass); |
|
106 |
} |
|
107 |
String colorTableName = rasterGdalProvider.getName() + "_color_table"; |
|
108 |
colorTable = legendManager.createColorTable(colorTableName, colorTableClasses, true); |
|
109 |
// FIXME: De momento devolvemos el primero solo. |
|
110 |
// return colorTable; |
|
111 |
} else { |
|
112 |
List<ColorTableClass> colorTableClasses = new ArrayList<ColorTableClass>(); |
|
113 |
double[] minMax = new double[2]; |
|
114 |
gdalBand.ComputeRasterMinMax(minMax); |
|
115 |
Double increment = (minMax[1] - minMax[0]) / 256; |
|
116 |
|
|
117 |
for (int i = 0; i < 255; i++) { |
|
118 |
String className = i + ""; |
|
119 |
double value = ((minMax[0] + (i * increment))); |
|
120 |
double interpolation = 50.0; |
|
121 |
int intARGB = ((i & 0xFF) << 24) | // alpha |
|
122 |
((i & 0xFF) << 16) | // red |
|
123 |
((i & 0xFF) << 8) | // green |
|
124 |
((i & 0xFF) << 0); // blue |
|
125 |
Color color = new Color(intARGB); |
|
126 |
ColorTableClass colorTableClass = |
|
127 |
legendManager.createColorTableClass(className, value, interpolation, color); |
|
128 |
colorTableClasses.add(colorTableClass); |
|
129 |
} |
|
130 |
String colorTableName = rasterGdalProvider.getName() + "_color_table"; |
|
131 |
colorTable = legendManager.createColorTable(colorTableName, colorTableClasses, true); |
|
132 |
// FIXME: De momento devolvemos el primero solo. |
|
133 |
// return colorTable; |
|
134 |
} |
|
135 |
colorInterpretation.setPalette(colorTable); |
|
136 |
colorInterpretation.setPaletteBand(bandNumber); |
|
137 |
} |
|
138 |
} |
|
139 |
|
|
140 |
return colorInterpretation; |
|
141 |
} |
|
142 |
|
|
143 |
private void guessingColorInterpretation(String[] bandColorInterpretations){ |
|
144 |
//FIXME:Intenta suponer cual es la forma correcta de interpretar los colores en funcion del numero de bandas |
|
145 |
//Seguramente haya que arreglarlo cuando haya GUI para que el usuario pueda especificar la forma correcta. |
|
146 |
if (bandColorInterpretations.length==1){ |
|
147 |
if (bandColorInterpretations[0].equals(ColorInterpretation.UNDEFINED_BAND)){ |
|
148 |
bandColorInterpretations[0]=ColorInterpretation.PALETTE_BAND; |
|
149 |
} |
|
150 |
} |
|
151 |
if (bandColorInterpretations.length==3 || bandColorInterpretations.length>4){ |
|
152 |
if (bandColorInterpretations[0].equals(ColorInterpretation.UNDEFINED_BAND) || |
|
153 |
bandColorInterpretations[1].equals(ColorInterpretation.UNDEFINED_BAND) || |
|
154 |
bandColorInterpretations[2].equals(ColorInterpretation.UNDEFINED_BAND) ){ |
|
155 |
|
|
156 |
bandColorInterpretations[0]=ColorInterpretation.RED_BAND; |
|
157 |
bandColorInterpretations[1]=ColorInterpretation.GREEN_BAND; |
|
158 |
bandColorInterpretations[2]=ColorInterpretation.BLUE_BAND; |
|
159 |
} |
|
160 |
} |
|
161 |
if (bandColorInterpretations.length==4){ |
|
162 |
if (bandColorInterpretations[0].equals(ColorInterpretation.UNDEFINED_BAND) && |
|
163 |
bandColorInterpretations[1].equals(ColorInterpretation.UNDEFINED_BAND) && |
|
164 |
bandColorInterpretations[2].equals(ColorInterpretation.UNDEFINED_BAND) && |
|
165 |
bandColorInterpretations[3].equals(ColorInterpretation.UNDEFINED_BAND) ){ |
|
166 |
|
|
167 |
bandColorInterpretations[0]=ColorInterpretation.RED_BAND; |
|
168 |
bandColorInterpretations[1]=ColorInterpretation.GREEN_BAND; |
|
169 |
bandColorInterpretations[2]=ColorInterpretation.BLUE_BAND; |
|
170 |
bandColorInterpretations[3]=ColorInterpretation.ALPHA_BAND; |
|
171 |
} else if (bandColorInterpretations[0].equals(ColorInterpretation.RED_BAND) && |
|
172 |
bandColorInterpretations[1].equals(ColorInterpretation.GREEN_BAND) && |
|
173 |
bandColorInterpretations[2].equals(ColorInterpretation.BLUE_BAND) && |
|
174 |
bandColorInterpretations[3].equals(ColorInterpretation.UNDEFINED_BAND) ){ |
|
175 |
|
|
176 |
bandColorInterpretations[3]=ColorInterpretation.ALPHA_BAND; |
|
177 |
|
|
178 |
} |
|
179 |
} |
|
180 |
} |
|
181 |
|
|
182 |
/** |
|
183 |
* Obtiene la cadena que representa el tipo de banda de color. Los tipos posibles son: |
|
184 |
* <UL> |
|
185 |
* <LI>0 = "Undefined" </LI> |
|
186 |
* <LI>1 = "Gray";</LI> |
|
187 |
* <LI>2 = "Palette";</LI> |
|
188 |
* <LI>3 = "Red";</LI> |
|
189 |
* <LI>4 = "Green";</LI> |
|
190 |
* <LI>5 = "Blue";</LI> |
|
191 |
* <LI>6 = "Alpha";</LI> |
|
192 |
* <LI>7 = "Hue";</LI> |
|
193 |
* <LI>8 = "Saturation";</LI> |
|
194 |
* <LI>9 = "Lightness";</LI> |
|
195 |
* <LI>10 = "Cyan";</LI> |
|
196 |
* <LI>11 = "Magenta";</LI> |
|
197 |
* <LI>12 = "Yellow";</LI> |
|
198 |
* <LI>13 = "Black";</LI> |
|
199 |
* <LI>14 = "YCbCr_Y";</LI> |
|
200 |
* <LI>15 = "YCbCr_Cb";</LI> |
|
201 |
* <LI>16 = "YCbCr_Cr";</LI> |
|
202 |
* </UL> |
|
203 |
* @return Cadena con el nombre del tipo de banda de colorn |
|
204 |
*/ |
|
205 |
private String colorInterpretationFromGdal(int gdalCode){ |
|
206 |
String gdalNameCI=gdal.GetColorInterpretationName(gdalCode); |
|
207 |
|
|
208 |
switch (gdalNameCI) { |
|
209 |
case "Undefined" : |
|
210 |
return ColorInterpretation.UNDEFINED_BAND; |
|
211 |
case "Gray" : |
|
212 |
return ColorInterpretation.GRAY_BAND; |
|
213 |
case "Palette" : |
|
214 |
return ColorInterpretation.PALETTE_BAND; |
|
215 |
case "Red" : |
|
216 |
return ColorInterpretation.RED_BAND; |
|
217 |
case "Green" : |
|
218 |
return ColorInterpretation.GREEN_BAND; |
|
219 |
case "Blue" : |
|
220 |
return ColorInterpretation.BLUE_BAND; |
|
221 |
case "Alpha" : |
|
222 |
return ColorInterpretation.ALPHA_BAND; |
|
223 |
case "Hue" : |
|
224 |
return ColorInterpretation.HUE_BAND; |
|
225 |
case "Saturation" : |
|
226 |
return ColorInterpretation.SATURATION_BAND; |
|
227 |
case "Lightness" : |
|
228 |
return ColorInterpretation.LIGHTNESS_BAND; |
|
229 |
case "Cyan" : |
|
230 |
return ColorInterpretation.CYAN_BAND; |
|
231 |
case "Magenta" : |
|
232 |
return ColorInterpretation.MAGENTA_BAND; |
|
233 |
case "Yellow" : |
|
234 |
return ColorInterpretation.YELLOW_BAND; |
|
235 |
case "Black" : |
|
236 |
return ColorInterpretation.BLACK_BAND; |
|
237 |
case "YCbCr_Y" : |
|
238 |
return ColorInterpretation.YCBCR_Y_BAND; |
|
239 |
case "YCbCr_Cb" : |
|
240 |
return ColorInterpretation.YCBCR_CB_BAND; |
|
241 |
case "YCbCr_Cr" : |
|
242 |
return ColorInterpretation.YCBCR_CR_BAND; |
|
243 |
default: |
|
244 |
return ColorInterpretation.UNDEFINED_BAND; |
|
245 |
} |
|
246 |
} |
|
247 |
|
|
248 |
@Override |
|
249 |
public Object clone() throws CloneNotSupportedException { |
|
250 |
return super.clone(); |
|
251 |
} |
|
252 |
} |
branches/org.gvsig.gdal-2018a/org.gvsig.gdal.prov/org.gvsig.gdal.raster/org.gvsig.gdal.raster.provider.legend/src/main/java/org/gvsig/raster/gdal/provider/legend/RasterGdalGetColorTable.java | ||
---|---|---|
1 |
package org.gvsig.raster.gdal.provider.legend; |
|
2 |
|
|
3 |
import java.awt.Color; |
|
4 |
import java.util.ArrayList; |
|
5 |
import java.util.List; |
|
6 |
|
|
7 |
import org.gdal.gdal.Band; |
|
8 |
import org.gdal.gdal.Dataset; |
|
9 |
|
|
10 |
import org.gvsig.fmap.dal.raster.api.RasterStore; |
|
11 |
import org.gvsig.raster.gdal.provider.AbstractRasterGdalStoreProvider; |
|
12 |
import org.gvsig.raster.gdal.provider.DisposableGdalDataSet; |
|
13 |
import org.gvsig.raster.lib.legend.api.RasterLegendLocator; |
|
14 |
import org.gvsig.raster.lib.legend.api.RasterLegendManager; |
|
15 |
import org.gvsig.raster.lib.legend.api.colorinterpretation.ColorInterpretation; |
|
16 |
import org.gvsig.raster.lib.legend.api.colortable.ColorTable; |
|
17 |
import org.gvsig.raster.lib.legend.api.colortable.colortableclass.ColorTableClass; |
|
18 |
import org.gvsig.tools.ToolsLocator; |
|
19 |
import org.gvsig.tools.dynobject.DynClass; |
|
20 |
import org.gvsig.tools.dynobject.DynMethod; |
|
21 |
import org.gvsig.tools.dynobject.DynObject; |
|
22 |
import org.gvsig.tools.dynobject.exception.DynMethodException; |
|
23 |
import org.gvsig.tools.dynobject.exception.DynMethodNotSupportedException; |
|
24 |
|
|
25 |
/** |
|
26 |
* Dynamic method to add a get Color Table funcionality |
|
27 |
* @author dmartinezizquierdo |
|
28 |
* |
|
29 |
*/ |
|
30 |
public class RasterGdalGetColorTable implements DynMethod { |
|
31 |
|
|
32 |
private static Integer code = null; |
|
33 |
|
|
34 |
static void register(DynClass storeClass) { |
|
35 |
if (code != null) { |
|
36 |
return; |
|
37 |
} |
|
38 |
code = ToolsLocator.getDynObjectManager() |
|
39 |
.registerDynMethod(storeClass, new RasterGdalGetColorTable()); |
|
40 |
|
|
41 |
} |
|
42 |
|
|
43 |
@Override |
|
44 |
public int getCode() throws DynMethodNotSupportedException { |
|
45 |
return code; |
|
46 |
} |
|
47 |
|
|
48 |
@Override |
|
49 |
public String getDescription() { |
|
50 |
return "Raster GDAL Color Table"; |
|
51 |
} |
|
52 |
|
|
53 |
@Override |
|
54 |
public String getName() { |
|
55 |
return RasterStore.DYNMETHOD_GETCOLORTABLE_NAME; |
|
56 |
} |
|
57 |
|
|
58 |
@Override |
|
59 |
public Object invoke(DynObject self, Object[] args) |
|
60 |
throws DynMethodException { |
|
61 |
ColorTable colorTable = null; |
|
62 |
|
|
63 |
|
|
64 |
try { |
|
65 |
AbstractRasterGdalStoreProvider rasterGdalProvider=(AbstractRasterGdalStoreProvider)self; |
|
66 |
RasterLegendManager legendManager=RasterLegendLocator.getRasterLegendManager(); |
|
67 |
|
|
68 |
DisposableGdalDataSet gdalDataSet = rasterGdalProvider.getGdalDataSet(); |
|
69 |
|
|
70 |
ColorInterpretation colorInterpretation =(ColorInterpretation)rasterGdalProvider. |
|
71 |
invokeDynMethod(RasterStore.DYNMETHOD_GETCOLORINTERPRETATION_NAME, null); |
|
72 |
for (int bandNumber = 1; bandNumber <= gdalDataSet.getRasterCount(); bandNumber++) { |
|
73 |
//Band in GDAL begins in 1, meanwhile we begin in 0 |
|
74 |
int indexColorInterpretation=bandNumber-1; |
|
75 |
if (ColorInterpretation.PALETTE_BAND.equals(colorInterpretation.get(indexColorInterpretation))){ |
|
76 |
Band gdalBand=gdalDataSet.GetRasterBand(bandNumber); |
|
77 |
org.gdal.gdal.ColorTable gdalBandColorTable = gdalBand.GetColorTable(); |
|
78 |
if (gdalBandColorTable!=null){ |
|
79 |
List<ColorTableClass> colorTableClasses=new ArrayList<ColorTableClass>(); |
|
80 |
|
|
81 |
for (int i=0;i<gdalBandColorTable.GetCount();i++){ |
|
82 |
String className=i+""; |
|
83 |
double value=((byte)i); |
|
84 |
double interpolation=50.0; |
|
85 |
Color color=gdalBandColorTable.GetColorEntry(i); |
|
86 |
ColorTableClass colorTableClass = legendManager.createColorTableClass(className, value, interpolation, color); |
|
87 |
colorTableClasses.add(colorTableClass); |
|
88 |
} |
|
89 |
String colorTableName = rasterGdalProvider.getName() + "_color_table"; |
|
90 |
colorTable = legendManager.createColorTable(colorTableName, |
|
91 |
colorTableClasses, true); |
|
92 |
//FIXME: De momento devolvemos el primero solo. |
|
93 |
return colorTable; |
|
94 |
} |
|
95 |
else { |
|
96 |
List<ColorTableClass> colorTableClasses=new ArrayList<ColorTableClass>(); |
|
97 |
double[] minMax=new double[2]; |
|
98 |
gdalBand.ComputeRasterMinMax(minMax); |
|
99 |
Double increment=(minMax[1]-minMax[0])/256; |
|
100 |
|
|
101 |
for (int i=0;i<255;i++){ |
|
102 |
String className=i+""; |
|
103 |
double value=((minMax[0]+(i*increment))); |
|
104 |
double interpolation=50.0; |
|
105 |
int intARGB = ((i & 0xFF) << 24) | // alpha |
|
106 |
((i & 0xFF) << 16) | // red |
|
107 |
((i & 0xFF) << 8) | // green |
|
108 |
((i & 0xFF) << 0); // blue |
|
109 |
Color color=new Color(intARGB); |
|
110 |
ColorTableClass colorTableClass = legendManager.createColorTableClass(className, value, interpolation, color); |
|
111 |
colorTableClasses.add(colorTableClass); |
|
112 |
} |
|
113 |
String colorTableName = rasterGdalProvider.getName() + "_color_table"; |
|
114 |
colorTable = legendManager.createColorTable(colorTableName, |
|
115 |
colorTableClasses, true); |
|
116 |
//FIXME: De momento devolvemos el primero solo. |
|
117 |
return colorTable; |
|
118 |
} |
|
119 |
} |
|
120 |
|
|
121 |
} |
|
122 |
} catch (DynMethodNotSupportedException e) { |
|
123 |
//FIXME |
|
124 |
throw new RuntimeException(e); |
|
125 |
} |
|
126 |
return null; |
|
127 |
} |
|
128 |
|
|
129 |
@Override |
|
130 |
public Object clone() throws CloneNotSupportedException { |
|
131 |
return super.clone(); |
|
132 |
} |
|
133 |
} |
branches/org.gvsig.gdal-2018a/org.gvsig.gdal.prov/org.gvsig.gdal.raster/org.gvsig.gdal.raster.provider.legend/pom.xml | ||
---|---|---|
1 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|
2 |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
3 |
<modelVersion>4.0.0</modelVersion> |
|
4 |
<parent> |
|
5 |
<groupId>org.gvsig</groupId> |
|
6 |
<artifactId>org.gvsig.gdal.raster</artifactId> |
|
7 |
<version>3.0.0-SNAPSHOT</version> |
|
8 |
</parent> |
|
9 |
<artifactId>org.gvsig.gdal.raster.provider.legend</artifactId> |
|
10 |
<name>${project.artifactId}</name> |
|
11 |
<description>Legend provider for raster gdal</description> |
|
12 |
|
|
13 |
<dependencies> |
|
14 |
<dependency> |
|
15 |
<groupId>org.gvsig</groupId> |
|
16 |
<artifactId>org.gvsig.gdal.raster.provider</artifactId> |
|
17 |
<scope>compile</scope> |
|
18 |
</dependency> |
|
19 |
<dependency> |
|
20 |
<groupId>org.gvsig</groupId> |
|
21 |
<artifactId>org.gvsig.fmap.mapcontext.api</artifactId> |
|
22 |
<scope>compile</scope> |
|
23 |
</dependency> |
|
24 |
</dependencies> |
|
25 |
</project> |
branches/org.gvsig.gdal-2018a/org.gvsig.gdal.prov/org.gvsig.gdal.raster/org.gvsig.gdal.raster.provider/src/test/java/org/gvsig/raster/gdal/provider/RasterGdalStoreProviderTest.java | ||
---|---|---|
1 |
package org.gvsig.raster.gdal.provider; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import java.net.URL; |
|
5 |
|
|
6 |
import org.cresques.cts.IProjection; |
|
7 |
|
|
8 |
import org.gvsig.fmap.crs.CRSFactory; |
|
9 |
import org.gvsig.fmap.dal.DALLocator; |
|
10 |
import org.gvsig.fmap.dal.DataManager; |
|
11 |
import org.gvsig.fmap.dal.DataServerExplorer; |
|
12 |
import org.gvsig.fmap.dal.DataServerExplorerParameters; |
|
13 |
import org.gvsig.fmap.dal.raster.api.NewRasterStoreParameters; |
|
14 |
import org.gvsig.fmap.dal.raster.api.RasterStore; |
|
15 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters; |
|
16 |
import org.gvsig.fmap.dal.spi.DALSPILocator; |
|
17 |
import org.gvsig.fmap.dal.spi.DataManagerProviderServices; |
|
18 |
import org.gvsig.raster.lib.buffer.api.Buffer; |
|
19 |
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase; |
|
20 |
|
|
21 |
public class RasterGdalStoreProviderTest extends AbstractLibraryAutoInitTestCase { |
|
22 |
|
|
23 |
@Override |
|
24 |
protected void doSetUp() throws Exception { |
|
25 |
|
|
26 |
|
|
27 |
} |
|
28 |
|
|
29 |
/** |
|
30 |
* Tries to copy an store into a new one using gdal provider |
|
31 |
* @throws Exception |
|
32 |
*/ |
|
33 |
public void testGdalCopyStore() throws Exception{ |
|
34 |
IProjection projection = CRSFactory.getCRS("EPSG:23030"); |
|
35 |
final URL url = this.getClass().getResource("/pathcv.png"); |
|
36 |
//The store is created using the PNG provider |
|
37 |
String openingProviderName="PNG"; |
|
38 |
File openedFile=new File(url.toURI()); |
|
39 |
//The store is copied using the GTiff provider |
|
40 |
String storingProviderName="GTiff"; |
|
41 |
String extension="tif"; |
|
42 |
File destFile=new File(openedFile.getParentFile(), "copiedFile."+extension); |
|
43 |
|
|
44 |
DataManager dataManager = DALLocator.getDataManager(); |
|
45 |
try { |
|
46 |
//Opening the store |
|
47 |
RasterGdalStoreProviderFactory gdalFactory= |
|
48 |
(RasterGdalStoreProviderFactory)dataManager.getStoreProviderFactory(openingProviderName); |
|
49 |
RasterGdalFileStoreParameters openParams = (RasterGdalFileStoreParameters)gdalFactory.createParameters(); |
|
50 |
openParams.setFile(openedFile); |
|
51 |
openParams.setCRS(projection); |
|
52 |
|
|
53 |
RasterStore store=null; |
|
54 |
store = (RasterStore) dataManager.openStore(openingProviderName,openParams); |
|
55 |
assertNotNull(store); |
|
56 |
|
|
57 |
//The store is opened and must be copied |
|
58 |
DataManagerProviderServices manager=DALSPILocator.getDataManagerProviderServices(); |
|
59 |
DataServerExplorerParameters eparams = manager.createServerExplorerParameters("FilesystemExplorer"); |
|
60 |
eparams.setDynValue("initialpath","/"); |
|
61 |
DataServerExplorer serverExplorer= manager.createServerExplorer(eparams); |
|
62 |
|
|
63 |
NewRasterStoreParameters newStoreParams =(NewRasterStoreParameters) serverExplorer.getAddParameters(storingProviderName); |
|
64 |
if (newStoreParams instanceof FilesystemStoreParameters) { |
|
65 |
((FilesystemStoreParameters) newStoreParams).setFile(destFile); |
|
66 |
} |
|
67 |
if (newStoreParams instanceof NewRasterStoreParameters) { |
|
68 |
Buffer buffer = store.getRasterSet().clip(store.getEnvelope()); |
|
69 |
((NewRasterStoreParameters) newStoreParams).setBuffer(buffer); |
|
70 |
} |
|
71 |
if (newStoreParams.hasDynValue("compress")) { |
|
72 |
newStoreParams.setDynValue("compress", "NONE"); |
|
73 |
} |
|
74 |
if (newStoreParams.hasDynValue("tfw")) { |
|
75 |
newStoreParams.setDynValue("tfw", true); |
|
76 |
} |
|
77 |
if (newStoreParams.hasDynValue("photometric")) { |
|
78 |
newStoreParams.setDynValue("photometric", "RGB"); |
|
79 |
} |
|
80 |
|
|
81 |
|
|
82 |
if (newStoreParams.isValid() ) { |
|
83 |
serverExplorer.add(storingProviderName, newStoreParams, true); |
|
84 |
} |
|
85 |
assert(destFile.exists()); |
|
86 |
|
|
87 |
}catch (Exception e){ |
|
88 |
fail("Exception happened: "+e.getMessage()); |
|
89 |
}finally{ |
|
90 |
if (destFile!=null && destFile.exists()){ |
|
91 |
destFile.delete(); |
|
92 |
} |
|
93 |
} |
|
94 |
|
|
95 |
} |
|
96 |
|
|
97 |
} |
branches/org.gvsig.gdal-2018a/org.gvsig.gdal.prov/org.gvsig.gdal.raster/org.gvsig.gdal.raster.provider/src/main/java/org/gvsig/raster/gdal/provider/RasterGdalLibrary.java | ||
---|---|---|
1 |
package org.gvsig.raster.gdal.provider; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.Arrays; |
|
5 |
import java.util.List; |
|
6 |
|
|
7 |
import org.apache.commons.lang3.StringUtils; |
|
8 |
import org.gdal.gdal.Driver; |
|
9 |
import org.gdal.gdal.gdal; |
|
10 |
import org.gdal.ogr.ogr; |
|
11 |
import org.gvsig.fmap.dal.DALFileLibrary; |
|
12 |
import org.gvsig.fmap.dal.DALFileLocator; |
|
13 |
import org.gvsig.fmap.dal.DALLibrary; |
|
14 |
import org.gvsig.fmap.dal.FileHelper; |
|
15 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProviderFactory; |
|
16 |
import org.gvsig.fmap.dal.spi.DALSPILocator; |
|
17 |
import org.gvsig.fmap.dal.spi.DataManagerProviderServices; |
|
18 |
import org.gvsig.metadata.exceptions.MetadataException; |
|
19 |
import org.gvsig.tools.ToolsLocator; |
|
20 |
import org.gvsig.tools.dynobject.DynStruct_v2; |
|
21 |
import org.gvsig.tools.dynobject.Tags; |
|
22 |
import org.gvsig.tools.library.AbstractLibrary; |
|
23 |
import org.gvsig.tools.library.LibraryException; |
|
24 |
|
|
25 |
/** |
|
26 |
* Raster GDAL Provider Library to register provider commponents |
|
27 |
* |
|
28 |
* @author dmartinezizquierdo |
|
29 |
* |
|
30 |
*/ |
|
31 |
public class RasterGdalLibrary extends AbstractLibrary { |
|
32 |
|
|
33 |
/** |
|
34 |
* Driver name that must not be used to open files |
|
35 |
*/ |
|
36 |
public static final String[] EXCLUDED_OPEN_DRIVERS={"netCDF"}; |
|
37 |
/** |
|
38 |
* Driver name that must not be used to create new files |
|
39 |
*/ |
|
40 |
public static final String[] EXCLUDED_STORE_DRIVERS={}; |
|
41 |
|
|
42 |
/** |
|
43 |
* This drivers will be not used by GDAL |
|
44 |
*/ |
|
45 |
public static final String[] NOT_REGISTERED_DRIVERS={"PostGISRaster", "WMS", "WCS"}; |
|
46 |
|
|
47 |
|
|
48 |
@Override |
|
49 |
public void doRegistration() { |
|
50 |
registerAsServiceOf(DALLibrary.class); |
|
51 |
require(DALFileLibrary.class); |
|
52 |
} |
|
53 |
|
|
54 |
@Override |
|
55 |
protected void doInitialize() throws LibraryException { |
|
56 |
} |
|
57 |
|
|
58 |
@Override |
|
59 |
protected void doPostInitialize() throws LibraryException { |
|
60 |
List<Throwable> exs = new ArrayList<Throwable>(); |
|
61 |
|
|
62 |
// initialize gdal drivers |
|
63 |
try { |
|
64 |
gdal.AllRegister(); |
|
65 |
ogr.RegisterAll(); |
|
66 |
} catch (RuntimeException e) { |
|
67 |
exs.add(e); |
|
68 |
} |
|
69 |
|
|
70 |
DataManagerProviderServices dataman = |
|
71 |
DALSPILocator.getDataManagerProviderServices(); |
|
72 |
|
|
73 |
//Register supported parameters |
|
74 |
try { |
|
75 |
FileHelper.registerParametersDefinition( |
|
76 |
RasterGdalFileStoreParameters.PARAMETERS_DEFINITION_NAME, |
|
77 |
RasterGdalFileStoreParameters.class, "RasterGdalParameters.xml"); |
|
78 |
} catch (Exception e) { |
|
79 |
exs.add(e); |
|
80 |
} |
|
81 |
|
|
82 |
try { |
|
83 |
FileHelper.registerMetadataDefinition( |
|
84 |
AbstractFileRasterGdalStoreProvider.METADATA_DEFINITION_NAME, |
|
85 |
AbstractFileRasterGdalStoreProvider.class, "RasterGdalMetadata.xml"); |
|
86 |
} catch (MetadataException e) { |
|
87 |
exs.add(e); |
|
88 |
} |
|
89 |
|
|
90 |
try { |
|
91 |
FileHelper.registerParametersDefinition( |
|
92 |
NewRasterGdalStoreParameters.PARAMETERS_DEFINITION_NAME, |
|
93 |
NewRasterGdalStoreParameters.class, "NewRasterGdalStoreParameters.xml"); |
|
94 |
} catch (Exception e) { |
|
95 |
exs.add(e); |
|
96 |
} |
|
97 |
|
|
98 |
try { |
|
99 |
FileHelper.registerParametersDefinition( |
|
100 |
RasterGdalStoreParameters.PARAMETERS_DEFINITION_NAME, |
|
101 |
RasterGdalStoreParameters.class, "RasterGdalParameters.xml"); |
|
102 |
} catch (Exception e) { |
|
103 |
exs.add(e); |
|
104 |
} |
|
105 |
|
|
106 |
List<String> notRegisteredDrivers=Arrays.asList(NOT_REGISTERED_DRIVERS); |
|
107 |
try { |
|
108 |
for (int i = 0; i < gdal.GetDriverCount(); i++) { |
|
109 |
//For each driver must be a StoreProviderFactory and a FilesystemProviderFactory |
|
110 |
Driver gdalDriver = gdal.GetDriver(i); |
|
111 |
String driverName = gdalDriver.getShortName(); |
|
112 |
if (notRegisteredDrivers.contains(driverName)){ |
|
113 |
continue; |
|
114 |
} |
|
115 |
|
|
116 |
String provName =driverName; |
|
117 |
//RasterGdalStoreProvider.NAME + "_" + driverName; |
|
118 |
String provDescription = AbstractFileRasterGdalStoreProvider.DESCRIPTION |
|
119 |
+ " for driver " + driverName; |
|
120 |
|
|
121 |
String openParams; |
|
122 |
//Try to load specific params with file |
|
123 |
try { |
|
124 |
openParams=RasterGdalFileStoreParameters.PARAMETERS_DEFINITION_NAME+"_"+driverName; |
|
125 |
FileHelper.registerParametersDefinition( |
|
126 |
openParams, |
|
127 |
RasterGdalFileStoreParameters.class, "RasterGdalParameters.xml"); |
|
128 |
// FileHelper.registerParametersDefinition( |
|
129 |
// openParams, |
|
130 |
// RasterGdalFileStoreParameters.class, "RasterGdalParameters.xml"); |
|
131 |
} catch (Exception e) { |
|
132 |
try { |
|
133 |
//Try to load specific params without file |
|
134 |
openParams=RasterGdalStoreParameters.PARAMETERS_DEFINITION_NAME+"_"+driverName; |
|
135 |
FileHelper.registerParametersDefinition( |
|
136 |
openParams, |
|
137 |
RasterGdalStoreParameters.class, "RasterGdalParameters.xml"); |
|
138 |
} catch (Exception e1) { |
|
139 |
//If specific params are not found, generic ones with file are used |
|
140 |
openParams=RasterGdalFileStoreParameters.PARAMETERS_DEFINITION_NAME; |
|
141 |
} |
|
142 |
|
|
143 |
} |
|
144 |
|
|
145 |
//The store provider factory is created |
|
146 |
RasterGdalStoreProviderFactory providerFactory=null; |
|
147 |
try { |
|
148 |
if (!dataman.getStoreProviders().contains(provName)) { |
|
149 |
providerFactory= new RasterGdalStoreProviderFactory(provName, |
|
150 |
provDescription, |
|
151 |
gdalDriver, openParams); |
|
152 |
dataman.registerStoreProviderFactory(providerFactory); |
|
153 |
|
|
154 |
} |
|
155 |
} catch (RuntimeException e) { |
|
156 |
exs.add(e); |
|
157 |
} |
|
158 |
|
|
159 |
|
|
160 |
String newParams; |
|
161 |
//Try to load specific params |
|
162 |
try { |
|
163 |
newParams=NewRasterGdalStoreParameters.PARAMETERS_DEFINITION_NAME+"_"+driverName; |
|
164 |
FileHelper.registerParametersDefinition( |
|
165 |
newParams, |
|
166 |
NewRasterGdalStoreParameters.class, "NewRasterGdalStoreParameters.xml"); |
|
167 |
} catch (Exception e) { |
|
168 |
//If specific params are not found, generic ones are used |
|
169 |
newParams=NewRasterGdalStoreParameters.PARAMETERS_DEFINITION_NAME; |
|
170 |
} |
|
171 |
|
|
172 |
// The FilesystemServerExplorerProvider Factory is created |
|
173 |
FilesystemServerExplorerProviderFactory filesystemProviderFactory =null; |
|
174 |
try { |
|
175 |
if (providerFactory!=null){ |
|
176 |
filesystemProviderFactory = (FilesystemServerExplorerProviderFactory) |
|
177 |
new RasterGdalFileSystemServerProviderFactory( |
|
178 |
providerFactory, newParams); |
|
179 |
|
|
180 |
DALFileLocator.getFilesystemServerExplorerManager() |
|
181 |
.registerProviderFactory(filesystemProviderFactory); |
|
182 |
} |
|
183 |
} catch (RuntimeException e) { |
|
184 |
exs.add(e); |
|
185 |
} |
|
186 |
|
|
187 |
//The valid extensions from the parameters are added to the filesystem server factory |
|
188 |
String validExtensions=null; |
|
189 |
DynStruct_v2 params = (DynStruct_v2)ToolsLocator.getPersistenceManager().getDefinition(openParams); |
|
190 |
Tags paramsTags=params.getTags(); |
|
191 |
if (paramsTags.has(RasterGdalFileStoreParameters.VALID_EXTENSIONS_TAG_NAME)){ |
|
192 |
validExtensions=(String)paramsTags.get(RasterGdalFileStoreParameters.VALID_EXTENSIONS_TAG_NAME); |
|
193 |
} |
|
194 |
if (filesystemProviderFactory!=null && |
|
195 |
filesystemProviderFactory instanceof RasterGdalFileSystemServerProviderFactory && |
|
196 |
StringUtils.isNotEmpty(validExtensions)){ |
|
197 |
|
|
198 |
String[] extensions=validExtensions.split(","); |
|
199 |
((RasterGdalFileSystemServerProviderFactory)filesystemProviderFactory). |
|
200 |
addAcceptedExtensions(extensions); |
|
201 |
} |
|
202 |
} |
|
203 |
|
|
204 |
} catch (RuntimeException e) { |
|
205 |
exs.add(e); |
|
206 |
} |
|
207 |
|
|
208 |
if (exs.size() > 0) { |
|
209 |
throw new LibraryException(this.getClass(), exs); |
|
210 |
} |
|
211 |
|
|
212 |
} |
|
213 |
|
|
214 |
} |
branches/org.gvsig.gdal-2018a/org.gvsig.gdal.prov/org.gvsig.gdal.raster/org.gvsig.gdal.raster.provider/src/main/java/org/gvsig/raster/gdal/provider/DisposableGdalDataSet.java | ||
---|---|---|
1 |
/* gvSIG. Desktop Geographic Information System. |
|
2 |
* |
|
3 |
* Copyright ? 2007-2018 gvSIG Association |
|
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., 51 Franklin Street, Fifth Floor, Boston, |
|
18 |
* MA 02110-1301, USA. |
|
19 |
* |
|
20 |
* For any additional information, do not hesitate to contact us |
|
21 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
22 |
*/ |
|
23 |
package org.gvsig.raster.gdal.provider; |
|
24 |
|
|
25 |
import java.util.Vector; |
|
26 |
|
|
27 |
import org.gdal.gdal.Dataset; |
|
28 |
import org.slf4j.Logger; |
|
29 |
import org.slf4j.LoggerFactory; |
|
30 |
|
|
31 |
import org.gvsig.tools.dispose.impl.AbstractDisposable; |
|
32 |
|
|
33 |
|
|
34 |
/** |
|
35 |
* @author fdiaz |
|
36 |
* |
|
37 |
*/ |
|
38 |
public class DisposableGdalDataSet extends AbstractDisposable { // implements Disposable{ |
|
39 |
|
|
40 |
private static final Logger LOG = |
|
41 |
LoggerFactory.getLogger(DisposableGdalDataSet.class); |
|
42 |
|
|
43 |
// private final Object lock = new Object(); |
|
44 |
// |
|
45 |
// private boolean disposed = false; |
|
46 |
|
|
47 |
private Dataset gdalDataSet; |
|
48 |
|
|
49 |
|
|
50 |
/** |
|
51 |
* @param cPtr |
|
52 |
* @param cMemoryOwn |
|
53 |
*/ |
|
54 |
public DisposableGdalDataSet(Dataset gdalDataSet) { |
|
55 |
super(); |
|
56 |
|
|
57 |
this.gdalDataSet = gdalDataSet; |
|
58 |
// if(ToolsLocator.getDisposableManager() != null) { |
|
59 |
// ToolsLocator.getDisposableManager().bind(this); |
|
60 |
// } else { |
|
61 |
// LOG.warn("Can't retrieve the disposable manager,"); |
|
62 |
// } |
|
63 |
|
|
64 |
} |
|
65 |
|
|
66 |
// @Override |
|
67 |
// public void dispose() { |
|
68 |
// synchronized (lock) { |
|
69 |
// // Check if we have already been disposed, and don't do it again |
|
70 |
// if (!disposed) { |
|
71 |
// if ( ToolsLocator.getDisposableManager().release(this) ) { |
|
72 |
// try { |
|
73 |
// doDispose(); |
|
74 |
// } catch (BaseException ex) { |
|
75 |
// LOG.error("Error performing dispose", ex); |
|
76 |
// } |
|
77 |
// disposed = true; |
|
78 |
// } |
|
79 |
// } |
|
80 |
// } |
|
81 |
// } |
|
82 |
// |
|
83 |
// protected void dispose(Disposable disposable) { |
|
84 |
// DisposeUtils.dispose(disposable); |
|
85 |
// } |
|
86 |
|
|
87 |
|
|
88 |
/** |
|
89 |
* @return the gdalDataSet |
|
90 |
*/ |
|
91 |
public Dataset getDataSet() { |
|
92 |
return gdalDataSet; |
|
93 |
} |
|
94 |
|
|
95 |
// /** |
|
96 |
// * @param gdalDataSet the gdalDataSet to set |
|
97 |
// */ |
|
98 |
// public void setDataSet(Dataset gdalDataSet) { |
|
99 |
// this.gdalDataSet = gdalDataSet; |
|
100 |
// } |
|
101 |
|
|
102 |
@Override |
|
103 |
protected void doDispose() { |
|
104 |
if (this.gdalDataSet != null) { |
|
105 |
this.gdalDataSet.delete(); |
|
106 |
gdalDataSet = null; |
|
107 |
} |
|
108 |
} |
|
109 |
|
|
110 |
/** |
|
111 |
* @return |
|
112 |
*/ |
|
113 |
public int getRasterYSize() { |
|
114 |
return getDataSet().getRasterYSize(); |
|
115 |
} |
|
116 |
|
|
117 |
/** |
|
118 |
* @return |
|
119 |
*/ |
|
120 |
public int getRasterXSize() { |
|
121 |
return getDataSet().getRasterXSize(); |
|
122 |
} |
|
123 |
|
|
124 |
/** |
|
125 |
* @return |
|
126 |
*/ |
|
127 |
public int getRasterCount() { |
|
128 |
return getDataSet().getRasterCount(); |
|
129 |
} |
|
130 |
|
|
131 |
/** |
|
132 |
* @param gdalBandNumber |
|
133 |
* @return |
|
134 |
*/ |
|
135 |
public org.gdal.gdal.Band GetRasterBand(int gdalBandNumber) { |
|
136 |
return getDataSet().GetRasterBand(gdalBandNumber); |
|
137 |
} |
|
138 |
|
|
139 |
/** |
|
140 |
* @return |
|
141 |
*/ |
|
142 |
public double[] GetGeoTransform() { |
|
143 |
return getDataSet().GetGeoTransform(); |
|
144 |
} |
|
145 |
|
|
146 |
/** |
|
147 |
* @return |
|
148 |
*/ |
|
149 |
public Vector<?> GetGCPs() { |
|
150 |
return getDataSet().GetGCPs(); |
|
151 |
} |
|
152 |
|
|
153 |
/** |
|
154 |
* @return |
|
155 |
*/ |
|
156 |
public int GetGCPCount() { |
|
157 |
return getDataSet().GetGCPCount(); |
|
158 |
} |
|
159 |
|
|
160 |
/** |
|
161 |
* |
|
162 |
*/ |
|
163 |
public void delete() { |
|
164 |
getDataSet().delete(); |
|
165 |
} |
|
166 |
|
|
167 |
|
|
168 |
} |
branches/org.gvsig.gdal-2018a/org.gvsig.gdal.prov/org.gvsig.gdal.raster/org.gvsig.gdal.raster.provider/src/main/java/org/gvsig/raster/gdal/provider/DefaultRasterGdalStoreProvider.java | ||
---|---|---|
1 |
package org.gvsig.raster.gdal.provider; |
|
2 |
|
|
3 |
import org.gdal.gdal.Driver; |
|
4 |
|
|
5 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
6 |
import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
|
7 |
import org.gvsig.raster.lib.buffer.api.BufferDimensions; |
|
8 |
import org.gvsig.tools.dynobject.DynObject; |
|
9 |
|
|
10 |
/** |
|
11 |
* Raster Gdal provider to raster files |
|
12 |
* @author dmartinezizquierdo |
|
13 |
* |
|
14 |
*/ |
|
15 |
public class DefaultRasterGdalStoreProvider |
|
16 |
extends AbstractFileRasterGdalStoreProvider { |
|
17 |
|
|
18 |
protected DefaultRasterGdalStoreProvider( |
|
19 |
NewRasterGdalStoreParameters params, Driver gdalDriver) { |
|
20 |
super(params, gdalDriver); |
|
21 |
} |
|
22 |
|
|
23 |
protected DefaultRasterGdalStoreProvider(RasterGdalFileStoreParameters params, |
|
24 |
DataStoreProviderServices storeServices, DynObject metadata) |
|
25 |
throws InitializeException { |
|
26 |
super(params, storeServices, metadata); |
|
27 |
} |
|
28 |
|
|
29 |
public DefaultRasterGdalStoreProvider(RasterGdalFileStoreParameters params, |
|
30 |
DataStoreProviderServices storeServices) throws InitializeException { |
|
31 |
super(params, storeServices); |
|
32 |
} |
|
33 |
} |
branches/org.gvsig.gdal-2018a/org.gvsig.gdal.prov/org.gvsig.gdal.raster/org.gvsig.gdal.raster.provider/src/main/java/org/gvsig/raster/gdal/provider/RasterGdalBandTileManager.java | ||
---|---|---|
1 |
package org.gvsig.raster.gdal.provider; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
import java.nio.Buffer; |
|
5 |
import java.nio.ByteBuffer; |
|
6 |
import java.nio.DoubleBuffer; |
|
7 |
import java.nio.FloatBuffer; |
|
8 |
import java.nio.IntBuffer; |
|
9 |
import java.nio.ShortBuffer; |
|
10 |
import java.util.ArrayList; |
|
11 |
import java.util.Hashtable; |
|
12 |
import java.util.LinkedHashMap; |
|
13 |
import java.util.Map; |
|
14 |
import java.util.Set; |
|
15 |
|
|
16 |
import org.gdal.gdal.Band; |
|
17 |
import org.gdal.gdal.Dataset; |
|
18 |
|
|
19 |
import org.gvsig.raster.lib.buffer.api.BandInfo; |
|
20 |
import org.gvsig.raster.lib.buffer.api.BandPageManager; |
|
21 |
import org.gvsig.raster.lib.buffer.api.BandTileManager; |
|
22 |
import org.gvsig.raster.lib.buffer.api.BufferLocator; |
|
23 |
import org.gvsig.raster.lib.buffer.api.BufferManager; |
|
24 |
import org.gvsig.raster.lib.buffer.api.TileStruct; |
|
25 |
import org.gvsig.tools.dispose.impl.AbstractDisposable; |
|
26 |
import org.gvsig.tools.exception.BaseException; |
|
27 |
|
|
28 |
/** |
|
29 |
* Band Page Manager for a Memory Image |
|
30 |
* |
|
31 |
* @author dmartinezizquierdo |
|
32 |
* |
|
33 |
*/ |
|
34 |
@Deprecated |
|
35 |
public class RasterGdalBandTileManager extends AbstractDisposable implements BandTileManager { |
|
36 |
|
|
37 |
private Band gdalBand; |
|
38 |
private Dataset gdalDataSet; |
|
39 |
|
|
40 |
private int rowsPerTile; |
|
41 |
private int columnsPerTile; |
|
42 |
|
|
43 |
/** |
|
44 |
* @param gdalDataSet |
|
45 |
* @param bandNumber |
|
46 |
*/ |
|
47 |
public RasterGdalBandTileManager(Dataset gdalDataSet, int bandNumber, int rowsPerTile, int columnsPerTile) { |
|
48 |
this.gdalDataSet = gdalDataSet; |
|
49 |
this.gdalBand = gdalDataSet.GetRasterBand(bandNumber); |
|
50 |
this.rowsPerTile=rowsPerTile; |
|
51 |
this.columnsPerTile=columnsPerTile; |
|
52 |
} |
|
53 |
|
|
54 |
@Override |
|
55 |
public boolean isSupportedSave() { |
|
56 |
return false; |
|
57 |
} |
|
58 |
|
|
59 |
@Override |
|
60 |
public org.gvsig.raster.lib.buffer.api.Band load(int row, int col, int dataType) throws IOException { |
|
61 |
//FIXME: |
|
62 |
// Comentarizado para que me deje compilar. |
|
63 |
// Esta clase no va a ser necesaria porque gdal se va a a paginar a franjas en lugar de a tiles. |
|
64 |
|
|
65 |
// int xOffset = col; |
|
66 |
// int xSize = cols; |
|
67 |
// int yOffset = row; |
|
68 |
// int ySize = rows; |
|
69 |
// buffer.rewind(); |
|
70 |
// |
|
71 |
// switch (dataType) { |
|
72 |
// case BufferManager.TYPE_INT: |
|
73 |
// gdalBand.ReadRaster(xOffset, yOffset, xSize, ySize, ((IntBuffer) buffer).array()); |
|
74 |
// break; |
|
75 |
// case BufferManager.TYPE_BYTE: |
|
76 |
// gdalBand.ReadRaster(xOffset, yOffset, xSize, ySize, ((ByteBuffer) buffer).array()); |
|
77 |
// break; |
|
78 |
// case BufferManager.TYPE_DOUBLE: |
|
79 |
// gdalBand.ReadRaster(xOffset, yOffset, xSize, ySize, ((DoubleBuffer) buffer).array()); |
|
80 |
// break; |
|
81 |
// case BufferManager.TYPE_FLOAT: |
|
82 |
// gdalBand.ReadRaster(xOffset, yOffset, xSize, ySize, ((FloatBuffer) buffer).array()); |
|
83 |
// break; |
|
84 |
// case BufferManager.TYPE_SHORT: |
|
85 |
// case BufferManager.TYPE_USHORT: |
|
86 |
// gdalBand.ReadRaster(xOffset, yOffset, xSize, ySize, ((ShortBuffer) buffer).array()); |
|
87 |
// break; |
|
88 |
// } |
|
89 |
|
|
90 |
return null; |
|
91 |
} |
|
92 |
|
|
93 |
@Override |
|
94 |
public void save(Buffer buffer, int row, int rows, int col, int cols,int dataType) throws IOException { |
|
95 |
throw new UnsupportedOperationException(); |
|
96 |
|
|
97 |
} |
|
98 |
|
|
99 |
@Override |
|
100 |
public BandInfo getBandInfo() { |
|
101 |
BufferManager bufferManager = BufferLocator.getBufferManager(); |
|
102 |
String description = gdalBand.GetDescription(); |
|
103 |
|
|
104 |
Map<Object, Object> values = new LinkedHashMap<Object, Object>(); |
|
105 |
values.put("X size", gdalBand.getXSize()); |
|
106 |
values.put("Y size", gdalBand.getYSize()); |
|
107 |
values.put("NoData value", this.getNoData(gdalBand)); |
|
108 |
values.put("Block X size", gdalBand.GetBlockXSize()); |
|
109 |
values.put("Block Y size", gdalBand.GetBlockYSize()); |
|
110 |
values.put("Unit type", gdalBand.GetUnitType()); |
|
111 |
|
|
112 |
Hashtable metadataDict = gdalBand.GetMetadata_Dict(); |
|
113 |
Set keySet = metadataDict.keySet(); |
|
114 |
for (Object object : keySet) { |
|
115 |
values.put(object, metadataDict.get(keySet)); |
|
116 |
} |
|
117 |
|
|
118 |
return bufferManager.createBandInfo(gdalBand.GetBand(), String.valueOf(gdalBand.GetBand()), |
|
119 |
description, |
|
120 |
AbstractFileRasterGdalStoreProvider.getRasterBufTypeFromGdalType(gdalBand.getDataType()), |
|
121 |
new ArrayList<Map.Entry<Object, Object>>(values.entrySet())); |
|
122 |
} |
|
123 |
|
|
124 |
private Object getNoData(Band gdalBand) { |
|
125 |
Double[] noDataValueResult = new Double[1]; |
|
126 |
gdalBand.GetNoDataValue(noDataValueResult); |
|
127 |
Double noData = noDataValueResult[0]; |
|
128 |
return noData; |
|
129 |
} |
|
130 |
|
|
131 |
@Override |
|
132 |
public int getRowsPerTile() { |
|
133 |
return this.rowsPerTile; |
|
134 |
} |
|
135 |
|
|
136 |
@Override |
|
137 |
public int getColumnsPerTile() { |
|
138 |
return this.columnsPerTile; |
|
139 |
} |
|
140 |
|
|
141 |
@Override |
|
142 |
public TileStruct getTileStruct() { |
|
143 |
// TODO Auto-generated method stub |
|
144 |
return null; |
|
145 |
} |
|
146 |
|
|
147 |
@Override |
|
148 |
protected void doDispose() throws BaseException { |
|
149 |
this.gdalDataSet = null; |
|
150 |
this.gdalBand = null; |
|
151 |
} |
|
152 |
|
|
153 |
} |
branches/org.gvsig.gdal-2018a/org.gvsig.gdal.prov/org.gvsig.gdal.raster/org.gvsig.gdal.raster.provider/src/main/java/org/gvsig/raster/gdal/provider/RasterGdalFileSystemServerProviderFactory.java | ||
---|---|---|
1 |
package org.gvsig.raster.gdal.provider; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import java.util.Arrays; |
|
5 |
import java.util.HashSet; |
|
6 |
import java.util.Set; |
|
7 |
|
|
8 |
import org.apache.commons.io.FilenameUtils; |
|
9 |
import org.gdal.gdal.Driver; |
|
10 |
import org.gdal.gdal.gdal; |
|
11 |
import org.gdal.gdalconst.gdalconstConstants; |
|
12 |
import org.gvsig.fmap.dal.DataServerExplorer; |
|
13 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
14 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProvider; |
|
15 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProviderFactory; |
|
16 |
|
|
17 |
/** |
|
18 |
* Factory for GDAL filesystem providers |
|
19 |
* @author dmartinezizquierdo |
|
20 |
* |
|
21 |
*/ |
|
22 |
public class RasterGdalFileSystemServerProviderFactory |
|
23 |
implements FilesystemServerExplorerProviderFactory { |
|
24 |
|
|
25 |
private RasterGdalStoreProviderFactory providerFactory; |
|
26 |
private String newParams; |
|
27 |
private Set<String> validExtensions; |
|
28 |
|
|
29 |
/** |
|
30 |
* Constructor |
|
31 |
* @param providerFactory |
|
32 |
* @param newParams Definition name of the params used to create a new store |
|
33 |
*/ |
|
34 |
public RasterGdalFileSystemServerProviderFactory(RasterGdalStoreProviderFactory providerFactory, String newParams){ |
|
35 |
this.providerFactory=providerFactory; |
|
36 |
this.newParams=newParams; |
|
37 |
init(); |
|
38 |
} |
|
39 |
|
|
40 |
private void init(){ |
|
41 |
this.validExtensions=new HashSet<String>(); |
|
42 |
String driverExtension=(String)getDriver().GetMetadata_Dict().get(gdalconstConstants.GDAL_DMD_EXTENSION); |
|
43 |
//At least the driver given extension is always accepted (more can be defined in its parameters) |
|
44 |
// GDAL_DMD_EXTENSION only returns an extension. GDAL_DMD_EXTENSIONS should be used instead in GDAL 2.0. |
|
45 |
// GDAL_DMD_EXTENSIONS returns a list of accepted extensions separated by a blank |
|
46 |
// Meanwhile, most common extensions are added defined in the xml parameters |
|
47 |
if (driverExtension!=null){ |
|
48 |
validExtensions.add(driverExtension); |
|
49 |
} |
|
50 |
} |
|
51 |
|
|
52 |
/** |
|
53 |
* Adds valid extensions to be accepted by the driver ({"jpg","jpeg","jp2",...}) |
|
54 |
* @param extensions |
|
55 |
*/ |
|
56 |
public void addAcceptedExtensions(String[] extensions){ |
|
57 |
if (extensions!=null){ |
|
58 |
for (String extension:extensions){ |
|
59 |
validExtensions.add(extension.trim()); |
|
60 |
} |
|
61 |
} |
|
62 |
} |
|
63 |
|
|
64 |
@Override |
|
65 |
public FilesystemServerExplorerProvider createProvider() throws InitializeException { |
|
66 |
return new RasterGdalFileSystemServerProvider(this); |
|
67 |
} |
|
68 |
|
|
69 |
@Override |
|
70 |
public boolean accept(File file) { |
|
71 |
//If the driver is in the list to be avoided, it will not be opened |
|
72 |
String drvName=providerFactory.getDriver().getShortName(); |
|
73 |
if ( Arrays.asList(RasterGdalLibrary.EXCLUDED_OPEN_DRIVERS).contains(drvName) ){ |
|
74 |
return false; |
|
75 |
} |
|
76 |
|
|
77 |
if (isAcceptedExtension(file)){ |
|
78 |
if (!file.exists()) { |
|
79 |
return true; |
|
80 |
} |
|
81 |
return isAcceptedByDriver(file); |
|
82 |
|
|
83 |
|
|
84 |
} |
|
85 |
|
|
86 |
return false; |
|
87 |
} |
|
88 |
|
|
89 |
private Driver getDriver(){ |
|
90 |
return providerFactory.getDriver(); |
|
91 |
} |
|
92 |
|
|
93 |
/** |
|
94 |
* Return true if the File extension is accepted by the FileSystemServerProvider |
|
95 |
* @param file |
|
96 |
* @return |
|
97 |
*/ |
|
98 |
private boolean isAcceptedExtension(File file) { |
|
99 |
if (file!=null){ |
|
100 |
String extension=FilenameUtils.getExtension(file.getName()); |
|
101 |
if (validExtensions != null && !validExtensions.isEmpty()) { |
|
102 |
for (String validExtension : validExtensions) { |
|
103 |
if (validExtension.equalsIgnoreCase(extension)) { |
|
104 |
return true; |
|
105 |
} |
|
106 |
} |
|
107 |
} else { |
|
108 |
return true; |
|
109 |
} |
|
110 |
|
|
111 |
} |
|
112 |
return false; |
|
113 |
} |
|
114 |
|
|
115 |
/** |
|
116 |
* Returns true if the driver can open the file |
|
117 |
* @param file |
|
118 |
* @return |
|
119 |
*/ |
|
120 |
private boolean isAcceptedByDriver(File file) { |
|
121 |
String drvName=getDriver().getShortName(); |
|
122 |
|
|
123 |
Driver openingDriver=null; |
|
124 |
openingDriver = gdal.IdentifyDriver(file.getAbsolutePath()); |
|
125 |
|
|
126 |
if (openingDriver==null){ |
|
127 |
return false; |
|
128 |
} |
|
129 |
String openingDrvName=openingDriver.getShortName(); |
|
130 |
return drvName.equalsIgnoreCase(openingDrvName); |
|
131 |
} |
|
132 |
|
|
133 |
@Override |
|
134 |
public int allowCreate() { |
|
135 |
//If the driver is in the list to be avoided, it will not be created |
|
136 |
String drvName=getDriver().getShortName(); |
|
137 |
if ( Arrays.asList(RasterGdalLibrary.EXCLUDED_STORE_DRIVERS).contains(drvName) ){ |
|
138 |
return NO; |
|
139 |
} |
|
140 |
String allowCreate=(String)getDriver().GetMetadata_Dict().get(gdalconstConstants.GDAL_DCAP_CREATE); |
|
141 |
String allowCreateCopy=(String)getDriver().GetMetadata_Dict().get(gdalconstConstants.GDAL_DCAP_CREATECOPY); |
|
142 |
|
|
143 |
if ( (allowCreate!=null && allowCreate.equalsIgnoreCase("YES")) || |
|
144 |
(allowCreateCopy!=null && allowCreateCopy.equalsIgnoreCase("YES")) ){ |
|
145 |
return YES; |
|
146 |
}else{ |
|
147 |
return NO; |
|
148 |
} |
|
149 |
} |
|
150 |
|
|
151 |
@Override |
|
152 |
public String getName() { |
|
153 |
return providerFactory.getName(); |
|
154 |
} |
|
155 |
|
|
156 |
@Override |
|
157 |
public String getDescription() { |
|
158 |
return providerFactory.getDescription(); |
|
159 |
} |
|
160 |
|
Also available in: Unified diff