Statistics
| Revision:

svn-gvsig-desktop / tags / Root_v05 / libraries / libjni-gdal / src / ogrfeaturedefn_interfaz.cpp @ 34079

History | View | Annotate | Download (10.9 KB)

1 915 igbrotru
 /**********************************************************************
2
 * $Id$
3
 *
4
 * Name:     ogrfeaturedefn_interfaz.c
5
 * Project:  JGDAL. Interface java to gdal (Frank Warmerdam).
6
 * Purpose:
7
 * Author:   Nacho Brodin, brodin_ign@gva.es
8
 *
9
 **********************************************************************/
10 2210 igbrotru
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
11
*
12
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
13
*
14
* This program is free software; you can redistribute it and/or
15
* modify it under the terms of the GNU General Public License
16
* as published by the Free Software Foundation; either version 2
17
* of the License, or (at your option) any later version.
18
*
19
* This program is distributed in the hope that it will be useful,
20
* but WITHOUT ANY WARRANTY; without even the implied warranty of
21
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
* GNU General Public License for more details.
23
*
24
* You should have received a copy of the GNU General Public License
25
* along with this program; if not, write to the Free Software
26
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
27
*
28
* For more information, contact:
29
*
30
*  Generalitat Valenciana
31
*   Conselleria d'Infraestructures i Transport
32
*   Av. Blasco Ib??ez, 50
33
*   46010 VALENCIA
34
*   SPAIN
35
*
36
*      +34 963862235
37
*   gvsig@gva.es
38
*      www.gvsig.gva.es
39
*
40
*    or
41
*
42
*   IVER T.I. S.A
43
*   Salamanca 50
44
*   46005 Valencia
45
*   Spain
46
*
47
*   +34 963163400
48
*   dac@iver.es
49
*/
50 915 igbrotru
51
52
#include <jni.h>
53 920 igbrotru
#include "es_gva_cit_jogr_OGRFeatureDefn.h"
54
#include "es_gva_cit_jogr_JNIBase.h"
55 915 igbrotru
#include "ogr_api.h"
56 920 igbrotru
#include "ogrsf_frmts.h"
57
58
/******************************************************************************/
59
//                                                                getName
60
/******************************************************************************/
61
62
JNIEXPORT jstring JNICALL Java_es_gva_cit_jogr_OGRFeatureDefn_getNameNat
63
  (JNIEnv *env, jobject obj, jlong cPtr){
64
65
          OGRFeatureDefn                         *fd = (OGRFeatureDefn *) 0 ;
66
          jstring                                        nom_fd;
67
68
          fd = *(OGRFeatureDefn **)&cPtr;
69
          const char *name = fd->GetName();
70
71
          if(name!=NULL)
72
                  nom_fd = env->NewStringUTF(name);
73
          else return NULL;
74
75
          return nom_fd;
76
77
  }
78
79
/******************************************************************************/
80
//                                                                getGeomType
81
/******************************************************************************/
82
83
JNIEXPORT jint JNICALL Java_es_gva_cit_jogr_OGRFeatureDefn_getGeomTypeNat
84
  (JNIEnv *env, jobject obj, jlong cPtr){
85
86
          OGRFeatureDefn                         *fd = (OGRFeatureDefn *) 0 ;
87
88
          fd = *(OGRFeatureDefn **)&cPtr;
89
          OGRwkbGeometryType tipo = fd->GetGeomType();
90
91
          if(tipo==wkbUnknown)return 0;
92
          if(tipo==wkbPoint)return 1;
93
          if(tipo==wkbLineString)return 2;
94
          if(tipo==wkbPolygon)return 3;
95
          if(tipo==wkbMultiPoint)return 4;
96
          if(tipo==wkbMultiLineString)return 5;
97
          if(tipo==wkbMultiPolygon)return 6;
98
          if(tipo==wkbGeometryCollection)return 7;
99
          if(tipo==wkbNone)return 8;
100
          if(tipo==wkbLinearRing)return 9;
101
          if(tipo==wkbPoint25D)return 10;
102
          if(tipo==wkbLineString25D)return 11;
103
          if(tipo==wkbPolygon25D)return 12;
104
          if(tipo==wkbMultiPoint25D)return 13;
105
          if(tipo==wkbMultiLineString25D)return 14;
106
          if(tipo==wkbMultiPolygon25D)return 15;
107
          if(tipo==wkbGeometryCollection25D)return 16;
108
109
          return -1;
110 945 igbrotru
  }
111
112
/******************************************************************************/
113
//                                                                ~OGRFeatureDefn
114
/******************************************************************************/
115
116
  JNIEXPORT void JNICALL Java_es_gva_cit_jogr_OGRFeatureDefn_FreeOGRFeatureDefnNat
117
  (JNIEnv *env, jobject obj, jlong cPtr){
118
119
          OGRFeatureDefn *df = (OGRFeatureDefn *) 0 ;
120
121
          df = *(OGRFeatureDefn **)&cPtr;
122
          if(df!=NULL){
123 971 igbrotru
                  delete df;
124 945 igbrotru
          }
125 970 igbrotru
  }
