Revision 11

View differences:

trunk/org.gvsig.gdal/org.gvsig.gdal.app/org.gvsig.gdal.app.gpx/src/main/assembly/gvsig-plugin-package.xml
28 28
      <useTransitiveDependencies>false</useTransitiveDependencies>
29 29
      <outputDirectory>lib</outputDirectory>
30 30
      <includes>
31
        <include>org.gvsig:gdal</include>
31 32
      	<include>org.gvsig:org.gvsig.gdal.gpx</include>
32 33
      </includes>
33 34
    </dependencySet>
trunk/org.gvsig.gdal/org.gvsig.gdal.app/org.gvsig.gdal.app.gpx/src/main/java/org/gvsig/gdal/app/gpx/gui/GPXWizard.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.gdal.app.gpx.gui;
23

  
24
import java.awt.FlowLayout;
25
import java.awt.GridBagConstraints;
26
import java.awt.GridBagLayout;
27
import java.awt.event.MouseEvent;
28
import java.awt.event.MouseListener;
29
import java.io.File;
30
import java.net.URL;
31
import java.util.List;
32

  
33
import javax.swing.JButton;
34
import javax.swing.JLabel;
35
import javax.swing.JPanel;
36
import javax.swing.JScrollPane;
37
import javax.swing.JTextArea;
38

  
39
import org.gdal.gdal.gdal;
40
import org.gdal.ogr.DataSource;
41
import org.gdal.ogr.Feature;
42
import org.gdal.ogr.FeatureDefn;
43
import org.gdal.ogr.FieldDefn;
44
import org.gdal.ogr.Layer;
45
import org.gdal.ogr.ogr;
46
import org.gvsig.andami.PluginServices;
47
import org.gvsig.andami.ui.mdiManager.IWindow;
48
import org.gvsig.app.ApplicationLocator;
49
import org.gvsig.app.ApplicationManager;
50
import org.gvsig.app.gui.WizardPanel;
51
import org.gvsig.app.gui.wizards.WizardListener;
52
import org.gvsig.app.gui.wizards.WizardListenerSupport;
53
import org.gvsig.app.project.ProjectManager;
54
import org.gvsig.app.project.documents.view.ViewDocument;
55
import org.gvsig.app.project.documents.view.gui.AbstractViewPanel;
56
import org.gvsig.fmap.dal.DALLocator;
57
import org.gvsig.fmap.dal.DataManager;
58
import org.gvsig.fmap.dal.DataStoreParameters;
59
import org.gvsig.fmap.dal.exception.InitializeException;
60
import org.gvsig.fmap.dal.exception.OpenException;
61
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException;
62
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
63
import org.gvsig.fmap.dal.feature.FeatureStore;
64
import org.gvsig.fmap.dal.store.gpx.OGRStoreParameters;
65
import org.gvsig.fmap.dal.store.gpx.OGRStoreProvider;
66
import org.gvsig.fmap.dal.store.gpx.OGRStoreProviderFactory;
67
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException;
68
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
69
import org.gvsig.gdal.app.gpx.gui.utils.JFileField;
70
import org.slf4j.Logger;
71
import org.slf4j.LoggerFactory;
72

  
73
/**
74
 * Wizard panel to add a new OSM raster layer
75
 * @author Jos? Bad?a (jbadia@scolab.es)
76
 */
