Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libjni-gdal-macosx / src / ogrspatialreference_interfaz.c @ 25845

History | View | Annotate | Download (6.27 KB)

1
 /**********************************************************************
2
 * $Id: ogrspatialreference_interfaz.c 8219 2006-10-23 06:25:39Z nacho $
3
 *
4
 * Name:     OGRSpatialReference_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

    
51

    
52
#include <jni.h>
53
#include "es_gva_cit_jogr_OGRSpatialReference.h"
54
#include "es_gva_cit_jogr_JNIBase.h"
55
#include "gdal.h"
56
#include "cpl_string.h"
57
#include "ogr_api.h"
58
#include "ogr_srs_api.h"
59

    
60

    
61
/******************************************************************************/
62
//                                                                setUTM
63
/******************************************************************************/
64

    
65
JNIEXPORT jint JNICALL Java_es_gva_cit_jogr_OGRSpatialReference_setUTMNat
66
  (JNIEnv *env, jobject obj, jlong cPtr, jint zona, jint norte_sur){
67
          
68
          OGRSpatialReferenceH *hSRS = (OGRSpatialReferenceH *) 0 ;
69
          
70
          hSRS = *(OGRSpatialReferenceH **)&cPtr;
71
          if(hSRS!=NULL){
72
                  OSRSetUTM( *hSRS, zona, norte_sur );
73
                 return 1;
74
          }
75
          return -1;
76
  }
77

    
78
/******************************************************************************/
79
//                                                        setWellKnownGeogCS
80
/******************************************************************************/
81

    
82
JNIEXPORT jint JNICALL Java_es_gva_cit_jogr_OGRSpatialReference_setWellKnownGeogCSNat
83
  (JNIEnv *env, jobject obj, jlong cPtr, jstring cs){
84
          
85
          OGRSpatialReferenceH *hSRS = (OGRSpatialReferenceH *) 0 ;
86
          
87
          hSRS = *(OGRSpatialReferenceH **)&cPtr;
88
          if(hSRS!=NULL){
89
                  const char *coord_sys = (*env)->GetStringUTFChars(env, cs, 0);
90
                  OSRSetWellKnownGeogCS( *hSRS, coord_sys );
91
                  (*env)->ReleaseStringUTFChars(env, cs, coord_sys);
92
                  return 1;
93
          }
94
          
95
          return -1;
96
  }
97

    
98
/******************************************************************************/
99
//                                                        OGRSpatialReference
100
/******************************************************************************/
101

    
102
JNIEXPORT jlong JNICALL Java_es_gva_cit_jogr_OGRSpatialReference_OGRSpatialReferenceNat
103
  (JNIEnv *env, jobject obj){
104
          
105
          OGRSpatialReferenceH *hSRS;
106
          jlong jresult=0;
107
          hSRS=(OGRSpatialReferenceH*)malloc(sizeof(OGRSpatialReferenceH));
108
          
109
         *hSRS = OSRNewSpatialReference( NULL );
110
          *(OGRSpatialReferenceH **)&jresult = hSRS;
111
          
112
          //printf("-------->%ld\n",(long)jresult);
113
          return (long)jresult;
114
  }
115
  
116
/******************************************************************************/
117
//                                                                exportToWkt
118
/******************************************************************************/
119

    
120
JNIEXPORT jstring JNICALL Java_es_gva_cit_jogr_OGRSpatialReference_exportToWktNat
121
  (JNIEnv *env, jobject obj, jlong cPtr){
122
          
123
          OGRSpatialReferenceH *hSRS = (OGRSpatialReferenceH *) 0 ;
124
          jstring wkt;
125
          char *pszSRS_WKT = NULL;
126
          
127
          hSRS = *(OGRSpatialReferenceH **)&cPtr;
128
          
129
          if(hSRS!=NULL){
130
                   OSRExportToWkt( *hSRS, &pszSRS_WKT );
131
                   if(pszSRS_WKT!=NULL){
132
                        wkt = (*env)->NewStringUTF(env, pszSRS_WKT);        
133
                        return wkt;
134
                   }                  
135
          }
136
          
137
          return NULL;
138
  }
139
  
140
/******************************************************************************/
141
//                                                        getUTMZone
142
/******************************************************************************/    
143
  
144
JNIEXPORT jint JNICALL Java_es_gva_cit_jogr_OGRSpatialReference_getUTMZoneNat
145
  (JNIEnv *env, jobject obj, jlong cPtr){
146
          
147
          /*OGRSpatialReferenceH *hSRS = (OGRSpatialReferenceH *) 0 ;
148
          
149
          hSRS = *(OGRSpatialReferenceH **)&cPtr;
150
          if(hSRS!=NULL){
151
                  int *pH;
152
                  return OSRGetUTMZone(hSRS,pH);
153
          }*/
154
          return -1;
155
          
156
  }
157

    
158

    
159
/******************************************************************************/
160
//                                                        getHemisphere
161
/******************************************************************************/   
162
 
163
JNIEXPORT jint JNICALL Java_es_gva_cit_jogr_OGRSpatialReference_getHemisphereNat
164
  (JNIEnv *env, jobject obj, jlong cPtr){
165

    
166
          /*OGRSpatialReferenceH *hSRS = (OGRSpatialReferenceH *) 0 ;
167
          
168
          hSRS = *(OGRSpatialReferenceH **)&cPtr;
169
          if(hSRS!=NULL){
170
                  int pH;
171
                  OSRGetUTMZone(hSRS,&pH);
172
                  return *pH;
173
          }*/
174
          return -1;
175
          
176
  }
177
  
178
/******************************************************************************/
179
//                                                        OSRDestroySpatialReference
180
/******************************************************************************/  
181
  
182
JNIEXPORT void JNICALL Java_es_gva_cit_jogr_OGRSpatialReference_OSRDestroySpatialReferenceNat
183
  (JNIEnv *env, jobject obj, jlong cPtr){
184

    
185
          OGRSpatialReferenceH *hSRS = (OGRSpatialReferenceH *) 0 ;
186
          
187
          hSRS = *(OGRSpatialReferenceH **)&cPtr;
188
          
189
          if(hSRS!=NULL){
190
                  OSRDestroySpatialReference(*hSRS);
191
          }
192
  }
193

    
194
/******************************************************************************/
195
//                                                        setFromUserInput
196
/******************************************************************************/  
197
 
198
 JNIEXPORT jint JNICALL Java_es_gva_cit_jogr_OGRSpatialReference_setFromUserInputNat
199
  (JNIEnv *env, jobject obj, jlong cPtr, jstring a_srs){
200
          
201
          int                                                ogrerr;
202
          OGRSpatialReferenceH         *hSRS = (OGRSpatialReferenceH *) 0 ;
203
          const char *s;
204
          
205
          hSRS = *(OGRSpatialReferenceH **)&cPtr;
206
          s = (*env)->GetStringUTFChars(env, a_srs, 0);
207
          ogrerr = OSRSetFromUserInput(hSRS,s);
208
          (*env)->ReleaseStringUTFChars(env, a_srs, s);
209
          return ogrerr;
210
          
211
  }