Revision 915

View differences:

trunk/libraries/libjni-gdal/include/es_gva_cit_jgdal_OGRDataSource.h
7 7
#ifdef __cplusplus
8 8
extern "C" {
9 9
#endif
10
/*
11
 * Class:     es_gva_cit_jgdal_OGRDataSource
12
 * Method:    getNameNat
13
 * Signature: (J)Ljava/lang/String;
14
 */
15
JNIEXPORT jstring JNICALL Java_es_gva_cit_jgdal_OGRDataSource_getNameNat
16
  (JNIEnv *, jobject, jlong);
17

  
18
/*
19
 * Class:     es_gva_cit_jgdal_OGRDataSource
20
 * Method:    getLayerNat
21
 * Signature: (JI)J
22
 */
23
JNIEXPORT jlong JNICALL Java_es_gva_cit_jgdal_OGRDataSource_getLayerNat
24
  (JNIEnv *, jobject, jlong, jint);
25

  
10 26
#ifdef __cplusplus
11 27
}
12 28
#endif
trunk/libraries/libjni-gdal/include/es_gva_cit_jgdal_JNIBase.h
95 95
JNIEXPORT jint JNICALL Java_es_gva_cit_jgdal_JNIBase_getDriverCountNat
96 96
  (JNIEnv *, jobject, jlong);
97 97

  
98
/*
99
 * Class:     es_gva_cit_jgdal_JNIBase
100
 * Method:    getLayerCountNat
101
 * Signature: (J)I
102
 */
103
JNIEXPORT jint JNICALL Java_es_gva_cit_jgdal_JNIBase_getLayerCountNat
104
  (JNIEnv *, jobject, jlong);
105

  
98 106
#ifdef __cplusplus
99 107
}
100 108
#endif
trunk/libraries/libjni-gdal/include/es_gva_cit_jgdal_OGRLayer.h
7 7
#ifdef __cplusplus
8 8
extern "C" {
9 9
#endif
10
/*
11
 * Class:     es_gva_cit_jgdal_OGRLayer
12
 * Method:    getLayerDefnNat
13
 * Signature: (J)J
14
 */
15
JNIEXPORT jlong JNICALL Java_es_gva_cit_jgdal_OGRLayer_getLayerDefnNat
16
  (JNIEnv *, jobject, jlong);
17

  
10 18
#ifdef __cplusplus
11 19
}
12 20
#endif
trunk/libraries/libjni-gdal/src/ogrdatasource_interfaz.c
1
 /**********************************************************************
2
 * $Id$
3
 *
4
 * Name:     ogrdatasource_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_OGRDataSource.h"
30
#include "es_gva_cit_jgdal_JNIBase.h"
31
#include "ogr_api.h"
32
#include "ogr_srs_api.h"
33

  
34

  
35

  
36
/******************************************************************************/
37
//								Open
38
/******************************************************************************/
trunk/libraries/libjni-gdal/src/ogrlayer_interfaz.c
1
 /**********************************************************************
2
 * $Id$
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_jgdal_OGRLayer.h"
30
#include "es_gva_cit_jgdal_JNIBase.h"
31
#include "ogr_api.h"
32
#include "ogr_srs_api.h"
trunk/libraries/libjni-gdal/src/ogrfeaturedefn_interfaz.c
1
 /**********************************************************************
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
/*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_OGRFeatureDefn.h"
30
#include "es_gva_cit_jgdal_JNIBase.h"
31
#include "ogr_api.h"
32
#include "ogr_srs_api.h"
trunk/libraries/libjni-gdal/src/ogrsfdriverregistrar_interfaz.cpp
30 30
#include "es_gva_cit_jgdal_JNIBase.h"
31 31
#include "ogr_api.h"
32 32
#include "ogrsf_frmts.h"
33
#include "ogr_srs_api.h"
34 33

  
35 34

  
36 35
/******************************************************************************/
trunk/libraries/libjni-gdal/src/ogrfeaturedefn_interfaz.cpp
1
 /**********************************************************************
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
/*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_OGRFeatureDefn.h"
30
#include "es_gva_cit_jgdal_JNIBase.h"
31
#include "ogr_api.h"
32
#include "ogrsf_frmts.h"
0 33

  
trunk/libraries/libjni-gdal/src/ogrdatasource_interfaz.cpp
1
 /**********************************************************************
2
 * $Id$
3
 *
4
 * Name:     ogrdatasource_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_OGRDataSource.h"
30
#include "es_gva_cit_jgdal_JNIBase.h"
31
#include "ogr_api.h"
32
#include "ogrsf_frmts.h"
33

  
34

  
35

  
36
/******************************************************************************/
37
//								getName
38
/******************************************************************************/
39

  
40
JNIEXPORT jstring JNICALL Java_es_gva_cit_jgdal_OGRDataSource_getNameNat
41
  (JNIEnv *env, jobject obj, jlong cPtr){
42
  	
43
  	OGRDataSource 			*ds = (OGRDataSource *) 0 ;
44
  	jstring					nom_ds;
45
  	
46
  	ds = *(OGRDataSource **)&cPtr;
47
  	const char *name = ds->GetName();
48
  	
49
  	if(name!=NULL)
50
	  	nom_ds = env->NewStringUTF(name);
51
  	else return NULL;
52
  	
53
  	return nom_ds;
54
  	
55
  }