126
127
  /******************************************************************************/
128
//                                                                getFieldCount
129
/******************************************************************************/
130
131
JNIEXPORT jint JNICALL Java_es_gva_cit_jogr_JNIBase_getFieldCountNat
132
  (JNIEnv *env, jobject obj, jlong cPtr){
133
134
          OGRFeatureDefn         *df = (OGRFeatureDefn *) 0 ;
135
          int                         nfields=-1;
136
137
          df = *(OGRFeatureDefn **)&cPtr;
138
          if(df!=NULL){
139
                  nfields = df->GetFieldCount();
140
          }
141
          return nfields;
142
  }
143
144
/******************************************************************************/
145
//                                                                getFieldDefn
146
/******************************************************************************/
147
148
JNIEXPORT jlong JNICALL Java_es_gva_cit_jogr_OGRFeatureDefn_getFieldDefnNat
149
  (JNIEnv *env, jobject obj, jlong cPtr, jint i){
150
151
          OGRFeatureDefn         *df = (OGRFeatureDefn *) 0 ;
152
          OGRFieldDefn         *field;
153
          long                        ptro_field;
154
          df = *(OGRFeatureDefn **)&cPtr;
155
          if(df!=NULL){
156
                  field = df->GetFieldDefn(i);
157
                  ptro_field = (long)&(*field);
158
          }
159
          return (jlong)ptro_field;
160
161 1101 igbrotru
  }
162
163
164
/******************************************************************************/
165
//                                                                getFieldIndex
166
/******************************************************************************/
167
168
JNIEXPORT jint JNICALL Java_es_gva_cit_jogr_OGRFeatureDefn_getFieldIndexNat
169
  (JNIEnv *env, jobject obj, jlong cPtr, jstring field){
170
171
            OGRFeatureDefn         *fd = (OGRFeatureDefn *) 0 ;
172
            const char                *campo;
173
            int                                 index=-1;
174
175
          fd = *(OGRFeatureDefn **)&cPtr;
176
          if(fd!=NULL){
177
                  campo = env->GetStringUTFChars(field, 0);
178
                index =        fd->GetFieldIndex(campo);
179
                  env->ReleaseStringUTFChars(field, campo);
180
          }
181
          return index;
182
  }
183
184
/******************************************************************************/
185
//                                                                addFieldDefn
186
/******************************************************************************/
187
188
JNIEXPORT void JNICALL Java_es_gva_cit_jogr_OGRFeatureDefn_addFieldDefnNat
189
  (JNIEnv *env, jobject obj, jlong cPtr, jlong fdefn){
190
191
            OGRFeatureDefn         *fd = (OGRFeatureDefn *) 0 ;
192
          OGRFieldDefn                *fielddefn;
193
194
          fd = *(OGRFeatureDefn **)&cPtr;
195
          fielddefn = *(OGRFieldDefn **)&fdefn;
196
          if(fd!=NULL){
197
                  fd->AddFieldDefn(fielddefn);
198
          }
199
  }
200
201
/******************************************************************************/
202
//                                                                setGeomType
203
/******************************************************************************/
204
205
JNIEXPORT void JNICALL Java_es_gva_cit_jogr_OGRFeatureDefn_setGeomTypeNat
206
  (JNIEnv *env, jobject obj, jlong cPtr, jstring eGType){
207
208
            OGRFeatureDefn         *fd = (OGRFeatureDefn *) 0 ;
209
            OGRwkbGeometryType         geomtype;
210
211
          fd = *(OGRFeatureDefn **)&cPtr;
212
          if(fd!=NULL){
213
                  const char *type = env->GetStringUTFChars( eGType, 0);
214
                  if(strcmp(type,"wkbUnknown")==0)geomtype = wkbUnknown;
215
                  else if(strcmp(type,"wkbPoint")==0)geomtype = wkbPoint;
216
                  else if(strcmp(type,"wkbLineString")==0)geomtype = wkbLineString;
217
                  else if(strcmp(type,"wkbPolygon")==0)geomtype = wkbPolygon;
218
                  else if(strcmp(type,"wkbMultiPoint")==0)geomtype = wkbMultiPoint;
219
                  else if(strcmp(type,"wkbMultiLineString")==0)geomtype = wkbMultiLineString;
220
                  else if(strcmp(type,"wkbMultiPolygon")==0)geomtype = wkbMultiPolygon;
221
                  else if(strcmp(type,"wkbGeometryCollection")==0)geomtype = wkbGeometryCollection;
222
                  else if(strcmp(type,"wkbNone")==0)geomtype = wkbNone;
223
                  else if(strcmp(type,"wkbLinearRing")==0)geomtype = wkbLinearRing;
224
                else if(strcmp(type,"wkbPoint25D")==0)geomtype = wkbPoint25D;
225
                  else if(strcmp(type,"wkbLineString25D")==0)geomtype = wkbLineString25D;
226
                  else if(strcmp(type,"wkbPolygon25D")==0)geomtype = wkbPolygon25D;
227
                  else if(strcmp(type,"wkbMultiPoint25D")==0)geomtype = wkbMultiPoint25D;
228
                  else if(strcmp(type,"wkbMultiLineString25D")==0)geomtype = wkbMultiLineString25D;
229
                  else if(strcmp(type,"wkbMultiPolygon25D")==0)geomtype = wkbMultiPolygon25D;
230
                  else if(strcmp(type,"wkbGeometryCollection25D")==0)geomtype = wkbGeometryCollection25D;
231
232
                  fd->SetGeomType(geomtype);
233
                  env->ReleaseStringUTFChars( eGType, type );
234
235
236
          }
237
  }
