Revision 37717
tags/v2_0_0_Build_2043/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_2043/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_2043/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_2043/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_2043/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">© 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_2043/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_2043/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_2043/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_2043/extensions/extGPE-gvSIG/src/org/gvsig/fmap/dal/store/gpe/GPEStoreProvider.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.Map; |
|
32 |
|
|
33 |
import org.cresques.cts.IProjection; |
|
34 |
|
|
35 |
import org.gvsig.fmap.dal.DALLocator; |
|
36 |
import org.gvsig.fmap.dal.DataManager; |
|
37 |
import org.gvsig.fmap.dal.DataServerExplorer; |
|
38 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
39 |
import org.gvsig.fmap.dal.DataTypes; |
|
40 |
import org.gvsig.fmap.dal.FileHelper; |
|
41 |
import org.gvsig.fmap.dal.exception.DataException; |
|
42 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
43 |
import org.gvsig.fmap.dal.exception.OpenException; |
|
44 |
import org.gvsig.fmap.dal.exception.ReadException; |
|
45 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
|
46 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
|
47 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
48 |
import org.gvsig.fmap.dal.feature.spi.AbstractFeatureStoreProvider; |
|
49 |
import org.gvsig.fmap.dal.feature.spi.FeatureProvider; |
|
50 |
import org.gvsig.fmap.dal.feature.spi.FeatureReferenceProviderServices; |
|
51 |
import org.gvsig.fmap.dal.feature.spi.FeatureSetProvider; |
|
52 |
import org.gvsig.fmap.dal.resource.exception.ResourceExecuteException; |
|
53 |
import org.gvsig.fmap.dal.resource.file.FileResource; |
|
54 |
import org.gvsig.fmap.dal.resource.spi.ResourceConsumer; |
|
55 |
import org.gvsig.fmap.dal.resource.spi.ResourceProvider; |
|
56 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer; |
|
57 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorerParameters; |
|
58 |
import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
|
59 |
import org.gvsig.fmap.dal.store.gpe.handlers.FmapContentHandler; |
|
60 |
import org.gvsig.fmap.dal.store.gpe.handlers.FmapErrorHandler; |
|
61 |
import org.gvsig.fmap.geom.Geometry.TYPES; |
|
62 |
import org.gvsig.fmap.geom.primitive.Envelope; |
|
63 |
import org.gvsig.gpe.lib.api.GPELocator; |
|
64 |
import org.gvsig.gpe.lib.api.GPEManager; |
|
65 |
import org.gvsig.tools.dynobject.DynObject; |
|
66 |
import org.gvsig.xmlschema.lib.api.XMLSchemaLocator; |
|
67 |
import org.gvsig.xmlschema.lib.api.XMLSchemaManager; |
|
68 |
|
|
69 |
/** |
|
70 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
|
71 |
*/ |
|
72 |
public class GPEStoreProvider extends AbstractFeatureStoreProvider implements |
|
73 |
ResourceConsumer { |
|
74 |
public static final String NAME = "GPE"; |
|
75 |
public static final String DESCRIPTION = "GPE file"; |
|
76 |
public static final String METADATA_DEFINITION_NAME = NAME; |
|
77 |
|
|
78 |
protected File m_Fich; |
|
79 |
protected boolean isOpen = false; |
|
80 |
//private GPEStoreParameters gpeParams; |
|
81 |
private ResourceProvider gpeResource; |
|
82 |
|
|
83 |
//Managers to manage the parsing process |
|
84 |
protected GPEManager gpeManager = null; |
|
85 |
protected XMLSchemaManager xmlSchemaManager = null; |
|
86 |
|
|
87 |
//The content handler and the error handler |
|
88 |
protected FmapContentHandler contentHandler; |
|
89 |
protected FmapErrorHandler errorHandler; |
|
90 |
|
|
91 |
public GPEStoreProvider(DataStoreParameters params, |
|
92 |
DataStoreProviderServices storeServices) |
|
93 |
throws InitializeException { |
|
94 |
this(params, storeServices, FileHelper |
|
95 |
.newMetadataContainer(METADATA_DEFINITION_NAME)); |
|
96 |
} |
|
97 |
|
|
98 |
protected GPEStoreProvider(DataStoreParameters params, |
|
99 |
DataStoreProviderServices storeServices, DynObject metadata) |
|
100 |
throws InitializeException { |
|
101 |
|
|
102 |
super(params, storeServices, metadata); |
|
103 |
|
|
104 |
this.setDynValue("Envelope", params.getDynValue("Envelope")); |
|
105 |
|
|
106 |
gpeManager = GPELocator.getGPEManager(); |
|
107 |
xmlSchemaManager = XMLSchemaLocator.getXMLSchemaManager(); |
|
108 |
|
|
109 |
retrieveFile(); |
|
110 |
gpeResource = this.createResource(FileResource.NAME, |
|
111 |
new Object[] { m_Fich.getAbsolutePath() }); |
|
112 |
gpeResource.addConsumer(this); |
|
113 |
this.initFeatureType(); |
|
114 |
} |
|
115 |
|
|
116 |
protected void retrieveFile() throws InitializeException{ |
|
117 |
m_Fich = getGPEParameters().getFile(); |
|
118 |
} |
|
119 |
|
|
120 |
protected void initFeatureType() throws InitializeException { |
|
121 |
try { |
|
122 |
|
|
123 |
this.open(); |
|
124 |
} catch (DataException e) { |
|
125 |
throw new InitializeException(this.getProviderName(), e); |
|
126 |
} |
|
127 |
} |
|
128 |
|
|
129 |
private GPEStoreParameters getGPEParameters() { |
|
130 |
return (GPEStoreParameters) this.getParameters(); |
|
131 |
} |
|
132 |
|
|
133 |
/* (non-Javadoc) |
|
134 |
* @see org.gvsig.fmap.dal.resource.spi.ResourceConsumer#closeResourceRequested(org.gvsig.fmap.dal.resource.spi.ResourceProvider) |
|
135 |
*/ |
|
136 |
public boolean closeResourceRequested(ResourceProvider resource) { |
|
137 |
// TODO Auto-generated method stub |
|
138 |
return false; |
|
139 |
} |
|
140 |
|
|
141 |
/* (non-Javadoc) |
|
142 |
* @see org.gvsig.fmap.dal.resource.spi.ResourceConsumer#resourceChanged(org.gvsig.fmap.dal.resource.spi.ResourceProvider) |
|
143 |
*/ |
|
144 |
public void resourceChanged(ResourceProvider resource) { |
|
145 |
// TODO Auto-generated method stub |
|
146 |
|
|
147 |
} |
|
148 |
|
|
149 |
/* (non-Javadoc) |
|
150 |
* @see org.gvsig.fmap.dal.feature.spi.FeatureStoreProvider#canWriteGeometry(int) |
|
151 |
*/ |
|
152 |
public boolean canWriteGeometry(int geometryType, int geometrySubtype) |
|
153 |
throws DataException { |
|
154 |
// TODO Auto-generated method stub |
|
155 |
return false; |
|
156 |
} |
|
157 |
|
|
158 |
/* (non-Javadoc) |
|
159 |
* @see org.gvsig.fmap.dal.feature.spi.FeatureStoreProvider#createNewOID() |
|
160 |
*/ |
|
161 |
public Object createNewOID() { |
|
162 |
return contentHandler.createNewOID(); |
|
163 |
} |
|
164 |
|
|
165 |
/* (non-Javadoc) |
|
166 |
* @see org.gvsig.fmap.dal.feature.spi.FeatureStoreProvider#createSet(org.gvsig.fmap.dal.feature.FeatureQuery) |
|
167 |
*/ |
|
168 |
public FeatureSetProvider createSet(FeatureQuery query) |
|
169 |
throws DataException { |
|
170 |
return new GPESetProvider(this, query); |
|
171 |
} |
|
172 |
|
|
173 |
protected FeatureProvider internalGetFeatureProviderByReference( |
|
174 |
FeatureReferenceProviderServices reference) throws DataException { |
|
175 |
return internalGetFeatureProviderByReference(reference, |
|
176 |
this |
|
177 |
.getFeatureStore() |
|
178 |
.getDefaultFeatureType()); |
|
179 |
} |
|
180 |
|
|
181 |
public FeatureProvider internalGetFeatureProviderByReference( |
|
182 |
FeatureReferenceProviderServices reference, FeatureType featureType) |
|
183 |
throws DataException { |
|
184 |
Map featureSet = contentHandler.getFeatureSet(); |
|
185 |
if (featureSet.containsKey(reference.getOID())){ |
|
186 |
return (FeatureProvider)featureSet.get(reference.getOID()); |
|
187 |
} |
|
188 |
return null; |
|
189 |
} |
|
190 |
|
|
191 |
FeatureProvider getFeatureProviderByIndex(Long index, FeatureType fType) |
|
192 |
throws DataException { |
|
193 |
Map featureSet = contentHandler.getFeatureSet(); |
|
194 |
if (featureSet.containsKey(index)){ |
|
195 |
return (FeatureProvider)featureSet.get(index); |
|
196 |
} |
|
197 |
return null; |
|
198 |
} |
|
199 |
|
|
200 |
public void resourcesBegin() throws ResourceExecuteException { |
|
201 |
// Nothing to do |
|
202 |
} |
|
203 |
|
|
204 |
public void resourcesEnd() { |
|
205 |
// Nothing to do |
|
206 |
} |
|
207 |
|
|
208 |
/* (non-Javadoc) |
|
209 |
* @see org.gvsig.fmap.dal.feature.spi.FeatureStoreProvider#getFeatureReferenceOIDType() |
|
210 |
*/ |
|
211 |
public int getOIDType() { |
|
212 |
return DataTypes.STRING; |
|
213 |
} |
|
214 |
|
|
215 |
/* (non-Javadoc) |
|
216 |
* @see org.gvsig.fmap.dal.feature.spi.FeatureStoreProvider#getName() |
|
217 |
*/ |
|
218 |
public String getProviderName() { |
|
219 |
return NAME; |
|
220 |
} |
|
221 |
|
|
222 |
/* (non-Javadoc) |
|
223 |
* @see org.gvsig.fmap.dal.spi.DataStoreProvider#getSourceId() |
|
224 |
*/ |
|
225 |
public Object getSourceId() { |
|
226 |
return getGPEParameters().getFile(); |
|
227 |
} |
|
228 |
|
|
229 |
public String getName() { |
|
230 |
String name = this.getGPEParameters().getFile().getName(); |
|
231 |
int n = name.lastIndexOf("."); |
|
232 |
if( n<1 ) { |
|
233 |
return name; |
|
234 |
} |
|
235 |
return name.substring(0, n); |
|
236 |
} |
|
237 |
|
|
238 |
public String getFullName() { |
|
239 |
return this.getGPEParameters().getFile().getAbsolutePath(); |
|
240 |
} |
|
241 |
|
|
242 |
/* (non-Javadoc) |
|
243 |
* @see org.gvsig.fmap.dal.spi.DataStoreProvider#open() |
|
244 |
*/ |
|
245 |
public void open() throws OpenException { |
|
246 |
if (isOpen) { |
|
247 |
return; |
|
248 |
} |
|
249 |
try { |
|
250 |
errorHandler = new FmapErrorHandler(); |
|
251 |
contentHandler = new FmapContentHandler(errorHandler, |
|
252 |
getStoreServices(), this, m_Fich, |
|
253 |
getSRS(), |
|
254 |
getGeometryType()); |
|
255 |
if (getStoreServices().getDefaultFeatureType() != null){ |
|
256 |
contentHandler.setFeatureType(getStoreServices().getDefaultFeatureType().getEditable()); |
|
257 |
} |
|
258 |
contentHandler.setEnvelope((Envelope)getDynValue("Envelope")); |
|
259 |
isOpen = true; |
|
260 |
gpeManager.parse(contentHandler, errorHandler, m_Fich.toURI()); |
|
261 |
} catch (Exception e) { |
|
262 |
throw new OpenException("Imposible create a parser",e); |
|
263 |
} |
|
264 |
} |
|
265 |
|
|
266 |
protected IProjection getSRS(){ |
|
267 |
return getGPEParameters().getCRS(); |
|
268 |
} |
|
269 |
|
|
270 |
protected int getGeometryType() { |
|
271 |
return TYPES.GEOMETRY; |
|
272 |
} |
|
273 |
|
|
274 |
/* (non-Javadoc) |
|
275 |
* @see org.gvsig.fmap.dal.feature.spi.FeatureStoreProvider#createSet(org.gvsig.fmap.dal.feature.FeatureQuery, org.gvsig.fmap.dal.feature.FeatureType) |
|
276 |
*/ |
|
277 |
public FeatureSetProvider createSet(FeatureQuery query, |
|
278 |
FeatureType featureType) throws DataException { |
|
279 |
return new GPESetProvider(this, query, featureType); |
|
280 |
} |
|
281 |
|
|
282 |
public long getFeatureCount() throws DataException { |
|
283 |
return contentHandler.getFeaturesCount(); |
|
284 |
} |
|
285 |
|
|
286 |
/* (non-Javadoc) |
|
287 |
* @see org.gvsig.fmap.dal.feature.spi.AbstractFeatureStoreProvider#getEnvelope() |
|
288 |
*/ |
|
289 |
public Envelope getEnvelope() throws DataException { |
|
290 |
this.open(); |
|
291 |
return (Envelope) this.getDynValue("Envelope"); |
|
292 |
} |
|
293 |
|
|
294 |
public void setEnvelope(Envelope envelope) { |
|
295 |
this.setDynValue("Envelope", envelope); |
|
296 |
} |
|
297 |
|
|
298 |
public ResourceProvider getResource() { |
|
299 |
return gpeResource; |
|
300 |
} |
|
301 |
|
|
302 |
public DataServerExplorer getExplorer() throws ReadException, |
|
303 |
ValidateDataParametersException { |
|
304 |
DataManager manager = DALLocator.getDataManager(); |
|
305 |
FilesystemServerExplorerParameters params; |
|
306 |
try { |
|
307 |
params = (FilesystemServerExplorerParameters) manager |
|
308 |
.createServerExplorerParameters(FilesystemServerExplorer.NAME); |
|
309 |
params.setRoot(this.getGPEParameters().getFile().getParent()); |
|
310 |
return manager.createServerExplorer(params); |
|
311 |
} catch (DataException e) { |
|
312 |
throw new ReadException(this.getProviderName(), e); |
|
313 |
} catch (ValidateDataParametersException e) { |
|
314 |
// TODO Auto-generated catch block |
|
315 |
throw new ReadException(this.getProviderName(), e); |
|
316 |
} |
|
317 |
} |
|
318 |
|
|
319 |
/** |
|
320 |
* @return the contentHandler |
|
321 |
*/ |
|
322 |
public FmapContentHandler getContentHandler() { |
|
323 |
return contentHandler; |
|
324 |
} |
|
325 |
|
|
326 |
/** |
|
327 |
* @return the errorHandler |
|
328 |
*/ |
|
329 |
public FmapErrorHandler getErrorHandler() { |
|
330 |
return errorHandler; |
|
331 |
} |
|
332 |
|
|
333 |
} |
|
0 | 334 |
tags/v2_0_0_Build_2043/extensions/extGPE-gvSIG/src/org/gvsig/fmap/dal/store/gpe/GPEStoreParameters.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.cresques.cts.IProjection; |
|
33 |
|
|
34 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
35 |
import org.gvsig.fmap.dal.FileHelper; |
|
36 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters; |
|
37 |
import org.gvsig.fmap.dal.spi.AbstractDataParameters; |
|
38 |
import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
|
39 |
import org.gvsig.fmap.geom.primitive.Envelope; |
|
40 |
import org.gvsig.tools.dynobject.DelegatedDynObject; |
|
41 |
import org.gvsig.tools.dynobject.DynStruct; |
|
42 |
|
|
43 |
/** |
|
44 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
|
45 |
*/ |
|
46 |
public class GPEStoreParameters extends AbstractDataParameters implements |
|
47 |
DataStoreParameters, FilesystemStoreParameters { |
|
48 |
|
|
49 |
public static final String PARAMETERS_DEFINITION_NAME = "GPEStoreParameters"; |
|
50 |
|
|
51 |
private static final String FILE_PARAMETER_NAME = "File"; |
|
52 |
private static final String CRS_PARAMETER_NAME = "CRS"; |
|
53 |
private static final String ENVELOPE_PARAMETER_NAME = "Envelope"; |
|
54 |
|
|
55 |
private DelegatedDynObject parameters; |
|
56 |
|
|
57 |
public GPEStoreParameters() { |
|
58 |
this(PARAMETERS_DEFINITION_NAME); |
|
59 |
} |
|
60 |
|
|
61 |
protected GPEStoreParameters(String parametersDefinitionName) { |
|
62 |
this(parametersDefinitionName, GPEStoreProvider.NAME); |
|
63 |
} |
|
64 |
|
|
65 |
public GPEStoreParameters(String parametersDefinitionName, String name) { |
|
66 |
super(); |
|
67 |
this.parameters = (DelegatedDynObject) FileHelper.newParameters(parametersDefinitionName); |
|
68 |
this.setDynValue(DataStoreProviderServices.PROVIDER_PARAMTER_NAME, name); |
|
69 |
} |
|
70 |
|
|
71 |
protected static void registerParametersDefinition(){ |
|
72 |
DynStruct dynStruct = FileHelper.registerParametersDefinition( |
|
73 |
GPEStoreParameters.PARAMETERS_DEFINITION_NAME, |
|
74 |
GPEStoreParameters.class, "GPEParameters.xml"); |
|
75 |
dynStruct.addDynFieldObject("Envelope").setClassOfValue(Envelope.class).setMandatory(false); |
|
76 |
} |
|
77 |
|
|
78 |
protected DelegatedDynObject getDelegatedDynObject() { |
|
79 |
return parameters; |
|
80 |
} |
|
81 |
|
|
82 |
public String getDataStoreName() { |
|
83 |
return GPEStoreProvider.NAME; |
|
84 |
} |
|
85 |
|
|
86 |
public String getDescription() { |
|
87 |
return GPEStoreProvider.DESCRIPTION; |
|
88 |
} |
|
89 |
|
|
90 |
public boolean isValid() { |
|
91 |
return (this.getFile() != null); |
|
92 |
} |
|
93 |
|
|
94 |
public File getFile() { |
|
95 |
return (File) this.getDynValue(FILE_PARAMETER_NAME); |
|
96 |
} |
|
97 |
|
|
98 |
public void setFile(File file) { |
|
99 |
this.setDynValue(FILE_PARAMETER_NAME, file); |
|
100 |
} |
|
101 |
|
|
102 |
public String getFileName() { |
|
103 |
return this.getFile().getAbsolutePath(); |
|
104 |
} |
|
105 |
|
|
106 |
public void setFileName(String fileName) { |
|
107 |
this.setDynValue(FILE_PARAMETER_NAME, fileName); |
|
108 |
} |
|
109 |
|
|
110 |
public IProjection getCRS() { |
|
111 |
return (IProjection) this.getDynValue(CRS_PARAMETER_NAME); |
|
112 |
} |
|
113 |
|
|
114 |
public void setCRS(IProjection srs) { |
|
115 |
this.setDynValue(CRS_PARAMETER_NAME, srs); |
|
116 |
} |
|
117 |
|
|
118 |
public void setCRS(String srs) { |
|
119 |
this.setDynValue(CRS_PARAMETER_NAME, srs); |
|
120 |
} |
|
121 |
|
|
122 |
public Envelope getEnvelope() { |
|
123 |
return (Envelope) this.getDynValue(ENVELOPE_PARAMETER_NAME); |
|
124 |
} |
|
125 |
|
|
126 |
public void setEnvelope(Envelope envelope) { |
|
127 |
this.setDynValue(ENVELOPE_PARAMETER_NAME, envelope); |
|
128 |
} |
|
129 |
} |
|
0 | 130 |
tags/v2_0_0_Build_2043/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_2043/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 |
Also available in: Unified diff