Exemplo2.java
Go to the documentation of this file.
1 /*
2  * To change this license header, choose License Headers in Project Properties.
3  * To change this template file, choose Tools | Templates
4  * and open the template in the editor.
5  */
6 
7 
8 
9 import br.inpe.terralib5.DataSet;
11 import br.inpe.terralib5.QtInitializer;
12 import br.inpe.terralib5.Str2StrMap;
13 import br.inpe.terralib5.StrVector;
14 import br.inpe.terralib5.TerraLib;
15 import java.io.IOException;
16 import java.util.logging.Level;
17 import java.util.logging.Logger;
18 
19 /**
20  *
21  * @author FredBede
22  */
23 public class Exemplo2 {
24 
25  static {
26  // Loading T5Java dll
27  System.loadLibrary("terralib_mod_binding_java");
28  }
29 
30  /**
31  * @param args the command line arguments
32  */
33  public static void main(String[] args) {
34  // TODO code application logic here
35 
36  // Initialize TerraLib and Qt.
37  QtInitializer qt = new QtInitializer();
38  qt.begin();
39 
40  try {
41  TerraLib.Initialize();
42 
43  // Getting data source
44  Str2StrMap info = new Str2StrMap();
45  info.set("URI", "D:/funcate/vs2010/terralib5/munic_shp");
46  DataSource src = TerraLib.MakeDataSource("OGR", info);
47 
48  // Getting data set names
49  StrVector dsets = src.getDataSetNames();
50 
51  // Getting the first data set
52  if(!dsets.isEmpty()) {
53  String dsetName = dsets.get(0);
54 
55  // Getting data set
56  DataSet dset = src.newDataSet(dsetName);
57 
58  // Move to the first position.
59  dset.moveFirst();
60 
61  // Number of columns of the data set
62  long ncols = dset.getNumProperties();
63 
64  // Print header
65  for(int c = 0; c < ncols; c++)
66  if(dset.getPropertyDataType(c) != TerraLib.GEOMETRY_TYPE)
67  System.out.print(dset.getPropertyName(c) + " | ");
68 
69  System.out.println();
70  System.out.println(" ------------------------------------------- ");
71 
72  do {
73  // Print data
74  for(int c = 0; c < ncols; c++)
75  if(dset.getPropertyDataType(c) != TerraLib.GEOMETRY_TYPE)
76  System.out.print(dset.getAsString(c) + " | ");
77 
78  System.out.println();
79  } while (dset.moveNext());
80  }
81 
82  } catch (IOException ex) {
83  Logger.getLogger(Exemplo2.class.getName()).log(Level.SEVERE, null, ex);
84  }
85 
86  qt.end();
87 
88  TerraLib.Finalize();
89  }
90 
91 }
This class is a singleton designed to manage log messages in TerraLib.
SimpleData< std::string, STRING_TYPE > String
Definition: SimpleData.h:229
void DataSet()
static void main(String[] args)
Definition: Exemplo2.java:33
void DataSource()
An utility class to control the startup and cleanup of the TerraLib Platform and its resources...