Statistics
| Revision:

root / branches / v051 / libraries / libjni-gdal / src / ogrfielddefn_interfaz.cpp @ 37535

History | View | Annotate | Download (4.85 KB)

1 945 igbrotru
 /**********************************************************************
2
 * $Id$
3
 *
4
 * Name:     ogrfielddefn_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 945 igbrotru
51
52
#include <jni.h>
53
#include "es_gva_cit_jogr_OGRFieldDefn.h"
54
#include "es_gva_cit_jogr_JNIBase.h"
55
#include "ogr_api.h"
56
#include "ogrsf_frmts.h"
57
58
/******************************************************************************/
59
//                                                                ~OGRFieldDefn
60
/******************************************************************************/
61
62
  JNIEXPORT void JNICALL Java_es_gva_cit_jogr_OGRFieldDefn_FreeOGRFieldDefnNat
63
  (JNIEnv *env, jobject obj, jlong cPtr){
64
65 970 igbrotru
          OGRFieldDefn         *fd = (OGRFieldDefn *) 0 ;
66 945 igbrotru
67 970 igbrotru
          fd = *(OGRFieldDefn **)&cPtr;
68
          if(fd!=NULL){
69 971 igbrotru
                  delete fd;
70 945 igbrotru
          }
71
  }
72 970 igbrotru
73
/******************************************************************************/
74
//                                                                getType
75
/******************************************************************************/
76
77
 JNIEXPORT jint JNICALL Java_es_gva_cit_jogr_OGRFieldDefn_getTypeNat
78
  (JNIEnv *env, jobject obj, jlong cPtr){
79
80
          OGRFieldDefn         *fd = (OGRFieldDefn *) 0 ;
81
          OGRFieldType        ft;
82
83
          fd = *(OGRFieldDefn **)&cPtr;
84
          if(fd!=NULL)
85
                  ft = fd->GetType();
86
87
          return (int)ft;
88
  }
89
90
/******************************************************************************/
91
//                                                                getNameRef
92
/******************************************************************************/
93
94
JNIEXPORT jstring JNICALL Java_es_gva_cit_jogr_OGRFieldDefn_getNameRefNat
95
  (JNIEnv *env, jobject obj, jlong cPtr){
96
97
          OGRFieldDefn         *fd = (OGRFieldDefn *) 0 ;
98
          jstring                        jstipo;
99
100
          fd = *(OGRFieldDefn **)&cPtr;
101
          if(fd!=NULL){
102
            const char *tipo = fd->GetNameRef();
103
            jstipo = env->NewStringUTF(tipo);
104
          }
105
          return jstipo;
106
  }
107
108
/******************************************************************************/
109
//                                                                getFieldTypeName
110
/******************************************************************************/
111
112
JNIEXPORT jstring JNICALL Java_es_gva_cit_jogr_OGRFieldDefn_getFieldTypeNameNat
113
  (JNIEnv *env, jobject obj, jlong cPtr, jint tipo){
114
115
          OGRFieldDefn        *fd = (OGRFieldDefn *) 0 ;
116
          jstring                        jsnombretipo;
117
118
          fd = *(OGRFieldDefn **)&cPtr;
119
          if(fd!=NULL){
120
                  OGRFieldType ft;
121
                  switch(tipo){
122
                          case 0:ft=OFTInteger;break;
123
                        case 1:ft=OFTIntegerList;break;
124
                        case 2:ft=OFTReal;break;
125
                        case 3:ft=OFTRealList;break;
126
                        case 4:ft=OFTString;break;
127
                        case 5:ft=OFTStringList;break;
128
                        case 6:ft=OFTWideString;break;
129
                        case 7:ft=OFTWideStringList;break;
130
                        case 8:ft=OFTBinary;break;
131
                  }
132
                  const char  *nombretipo = fd->GetFieldTypeName(ft);
133
                  jsnombretipo = env->NewStringUTF(nombretipo);
134
          }
135
          return jsnombretipo;
136
  }
137
138
/******************************************************************************/
139
//                                                                getWidth
140
/******************************************************************************/
141
142
JNIEXPORT jint JNICALL Java_es_gva_cit_jogr_JNIBase_getWidthNat
143
 (JNIEnv *env, jobject obj, jlong cPtr){
144
145
          OGRFieldDefn         *fd = (OGRFieldDefn *) 0 ;
146
          int                         width = -1;
147
148
          fd = *(OGRFieldDefn **)&cPtr;
149
          if(fd!=NULL){
150
                  width = fd->GetWidth();
151
          }
152
          return width;
153
  }
154
155
/******************************************************************************/
156
//                                                                getPrecision
157
/******************************************************************************/
158
159
JNIEXPORT jint JNICALL Java_es_gva_cit_jogr_JNIBase_getPrecisionNat
160
  (JNIEnv *env, jobject obj, jlong cPtr){
161
162
          OGRFieldDefn         *fd = (OGRFieldDefn *) 0 ;
163
          int                         precision = -1;
164
165
          fd = *(OGRFieldDefn **)&cPtr;
166
          if(fd!=NULL){
167
                  precision = fd->GetPrecision();
168
          }
169
          return precision;
170
  }