Revision 38273

View differences:

tags/v2_0_0_Build_2047/extensions/extGPE-gvSIG/distribution/distribution.xml
1
<assembly>
2
  <id>distribution</id>
3
  <formats>
4
    <format>dir</format>
5
  </formats>
6
  <fileSets>
7
    <fileSet>
8
      <directory>config</directory>
9
	  <outputDirectory>${extension.install.dir.name}</outputDirectory>
10
    </fileSet>
11
	<fileSet>
12
      <directory>images</directory>
13
	  <outputDirectory>/${extension.install.dir.name}/images</outputDirectory>
14
    </fileSet>
15
  </fileSets>
16
  <files>
17
    <file>
18
      <source>package.info</source>
19
      <outputDirectory>${extension.install.dir.name}</outputDirectory>
20
    </file>
21
  </files>
22
  	<dependencySets>
23
  		<dependencySet>
24
			<useProjectArtifact>false</useProjectArtifact>
25
			<useProjectAttachments>true</useProjectAttachments>
26
  			<outputDirectory>${extension.install.dir.name}/${library-dir}
27
        	</outputDirectory>
28
          	 <includes>        	
29
                <include>org.gvsig:org.gvsig.gpe.extension:jar:gui</include>
30
                <include>org.gvsig:org.gvsig.gpe.extension:jar:store</include>
31
        		<include>org.gvsig:org.gvsig.gpe.lib**</include>
32
                <include>org.gvsig:org.gvsig.gpe.prov**</include>
33
        		<include>org.gvsig:org.gvsig.xmlpull**</include>
34
        		<include>org.gvsig:org.gvsig.xmlschema**</include>
35
        		<include>stax:stax</include>
36
        	</includes>
37
  		</dependencySet>  		
38
	</dependencySets>
39
</assembly>
40

  
0 41

  
tags/v2_0_0_Build_2047/extensions/extGPE-gvSIG/buildNumber.properties
1
#maven.buildNumber.plugin properties file
2
#Tue May 29 16:39:14 CEST 2012
3
buildNumber=2047
tags/v2_0_0_Build_2047/extensions/extGPE-gvSIG/src-test/org/gvsig/fmap/geom/operation/writegml2/WriteGmlTest.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.fmap.geom.operation.writegml2;
23

  
24
import java.io.ByteArrayOutputStream;
25
import java.io.IOException;
26
import java.io.OutputStream;
27

  
28
import org.slf4j.Logger;
29
import org.slf4j.LoggerFactory;
30

  
31
import org.gvsig.fmap.geom.Geometry;
32
import org.gvsig.fmap.geom.Geometry.SUBTYPES;
33
import org.gvsig.fmap.geom.Geometry.TYPES;
34
import org.gvsig.fmap.geom.GeometryLocator;
35
import org.gvsig.fmap.geom.GeometryManager;
36
import org.gvsig.fmap.geom.aggregate.MultiCurve;
37
import org.gvsig.fmap.geom.aggregate.MultiPoint;
38
import org.gvsig.fmap.geom.aggregate.MultiSurface;
39
import org.gvsig.fmap.geom.exception.CreateGeometryException;
40
import org.gvsig.fmap.geom.operation.GeometryOperationException;
41
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException;
42
import org.gvsig.fmap.geom.primitive.Curve;
43
import org.gvsig.fmap.geom.primitive.GeneralPathX;
44
import org.gvsig.fmap.geom.primitive.Point;
45
import org.gvsig.fmap.geom.primitive.Surface;
46
import org.gvsig.gpe.lib.api.GPELocator;
47
import org.gvsig.gpe.lib.api.GPEManager;
48
import org.gvsig.gpe.lib.api.exceptions.WriterHandlerCreationException;
49
import org.gvsig.gpe.lib.api.writer.IGPEWriterHandler;
50
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase;
51

  
52

  
53
/**
54
 * @author gvSIG Team
55
 * @version $Id$
56
 *
57
 */