77
public class GPXWizard extends WizardPanel implements MouseListener {
78
	private static final long           serialVersionUID      = 1L;
79
	private static final String         TAB_NAME              = "GDAL/OGR";
80
	private static Logger               logger                = LoggerFactory.getLogger(GPXWizard.class.getName());
81
	private AbstractViewPanel           view                  = null;
82
	private WizardListenerSupport       listenerSupport       = null;
83

  
84
	private JPanel chooserPanel;
85
	private JPanel jPanel1;
86
	private JFileField cmbHost;
87
	private JButton btnConnect;
88
	private JPanel jPanel;
89
	private JScrollPane jScrollPane;
90
	private JTextArea txtAbstract;
91
	private JPanel pnlName;
92
	private JLabel jLabel1;
93
	private JLabel lblTitle;
94

  
95
	private DataSource poDS = null;
96
	private File file = null;
97
	private OGRStoreParameters ogrStoreParameters;
98

  
99

  
100
	public GPXWizard() {
101
		super();
102
		initialize();
103
	}
104

  
105
	/**
106
	 * This method initializes this
107
	 *
108
	 * @return void
109
	 */
110
	private void initialize() {
111
		setTabName(PluginServices.getText(this, TAB_NAME));
112
		setLayout(new GridBagLayout());
113

  
114
		gdal.AllRegister();
115
		ogr.RegisterAll();
116

  
117
		IWindow iw = PluginServices.getMDIManager().getActiveWindow();
118

  
119
		if (iw == null) {
120
			return;
121
		}
122

  
123
		if (!(iw instanceof AbstractViewPanel)) {
124
			return;
125
		}
126

  
127
		view = (AbstractViewPanel) iw;
128
		setMapCtrl(view.getMapControl());
129

  
130
		GridBagConstraints gridBagConstraints = new GridBagConstraints();
131
		gridBagConstraints.fill = GridBagConstraints.BOTH;
132
		gridBagConstraints.weightx = 1.0;
133
		gridBagConstraints.weighty = 1.0;
134
		gridBagConstraints.gridx = 0;
135
		gridBagConstraints.gridy = 0;
136
		add(getFileChooserPanel(), gridBagConstraints);
137

  
138
		gridBagConstraints.weightx = 1.0;
139
		gridBagConstraints.gridy = 1;
140
		gridBagConstraints.weighty = 4;
141
		add(getDescriptionPanel(), gridBagConstraints);
142
	}
143

  
144
	private WizardListenerSupport getWizardListenerSupport() {
145
		if(listenerSupport == null)
146
			listenerSupport = new WizardListenerSupport();
147
		return listenerSupport;
148
	}
149

  
150
	/**
151
	 * This method checks for the options selected within the configuration
152
	 * dialog are correct.
153
	 *
154
	 * @return true if you're done, false if not.
155
	 */
156
	public boolean areSettingsValid() {
157
		return true;
158
	}
159

  
160
	public void addWizardListener(WizardListener listener) {
161
		getWizardListenerSupport().addWizardListener(listener);
162
		getWizardListenerSupport().callStateChanged(false);
163
	}
164

  
165
	public void removeWizardListener(WizardListener listener) {
166
		getWizardListenerSupport().removeWizardListener(listener);
167
	}
168

  
169
	@Override
170
	public void close() {
171
	}
172

  
173
	@Override
174
	public void execute() {
175
		if(this.file != null){
176
			isFileSupported(this.file);
177

  
178
			// Si el fichero es soportado por OGR
179
			if(poDS != null){
180
				DataManager dataManager = DALLocator.getDataManager();
181
				OGRStoreProviderFactory provFact = (OGRStoreProviderFactory) dataManager.getStoreProviderFactory(OGRStoreProvider.NAME);
182
				OGRStoreParameters params = (OGRStoreParameters) provFact.createParameters();
183

  
184
				ApplicationManager application = ApplicationLocator.getManager();
185
				ProjectManager projectManager = application.getProjectManager();
186
				ViewDocument view = (ViewDocument) projectManager.getCurrentProject().getActiveDocument();
187

  
188
				try {
189

  
190
					FLyrVect layer = (FLyrVect) application.getMapContextManager().createLayer("prueba-ogr",  openFile(this.file));
191
					view.getMapContext().getLayers().addLayer(layer);
192
				} catch (LoadLayerException e) {
193
					e.printStackTrace();
194
				}
195
			}
196
		}else{
197
			// TODO mensaje de error que no hay fichero escogido
198
		}
199

  
200

  
201
	}
202

  
203
	private void isFileSupported(File path) {
204
		if(path != null){
205
			lblTitle.setText(path.getAbsolutePath());
206
		}else{
207
			poDS = null;
208
			lblTitle.setText("-");
209
			return ;
210
		}
211

  
212
		String aux = "Running under GDAL/OGR "+ gdal.VersionInfo()  +" version.\n\n";
213
		txtAbstract.setText(aux);
214

  
215
		if(ogr.GetDriverCount() != 0){
216
			poDS = ogr.Open(path.getAbsolutePath(), false);
217
			if(poDS != null){
218
				aux = aux + "Opened file '"+ path.getName()  +"' with "+ poDS.GetDriver().getName() +" driver.\n";
219
			}else{
220
				aux = aux + "ERROR: This file cannot be opened. Available drivers are the following:\n"; 
221
				for(int i = 0; i<ogr.GetDriverCount(); i++){
222
					aux = aux + ogr.GetDriver(i).getName();
223
					if(i+1<ogr.GetDriverCount()){
224
						aux = aux + ",   ";
225
					}
226
				}
227
				txtAbstract.setText(aux);
228
				return;
229
			}
230
		}else{
231
			aux = aux + "ERROR: GDAL/OGR driver are not initialized"; 
232
		}
233
		txtAbstract.setText(aux);
234
	}
235

  
236
	private JPanel getFileChooserPanel() {
237
		if (chooserPanel == null) {
238
			chooserPanel = new javax.swing.JPanel();
239
			chooserPanel.setLayout(null);
240
			chooserPanel.setPreferredSize(new java.awt.Dimension(480, 220));
241
			chooserPanel.setVisible(true);
242
			chooserPanel.setBounds(15, 5, 480, 407);
243
			chooserPanel.add(getFilePanel(), null);
244
		}
245

  
246
		return chooserPanel;
247
	}
248

  
249
	private JPanel getFilePanel() {
250
		if (jPanel1 == null) {
251
			jPanel1 = new javax.swing.JPanel();
252
			jPanel1.setLayout(null);
253
			jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(
254
					null, PluginServices.getText(this, "file"),
255
					javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
256
					javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
257
			jPanel1.setBounds(2, 5, 477, 85);
258
			jPanel1.add(getTxtHost(), null);
259
			jPanel1.add(getBtnConnect(), null);
260
		}
261

  
262
		return jPanel1;
263
	}
264

  
265
	private JFileField getTxtHost() {
266
		if (cmbHost == null) {
267
			cmbHost = new JFileField(null, "...");
268
			cmbHost.setMode(JFileField.MODE_OPEN);
269
			cmbHost.getFileChooser().setCurrentDirectory(new File(System.getProperty("user.home")));
270
			cmbHost.setPreferredSize(new java.awt.Dimension(350, 40));
271
			cmbHost.setBounds(11, 26, 470, 30);
272
			//cmbHost.setEditable(true);
273
		}
274
		return cmbHost;
275
	}
276

  
277
	private JButton getBtnConnect() {
278
		if (btnConnect == null) {
279
			btnConnect = new JButton();
280
			btnConnect.setPreferredSize(new java.awt.Dimension(100, 20));
281
			btnConnect.setBounds(366, 60, 100, 20);
282
			btnConnect.setText(PluginServices.getText(this, "Cargar"));
283
			btnConnect.addActionListener(new java.awt.event.ActionListener() {
284

  
285
				public void actionPerformed(java.awt.event.ActionEvent e) {
286
					file = cmbHost.getFileChooser().getSelectedFile();
287
					isFileSupported(file);
288

  
289
					String aux = txtAbstract.getText();
290

  
291
					DataManager dataManager = DALLocator.getDataManager();
292

  
293
					OGRStoreProviderFactory provFact = (OGRStoreProviderFactory) dataManager.getStoreProviderFactory(OGRStoreProvider.NAME);
294
					OGRStoreParameters params = (OGRStoreParameters) provFact.createParameters();
295
					params.setFile(file);
296

  
297
					OGRStoreProvider provider = null;
298
					try {
299
						provider = (OGRStoreProvider) provFact.createProvider(params, null);
300
					} catch (InitializeException e1) {
301
						// TODO Auto-generated catch block
302
						e1.printStackTrace();
303
					}
304

  
305
					if(provider != null){
306
						aux.concat("Running under GDAL/OGR "+ provider.getOGRVersion()  +" version.\n");
307
						try {
308
							provider.open();
309
							if(((OGRStoreParameters)provider.getParameters()).getDriver() != null){
310
								aux.concat("Opened file '"+ file.getName()  +"' with "+ ((OGRStoreParameters)provider.getParameters()).getDriver() +" driver.\n");
311
							}else{
312
								List<String> availableDrivers = provider.getAvailableDrivers();
313
								aux.concat("ERROR: This file cannot be opened. Available drivers are the following:\n"); 
314
								for(int i = 0; i<provider.getDriverCount(); i++){
315
									aux.concat(provider.getDriver(i)+" ");
316
								}
317
							}
318
						} catch (OpenException e1) {
319
							// TODO Auto-generated catch block
320
							e1.printStackTrace();
321
						}
322
					}
323

  
324

  
325
					for(int index = 0; index < poDS.GetLayerCount();index++){
326
						Layer layer = poDS.GetLayer(index);
327
						for(int feats = 0; feats < layer.GetFeatureCount();feats++){
328
							Feature feat = layer.GetFeature(feats);
329
							FeatureDefn definition = feat.GetDefnRef();
330
							for(int fields = 0; fields < definition.GetFieldCount();fields++){
331
								FieldDefn field = definition.GetFieldDefn(fields);
332
								String fieldName = field.GetName();
333
								int fieldType = field.GetFieldType();
334
								switch(fieldType){
335
								// Ejemplo -> Type 1 : Integer
336
								case 1:
337
									// Crear una feature en la vista
338
									int feature = feat.GetFieldAsInteger(field.GetFieldTypeName(fieldType));
339

  
340
									// A?adirla
341
									break;
342
								default:
343
									break;
344
								}
345
							}
346
						}
347
					}
348

  
349

  
350

  
351
				}
352

  
353
			});
354
		}
355

  
356
		return btnConnect;
357
	}
358

  
359
	private JPanel getDescriptionPanel() {
360
		if (jPanel == null) {
361
			jPanel = new JPanel();
362
			jPanel.setLayout(null);
363
			jPanel.setPreferredSize(new java.awt.Dimension(480, 330));
364
			jPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null,
365
					PluginServices.getText(this, "descripcion"),
366
					javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
367
					javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
368
			jPanel.setBounds(15, 5, 480, 407);
369
			jPanel.add(getJScrollPane(), null);
370
			jPanel.add(getPnlName(), null);
371
		}
372

  
373
		return jPanel;
374
	}
375

  
376
	private JScrollPane getJScrollPane() {
377
		if (jScrollPane == null) {
378
			jScrollPane = new JScrollPane();
379
			jScrollPane.setViewportView(getTxtAbstract());
380
			jScrollPane.setPreferredSize(new java.awt.Dimension(450, 60));
381
			jScrollPane.setBounds(10, 47, 457, 247);
382
		}
383

  
384
		return jScrollPane;
385
	}
386

  
387
	private JTextArea getTxtAbstract() {
388
		if (txtAbstract == null) {
389
			txtAbstract = new JTextArea();
390
			txtAbstract.setWrapStyleWord(true);
391
			txtAbstract.setColumns(30);
392
			txtAbstract.setLineWrap(true);
393
			txtAbstract.setEditable(false);
394
		}
395

  
396
		return txtAbstract;
397
	}
398

  
399
	private JPanel getPnlName() {
400
		if (pnlName == null) {
401
			pnlName = new JPanel();
402
			pnlName.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 0));
403
			pnlName.setBounds(new java.awt.Rectangle(9, 19, 452, 24));
404
			pnlName.add(getJLabel1(), null);
405
			pnlName.add(getLblTitle(), null);
406
		}
407
		return pnlName;
408
	}