238
239
/******************************************************************************/
240
//                                                                cloneFeatureDefn
241
/******************************************************************************/
242
243
JNIEXPORT jlong JNICALL Java_es_gva_cit_jogr_OGRFeatureDefn_cloneFeatureDefnNat
244
  (JNIEnv *env, jobject obj, jlong cPtr){
245
246
            OGRFeatureDefn         *fd = (OGRFeatureDefn *) 0 ;
247
             OGRFeatureDefn         *return_fd;
248
             long                                ptr_fd=-1;
249
250
          fd = *(OGRFeatureDefn **)&cPtr;
251
          if(fd!=NULL){
252
                  return_fd = fd->Clone();
253
                  if(return_fd!=NULL)
254
                            ptr_fd = (long)&(*return_fd);
255
          }
256
257
      return (jlong)ptr_fd;
258
  }
259
260
/******************************************************************************/
261
//                                                                createFeatureDefn
262
/******************************************************************************/
263
264
JNIEXPORT jlong JNICALL Java_es_gva_cit_jogr_OGRFeatureDefn_createFeatureDefnNat
265
  (JNIEnv *env, jclass clase, jstring pszName){
266
267
            OGRFeatureDefn        *return_fd;
268
            long                                ptr_fd=-1;
269
            const        char                *name;
270
271
          name = env->GetStringUTFChars(pszName, 0);
272
          return_fd = OGRFeatureDefn::CreateFeatureDefn(name);
273
          if(return_fd!=NULL)
274
                    ptr_fd = (long)&(*return_fd);
275
          env->ReleaseStringUTFChars( pszName, name );
276
277
          return (jlong)ptr_fd;
278
  }
279
280
/******************************************************************************/
281
//                                                                destroyFeatureDefn
282
/******************************************************************************/
283
284
JNIEXPORT void JNICALL Java_es_gva_cit_jogr_OGRFeatureDefn_destroyFeatureDefnNat
285
  (JNIEnv *env, jclass clase, jlong ptr_fd){
286
287
            OGRFeatureDefn         *fd = (OGRFeatureDefn *) 0 ;
288
289
          fd = *(OGRFeatureDefn **)&ptr_fd;
290
          if(fd!=NULL){
291
                  OGRFeatureDefn::DestroyFeatureDefn(fd);
292
          }
293
  }
294
295
/******************************************************************************/
296
//                                                                referenceFeatureDefn
297
/******************************************************************************/
298
299
JNIEXPORT jint JNICALL Java_es_gva_cit_jogr_JNIBase_referenceFeatureDefnNat
300
  (JNIEnv *env, jobject obj, jlong cPtr){
301
302
            OGRFeatureDefn         *fd = (OGRFeatureDefn *) 0 ;
303
            int                                 res=-1;
304
305
          fd = *(OGRFeatureDefn **)&cPtr;
306
          if(fd!=NULL){
307
                  res = fd->Reference();
308
          }
309
          return res;
310
  }
311
312
/******************************************************************************/
313
//                                                                dereferenceFeatureDefn
314
/******************************************************************************/
315
316
JNIEXPORT jint JNICALL Java_es_gva_cit_jogr_JNIBase_dereferenceFeatureDefnNat
317
  (JNIEnv *env, jobject obj, jlong cPtr){
318
319
            OGRFeatureDefn         *fd = (OGRFeatureDefn *) 0 ;
320
            int                                res=-1;
321
322
          fd = *(OGRFeatureDefn **)&cPtr;
323
          if(fd!=NULL){
324
                  res = fd->Dereference();
325
          }
326
327
          return res;
328
  }
329
330
/******************************************************************************/
331
//                                                                getReferenceCount
332
/******************************************************************************/
333
334
JNIEXPORT jint JNICALL Java_es_gva_cit_jogr_JNIBase_getReferenceCountNat
335
  (JNIEnv *env, jobject obj, jlong cPtr){
336
337
            OGRFeatureDefn         *fd = (OGRFeatureDefn *) 0 ;
338
            int                                 count=-1;
339
340
          fd = *(OGRFeatureDefn **)&cPtr;
341
          if(fd!=NULL){
342
                  count = fd->GetReferenceCount();
343
          }
344
          return count;
345
  }