58
public class WriteGmlTest extends AbstractLibraryAutoInitTestCase{
59
    private static final Logger LOG = LoggerFactory.getLogger(WriteGmlTest.class);
60
    private GeometryManager geometryManager;
61
    private GPEManager gpeManager;
62
    
63
    protected void doSetUp() throws Exception {
64
        geometryManager = GeometryLocator.getGeometryManager();   
65
        gpeManager = GPELocator.getGPEManager();
66
    }
67
    
68
    private String write(Geometry geometry) throws WriterHandlerCreationException, GeometryOperationNotSupportedException, GeometryOperationException{      
69
        OutputStream os = new ByteArrayOutputStream();   
70
        IGPEWriterHandler writerHandler = gpeManager.createWriterByMimeType("text/xml; subtype=gml/3.1.2");  
71
        writerHandler.setOutputStream(os);
72
        writerHandler.initialize(); 
73
               
74
        WriteGml2OperationContext operationContext = new WriteGml2OperationContext();
75
        operationContext.setWriterHandler(writerHandler);
76
        operationContext.setId("0");
77
        operationContext.setSrs("EPSG:23030");
78
        
79
        geometry.invokeOperation(WriteGml2Operation.NAME, operationContext);
80
   
81
        writerHandler.close();
82

  
83
        LOG.info("Parsed geometry: " + os.toString());
84
        assertTrue(os.toString().startsWith("<?xml"));
85
        return os.toString();
86
    }
87
    
88
    public void testPoint2D() throws CreateGeometryException, WriterHandlerCreationException, GeometryOperationNotSupportedException, GeometryOperationException, IOException{
89
        Point point = (Point)geometryManager.create(TYPES.POINT, SUBTYPES.GEOM2D);
90
        point.setCoordinateAt(0, 1.0);
91
        point.setCoordinateAt(1, 2.0);
92
        
93
        write(point);        
94
    }    
95
    
96
    public void testCurve2D() throws CreateGeometryException, WriterHandlerCreationException, GeometryOperationNotSupportedException, GeometryOperationException, IOException{
97
        Curve curve = (Curve)geometryManager.create(TYPES.CURVE, SUBTYPES.GEOM2D);
98
        GeneralPathX generalPathX = new GeneralPathX();
99
        generalPathX.moveTo(0, 0);
100
        generalPathX.lineTo(1, 1);
101
        generalPathX.lineTo(2, 1);      
102
        curve.setGeneralPath(generalPathX); 
103
        
104
        write(curve);
105
    }  
106
    
107
    public void testSurface2D() throws CreateGeometryException, WriterHandlerCreationException, GeometryOperationNotSupportedException, GeometryOperationException, IOException{
108
        Surface surface = (Surface)geometryManager.create(TYPES.SURFACE, SUBTYPES.GEOM2D);
109
        GeneralPathX generalPathX = new GeneralPathX();
110
        generalPathX.moveTo(0, 0);
111
        generalPathX.lineTo(1, 1);
112
        generalPathX.lineTo(2, 1);
113
        surface.setGeneralPath(generalPathX);   
114
        
115
        write(surface);
116
    } 
117
    
118
    public void testMultiPoint2D() throws CreateGeometryException, WriterHandlerCreationException, GeometryOperationNotSupportedException, GeometryOperationException, IOException{
119
        Point point1 = (Point)geometryManager.create(TYPES.POINT, SUBTYPES.GEOM3D);
120
        point1.setCoordinateAt(0, 1.0);
121
        point1.setCoordinateAt(1, 2.0);
122
        point1.setCoordinateAt(2, 3.0);
123
        
124
        Point point2 = (Point)geometryManager.create(TYPES.POINT, SUBTYPES.GEOM3D);
125
        point2.setCoordinateAt(0, 4.0);
126
        point2.setCoordinateAt(1, 5.0);
127
        point2.setCoordinateAt(2, 6.0);
128
        
129
        MultiPoint multiPoint = (MultiPoint)geometryManager.create(TYPES.MULTIPOINT, SUBTYPES.GEOM2D);
130
        multiPoint.addPoint(point1);
131
        multiPoint.addPoint(point2);
132
        
133
        write(multiPoint);        
134
    }    
135
    
136
    public void testMultiCurve2D() throws CreateGeometryException, WriterHandlerCreationException, GeometryOperationNotSupportedException, GeometryOperationException, IOException{
137
        Curve curve1 = (Curve)geometryManager.create(TYPES.CURVE, SUBTYPES.GEOM2D);
138
        GeneralPathX generalPathX1 = new GeneralPathX();
139
        generalPathX1.moveTo(0, 0);
140
        generalPathX1.lineTo(1, 1);
141
        generalPathX1.lineTo(2, 1);     
142
        curve1.setGeneralPath(generalPathX1);   
143
        
144
        Curve curve2 = (Curve)geometryManager.create(TYPES.CURVE, SUBTYPES.GEOM2D);
145
        GeneralPathX generalPathX2 = new GeneralPathX();
146
        generalPathX2.moveTo(0, 0);
147
        generalPathX2.lineTo(1, 1);
148
        generalPathX2.lineTo(2, 1);     
149
        curve2.setGeneralPath(generalPathX2);   
150
        
151
        MultiCurve multiCurve = (MultiCurve)geometryManager.create(TYPES.MULTICURVE, SUBTYPES.GEOM2D);
152
        multiCurve.addCurve(curve1);
153
        multiCurve.addCurve(curve2);
154
        
155
        write(multiCurve);
156
    }  
157
    
158
    public void testMultiSurface2D() throws CreateGeometryException, WriterHandlerCreationException, GeometryOperationNotSupportedException, GeometryOperationException, IOException{
159
        Surface surface1 = (Surface)geometryManager.create(TYPES.SURFACE, SUBTYPES.GEOM2D);
160
        GeneralPathX generalPathX1 = new GeneralPathX();
161
        generalPathX1.moveTo(0, 0);
162
        generalPathX1.lineTo(1, 1);
163
        generalPathX1.lineTo(2, 1);     
164
        surface1.setGeneralPath(generalPathX1); 
165
        
166
        Surface surface2 = (Surface)geometryManager.create(TYPES.SURFACE, SUBTYPES.GEOM2D);     
167
        GeneralPathX generalPathX2 = new GeneralPathX();
168
        generalPathX2.moveTo(0, 0);
169
        generalPathX2.lineTo(1, 1);
170
        generalPathX2.lineTo(2, 1);     
171
        surface2.setGeneralPath(generalPathX2); 
172
        
173
        MultiSurface multiSurface = (MultiSurface)geometryManager.create(TYPES.MULTISURFACE, SUBTYPES.GEOM2D);
174
        multiSurface.addSurface(surface1);
175
        multiSurface.addSurface(surface2); 
176
        
177
        write(multiSurface);
178
    } 
179
    
180
}
0 181

  
tags/v2_0_0_Build_2047/extensions/extGPE-gvSIG/src-test/org/gvsig/fmap/dal/store/gpe/GPETest.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.gpe;
29

  
30
import java.io.File;
31

  
32
import org.gvsig.fmap.crs.CRSFactory;
33
import org.gvsig.fmap.dal.DataStoreParameters;
34
import org.gvsig.fmap.dal.exception.DataException;
35
import org.gvsig.fmap.dal.feature.BaseTestEditableFeatureStore;
36
import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters;
37
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer;
38
import org.gvsig.gpe.lib.api.GPELocator;
39
import org.gvsig.gpe.lib.api.GPEManager;
40

  
41
/**
42
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
43
 */