409

  
410
	private JLabel getJLabel1() {
411
		if (jLabel1 == null) {
412
			jLabel1 = new javax.swing.JLabel();
413
			jLabel1.setText(PluginServices.getText(this, "nombre") + ":");
414
			jLabel1.setBounds(15, 26, 65, 15);
415
		}
416

  
417
		return jLabel1;
418
	}
419

  
420
	private JLabel getLblTitle() {
421
		if (lblTitle == null) {
422
			lblTitle = new javax.swing.JLabel();
423
			lblTitle.setText("-");
424
			lblTitle.setPreferredSize(new java.awt.Dimension(350, 16));
425
			lblTitle.setBounds(82, 26, 350, 16);
426
		}
427

  
428
		return lblTitle;
429
	}
430

  
431
	@Override
432
	public DataStoreParameters[] getParameters() {
433
		return null;
434
	}
435

  
436
	@Override
437
	public void initWizard() {
438

  
439
	}
440

  
441
	public void mouseClicked(MouseEvent e) {
442

  
443
	}
444

  
445
	public void mouseEntered(MouseEvent e) {
446

  
447
	}
448

  
449
	public void mouseExited(MouseEvent e) {
450

  
451
	}
452

  
453
	public void mousePressed(MouseEvent e) {
454
		getWizardListenerSupport().callStateChanged(true);
455
	}
456

  
457
	public void mouseReleased(MouseEvent e) {
458

  
459
	}
460

  
461
	/**
462
	 * Get a resource as a File from a path name in the
463
	 * class path.
464
	 * 
465
	 * @param pathname
466
	 * 
467
	 * @return resource as a File
468
	 */
469
	private File getResource(String pathname) {
470
		URL res = this.getClass().getClassLoader().getResource(pathname);
471
		return new File(res.getPath());
472
	}
473

  
474
	private FeatureStore openFile(File shape) {
475
		//    	try {
476
		//
477
		//    		DataStoreParameters parameters;
478
		//	    	DataManager manager = DALLocator.getDataManager();
479
		//	    	
480
		//			parameters = manager.createStoreParameters("Shape");
481
		//		    parameters.setDynValue("shpfile", shape);
482
		//		    parameters.setDynValue("crs", "EPSG:23030");
483
		//	    	return (FeatureStore) manager.openStore("Shape", parameters);
484
		//
485
		//    	} catch (InitializeException e) {
486
		//			logger.error(e.getMessageStack());
487
		//			throw new RuntimeException(e);
488
		//		} catch (ProviderNotRegisteredException e) {
489
		//			logger.error(e.getMessageStack());
490
		//			throw new RuntimeException(e);
491
		//		} catch (ValidateDataParametersException e) {
492
		//			logger.error(e.getMessageStack());
493
		//			throw new RuntimeException(e);
494
		//		}
495

  
496
		DataManager dataManager = DALLocator.getDataManager();
497

  
498

  
499
		try {	
500
			if(this.ogrStoreParameters == null){
501
				this.ogrStoreParameters = 
502
						(OGRStoreParameters) dataManager.createStoreParameters(OGRStoreProvider.NAME);
503
			}
504
			this.ogrStoreParameters.setFile(file);
505
			return (FeatureStore) dataManager.openStore(
506
					OGRStoreProvider.NAME, this.ogrStoreParameters);
507
		} catch (ValidateDataParametersException e) {
508
			e.printStackTrace();
509
		} catch (InitializeException e) {
510
			e.printStackTrace();
511
		} catch (ProviderNotRegisteredException e) {
512
			e.printStackTrace();
513
		}
514
		return null;
515

  
516
	}
