svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / DEMO / PruebasGT2.java @ 623
History | View | Annotate | Download (3.33 KB)
1 |
/*
|
---|---|
2 |
* Created on 22-dic-2004
|
3 |
*/
|
4 |
package com.iver.cit.gvsig.DEMO; |
5 |
|
6 |
import java.awt.event.ActionEvent; |
7 |
import java.awt.event.ActionListener; |
8 |
import java.io.IOException; |
9 |
import java.util.HashMap; |
10 |
import java.util.Map; |
11 |
|
12 |
import java.net.URL; |
13 |
import javax.swing.JFileChooser; |
14 |
import javax.swing.JOptionPane; |
15 |
|
16 |
import org.geotools.data.DataStore; |
17 |
import org.geotools.data.arcsde.ArcSDEDataStoreFactory; |
18 |
/* import org.geotools.data.postgis.PostgisDataStoreFactory;
|
19 |
import org.geotools.data.shapefile.ShapefileDataStore; */
|
20 |
|
21 |
/**
|
22 |
* Pruebas de capas GT2 (ArcSDE, etc), hechas por Fran, sacadas del
|
23 |
* CommandListener
|
24 |
* @author Luis W. Sevilla (sevilla_lui@gva.es)
|
25 |
*/
|
26 |
public class PruebasGT2 implements ActionListener { |
27 |
// static PostgisDataStoreFactory postGisFactory = new PostgisDataStoreFactory();
|
28 |
static ArcSDEDataStoreFactory arcSdeFactory = new ArcSDEDataStoreFactory(); |
29 |
|
30 |
Map remote;
|
31 |
|
32 |
|
33 |
/**
|
34 |
*
|
35 |
*/
|
36 |
protected void addLayerGT2_Shp() { |
37 |
/* JFileChooser fileChooser = new JFileChooser(); // lastFolder);
|
38 |
fileChooser.addChoosableFileFilter(new SimpleFileFilter("shp", "Shapefile (*.shp)"));
|
39 |
|
40 |
int result = fileChooser.showOpenDialog(theView);
|
41 |
|
42 |
if (result == JFileChooser.APPROVE_OPTION) {
|
43 |
File file = fileChooser.getSelectedFile();
|
44 |
// lastFolder = file.getParentFile();
|
45 |
|
46 |
try {
|
47 |
// Load the file
|
48 |
URL url = file.toURL();
|
49 |
|
50 |
DataStore store;
|
51 |
|
52 |
// Para shapes
|
53 |
store = new ShapefileDataStore(url);
|
54 |
|
55 |
loadLayer(store, store.getTypeNames()[0]);
|
56 |
} catch (Throwable t) {
|
57 |
JOptionPane.showMessageDialog(null, "An error occurred while loading the file",
|
58 |
"Demo GT2", JOptionPane.ERROR_MESSAGE);
|
59 |
t.printStackTrace();
|
60 |
}
|
61 |
} */
|
62 |
} |
63 |
protected void addLayerGT2_PostGIS() |
64 |
{ |
65 |
/* remote = new HashMap();
|
66 |
remote.put("dbtype","postgis");
|
67 |
remote.put("host","213.172.37.189"); //Jos? Miguel
|
68 |
remote.put("port", new Integer(5432));
|
69 |
remote.put("database", "geomarketing");
|
70 |
remote.put("user", "Geomarketing");
|
71 |
remote.put("passwd", "geomarketing");
|
72 |
remote.put("charset", "");
|
73 |
remote.put("namespace", "");
|
74 |
|
75 |
DataStore store;
|
76 |
try {
|
77 |
store = postGisFactory.createDataStore(remote);
|
78 |
loadLayer(store, "ferrocarril");
|
79 |
|
80 |
} catch (IOException e) {
|
81 |
// TODO Auto-generated catch block
|
82 |
e.printStackTrace();
|
83 |
} */
|
84 |
|
85 |
|
86 |
} |
87 |
protected void addLayerGT2_ArcSDE() |
88 |
{ |
89 |
remote = new HashMap(); |
90 |
remote.put("dbtype","arcsde"); |
91 |
remote.put("server","192.168.0.165"); //Jos? Miguel |
92 |
remote.put("port", new Integer(5151)); |
93 |
remote.put("instance", "sde"); |
94 |
remote.put("user", "sde"); |
95 |
remote.put("password", "aquilina"); |
96 |
|
97 |
|
98 |
DataStore store; |
99 |
try {
|
100 |
store = arcSdeFactory.createDataStore(remote); |
101 |
loadLayer(store, "SDE.VIAS");
|
102 |
|
103 |
} catch (IOException e) { |
104 |
// TODO Auto-generated catch block
|
105 |
e.printStackTrace(); |
106 |
} |
107 |
|
108 |
|
109 |
} |
110 |
|
111 |
public void actionPerformed(ActionEvent e) { |
112 |
if (e.getActionCommand() == "ADD_GT2_POSTGIS") { |
113 |
addLayerGT2_PostGIS(); |
114 |
} |
115 |
if (e.getActionCommand() == "ADD_GT2_SHP") { |
116 |
addLayerGT2_Shp(); |
117 |
} |
118 |
if (e.getActionCommand() == "ADD_GT2_ARCSDE") { |
119 |
addLayerGT2_ArcSDE(); |
120 |
} |
121 |
} |
122 |
} |