Statistics
| Revision:

root / trunk / libraries / libjni-gdal / src / ogrlayer_interfaz.cpp @ 970

History | View | Annotate | Download (4.61 KB)

1
 /**********************************************************************
2
 * $Id: ogrlayer_interfaz.cpp 970 2005-01-13 12:52:33Z igbrotru $
3
 *
4
 * Name:     ogrlayer_interfaz.c
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

    
28
#include <jni.h>
29
#include "es_gva_cit_jogr_OGRLayer.h"
30
#include "es_gva_cit_jogr_JNIBase.h"
31
#include "ogr_api.h"
32
#include "ogrsf_frmts.h"
33

    
34
/******************************************************************************/
35
//                                                                        getLayerDefn
36
/******************************************************************************/
37

    
38
JNIEXPORT jlong JNICALL Java_es_gva_cit_jogr_OGRLayer_getLayerDefnNat
39
  (JNIEnv *env, jobject obj, jlong cPtr){
40
          
41
          OGRLayer                                 *capa  = (OGRLayer *) 0 ;
42
          OGRFeatureDefn                         *fd;
43
          long                                        featuredefn=0;
44
          
45
          capa = *(OGRLayer **)&cPtr;
46
          fd = capa->GetLayerDefn();
47
          featuredefn = (long)&(*fd);
48
          
49
          return (jlong)featuredefn;
50
  }
51
  
52
/******************************************************************************/
53
//                                                                getFeatureCount
54
/******************************************************************************/
55

    
56
JNIEXPORT jint JNICALL Java_es_gva_cit_jogr_JNIBase_getFeatureCountNat
57
  (JNIEnv *env, jobject obj, jlong cPtr){
58
          
59
          int                                 res        = -1;
60
          OGRLayer                         *capa  = (OGRLayer *) 0 ;
61
          
62
          capa = *(OGRLayer **)&cPtr;
63
          res = capa->GetFeatureCount();
64
          
65
          return res;
66
          
67
  }
68

    
69
/******************************************************************************/
70
//                                                                  resetReading
71
/******************************************************************************/
72

    
73
JNIEXPORT void JNICALL Java_es_gva_cit_jogr_OGRLayer_resetReadingNat
74
  (JNIEnv *env, jobject obj, jlong cPtr){
75
          
76
          OGRLayer         *capa  = (OGRLayer *) 0 ;
77
          
78
          capa = *(OGRLayer **)&cPtr;
79
          capa->ResetReading();
80
  }
81

    
82
/******************************************************************************/
83
//                                                                        getExtent
84
/******************************************************************************/
85
  
86
JNIEXPORT jint JNICALL Java_es_gva_cit_jogr_OGRLayer_getExtentNat
87
  (JNIEnv *env, jobject obj, jlong cPtr, jobject extent, jboolean bForce){
88
          
89
          OGRLayer                                 *capa  = (OGRLayer *) 0 ;
90
          OGREnvelope                         oExt;
91
          jclass                                         clase;
92
          jfieldID                                 id_campo;
93
          int                                         res;
94
          
95
          capa = *(OGRLayer **)&cPtr;
96
          res = capa->GetExtent(&oExt, (bool)bForce);
97
                    
98
          clase = env->GetObjectClass(extent);
99
          id_campo = env->GetFieldID( clase, "minX", "D");
100
          env->SetDoubleField( extent, id_campo, oExt.MinX);
101
          id_campo = env->GetFieldID( clase, "maxX", "D");
102
          env->SetDoubleField( extent, id_campo, oExt.MaxX);
103
          id_campo = env->GetFieldID( clase, "minY", "D");
104
          env->SetDoubleField( extent, id_campo, oExt.MinY);
105
          id_campo = env->GetFieldID( clase, "maxY", "D");
106
          env->SetDoubleField( extent, id_campo, oExt.MaxX);
107
          
108
          oExt.~OGREnvelope();          
109
          return res;
110
  }
111
  
112
/******************************************************************************/
113
//                                                                getNextFeature
114
/******************************************************************************/  
115

    
116
JNIEXPORT jlong JNICALL Java_es_gva_cit_jogr_OGRLayer_getNextFeatureNat
117
  (JNIEnv *env, jobject obj, jlong cPtr){
118
          
119
          OGRLayer                 *capa = (OGRLayer *) 0 ;
120
          OGRFeature                 *feature;
121
          long                         ptro_feat = -1;
122
          
123
          capa = *(OGRLayer **)&cPtr;
124
          if(capa!=NULL){
125
                  feature = capa->GetNextFeature();
126
                  if(feature !=NULL)
127
                          ptro_feat = (long)&(*feature);
128
                  else return -1;
129
          }
130
          
131
          return ptro_feat;
132
          
133
  }
134
    
135
/******************************************************************************/
136
//                                                                ~OGRLayer
137
/******************************************************************************/
138
 
139
  JNIEXPORT void JNICALL Java_es_gva_cit_jogr_OGRLayer_FreeOGRLayerNat
140
  (JNIEnv *env, jobject obj, jlong cPtr){
141
          
142
          OGRLayer *df = (OGRLayer *) 0 ;
143
          
144
          df = *(OGRLayer **)&cPtr;
145
          if(df!=NULL){
146
                  df->~OGRLayer();
147
          }
148
  }
149
  
150
  
151