517
}
0 518

  
trunk/org.gvsig.gdal/org.gvsig.gdal.app/org.gvsig.gdal.app.gpx/src/main/java/org/gvsig/gdal/app/gpx/gui/utils/FileTypeFilter.java
1
package org.gvsig.gdal.app.gpx.gui.utils;
2

  
3
import java.io.File;
4
import javax.swing.filechooser.FileFilter;
5
 
6
public class FileTypeFilter extends FileFilter {
7
 
8
    private String extension;
9
    private String description;
10
     
11
    public FileTypeFilter(String extension, String description) {
12
        this.extension = extension;
13
        this.description = description;
14
    }
15
     
16
    @Override
17
    public boolean accept(File file) {
18
        if (file.isDirectory()) {
19
            return true;
20
        }
21
        return file.getName().toLowerCase().endsWith(extension);
22
    }
23
     
24
    public String getDescription() {
25
        return description + String.format(" (*%s)", extension);
26
    }
27
}
0 28

  
trunk/org.gvsig.gdal/org.gvsig.gdal.app/org.gvsig.gdal.app.gpx/src/main/java/org/gvsig/gdal/app/gpx/gui/utils/JFileField.java
1
package org.gvsig.gdal.app.gpx.gui.utils;
2

  
3
import java.awt.Dimension;
4
import java.awt.FlowLayout;
5
import java.awt.Rectangle;
6
import java.awt.event.ActionEvent;
7
import java.awt.event.ActionListener;
8

  
9
import javax.swing.JButton;
10
import javax.swing.JFileChooser;
11
import javax.swing.JLabel;
12
import javax.swing.JPanel;
13
import javax.swing.JTextField;
14
 
15
public class JFileField extends JPanel {
16
    private String textFieldLabel;
17
    private String buttonLabel;
18
     
19
    private JLabel label;
20
    private JTextField textField;
21
    private JButton button;
22
     
23
    private JFileChooser fileChooser;
24
     
25
    private int mode;
26
    public static final int MODE_OPEN = 1;
27
    public static final int MODE_SAVE = 2;
28
     
29
    public JFileField(String textFieldLabel, String buttonLabel) {
30
        this.textFieldLabel = textFieldLabel;
31
        this.buttonLabel = buttonLabel;
32
         
33
        fileChooser = new JFileChooser();
34
         
35
        setLayout(new FlowLayout(FlowLayout.CENTER, 2, 0));
36
 
37
        if(textFieldLabel!=null){
38
        	label = new JLabel(textFieldLabel);
39
        	add(label);
40
        }
41
         
42
        textField = new JTextField(37);
43
        textField.setEditable(false);
44
        button = new JButton(buttonLabel);
45
        button.setPreferredSize(new Dimension(35, 22));
46
         
47
        button.addActionListener(new ActionListener() {
48
            public void actionPerformed(ActionEvent evt) {
49
                buttonActionPerformed(evt);            
50
            }
51
        });
52
         
53
        add(textField);
54
        add(button);
55
         
56
    }
57
     
58
    private void buttonActionPerformed(ActionEvent evt) {
59
        if (mode == MODE_OPEN) {
60
            if (fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
61
                textField.setText(fileChooser.getSelectedFile().getName());
62
            }
63
        } else if (mode == MODE_SAVE) {
64
            if (fileChooser.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {
65
                textField.setText(fileChooser.getSelectedFile().getName());
66
            }
67
        }
68
    }
69
 
70
    public void addFileTypeFilter(String extension, String description) {
71
        FileTypeFilter filter = new FileTypeFilter(extension, description);
72
        fileChooser.addChoosableFileFilter(filter);
73
    }
74
     
75
    public void setMode(int mode) {
76
        this.mode = mode;
77
    }
78
     
79
    public String getSelectedFilePath() {
80
        return textField.getText();
81
    }
82
     
83
    public JFileChooser getFileChooser() {
84
        return this.fileChooser;
85
    }
86
}
0 87

  
trunk/org.gvsig.gdal/org.gvsig.gdal.app/org.gvsig.gdal.app.gpx/src/main/java/org/gvsig/gdal/app/gpx/GPXClientExtension.java
33 33
	private Logger log = LoggerFactory.getLogger(GPXClientExtension.class);
34 34
	
35 35
	public void initialize() {
36

  
37
//		IconThemeHelper.registerIcon("icon", "icon-layer-osm", this);
36
//		IconThemeHelper.registerIcon(null, "icon-layer-osm", this);
38 37
	}
39 38

  
40 39
    /*
......
43 42
	 */
44 43
	public void postInitialize() {
45 44
//		addAboutInfo();
45
//		AddLayer.addWizard(OGRWizard.class);
46
//		
47
//		DataManagerProviderServices dataman = (DataManagerProviderServices) DALLocator
48
//				.getDataManager();
49
//		try {
50
//			if (!dataman.getStoreProviders().contains(OGRStoreProvider.NAME)) {
51
//				dataman.registerStoreProviderFactory(
52
//						new OGRStoreProviderFactory(
53
//								OGRStoreProvider.NAME, 
54
//								OGRStoreProvider.DESCRIPTION));
55
//			}
56
//		} catch (RuntimeException e) {
57
//			log.debug(e.getMessage());
58
//		}
59
//		
60
//		try {
61
//			DALFileLocator.getFilesystemServerExplorerManager()
62
//					.registerProvider(OGRStoreProvider.NAME,
63
//							OGRStoreProvider.DESCRIPTION,
64
//							OGRFilesystemServerProvider.class);
65
//		} catch (RuntimeException e) {
66
//			log.debug(e.getMessage());
67
//		}
68
		
46 69
	}
47 70
	
48
	
49 71
	public void execute(String actionCommand) {
50 72

  
51 73
	}
......
58 80
		return true;
59 81
	}