56
  
57
/******************************************************************************/
58
//								getLayerCount
59
/******************************************************************************/
60
 
61
 JNIEXPORT jint JNICALL Java_es_gva_cit_jgdal_JNIBase_getLayerCountNat
62
  (JNIEnv *env, jobject obj, jlong cPtr){
63
  	
64
  	int res=-1;
65
  	OGRDataSource *ds  = (OGRDataSource *) 0 ;
66
  
67
  	ds = *(OGRDataSource **)&cPtr;
68
  	if(ds!=NULL)
69
	  	res = ds->GetLayerCount();
70
	  	  
71
  	return res;
72
  }
73
  
74
/******************************************************************************/
75
//									getLayer
76
/******************************************************************************/
77

  
78
JNIEXPORT jlong JNICALL Java_es_gva_cit_jgdal_OGRDataSource_getLayerNat
79
  (JNIEnv *env, jobject obj, jlong cPtr, jint iLayer){
80
  	
81
  	OGRDataSource		 	*ds  = (OGRDataSource *) 0 ;
82
  	OGRLayer 				*capa;
83
  	long					layer=0;
84
  	
85
  	ds = *(OGRDataSource **)&cPtr;
86
  	capa = ds->GetLayer(iLayer);
87
  	layer = (long)&(*capa);
88
  	
89
  	return (jlong)layer;
90
  	
91
  }
