root / trunk / libraries / libjni-gdal / src-test / Ogr_info.java @ 970
History | View | Annotate | Download (3.09 KB)
1 |
/**********************************************************************
|
---|---|
2 |
* $Id: Ogr_info.java 970 2005-01-13 12:52:33Z igbrotru $
|
3 |
*
|
4 |
* Name: ogr-info.java
|
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 |
import es.gva.cit.jogr.*; |
29 |
|
30 |
|
31 |
public class Ogr_info{ |
32 |
|
33 |
public static void main(String[] args){ |
34 |
|
35 |
OGRRegisterAll.register(); |
36 |
|
37 |
OGRDataSource ds=null;
|
38 |
OGRSFDriver drv=null;
|
39 |
OGRSFDriverRegistrar registro = new OGRSFDriverRegistrar();
|
40 |
OGRLayer capa=null;
|
41 |
OGRFeatureDefn fd; |
42 |
OGREnvelope extent; |
43 |
OGRFieldDefn poField; |
44 |
OGRFeature feature; |
45 |
int ndrivers;
|
46 |
int ncapas;
|
47 |
int nfielddefn;
|
48 |
|
49 |
|
50 |
try{
|
51 |
ds=registro.open(args[0],false,drv); |
52 |
ndrivers = registro.getDriverCount(); |
53 |
System.out.println("N?mero de drivers registrados: "+ndrivers); |
54 |
|
55 |
//Informaci?n sobre los drivers
|
56 |
|
57 |
for(int i=0;i<ndrivers;i++) |
58 |
System.out.println(registro.getDriver(i).getName());
|
59 |
System.out.println("******************"); |
60 |
|
61 |
//Informaci?n sobre las capas
|
62 |
|
63 |
System.out.println("Nombre datasource: "+ds.getName()); |
64 |
ncapas = ds.getLayerCount(); |
65 |
System.out.println("N?mero de capas: "+ncapas); |
66 |
|
67 |
//Se recorren las capas
|
68 |
|
69 |
for( int iLayer = 0; iLayer < ncapas; iLayer++ ){ |
70 |
|
71 |
System.out.println("******CAPA "+(iLayer+1)+"******"); |
72 |
capa = ds.getLayer(iLayer); |
73 |
fd = capa.getLayerDefn(); |
74 |
System.out.println("Nombre FeatureDefn: "+fd.getName()); |
75 |
System.out.println("Tipo de geometria: "+fd.getGeomType()); |
76 |
|
77 |
extent = capa.getExtent(true);
|
78 |
System.out.println("Extent: "+extent.minX+" "+extent.maxX+" "+extent.minY+" "+extent.maxY); |
79 |
|
80 |
//Se recorren los atributos de cada capa
|
81 |
|
82 |
nfielddefn=fd.getFieldCount(); |
83 |
for( int iAttr = 0; iAttr < nfielddefn; iAttr++ ){ |
84 |
poField = fd.getFieldDefn( iAttr ); |
85 |
|
86 |
System.out.println( poField.getNameRef()+": "+ |
87 |
poField.getFieldTypeName( poField.getType())+" ("+
|
88 |
poField.getWidth()+"."+
|
89 |
poField.getPrecision()+")" );
|
90 |
} |
91 |
|
92 |
} |
93 |
|
94 |
System.out.println("******************"); |
95 |
|
96 |
while( (feature = capa.getNextFeature()) != null ){ |
97 |
feature.dumpReadable( null );
|
98 |
feature=null;
|
99 |
} |
100 |
|
101 |
|
102 |
}catch(Exception e){ |
103 |
e.printStackTrace(); |
104 |
} |
105 |
|
106 |
} |
107 |
} |