60 82
	
83
//	private void addAboutInfo() {
84
//        ApplicationManager application = ApplicationLocator.getManager();
85
//        
86
//        AboutManager about = application.getAbout();
87
//        about.addDeveloper("Nacho Brodin", getClass().getClassLoader()
88
//            .getResource("about/osm-about.html"), 2);
89
//
90
//        AboutParticipant participant = about.getDeveloper("Nacho Brodin");
91
//        participant.addContribution(
92
//            "OSM",
93
//            "Open Street Map client for gvSIG", 
94
//            2012,1,1, 
95
//            2012,1,15
96
//        );      
97
//    }
61 98
}
trunk/org.gvsig.gdal/org.gvsig.gdal.app/org.gvsig.gdal.app.gpx/pom.xml
13 13
	<dependencies>
14 14
	    <dependency>
15 15
            <groupId>org.gvsig</groupId>
16
            <artifactId>gdal</artifactId>
17
        </dependency>
18
	    <dependency>
19
            <groupId>org.gvsig</groupId>
16 20
            <artifactId>org.gvsig.gdal.gpx</artifactId>
17
            <scope>compile</scope>
18
          </dependency>
19
       <dependency>
20
		<groupId>org.gvsig</groupId>
21
		<artifactId>org.gvsig.tools.lib</artifactId>
22
		<scope>compile</scope>
23
	</dependency>
24
	<dependency>
25
		<groupId>org.gvsig</groupId>
26
		<artifactId>org.gvsig.andami</artifactId>
27
		<scope>compile</scope>
28
	</dependency>
21
        </dependency>
22
	    <dependency>
23
	        <groupId>org.gvsig</groupId>
24
	        <artifactId>org.gvsig.tools.lib</artifactId>
25
	        <scope>compile</scope>
26
	    </dependency>
27
	    <dependency>
28
	        <groupId>org.gvsig</groupId>
29
	        <artifactId>org.gvsig.andami</artifactId>
30
	        <scope>compile</scope>
31
	    </dependency>
32
	    <dependency>
33
	        <groupId>org.gvsig</groupId>
34
	        <artifactId>org.gvsig.app.mainplugin</artifactId>
35
	        <scope>compile</scope>
36
	    </dependency>
29 37
	</dependencies>
30 38
	<modules>
31 39
	</modules>
trunk/org.gvsig.gdal/org.gvsig.gdal.app/org.gvsig.gdal.app.mainplugin/org.gvsig.gdal.app.mainplugin.commons/pom.xml
11 11
		<version>1.0.0-SNAPSHOT</version>
12 12
	</parent>
13 13
	<dependencies>
14
	    <dependency>
15
			<groupId>org.gvsig</groupId>
16
			<artifactId>gdal</artifactId>
17
		</dependency>
14 18
	</dependencies>
15 19
	<modules>
16 20
		
trunk/org.gvsig.gdal/pom.xml
68 68
					<tagBase>https://devel.gvsig.org/svn/gvsig-gdal/org.gvsig.gdal/tags</tagBase>
69 69
				</configuration>
70 70
			</plugin>
71
            <plugin>
72
                <groupId>org.codehaus.mojo</groupId>
73
                <artifactId>exec-maven-plugin</artifactId>
74
                <inherited>false</inherited>
75
                <executions>
76
                    <execution>
77
                        <id>install-gdal</id>
78
                        <phase>validate</phase>
79
                        <goals>
80
                            <goal>exec</goal>
81
                        </goals>
82
                    </execution>
83
                </executions>
84
                <configuration>
85
                    <executable>mvn</executable>
86
                    <arguments>
87
                        <argument>install:install-file</argument>
88
                        <argument>-Dfile=${basedir}/lib/gdal-1.11.2.jar</argument>
89
                        <argument>-DgroupId=org.gvsig</argument>
90
                        <argument>-DartifactId=gdal</argument>
91
                        <argument>-Dversion=1.11.2</argument>
92
                        <argument>-Dpackaging=jar</argument>
93
                    </arguments>
94
                </configuration>
95
            </plugin>
71 96
		</plugins>
72 97
	</build>
73 98
  <dependencyManagement>
......
102 127
            <artifactId>org.gvsig.gdal.app.mainplugin.win.x86</artifactId>
103 128
            <version>1.0.0-SNAPSHOT</version>
104 129
          </dependency>
130
          <dependency>
131
			  <groupId>org.gvsig</groupId>
132
			  <artifactId>gdal</artifactId>
133
			  <version>1.11.2</version>
134
		</dependency>
105 135
	</dependencies>
106 136
	</dependencyManagement>
107 137
  <modules>
trunk/org.gvsig.gdal/lib/.settings/org.eclipse.jdt.core.prefs
1
eclipse.preferences.version=1
2
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
3
org.eclipse.jdt.core.compiler.compliance=1.5
4
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
5
org.eclipse.jdt.core.compiler.source=1.5
0 6

  
trunk/org.gvsig.gdal/lib/.settings/org.eclipse.m2e.core.prefs
1
activeProfiles=
2
eclipse.preferences.version=1
3
resolveWorkspaceProjects=true
4
version=1
0 5

  
trunk/org.gvsig.gdal/lib/.settings/org.eclipse.core.resources.prefs
1
eclipse.preferences.version=1
2
encoding/<project>=ISO-8859-1
0 3

  
trunk/org.gvsig.gdal/lib/.classpath
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
3
	<classpathentry kind="src" output="target/classes" path="src/main/java">
4
		<attributes>
5
			<attribute name="optional" value="true"/>
6
			<attribute name="maven.pomderived" value="true"/>
7
		</attributes>
8
	</classpathentry>
9
	<classpathentry kind="src" output="target/test-classes" path="src/test/java">
10
		<attributes>
11
			<attribute name="optional" value="true"/>
12
			<attribute name="maven.pomderived" value="true"/>
13
		</attributes>
14
	</classpathentry>
15
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
16
		<attributes>
17
			<attribute name="maven.pomderived" value="true"/>
18
		</attributes>
19
	</classpathentry>
20
	<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
21
		<attributes>
22
			<attribute name="maven.pomderived" value="true"/>
23
		</attributes>
24
	</classpathentry>
25
	<classpathentry kind="output" path="target/classes"/>