44
public class GPETest extends BaseTestEditableFeatureStore {
45
	public static final File file_prueba = new File("testdata/GML-points.gml");
46

  
47
	private FilesystemServerExplorer myExplorer = null;
48
	private GPEManager gpeManager = null;
49

  
50
	protected void doSetUp() throws Exception {
51
		super.doSetUp();
52
		gpeManager = GPELocator.getGPEManager();
53
	}
54

  
55
	/*
56
	 * (non-Javadoc)
57
	 *
58
	 * @see
59
	 * org.gvsig.fmap.dal.feature.BaseTestFeatureStore#getDefaultDataStoreParameters
60
	 * ()
61
	 */
62
	public DataStoreParameters getDefaultDataStoreParameters()
63
	throws DataException {
64
		GPEStoreParameters parameters = null;
65

  
66
		parameters = (GPEStoreParameters) dataManager
67
		.createStoreParameters(GPEStoreProvider.NAME);
68

  
69
		parameters.setFileName(file_prueba.getAbsolutePath());
70
		parameters.setCRS(CRSFactory.getCRS("EPSG:23030"));
71
		return parameters;
72
	}
73

  
74
	/*
75
	 * (non-Javadoc)
76
	 *
77
	 * @see org.gvsig.fmap.dal.feature.BaseTestFeatureStore#hasExplorer()
78
	 */
79
	public boolean hasExplorer() {
80
		return false;
81
	}
82

  
83
	/* (non-Javadoc)
84
	 * @see org.gvsig.fmap.dal.feature.BaseTestEditableFeatureStore#getDefaultNewDataStoreParameters()
85
	 */
86
	public NewFeatureStoreParameters getDefaultNewDataStoreParameters()
87
	throws Exception {
88
		return null;
89
//		if (this.myExplorer == null) {
90
//			GPEStoreParameters gpeStoreParameters = (GPEStoreParameters) this
91
//			.getDefaultDataStoreParameters();
92
//			FeatureStore store = (FeatureStore) dataManager
93
//			.createStore(gpeStoreParameters);
94
//			myExplorer = (FilesystemServerExplorer) store.getExplorer();
95
//			store.dispose();
96
//		}
97
//
98
//		return (NewFeatureStoreParameters) myExplorer
99
//		.getAddParameters(dbf_prueba_destino);
100
	}
101

  
102
	/* (non-Javadoc)
103
	 * @see org.gvsig.fmap.dal.feature.BaseTestEditableFeatureStore#usesResources()
104
	 */
105
	public boolean usesResources() {
106
		// TODO Auto-generated method stub
107
		return false;
108
	}
109

  
110
	public boolean resourcesNotifyChanges() {
111
		return true;
112
	}
113

  
114

  
115
}
116

  
0 117

  
tags/v2_0_0_Build_2047/extensions/extGPE-gvSIG/src-test/org/gvsig/fmap/dal/store/gpe/GPEMobileTest.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.gpe;
29

  
30
import java.io.File;
31
import java.util.Iterator;
32

  
33
import junit.framework.TestCase;
34

  
35
import org.gvsig.compat.se.SECompatLibrary;
36
import org.gvsig.fmap.dal.DALFileLibrary;
37
import org.gvsig.fmap.dal.DALLibrary;
38
import org.gvsig.fmap.dal.DALLocator;
39
import org.gvsig.fmap.dal.DataManager;
40
import org.gvsig.fmap.dal.DataStoreParameters;
41
import org.gvsig.fmap.dal.exception.DataException;
42
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
43
import org.gvsig.fmap.dal.feature.Feature;
44
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
45
import org.gvsig.fmap.dal.feature.FeatureSet;
46
import org.gvsig.fmap.dal.feature.FeatureStore;
47
import org.gvsig.fmap.dal.feature.FeatureType;
48
import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters;
49
import org.gvsig.fmap.dal.impl.DALDefaultImplLibrary;
50
import org.gvsig.fmap.dal.impl.DefaultDataManager;
51
import org.gvsig.fmap.dal.index.spatial.jts.JTSIndexLibrary;
52
import org.gvsig.fmap.dal.resource.impl.DefaultResourceManager;
53
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer;
54
import org.gvsig.fmap.geom.Geometry;
55
import org.gvsig.fmap.geom.impl.DefaultGeometryLibrary;
56
import org.gvsig.fmap.geom.primitive.Envelope;
57
import org.gvsig.gpe.lib.api.GPELocator;
58
import org.gvsig.gpe.lib.api.GPEManager;
59
import org.gvsig.tools.ToolsLibrary;
60
import org.gvsig.tools.persistence.xml.XMLPersistenceLibrary;
61

  
62
/**
63
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
64
 */
