Statistics
| Revision:

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

History | View | Annotate | Download (3.69 KB)

1
 /**********************************************************************
2
 * $Id: ogrsfdriverregistrar_interfaz.cpp 915 2005-01-12 08:21:15Z igbrotru $
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
/*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_jgdal_OGRSFDriverRegistrar.h"
30
#include "es_gva_cit_jgdal_JNIBase.h"
31
#include "ogr_api.h"
32
#include "ogrsf_frmts.h"
33

    
34

    
35
/******************************************************************************/
36
//                                                                        open
37
/******************************************************************************/
38

    
39
JNIEXPORT jlong JNICALL Java_es_gva_cit_jgdal_OGRSFDriverRegistrar_openNat
40
  (JNIEnv *env, jobject obj, jstring fte, jint bUpdate){
41
          
42
          OGRDataSource       *poDS;
43
    OGRSFDriver         *poDriver;
44
    long                                driver=0;
45
    long                                dataset=0;
46
    const char                         *pszFilename;
47
    jclass                                 clase;
48
          jfieldID                         id_campo;
49
    
50
    pszFilename = env->GetStringUTFChars( fte, 0);
51
        
52
        poDS = OGRSFDriverRegistrar::Open( pszFilename, bUpdate, &poDriver );
53
        
54
    if( poDS == NULL )return -1;
55
    driver = (long)&(*poDriver);
56

    
57
    clase = env->GetObjectClass(obj);
58
    id_campo = env->GetFieldID( clase, "driver", "J");
59
    env->SetLongField( obj, id_campo, (jlong)driver);    
60
    dataset = (long)&(*poDS);
61
    env->ReleaseStringUTFChars( fte, pszFilename);
62
   
63
    return (jlong)dataset;
64
          
65
  }
66
  
67
/******************************************************************************/
68
//                                                                        getDriverCount
69
/******************************************************************************/
70

    
71
JNIEXPORT jint JNICALL Java_es_gva_cit_jgdal_JNIBase_getDriverCountNat
72
  (JNIEnv *env, jobject obj, jlong cPtr){
73
          
74
          int res=-1;
75
          OGRSFDriverRegistrar *drvreg  = (OGRSFDriverRegistrar *) 0 ;
76
  
77
          drvreg = *(OGRSFDriverRegistrar **)&cPtr;
78
          if(drvreg!=NULL)
79
                  res = drvreg->GetDriverCount();
80
                    
81
          return res;
82
          
83
  }
84
  
85
/******************************************************************************/
86
//                                                                        getRegistrar
87
/******************************************************************************/
88

    
89
  JNIEXPORT jlong JNICALL Java_es_gva_cit_jgdal_OGRSFDriverRegistrar_getRegistrarNat
90
  (JNIEnv *env, jobject obj){
91
          
92
          long ptro;
93
          OGRSFDriverRegistrar    *poR = OGRSFDriverRegistrar::GetRegistrar();
94
          ptro = (long)&(*poR);
95
          
96
          return (jlong)ptro;
97
  }        
98
  
99
/******************************************************************************/
100
//                                                                        getDriver
101
/******************************************************************************/
102
  
103
  
104
  JNIEXPORT jlong JNICALL Java_es_gva_cit_jgdal_OGRSFDriverRegistrar_getDriverNat
105
  (JNIEnv *env, jobject obj, jlong cPtr, jint i){
106
          
107
          OGRSFDriverRegistrar         *drvreg  = (OGRSFDriverRegistrar *) 0 ;
108
          OGRSFDriver                         *drv;
109
          long                                        driver=0;
110
          
111
          drvreg = *(OGRSFDriverRegistrar **)&cPtr;
112
          drv = drvreg->GetDriver(i);
113
          driver = (long)&(*drv);
114
          
115
          return (jlong)driver;
116
          
117
          
118
  }
119