26
</classpath>
0 27

  
trunk/org.gvsig.gdal/lib/.project
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>org.gvsig.gdal.gpx</name>
4
	<comment></comment>
5
	<projects>
6
	</projects>
7
	<buildSpec>
8
		<buildCommand>
9
			<name>org.eclipse.jdt.core.javabuilder</name>
10
			<arguments>
11
			</arguments>
12
		</buildCommand>
13
		<buildCommand>
14
			<name>org.eclipse.m2e.core.maven2Builder</name>
15
			<arguments>
16
			</arguments>
17
		</buildCommand>
18
	</buildSpec>
19
	<natures>
20
		<nature>org.eclipse.jdt.core.javanature</nature>
21
		<nature>org.eclipse.m2e.core.maven2Nature</nature>
22
	</natures>
23
</projectDescription>
0 24

  
trunk/org.gvsig.gdal/org.gvsig.gdal.gpx/pom.xml
1 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" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
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/xsd/maven-4.0.0.xsd">
3 4

  
4 5
	<modelVersion>4.0.0</modelVersion>
5 6
	<artifactId>org.gvsig.gdal.gpx</artifactId>
......
11 12
		<version>1.0.0-SNAPSHOT</version>
12 13
	</parent>
13 14
	<dependencies>
15
	    <dependency>
16
		  <groupId>org.gvsig</groupId>
17
		  <artifactId>gdal</artifactId>
18
		</dependency>
19
		<dependency>
20
			<groupId>commons-io</groupId>
21
			<artifactId>commons-io</artifactId>
22
			<scope>compile</scope>
23
		</dependency>
24
		<dependency>
25
			<groupId>org.gvsig</groupId>
26
			<artifactId>org.gvsig.tools.lib</artifactId>
27
			<scope>compile</scope>
28
		</dependency>
29
		<dependency>
30
			<groupId>org.gvsig</groupId>
31
			<artifactId>org.gvsig.projection.api</artifactId>
32
			<scope>compile</scope>
33
		</dependency>
34
		<dependency>
35
			<groupId>org.gvsig</groupId>
36
			<artifactId>org.gvsig.fmap.dal.api</artifactId>
37
			<scope>compile</scope>
38
		</dependency>
39
		<dependency>
40
			<groupId>org.gvsig</groupId>
41
			<artifactId>org.gvsig.fmap.dal.spi</artifactId>
42
			<scope>compile</scope>
43
		</dependency>
44
		<dependency>
45
			<groupId>org.gvsig</groupId>
46
			<artifactId>org.gvsig.metadata.lib.basic.api</artifactId>
47
			<scope>compile</scope>
48
		</dependency>
49
		<dependency>
50
			<groupId>org.gvsig</groupId>
51
			<artifactId>org.gvsig.fmap.geometry.api</artifactId>
52
			<scope>compile</scope>
53
		</dependency>
54

  
55
		<dependency>
56
			<groupId>org.gvsig</groupId>
57
			<artifactId>org.gvsig.utils</artifactId>
58
			<scope>compile</scope>
59
		</dependency>
60
		<dependency>
61
			<groupId>org.gvsig</groupId>
62
			<artifactId>org.gvsig.fmap.dal.file.lib</artifactId>
63
			<scope>compile</scope>
64
		</dependency>
14 65
	</dependencies>
15 66
	<modules>
16
		
67

  
17 68
	</modules>
18 69
</project>
trunk/org.gvsig.gdal/org.gvsig.gdal.gpx/src/main/resources/org/gvsig/fmap/dal/store/gpx/OGRMetadata.xml
1
<?xml version="1.0"?>
2
<!--
3
Definitions of metadata fields of a shp file.  
4
 -->
5
<definitions>
6
  <version>1.0.0</version>
7
  <classes>
8
    
9
    <class name="OGR_DRIVER" namespace="Metadata">
10
      <extends>
11
      	<class namespace="Metadata" name="SpatialProvider"/>
12
      </extends>
13
      <description>Metadata of a OGR store</description>
14
      <fields>
15
      </fields>
16
    </class>
17

  
18
  </classes>
19
</definitions>  
0 20

  
trunk/org.gvsig.gdal/org.gvsig.gdal.gpx/src/main/resources/org/gvsig/fmap/dal/store/gpx/OGRParameters.xml
1
<?xml version= "1.0 "?>
2
<definitions>
3
  <version>1.0.0</version>
4
  <classes>
5
    <class name="OGRStoreParameters">
6
       <extends>
7
      	<class namespace="dal" name="ProviderParameters"/>
8
      </extends>
9
      <description>Store the parameters need to open a OGR file</description>
10
      <fields>
11
        <field name="File" type="file" mandatory="true" group="Basic">
12
          <description>Driver file</description>
13
        </field>
14
        <field name="Driver" type="string" mandatory="false" defaultValue="" group="Basic">
15
          <description>Sets the driver needed to open.</description>
16
        </field>
17
      </fields>
18
    </class>
19
  </classes>
20
</definitions>  
0 21

  
trunk/org.gvsig.gdal/org.gvsig.gdal.gpx/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.fmap.dal.store.gpx.OGRLibrary
trunk/org.gvsig.gdal/org.gvsig.gdal.gpx/src/main/java/org/gvsig/fmap/dal/store/gpx/OGRLibrary.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

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2009 {Iver T.I.}   {Task}
26
*/
27
 