65
public class GPEMobileTest extends TestCase{
66
	public static final File file_prueba = new File("testdata/GML-points.gml");
67

  
68
	private FilesystemServerExplorer myExplorer = null;
69
	private GPEManager gpeManager = null;
70

  
71
	private boolean baseTestInitialized=false;
72

  
73
	private DataManager dataManager;
74

  
75
	private FeatureStore store;
76

  
77
	public void setUp(){
78
		DALLocator.registerDataManager(DefaultDataManager.class);
79
		DALLocator.registerResourceManager(DefaultResourceManager.class);
80
		if (baseTestInitialized) {
81
			return;
82
		}
83
		
84
		ToolsLibrary tools = new ToolsLibrary();
85
		tools.initialize();
86
		tools.postInitialize();
87

  
88
		XMLPersistenceLibrary xmlPersistence = new XMLPersistenceLibrary();
89
		xmlPersistence.initialize();
90
		xmlPersistence.postInitialize();
91

  
92
		DALLocator.registerDataManager(DefaultDataManager.class);
93
		DALLocator.registerResourceManager(DefaultResourceManager.class);
94
		
95
		DALLibrary lib = new DALLibrary();
96
		lib.initialize();
97
		lib.postInitialize();
98

  
99
		DALDefaultImplLibrary libImpl = new DALDefaultImplLibrary();
100
		libImpl.initialize();
101
		libImpl.postInitialize();		
102

  
103
		DALFileLibrary libFile = new DALFileLibrary();
104
		libFile.initialize();
105
		libFile.postInitialize();
106

  
107
		DefaultGeometryLibrary defGeomLib = new DefaultGeometryLibrary();
108
		defGeomLib.initialize();
109
		defGeomLib.postInitialize();
110

  
111
		JTSIndexLibrary jtsIndex = new JTSIndexLibrary();
112
		jtsIndex.initialize();
113
		jtsIndex.postInitialize();
114
		
115
//		DefaultGPEDataTypesLibrary gpeDataTypesLibrary = new DefaultGPEDataTypesLibrary();
116
//		gpeDataTypesLibrary.initialize();
117
//		gpeDataTypesLibrary.postInitialize();
118
		 
119
		DALGPELibrary gpeLibrary = new DALGPELibrary();
120
		gpeLibrary.initialize();
121
		gpeLibrary.postInitialize();
122
		
123
//		DefaultGPELibrary defaultGPElibrary = new DefaultGPELibrary();
124
//		defaultGPElibrary.initialize();
125
//		defaultGPElibrary.postInitialize();		
126
//		
127
		
128
//		DefaultXmlLibrary defaultXmllibrary = new DefaultXmlLibrary();
129
//		defaultXmllibrary.initialize();
130
//		defaultXmllibrary.postInitialize();
131
		
132
//		DefaultKmlLibrary kmlLibrary = new DefaultKmlLibrary();
133
//		kmlLibrary.initialize();
134
//		kmlLibrary.postInitialize();
135
		
136
//		DefaultGmlLibrary gmlLibrary = new DefaultGmlLibrary();
137
//		gmlLibrary.initialize();
138
//		gmlLibrary.postInitialize();	
139
		
140
		SECompatLibrary compatLibrary = new SECompatLibrary();
141
		compatLibrary.initialize();
142
		compatLibrary.postInitialize();
143

  
144
		gpeManager = GPELocator.getGPEManager();
145
		
146
		dataManager = DALLocator.getDataManager();
147
		
148
		baseTestInitialized = true;
149
	}
150

  
151

  
152
	public void testGetDataStore(){
153
		try {
154
			DataStoreParameters params = this.getDefaultDataStoreParameters();
155
			store = (FeatureStore)dataManager.createStore(params);			
156
			//gpestore.setParserName("GML");
157
			
158
			FeatureSet set;
159
			// FeatureType type = store.getDefaultFeatureType();
160
			
161
			set = store.getFeatureSet();
162

  
163
			System.out.println("Feature count: " + set.getSize());
164
			Iterator it = set.iterator();
165
			// Iterator ftIt;
166
			// FeatureAttributeDescriptor desc;
167

  
168
			int i = 0;
169
			Feature feature;
170
			while (it.hasNext()) {
171
				// ftIt = type.iterator();
172

  
173
				System.out.println("=====================================");
174
				System.out.println("Feature " + i + ": ");
175
				System.out.println("-------------------------------------");
176
				feature = (Feature) it.next();
177
				Geometry geom = (Geometry) feature.getDefaultGeometry(); // .getGeometries().get(0);
178
				
179
				FeatureType ft = feature.getType();
180
				FeatureAttributeDescriptor[] atts = ft.getAttributeDescriptors();
181
				int len = atts.length;
182
				FeatureAttributeDescriptor att;
183
				for (int j=0; j<len; j++) {
184
					att = ft.getAttributeDescriptor(j);
185
					System.out.println("ATT: " + att.getName() + "; VAL = " + feature.get(j).toString());
186
				}
187
				System.out.println("-------------------------------------");
188
				Envelope env = geom.getEnvelope();
189
				System.out.println("GEOM BB: "
190
						+ env.getMinimum(0)
191
						+ ", " + env.getMinimum(1)
192
						+ ", " + env.getMaximum(0)
193
						+ ", " + env.getMaximum(1));
194
				System.out.println("=====================================");
195
				i++;
196
			}
197
			set.dispose();
198
			store.dispose();
199
		} catch (DataException e) {
200
			// TODO Auto-generated catch block
201
			e.printStackTrace();
202
		} catch (ValidateDataParametersException e) {
203
			// TODO Auto-generated catch block
204
			e.printStackTrace();
205
		}
206
	}
207

  
208
	/*
209
	 * (non-Javadoc)
210
	 *
211
	 * @see
212
	 * org.gvsig.fmap.dal.feature.BaseTestFeatureStore#getDefaultDataStoreParameters
213
	 * ()
214
	 */
215
	public DataStoreParameters getDefaultDataStoreParameters()
216
	throws DataException {
217
		GPEStoreParameters parameters = null;
218

  
219
		parameters = (GPEStoreParameters) dataManager
220
		.createStoreParameters(GPEStoreProvider.NAME);
221

  
222
		parameters.setFileName(file_prueba.getAbsolutePath());
223
		//IProjection proj = null; 
224
		// parameters.setSRS(CRSFactory.getCRS("ESPG:23030"));
225
		//parameters.setSRS(proj);
226
		
227
		return parameters;
228
	}
229

  
230
	/*
231
	 * (non-Javadoc)
232
	 *
233
	 * @see org.gvsig.fmap.dal.feature.BaseTestFeatureStore#hasExplorer()
234
	 */
235
	public boolean hasExplorer() {
236
		return false;
237
	}
238

  
239
	/* (non-Javadoc)
240
	 * @see org.gvsig.fmap.dal.feature.BaseTestEditableFeatureStore#getDefaultNewDataStoreParameters()
241
	 */
242
	public NewFeatureStoreParameters getDefaultNewDataStoreParameters()
243
	throws Exception {
244
		return null;
245
//		if (this.myExplorer == null) {
246
//			GPEStoreParameters gpeStoreParameters = (GPEStoreParameters) this
247
//			.getDefaultDataStoreParameters();
248
//			FeatureStore store = (FeatureStore) dataManager
249
//			.createStore(gpeStoreParameters);
250
//			myExplorer = (FilesystemServerExplorer) store.getExplorer();
251
//			store.dispose();
252
//		}
253
//
254
//		return (NewFeatureStoreParameters) myExplorer
255
//		.getAddParameters(dbf_prueba_destino);
256
	}
257

  
258
	/* (non-Javadoc)
259
	 * @see org.gvsig.fmap.dal.feature.BaseTestEditableFeatureStore#usesResources()
260
	 */
261
	public boolean usesResources() {
262
		// TODO Auto-generated method stub
263
		return false;
264
	}
265

  
266
	public boolean resourcesNotifyChanges() {
267
		return true;
268
	}
269

  
270
}
271

  
0 272

  
tags/v2_0_0_Build_2047/extensions/extGPE-gvSIG/config/text.properties
1
gpe_preferences_window=Gml Persistence Engine
2
gpe_preferences_window_other=Otros
3
gpe_preferences_window_xmlschema=XML Schema
4
gpe_preferences_window_xml=XML
5
gpe_preferences_window_coordinates=Coordenadas
6
gpe_xmlVersion=Versi?n de XML
7
gpe_xmlEncoding=Codificaci?n
8
gpe_defaultBlancSpace=Espacio en blanco para la etiquetas
9
gpe_namespacePrefix=Prefijo del Namespace
10
gpe_namespaceURI=Namespace
11
gpe_schemaName=Nombre del esquema por defecto
12
gpe_coordinates=S?mbolo decimal
13
gpe_coordinatesSeparator=Separador entre coordenadas
14
gpe_tuplesSeparator=Separador entre pares de coordenadas
15
gpe_decimalDigits=N?mero de decimales
16
gpe_exporting=Exportando capa
17
gpe_select_version=Selecciona la versi?n 
18
gpe_select_format=Selecciona el formato
19
gpe_select_writer=Selecciona el writer
20
gpe_select_schema=Selecciona el XML schema
21
gpe_create_default_schema=Crear un esquema por defecto
22
gpe_select_file=Seleciona el fichero
23
gpe_select_writer_window=Exportar a fichero
24
gpe_gvsig_dont_support_multilayer=La actual versi?n de gvSIG no soporta multicapa.\ Todas las geometr\u00edas se cargar\u00e1n en la misma capa. 
0 25

  
tags/v2_0_0_Build_2047/extensions/extGPE-gvSIG/config/about.htm
1
<html>
2
  <head>
3
    <title>libGPE Extension.</title>
4
    <meta content="">
5
    <style></style>
6
  </head>
7
  <body>
8
<table width="60%" border="0">
9
  <tr>
10
     <td width="64%"><img src="images/logo_horiz_bicolor_gva.png" width="329" height="50"></td>
11
    <td width="36%"><div align="right"><img src="images/logoIver.png" width="87" height="50"></div></td>
12
  </tr>
13
  <tr>
14
    <td colspan="2"><font face="Arial, Helvetica, sans-serif">&copy; Copyright
