Revision 35412
tags/v2_0_0_Build_2027/libjni-gdal/src/test/java/es/gva/cit/jgdal/TestReadData.java | ||
---|---|---|
1 |
package es.gva.cit.jgdal; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
|
|
5 |
import junit.framework.TestCase; |
|
6 |
|
|
7 |
/** |
|
8 |
* Test de acceso a datos de la imagen. |
|
9 |
* @author Miguel ?ngel Qierol Carratal? <miguelangel.querol@iver.es> |
|
10 |
* |
|
11 |
*/ |
|
12 |
public class TestReadData extends TestCase{ |
|
13 |
|
|
14 |
private Gdal gdal = null; |
|
15 |
private String baseDir = "./test-images/"; |
|
16 |
private String file1 = baseDir + "testGdal.tif"; |
|
17 |
private String[] metadata = null; |
|
18 |
|
|
19 |
public void start(){ |
|
20 |
try { |
|
21 |
setUp(); |
|
22 |
testStack(); |
|
23 |
} catch (GdalException e) { |
|
24 |
e.printStackTrace(); |
|
25 |
} catch (IOException e) { |
|
26 |
e.printStackTrace(); |
|
27 |
} |
|
28 |
|
|
29 |
} |
|
30 |
|
|
31 |
public void setUp() throws GdalException, IOException{ |
|
32 |
gdal = new Gdal(); |
|
33 |
gdal.open(file1, Gdal.GA_Update); |
|
34 |
} |
|
35 |
|
|
36 |
public void testStack() throws GdalException, IOException{ |
|
37 |
//Llamada sin dominio |
|
38 |
metadata = gdal.getMetadata(); |
|
39 |
assertNotNull("No se han devuelto metadatos", metadata); |
|
40 |
for (int i = 0 ; i<metadata.length ; i++){ |
|
41 |
System.out.println("Metadato: " + metadata[i]); |
|
42 |
} |
|
43 |
|
|
44 |
//Llamada con dominio "Image Structure Metadata" |
|
45 |
metadata = gdal.getMetadata("Image Structure Metadata"); |
|
46 |
assertNotNull("No se han devuelto metadatos", metadata); |
|
47 |
for (int i = 0 ; i<metadata.length ; i++){ |
|
48 |
System.out.println("Metadato: " + metadata[i]); |
|
49 |
} |
|
50 |
|
|
51 |
//Comprobaci?n del tama?o de la imagen |
|
52 |
assertEquals(842, gdal.getRasterXSize()); |
|
53 |
assertEquals(1023, gdal.getRasterYSize()); |
|
54 |
|
|
55 |
//Comprobaci?n del n?mero de bandas |
|
56 |
assertEquals(4, gdal.getRasterCount()); |
|
57 |
|
|
58 |
//Comprobaci?n del driver de la imagen |
|
59 |
assertEquals("GTiff", gdal.getDriverShortName()); |
|
60 |
|
|
61 |
//Comprobaci?n del acceso a las bandas |
|
62 |
for (int i = 0 ; i < gdal.getRasterCount() ; i++){ |
|
63 |
assertNotNull(gdal.getRasterBand(i+1)); |
|
64 |
} |
|
65 |
|
|
66 |
gdal.close(); |
|
67 |
gdal = null; |
|
68 |
System.gc(); |
|
69 |
} |
|
70 |
} |
tags/v2_0_0_Build_2027/libjni-gdal/src/test/java/es/gva/cit/jgdal/TestReadBandData.java | ||
---|---|---|
1 |
package es.gva.cit.jgdal; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
|
|
5 |
import junit.framework.TestCase; |
|
6 |
|
|
7 |
/** |
|
8 |
* Test de acceso a datos de las bandas de una imagen. |
|
9 |
* @author Miguel ?ngel Querol Carratal? <miguelangel.querol@iver.es> |
|
10 |
* |
|
11 |
*/ |
|
12 |
public class TestReadBandData extends TestCase{ |
|
13 |
private Gdal gdal = null; |
|
14 |
private GdalRasterBand band = null; |
|
15 |
private String baseDir = "./test-images/"; |
|
16 |
private String file1 = baseDir + "testGdal.tif"; |
|
17 |
|
|
18 |
public void start(){ |
|
19 |
try { |
|
20 |
setUp(); |
|
21 |
testStack(); |
|
22 |
} catch (GdalException e) { |
|
23 |
e.printStackTrace(); |
|
24 |
} catch (IOException e) { |
|
25 |
e.printStackTrace(); |
|
26 |
} |
|
27 |
|
|
28 |
} |
|
29 |
|
|
30 |
public void setUp() throws GdalException, IOException{ |
|
31 |
gdal = new Gdal(); |
|
32 |
gdal.open(file1, Gdal.GA_Update); |
|
33 |
} |
|
34 |
|
|
35 |
public void testStack() throws GdalException, IOException{ |
|
36 |
//Llamada sin dominio |
|
37 |
String[] metadata = gdal.getMetadata(); |
|
38 |
assertNotNull("No se han devuelto metadatos", metadata); |
|
39 |
for (int i = 0 ; i<metadata.length ; i++){ |
|
40 |
System.out.println("Metadato: " + metadata[i]); |
|
41 |
} |
|
42 |
|
|
43 |
//Llamada con dominio "Image Structure Metadata" |
|
44 |
metadata = gdal.getMetadata("Image Structure Metadata"); |
|
45 |
assertNotNull("No se han devuelto metadatos", metadata); |
|
46 |
for (int i = 0 ; i<metadata.length ; i++){ |
|
47 |
System.out.println("Metadato: " + metadata[i]); |
|
48 |
} |
|
49 |
|
|
50 |
//Comprobaci?n del tama?o de la imagen |
|
51 |
assertEquals(842, gdal.getRasterXSize()); |
|
52 |
assertEquals(1023, gdal.getRasterYSize()); |
|
53 |
|
|
54 |
//Comprobaci?n del n?mero de bandas |
|
55 |
assertEquals(4, gdal.getRasterCount()); |
|
56 |
|
|
57 |
//Comprobaci?n del driver de la imagen |
|
58 |
assertEquals("GTiff", gdal.getDriverShortName()); |
|
59 |
|
|
60 |
//Comprobaci?n del acceso a las bandas |
|
61 |
for (int i = 0 ; i < gdal.getRasterCount() ; i++){ |
|
62 |
assertNotNull(gdal.getRasterBand(i+1)); |
|
63 |
} |
|
64 |
} |
|
65 |
} |
tags/v2_0_0_Build_2027/libjni-gdal/src/test/java/es/gva/cit/jgdal/TestWarpDataset.java | ||
---|---|---|
1 |
package es.gva.cit.jgdal; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import java.io.IOException; |
|
5 |
|
|
6 |
import junit.framework.TestCase; |
|
7 |
|
|
8 |
public class TestWarpDataset extends TestCase { |
|
9 |
private GdalWarp warp = null; |
|
10 |
private String baseDir = "./test-images/"; |
|
11 |
private String src = baseDir + "testGdalWarp.tif"; |
|
12 |
private String dst = baseDir + "warpedImage.tif"; |
|
13 |
private String frm = "GTiff"; |
|
14 |
private String t_srs = "EPSG:23030"; |
|
15 |
|
|
16 |
public void start() { |
|
17 |
setUp(); |
|
18 |
testStack(); |
|
19 |
} |
|
20 |
|
|
21 |
public void setUp() { |
|
22 |
warp = new GdalWarp(); |
|
23 |
File f = new File(src); |
|
24 |
Gdal dataset = new Gdal(); |
|
25 |
|
|
26 |
try { |
|
27 |
assertTrue("El fichero no existe", f.exists()); |
|
28 |
assertTrue("El fichero no se puede leer", f.canRead()); |
|
29 |
dataset.open(src, Gdal.GA_ReadOnly); |
|
30 |
GdalRasterBand band = dataset.getRasterBand(1); |
|
31 |
band.readRaster(0, 0, 10, 10, 10, 10, Gdal.GDT_Byte); |
|
32 |
} catch (GdalException e) { |
|
33 |
new AssertionError("Fallo en gdal al acceder al fichero fuente"); |
|
34 |
} catch (IOException e) { |
|
35 |
new AssertionError("Fallo en gdal al acceder al fichero fuente"); |
|
36 |
e.printStackTrace(); |
|
37 |
} |
|
38 |
} |
|
39 |
|
|
40 |
public void testStack() { |
|
41 |
assertNotNull(t_srs); |
|
42 |
|
|
43 |
warp.warp(t_srs, src, dst, frm); |
|
44 |
System.err.println("Proceso completado al " + warp.getPercent() + " %"); |
|
45 |
|
|
46 |
File f = new File(dst); |
|
47 |
|
|
48 |
assertTrue("El fichero destino no existe", f.exists()); |
|
49 |
assertTrue("El fichero destino no se puede leer", f.canRead()); |
|
50 |
} |
|
51 |
} |
tags/v2_0_0_Build_2027/libjni-gdal/src/test/java/org/gvsig/addo/TestBuildOverviews.java | ||
---|---|---|
1 |
package org.gvsig.addo; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
|
|
5 |
import junit.framework.TestCase; |
|
6 |
import es.gva.cit.jgdal.Gdal; |
|
7 |
import es.gva.cit.jgdal.GdalException; |
|
8 |
|
|
9 |
/** |
|
10 |
* Test para la generacion de overviews sobre una imagen raster. |
|
11 |
* Registra un listener para mostrar el incremento de la tarea. |
|
12 |
* |
|
13 |
* 18-nov-2007 |
|
14 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
15 |
*/ |
|
16 |
public class TestBuildOverviews extends TestCase implements IOverviewIncrement { |
|
17 |
private int value = 0; |
|
18 |
|
|
19 |
private Jaddo addo = null; |
|
20 |
private Gdal gdal = null; |
|
21 |
private String path = "./test-images/testGdalWarp.tif"; |
|
22 |
|
|
23 |
public void start(){ |
|
24 |
setUp(); |
|
25 |
testStack(); |
|
26 |
} |
|
27 |
|
|
28 |
|
|
29 |
public void setUp(){ |
|
30 |
addo = new Jaddo(); |
|
31 |
addo.setIncrementListener(this); |
|
32 |
gdal = new Gdal(); |
|
33 |
} |
|
34 |
|
|
35 |
|
|
36 |
public void testStack(){ |
|
37 |
try { |
|
38 |
addo.buildOverviews(Jaddo.AVERAGE, path, new int[]{2, 4, 8, 16}); |
|
39 |
gdal.open(path, Gdal.GA_ReadOnly); |
|
40 |
assertTrue("No hay overviews!!", gdal.getRasterBand(1).getOverviewCount()>0); |
|
41 |
} catch (BuildingOverviewsException e) { |
|
42 |
System.err.println(e); |
|
43 |
} catch (WritingException e) { |
|
44 |
System.err.println(e); |
|
45 |
} catch (GdalException e) { |
|
46 |
e.printStackTrace(); |
|
47 |
} catch (IOException e) { |
|
48 |
e.printStackTrace(); |
|
49 |
} |
|
50 |
|
|
51 |
} |
|
52 |
|
|
53 |
public int getPercent() { |
|
54 |
return value; |
|
55 |
} |
|
56 |
|
|
57 |
public void setPercent(int value) { |
|
58 |
this.value = value; |
|
59 |
System.out.println("Increment:" + value); |
|
60 |
} |
|
61 |
} |
tags/v2_0_0_Build_2027/libjni-gdal/src/main/native/CMakeLists.txt | ||
---|---|---|
1 |
ADD_SUBDIRECTORY(jgdal) |
|
2 |
|
|
3 |
|
tags/v2_0_0_Build_2027/libjni-gdal/src/main/native/jgdal/ogrpolygon_interfaz.cpp | ||
---|---|---|
1 |
/********************************************************************** |
|
2 |
* $Id: ogrpolygon_interfaz.cpp 7765 2006-10-03 07:05:18Z nacho $ |
|
3 |
* |
|
4 |
* Name: ogrpolygon_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 |
#include <jni.h> |
|
52 |
#include "ogr_api.h" |
|
53 |
#include "ogrsf_frmts.h" |
|
54 |
|
|
55 |
/******************************************************************************/ |
|
56 |
// OGRPolygon |
|
57 |
/******************************************************************************/ |
|
58 |
|
|
59 |
JNIEXPORT jlong JNICALL Java_es_gva_cit_jogr_OGRPolygon_OGRPolygonNat |
|
60 |
(JNIEnv *env, jobject obj){ |
|
61 |
|
|
62 |
long ptro_polig = -1; |
|
63 |
|
|
64 |
OGRPolygon *poligono = new OGRPolygon(); |
|
65 |
|
|
66 |
if(poligono==NULL)return -1; |
|
67 |
ptro_polig = (long)&(*poligono); |
|
68 |
|
|
69 |
return ptro_polig; |
|
70 |
} |
|
71 |
|
tags/v2_0_0_Build_2027/libjni-gdal/src/main/native/jgdal/ogrfeaturedefn_interfaz.cpp | ||
---|---|---|
1 |
/********************************************************************** |
|
2 |
* $Id: ogrfeaturedefn_interfaz.cpp 7765 2006-10-03 07:05:18Z nacho $ |
|
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 |
/* 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>h" |
|
53 |
#include "ogr_api.h" |
|
54 |
#include "ogrsf_frmts.h" |
|
55 |
|
|
56 |
/******************************************************************************/ |
|
57 |
// getName |
|
58 |
/******************************************************************************/ |
|
59 |
|
|
60 |
JNIEXPORT jstring JNICALL Java_es_gva_cit_jogr_OGRFeatureDefn_getNameNat |
|
61 |
(JNIEnv *env, jobject obj, jlong cPtr){ |
|
62 |
|
|
63 |
OGRFeatureDefn *fd = (OGRFeatureDefn *) 0 ; |
|
64 |
jstring nom_fd; |
|
65 |
|
|
66 |
fd = *(OGRFeatureDefn **)&cPtr; |
|
67 |
const char *name = fd->GetName(); |
|
68 |
|
|
69 |
if(name!=NULL) |
|
70 |
nom_fd = env->NewStringUTF(name); |
|
71 |
else return NULL; |
|
72 |
|
|
73 |
return nom_fd; |
|
74 |
|
|
75 |
} |
|
76 |
|
|
77 |
/******************************************************************************/ |
|
78 |
// getGeomType |
|
79 |
/******************************************************************************/ |
|
80 |
|
|
81 |
JNIEXPORT jint JNICALL Java_es_gva_cit_jogr_OGRFeatureDefn_getGeomTypeNat |
|
82 |
(JNIEnv *env, jobject obj, jlong cPtr){ |
|
83 |
|
|
84 |
OGRFeatureDefn *fd = (OGRFeatureDefn *) 0 ; |
|
85 |
|
|
86 |
fd = *(OGRFeatureDefn **)&cPtr; |
|
87 |
OGRwkbGeometryType tipo = fd->GetGeomType(); |
|
88 |
|
|
89 |
if(tipo==wkbUnknown)return 0; |
|
90 |
if(tipo==wkbPoint)return 1; |
|
91 |
if(tipo==wkbLineString)return 2; |
|
92 |
if(tipo==wkbPolygon)return 3; |
|
93 |
if(tipo==wkbMultiPoint)return 4; |
|
94 |
if(tipo==wkbMultiLineString)return 5; |
|
95 |
if(tipo==wkbMultiPolygon)return 6; |
|
96 |
if(tipo==wkbGeometryCollection)return 7; |
|
97 |
if(tipo==wkbNone)return 8; |
|
98 |
if(tipo==wkbLinearRing)return 9; |
|
99 |
if(tipo==wkbPoint25D)return 10; |
|
100 |
if(tipo==wkbLineString25D)return 11; |
|
101 |
if(tipo==wkbPolygon25D)return 12; |
|
102 |
if(tipo==wkbMultiPoint25D)return 13; |
|
103 |
if(tipo==wkbMultiLineString25D)return 14; |
|
104 |
if(tipo==wkbMultiPolygon25D)return 15; |
|
105 |
if(tipo==wkbGeometryCollection25D)return 16; |
|
106 |
|
|
107 |
return -1; |
|
108 |
} |
|
109 |
|
|
110 |
/******************************************************************************/ |
|
111 |
// ~OGRFeatureDefn |
|
112 |
/******************************************************************************/ |
|
113 |
|
|
114 |
JNIEXPORT void JNICALL Java_es_gva_cit_jogr_OGRFeatureDefn_FreeOGRFeatureDefnNat |
|
115 |
(JNIEnv *env, jobject obj, jlong cPtr){ |
|
116 |
|
|
117 |
OGRFeatureDefn *df = (OGRFeatureDefn *) 0 ; |
|
118 |
|
|
119 |
df = *(OGRFeatureDefn **)&cPtr; |
|
120 |
if(df!=NULL){ |
|
121 |
delete df; |
|
122 |
} |
|
123 |
} |
|
124 |
|
|
125 |
/******************************************************************************/ |
|
126 |
// getFieldCount |
|
127 |
/******************************************************************************/ |
|
128 |
|
|
129 |
JNIEXPORT jint JNICALL Java_es_gva_cit_jogr_JNIBase_getFieldCountNat |
|
130 |
(JNIEnv *env, jobject obj, jlong cPtr){ |
|
131 |
|
|
132 |
OGRFeatureDefn *df = (OGRFeatureDefn *) 0 ; |
|
133 |
int nfields=-1; |
|
134 |
|
|
135 |
df = *(OGRFeatureDefn **)&cPtr; |
|
136 |
if(df!=NULL){ |
|
137 |
nfields = df->GetFieldCount(); |
|
138 |
} |
|
139 |
return nfields; |
|
140 |
} |
|
141 |
|
|
142 |
/******************************************************************************/ |
|
143 |
// getFieldDefn |
|
144 |
/******************************************************************************/ |
|
145 |
|
|
146 |
JNIEXPORT jlong JNICALL Java_es_gva_cit_jogr_OGRFeatureDefn_getFieldDefnNat |
|
147 |
(JNIEnv *env, jobject obj, jlong cPtr, jint i){ |
|
148 |
|
|
149 |
OGRFeatureDefn *df = (OGRFeatureDefn *) 0 ; |
|
150 |
OGRFieldDefn *field; |
|
151 |
long ptro_field; |
|
152 |
df = *(OGRFeatureDefn **)&cPtr; |
|
153 |
if(df!=NULL){ |
|
154 |
field = df->GetFieldDefn(i); |
|
155 |
ptro_field = (long)&(*field); |
|
156 |
} |
|
157 |
return (jlong)ptro_field; |
|
158 |
|
|
159 |
} |
|
160 |
|
|
161 |
|
|
162 |
/******************************************************************************/ |
|
163 |
// getFieldIndex |
|
164 |
/******************************************************************************/ |
|
165 |
|
|
166 |
JNIEXPORT jint JNICALL Java_es_gva_cit_jogr_OGRFeatureDefn_getFieldIndexNat |
|
167 |
(JNIEnv *env, jobject obj, jlong cPtr, jstring field){ |
|
168 |
|
|
169 |
OGRFeatureDefn *fd = (OGRFeatureDefn *) 0 ; |
|
170 |
const char *campo; |
|
171 |
int index=-1; |
|
172 |
|
|
173 |
fd = *(OGRFeatureDefn **)&cPtr; |
|
174 |
if(fd!=NULL){ |
|
175 |
campo = env->GetStringUTFChars(field, 0); |
|
176 |
index = fd->GetFieldIndex(campo); |
|
177 |
env->ReleaseStringUTFChars(field, campo); |
|
178 |
} |
|
179 |
return index; |
|
180 |
} |
|
181 |
|
|
182 |
/******************************************************************************/ |
|
183 |
// addFieldDefn |
|
184 |
/******************************************************************************/ |
|
185 |
|
|
186 |
JNIEXPORT void JNICALL Java_es_gva_cit_jogr_OGRFeatureDefn_addFieldDefnNat |
|
187 |
(JNIEnv *env, jobject obj, jlong cPtr, jlong fdefn){ |
|
188 |
|
|
189 |
OGRFeatureDefn *fd = (OGRFeatureDefn *) 0 ; |
|
190 |
OGRFieldDefn *fielddefn; |
|
191 |
|
|
192 |
fd = *(OGRFeatureDefn **)&cPtr; |
|
193 |
fielddefn = *(OGRFieldDefn **)&fdefn; |
|
194 |
if(fd!=NULL){ |
|
195 |
fd->AddFieldDefn(fielddefn); |
|
196 |
} |
|
197 |
} |
|
198 |
|
|
199 |
/******************************************************************************/ |
|
200 |
// setGeomType |
|
201 |
/******************************************************************************/ |
|
202 |
|
|
203 |
JNIEXPORT void JNICALL Java_es_gva_cit_jogr_OGRFeatureDefn_setGeomTypeNat |
|
204 |
(JNIEnv *env, jobject obj, jlong cPtr, jstring eGType){ |
|
205 |
|
|
206 |
OGRFeatureDefn *fd = (OGRFeatureDefn *) 0 ; |
|
207 |
OGRwkbGeometryType geomtype; |
|
208 |
|
|
209 |
fd = *(OGRFeatureDefn **)&cPtr; |
|
210 |
if(fd!=NULL){ |
|
211 |
const char *type = env->GetStringUTFChars( eGType, 0); |
|
212 |
if(strcmp(type,"wkbUnknown")==0)geomtype = wkbUnknown; |
|
213 |
else if(strcmp(type,"wkbPoint")==0)geomtype = wkbPoint; |
|
214 |
else if(strcmp(type,"wkbLineString")==0)geomtype = wkbLineString; |
|
215 |
else if(strcmp(type,"wkbPolygon")==0)geomtype = wkbPolygon; |
|
216 |
else if(strcmp(type,"wkbMultiPoint")==0)geomtype = wkbMultiPoint; |
|
217 |
else if(strcmp(type,"wkbMultiLineString")==0)geomtype = wkbMultiLineString; |
|
218 |
else if(strcmp(type,"wkbMultiPolygon")==0)geomtype = wkbMultiPolygon; |
|
219 |
else if(strcmp(type,"wkbGeometryCollection")==0)geomtype = wkbGeometryCollection; |
|
220 |
else if(strcmp(type,"wkbNone")==0)geomtype = wkbNone; |
|
221 |
else if(strcmp(type,"wkbLinearRing")==0)geomtype = wkbLinearRing; |
|
222 |
else if(strcmp(type,"wkbPoint25D")==0)geomtype = wkbPoint25D; |
|
223 |
else if(strcmp(type,"wkbLineString25D")==0)geomtype = wkbLineString25D; |
|
224 |
else if(strcmp(type,"wkbPolygon25D")==0)geomtype = wkbPolygon25D; |
|
225 |
else if(strcmp(type,"wkbMultiPoint25D")==0)geomtype = wkbMultiPoint25D; |
|
226 |
else if(strcmp(type,"wkbMultiLineString25D")==0)geomtype = wkbMultiLineString25D; |
|
227 |
else if(strcmp(type,"wkbMultiPolygon25D")==0)geomtype = wkbMultiPolygon25D; |
|
228 |
else if(strcmp(type,"wkbGeometryCollection25D")==0)geomtype = wkbGeometryCollection25D; |
|
229 |
|
|
230 |
fd->SetGeomType(geomtype); |
|
231 |
env->ReleaseStringUTFChars( eGType, type ); |
|
232 |
|
|
233 |
|
|
234 |
} |
|
235 |
} |
|
236 |
|
|
237 |
/******************************************************************************/ |
|
238 |
// cloneFeatureDefn |
|
239 |
/******************************************************************************/ |
|
240 |
|
|
241 |
JNIEXPORT jlong JNICALL Java_es_gva_cit_jogr_OGRFeatureDefn_cloneFeatureDefnNat |
|
242 |
(JNIEnv *env, jobject obj, jlong cPtr){ |
|
243 |
|
|
244 |
OGRFeatureDefn *fd = (OGRFeatureDefn *) 0 ; |
|
245 |
OGRFeatureDefn *return_fd; |
|
246 |
long ptr_fd=-1; |
|
247 |
|
|
248 |
fd = *(OGRFeatureDefn **)&cPtr; |
|
249 |
if(fd!=NULL){ |
|
250 |
return_fd = fd->Clone(); |
|
251 |
if(return_fd!=NULL) |
|
252 |
ptr_fd = (long)&(*return_fd); |
|
253 |
} |
|
254 |
|
|
255 |
return (jlong)ptr_fd; |
|
256 |
} |
|
257 |
|
|
258 |
/******************************************************************************/ |
|
259 |
// createFeatureDefn |
|
260 |
/******************************************************************************/ |
|
261 |
|
|
262 |
JNIEXPORT jlong JNICALL Java_es_gva_cit_jogr_OGRFeatureDefn_createFeatureDefnNat |
|
263 |
(JNIEnv *env, jclass clase, jstring pszName){ |
|
264 |
|
|
265 |
OGRFeatureDefn *return_fd; |
|
266 |
long ptr_fd=-1; |
|
267 |
const char *name; |
|
268 |
|
|
269 |
name = env->GetStringUTFChars(pszName, 0); |
|
270 |
return_fd = OGRFeatureDefn::CreateFeatureDefn(name); |
|
271 |
if(return_fd!=NULL) |
|
272 |
ptr_fd = (long)&(*return_fd); |
|
273 |
env->ReleaseStringUTFChars( pszName, name ); |
|
274 |
|
|
275 |
return (jlong)ptr_fd; |
|
276 |
} |
|
277 |
|
|
278 |
/******************************************************************************/ |
|
279 |
// destroyFeatureDefn |
|
280 |
/******************************************************************************/ |
|
281 |
|
|
282 |
JNIEXPORT void JNICALL Java_es_gva_cit_jogr_OGRFeatureDefn_destroyFeatureDefnNat |
|
283 |
(JNIEnv *env, jclass clase, jlong ptr_fd){ |
|
284 |
|
|
285 |
OGRFeatureDefn *fd = (OGRFeatureDefn *) 0 ; |
|
286 |
|
|
287 |
fd = *(OGRFeatureDefn **)&ptr_fd; |
|
288 |
if(fd!=NULL){ |
|
289 |
OGRFeatureDefn::DestroyFeatureDefn(fd); |
|
290 |
} |
|
291 |
} |
|
292 |
|
|
293 |
/******************************************************************************/ |
|
294 |
// referenceFeatureDefn |
|
295 |
/******************************************************************************/ |
|
296 |
|
|
297 |
JNIEXPORT jint JNICALL Java_es_gva_cit_jogr_JNIBase_referenceFeatureDefnNat |
|
298 |
(JNIEnv *env, jobject obj, jlong cPtr){ |
|
299 |
|
|
300 |
OGRFeatureDefn *fd = (OGRFeatureDefn *) 0 ; |
|
301 |
int res=-1; |
|
302 |
|
|
303 |
fd = *(OGRFeatureDefn **)&cPtr; |
|
304 |
if(fd!=NULL){ |
|
305 |
res = fd->Reference(); |
|
306 |
} |
|
307 |
return res; |
|
308 |
} |
|
309 |
|
|
310 |
/******************************************************************************/ |
|
311 |
// dereferenceFeatureDefn |
|
312 |
/******************************************************************************/ |
|
313 |
|
|
314 |
JNIEXPORT jint JNICALL Java_es_gva_cit_jogr_JNIBase_dereferenceFeatureDefnNat |
|
315 |
(JNIEnv *env, jobject obj, jlong cPtr){ |
|
316 |
|
|
317 |
OGRFeatureDefn *fd = (OGRFeatureDefn *) 0 ; |
|
318 |
int res=-1; |
|
319 |
|
|
320 |
fd = *(OGRFeatureDefn **)&cPtr; |
|
321 |
if(fd!=NULL){ |
|
322 |
res = fd->Dereference(); |
|
323 |
} |
|
324 |
|
|
325 |
return res; |
|
326 |
} |
|
327 |
|
|
328 |
/******************************************************************************/ |
|
329 |
// getReferenceCount |
|
330 |
/******************************************************************************/ |
|
331 |
|
|
332 |
JNIEXPORT jint JNICALL Java_es_gva_cit_jogr_JNIBase_getReferenceCountNat |
|
333 |
(JNIEnv *env, jobject obj, jlong cPtr){ |
|
334 |
|
|
335 |
OGRFeatureDefn *fd = (OGRFeatureDefn *) 0 ; |
|
336 |
int count=-1; |
|
337 |
|
|
338 |
fd = *(OGRFeatureDefn **)&cPtr; |
|
339 |
if(fd!=NULL){ |
|
340 |
count = fd->GetReferenceCount(); |
|
341 |
} |
|
342 |
return count; |
|
343 |
} |
|
344 |
|
tags/v2_0_0_Build_2027/libjni-gdal/src/main/native/jgdal/gdalwarp_interfaz.cpp | ||
---|---|---|
1 |
/********************************************************************** |
|
2 |
* $Id: gdalwarp_interfaz.cpp,v 1.0 2007/04/10 00:08:29 maquerol Exp $ |
|
3 |
* |
|
4 |
* Name: gdalwarp_interfaz.c |
|
5 |
* Project: JGDAL. Interface java to gdalwarp (Frank Warmerdam). |
|
6 |
* Purpose: dataset's Basic Funcions. |
|
7 |
* Author: Miguel ?ngel Querol <miguelangel.querol@iver.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 |
* [01] 01-Oct-2005 nbt OpenArray function to support name parameter in char array |
|
28 |
*/ |
|
29 |
#include <jni.h> |
|
30 |
#include "gdal.h" |
|
31 |
#include "cpl_string.h" |
|
32 |
|
|
33 |
int warpFunction(JNIEnv *env, char *s_srs, char *t_srs, char *source, char *dest, char *format); |
|
34 |
|
|
35 |
JNIEnv *gEnv; |
|
36 |
jobject gObj; |
|
37 |
jclass gClass; |
|
38 |
|
|
39 |
/******************************************************************************/ |
|
40 |
// Warp |
|
41 |
/******************************************************************************/ |
|
42 |
|
|
43 |
extern "C" JNIEXPORT jint JNICALL Java_es_gva_cit_jgdal_GdalWarp_warpDataset(JNIEnv *env, jobject obj, jstring srcProj, jstring newProj, jstring source, jstring dest, jstring format) { |
|
44 |
gEnv = env; |
|
45 |
gObj = obj; |
|
46 |
gClass = (env)->GetObjectClass(obj); |
|
47 |
|
|
48 |
const char * oldProj; |
|
49 |
const char * proj; |
|
50 |
const char * src; |
|
51 |
const char * dst; |
|
52 |
const char * form; |
|
53 |
int stat = 2; |
|
54 |
|
|
55 |
proj = (env)->GetStringUTFChars(newProj, 0); |
|
56 |
src = (env)->GetStringUTFChars(source, 0); |
|
57 |
dst = (env)->GetStringUTFChars(dest, 0); |
|
58 |
|
|
59 |
if (format != NULL) { |
|
60 |
form = (env)->GetStringUTFChars(format, 0); |
|
61 |
if (srcProj != NULL) { |
|
62 |
oldProj = (env)->GetStringUTFChars(srcProj, 0); |
|
63 |
stat = warpFunction(env, (char *)oldProj, (char *)proj, (char *)src, (char *)dst, (char *)form); |
|
64 |
(env)->ReleaseStringUTFChars(srcProj, oldProj); |
|
65 |
} else { |
|
66 |
stat = warpFunction(env, NULL, (char *)proj, (char *)src, (char *)dst, (char *)form); |
|
67 |
} |
|
68 |
(env)->ReleaseStringUTFChars(format, form); |
|
69 |
} else { |
|
70 |
if (srcProj != NULL) { |
|
71 |
oldProj = (env)->GetStringUTFChars(srcProj, 0); |
|
72 |
stat = warpFunction(env, (char *)oldProj, (char *)proj, (char *)src, (char *)dst, NULL); |
|
73 |
(env)->ReleaseStringUTFChars(srcProj,oldProj); |
|
74 |
} else { |
|
75 |
stat = warpFunction(env, NULL, (char *)proj, (char *)src, (char *)dst, NULL); |
|
76 |
} |
|
77 |
} |
|
78 |
|
|
79 |
(env)->ReleaseStringUTFChars(newProj,proj); |
|
80 |
(env)->ReleaseStringUTFChars(source,src); |
|
81 |
(env)->ReleaseStringUTFChars(dest,dst); |
|
82 |
|
|
83 |
return stat; |
|
84 |
} |
|
85 |
|
|
86 |
/******************************************************************************/ |
|
87 |
// StatusCallback |
|
88 |
/******************************************************************************/ |
|
89 |
//Asigna el tanto por cien de imagen que lleva comprimido en una variable de java |
|
90 |
//Ejecuta la funci?n updatePercent de java despues de actualizar la varible. |
|
91 |
|
|
92 |
void CPL_STDCALL statusCallBack(int nPercent) { |
|
93 |
jclass GdalWarp = gClass; |
|
94 |
JNIEnv *env=gEnv; |
|
95 |
jobject obj = gObj; |
|
96 |
jmethodID metodo; |
|
97 |
jfieldID fid; |
|
98 |
jint jpercent = nPercent; |
|
99 |
|
|
100 |
fid = (env)->GetFieldID(gClass, "porcentaje", "I"); |
|
101 |
(env)->SetIntField(obj, fid, jpercent); |
|
102 |
} |
tags/v2_0_0_Build_2027/libjni-gdal/src/main/native/jgdal/ogrdatasource_interfaz.cpp | ||
---|---|---|
1 |
/********************************************************************** |
|
2 |
* $Id: ogrdatasource_interfaz.cpp 7765 2006-10-03 07:05:18Z nacho $ |
|
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 |
/* 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 "ogr_api.h" |
|
54 |
#include "ogrsf_frmts.h" |
|
55 |
|
|
56 |
|
|
57 |
|
|
58 |
/******************************************************************************/ |
|
59 |
// getName |
|
60 |
/******************************************************************************/ |
|
61 |
|
|
62 |
JNIEXPORT jstring JNICALL Java_es_gva_cit_jogr_OGRDataSource_getNameNat |
|
63 |
(JNIEnv *env, jobject obj, jlong cPtr){ |
|
64 |
|
|
65 |
OGRDataSource *ds = (OGRDataSource *) 0 ; |
|
66 |
jstring nom_ds; |
|
67 |
|
|
68 |
ds = *(OGRDataSource **)&cPtr; |
|
69 |
const char *name = ds->GetName(); |
|
70 |
|
|
71 |
if(name!=NULL) |
|
72 |
nom_ds = env->NewStringUTF(name); |
|
73 |
else return NULL; |
|
74 |
|
|
75 |
return nom_ds; |
|
76 |
|
|
77 |
} |
|
78 |
|
|
79 |
/******************************************************************************/ |
|
80 |
// getLayerCount |
|
81 |
/******************************************************************************/ |
|
82 |
|
|
83 |
JNIEXPORT jint JNICALL Java_es_gva_cit_jogr_JNIBase_getLayerCountNat |
|
84 |
(JNIEnv *env, jobject obj, jlong cPtr){ |
|
85 |
|
|
86 |
int res=-1; |
|
87 |
OGRDataSource *ds = (OGRDataSource *) 0 ; |
|
88 |
|
|
89 |
ds = *(OGRDataSource **)&cPtr; |
|
90 |
if(ds!=NULL) |
|
91 |
res = ds->GetLayerCount(); |
|
92 |
|
|
93 |
return res; |
|
94 |
} |
|
95 |
|
|
96 |
/******************************************************************************/ |
|
97 |
// getLayer |
|
98 |
/******************************************************************************/ |
|
99 |
|
|
100 |
JNIEXPORT jlong JNICALL Java_es_gva_cit_jogr_OGRDataSource_getLayerNat |
|
101 |
(JNIEnv *env, jobject obj, jlong cPtr, jint iLayer){ |
|
102 |
|
|
103 |
OGRDataSource *ds = (OGRDataSource *) 0 ; |
|
104 |
OGRLayer *capa; |
|
105 |
long layer=-1; |
|
106 |
|
|
107 |
ds = *(OGRDataSource **)&cPtr; |
|
108 |
if(ds!=NULL){ |
|
109 |
capa = ds->GetLayer(iLayer); |
|
110 |
if(capa!=NULL)layer = (long)&(*capa); |
|
111 |
} |
|
112 |
|
|
113 |
return (jlong)layer; |
|
114 |
|
|
115 |
} |
|
116 |
|
|
117 |
/******************************************************************************/ |
|
118 |
// ~OGRDataSource |
|
119 |
/******************************************************************************/ |
|
120 |
|
|
121 |
JNIEXPORT void JNICALL Java_es_gva_cit_jogr_OGRDataSource_FreeOGRDataSource |
|
122 |
(JNIEnv *env, jobject obj, jlong cPtr){ |
|
123 |
|
|
124 |
OGRDataSource *df = (OGRDataSource *) 0 ; |
|
125 |
|
|
126 |
df = *(OGRDataSource **)&cPtr; |
|
127 |
if(df!=NULL){ |
|
128 |
delete df; |
|
129 |
} |
|
130 |
} |
|
131 |
|
|
132 |
/******************************************************************************/ |
|
133 |
// reference |
|
134 |
/******************************************************************************/ |
|
135 |
|
|
136 |
JNIEXPORT jint JNICALL Java_es_gva_cit_jogr_JNIBase_referenceNat |
|
137 |
(JNIEnv *env, jobject obj, jlong cPtr){ |
|
138 |
|
|
139 |
OGRDataSource *ds = (OGRDataSource *) 0 ; |
|
140 |
int res=-1; |
|
141 |
|
|
142 |
ds = *(OGRDataSource **)&cPtr; |
|
143 |
if(ds!=NULL){ |
|
144 |
res=ds->Reference(); |
|
145 |
} |
|
146 |
return res; |
|
147 |
|
|
148 |
} |
|
149 |
|
|
150 |
/******************************************************************************/ |
|
151 |
// dereference |
|
152 |
/******************************************************************************/ |
|
153 |
|
|
154 |
JNIEXPORT jint JNICALL Java_es_gva_cit_jogr_JNIBase_dereferenceNat |
|
155 |
(JNIEnv *env, jobject obj, jlong cPtr){ |
|
156 |
|
|
157 |
OGRDataSource *ds = (OGRDataSource *) 0 ; |
|
158 |
int res=-1; |
|
159 |
|
|
160 |
ds = *(OGRDataSource **)&cPtr; |
|
161 |
if(ds!=NULL){ |
|
162 |
res = ds->Dereference(); |
|
163 |
} |
|
164 |
return res; |
|
165 |
|
|
166 |
} |
|
167 |
|
|
168 |
/******************************************************************************/ |
|
169 |
// getRefCount |
|
170 |
/******************************************************************************/ |
|
171 |
|
|
172 |
JNIEXPORT jint JNICALL Java_es_gva_cit_jogr_JNIBase_getRefCountNat |
|
173 |
(JNIEnv *env, jobject obj, jlong cPtr){ |
|
174 |
|
|
175 |
OGRDataSource *ds = (OGRDataSource *) 0 ; |
|
176 |
int res = -1; |
|
177 |
|
|
178 |
ds = *(OGRDataSource **)&cPtr; |
|
179 |
if(ds!=NULL){ |
|
180 |
res = ds->GetRefCount(); |
|
181 |
} |
|
182 |
return res; |
|
183 |
|
|
184 |
|
|
185 |
} |
|
186 |
|
|
187 |
/******************************************************************************/ |
|
188 |
// getSummaryRefCount |
|
189 |
/******************************************************************************/ |
|
190 |
|
|
191 |
JNIEXPORT jint JNICALL Java_es_gva_cit_jogr_JNIBase_getSummaryRefCountNat |
|
192 |
(JNIEnv *env, jobject obj, jlong cPtr){ |
|
193 |
|
|
194 |
OGRDataSource *ds = (OGRDataSource *) 0 ; |
|
195 |
int res = -1; |
|
196 |
|
|
197 |
ds = *(OGRDataSource **)&cPtr; |
|
198 |
if(ds!=NULL){ |
|
199 |
res = ds->GetSummaryRefCount(); |
|
200 |
} |
|
201 |
return res; |
|
202 |
|
|
203 |
} |
|
204 |
|
|
205 |
/******************************************************************************/ |
|
206 |
// OGRDataSource |
|
207 |
/******************************************************************************/ |
|
208 |
|
|
209 |
JNIEXPORT jlong JNICALL Java_es_gva_cit_jogr_OGRDataSource_getLayerByNameNat |
|
210 |
(JNIEnv *env, jobject obj, jlong cPtr, jstring name){ |
|
211 |
|
|
212 |
OGRDataSource *ds = (OGRDataSource *) 0 ; |
|
213 |
const char *layername; |
|
214 |
OGRLayer *layer; |
|
215 |
long ptro_layer=-1; |
|
216 |
|
|
217 |
ds = *(OGRDataSource **)&cPtr; |
|
218 |
layername = env->GetStringUTFChars( name, 0 ); |
|
219 |
if(ds!=NULL){ |
|
220 |
layer=ds->GetLayerByName(layername); |
|
221 |
if(layer!=NULL)ptro_layer = (long)&(*layer); |
|
222 |
} |
|
223 |
env->ReleaseStringUTFChars( name, layername ); |
|
224 |
return (jlong)ptro_layer; |
|
225 |
} |
|
226 |
|
|
227 |
/******************************************************************************/ |
|
228 |
// deleteLayer |
|
229 |
/******************************************************************************/ |
|
230 |
|
|
231 |
JNIEXPORT jint JNICALL Java_es_gva_cit_jogr_OGRDataSource_deleteLayerNat |
|
232 |
(JNIEnv *env, jobject obj, jlong cPtr, jint layer){ |
|
233 |
|
|
234 |
OGRDataSource *ds = (OGRDataSource *) 0 ; |
|
235 |
int ogrerr; |
|
236 |
|
|
237 |
ds = *(OGRDataSource **)&cPtr; |
|
238 |
if(ds!=NULL){ |
|
239 |
ogrerr = ds->DeleteLayer(layer); |
|
240 |
} |
|
241 |
return ogrerr; |
|
242 |
} |
|
243 |
|
|
244 |
/******************************************************************************/ |
|
245 |
// testCapability |
|
246 |
/******************************************************************************/ |
|
247 |
|
|
248 |
JNIEXPORT jint JNICALL Java_es_gva_cit_jogr_OGRDataSource_testCapabilityNat |
|
249 |
(JNIEnv *env, jobject obj, jlong cPtr, jstring cap){ |
|
250 |
|
|
251 |
OGRDataSource *ds = (OGRDataSource *) 0 ; |
|
252 |
int res=-1; |
|
253 |
const char *capability; |
|
254 |
|
|
255 |
ds = *(OGRDataSource **)&cPtr; |
|
256 |
if(ds!=NULL){ |
|
257 |
capability = env->GetStringUTFChars( cap, 0 ); |
|
258 |
res = ds->TestCapability(capability); |
|
259 |
env->ReleaseStringUTFChars( cap, capability ); |
|
260 |
} |
|
261 |
return res; |
|
262 |
|
|
263 |
} |
|
264 |
|
|
265 |
/******************************************************************************/ |
|
266 |
// createLayer |
|
267 |
/******************************************************************************/ |
|
268 |
|
|
269 |
JNIEXPORT jlong JNICALL Java_es_gva_cit_jogr_OGRDataSource_createLayerNat |
|
270 |
(JNIEnv *env, jobject obj, jlong cPtr, jstring pszName, jlong poSpatialRef, jstring eGType, jobjectArray papszOptions){ |
|
271 |
|
|
272 |
OGRDataSource *ds = (OGRDataSource *) 0 ; |
|
273 |
int longitud; |
|
274 |
char **opciones; |
|
275 |
OGRLayer *layer_dstno; |
|
276 |
OGRSpatialReference *spatialRef; |
|
277 |
long ptr_dtno=-1; |
|
278 |
OGRwkbGeometryType geomtype; |
|
279 |
|
|
280 |
ds = *(OGRDataSource **)&cPtr; |
|
281 |
|
|
282 |
spatialRef = *(OGRSpatialReference **)&poSpatialRef; |
|
283 |
|
|
284 |
if(ds!=NULL){ |
|
285 |
longitud = env->GetArrayLength( papszOptions); |
|
286 |
opciones = (char **)malloc(sizeof(char *)*longitud); |
|
287 |
for(int i=0;i<longitud;i++){ |
|
288 |
jstring el = (jstring)env->GetObjectArrayElement(papszOptions,i); |
|
289 |
const char *simple_option = env->GetStringUTFChars( el, 0); |
|
290 |
opciones[i]=(char *)malloc(strlen(simple_option)); |
|
291 |
strcpy(opciones[i],simple_option); |
|
292 |
env->ReleaseStringUTFChars( el, simple_option); |
|
293 |
} |
|
294 |
|
|
295 |
const char *type = env->GetStringUTFChars( eGType, 0); |
|
296 |
const char *name = env->GetStringUTFChars( pszName, 0); |
|
297 |
if(strcmp(type,"wkbUnknown")==0)geomtype = wkbUnknown; |
|
298 |
else if(strcmp(type,"wkbPoint")==0)geomtype = wkbPoint; |
|
299 |
else if(strcmp(type,"wkbLineString")==0)geomtype = wkbLineString; |
|
300 |
else if(strcmp(type,"wkbPolygon")==0)geomtype = wkbPolygon; |
|
301 |
else if(strcmp(type,"wkbMultiPoint")==0)geomtype = wkbMultiPoint; |
|
302 |
else if(strcmp(type,"wkbMultiLineString")==0)geomtype = wkbMultiLineString; |
|
303 |
else if(strcmp(type,"wkbMultiPolygon")==0)geomtype = wkbMultiPolygon; |
|
304 |
else if(strcmp(type,"wkbGeometryCollection")==0)geomtype = wkbGeometryCollection; |
|
305 |
else if(strcmp(type,"wkbNone")==0)geomtype = wkbNone; |
|
306 |
else if(strcmp(type,"wkbLinearRing")==0)geomtype = wkbLinearRing; |
|
307 |
else if(strcmp(type,"wkbPoint25D")==0)geomtype = wkbPoint25D; |
|
308 |
else if(strcmp(type,"wkbLineString25D")==0)geomtype = wkbLineString25D; |
|
309 |
else if(strcmp(type,"wkbPolygon25D")==0)geomtype = wkbPolygon25D; |
|
310 |
else if(strcmp(type,"wkbMultiPoint25D")==0)geomtype = wkbMultiPoint25D; |
|
311 |
else if(strcmp(type,"wkbMultiLineString25D")==0)geomtype = wkbMultiLineString25D; |
|
312 |
else if(strcmp(type,"wkbMultiPolygon25D")==0)geomtype = wkbMultiPolygon25D; |
|
313 |
else if(strcmp(type,"wkbGeometryCollection25D")==0)geomtype = wkbGeometryCollection25D; |
|
314 |
|
|
315 |
layer_dstno = ds->CreateLayer(name, spatialRef, geomtype, opciones); |
|
316 |
env->ReleaseStringUTFChars( eGType, type); |
|
317 |
env->ReleaseStringUTFChars( pszName, name); |
|
318 |
} |
|
319 |
|
|
320 |
for(int i=0;i<longitud;i++)free(opciones[i]); |
|
321 |
free(opciones); |
|
322 |
|
|
323 |
if(layer_dstno==NULL)return -1; |
|
324 |
|
|
325 |
ptr_dtno = (long)&(*layer_dstno); |
|
326 |
return (jlong)ptr_dtno; |
|
327 |
} |
|
328 |
|
|
329 |
/******************************************************************************/ |
|
330 |
// copyLayer |
|
331 |
/******************************************************************************/ |
|
332 |
|
|
333 |
JNIEXPORT jlong JNICALL Java_es_gva_cit_jogr_OGRDataSource_copyLayerNat |
|
334 |
(JNIEnv *env, jobject obj, jlong cPtr, jlong poSrcLayer, jstring pszNewName, jobjectArray papszOptions){ |
|
335 |
|
|
336 |
OGRDataSource *ds = (OGRDataSource *) 0 ; |
|
337 |
int longitud; |
|
338 |
char **opciones; |
|
339 |
OGRLayer *layer_dstno; |
|
340 |
OGRLayer *layer; |
|
341 |
long ptr_dtno=-1; |
|
342 |
|
|
343 |
ds = *(OGRDataSource **)&cPtr; |
|
344 |
layer = *(OGRLayer **)&poSrcLayer; |
|
345 |
if(ds!=NULL && layer!=NULL){ |
|
346 |
longitud = env->GetArrayLength( papszOptions); |
|
347 |
opciones = (char **)malloc(sizeof(char *)*longitud); |
|
348 |
for(int i=0;i<longitud;i++){ |
|
349 |
jstring el = (jstring)env->GetObjectArrayElement(papszOptions,i); |
|
350 |
const char *simple_option = env->GetStringUTFChars( el, 0); |
|
351 |
opciones[i]=(char *)malloc(strlen(simple_option)); |
|
352 |
strcpy(opciones[i],simple_option); |
|
353 |
env->ReleaseStringUTFChars( el, simple_option); |
|
354 |
} |
|
355 |
|
|
356 |
const char *name = env->GetStringUTFChars( pszNewName, 0); |
|
357 |
layer_dstno = ds->CopyLayer(layer, name, opciones); |
|
358 |
env->ReleaseStringUTFChars( pszNewName, name); |
|
359 |
|
|
360 |
} |
|
361 |
|
|
362 |
for(int i=0;i<longitud;i++)free(opciones[i]); |
|
363 |
free(opciones); |
|
364 |
|
|
365 |
if(layer_dstno==NULL)return -1; |
|
366 |
|
|
367 |
ptr_dtno = (long)&(*layer_dstno); |
|
368 |
return (jlong)ptr_dtno; |
|
369 |
} |
|
370 |
|
|
371 |
/******************************************************************************/ |
|
372 |
// getStyleTable |
|
373 |
/******************************************************************************/ |
|
374 |
|
|
375 |
JNIEXPORT jlong JNICALL Java_es_gva_cit_jogr_OGRDataSource_getStyleTableNat |
|
376 |
(JNIEnv *env, jobject obj, jlong cPtr){ |
|
377 |
|
|
378 |
OGRDataSource *ds = (OGRDataSource *) 0 ; |
|
379 |
OGRStyleTable *styletable; |
|
380 |
long ptro_styletable=-1; |
|
381 |
|
|
382 |
ds = *(OGRDataSource **)&cPtr; |
|
383 |
if(ds!=NULL){ |
|
384 |
styletable = ds->GetStyleTable(); |
|
385 |
if(styletable!=NULL) |
|
386 |
ptro_styletable = (long)&(*styletable); |
|
387 |
} |
|
388 |
return ptro_styletable; |
|
389 |
} |
|
390 |
|
|
391 |
/******************************************************************************/ |
|
392 |
// executeSQL |
|
393 |
/******************************************************************************/ |
|
394 |
|
|
395 |
JNIEXPORT jlong JNICALL Java_es_gva_cit_jogr_OGRDataSource_executeSQLNat |
|
396 |
(JNIEnv *env, jobject obj, jlong cPtr, jstring pszStatement, jlong ptr_spatialFilter, jstring pszDialect){ |
|
397 |
|
|
398 |
OGRDataSource *ds = (OGRDataSource *) 0 ; |
|
399 |
OGRGeometry *geom = (OGRGeometry *) 0 ; |
|
400 |
OGRLayer *layer; |
|
401 |
long ptro_layer=-1; |
|
402 |
|
|
403 |
ds = *(OGRDataSource **)&cPtr; |
|
404 |
geom = *(OGRGeometry **)&ptr_spatialFilter; |
|
405 |
if(ds!=NULL ){ |
|
406 |
const char *stat = env->GetStringUTFChars( pszStatement, 0); |
|
407 |
const char *dialect = env->GetStringUTFChars( pszDialect, 0); |
|
408 |
layer = ds->ExecuteSQL(stat, geom, dialect); |
|
409 |
env->ReleaseStringUTFChars( pszStatement, stat); |
|
410 |
env->ReleaseStringUTFChars( pszDialect, dialect); |
|
411 |
if(layer!=NULL) |
|
412 |
ptro_layer = (long)&(*layer); |
|
413 |
} |
|
414 |
return ptro_layer; |
|
415 |
} |
|
416 |
|
|
417 |
/******************************************************************************/ |
|
418 |
// releaseResultSet |
|
419 |
/******************************************************************************/ |
|
420 |
|
|
421 |
JNIEXPORT void JNICALL Java_es_gva_cit_jogr_OGRDataSource_releaseResultSetNat |
|
422 |
(JNIEnv *env, jobject obj, jlong cPtr, jlong ptr_poResultsSet){ |
|
423 |
|
|
424 |
OGRDataSource *ds = (OGRDataSource *) 0 ; |
|
425 |
OGRLayer *layer = (OGRLayer *) 0 ; |
|
426 |
|
|
427 |
ds = *(OGRDataSource **)&cPtr; |
|
428 |
layer = *(OGRLayer **)&ptr_poResultsSet; |
|
429 |
if(ds!=NULL ){ |
|
430 |
ds->ReleaseResultSet(layer); |
|
431 |
} |
|
432 |
} |
|
433 |
|
|
434 |
/******************************************************************************/ |
|
435 |
// syncToDisk |
|
436 |
/******************************************************************************/ |
|
437 |
|
|
438 |
JNIEXPORT jint JNICALL Java_es_gva_cit_jogr_OGRDataSource_syncToDiskNat |
|
439 |
(JNIEnv *env, jobject obj, jlong cPtr){ |
|
440 |
|
|
441 |
OGRDataSource *ds = (OGRDataSource *) 0 ; |
|
442 |
int ogrerr; |
|
443 |
|
|
444 |
ds = *(OGRDataSource **)&cPtr; |
|
445 |
if(ds!=NULL ){ |
|
446 |
ogrerr = ds->SyncToDisk(); |
|
447 |
} |
|
448 |
return ogrerr; |
|
449 |
} |
|
450 |
|
tags/v2_0_0_Build_2027/libjni-gdal/src/main/native/jgdal/ogrfeature_interfaz.cpp | ||
---|---|---|
1 |
/********************************************************************** |
|
2 |
* $Id: ogrfeature_interfaz.cpp 7765 2006-10-03 07:05:18Z nacho $ |
|
3 |
* |
|
4 |
* Name: ogrfeature_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 "ogr_api.h" |
|
54 |
#include "ogrsf_frmts.h" |
|
55 |
|
|
56 |
/******************************************************************************/ |
|
57 |
// dumpReadable |
|
58 |
/******************************************************************************/ |
|
59 |
|
|
60 |
JNIEXPORT void JNICALL Java_es_gva_cit_jogr_OGRFeature_dumpReadableNat |
|
61 |
(JNIEnv *env, jobject obj, jlong cPtr, jstring file){ |
|
62 |
|
|
63 |
const char *nomfile; |
|
64 |
FILE *fp; |
|
65 |
OGRFeature *feature = (OGRFeature *) 0 ; |
|
66 |
|
|
67 |
feature = *(OGRFeature **)&cPtr; |
|
68 |
if(file!=NULL){ |
|
69 |
nomfile = env->GetStringUTFChars(file, 0); |
|
70 |
fp = fopen(nomfile,"a+"); |
|
71 |
if(!fp)return; |
|
72 |
feature->DumpReadable(fp); |
|
73 |
fclose(fp); |
|
74 |
env->ReleaseStringUTFChars(file, nomfile); |
|
75 |
return; |
|
76 |
} |
|
77 |
|
|
78 |
feature->DumpReadable(NULL); |
|
79 |
|
|
80 |
|
|
81 |
} |
|
82 |
|
|
83 |
/******************************************************************************/ |
|
84 |
// ~OGRFeature |
|
85 |
/******************************************************************************/ |
|
86 |
|
|
87 |
JNIEXPORT void JNICALL Java_es_gva_cit_jogr_OGRFeature_FreeOGRFeatureNat |
|
88 |
(JNIEnv *env, jobject obj, jlong cPtr){ |
|
89 |
|
|
90 |
OGRFeature *df = (OGRFeature *) 0 ; |
|
91 |
|
|
92 |
df = *(OGRFeature **)&cPtr; |
|
93 |
if(df!=NULL){ |
|
94 |
delete df; |
|
95 |
} |
|
96 |
} |
|
97 |
|
tags/v2_0_0_Build_2027/libjni-gdal/src/main/native/jgdal/gdal_interfaz.c | ||
---|---|---|
1 |
/********************************************************************** |
|
2 |
* $Id: gdal_interfaz.c 15691 2007-10-31 10:49:53Z nbrodin $ |
|
3 |
* |
|
4 |
* Name: gdal_interfaz.c |
|
5 |
* Project: JGDAL. Interface java to gdal (Frank Warmerdam). |
|
6 |
* Purpose: dataset's Basic Funcions. |
|
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 |
* [01] 01-Oct-2005 nbt OpenArray function to support name parameter in char array |
|
51 |
*/ |
|
52 |
|
|
53 |
|
|
54 |
#include <jni.h> |
|
55 |
#include "gdal.h" |
|
56 |
#include "cpl_string.h" |
|
57 |
#include "signal.h" |
|
58 |
|
|
59 |
/******************************************************************************/ |
|
60 |
// Open |
|
61 |
/******************************************************************************/ |
|
62 |
|
|
63 |
|
|
64 |
JNIEXPORT jlong JNICALL Java_es_gva_cit_jgdal_Gdal_openNat |
|
65 |
(JNIEnv *env, jobject obj, jstring pszF, jint acc){ |
|
66 |
|
|
67 |
const char *pszFilename; |
|
68 |
GDALDatasetH *dataset; |
|
69 |
jlong jresult = 0 ; |
|
70 |
FILE *fich; |
|
71 |
|
|
72 |
pszFilename = (*env)->GetStringUTFChars(env, pszF, 0); |
|
73 |
|
|
74 |
fich=fopen( pszFilename, "r" ); |
|
75 |
if( fich ) |
|
76 |
fclose(fich); |
|
77 |
else |
|
78 |
{ |
|
79 |
fclose(fich); |
|
80 |
return -1; |
|
81 |
} |
|
82 |
|
|
83 |
GDALAllRegister(); |
|
84 |
dataset = GDALOpen((char *)pszFilename,(int)acc); |
|
85 |
|
|
86 |
jresult = (long)dataset; |
|
87 |
|
|
88 |
(*env)->ReleaseStringUTFChars(env, pszF, pszFilename); |
|
89 |
|
|
90 |
|
|
91 |
if(dataset==NULL)return -1; |
|
92 |
else return jresult; |
|
93 |
|
|
94 |
} |
|
95 |
|
|
96 |
/******************************************************************************/ |
|
97 |
// OpenArray |
|
98 |
/******************************************************************************/ |
|
99 |
void handler(int n) { |
|
100 |
#ifdef __linux__ |
|
101 |
raise(SIGALRM); |
|
102 |
#else |
|
103 |
raise(SIGABRT); |
|
104 |
#endif |
|
105 |
} |
|
106 |
|
|
107 |
|
|
108 |
|
|
109 |
JNIEXPORT jlong JNICALL Java_es_gva_cit_jgdal_Gdal_openArrayNat |
|
110 |
(JNIEnv *env, jobject obj, jbyteArray pszF, jint acc){ |
|
111 |
|
|
112 |
jbyte *pszFilename = NULL; |
|
113 |
jbyte *aux = NULL; |
|
114 |
GDALDatasetH *dataset; |
|
115 |
jlong jresult = 0 ; |
|
116 |
FILE *fich; |
|
117 |
jsize longitud = 0, i; |
|
118 |
|
|
119 |
longitud = (*env)->GetArrayLength(env, pszF); |
|
120 |
pszFilename = (*env)->GetByteArrayElements(env, pszF, 0); |
|
121 |
|
|
122 |
aux = (jbyte *)malloc(sizeof(jbyte) * (longitud + 1)); |
|
123 |
memcpy(aux, pszFilename, longitud); |
|
124 |
(*env)->ReleaseByteArrayElements(env, pszF, pszFilename, 0); |
|
125 |
pszFilename = aux; |
|
126 |
|
|
127 |
pszFilename[longitud] = '\0'; |
|
128 |
|
|
129 |
fich = fopen( pszFilename, "r" ); |
|
130 |
if( fich ) |
|
131 |
fclose(fich); |
Also available in: Unified diff