0 92

  
trunk/libraries/libjni-gdal/src/es/gva/cit/jgdal/OGRLayer.java
36 36

  
37 37
public class OGRLayer extends JNIBase{
38 38
	
39
	public native long getLayerDefnNat(long cPtr);
39 40
	
41
	/**
42
	 * Constructor
43
	 * @param cPtr	direcci?n de memoria al objeto OGRLayer de C. 
44
	 */
45
	
46
	public OGRLayer(long cPtr){
47
		this.cPtr=cPtr;
48
	}
49
	
50
	 /**
51
	 * 
52
	 * @throws GdalException
53
	 * @return 
54
	 */
55
			
56
	 public OGRFeatureDefn getLayerDefn()throws GdalException{
57
				
58
	 	if(cPtr <= 0)
59
			throw new GdalException("Error en getLayerDefn(). El constructor no tuvo exito");
60
		    	
61
		long layer = getLayerDefnNat(cPtr);
62
		
63
		if(layer<=0)
64
			throw new GdalException("Error en getLayerDefn(). No se ha podido obtener el objeto OGRFeatureDefn.");
65
						
66
		return new OGRFeatureDefn(layer);
67
			
68
	 }
40 69
}
trunk/libraries/libjni-gdal/src/es/gva/cit/jgdal/OGRFeatureDefn.java
36 36

  
37 37
public class OGRFeatureDefn extends JNIBase{
38 38
	
39
	/**
40
	 * Constructor
41
	 * @param cPtr	direcci?n de memoria al objeto OGRFeatureDefn de C. 
42
	 */
39 43
	
44
	public OGRFeatureDefn(long cPtr){
45
		this.cPtr=cPtr;
46
	}
40 47
}
trunk/libraries/libjni-gdal/src/es/gva/cit/jgdal/OGRDataSource.java
37 37

  
38 38
public class OGRDataSource extends JNIBase{
39 39
	
40
	public native String getNameNat(long cPtr);
41
	public native long getLayerNat(long cPtr, int i);
42
	
43
	/**
44
	 * Constructor
45
	 * @param cPtr	direcci?n de memoria al objeto OGRDataSource de C. 
46
	 */
47
	
40 48
	public OGRDataSource(long cPtr){
41 49
		this.cPtr=cPtr;
42 50
	}
43 51
		
52
	/**
53
	 * Obtiene el nombre del datasource
54
	 * @throws GdalException
55
	 * @return Nombre del datasource
56
	 */
57
	
58
	public String getName()throws GdalException{
59
		
60
		if(cPtr <= 0)
61
			throw new GdalException("Error en getName(). El constructor ha fallado.");
62
		    
63
		String name = getNameNat(cPtr);
64
		
65
		if(name==null)
66
			throw new GdalException("Error en getName(). No se ha podido obtener el nombre del datasource.");
67
		return name;
68
	}
69
	
70
	/**
71
	 * Obtiene el n?mero de capas
72
	 * @throws GdalException
73
	 * @return N?mero de capas
74
	 */
75
	
76
	 public int getLayerCount()throws GdalException{
77
			
78
		String msg1="Error en getLayerCount. El constructor no tuvo exito.";
79
		String msg2="Error en el conteo de capas.";
80
		return baseSimpleFunctions(11,msg1,msg2);
81
	 }
82
	 
83
	 /**
84
	 * Obtiene la capa indicada por el ?ndice
85
	 * @throws GdalException
86
	 * @return una capa
87
	 */
88
			
89
	 public OGRLayer getLayer(int i)throws GdalException{
90
				
91
	 	if(cPtr <= 0)
92
			throw new GdalException("Error en getLayer(). El constructor no tuvo exito");
93
		    	
94
		long layer = getLayerNat(cPtr, i);
95
		
96
		if(layer<=0)
97
			throw new GdalException("Error en getLayer(). No se ha podido obtener la capa indicada.");
98
						
99
		return new OGRLayer(layer);
100
			
101
	 }
44 102
}
trunk/libraries/libjni-gdal/src/es/gva/cit/jgdal/JNIBase.java
50 50
	private native int getGCPCountNat(long cPtr);
51 51
	private native int getRasterDataTypeNat(long cPtr);
52 52
	private native int getDriverCountNat(long cPtr);
53
	private native int getLayerCountNat(long cPtr);
53 54
	
54 55
	
55 56
	 /**
......
79 80
			case 8: res = getGCPCountNat(cPtr);break;
80 81
			case 9: res = getRasterDataTypeNat(cPtr);break;
81 82
			case 10: res = getDriverCountNat(cPtr);break;		//OGR
83
			case 11: res = getLayerCountNat(cPtr);break;		//OG
82 84
		}
83 85
			
84 86
		if(res<0)
trunk/libraries/libjni-gdal/src/ogrlayer_interfaz.cpp
1
 /**********************************************************************
2
 * $Id$
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_jgdal_OGRLayer.h"
30
#include "es_gva_cit_jgdal_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_jgdal_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
  
0 53

  

Also available in: Unified diff