15
      Generalitat Valenciana, IVER T.I. 2008.</font></td>
16
  </tr>
17
</table>
18
  <h3>libGPE Extension.</h3>
19
  <p><br><br><b> Build Number: #build.number#</b></p>
20
  </body>
21
</html>
0 22

  
tags/v2_0_0_Build_2047/extensions/extGPE-gvSIG/config/text_en.properties
1
gpe_preferences_window=Gml Persistence Engine
2
gpe_preferences_window_other=Others
3
gpe_preferences_window_xmlschema=XML Schema
4
gpe_preferences_window_xml=XML
5
gpe_preferences_window_coordinates=Coordinates
6
gpe_xmlVersion=XML version
7
gpe_xmlEncoding=XML Encoding
8
gpe_defaultBlancSpace=Blank space for the label names
9
gpe_namespacePrefix=Namespace prefix
10
gpe_namespaceURI=Namespace
11
gpe_schemaName=Default namespace
12
gpe_coordinates=Decimal symbol
13
gpe_coordinatesSeparator=Separator between coordinates
14
gpe_tuplesSeparator=Separator between a pair of coordinates
15
gpe_decimalDigits=Decimal number
16
gpe_exporting=Exporting a layer
17
gpe_select_version=Select the version 
18
gpe_select_format=Select the format
19
gpe_select_writer=Select a writer
20
gpe_select_schema=Select a schema
21
gpe_create_default_schema=Create a default schema
22
gpe_select_file=Select the file
23
gpe_select_writer_window=Export to file
24
gpe_gvsig_dont_support_multilayer=Current gvSIG version doesnt support multilayer.\All the geometries have been loaded on the same layer.
0 25

  
tags/v2_0_0_Build_2047/extensions/extGPE-gvSIG/config/config.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<plugin-config>
3
	<depends plugin-name="org.gvsig.app" />
4
	<libraries library-dir="lib"/>
5
	<resourceBundle name="text"/>
6
	<extensions>		
7
		<extension class-name="org.gvsig.gpe.GPELibraryExtension"
8
			description=""
9
			active="true"
10
			priority="1">			
11
		</extension>
12
		<!-- 	
13
		<extension class-name="org.gvsig.gpe.GPEWriterExtension"
14
			description="Support for writing"
15
			active="true">
16
			<menu text="Capa/export_to/GML" action-command="GML"/>
17
			<menu text="Capa/export_to/KML" action-command="KML"/>
18
		</extension>
19
		<extension class-name="org.gvsig.gpe.AboutGPEExtension"
20
                description="Extension to add about panel."
21
                active="true"
22
                priority="1">
23
		</extension>
24
		-->    			
25
	</extensions>
26
</plugin-config>
0 27

  
tags/v2_0_0_Build_2047/extensions/extGPE-gvSIG/src/org/gvsig/gpe/GPELibraryExtension.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.gpe;
29

  
30
import org.gvsig.andami.plugins.Extension;
31

  
32

  
33
/**
34
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
35
 */
36
public class GPELibraryExtension extends Extension{
37
//	private DALGPELibrary lib = null;
38
		
39
	/* (non-Javadoc)
40
	 * @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
41
	 */
42
	public void execute(String actionCommand) {
43
		// TODO Auto-generated method stub
44
		
45
	}
46

  
47
	/* (non-Javadoc)
48
	 * @see com.iver.andami.plugins.IExtension#initialize()
49
	 */
50
	public void initialize() {
51
//		lib = new DALGPELibrary();
52
//		lib.initialize();		
53
	}	
54

  
55
	/* (non-Javadoc)
56
	 * @see com.iver.andami.plugins.Extension#postInitialize()
57
	 */
58
	public void postInitialize() {
59
//		lib.postInitialize();		
60
	}
61

  
62
	/* (non-Javadoc)
63
	 * @see com.iver.andami.plugins.IExtension#isEnabled()
64
	 */
65
	public boolean isEnabled() {
66
		return false;
67
	}
68

  
69
	/* (non-Javadoc)
70
	 * @see com.iver.andami.plugins.IExtension#isVisible()
71
	 */
72
	public boolean isVisible() {
73
		return false;
74
	}
75

  
76
}
77

  
0 78

  
tags/v2_0_0_Build_2047/extensions/extGPE-gvSIG/src/org/gvsig/fmap/dal/store/gpe/handlers/FmapErrorHandler.java
1
package org.gvsig.fmap.dal.store.gpe.handlers;
2

  
3
import org.gvsig.gpe.lib.impl.parser.GPEErrorHandler;
4

  
5
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
6
 *
7
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
8
 *
9
 * This program is free software; you can redistribute it and/or
10
 * modify it under the terms of the GNU General Public License
11
 * as published by the Free Software Foundation; either version 2
12
 * of the License, or (at your option) any later version.
13
 *
14
 * This program is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 * GNU General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU General Public License
20
 * along with this program; if not, write to the Free Software
21
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
22
 *
23
 * For more information, contact:
24
 *
25
 *  Generalitat Valenciana
26
 *   Conselleria d'Infraestructures i Transport
27
 *   Av. Blasco Ib??ez, 50
28
 *   46010 VALENCIA
29
 *   SPAIN
30
 *
31
 *      +34 963862235
32
 *   gvsig@gva.es
33
 *      www.gvsig.gva.es
34
 *
35
 *    or
36
 *
37
 *   IVER T.I. S.A
38
 *   Salamanca 50
39
 *   46005 Valencia
40
 *   Spain
41
 *
42
 *   +34 963163400
43
 *   dac@iver.es
44
 */
45
/* CVS MESSAGES:
46
 *
47
 * $Id$
48
 * $Log$
49
 *
50
 */
51
/**
52
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
53
 */