28
package org.gvsig.fmap.dal.store.gpx;
29

  
30
import java.util.ArrayList;
31
import java.util.List;
32

  
33
import org.gvsig.fmap.dal.DALFileLibrary;
34
import org.gvsig.fmap.dal.DALFileLocator;
35
import org.gvsig.fmap.dal.DALLibrary;
36
import org.gvsig.fmap.dal.DALLocator;
37
import org.gvsig.fmap.dal.FileHelper;
38
import org.gvsig.fmap.dal.spi.DataManagerProviderServices;
39
import org.gvsig.metadata.MetadataLibrary;
40
import org.gvsig.metadata.exceptions.MetadataException;
41
import org.gvsig.tools.ToolsLocator;
42
import org.gvsig.tools.dynobject.DynClass;
43
import org.gvsig.tools.dynobject.DynField;
44
import org.gvsig.tools.dynobject.DynObjectManager;
45
import org.gvsig.tools.library.AbstractLibrary;
46
import org.gvsig.tools.library.LibraryException;
47
import org.slf4j.Logger;
48
import org.slf4j.LoggerFactory;
49

  
50
public class OGRLibrary extends AbstractLibrary {
51

  
52
	private static final Logger logger = LoggerFactory.getLogger(OGRLibrary.class);
53
   
54
	@Override
55
    public void doRegistration() {
56
        registerAsImplementationOf(OGRLibrary.class);
57
        require(DALLibrary.class);
58
        require(DALFileLibrary.class);
59
        require(MetadataLibrary.class);
60
    }
61

  
62
	@Override
63
	protected void doInitialize() throws LibraryException {
64
	}
65

  
66
	@Override
67
	protected void doPostInitialize() throws LibraryException {
68
		List<Throwable> exs = new ArrayList<Throwable>();
69
		
70
		FileHelper.registerParametersDefinition(
71
				OGRStoreParameters.PARAMETERS_DEFINITION_NAME, 
72
				OGRStoreParameters.class,
73
				"OGRParameters.xml"
74
		);
75
		try {
76
			FileHelper.registerMetadataDefinition(
77
					OGRStoreProvider.METADATA_DEFINITION_NAME, 
78
					OGRStoreProvider.class,
79
					"OGRMetadata.xml"
80
			);
81
		} catch (MetadataException e) {
82
			throw new LibraryException(getClass(), e);
83
		}
84

  
85
		DataManagerProviderServices dataman = (DataManagerProviderServices) DALLocator
86
				.getDataManager();
87
		try {
88
			if (!dataman.getStoreProviders().contains(OGRStoreProvider.NAME)) {
89
				dataman.registerStoreProviderFactory(new OGRStoreProviderFactory(OGRStoreProvider.NAME, OGRStoreProvider.DESCRIPTION));
90
			}
91
		} catch (RuntimeException e) {
92
			exs.add(e);
93
		}
94

  
95

  
96
		DALFileLocator.getFilesystemServerExplorerManager().registerProvider(
97
				OGRStoreProvider.NAME, OGRStoreProvider.DESCRIPTION,
98
				OGRFilesystemServerProvider.class);
99

  
100
		DynObjectManager dynMan = ToolsLocator.getDynObjectManager();
101
		DynClass dynClass = dynMan.get(
102
				OGRStoreProvider.METADATA_DEFINITION_NAME);
103
		DynField field;
104
		if (dynClass == null) {
105
			dynClass = dynMan.add(
106
					OGRStoreProvider.METADATA_DEFINITION_NAME);
107

  
108
		}
109
		
110
		if (exs.size() > 0) {
111
			throw new LibraryException(this.getClass(), exs);
112
		}
113
	}
114
}
115

  
116

  
117

  
0 118

  
trunk/org.gvsig.gdal/org.gvsig.gdal.gpx/src/main/java/org/gvsig/fmap/dal/store/gpx/OGRFilesystemServerProvider.java
1
package org.gvsig.fmap.dal.store.gpx;
2

  
3
import java.io.File;
4

  
5
import org.gvsig.fmap.dal.DALLocator;
6
import org.gvsig.fmap.dal.DataManager;
7
import org.gvsig.fmap.dal.DataServerExplorer;
8
import org.gvsig.fmap.dal.DataStoreParameters;
9
import org.gvsig.fmap.dal.NewDataStoreParameters;
10
import org.gvsig.fmap.dal.exception.CreateException;
11
import org.gvsig.fmap.dal.exception.DataException;
12
import org.gvsig.fmap.dal.exception.FileNotFoundException;
13
import org.gvsig.fmap.dal.exception.RemoveException;
14
import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters;
15
import org.gvsig.fmap.dal.resource.spi.ResourceConsumer;
16
import org.gvsig.fmap.dal.resource.spi.ResourceProvider;
17
import org.gvsig.fmap.dal.serverexplorer.filesystem.impl.AbstractFilesystemServerExplorerProvider;
18
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProvider;
19
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProviderServices;
20

  
21
public class OGRFilesystemServerProvider extends AbstractFilesystemServerExplorerProvider 
22
	implements FilesystemServerExplorerProvider, ResourceConsumer {
23

  
24
	//private FilesystemServerExplorerProviderServices serverExplorer;
25

  
26
	public String getDataStoreProviderName() {
27
		return OGRStoreProvider.NAME;
28
	}
29

  
30
	public int getMode() {
31
		return DataServerExplorer.MODE_FEATURE | DataServerExplorer.MODE_GEOMETRY;
32
	}
33

  
34
	public boolean accept(File pathname) {
35
		return (pathname.getName().toLowerCase().endsWith(".gpx"));
36
		//return true;
37
	}
38

  
39
	public String getDescription() {
40
		return OGRStoreProvider.DESCRIPTION;
41
	}
42

  
43
	public DataStoreParameters getParameters(File file) throws DataException {
44
		DataManager manager = DALLocator.getDataManager();
45
		OGRStoreParameters params = (OGRStoreParameters) manager
46
				.createStoreParameters(this
47
				.getDataStoreProviderName());
48
		params.setFileName(file.getPath());
49
		return params;
50
	}
51

  
52
	public boolean canCreate() {
53
		return true;
54
	}
55

  
56
	public boolean canCreate(NewDataStoreParameters parameters) {
57
		if (!(parameters instanceof OGRStoreParameters)) {
58
			throw new IllegalArgumentException(); // FIXME ???
59
		}
60
		OGRStoreParameters driverParams = (OGRStoreParameters) parameters;
61
		// TODO comporbar si el ftype es correcto (para este formato es fijo)
62
		File file = new File(driverParams.getFileName());
63

  
64
		if (driverParams.getCRS() == null) {
65
			return false;
66
		}
67
		// TODO comprobamos extension del fichero ??
68
		if (file.exists()) {
69
			return file.canWrite();
70
		} else {
71
			return file.getParentFile().canWrite();
72
		}
73
	}
74

  
75
	public void create(NewDataStoreParameters parameters, boolean overwrite)
76
			throws CreateException {
77
		// FIXME Exception
78
		throw new UnsupportedOperationException();
79
	}
80

  
81
	public NewDataStoreParameters getCreateParameters() throws DataException {
82
		return (NewFeatureStoreParameters) DALLocator.getDataManager()
83
				.createStoreParameters(this.getDataStoreProviderName());
84
	}
85

  
86
	public void initialize(
87
			FilesystemServerExplorerProviderServices serverExplorer) {
88
		//this.serverExplorer = serverExplorer;
89
	}
90

  
91
	public void remove(DataStoreParameters parameters) throws RemoveException {
92
		File file = new File(((OGRStoreParameters) parameters).getFileName());
93
		if (!file.exists()) {
94
			throw new RemoveException(this.getDataStoreProviderName(),
95
					new FileNotFoundException(file));
96
		}
97
		if (!file.delete()) {
98
			// FIXME throws ???
99
		}
100

  
101
	}
102

  
103
	public boolean closeResourceRequested(ResourceProvider resource) {
104
		// while it is using a resource anyone can't close it
105
		return false;
106
	}
107

  
108
	/*
109
	 * (non-Javadoc)
110
	 *
111
	 * @see
112
	 * org.gvsig.fmap.dal.resource.spi.ResourceConsumer#resourceChanged(org.
113
	 * gvsig.fmap.dal.resource.spi.ResourceProvider)
114
	 */
115
	public void resourceChanged(ResourceProvider resource) {
116
		//Do nothing
117

  
118
	}
119

  
120

  
121
}
0 122

  
trunk/org.gvsig.gdal/org.gvsig.gdal.gpx/src/main/java/org/gvsig/fmap/dal/store/gpx/OGRStoreProvider.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.fmap.dal.store.gpx;
25

  
26
import java.io.File;
27
import java.io.IOException;
28
import java.util.ArrayList;
29
import java.util.HashMap;
30
import java.util.List;
31

  
32
import org.apache.commons.io.FilenameUtils;
33
import org.apache.commons.lang3.StringUtils;
34
import org.gdal.gdal.gdal;
35
import org.gdal.ogr.DataSource;
36
import org.gdal.ogr.Driver;
37
import org.gdal.ogr.FeatureDefn;
38
import org.gdal.ogr.Layer;
39
import org.gdal.ogr.ogr;
40
import org.gvsig.fmap.dal.DALLocator;
41
import org.gvsig.fmap.dal.DataManager;
42
import org.gvsig.fmap.dal.DataServerExplorer;
43
import org.gvsig.fmap.dal.DataStoreNotification;
44
import org.gvsig.fmap.dal.DataTypes;
45
import org.gvsig.fmap.dal.FileHelper;
46
import org.gvsig.fmap.dal.exception.DataException;
47
import org.gvsig.fmap.dal.exception.InitializeException;
48
import org.gvsig.fmap.dal.exception.OpenException;
49
import org.gvsig.fmap.dal.exception.ReadException;
50
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
51
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor;
52
import org.gvsig.fmap.dal.feature.EditableFeatureType;
53
import org.gvsig.fmap.dal.feature.Feature;
54
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
55
import org.gvsig.fmap.dal.feature.FeatureStore;
56
import org.gvsig.fmap.dal.feature.FeatureType;
57
import org.gvsig.fmap.dal.feature.spi.FeatureProvider;
58
import org.gvsig.fmap.dal.feature.spi.FeatureStoreProviderServices;
59
import org.gvsig.fmap.dal.feature.spi.memory.AbstractMemoryStoreProvider;
60
import org.gvsig.fmap.dal.resource.file.FileResource;
61
import org.gvsig.fmap.dal.resource.spi.ResourceConsumer;
62
import org.gvsig.fmap.dal.resource.spi.ResourceProvider;
63
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer;
64
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorerParameters;
65
import org.gvsig.fmap.dal.spi.DataStoreProviderServices;
66
import org.gvsig.fmap.geom.Geometry;
67
import org.gvsig.fmap.geom.GeometryException;
68
import org.gvsig.fmap.geom.GeometryLocator;
69
import org.gvsig.fmap.geom.GeometryManager;
70
import org.gvsig.fmap.geom.exception.CreateGeometryException;
71
import org.gvsig.fmap.geom.primitive.Envelope;
72
import org.gvsig.fmap.geom.type.GeometryType;
73
import org.gvsig.tools.ToolsLocator;
74
import org.gvsig.tools.dataTypes.CoercionException;
75
import org.gvsig.tools.dataTypes.DataTypesManager;
76
import org.gvsig.tools.dynobject.exception.DynFieldNotFoundException;
77
import org.gvsig.tools.exception.BaseException;
78
import org.gvsig.tools.exception.NotYetImplemented;
79
import org.gvsig.tools.locator.LocatorException;
80
import org.gvsig.tools.persistence.PersistentState;
81
import org.gvsig.tools.persistence.exception.PersistenceException;
82
import org.gvsig.tools.task.SimpleTaskStatus;
83
import org.gvsig.tools.task.TaskStatusManager;
84
import org.gvsig.tools.visitor.VisitCanceledException;
85
import org.gvsig.tools.visitor.Visitor;
86
import org.slf4j.Logger;
87
import org.slf4j.LoggerFactory;
88

  
89

  
90
public class OGRStoreProvider extends AbstractMemoryStoreProvider implements
91
ResourceConsumer {
92
    private static final Logger logger = LoggerFactory.getLogger(OGRStoreProvider.class);
93

  
94
    public static final String NAME = "OGR_DRIVER";
95
    public static final String DESCRIPTION = "Driver file";
96

  
97
    public static final String METADATA_DEFINITION_NAME = NAME;
98

  
99
    private ResourceProvider resource;
100

  
101
    private long counterNewsOIDs = 0;
102
    private Envelope envelope;
103
    private boolean need_calculate_envelope = false;
104
    private SimpleTaskStatus taskStatus;
105

  
106

  
107
    public OGRStoreProvider(OGRStoreParameters parameters,
108
        DataStoreProviderServices storeServices) throws InitializeException {
109
        super(
110
            parameters, 
111
            storeServices,
112
            FileHelper.newMetadataContainer(METADATA_DEFINITION_NAME)
113
        );
114
        
115
        gdal.AllRegister();
116
		ogr.RegisterAll();
117

  
118
        TaskStatusManager manager = ToolsLocator.getTaskStatusManager();
119
        this.taskStatus = manager.createDefaultSimpleTaskStatus("Driver");
120

  
121
        counterNewsOIDs = 0;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff