Revision 1245
org.gvsig.seismic/tags/org.gvsig.seismic-1.0.240/org.gvsig.seismic/org.gvsig.seismic.main/src/main/java/org/gvsig/seismic/main/package.html | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8" ?> |
|
2 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|
3 |
<html xmlns="http://www.w3.org/1999/xhtml"> |
|
4 |
<head> |
|
5 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
|
6 |
<title>org.gvsig.construc package documentation</title> |
|
7 |
</head> |
|
8 |
<body> |
|
9 |
|
|
10 |
<p>Construc library testing and demo application.</p> |
|
11 |
|
|
12 |
</body> |
|
13 |
</html> |
|
0 | 14 |
org.gvsig.seismic/tags/org.gvsig.seismic-1.0.240/org.gvsig.seismic/org.gvsig.seismic.main/src/main/java/org/gvsig/seismic/main/Main.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.seismic.main; |
|
23 |
|
|
24 |
import java.awt.BorderLayout; |
|
25 |
import java.awt.Dimension; |
|
26 |
import java.awt.event.ActionEvent; |
|
27 |
import java.awt.event.ActionListener; |
|
28 |
import java.io.File; |
|
29 |
import java.net.URL; |
|
30 |
|
|
31 |
import javax.swing.AbstractAction; |
|
32 |
import javax.swing.Action; |
|
33 |
import javax.swing.JButton; |
|
34 |
import javax.swing.JFrame; |
|
35 |
import javax.swing.JMenu; |
|
36 |
import javax.swing.JMenuBar; |
|
37 |
import javax.swing.JMenuItem; |
|
38 |
import javax.swing.JPanel; |
|
39 |
import javax.swing.JToolBar; |
|
40 |
import javax.swing.UIManager; |
|
41 |
import javax.swing.UnsupportedLookAndFeelException; |
|
42 |
import javax.swing.WindowConstants; |
|
43 |
|
|
44 |
import org.gvsig.fmap.dal.DALLocator; |
|
45 |
import org.gvsig.fmap.geom.primitive.Envelope; |
|
46 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
47 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
|
48 |
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException; |
|
49 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
|
50 |
import org.gvsig.fmap.mapcontrol.MapControl; |
|
51 |
import org.gvsig.fmap.mapcontrol.MapControlCreationException; |
|
52 |
import org.gvsig.fmap.mapcontrol.MapControlLocator; |
|
53 |
import org.gvsig.fmap.mapcontrol.MapControlManager; |
|
54 |
import org.gvsig.fmap.mapcontrol.tools.PanListenerImpl; |
|
55 |
import org.gvsig.fmap.mapcontrol.tools.ZoomInListenerImpl; |
|
56 |
import org.gvsig.fmap.mapcontrol.tools.ZoomOutRightButtonListener; |
|
57 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior; |
|
58 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.MoveBehavior; |
|
59 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.PointBehavior; |
|
60 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.RectangleBehavior; |
|
61 |
import org.gvsig.seismic.swing.SeismicSwingLocator; |
|
62 |
import org.gvsig.seismic.swing.SeismicSwingManager; |
|
63 |
import org.gvsig.seismic.swing.gui.JSeismicWizard; |
|
64 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
|
65 |
import org.gvsig.tools.locator.LocatorException; |
|
66 |
import org.slf4j.Logger; |
|
67 |
import org.slf4j.LoggerFactory; |
|
68 |
|
|
69 |
import com.jgoodies.looks.plastic.PlasticLookAndFeel; |
|
70 |
import com.jgoodies.looks.plastic.PlasticXPLookAndFeel; |
|
71 |
|
|
72 |
/** |
|
73 |
* Main executable class for testing the Chart library. |
|
74 |
* |
|
75 |
* @author gvSIG Team |
|
76 |
* @version $Id$ |
|
77 |
*/ |
|
78 |
public class Main { |
|
79 |
|
|
80 |
private static final Logger LOG = LoggerFactory.getLogger(Main.class); |
|
81 |
|
|
82 |
private static final String SHOWINFO_TOOL_NAME = "LandRegistryViewer.infotool"; |
|
83 |
|
|
84 |
|
|
85 |
private MapControlManager mapControlManager; |
|
86 |
|
|
87 |
private MapControl mapControl; |
|
88 |
|
|
89 |
private SeismicSwingManager swingManager; |
|
90 |
|
|
91 |
private JSeismicWizard wizard; |
|
92 |
|
|
93 |
public JSeismicWizard getWizard() { |
|
94 |
return wizard; |
|
95 |
} |
|
96 |
|
|
97 |
public static void main(String args[]) throws MapControlCreationException, |
|
98 |
LocatorException, LoadLayerException, UnsupportedLookAndFeelException { |
|
99 |
new DefaultLibrariesInitializer().fullInitialize(); |
|
100 |
|
|
101 |
PlasticLookAndFeel laf = new PlasticXPLookAndFeel(); |
|
102 |
UIManager.setLookAndFeel(laf); |
|
103 |
|
|
104 |
Main main = new Main(); |
|
105 |
main.show(); |
|
106 |
} |
|
107 |
|
|
108 |
public SeismicSwingManager getSwingManager() { |
|
109 |
if(swingManager == null){ |
|
110 |
swingManager = SeismicSwingLocator.getDriverSwingManager(); |
|
111 |
} |
|
112 |
return swingManager; |
|
113 |
} |
|
114 |
|
|
115 |
@SuppressWarnings("serial") |
|
116 |
public void show() throws MapControlCreationException, LocatorException, LoadLayerException { |
|
117 |
AbstractAction exit = new AbstractAction("Exit") { |
|
118 |
public void actionPerformed(ActionEvent e) { |
|
119 |
System.exit(0); |
|
120 |
} |
|
121 |
}; |
|
122 |
|
|
123 |
JFrame frame = new JFrame("Example APP"); |
|
124 |
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); |
|
125 |
|
|
126 |
JPanel content = new JPanel(); |
|
127 |
content.setLayout(new BorderLayout()); |
|
128 |
//Parser parser = getSwingManager().getDriverManager().createParser("UKOOA-84"); |
|
129 |
wizard = getSwingManager().createWizard(); |
|
130 |
content.add(wizard.getJComponent(), BorderLayout.CENTER); |
|
131 |
|
|
132 |
JButton accept = new JButton("Load features to view"); |
|
133 |
accept.addActionListener(new ActionListener() { |
|
134 |
public void actionPerformed(ActionEvent e) { |
|
135 |
try { |
|
136 |
if(getWizard().accept()){ |
|
137 |
createLayer(); |
|
138 |
}else{ |
|
139 |
LOG.error("[Main - accept button] ERROR: There're problems generating the data"); |
|
140 |
} |
|
141 |
} catch (MapControlCreationException e1) { |
|
142 |
// TODO Auto-generated catch block |
|
143 |
e1.printStackTrace(); |
|
144 |
} catch (LocatorException e1) { |
|
145 |
// TODO Auto-generated catch block |
|
146 |
e1.printStackTrace(); |
|
147 |
} catch (LoadLayerException e1) { |
|
148 |
// TODO Auto-generated catch block |
|
149 |
e1.printStackTrace(); |
|
150 |
} |
|
151 |
} |
|
152 |
}); |
|
153 |
content.add(accept,BorderLayout.SOUTH); |
|
154 |
|
|
155 |
frame.add(content); |
|
156 |
frame.setPreferredSize(new Dimension(510, 560)); |
|
157 |
|
|
158 |
// Display the window. |
|
159 |
frame.pack(); |
|
160 |
frame.setVisible(true); |
|
161 |
} |
|
162 |
|
|
163 |
|
|
164 |
|
|
165 |
public void createLayer() throws MapControlCreationException, LocatorException, LoadLayerException { |
|
166 |
mapControlManager = MapControlLocator.getMapControlManager(); |
|
167 |
|
|
168 |
mapControl = mapControlManager.createJMapControlPanel(); |
|
169 |
mapControl.addBehavior( |
|
170 |
"zoom", |
|
171 |
new Behavior[] { |
|
172 |
new RectangleBehavior(new ZoomInListenerImpl(mapControl)), |
|
173 |
new PointBehavior(new ZoomOutRightButtonListener(mapControl)) |
|
174 |
} |
|
175 |
); |
|
176 |
mapControl.addBehavior( |
|
177 |
"pan", |
|
178 |
new MoveBehavior( |
|
179 |
new PanListenerImpl(mapControl) |
|
180 |
) |
|
181 |
); |
|
182 |
mapControl.setTool("pan"); |
|
183 |
|
|
184 |
|
|
185 |
Action exit = new AbstractAction("Exit") { |
|
186 |
public void actionPerformed(ActionEvent e) { |
|
187 |
System.exit(0); |
|
188 |
} |
|
189 |
}; |
|
190 |
|
|
191 |
JFrame frame = new JFrame("Driver view example app"); |
|
192 |
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); |
|
193 |
|
|
194 |
// Create the menu bar. |
|
195 |
JMenuBar menuBar = new JMenuBar(); |
|
196 |
|
|
197 |
// Build the menu. |
|
198 |
JMenu menuFile = new JMenu("File"); |
|
199 |
menuFile.add(new JMenuItem(exit)); |
|
200 |
|
|
201 |
menuBar.add(menuFile); |
|
202 |
|
|
203 |
JToolBar toolBar = new JToolBar(); |
|
204 |
toolBar.add( |
|
205 |
new JButton( |
|
206 |
new AbstractAction("Pan") { |
|
207 |
public void actionPerformed(ActionEvent e) { |
|
208 |
mapControl.setTool("pan"); |
|
209 |
} |
|
210 |
} |
|
211 |
) |
|
212 |
); |
|
213 |
toolBar.add( |
|
214 |
new JButton( |
|
215 |
new AbstractAction("Zoom") { |
|
216 |
public void actionPerformed(ActionEvent e) { |
|
217 |
mapControl.setTool("zoom"); |
|
218 |
} |
|
219 |
} |
|
220 |
) |
|
221 |
); |
|
222 |
toolBar.add( |
|
223 |
new JButton( |
|
224 |
new AbstractAction("Zoom all") { |
|
225 |
public void actionPerformed(ActionEvent e) { |
|
226 |
zoomAll(); |
|
227 |
} |
|
228 |
} |
|
229 |
) |
|
230 |
); |
|
231 |
|
|
232 |
toolBar.add( |
|
233 |
new JButton( |
|
234 |
new AbstractAction("Info") { |
|
235 |
public void actionPerformed(ActionEvent e) { |
|
236 |
mapControl.setTool(SHOWINFO_TOOL_NAME);; |
|
237 |
} |
|
238 |
} |
|
239 |
) |
|
240 |
); |
|
241 |
|
|
242 |
toolBar.add(new JButton(exit)); |
|
243 |
frame.setPreferredSize(new Dimension(400, 300)); |
|
244 |
frame.setJMenuBar(menuBar); |
|
245 |
frame.add(toolBar, BorderLayout.PAGE_START); |
|
246 |
frame.add(mapControl,BorderLayout.CENTER); |
|
247 |
|
|
248 |
// Display the window. |
|
249 |
frame.pack(); |
|
250 |
frame.setVisible(true); |
|
251 |
|
|
252 |
LOG.info("Providers: " + DALLocator.getDataManager().getStoreProviders().toString()); |
|
253 |
|
|
254 |
// Add the blocks layer |
|
255 |
// MapContextLocator.getMapContextManager().setDefaultVectorLegend(ISingleSymbolLegend.LEGEND_NAME); |
|
256 |
FLyrVect layer = (FLyrVect) MapContextLocator. |
|
257 |
getMapContextManager().createLayer( |
|
258 |
"test_driver", |
|
259 |
getWizard().getDriverStoreParameters() |
|
260 |
); |
|
261 |
|
|
262 |
mapControl.getMapContext().getLayers().addLayer(layer); |
|
263 |
|
|
264 |
// PropertiesOfBlockListener listener = new PropertiesOfBlockListener(); |
|
265 |
// mapControl.addBehavior(SHOWINFO_TOOL_NAME, new PointBehavior(listener)); |
|
266 |
|
|
267 |
zoomAll(); |
|
268 |
} |
|
269 |
|
|
270 |
private void zoomAll() { |
|
271 |
MapContext mapContext = mapControl.getMapContext(); |
|
272 |
Envelope all = mapContext.getLayers().getFullEnvelope(); |
|
273 |
LOG.info("Full extdents "+all.toString()); |
|
274 |
mapContext.getViewPort().setEnvelope(all); |
|
275 |
mapContext.invalidate(); |
|
276 |
} |
|
277 |
|
|
278 |
private File getResource(String pathname) { |
|
279 |
URL res = this.getClass().getClassLoader().getResource(pathname); |
|
280 |
return new File(res.getPath()); |
|
281 |
} |
|
282 |
|
|
283 |
|
|
284 |
} |
|
0 | 285 |
org.gvsig.seismic/tags/org.gvsig.seismic-1.0.240/org.gvsig.seismic/org.gvsig.seismic.main/src/main/resources/README.txt | ||
---|---|---|
1 |
Put into this folder the resources needed by your classes. |
|
2 |
|
|
3 |
This folder is added to the classpath, so you can load any resources |
|
4 |
through the ClassLoader. |
|
5 |
|
|
6 |
By default, in this folder you can find an example of log4j configuration, |
|
7 |
prepared to log messages through the console, so logging works when you |
|
8 |
run your classes. |
|
0 | 9 |
org.gvsig.seismic/tags/org.gvsig.seismic-1.0.240/org.gvsig.seismic/org.gvsig.seismic.main/src/main/resources/log4j.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1" ?> |
|
2 |
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> |
|
3 |
|
|
4 |
<!-- |
|
5 |
Log4J configuration file for unit tests execution. |
|
6 |
--> |
|
7 |
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> |
|
8 |
|
|
9 |
<!-- Appender configuration to show logging messages through the console --> |
|
10 |
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender"> |
|
11 |
<layout class="org.apache.log4j.PatternLayout"> |
|
12 |
<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n %m%n" /> |
|
13 |
</layout> |
|
14 |
</appender> |
|
15 |
|
|
16 |
<!-- |
|
17 |
Activate logging messages of DEBUG level of higher only for the |
|
18 |
org.gvsig.tools packages. |
|
19 |
You can put full classes names or packages instead, to configure |
|
20 |
logging for all the classes and subpackages of the package. |
|
21 |
--> |
|
22 |
<category name="org.gvsig.tools"> |
|
23 |
<priority value="DEBUG" /> |
|
24 |
</category> |
|
25 |
<category name="org.gvsig.construc"> |
|
26 |
<priority value="DEBUG" /> |
|
27 |
</category> |
|
28 |
|
|
29 |
<!-- |
|
30 |
By default, show only logging messages of INFO level or higher, |
|
31 |
through the previously configured CONSOLE appender. |
|
32 |
--> |
|
33 |
<root> |
|
34 |
<priority value="INFO" /> |
|
35 |
<appender-ref ref="CONSOLE" /> |
|
36 |
</root> |
|
37 |
</log4j:configuration> |
|
0 | 38 |
org.gvsig.seismic/tags/org.gvsig.seismic-1.0.240/org.gvsig.seismic/org.gvsig.seismic.main/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
|
2 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|
3 |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> |
|
4 |
<modelVersion>4.0.0</modelVersion> |
|
5 |
<artifactId>org.gvsig.seismic.main</artifactId> |
|
6 |
<packaging>jar</packaging> |
|
7 |
<name>org.gvsig.seismic.main</name> |
|
8 |
<parent> |
|
9 |
<groupId>org.gvsig</groupId> |
|
10 |
<artifactId>org.gvsig.seismic</artifactId> |
|
11 |
<version>1.0.0-SNAPSHOT</version> |
|
12 |
</parent> |
|
13 |
|
|
14 |
|
|
15 |
<dependencies> |
|
16 |
<dependency> |
|
17 |
<groupId>org.gvsig</groupId> |
|
18 |
<artifactId>org.gvsig.seismic.lib.api</artifactId> |
|
19 |
<scope>compile</scope> |
|
20 |
</dependency> |
|
21 |
<dependency> |
|
22 |
<groupId>org.gvsig</groupId> |
|
23 |
<artifactId>org.gvsig.seismic.lib.impl</artifactId> |
|
24 |
<scope>runtime</scope> |
|
25 |
</dependency> |
|
26 |
<dependency> |
|
27 |
<groupId>org.gvsig</groupId> |
|
28 |
<artifactId>org.gvsig.seismic.swing.api</artifactId> |
|
29 |
<scope>compile</scope> |
|
30 |
</dependency> |
|
31 |
<dependency> |
|
32 |
<groupId>org.gvsig</groupId> |
|
33 |
<artifactId>org.gvsig.seismic.provider</artifactId> |
|
34 |
<scope>compile</scope> |
|
35 |
</dependency> |
|
36 |
<dependency> |
|
37 |
<groupId>org.gvsig</groupId> |
|
38 |
<artifactId>org.gvsig.seismic.swing.impl</artifactId> |
|
39 |
<scope>runtime</scope> |
|
40 |
</dependency> |
|
41 |
<dependency> |
|
42 |
<groupId>org.gvsig</groupId> |
|
43 |
<artifactId>org.gvsig.tools.lib</artifactId> |
|
44 |
<scope>compile</scope> |
|
45 |
</dependency> |
|
46 |
<dependency> |
|
47 |
<groupId>org.gvsig</groupId> |
|
48 |
<artifactId>org.gvsig.tools.dynform.api</artifactId> |
|
49 |
<scope>compile</scope> |
|
50 |
</dependency> |
|
51 |
<dependency> |
|
52 |
<groupId>org.gvsig</groupId> |
|
53 |
<artifactId>org.gvsig.tools.dynform.impl</artifactId> |
|
54 |
<scope>runtime</scope> |
|
55 |
</dependency> |
|
56 |
|
|
57 |
<dependency> |
|
58 |
<groupId>org.gvsig</groupId> |
|
59 |
<artifactId>org.gvsig.metadata.lib.basic.api</artifactId> |
|
60 |
<scope>compile</scope> |
|
61 |
</dependency> |
|
62 |
<dependency> |
|
63 |
<groupId>org.gvsig</groupId> |
|
64 |
<artifactId>org.gvsig.tools.swing.api</artifactId> |
|
65 |
<type>jar</type> |
|
66 |
<scope>compile</scope> |
|
67 |
</dependency> |
|
68 |
<dependency> |
|
69 |
<groupId>org.gvsig</groupId> |
|
70 |
<artifactId>org.gvsig.fmap.control</artifactId> |
|
71 |
<scope>compile</scope> |
|
72 |
</dependency> |
|
73 |
<dependency> |
|
74 |
<groupId>org.gvsig</groupId> |
|
75 |
<artifactId>org.gvsig.fmap.dal.api</artifactId> |
|
76 |
<scope>compile</scope> |
|
77 |
</dependency> |
|
78 |
<dependency> |
|
79 |
<groupId>org.gvsig</groupId> |
|
80 |
<artifactId>org.gvsig.fmap.dal.spi</artifactId> |
|
81 |
<scope>compile</scope> |
|
82 |
</dependency> |
|
83 |
<dependency> |
|
84 |
<groupId>org.gvsig</groupId> |
|
85 |
<artifactId>org.gvsig.fmap.geometry.api</artifactId> |
|
86 |
<scope>compile</scope> |
|
87 |
</dependency> |
|
88 |
<dependency> |
|
89 |
<groupId>org.gvsig</groupId> |
|
90 |
<artifactId>org.gvsig.fmap.mapcontext.api</artifactId> |
|
91 |
<scope>compile</scope> |
|
92 |
</dependency> |
|
93 |
|
|
94 |
|
|
95 |
<dependency> |
|
96 |
<groupId>org.gvsig</groupId> |
|
97 |
<artifactId>org.gvsig.metadata.lib.basic.impl</artifactId> |
|
98 |
<scope>runtime</scope> |
|
99 |
</dependency> |
|
100 |
<dependency> |
|
101 |
<groupId>org.gvsig</groupId> |
|
102 |
<artifactId>org.gvsig.fmap.geometry.impl</artifactId> |
|
103 |
<scope>runtime</scope> |
|
104 |
</dependency> |
|
105 |
<dependency> |
|
106 |
<groupId>org.gvsig</groupId> |
|
107 |
<artifactId>org.gvsig.fmap.geometry.operation</artifactId> |
|
108 |
<scope>runtime</scope> |
|
109 |
</dependency> |
|
110 |
<dependency> |
|
111 |
<groupId>org.gvsig</groupId> |
|
112 |
<artifactId>org.gvsig.fmap.mapcontext.impl</artifactId> |
|
113 |
<scope>runtime</scope> |
|
114 |
</dependency> |
|
115 |
<dependency> |
|
116 |
<groupId>org.gvsig</groupId> |
|
117 |
<artifactId>org.gvsig.symbology.lib.impl</artifactId> |
|
118 |
<scope>runtime</scope> |
|
119 |
</dependency> |
|
120 |
<dependency> |
|
121 |
<groupId>org.gvsig</groupId> |
|
122 |
<artifactId>org.gvsig.fmap.dal.impl</artifactId> |
|
123 |
<scope>runtime</scope> |
|
124 |
</dependency> |
|
125 |
<dependency> |
|
126 |
<groupId>org.gvsig</groupId> |
|
127 |
<artifactId>org.gvsig.fmap.dal.spi</artifactId> |
|
128 |
<scope>runtime</scope> |
|
129 |
</dependency> |
|
130 |
<dependency> |
|
131 |
<groupId>org.gvsig</groupId> |
|
132 |
<artifactId>org.gvsig.fmap.dal.file.shp</artifactId> |
|
133 |
<scope>runtime</scope> |
|
134 |
</dependency> |
|
135 |
<dependency> |
|
136 |
<groupId>org.gvsig</groupId> |
|
137 |
<artifactId>org.gvsig.fmap.dal.file.dbf</artifactId> |
|
138 |
<scope>runtime</scope> |
|
139 |
</dependency> |
|
140 |
<dependency> |
|
141 |
<groupId>org.gvsig</groupId> |
|
142 |
<artifactId>org.gvsig.fmap.dal.file.lib</artifactId> |
|
143 |
<scope>runtime</scope> |
|
144 |
</dependency> |
|
145 |
<dependency> |
|
146 |
<groupId>org.gvsig</groupId> |
|
147 |
<artifactId>org.gvsig.timesupport.lib.api</artifactId> |
|
148 |
<scope>runtime</scope> |
|
149 |
</dependency> |
|
150 |
<dependency> |
|
151 |
<groupId>org.gvsig</groupId> |
|
152 |
<artifactId>org.gvsig.timesupport.lib.impl</artifactId> |
|
153 |
<scope>runtime</scope> |
|
154 |
</dependency> |
|
155 |
<dependency> |
|
156 |
<groupId>org.gvsig</groupId> |
|
157 |
<artifactId>org.gvsig.tools.evaluator.sqljep</artifactId> |
|
158 |
<scope>runtime</scope> |
|
159 |
</dependency> |
|
160 |
<dependency> |
|
161 |
<groupId>org.gvsig</groupId> |
|
162 |
<artifactId>org.gvsig.proj.lib.proj4j</artifactId> |
|
163 |
<scope>runtime</scope> |
|
164 |
</dependency> |
|
165 |
</dependencies> |
|
166 |
</project> |
|
0 | 167 |
org.gvsig.seismic/tags/org.gvsig.seismic-1.0.240/org.gvsig.seismic/org.gvsig.seismic.lib/org.gvsig.seismic.lib.impl/src/test/resources/README.txt | ||
---|---|---|
1 |
Put into this folder the resources needed by your test classes. |
|
2 |
|
|
3 |
This folder is added to the Tests classpath, so you can load any resources |
|
4 |
through the ClassLoader. |
|
5 |
|
|
6 |
By default, in this folder you can find an example of log4j configuration, |
|
7 |
prepared to log messages through the console, so logging works when you |
|
8 |
run your tests classes. |
|
0 | 9 |
org.gvsig.seismic/tags/org.gvsig.seismic-1.0.240/org.gvsig.seismic/org.gvsig.seismic.lib/org.gvsig.seismic.lib.impl/src/test/resources/log4j.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1" ?> |
|
2 |
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> |
|
3 |
|
|
4 |
<!-- |
|
5 |
Log4J configuration file for unit tests execution. |
|
6 |
--> |
|
7 |
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> |
|
8 |
|
|
9 |
<!-- Appender configuration to show logging messages through the console --> |
|
10 |
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender"> |
|
11 |
<layout class="org.apache.log4j.PatternLayout"> |
|
12 |
<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n %m%n" /> |
|
13 |
</layout> |
|
14 |
</appender> |
|
15 |
|
|
16 |
<!-- |
|
17 |
Activate logging messages of DEBUG level of higher only for the |
|
18 |
org.gvsig.tools packages. |
|
19 |
You can put full classes names or packages instead, to configure |
|
20 |
logging for all the classes and subpackages of the package. |
|
21 |
--> |
|
22 |
<category name="org.gvsig.tools"> |
|
23 |
<priority value="DEBUG" /> |
|
24 |
</category> |
|
25 |
<category name="org.gvsig.chart"> |
|
26 |
<priority value="DEBUG" /> |
|
27 |
</category> |
|
28 |
|
|
29 |
<!-- |
|
30 |
By default, show only logging messages of INFO level or higher, |
|
31 |
through the previously configured CONSOLE appender. |
|
32 |
--> |
|
33 |
<root> |
|
34 |
<priority value="DEBUG" /> |
|
35 |
<appender-ref ref="CONSOLE" /> |
|
36 |
</root> |
|
37 |
</log4j:configuration> |
|
0 | 38 |
org.gvsig.seismic/tags/org.gvsig.seismic-1.0.240/org.gvsig.seismic/org.gvsig.seismic.lib/org.gvsig.seismic.lib.impl/src/main/java/org/gvsig/seismic/impl/DefaultSeismicLibrary.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.seismic.impl; |
|
23 |
|
|
24 |
|
|
25 |
import org.gvsig.seismic.SeismicLibrary; |
|
26 |
import org.gvsig.seismic.SeismicLocator; |
|
27 |
import org.gvsig.seismic.SeismicManager; |
|
28 |
import org.gvsig.seismic.impl.parser.CADParser; |
|
29 |
import org.gvsig.seismic.impl.parser.GEOGParser; |
|
30 |
import org.gvsig.seismic.impl.parser.H19Parser; |
|
31 |
import org.gvsig.seismic.impl.parser.P190Parser; |
|
32 |
import org.gvsig.seismic.impl.parser.PTOParser; |
|
33 |
import org.gvsig.seismic.impl.parser.R06Parser; |
|
34 |
import org.gvsig.seismic.impl.parser.RPSParser; |
|
35 |
import org.gvsig.seismic.impl.parser.UKOOA84Parser; |
|
36 |
import org.gvsig.tools.library.AbstractLibrary; |
|
37 |
import org.gvsig.tools.library.LibraryException; |
|
38 |
import org.gvsig.tools.util.Caller; |
|
39 |
import org.gvsig.tools.util.impl.DefaultCaller; |
|
40 |
|
|
41 |
/** |
|
42 |
* Library for default implementation initialization and configuration. |
|
43 |
* This default implementation will be based in JFreeChart library. |
|
44 |
* |
|
45 |
* @author gvSIG team |
|
46 |
* @version $Id$ |
|
47 |
*/ |
|
48 |
public class DefaultSeismicLibrary extends AbstractLibrary { |
|
49 |
|
|
50 |
@Override |
|
51 |
public void doRegistration() { |
|
52 |
registerAsImplementationOf(SeismicLibrary.class); |
|
53 |
} |
|
54 |
|
|
55 |
|
|
56 |
@Override |
|
57 |
protected void doInitialize() throws LibraryException { |
|
58 |
SeismicLocator.registerDriverManager(DefaultSeismicManager.class); |
|
59 |
} |
|
60 |
|
|
61 |
@Override |
|
62 |
protected void doPostInitialize() throws LibraryException { |
|
63 |
|
|
64 |
Caller caller = new DefaultCaller(); |
|
65 |
//caller.add( new DefaultChartLegendItem.RegisterPersistence() ); |
|
66 |
caller.call(); |
|
67 |
|
|
68 |
SeismicManager manager = SeismicLocator.getDriverManager(); |
|
69 |
//manager.registerParser(new CADParser(manager)); |
|
70 |
manager.registerParser(new UKOOA84Parser(manager)); |
|
71 |
manager.registerParser(new RPSParser(manager)); |
|
72 |
manager.registerParser(new R06Parser(manager)); |
|
73 |
manager.registerParser(new H19Parser(manager)); |
|
74 |
manager.registerParser(new GEOGParser(manager)); |
|
75 |
manager.registerParser(new PTOParser(manager)); |
|
76 |
manager.registerParser(new P190Parser(manager)); |
|
77 |
//manager.registerParser(new U84Parser(manager)); |
|
78 |
} |
|
79 |
|
|
80 |
} |
|
0 | 81 |
org.gvsig.seismic/tags/org.gvsig.seismic-1.0.240/org.gvsig.seismic/org.gvsig.seismic.lib/org.gvsig.seismic.lib.impl/src/main/java/org/gvsig/seismic/impl/DefaultSeismicManager.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.seismic.impl; |
|
23 |
|
|
24 |
import java.io.File; |
|
25 |
import java.util.HashMap; |
|
26 |
import java.util.List; |
|
27 |
import java.util.Map; |
|
28 |
import java.util.Set; |
|
29 |
|
|
30 |
import org.gvsig.fmap.dal.DALLocator; |
|
31 |
import org.gvsig.fmap.dal.DataManager; |
|
32 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
33 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
34 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
|
35 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
|
36 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
37 |
import org.gvsig.fmap.dal.store.seismic.SeismicStoreParameters; |
|
38 |
import org.gvsig.fmap.dal.store.seismic.SeismicStoreProvider; |
|
39 |
import org.gvsig.seismic.Parser; |
|
40 |
import org.gvsig.seismic.SeismicManager; |
|
41 |
import org.gvsig.tools.dynobject.DynObject; |
|
42 |
import org.gvsig.tools.service.Service; |
|
43 |
import org.gvsig.tools.service.ServiceException; |
|
44 |
|
|
45 |
/** |
|
46 |
* Default {@link DriverManager} implementation. |
|
47 |
* |
|
48 |
* @author gvSIG Team |
|
49 |
* @version $Id$ |
|
50 |
*/ |
|
51 |
public class DefaultSeismicManager implements SeismicManager { |
|
52 |
|
|
53 |
private Map<String,Parser> parsers = new HashMap<String,Parser>(); |
|
54 |
private DataManager dataManager; |
|
55 |
private DataStoreParameters driverStoreParameters; |
|
56 |
|
|
57 |
public DefaultSeismicManager(){ |
|
58 |
this.dataManager = DALLocator.getDataManager(); |
|
59 |
} |
|
60 |
|
|
61 |
|
|
62 |
public Service getService(DynObject parameters) throws ServiceException { |
|
63 |
return null; |
|
64 |
} |
|
65 |
|
|
66 |
public Parser createParser(String name){ |
|
67 |
Parser parser = parsers.get(name).clone(); |
|
68 |
parser.initializeParser(); |
|
69 |
return parser; |
|
70 |
} |
|
71 |
|
|
72 |
|
|
73 |
|
|
74 |
public void registerParser(Parser parser){ |
|
75 |
parsers.put(parser.getName(), parser); |
|
76 |
} |
|
77 |
|
|
78 |
public List<DynObject> createFileParser(File file, Parser parser) { |
|
79 |
return parser.parseFile(file); |
|
80 |
} |
|
81 |
|
|
82 |
|
|
83 |
public Set<String> getRegisteredParsers() { |
|
84 |
return this.parsers.keySet(); |
|
85 |
} |
|
86 |
|
|
87 |
public FeatureStore getFeatureStore() { |
|
88 |
|
|
89 |
try { |
|
90 |
return (FeatureStore) this.dataManager.openStore( |
|
91 |
SeismicStoreProvider.NAME, (SeismicStoreParameters) getDriverStoreParameters()); |
|
92 |
} catch (ValidateDataParametersException e) { |
|
93 |
// TODO Auto-generated catch block |
|
94 |
e.printStackTrace(); |
|
95 |
} catch (InitializeException e) { |
|
96 |
// TODO Auto-generated catch block |
|
97 |
e.printStackTrace(); |
|
98 |
} catch (ProviderNotRegisteredException e) { |
|
99 |
// TODO Auto-generated catch block |
|
100 |
e.printStackTrace(); |
|
101 |
} |
|
102 |
return null; |
|
103 |
|
|
104 |
} |
|
105 |
|
|
106 |
public DataStoreParameters getDriverStoreParameters() { |
|
107 |
if(this.driverStoreParameters == null){ |
|
108 |
try { |
|
109 |
this.driverStoreParameters = dataManager.createStoreParameters(SeismicStoreProvider.NAME); |
|
110 |
} catch (InitializeException e) { |
|
111 |
// TODO Auto-generated catch block |
|
112 |
e.printStackTrace(); |
|
113 |
} catch (ProviderNotRegisteredException e) { |
|
114 |
// TODO Auto-generated catch block |
|
115 |
e.printStackTrace(); |
|
116 |
} |
|
117 |
} |
|
118 |
return this.driverStoreParameters; |
|
119 |
} |
|
120 |
|
|
121 |
} |
|
0 | 122 |
org.gvsig.seismic/tags/org.gvsig.seismic-1.0.240/org.gvsig.seismic/org.gvsig.seismic.lib/org.gvsig.seismic.lib.impl/src/main/java/org/gvsig/seismic/impl/parser/GEOGParser.java | ||
---|---|---|
1 |
package org.gvsig.seismic.impl.parser; |
|
2 |
|
|
3 |
import java.io.BufferedReader; |
|
4 |
import java.io.File; |
|
5 |
import java.io.FileReader; |
|
6 |
import java.util.ArrayList; |
|
7 |
import java.util.List; |
|
8 |
|
|
9 |
import org.cresques.cts.IProjection; |
|
10 |
import org.gvsig.fmap.crs.CRSFactory; |
|
11 |
import org.gvsig.fmap.geom.DataTypes; |
|
12 |
import org.gvsig.fmap.geom.Geometry; |
|
13 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
|
14 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
|
15 |
import org.gvsig.fmap.geom.primitive.Point; |
|
16 |
import org.gvsig.seismic.Parser; |
|
17 |
import org.gvsig.seismic.SeismicManager; |
|
18 |
import org.gvsig.seismic.impl.AbstractParser; |
|
19 |
import org.gvsig.tools.dynobject.DynObject; |
|
20 |
|
|
21 |
public class GEOGParser extends AbstractParser{ |
|
22 |
private List<String> fields; |
|
23 |
|
|
24 |
public static String NAME = "UKOOA-GEOG"; |
|
25 |
public static String DESCRIPTION = "Parser to the UKOOA-geog files"; |
|
26 |
|
|
27 |
public GEOGParser(SeismicManager manager) { |
|
28 |
super(manager); |
|
29 |
|
|
30 |
this.initialize(); |
|
31 |
} |
|
32 |
|
|
33 |
private void initialize(){ |
|
34 |
availableExtensions.add("geog"); |
|
35 |
} |
|
36 |
|
|
37 |
@Override |
|
38 |
public String getName() { |
|
39 |
return GEOGParser.NAME; |
|
40 |
} |
|
41 |
|
|
42 |
@Override |
|
43 |
public String getDescription() { |
|
44 |
return GEOGParser.DESCRIPTION; |
|
45 |
} |
|
46 |
|
|
47 |
@Override |
|
48 |
public boolean hasStartEndDelimiters() { |
|
49 |
return false; |
|
50 |
} |
|
51 |
|
|
52 |
@Override |
|
53 |
public String getStartDelimiter() { |
|
54 |
return ""; |
|
55 |
} |
|
56 |
|
|
57 |
@Override |
|
58 |
public String getEndDelimiter() { |
|
59 |
return "\n"; |
|
60 |
} |
|
61 |
|
|
62 |
@Override |
|
63 |
public boolean hasHeader() { |
|
64 |
return false; |
|
65 |
} |
|
66 |
|
|
67 |
@Override |
|
68 |
public String getHeaderToken() { |
|
69 |
return ""; |
|
70 |
} |
|
71 |
|
|
72 |
@Override |
|
73 |
public boolean hasHeaderTokenRepited() { |
|
74 |
return false; |
|
75 |
} |
|
76 |
|
|
77 |
@Override |
|
78 |
public String getFieldDelimiter() { |
|
79 |
return " "; |
|
80 |
} |
|
81 |
|
|
82 |
@Override |
|
83 |
public boolean hasFieldName() { |
|
84 |
return false; |
|
85 |
} |
|
86 |
|
|
87 |
@Override |
|
88 |
public String getFieldNameSeparator() { |
|
89 |
return ""; |
|
90 |
} |
|
91 |
|
|
92 |
public boolean hasMetadata() { |
|
93 |
return true; |
|
94 |
} |
|
95 |
|
|
96 |
public String getMetadataToken() { |
|
97 |
return "H[\\.0-9]*"; |
|
98 |
} |
|
99 |
|
|
100 |
public boolean hasMetadataFieldName() { |
|
101 |
return false; |
|
102 |
} |
|
103 |
|
|
104 |
public String getMetadataFieldNameSeparator() { |
|
105 |
return " "; |
|
106 |
} |
|
107 |
|
|
108 |
protected void initializeDefinitions() { |
|
109 |
addFieldDefinition("linea", DataTypes.STRING); |
|
110 |
addFieldDefinition("estaca", DataTypes.STRING); |
|
111 |
addFieldDefinition("xxx", DataTypes.STRING); |
|
112 |
addFieldDefinition("Este", DataTypes.STRING); |
|
113 |
addFieldDefinition("Norte", DataTypes.STRING); |
|
114 |
addFieldDefinition("GEOM", DataTypes.GEOMETRY); |
|
115 |
super.initializeDefinitions(); |
|
116 |
} |
|
117 |
|
|
118 |
public String[] getOrderedFieldNames() { |
|
119 |
return new String[]{"proyecto", "proyecto_id", "Estado", "Fecha", |
|
120 |
"linea", "estaca", "Este", "Norte", "GEOM"}; |
|
121 |
} |
|
122 |
|
|
123 |
protected void readDocument(File file, boolean onlyFirst){ |
|
124 |
//String text = ""; |
|
125 |
String line = ""; |
|
126 |
|
|
127 |
//boolean firstLine = true; |
|
128 |
|
|
129 |
List<DynObject> objects = new ArrayList<DynObject>(); |
|
130 |
//DynStruct struct = getDataStruct(); |
|
131 |
|
|
132 |
try { |
|
133 |
BufferedReader reader = new BufferedReader(new FileReader(file)); |
|
134 |
while ((line = reader.readLine()) != null) { |
|
135 |
if(line.startsWith("EOF")) |
|
136 |
break; |
|
137 |
|
|
138 |
if(onlyFirst){ |
|
139 |
if(!this.hasMetadata() || !line.matches("^"+getMetadataToken()+"(.*)$")){ |
|
140 |
//text = line; |
|
141 |
break; |
|
142 |
} |
|
143 |
}else{ |
|
144 |
|
|
145 |
if(!this.hasMetadata() || !line.matches("^"+getMetadataToken()+"(.*)$")){ |
|
146 |
String[] fields = null; |
|
147 |
fields = getFileFields(line); |
|
148 |
if(fields != null){ |
|
149 |
objects.add(createDynObject(fields)); |
|
150 |
} |
|
151 |
} |
|
152 |
|
|
153 |
} |
|
154 |
} |
|
155 |
reader.close(); |
|
156 |
}catch (Exception e) { |
|
157 |
e.printStackTrace(); |
|
158 |
} |
|
159 |
|
|
160 |
this.setData(objects); |
|
161 |
} |
|
162 |
|
|
163 |
private String[] getFileFields(String features) { |
|
164 |
fields = new ArrayList<String>(); |
|
165 |
String aux = features; |
|
166 |
|
|
167 |
aux = extractFilefield(40, aux); |
|
168 |
aux = extractFilefield(24, aux); |
|
169 |
aux = extractFilefield(16, aux); |
|
170 |
aux = extractFilefield(10, aux); |
|
171 |
aux = extractFilefield(0, aux); |
|
172 |
|
|
173 |
String[] names = new String[fields.size()]; |
|
174 |
return fields.toArray(names); |
|
175 |
} |
|
176 |
|
|
177 |
protected String extractFilefield(int index, String aux){ |
|
178 |
if(aux.length()>index){ |
|
179 |
String fieldAux = aux.substring(index); |
|
180 |
aux = aux.substring(0, index); |
|
181 |
String f = fieldAux.trim(); |
|
182 |
if(f!=null && f.length() > 0){ |
|
183 |
fields.add(0, f); |
|
184 |
} |
|
185 |
} |
|
186 |
return aux; |
|
187 |
} |
|
188 |
|
|
189 |
@Override |
|
190 |
protected DynObject createDynObject(String[] fields) { |
|
191 |
DynObject dynObject = dynManager.createDynObject(getDataStruct()); |
|
192 |
for(int j=0; j<fields.length; j++){ |
|
193 |
FieldDefinition fdef = getFieldDefinitions().get(j); |
|
194 |
dynObject.setDynValue(fdef.getName(), fields[j]); |
|
195 |
} |
|
196 |
if(getFieldNames() != null && getFieldNames().size() > 2){ |
|
197 |
Object objX = fields[3]; |
|
198 |
Object objY = fields[4]; |
|
199 |
|
|
200 |
Double coordX = degreesToDouble(objX.toString().trim()); |
|
201 |
Double coordY = degreesToDouble(objY.toString().trim()); |
|
202 |
|
|
203 |
try { |
|
204 |
Point point = (Point) geomanager.create(Geometry.TYPES.POINT, SUBTYPES.GEOM2D); |
|
205 |
point.setX(coordX); |
|
206 |
point.setY(coordY); |
|
207 |
dynObject.setDynValue("GEOM", point); |
|
208 |
} catch (CreateGeometryException e) { |
|
209 |
// TODO Auto-generated catch block |
|
210 |
e.printStackTrace(); |
|
211 |
} |
|
212 |
} |
|
213 |
|
|
214 |
this.createDynObjectProjectInfo(dynObject); |
|
215 |
|
|
216 |
return dynObject; |
|
217 |
} |
|
218 |
|
|
219 |
|
|
220 |
private Double degreesToDouble(String degree) { |
|
221 |
if(!degree.trim().matches("(-)?[0-9]*:[0-6][0-9]:[0-6][0-9](.[0-9]{1,5})?")) |
|
222 |
throw new IllegalArgumentException(); |
|
223 |
String[] strArray=degree.split("[:]"); |
|
224 |
Double hours = Double.parseDouble(strArray[0]); |
|
225 |
Double minutes = Double.parseDouble(strArray[1])/60; |
|
226 |
Double seconds = Double.parseDouble(strArray[2])/3600; |
|
227 |
return hours+minutes+seconds; |
|
228 |
} |
|
229 |
|
|
230 |
@Override |
|
231 |
protected IProjection getDefaultProjection() { |
|
232 |
return CRSFactory.getCRS("EPSG:4326"); |
|
233 |
} |
|
234 |
|
|
235 |
@Override |
|
236 |
public Parser clone() { |
|
237 |
return new GEOGParser(getDriverManager()); |
|
238 |
} |
|
239 |
|
|
240 |
} |
|
0 | 241 |
org.gvsig.seismic/tags/org.gvsig.seismic-1.0.240/org.gvsig.seismic/org.gvsig.seismic.lib/org.gvsig.seismic.lib.impl/src/main/java/org/gvsig/seismic/impl/parser/H19Parser.java | ||
---|---|---|
1 |
package org.gvsig.seismic.impl.parser; |
|
2 |
|
|
3 |
import java.io.BufferedReader; |
|
4 |
import java.io.File; |
|
5 |
import java.io.FileReader; |
|
6 |
import java.util.ArrayList; |
|
7 |
import java.util.List; |
|
8 |
|
|
9 |
import org.cresques.cts.IProjection; |
|
10 |
import org.gvsig.fmap.crs.CRSFactory; |
|
11 |
import org.gvsig.fmap.geom.DataTypes; |
|
12 |
import org.gvsig.fmap.geom.Geometry; |
|
13 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
|
14 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
|
15 |
import org.gvsig.fmap.geom.primitive.Point; |
|
16 |
import org.gvsig.seismic.Parser; |
|
17 |
import org.gvsig.seismic.SeismicManager; |
|
18 |
import org.gvsig.seismic.impl.AbstractParser; |
|
19 |
import org.gvsig.tools.dynobject.DynObject; |
|
20 |
|
|
21 |
public class H19Parser extends AbstractParser{ |
|
22 |
|
|
23 |
public static String NAME = "UKOOA-H19"; |
|
24 |
public static String DESCRIPTION = "Parser to the UKOOA-h19 files"; |
|
25 |
private List<String> fields; |
|
26 |
|
|
27 |
public H19Parser(SeismicManager manager) { |
|
28 |
super(manager); |
|
29 |
|
|
30 |
this.initialize(); |
|
31 |
} |
|
32 |
|
|
33 |
private void initialize(){ |
|
34 |
availableExtensions.add("h19"); |
|
35 |
} |
|
36 |
|
|
37 |
@Override |
|
38 |
public String getName() { |
|
39 |
return H19Parser.NAME; |
|
40 |
} |
|
41 |
|
|
42 |
@Override |
|
43 |
public String getDescription() { |
|
44 |
return H19Parser.DESCRIPTION; |
|
45 |
} |
|
46 |
|
|
47 |
@Override |
|
48 |
public boolean hasStartEndDelimiters() { |
|
49 |
return false; |
|
50 |
} |
|
51 |
|
|
52 |
@Override |
|
53 |
public String getStartDelimiter() { |
|
54 |
return ""; |
|
55 |
} |
|
56 |
|
|
57 |
@Override |
|
58 |
public String getEndDelimiter() { |
|
59 |
return "\n"; |
|
60 |
} |
|
61 |
|
|
62 |
@Override |
|
63 |
public boolean hasHeader() { |
|
64 |
return false; |
|
65 |
} |
|
66 |
|
|
67 |
@Override |
|
68 |
public String getHeaderToken() { |
|
69 |
return ""; |
|
70 |
} |
|
71 |
|
|
72 |
@Override |
|
73 |
public boolean hasHeaderTokenRepited() { |
|
74 |
return false; |
|
75 |
} |
|
76 |
|
|
77 |
@Override |
|
78 |
public String getFieldDelimiter() { |
|
79 |
return " "; |
|
80 |
} |
|
81 |
|
|
82 |
@Override |
|
83 |
public boolean hasFieldName() { |
|
84 |
return false; |
|
85 |
} |
|
86 |
|
|
87 |
@Override |
|
88 |
public String getFieldNameSeparator() { |
|
89 |
return ""; |
|
90 |
} |
|
91 |
|
|
92 |
public boolean hasMetadata() { |
|
93 |
return true; |
|
94 |
} |
|
95 |
|
|
96 |
public String getMetadataToken() { |
|
97 |
return "H[\\.0-9]*"; |
|
98 |
} |
|
99 |
|
|
100 |
public boolean hasMetadataFieldName() { |
|
101 |
return false; |
|
102 |
} |
|
103 |
|
|
104 |
public String getMetadataFieldNameSeparator() { |
|
105 |
return " "; |
|
106 |
} |
|
107 |
|
|
108 |
protected void initializeDefinitions() { |
|
109 |
addFieldDefinition("linea", DataTypes.STRING); |
|
110 |
addFieldDefinition("estaca", DataTypes.STRING); |
|
111 |
addFieldDefinition("latitud", DataTypes.STRING); |
|
112 |
addFieldDefinition("longitud", DataTypes.STRING); |
|
113 |
addFieldDefinition("Este", DataTypes.DOUBLE); |
|
114 |
addFieldDefinition("Norte", DataTypes.DOUBLE); |
|
115 |
addFieldDefinition("Elevacion", DataTypes.STRING); |
|
116 |
addFieldDefinition("GEOM", DataTypes.GEOMETRY); |
|
117 |
super.initializeDefinitions(); |
|
118 |
} |
|
119 |
|
|
120 |
public String[] getOrderedFieldNames() { |
|
121 |
return new String[]{"proyecto", "proyecto_id", "Estado", "Fecha", |
|
122 |
"linea", "estaca", "latitud", "longitud", "Este", "Norte", "Elevacion", "GEOM"}; |
|
123 |
} |
|
124 |
|
|
125 |
|
|
126 |
// @Override |
|
127 |
// protected List<Map<String,Object>> extractFeatures(File file, boolean onlyFirst){ |
|
128 |
// /** |
|
129 |
// * Fase 1: parsear el documento |
|
130 |
// */ |
|
131 |
// |
|
132 |
// List<Map<String,Object>> auxFeatures = new ArrayList<Map<String,Object>>(); |
|
133 |
// String text = readDocument(file, onlyFirst); |
|
134 |
// |
|
135 |
// text = preParsingProcess(text); |
|
136 |
// |
|
137 |
// // Fase 1a: Separar las Features |
|
138 |
// String[] features = null; |
|
139 |
// features = text.split(getEndDelimiter()); |
|
140 |
// |
|
141 |
// // Fase 1b: Obtener los fields de cada feature |
|
142 |
// for(int i=0; i<features.length; i++){ |
|
143 |
// Map<String,Object> auxFields = new HashMap<String,Object>(); |
|
144 |
// |
|
145 |
// // Si tiene cabecera, la primera iteraci?n es la definici?n |
|
146 |
// if(hasHeader() && i==0){ |
|
147 |
// i++; |
|
148 |
// } |
|
149 |
// |
|
150 |
// String[] fields = getFileFields(features[i]); |
|
151 |
// for(int j=0; j<fields.length; j++){ |
|
152 |
// FieldDefinition fdef = getFieldDefinitions().get(j); |
|
153 |
// auxFields.put(fdef.getName(), fields[j]); |
|
154 |
// //addFieldDefinition(fdef.getName(), fdef.getType()); |
|
155 |
// } |
|
156 |
// |
|
157 |
// auxFeatures.add(auxFields); |
|
158 |
// } |
|
159 |
// |
|
160 |
// |
|
161 |
// |
|
162 |
// return auxFeatures; |
|
163 |
// } |
|
164 |
|
|
165 |
protected void readDocument(File file, boolean onlyFirst){ |
|
166 |
//String text = ""; |
|
167 |
String line = ""; |
|
168 |
|
|
169 |
//boolean firstLine = true; |
|
170 |
|
|
171 |
List<DynObject> objects = new ArrayList<DynObject>(); |
|
172 |
//DynStruct struct = getDataStruct(); |
|
173 |
|
|
174 |
try { |
|
175 |
BufferedReader reader = new BufferedReader(new FileReader(file)); |
|
176 |
while ((line = reader.readLine()) != null) { |
|
177 |
if(line.startsWith("EOF")) |
|
178 |
break; |
|
179 |
|
|
180 |
if(onlyFirst){ |
|
181 |
if(!this.hasMetadata() || !line.matches("^"+getMetadataToken()+"(.*)$")){ |
|
182 |
//text = line; |
|
183 |
break; |
|
184 |
} |
|
185 |
}else{ |
|
186 |
|
|
187 |
if(!this.hasMetadata() || !line.matches("^"+getMetadataToken()+"(.*)$")){ |
|
188 |
String[] fields = null; |
|
189 |
fields = getFileFields(line); |
|
190 |
if(fields != null){ |
|
191 |
objects.add(createDynObject(fields)); |
|
192 |
} |
|
193 |
} |
|
194 |
|
|
195 |
} |
|
196 |
} |
|
197 |
reader.close(); |
|
198 |
}catch (Exception e) { |
|
199 |
e.printStackTrace(); |
|
200 |
} |
|
201 |
|
|
202 |
this.setData(objects); |
|
203 |
} |
|
204 |
|
|
205 |
|
|
206 |
private String[] getFileFields(String features) { |
|
207 |
fields = new ArrayList<String>(); |
|
208 |
String aux = features; |
|
209 |
|
|
210 |
aux = extractFilefield(68, aux); |
|
211 |
aux = extractFilefield(55, aux); |
|
212 |
aux = extractFilefield(44, aux); |
|
213 |
aux = extractFilefield(32, aux); |
|
214 |
aux = extractFilefield(18, aux); |
|
215 |
aux = extractFilefield(10, aux); |
|
216 |
aux = extractFilefield(0, aux); |
|
217 |
|
|
218 |
String[] names = new String[fields.size()]; |
|
219 |
return fields.toArray(names); |
|
220 |
} |
|
221 |
|
|
222 |
private String extractFilefield(int index, String aux){ |
|
223 |
if(aux.length()>index){ |
|
224 |
String fieldAux = aux.substring(index).trim(); |
|
225 |
aux = aux.substring(0, index); |
|
226 |
fields.add(0, fieldAux); |
|
227 |
} |
|
228 |
return aux; |
|
229 |
} |
|
230 |
|
|
231 |
@Override |
|
232 |
protected DynObject createDynObject(String[] fields) { |
|
233 |
DynObject dynObject = dynManager.createDynObject(getDataStruct()); |
|
234 |
for(int j=0; j<fields.length; j++){ |
|
235 |
FieldDefinition fdef = getFieldDefinitions().get(j); |
|
236 |
dynObject.setDynValue(fdef.getName(), fields[j]); |
|
237 |
} |
|
238 |
if(getFieldNames() != null && getFieldNames().size() > 3){ |
|
239 |
Object objX = fields[4]; |
|
240 |
Object objY = fields[5]; |
|
241 |
|
|
242 |
Double coordX = Double.parseDouble(objX.toString().trim()); |
|
243 |
Double coordY = Double.parseDouble(objY.toString().trim()); |
|
244 |
|
|
245 |
try { |
|
246 |
Point point = (Point) geomanager.create(Geometry.TYPES.POINT, SUBTYPES.GEOM2D); |
|
247 |
point.setX(coordX); |
|
248 |
point.setY(coordY); |
|
249 |
dynObject.setDynValue("GEOM", point); |
|
250 |
} catch (CreateGeometryException e) { |
|
251 |
// TODO Auto-generated catch block |
|
252 |
e.printStackTrace(); |
|
253 |
} |
|
254 |
} |
|
255 |
|
|
256 |
this.createDynObjectProjectInfo(dynObject); |
|
257 |
|
|
258 |
|
|
259 |
return dynObject; |
|
260 |
} |
|
261 |
|
|
262 |
|
|
263 |
@Override |
|
264 |
public Parser clone() { |
|
265 |
return new H19Parser(getDriverManager()); |
|
266 |
} |
|
267 |
|
|
268 |
} |
|
0 | 269 |
org.gvsig.seismic/tags/org.gvsig.seismic-1.0.240/org.gvsig.seismic/org.gvsig.seismic.lib/org.gvsig.seismic.lib.impl/src/main/java/org/gvsig/seismic/impl/parser/PTOParser.java | ||
---|---|---|
1 |
package org.gvsig.seismic.impl.parser; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.List; |
|
5 |
|
|
6 |
import org.cresques.cts.IProjection; |
|
7 |
import org.gvsig.fmap.crs.CRSFactory; |
|
8 |
import org.gvsig.fmap.geom.DataTypes; |
|
9 |
import org.gvsig.fmap.geom.Geometry; |
|
10 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
|
11 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
|
12 |
import org.gvsig.fmap.geom.primitive.Point; |
|
13 |
import org.gvsig.seismic.Parser; |
|
14 |
import org.gvsig.seismic.SeismicManager; |
|
15 |
import org.gvsig.seismic.impl.AbstractParser; |
|
16 |
import org.gvsig.tools.dynobject.DynObject; |
|
17 |
|
|
18 |
public class PTOParser extends AbstractParser{ |
|
19 |
private List<String> fields; |
|
20 |
|
|
21 |
public static String NAME = "UKOOA-PTO"; |
|
22 |
public static String DESCRIPTION = "Parser to the UKOOA-desconocido files"; |
|
23 |
|
|
24 |
public PTOParser(SeismicManager manager) { |
|
25 |
super(manager); |
|
26 |
|
|
27 |
this.initialize(); |
|
28 |
} |
|
29 |
|
|
30 |
private void initialize(){ |
|
31 |
availableExtensions.add("pto"); |
|
32 |
} |
|
33 |
|
|
34 |
@Override |
|
35 |
public String getName() { |
|
36 |
return PTOParser.NAME; |
|
37 |
} |
|
38 |
|
|
39 |
@Override |
|
40 |
public String getDescription() { |
|
41 |
return PTOParser.DESCRIPTION; |
|
42 |
} |
|
43 |
|
|
44 |
@Override |
|
45 |
public boolean hasStartEndDelimiters() { |
|
46 |
return false; |
|
47 |
} |
|
48 |
|
|
49 |
@Override |
|
50 |
public String getStartDelimiter() { |
|
51 |
return ""; |
|
52 |
} |
|
53 |
|
|
54 |
@Override |
|
55 |
public String getEndDelimiter() { |
|
56 |
return "\n"; |
|
57 |
} |
|
58 |
|
|
59 |
@Override |
|
60 |
public boolean hasHeader() { |
|
61 |
return false; |
|
62 |
} |
|
63 |
|
|
64 |
@Override |
|
65 |
public String getHeaderToken() { |
|
66 |
return ""; |
|
67 |
} |
|
68 |
|
|
69 |
@Override |
|
70 |
public boolean hasHeaderTokenRepited() { |
|
71 |
return false; |
|
72 |
} |
|
73 |
|
|
74 |
@Override |
|
75 |
public String getFieldDelimiter() { |
|
76 |
return " "; |
|
77 |
} |
|
78 |
|
|
79 |
@Override |
|
80 |
public boolean hasFieldName() { |
|
81 |
return false; |
|
82 |
} |
|
83 |
|
|
84 |
@Override |
|
85 |
public String getFieldNameSeparator() { |
|
86 |
return ""; |
|
87 |
} |
|
88 |
|
|
89 |
public boolean hasMetadata() { |
|
90 |
return true; |
|
91 |
} |
|
92 |
|
|
93 |
public String getMetadataToken() { |
|
94 |
return "H[\\.0-9]*"; |
Also available in: Unified diff