54
public class FmapErrorHandler extends GPEErrorHandler{
55

  
56
}
0 57

  
tags/v2_0_0_Build_2047/extensions/extGPE-gvSIG/src/org/gvsig/fmap/dal/store/gpe/handlers/FmapContentHandler.java
1
package org.gvsig.fmap.dal.store.gpe.handlers;
2

  
3
import java.io.File;
4
import java.io.IOException;
5
import java.util.ArrayList;
6
import java.util.HashMap;
7
import java.util.Iterator;
8
import java.util.List;
9
import java.util.Map;
10

  
11
import org.cresques.cts.IProjection;
12
import org.jfree.util.Log;
13
import org.slf4j.Logger;
14
import org.slf4j.LoggerFactory;
15

  
16
import org.gvsig.fmap.dal.DataTypes;
17
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor;
18
import org.gvsig.fmap.dal.feature.EditableFeatureType;
19
import org.gvsig.fmap.dal.feature.Feature;
20
import org.gvsig.fmap.dal.feature.FeatureType;
21
import org.gvsig.fmap.dal.feature.spi.DefaultFeatureProvider;
22
import org.gvsig.fmap.dal.feature.spi.FeatureProvider;
23
import org.gvsig.fmap.dal.feature.spi.FeatureStoreProviderServices;
24
import org.gvsig.fmap.dal.store.gpe.GPEStoreProvider;
25
import org.gvsig.fmap.dal.store.gpe.model.GPEElement;
26
import org.gvsig.fmap.dal.store.gpe.model.GPEFeature;
27
import org.gvsig.fmap.geom.Geometry;
28
import org.gvsig.fmap.geom.Geometry.SUBTYPES;
29
import org.gvsig.fmap.geom.Geometry.TYPES;
30
import org.gvsig.fmap.geom.GeometryLocator;
31
import org.gvsig.fmap.geom.GeometryManager;
32
import org.gvsig.fmap.geom.aggregate.MultiCurve;
33
import org.gvsig.fmap.geom.aggregate.MultiPoint;
34
import org.gvsig.fmap.geom.aggregate.MultiPrimitive;
35
import org.gvsig.fmap.geom.aggregate.MultiSurface;
36
import org.gvsig.fmap.geom.exception.CreateEnvelopeException;
37
import org.gvsig.fmap.geom.exception.CreateGeometryException;
38
import org.gvsig.fmap.geom.primitive.Curve;
39
import org.gvsig.fmap.geom.primitive.Envelope;
40
import org.gvsig.fmap.geom.primitive.GeneralPathX;
41
import org.gvsig.fmap.geom.primitive.Point;
42
import org.gvsig.fmap.geom.primitive.Primitive;
43
import org.gvsig.fmap.geom.primitive.Surface;
44
import org.gvsig.gpe.lib.api.parser.IAttributesIterator;
45
import org.gvsig.gpe.lib.api.parser.ICoordinateIterator;
46
import org.gvsig.gpe.lib.api.parser.IGPEErrorHandler;
47
import org.gvsig.gpe.lib.impl.parser.GPEContentHandler;
48
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
49
 *
50
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
51
 *
52
 * This program is free software; you can redistribute it and/or
53
 * modify it under the terms of the GNU General Public License
54
 * as published by the Free Software Foundation; either version 2
55
 * of the License, or (at your option) any later version.
56
 *
57
 * This program is distributed in the hope that it will be useful,
58
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
59
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
60
 * GNU General Public License for more details.
61
 *
62
 * You should have received a copy of the GNU General Public License
63
 * along with this program; if not, write to the Free Software
64
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
65
 *
66
 * For more information, contact:
67
 *
68
 *  Generalitat Valenciana
69
 *   Conselleria d'Infraestructures i Transport
70
 *   Av. Blasco Ib??ez, 50
71
 *   46010 VALENCIA
72
 *   SPAIN
73
 *
74
 *      +34 963862235
75
 *   gvsig@gva.es
76
 *      www.gvsig.gva.es
77
 *
78
 *    or
79
 *
80
 *   IVER T.I. S.A
81
 *   Salamanca 50
82
 *   46005 Valencia
83
 *   Spain
84
 *
85
 *   +34 963163400
86
 *   dac@iver.es
87
 */
88
/* CVS MESSAGES:
89
 *
90
 * $Id$
91
 * $Log$
92
 *
93
 */
94
/**
95
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
96
 */
