Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libjni-gdal / src / ogrsfdriverregistrar_interfaz.cpp @ 7284

History | View | Annotate | Download (4.63 KB)

1
 /**********************************************************************
2
 * $Id: ogrsfdriverregistrar_interfaz.cpp 3540 2006-01-09 12:51:24Z nacho $
3
 *
4
 * Name:     ogrsfdriverregistrar_interfaz.c
5
 * Project:  JGDAL. Interface java to gdal (Frank Warmerdam).
6
 * Purpose:  
7
 * Author:   Nacho Brodin, brodin_ign@gva.es
8
 *
9
 **********************************************************************/
10
/* 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

    
51

    
52
#include <jni.h>
53
#include "es_gva_cit_jogr_OGRSFDriverRegistrar.h"
54
#include "es_gva_cit_jogr_JNIBase.h"
55
#include "ogr_api.h"
56
#include "ogrsf_frmts.h"
57

    
58

    
59
/******************************************************************************/
60
//                                                                        open
61
/******************************************************************************/
62

    
63
JNIEXPORT jlong JNICALL Java_es_gva_cit_jogr_OGRSFDriverRegistrar_openNat
64
  (JNIEnv *env, jobject obj, jstring fte, jint bUpdate){
65
          
66
          OGRDataSource       *poDS;
67
    OGRSFDriver         *poDriver;
68
    long                                driver=0;
69
    long                                dataset=0;
70
    const char                         *pszFilename;
71
    jclass                                 clase;
72
          jfieldID                         id_campo;
73
    
74
    pszFilename = env->GetStringUTFChars( fte, 0);
75
        
76
        poDS = OGRSFDriverRegistrar::Open( pszFilename, bUpdate, &poDriver );
77
        
78
    if( poDS == NULL )return -1;
79
    if(poDriver!=NULL)
80
            driver = (long)&(*poDriver);
81

    
82
    clase = env->GetObjectClass(obj);
83
    id_campo = env->GetFieldID( clase, "driver", "J");
84
    env->SetLongField( obj, id_campo, (jlong)driver);    
85
    dataset = (long)&(*poDS);
86
    env->ReleaseStringUTFChars( fte, pszFilename);
87
   
88
    return (jlong)dataset;
89
          
90
  }
91
  
92
/******************************************************************************/
93
//                                                                        getDriverCount
94
/******************************************************************************/
95

    
96
JNIEXPORT jint JNICALL Java_es_gva_cit_jogr_JNIBase_getDriverCountNat
97
  (JNIEnv *env, jobject obj, jlong cPtr){
98
          
99
          int res=-1;
100
          OGRSFDriverRegistrar *drvreg  = (OGRSFDriverRegistrar *) 0 ;
101
  
102
          drvreg = *(OGRSFDriverRegistrar **)&cPtr;
103
          if(drvreg!=NULL)
104
                  res = drvreg->GetDriverCount();
105
                    
106
          return res;
107
          
108
  }
109
  
110
/******************************************************************************/
111
//                                                                        getRegistrar
112
/******************************************************************************/
113

    
114
  JNIEXPORT jlong JNICALL Java_es_gva_cit_jogr_OGRSFDriverRegistrar_getRegistrarNat
115
  (JNIEnv *env, jobject obj){
116
          
117
          long ptro;
118
          OGRSFDriverRegistrar    *poR = OGRSFDriverRegistrar::GetRegistrar();
119
          ptro = (long)&(*poR);
120
          
121
          return (jlong)ptro;
122
  }        
123
  
124
/******************************************************************************/
125
//                                                                        getDriver
126
/******************************************************************************/
127
  
128
  
129
  JNIEXPORT jlong JNICALL Java_es_gva_cit_jogr_OGRSFDriverRegistrar_getDriverNat
130
  (JNIEnv *env, jobject obj, jlong cPtr, jint i){
131
          
132
          OGRSFDriverRegistrar         *drvreg  = (OGRSFDriverRegistrar *) 0 ;
133
          OGRSFDriver                         *drv;
134
          long                                        driver=0;
135
          
136
          drvreg = *(OGRSFDriverRegistrar **)&cPtr;
137
          if(drvreg!=NULL){
138
                  drv = drvreg->GetDriver(i);
139
                  driver = (long)&(*drv);
140
          }
141
          return (jlong)driver;
142
          
143
          
144
  }
145
  
146
  
147
/******************************************************************************/
148
//                                                                ~OGRSFDriverRegistrar
149
/******************************************************************************/
150
 
151
  JNIEXPORT void JNICALL Java_es_gva_cit_jogr_OGRSFDriverRegistrar_FreeOGRSFDriverRegistrarNat
152
  (JNIEnv *env, jobject obj, jlong cPtr){
153
          
154
          OGRSFDriverRegistrar *df = (OGRSFDriverRegistrar *) 0 ;
155
          
156
          df = *(OGRSFDriverRegistrar **)&cPtr;
157
          if(df!=NULL){
158
                  delete df;
159
          }
160
  }
161
  
162