svn-gvsig-desktop / trunk / libraries / libjni-gdal / src / es / gva / cit / jogr / OGRFeatureDefn.java @ 945
History | View | Annotate | Download (4.05 KB)
1 |
/**********************************************************************
|
---|---|
2 |
* $Id: OGRFeatureDefn.java 945 2005-01-12 18:05:23Z igbrotru $
|
3 |
*
|
4 |
* Name: OGRFeatureDefn.java
|
5 |
* Project: JGDAL. Interface java to gdal (Frank Warmerdam).
|
6 |
* Purpose:
|
7 |
* Author: Nacho Brodin, brodin_ign@gva.es
|
8 |
*
|
9 |
**********************************************************************/
|
10 |
/*Copyright (C) 2004 Nacho Brodin <brodin_ign@gva.es>
|
11 |
|
12 |
This program is free software; you can redistribute it and/or
|
13 |
modify it under the terms of the GNU General Public License
|
14 |
as published by the Free Software Foundation; either version 2
|
15 |
of the License, or (at your option) any later version.
|
16 |
|
17 |
This program is distributed in the hope that it will be useful,
|
18 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
19 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
20 |
GNU General Public License for more details.
|
21 |
|
22 |
You should have received a copy of the GNU General Public License
|
23 |
along with this program; if not, write to the Free Software
|
24 |
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
25 |
*/
|
26 |
|
27 |
package es.gva.cit.jogr; |
28 |
|
29 |
|
30 |
/**
|
31 |
*
|
32 |
* @author Nacho Brodin <brodin_ign@gva.es>.<BR> Equipo de desarrollo gvSIG.<BR> http://www.gvsig.gva.es
|
33 |
* @version 0.0
|
34 |
* @link http://www.gvsig.gva.es
|
35 |
*/
|
36 |
|
37 |
public class OGRFeatureDefn extends JNIBase{ |
38 |
|
39 |
|
40 |
private native String getNameNat(long cPtr); |
41 |
private native int getGeomTypeNat(long cPtr); |
42 |
private native void FreeOGRFeatureDefnNat(long cPtr); |
43 |
|
44 |
/**
|
45 |
* Constructor
|
46 |
* @param cPtr direcci?n de memoria al objeto OGRFeatureDefn de C.
|
47 |
*/
|
48 |
|
49 |
public OGRFeatureDefn(long cPtr){ |
50 |
this.cPtr=cPtr;
|
51 |
} |
52 |
|
53 |
/**
|
54 |
* Obtiene el nombre de la feature
|
55 |
* @throws OGRException
|
56 |
* @return Nombre de la feature
|
57 |
*/
|
58 |
|
59 |
public String getName()throws OGRException{ |
60 |
|
61 |
if(cPtr <= 0) |
62 |
throw new OGRException("Error en getName(). El constructor ha fallado."); |
63 |
|
64 |
String name = getNameNat(cPtr);
|
65 |
|
66 |
if(name==null) |
67 |
throw new OGRException("Error en getName(). No se ha podido obtener el nombre."); |
68 |
return name;
|
69 |
} |
70 |
|
71 |
/**
|
72 |
* Obtiene el tipo de geometria
|
73 |
* @throws OGRException
|
74 |
* @return Tipo de geometria
|
75 |
*/
|
76 |
|
77 |
public String getGeomType()throws OGRException{ |
78 |
|
79 |
if(cPtr <= 0) |
80 |
throw new OGRException("Error en getGeomType(). El constructor ha fallado."); |
81 |
|
82 |
int tipo = getGeomTypeNat(cPtr);
|
83 |
|
84 |
if(tipo<0 || tipo>16) |
85 |
throw new OGRException("Error en getGeomType(). No se ha podido obtener un tipo de geometria valido."); |
86 |
|
87 |
String tipogeom=null; |
88 |
switch(tipo){
|
89 |
case 0:tipogeom="wkbUnknown";break; /* non-standard */ |
90 |
case 1:tipogeom="wkbPoint"; break; /* rest are standard WKB type codes */ |
91 |
case 2:tipogeom="wkbLineString";break; |
92 |
case 3:tipogeom="wkbPolygon";break; |
93 |
case 4:tipogeom="wkbMultiPoint";break; |
94 |
case 5:tipogeom="wkbMultiLineString";break; |
95 |
case 6:tipogeom="wkbMultiPolygon";break; |
96 |
case 7:tipogeom="wkbGeometryCollection";break; |
97 |
case 8:tipogeom="wkbNone";break; /* non-standard, for pure attribute records */ |
98 |
case 9:tipogeom="wkbLinearRing";break; /* non-standard, just for createGeometry() */ |
99 |
case 10:tipogeom="wkbPoint25D";break; /* 2.5D extensions as per 99-402 */ |
100 |
case 11:tipogeom="wkbLineString25D";break; |
101 |
case 12:tipogeom="wkbPolygon25D";break; |
102 |
case 13:tipogeom="wkbMultiPoint25D";break; |
103 |
case 14:tipogeom="wkbMultiLineString25D";break; |
104 |
case 15:tipogeom="wkbMultiPolygon25D";break; |
105 |
case 16:tipogeom="wkbGeometryCollection25D";break; |
106 |
} |
107 |
return tipogeom;
|
108 |
|
109 |
} |
110 |
|
111 |
/**
|
112 |
* Obtiene el n?mero de campos
|
113 |
* @throws OGRException
|
114 |
* @return N?mero de campos
|
115 |
*/
|
116 |
|
117 |
public int getFieldCount()throws OGRException{ |
118 |
|
119 |
String msg1="Error en getFieldCount. El constructor ha fallado."; |
120 |
String msg2="Error obteniendo el n?mero de campos"; |
121 |
return baseSimpleFunctions(3,msg1,msg2); |
122 |
} |
123 |
|
124 |
/**
|
125 |
* Obtiene el campo referenciado por el ?ndice
|
126 |
* @throws OGRException
|
127 |
* @return Objeto que contiene el campo seleccionado
|
128 |
*/
|
129 |
|
130 |
/*public OGRFieldDefn getFieldDefn(int i)throws OGRException{
|
131 |
|
132 |
|
133 |
}*/
|
134 |
|
135 |
/**
|
136 |
* Destructor
|
137 |
*/
|
138 |
|
139 |
protected void finalize(){ |
140 |
if(cPtr > 0) |
141 |
FreeOGRFeatureDefnNat(cPtr); |
142 |
} |
143 |
} |