97
public class FmapContentHandler extends GPEContentHandler {
98
    private static final Logger LOG = LoggerFactory.getLogger(FmapContentHandler.class);
99

  
100
    private HashMap featureSet = null;
101
    private EditableFeatureType featureType = null;
102
    private FeatureStoreProviderServices store = null;
103
    private GPEStoreProvider storeProvider = null;
104
    private GeometryManager geomManager = GeometryLocator.getGeometryManager();
105
    private int featureId = 0;
106
    private Envelope envelope = null;
107
    private File file = null;
108
    private IProjection srs = null;
109
    private int geometryType = 0;
110

  
111
    public FmapContentHandler(IGPEErrorHandler errorHandler, FeatureStoreProviderServices store,
112
        GPEStoreProvider storeProvider, File file, IProjection srs, int geometryType) {
113
        super();
114
        setErrorHandler(errorHandler);
115
        this.store = store;
116
        this.storeProvider = storeProvider;
117
        this.file = file;
118
        this.srs = srs;
119
        this.geometryType = geometryType;
120
    }
121

  
122
    public int getFeaturesCount(){
123
        return featureSet.size();
124
    }
125

  
126
    public Feature getFeatureAt(int index){
127
        return (Feature)featureSet.get(new Integer(index));
128
    }
129

  
130
    public EditableFeatureType getFeatureType(){
131
        return featureType;
132
    }
133

  
134

  
135
    /**
136
     * @return the featureSet
137
     */
138
    public HashMap getFeatureSet() {
139
        return featureSet;
140
    }
141

  
142
    /*
143
     * (non-Javadoc)
144
     * @see org.gvsig.gpe.parser.GPEContentHandler#startLayer(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, org.gvsig.gpe.parser.IAttributesIterator, java.lang.Object, java.lang.Object)
145
     */
146
    public Object startLayer(String id, String namespace, String name,
147
        String description, String srs, IAttributesIterator iterator, Object parentLayer, Object box) {
148
        if (featureSet == null){
149
            featureSet = new HashMap();
150
        }
151
        if (envelope == null){
152
            try {
153
                envelope = geomManager.createEnvelope(SUBTYPES.GEOM2D);
154
            } catch (CreateEnvelopeException e) {
155
                Log.error("Error creating the envelope", e);
156
            }
157
        }
158
        return featureSet;
159
    }
160

  
161
    /*
162
     * (non-Javadoc)
163
     * @see org.gvsig.gpe.IGPEContentHandler#endLayer(java.lang.Object)
164
     */
165
    public void endLayer(Object layer) {
166
        if (featureType == null){
167
            createFeatureType(null);
168
        }
169
        storeProvider.setEnvelope(envelope);
170
    }
171

  
172
    /*
173
     * (non-Javadoc)
174
     * @see org.gvsig.gpe.parser.GPEContentHandler#startPoint(java.lang.String, org.gvsig.gpe.parser.ICoordinateIterator, java.lang.String)
175
     */
176
    public Object startPoint(String id, ICoordinateIterator coords, String srs) {
177
        return createPoint(coords);
178
    }
179

  
180
    private Point createPoint(ICoordinateIterator coords){
181
        double[] buffer = new double[coords.getDimension()];
182
        try {
183
            coords.hasNext();
184
            coords.next(buffer);
185
            Point point = null;
186
            if (coords.getDimension() == 2){
187
                point = (Point) geomManager.create(TYPES.POINT, SUBTYPES.GEOM2D);
188
            }else if (coords.getDimension() == 3){
189
                point = (Point) geomManager.create(TYPES.POINT, SUBTYPES.GEOM3D);
190
            }
191
            for (int i=0 ; i<buffer.length ; i++){
192
                point.setCoordinateAt(i, buffer[i]);
193
            }
194
            return point;
195
        } catch (IOException e) {
196
            getErrorHandler().addError(e);
197
        } catch (CreateGeometryException e) {
198
            getErrorHandler().addError(e);
199
        }
200
        return null;
201
    }
202

  
203
    private Point createPoint(double[] buffer){
204
        try {
205
            Point point = null;
206
            if (buffer.length == 2){
207
                point = (Point) geomManager.create(TYPES.POINT, SUBTYPES.GEOM2D);
208
            }else if (buffer.length == 3){
209
                point = (Point) geomManager.create(TYPES.POINT, SUBTYPES.GEOM3D);
210
            }
211
            for (int i=0 ; i<buffer.length ; i++){
212
                point.setCoordinateAt(i, buffer[i]);
213
            }
214
            return point;
215
        }catch (CreateGeometryException e) {
216
            getErrorHandler().addError(e);
217
        }
218
        return null;
219
    }
220

  
221

  
222
    /* (non-Javadoc)
223
     * @see org.gvsig.gpe.parser.GPEContentHandler#startLineString(java.lang.String, org.gvsig.gpe.parser.ICoordinateIterator, java.lang.String)
224
     */
225
    public Object startLineString(String id, ICoordinateIterator coords,
226
        String srs) {
227
        return createCurve(coords);
228
    }
229

  
230
    private Curve createCurve(ICoordinateIterator coords){
231
        GeneralPathX gp = createGeneralPathX(coords);
232
        try {
233
            Curve curve = null;
234
            if (coords.getDimension() == 2){
235
                curve = (Curve) geomManager.create(TYPES.CURVE, SUBTYPES.GEOM2D);
236
            }else if (coords.getDimension() == 3){
237
                curve = (Curve) geomManager.create(TYPES.CURVE, SUBTYPES.GEOM3D);
238
            }
239
            curve.setGeneralPath(gp);
240
            return curve;
241
        } catch (CreateGeometryException e) {
242
            getErrorHandler().addError(e);
243
        }
244
        return null;
245
    }
246

  
247
    private GeneralPathX createGeneralPathX(ICoordinateIterator coords){
248
        GeneralPathX gp = new GeneralPathX();
249
        if (coords == null){
250
            return gp;
251
        }
252
        double[] buffer = new double[coords.getDimension()];
253
        try {
254
            if (coords.hasNext()){
255
                coords.next(buffer);
256
                gp.moveTo(buffer[0], buffer[1]);
257
            }
258
            while(coords.hasNext()){
259
                coords.next(buffer);
260
                gp.lineTo(buffer[0], buffer[1]);
261
            }
262
        } catch (IOException e) {
263
            getErrorHandler().addError(e);
264
        }
265
        return gp;
266
    }
267

  
268
    /* (non-Javadoc)
269
     * @see org.gvsig.gpe.parser.GPEContentHandler#startPolygon(java.lang.String, org.gvsig.gpe.parser.ICoordinateIterator, java.lang.String)
270
     */
271

  
272
    public Object startPolygon(String id, ICoordinateIterator coords, String srs) {
273
        return createSurface(coords);
274
    }
275

  
276
    private Surface createSurface(ICoordinateIterator coords){
277
        GeneralPathX gp = createGeneralPathX(coords);
278
        try {
279
            Surface surface = null;
280
            if (coords.getDimension() == 2){
281
                surface = (Surface) geomManager.create(TYPES.SURFACE, SUBTYPES.GEOM2D);
282
            }else if (coords.getDimension() == 3){
283
                surface = (Surface) geomManager.create(TYPES.SURFACE, SUBTYPES.GEOM3D);
284
            }
285
            surface.setGeneralPath(gp);
286
            return surface;
287
        } catch (CreateGeometryException e) {
288
            getErrorHandler().addError(e);
289
        }
290
        return null;
291
    }
292

  
293

  
294
    /* (non-Javadoc)
295
     * @see org.gvsig.gpe.parser.GPEContentHandler#startInnerPolygon(java.lang.String, org.gvsig.gpe.parser.ICoordinateIterator, java.lang.String)
296
     */
297
    public Object startInnerPolygon(String id, ICoordinateIterator coords,
298
        String srs) {
299
        return createSurface(coords);
300
    }
301

  
302
    /*
303
     * (non-Javadoc)
304
     * @see org.gvsig.gpe.IGPEContentHandler#addGeometryToFeature(java.lang.Object, java.lang.Object)
305
     */
306
    public void addGeometryToFeature(Object geometry, Object feature) {
307
        ((GPEFeature)feature).setGeometry((Geometry)geometry);
308
    }
309

  
310
    /*
311
     * (non-Javadoc)
312
     * @see org.gvsig.gpe.IGPEContentHandler#addBboxToLayer(java.lang.Object, java.lang.Object)
313
     */
314
    public void addBboxToLayer(Object bbox, Object layer) {
315
        //		if (layer != null){
316
        //		GPEBBox gpeBBox = (GPEBBox)bbox;
317
        //		if (gpeBBox.getSrs() != null){
318
        //		IProjection projection = null;
319
        //		try{
320
        //		CRSFactory.getCRS(gpeBBox.getSrs());
321
        //		}catch(Exception e){
322
        //		//If the CRS factory has an error.
323
        //		}
324
        //		if ((projection != null) && (!(projection.equals(((FLayer)layer).getProjection())))){
325
        //		//TODO reproyectar la bbox y asignarsela a la capa
326
        //		}
327
        //		}
328
        //		((IGPEDriver)layer).setExtent(gpeBBox.getBbox2D());
329
        //		}
330
    }
331

  
332
    /*
333
     * (non-Javadoc)
334
     * @see org.gvsig.gpe.IGPEContentHandler#addElementToFeature(java.lang.Object, java.lang.Object)
335
     */
336
    public void addElementToFeature(Object element, Object feature) {
337
        GPEElement gpeElement = (GPEElement)element;
338
        ((GPEFeature)feature).addElement(gpeElement);
339
    }
340

  
341
    /*
342
     * (non-Javadoc)
343
     * @see org.gvsig.gpe.IGPEContentHandler#addFeatureToLayer(java.lang.Object, java.lang.Object)
344
     */
345
    public void addFeatureToLayer(Object feature, Object layer) {
346
        GPEFeature gpefeature = (GPEFeature)feature;
347
        Envelope currentEnvelope = gpefeature.getEnvelope();
348
        if (featureType == null){
349
            createFeatureType(gpefeature);
350

  
351
            //Initialize the envelope
352
            try {
353
                envelope = geomManager.createEnvelope(SUBTYPES.GEOM2D);
354
            } catch (CreateEnvelopeException e) {
355
                getErrorHandler().addError(e);
356
            }
357
            //Calculates the envelope
358
            envelope = currentEnvelope;
359
        }else{
360
            //Calculates the envelope
361
            if (currentEnvelope != null){
362
                envelope.add(currentEnvelope);
363
            }
364
        }
365
        //If it is null is a multilayer: not supported yet
366
        if (layer != null){
367
            FeatureProvider data = new DefaultFeatureProvider(featureType.getNotEditableCopy(), storeProvider.createNewOID());
368
            Map elements = gpefeature.getelements();
369
            Iterator keys = elements.keySet().iterator();
370
            String gid = gpefeature.getId();              
371
            data.setOID(gid);              
372
            while (keys.hasNext()){
373
                String elementName = (String)keys.next();
374
                data.set(elementName, ((GPEElement)elements.get(elementName)).getValue());
375
            }
376
            data.setDefaultGeometry(gpefeature.getGeometry());
377
            data.set(featureType.getDefaultGeometryAttributeIndex(), gpefeature.getGeometry());
378
            ((HashMap)layer).put(gid, data);
379
        }
380
    }
381

  
382
    private void createFeatureType(GPEFeature gpefeature){
383
        featureType = store.createFeatureType();
384
        
385
        //Adding the Geometry field
386
        EditableFeatureAttributeDescriptor attributeDescriptor = featureType.add("the_geom", DataTypes.GEOMETRY).setGeometryType(geometryType);
387
        attributeDescriptor.setGeometrySubType(SUBTYPES.GEOM2D);
388
        attributeDescriptor.setSRS(srs);
389
        featureType.setDefaultGeometryAttributeName("the_geom");
390
        
391
        //Adding the ID
392
        featureType.add("gid", DataTypes.LONG);
393
        featureType.setHasOID(true);
394

  
395
        if (gpefeature != null){
396
            Map elements = gpefeature.getelements();
397
            Iterator keys = elements.keySet().iterator();
398
            while (keys.hasNext()){
399
                String elementName = (String)keys.next();
400
                if (!elementName.equals("the_geom")){
401
                    featureType.add(elementName, DataTypes.STRING);
402
                }
403
            }
404
        }
405

  
406
        FeatureType defaultType = featureType.getNotEditableCopy();
407
        List types = new ArrayList(1);
408
        types.add(defaultType);
409
        this.store.setFeatureTypes(types, defaultType);
410
    }
411

  
412
    /*
413
     * (non-Javadoc)
414
     * @see org.gvsig.gpe.IGPEContentHandler#addInnerPolygonToPolygon(java.lang.Object, java.lang.Object)
415
     */
416
    public void addInnerPolygonToPolygon(Object innerPolygon, Object Polygon) {
417
        //((Geometry)Polygon).addGeometry((GPEGeometry)innerPolygon);
418
    }
419

  
420
    /*
421
     * (non-Javadoc)
422
     * @see org.gvsig.gpe.IGPEContentHandler#addNameToFeature(java.lang.String, java.lang.Object)
423
     */
424
    public void addNameToFeature(String name, Object feature) {
425

  
426
    }
427

  
428
    /*
429
     * (non-Javadoc)
430
     * @see org.gvsig.gpe.IGPEContentHandler#addParentElementToElement(java.lang.Object, java.lang.Object)
431
     */
432
    public void addParentElementToElement(Object parent, Object element) {
433

  
434
    }
435

  
436
    /*
437
     * (non-Javadoc)
438
     * @see org.gvsig.gpe.IGPEContentHandler#addSrsToLayer(java.lang.String, java.lang.Object)
439
     */
440
    public void addSrsToLayer(String srs, Object Layer) {
441
        //		this.srs = srs;
442
    }
443

  
444

  
445
    /* (non-Javadoc)
446
     * @see org.gvsig.gpe.parser.GPEContentHandler#startBbox(java.lang.String, org.gvsig.gpe.parser.ICoordinateIterator, java.lang.String)
447
     */
448
    public Object startBbox(String id, ICoordinateIterator coords, String srs) {
449
        Envelope envelope = null;
450
        try {
451
            if (coords.getDimension() == 2){
452
                envelope = geomManager.createEnvelope(SUBTYPES.GEOM2D);
453
            }else if (coords.getDimension() == 3){
454
                envelope = geomManager.createEnvelope(SUBTYPES.GEOM3D);
455
            }
456
            double[] buffer = new double[coords.getDimension()];
457

  
458
            if (coords.hasNext()){
459
                coords.next(buffer);
460
                envelope.setLowerCorner(createPoint(buffer));
461
            }
462
            if (coords.hasNext()){
463
                coords.next(buffer);
464
                envelope.setUpperCorner(createPoint(buffer));
465
            }
466
        } catch (IOException e) {
467
            getErrorHandler().addError(e);
468
        } catch (CreateEnvelopeException e) {
469
            getErrorHandler().addError(e);
470
        }
471
        return envelope;
472
    }
473

  
474
    /*
475
     * (non-Javadoc)
476
     * @see org.gvsig.gpe.parser.GPEContentHandler#startElement(java.lang.String, java.lang.String, java.lang.Object, org.gvsig.gpe.parser.IAttributesIterator, java.lang.Object)
477
     */
478
    public Object startElement(String namespace, String name, Object value,
479
        IAttributesIterator attributesIterator,	Object parentElement) {
480
        return new GPEElement(name, value, (GPEElement)parentElement);
481
    }
482

  
483
    /*
484
     * (non-Javadoc)
485
     * @see org.gvsig.gpe.parser.GPEContentHandler#startFeature(java.lang.String, java.lang.String, java.lang.String, org.gvsig.gpe.parser.IAttributesIterator, java.lang.Object)
486
     */
487
    public Object startFeature(String id, String namespace, String name,
488
        IAttributesIterator attributes, Object layer){
489
        String sId;
490
        if (id == null){
491
            sId = new String(new Long(featureId).toString());			
492
        }else{
493
            sId = id;
494
        }
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff