Revision 915 trunk/libraries/libjni-gdal/src/es/gva/cit/jgdal/OGRDataSource.java
OGRDataSource.java | ||
---|---|---|
37 | 37 |
|
38 | 38 |
public class OGRDataSource extends JNIBase{ |
39 | 39 |
|
40 |
public native String getNameNat(long cPtr); |
|
41 |
public native long getLayerNat(long cPtr, int i); |
|
42 |
|
|
43 |
/** |
|
44 |
* Constructor |
|
45 |
* @param cPtr direcci?n de memoria al objeto OGRDataSource de C. |
|
46 |
*/ |
|
47 |
|
|
40 | 48 |
public OGRDataSource(long cPtr){ |
41 | 49 |
this.cPtr=cPtr; |
42 | 50 |
} |
43 | 51 |
|
52 |
/** |
|
53 |
* Obtiene el nombre del datasource |
|
54 |
* @throws GdalException |
|
55 |
* @return Nombre del datasource |
|
56 |
*/ |
|
57 |
|
|
58 |
public String getName()throws GdalException{ |
|
59 |
|
|
60 |
if(cPtr <= 0) |
|
61 |
throw new GdalException("Error en getName(). El constructor ha fallado."); |
|
62 |
|
|
63 |
String name = getNameNat(cPtr); |
|
64 |
|
|
65 |
if(name==null) |
|
66 |
throw new GdalException("Error en getName(). No se ha podido obtener el nombre del datasource."); |
|
67 |
return name; |
|
68 |
} |
|
69 |
|
|
70 |
/** |
|
71 |
* Obtiene el n?mero de capas |
|
72 |
* @throws GdalException |
|
73 |
* @return N?mero de capas |
|
74 |
*/ |
|
75 |
|
|
76 |
public int getLayerCount()throws GdalException{ |
|
77 |
|
|
78 |
String msg1="Error en getLayerCount. El constructor no tuvo exito."; |
|
79 |
String msg2="Error en el conteo de capas."; |
|
80 |
return baseSimpleFunctions(11,msg1,msg2); |
|
81 |
} |
|
82 |
|
|
83 |
/** |
|
84 |
* Obtiene la capa indicada por el ?ndice |
|
85 |
* @throws GdalException |
|
86 |
* @return una capa |
|
87 |
*/ |
|
88 |
|
|
89 |
public OGRLayer getLayer(int i)throws GdalException{ |
|
90 |
|
|
91 |
if(cPtr <= 0) |
|
92 |
throw new GdalException("Error en getLayer(). El constructor no tuvo exito"); |
|
93 |
|
|
94 |
long layer = getLayerNat(cPtr, i); |
|
95 |
|
|
96 |
if(layer<=0) |
|
97 |
throw new GdalException("Error en getLayer(). No se ha podido obtener la capa indicada."); |
|
98 |
|
|
99 |
return new OGRLayer(layer); |
|
100 |
|
|
101 |
} |
|
44 | 102 |
} |
Also available in: Unified diff