Revision 29154
tags/tmp_build/libraries/libFMap_dalfile/.settings/org.eclipse.jdt.core.prefs | ||
---|---|---|
1 |
#Fri Apr 17 13:22:07 CEST 2009 |
|
2 |
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 |
|
3 |
eclipse.preferences.version=1 |
|
4 |
org.eclipse.jdt.core.compiler.source=1.5 |
|
5 |
org.eclipse.jdt.core.compiler.compliance=1.5 |
|
0 | 6 |
tags/tmp_build/libraries/libFMap_dalfile/.classpath | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<classpath> |
|
3 |
<classpathentry kind="src" path="src"/> |
|
4 |
<classpathentry kind="src" output="target/test-classes" path="src-test"/> |
|
5 |
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> |
|
6 |
<classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/batik/batik-anim/gvsig/batik-anim-gvsig.jar"/> |
|
7 |
<classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/batik/batik-awt-util/gvsig/batik-awt-util-gvsig.jar"/> |
|
8 |
<classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/batik/batik-bridge/gvsig/batik-bridge-gvsig.jar"/> |
|
9 |
<classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/batik/batik-codec/gvsig/batik-codec-gvsig.jar"/> |
|
10 |
<classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/batik/batik-css/gvsig/batik-css-gvsig.jar"/> |
|
11 |
<classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/batik/batik-dom/gvsig/batik-dom-gvsig.jar"/> |
|
12 |
<classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/batik/batik-ext/gvsig/batik-ext-gvsig.jar"/> |
|
13 |
<classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/batik/batik-extension/gvsig/batik-extension-gvsig.jar"/> |
|
14 |
<classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/batik/batik-gui-util/gvsig/batik-gui-util-gvsig.jar"/> |
|
15 |
<classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/batik/batik-gvt/gvsig/batik-gvt-gvsig.jar"/> |
|
16 |
<classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/batik/batik-parser/gvsig/batik-parser-gvsig.jar"/> |
|
17 |
<classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/batik/batik-script/gvsig/batik-script-gvsig.jar"/> |
|
18 |
<classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/batik/batik-svg-dom/gvsig/batik-svg-dom-gvsig.jar"/> |
|
19 |
<classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/batik/batik-svggen/gvsig/batik-svggen-gvsig.jar"/> |
|
20 |
<classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/batik/batik-swing/gvsig/batik-swing-gvsig.jar"/> |
|
21 |
<classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/batik/batik-transcoder/gvsig/batik-transcoder-gvsig.jar"/> |
|
22 |
<classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/batik/batik-util/gvsig/batik-util-gvsig.jar"/> |
|
23 |
<classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/batik/batik-xml/gvsig/batik-xml-gvsig.jar"/> |
|
24 |
<classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/castor/gvsig/castor-gvsig.jar"/> |
|
25 |
<classpathentry kind="var" path="M2_REPO/org/gvsig/com.iver.utiles/2.0-SNAPSHOT/com.iver.utiles-2.0-SNAPSHOT.jar" sourcepath="M2_REPO/org/gvsig/com.iver.utiles/2.0-SNAPSHOT/com.iver.utiles-2.0-SNAPSHOT-sources.jar"> |
|
26 |
<attributes> |
|
27 |
<attribute name="javadoc_location" value="jar:file:/home/cordin/.m2/repository/org/gvsig/com.iver.utiles/2.0-SNAPSHOT/com.iver.utiles-2.0-SNAPSHOT-javadoc.jar!/"/> |
|
28 |
</attributes> |
|
29 |
</classpathentry> |
|
30 |
<classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/geoapi/gvsig/geoapi-gvsig.jar"/> |
|
31 |
<classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/geojava/gvsig/geojava-gvsig.jar"/> |
|
32 |
<classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/gt2-legacy/gvsig/gt2-legacy-gvsig.jar"/> |
|
33 |
<classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/gt2-main/gvsig/gt2-main-gvsig.jar"/> |
|
34 |
<classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/gt2-postgis/gvsig/gt2-postgis-gvsig.jar"/> |
|
35 |
<classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/gt2sidx/gvsig/gt2sidx-gvsig.jar"/> |
|
36 |
<classpathentry kind="var" path="M2_REPO/javax/media/jai_codec/1.1.3/jai_codec-1.1.3.jar"/> |
|
37 |
<classpathentry kind="var" path="M2_REPO/javax/media/jai_core/1.1.3/jai_core-1.1.3.jar"/> |
|
38 |
<classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/units/gvsig/units-gvsig.jar"/> |
|
39 |
<classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/jts/gvsig/jts-gvsig.jar"/> |
|
40 |
<classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar" sourcepath="M2_REPO/junit/junit/3.8.1/junit-3.8.1-sources.jar"/> |
|
41 |
<classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.14/log4j-1.2.14.jar" sourcepath="M2_REPO/log4j/log4j/1.2.14/log4j-1.2.14-sources.jar"/> |
|
42 |
<classpathentry kind="var" path="M2_REPO/org/gvsig/org.gvsig.compat/2.0-SNAPSHOT/org.gvsig.compat-2.0-SNAPSHOT.jar" sourcepath="M2_REPO/org/gvsig/org.gvsig.compat/2.0-SNAPSHOT/org.gvsig.compat-2.0-SNAPSHOT-sources.jar"> |
|
43 |
<attributes> |
|
44 |
<attribute name="javadoc_location" value="jar:file:/home/cordin/.m2/repository/org/gvsig/org.gvsig.compat/2.0-SNAPSHOT/org.gvsig.compat-2.0-SNAPSHOT-javadoc.jar!/"/> |
|
45 |
</attributes> |
|
46 |
</classpathentry> |
|
47 |
<classpathentry kind="var" path="M2_REPO/org/gvsig/org.gvsig.i18n/2.0-SNAPSHOT/org.gvsig.i18n-2.0-SNAPSHOT.jar" sourcepath="M2_REPO/org/gvsig/org.gvsig.i18n/2.0-SNAPSHOT/org.gvsig.i18n-2.0-SNAPSHOT-sources.jar"> |
|
48 |
<attributes> |
|
49 |
<attribute name="javadoc_location" value="jar:file:/home/cordin/.m2/repository/org/gvsig/org.gvsig.i18n/2.0-SNAPSHOT/org.gvsig.i18n-2.0-SNAPSHOT-javadoc.jar!/"/> |
|
50 |
</attributes> |
|
51 |
</classpathentry> |
|
52 |
<classpathentry kind="var" path="M2_REPO/org/gvsig/org.gvsig.metadata/2.0-SNAPSHOT/org.gvsig.metadata-2.0-SNAPSHOT.jar" sourcepath="M2_REPO/org/gvsig/org.gvsig.metadata/2.0-SNAPSHOT/org.gvsig.metadata-2.0-SNAPSHOT-sources.jar"> |
|
53 |
<attributes> |
|
54 |
<attribute name="javadoc_location" value="jar:file:/home/cordin/.m2/repository/org/gvsig/org.gvsig.metadata/2.0-SNAPSHOT/org.gvsig.metadata-2.0-SNAPSHOT-javadoc.jar!/"/> |
|
55 |
</attributes> |
|
56 |
</classpathentry> |
|
57 |
<classpathentry kind="var" path="M2_REPO/org/gvsig/org.gvsig.projection/2.0-SNAPSHOT/org.gvsig.projection-2.0-SNAPSHOT.jar" sourcepath="M2_REPO/org/gvsig/org.gvsig.projection/2.0-SNAPSHOT/org.gvsig.projection-2.0-SNAPSHOT-sources.jar"> |
|
58 |
<attributes> |
|
59 |
<attribute name="javadoc_location" value="jar:file:/home/cordin/.m2/repository/org/gvsig/org.gvsig.projection/2.0-SNAPSHOT/org.gvsig.projection-2.0-SNAPSHOT-javadoc.jar!/"/> |
|
60 |
</attributes> |
|
61 |
</classpathentry> |
|
62 |
<classpathentry kind="var" path="M2_REPO/org/gvsig/org.gvsig.projection/2.0-SNAPSHOT/org.gvsig.projection-2.0-SNAPSHOT-cresques-impl.jar"/> |
|
63 |
<classpathentry kind="var" path="M2_REPO/org/gvsig/org.gvsig.tools/2.0-SNAPSHOT/org.gvsig.tools-2.0-SNAPSHOT.jar" sourcepath="M2_REPO/org/gvsig/org.gvsig.tools/2.0-SNAPSHOT/org.gvsig.tools-2.0-SNAPSHOT-sources.jar"> |
|
64 |
<attributes> |
|
65 |
<attribute name="javadoc_location" value="jar:file:/home/cordin/.m2/repository/org/gvsig/org.gvsig.tools/2.0-SNAPSHOT/org.gvsig.tools-2.0-SNAPSHOT-javadoc.jar!/"/> |
|
66 |
</attributes> |
|
67 |
</classpathentry> |
|
68 |
<classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-api/1.5.5/slf4j-api-1.5.5.jar" sourcepath="M2_REPO/org/slf4j/slf4j-api/1.5.5/slf4j-api-1.5.5-sources.jar"/> |
|
69 |
<classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-log4j12/1.5.5/slf4j-log4j12-1.5.5.jar" sourcepath="M2_REPO/org/slf4j/slf4j-log4j12/1.5.5/slf4j-log4j12-1.5.5-sources.jar"/> |
|
70 |
<classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/spatialindex/gvsig/spatialindex-gvsig.jar"/> |
|
71 |
<classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/sqljep/gvsig/sqljep-gvsig.jar"/> |
|
72 |
<classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/vecmath/gvsig/vecmath-gvsig.jar"/> |
|
73 |
<classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/xerces/gvsig/xerces-gvsig.jar"/> |
|
74 |
<classpathentry combineaccessrules="false" kind="src" path="/libDXF"/> |
|
75 |
<classpathentry combineaccessrules="false" kind="src" path="/libEvaluator_SQLJEP"/> |
|
76 |
<classpathentry combineaccessrules="false" kind="src" path="/libFMap_dal"/> |
|
77 |
<classpathentry combineaccessrules="false" kind="src" path="/libFMap_dalindex"/> |
|
78 |
<classpathentry combineaccessrules="false" kind="src" path="/libFMap_geometries"/> |
|
79 |
<classpathentry combineaccessrules="false" kind="src" path="/libFMap_mapcontext"/> |
|
80 |
<classpathentry kind="output" path="target/classes"/> |
|
81 |
</classpath> |
tags/tmp_build/libraries/libFMap_dalfile/.project | ||
---|---|---|
1 |
<projectDescription> |
|
2 |
<name>libFMap_dalfile</name> |
|
3 |
<comment>Base POM for all GvSIG libraries projects. This pom knows how to |
|
4 |
build and made an libraries for GvSIG. The property |
|
5 |
"gvsig-path" must be set up correctly.</comment> |
|
6 |
<projects> |
|
7 |
<project>libDXF</project> |
|
8 |
<project>libFMap_dal</project> |
|
9 |
<project>libFMap_spatialindex</project> |
|
10 |
<project>libFMap_geometries</project> |
|
11 |
<project>libFMap_mapcontext</project> |
|
12 |
<project>libEvaluator_SQLJEP</project> |
|
13 |
</projects> |
|
14 |
<buildSpec> |
|
15 |
<buildCommand> |
|
16 |
<name>org.eclipse.jdt.core.javabuilder</name> |
|
17 |
</buildCommand> |
|
18 |
</buildSpec> |
|
19 |
<natures> |
|
20 |
<nature>org.eclipse.jdt.core.javanature</nature> |
|
21 |
</natures> |
|
22 |
</projectDescription> |
tags/tmp_build/libraries/libFMap_dalfile/src-test/org/gvsig/fmap/dal/store/shp/TestSHP.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 |
* 2008 IVER T.I. S.A. {{Task}} |
|
26 |
*/ |
|
27 |
|
|
28 |
package org.gvsig.fmap.dal.store.shp; |
|
29 |
|
|
30 |
import java.io.File; |
|
31 |
import java.util.Iterator; |
|
32 |
|
|
33 |
import org.cresques.ProjectionLibrary; |
|
34 |
import org.cresques.impl.CresquesCtsLibrary; |
|
35 |
import org.gvsig.fmap.dal.DALFileLibrary; |
|
36 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
37 |
import org.gvsig.fmap.dal.exception.DataException; |
|
38 |
import org.gvsig.fmap.dal.feature.BaseTestEditableFeatureStore; |
|
39 |
import org.gvsig.fmap.dal.feature.DisposableIterator; |
|
40 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
|
41 |
import org.gvsig.fmap.dal.feature.Feature; |
|
42 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
43 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
|
44 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
45 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
46 |
import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters; |
|
47 |
import org.gvsig.fmap.dal.index.spatial.jts.JTSIndexLibrary; |
|
48 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer; |
|
49 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorerParameters; |
|
50 |
import org.gvsig.fmap.dal.store.dbf.DBFStoreParameters; |
|
51 |
import org.gvsig.fmap.dal.store.dbf.DBFStoreProvider; |
|
52 |
import org.gvsig.fmap.geom.impl.DefaultGeometryLibrary; |
|
53 |
|
|
54 |
public class TestSHP extends BaseTestEditableFeatureStore { |
|
55 |
|
|
56 |
protected boolean testSHPInitialized = false; |
|
57 |
|
|
58 |
|
|
59 |
private FilesystemServerExplorer myExplorer; |
|
60 |
|
|
61 |
|
|
62 |
public static final File file_prueba = new File(TestSHP.class.getResource( |
|
63 |
"data/prueba.shp").getFile()); |
|
64 |
public static final File file_prueba_destino = new File(file_prueba |
|
65 |
.getParent() |
|
66 |
+ File.separatorChar + "pruebaTemp.shp"); |
|
67 |
public static final File file_pruebaNull = new File(TestSHP.class |
|
68 |
.getResource("data/pruebaNull.shp").getFile()); |
|
69 |
|
|
70 |
public static final File file_poly_valencia = new File(TestSHP.class |
|
71 |
.getResource("data/poly-valencia.shp").getFile()); |
|
72 |
|
|
73 |
|
|
74 |
protected void setUp() throws Exception { |
|
75 |
super.setUp(); |
|
76 |
|
|
77 |
if (testSHPInitialized) { |
|
78 |
return; |
|
79 |
} |
|
80 |
|
|
81 |
DALFileLibrary libFile = new DALFileLibrary(); |
|
82 |
libFile.initialize(); |
|
83 |
|
|
84 |
DefaultGeometryLibrary defGeomLib = new DefaultGeometryLibrary(); |
|
85 |
defGeomLib.initialize(); |
|
86 |
|
|
87 |
ProjectionLibrary projLib = new ProjectionLibrary(); |
|
88 |
projLib.initialize(); |
|
89 |
|
|
90 |
CresquesCtsLibrary cresquesLib = new CresquesCtsLibrary(); |
|
91 |
cresquesLib.initialize(); |
|
92 |
|
|
93 |
SHPLibrary shpLib = new SHPLibrary(); |
|
94 |
shpLib.initialize(); |
|
95 |
|
|
96 |
|
|
97 |
JTSIndexLibrary jtsIndex = new JTSIndexLibrary(); |
|
98 |
jtsIndex.initialize(); |
|
99 |
|
|
100 |
defGeomLib.postInitialize(); |
|
101 |
projLib.postInitialize(); |
|
102 |
cresquesLib.postInitialize(); |
|
103 |
libFile.postInitialize(); |
|
104 |
shpLib.postInitialize(); |
|
105 |
jtsIndex.postInitialize(); |
|
106 |
|
|
107 |
testSHPInitialized = true; |
|
108 |
|
|
109 |
|
|
110 |
} |
|
111 |
|
|
112 |
public void testSimpleIteration() throws Exception { |
|
113 |
|
|
114 |
FeatureStore store = null; |
|
115 |
SHPStoreParameters shpParameters = null; |
|
116 |
|
|
117 |
shpParameters = (SHPStoreParameters) dataManager |
|
118 |
.createStoreParameters(SHPStoreProvider.NAME); |
|
119 |
|
|
120 |
// shpParameters.setFile(file_poly_valencia); |
|
121 |
shpParameters.setFile(file_prueba); |
|
122 |
|
|
123 |
shpParameters.setSRSID("EPSG:23030"); |
|
124 |
|
|
125 |
store = (FeatureStore) dataManager.createStore(shpParameters); |
|
126 |
FeatureSet set; |
|
127 |
FeatureType type = store.getDefaultFeatureType(); |
|
128 |
set = store.getFeatureSet(); |
|
129 |
|
|
130 |
System.out.println("Num:" + set.getSize()); |
|
131 |
DisposableIterator it = set.iterator(); |
|
132 |
Iterator ftIt; |
|
133 |
FeatureAttributeDescriptor desc; |
|
134 |
|
|
135 |
int i = 0; |
|
136 |
Feature feature; |
|
137 |
while (it.hasNext()) { |
|
138 |
ftIt = type.iterator(); |
|
139 |
|
|
140 |
feature = (Feature) it.next(); |
|
141 |
// while (ftIt.hasNext()) { |
|
142 |
// desc = (FeatureAttributeDescriptor) ftIt.next(); |
|
143 |
// System.out.println(desc.getName() + ":" |
|
144 |
// + feature.get(desc.getIndex())); |
|
145 |
// |
|
146 |
// } |
|
147 |
// System.out.println(feature.get("NOMBRE")); |
|
148 |
System.out.print(feature.getDefaultEnvelope() + "\t"); |
|
149 |
// System.out.print(feature.getDefaultGeometry() + "\t"); |
|
150 |
// System.out.println(feature.get("NOMBRE")); |
|
151 |
System.out.println("row:" + i); |
|
152 |
i++; |
|
153 |
|
|
154 |
|
|
155 |
} |
|
156 |
|
|
157 |
it.dispose(); |
|
158 |
set.dispose(); |
|
159 |
|
|
160 |
store.dispose(); |
|
161 |
|
|
162 |
} |
|
163 |
|
|
164 |
public void testEditing(Object x) throws Exception { |
|
165 |
FeatureStore store = null; |
|
166 |
SHPStoreParameters shpParameters = null; |
|
167 |
|
|
168 |
shpParameters = (SHPStoreParameters) dataManager |
|
169 |
.createStoreParameters(SHPStoreProvider.NAME); |
|
170 |
|
|
171 |
shpParameters.setFile(file_poly_valencia); |
|
172 |
|
|
173 |
store = (FeatureStore) dataManager.createStore(shpParameters); |
|
174 |
FeatureSet set; |
|
175 |
FeatureType type = store.getDefaultFeatureType(); |
|
176 |
System.err.println("Antes de la edici?n"); |
|
177 |
set = store.getFeatureSet(); |
|
178 |
System.out.println("Num:" + set.getSize()); |
|
179 |
DisposableIterator it = set.iterator(); |
|
180 |
Iterator ftIt; |
|
181 |
FeatureAttributeDescriptor desc; |
|
182 |
|
|
183 |
int i = 0; |
|
184 |
Feature feature; |
|
185 |
while (it.hasNext()) { |
|
186 |
ftIt = type.iterator(); |
|
187 |
|
|
188 |
feature = (Feature) it.next(); |
|
189 |
// while (ftIt.hasNext()) { |
|
190 |
// desc = (FeatureAttributeDescriptor) ftIt.next(); |
|
191 |
// System.out.println(desc.getName() + ":" |
|
192 |
// + feature.get(desc.getIndex())); |
|
193 |
// |
|
194 |
// } |
|
195 |
// System.out.println(feature.get("NOMBRE")); |
|
196 |
System.out.print(feature.getDefaultEnvelope() + "\t"); |
|
197 |
// System.out.print(feature.getDefaultGeometry() + "\t"); |
|
198 |
// System.out.println(feature.get("NOMBRE")); |
|
199 |
System.out.println("row:" + i); |
|
200 |
i++; |
|
201 |
|
|
202 |
|
|
203 |
} |
|
204 |
|
|
205 |
it.dispose(); |
|
206 |
set.dispose(); |
|
207 |
store.edit(); |
|
208 |
EditableFeature ef = store.createNewFeature(); |
|
209 |
store.insert(ef); |
|
210 |
store.finishEditing(); |
|
211 |
System.err.println("Despu?s de la edici?n"); |
|
212 |
set = store.getFeatureSet(); |
|
213 |
System.out.println("Num:" + set.getSize()); |
|
214 |
it = set.iterator(); |
|
215 |
|
|
216 |
i = 0; |
|
217 |
while (it.hasNext()) { |
|
218 |
ftIt = type.iterator(); |
|
219 |
|
|
220 |
feature = (Feature) it.next(); |
|
221 |
// while (ftIt.hasNext()) { |
|
222 |
// desc = (FeatureAttributeDescriptor) ftIt.next(); |
|
223 |
// System.out.println(desc.getName() + ":" |
|
224 |
// + feature.get(desc.getIndex())); |
|
225 |
// |
|
226 |
// } |
|
227 |
// System.out.println(feature.get("NOMBRE")); |
|
228 |
System.out.print(feature.getDefaultEnvelope() + "\t"); |
|
229 |
// System.out.print(feature.getDefaultGeometry() + "\t"); |
|
230 |
// System.out.println(feature.get("NOMBRE")); |
|
231 |
System.out.println("row:" + i); |
|
232 |
i++; |
|
233 |
|
|
234 |
|
|
235 |
} |
|
236 |
|
|
237 |
it.dispose(); |
|
238 |
set.dispose(); |
|
239 |
|
|
240 |
store.dispose(); |
|
241 |
|
|
242 |
} |
|
243 |
|
|
244 |
public void testExport(Object x) throws Exception { |
|
245 |
DBFStoreParameters dbfParameters = null; |
|
246 |
|
|
247 |
dbfParameters = (DBFStoreParameters) dataManager |
|
248 |
.createStoreParameters(DBFStoreProvider.NAME); |
|
249 |
|
|
250 |
dbfParameters.setFile(file_prueba); |
|
251 |
|
|
252 |
FeatureStore store = (FeatureStore) dataManager |
|
253 |
.createStore(dbfParameters); |
|
254 |
FilesystemServerExplorerParameters explorerParams = (FilesystemServerExplorerParameters) dataManager |
|
255 |
.createServerExplorerParameters(FilesystemServerExplorerParameters.DYNCLASS_NAME); |
|
256 |
explorerParams.setRoot(file_prueba.getParent()); |
|
257 |
|
|
258 |
FilesystemServerExplorer explorer = (FilesystemServerExplorer) dataManager |
|
259 |
.createServerExplorer(explorerParams); |
|
260 |
|
|
261 |
NewFeatureStoreParameters newParams = (NewFeatureStoreParameters) explorer |
|
262 |
.getAddParameters(file_prueba_destino); |
|
263 |
|
|
264 |
store.export(explorer, newParams); |
|
265 |
|
|
266 |
FeatureStore result = (FeatureStore) dataManager.createStore(newParams); |
|
267 |
|
|
268 |
FeatureSet set = result.getFeatureSet(); |
|
269 |
FeatureSet originalSet = store.getFeatureSet(); |
|
270 |
assertEquals(set.getSize(), originalSet.getSize()); |
|
271 |
|
|
272 |
DisposableIterator originalIter = originalSet.iterator(); |
|
273 |
DisposableIterator iter = set.iterator(); |
|
274 |
while (iter.hasNext()) { |
|
275 |
assertEquals(originalIter.next(), iter.next()); |
|
276 |
} |
|
277 |
|
|
278 |
originalIter.dispose(); |
|
279 |
iter.dispose(); |
|
280 |
result.dispose(); |
|
281 |
explorer.remove(newParams); |
|
282 |
|
|
283 |
} |
|
284 |
|
|
285 |
/* |
|
286 |
* (non-Javadoc) |
|
287 |
* |
|
288 |
* @see |
|
289 |
* org.gvsig.fmap.dal.feature.BaseTestFeatureStore#getDefaultDataStoreParameters |
|
290 |
* () |
|
291 |
*/ |
|
292 |
public DataStoreParameters getDefaultDataStoreParameters() |
|
293 |
throws DataException { |
|
294 |
SHPStoreParameters shpParameters = (SHPStoreParameters) dataManager |
|
295 |
.createStoreParameters(SHPStoreProvider.NAME); |
|
296 |
|
|
297 |
// shpParameters.setFile(file_poly_valencia); |
|
298 |
shpParameters.setFile(file_prueba); |
|
299 |
shpParameters.setSRSID("EPSG:23030"); |
|
300 |
return shpParameters; |
|
301 |
} |
|
302 |
|
|
303 |
/* |
|
304 |
* (non-Javadoc) |
|
305 |
* |
|
306 |
* @see org.gvsig.fmap.dal.feature.BaseTestFeatureStore#hasExplorer() |
|
307 |
*/ |
|
308 |
public boolean hasExplorer() { |
|
309 |
return true; |
|
310 |
} |
|
311 |
|
|
312 |
/* |
|
313 |
* (non-Javadoc) |
|
314 |
* |
|
315 |
* @seeorg.gvsig.fmap.dal.feature.BaseTestEditableFeatureStore# |
|
316 |
* getDefaultNewDataStoreParameters() |
|
317 |
*/ |
|
318 |
public NewFeatureStoreParameters getDefaultNewDataStoreParameters() |
|
319 |
throws Exception { |
|
320 |
SHPStoreParameters parameters = (SHPStoreParameters) this |
|
321 |
.getDefaultDataStoreParameters(); |
|
322 |
|
|
323 |
if (this.myExplorer == null) { |
|
324 |
FeatureStore store = (FeatureStore) dataManager |
|
325 |
.createStore(parameters); |
|
326 |
myExplorer = (FilesystemServerExplorer) store.getExplorer(); |
|
327 |
store.dispose(); |
|
328 |
} |
|
329 |
|
|
330 |
SHPNewStoreParameters result = (SHPNewStoreParameters) myExplorer |
|
331 |
.getAddParameters(file_prueba_destino); |
|
332 |
|
|
333 |
result.setSRS(parameters.getSRS()); |
|
334 |
return result; |
|
335 |
} |
|
336 |
|
|
337 |
public boolean usesResources() { |
|
338 |
return true; |
|
339 |
} |
|
340 |
|
|
341 |
public boolean resourcesNotifyChanges() { |
|
342 |
return true; |
|
343 |
} |
|
344 |
|
|
345 |
} |
|
0 | 346 |
tags/tmp_build/libraries/libFMap_dalfile/src-test/org/gvsig/fmap/dal/store/dbf/JoinTransform.java | ||
---|---|---|
1 |
package org.gvsig.fmap.dal.store.dbf; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.Arrays; |
|
5 |
import java.util.HashMap; |
|
6 |
import java.util.Iterator; |
|
7 |
import java.util.Map; |
|
8 |
import java.util.Map.Entry; |
|
9 |
|
|
10 |
import org.gvsig.fmap.dal.exception.DataException; |
|
11 |
import org.gvsig.fmap.dal.feature.AbstractFeatureStoreTransform; |
|
12 |
import org.gvsig.fmap.dal.feature.DisposableIterator; |
|
13 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
|
14 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
|
15 |
import org.gvsig.fmap.dal.feature.Feature; |
|
16 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
17 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
|
18 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
|
19 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
20 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
21 |
import org.gvsig.tools.evaluator.Evaluator; |
|
22 |
import org.gvsig.tools.evaluator.EvaluatorData; |
|
23 |
import org.gvsig.tools.evaluator.EvaluatorException; |
|
24 |
import org.gvsig.tools.evaluator.EvaluatorFieldsInfo; |
|
25 |
import org.gvsig.tools.persistence.PersistenceException; |
|
26 |
import org.gvsig.tools.persistence.PersistentState; |
|
27 |
|
|
28 |
public class JoinTransform extends AbstractFeatureStoreTransform { |
|
29 |
|
|
30 |
/** |
|
31 |
* Store from which the join transform will get the additional attributes |
|
32 |
*/ |
|
33 |
private FeatureStore store2; |
|
34 |
|
|
35 |
/** |
|
36 |
* name of the key attr in store1 that will be used to match features in |
|
37 |
* store2 |
|
38 |
*/ |
|
39 |
private String keyAttr1; |
|
40 |
|
|
41 |
/** |
|
42 |
* name of the key attr in store2 that will be used to match features in |
|
43 |
* store1 |
|
44 |
*/ |
|
45 |
private String keyAttr2; |
|
46 |
|
|
47 |
/** |
|
48 |
* names of the attributes to join from store2 to store1 |
|
49 |
*/ |
|
50 |
private String[] attrs; |
|
51 |
|
|
52 |
/** |
|
53 |
* Attribute names may change after transformation if they are repeated in |
|
54 |
* both stores. This map keeps correspondence between store2 original names |
|
55 |
* and their transformed counterparts. |
|
56 |
*/ |
|
57 |
private Map targetNamesMap; |
|
58 |
|
|
59 |
private JoinTransformEvaluator evaluator = null; |
|
60 |
|
|
61 |
private FeatureType originalFeatureType; |
|
62 |
|
|
63 |
private String[] attrsForQuery; |
|
64 |
|
|
65 |
private String prefix1; |
|
66 |
|
|
67 |
private String prefix2; |
|
68 |
|
|
69 |
/** |
|
70 |
* A default constructor |
|
71 |
*/ |
|
72 |
public JoinTransform() { |
|
73 |
targetNamesMap = new HashMap(); |
|
74 |
} |
|
75 |
|
|
76 |
/** |
|
77 |
* Initializes all the necessary data for this transform |
|
78 |
* |
|
79 |
* @param store1 |
|
80 |
* store whose default feature type is the target of this |
|
81 |
* transform |
|
82 |
* |
|
83 |
* @param store2 |
|
84 |
* store whose default feature type will provide the new |
|
85 |
* attributes to join |
|
86 |
* |
|
87 |
* @param keyAttr1 |
|
88 |
* key attribute in store1 that matches keyAttr2 in store2 |
|
89 |
* (foreign key), used for joining both stores. |
|
90 |
* |
|
91 |
* @param keyAttr2 |
|
92 |
* key attribute in store2 that matches keyAttr1 in store2 |
|
93 |
* (foreign key), used for joining both stores. |
|
94 |
* |
|
95 |
* @param attrs |
|
96 |
* names of the attributes in store2 that will be joined to |
|
97 |
* store1. |
|
98 |
*/ |
|
99 |
public void initialize(FeatureStore store1, FeatureStore store2, |
|
100 |
String keyAttr1, String keyAttr2, String prefix1, String prefix2, |
|
101 |
String[] attrs) |
|
102 |
throws DataException { |
|
103 |
|
|
104 |
if (store1 == store2) { |
|
105 |
throw new IllegalArgumentException("store1 == store2"); |
|
106 |
} |
|
107 |
|
|
108 |
// Initialize needed data |
|
109 |
this.setFeatureStore(store1); |
|
110 |
this.store2 = store2; |
|
111 |
this.keyAttr1 = keyAttr1; |
|
112 |
this.keyAttr2 = keyAttr2; |
|
113 |
this.prefix1 = prefix1; // TODO |
|
114 |
this.prefix2 = prefix2; // TODO |
|
115 |
this.attrs = attrs; |
|
116 |
|
|
117 |
// calculate this transform resulting feature type |
|
118 |
// by adding all specified attrs from store2 to store1's default |
|
119 |
// feature type |
|
120 |
// FIXME for more than one FTypes ?? |
|
121 |
this.originalFeatureType = this.getFeatureStore() |
|
122 |
.getDefaultFeatureType(); |
|
123 |
|
|
124 |
// TODO tener en cuenta prefix1 |
|
125 |
EditableFeatureType type = this.getFeatureStore().getDefaultFeatureType().getEditable(); |
|
126 |
|
|
127 |
FeatureType type2 = store2.getDefaultFeatureType(); |
|
128 |
|
|
129 |
// TODO tener en cuenta prefix2 |
|
130 |
for (int i = 0; i < attrs.length; i++) { |
|
131 |
String name = attrs[i]; |
|
132 |
|
|
133 |
// If an attribute already exists with the same name in store1's |
|
134 |
// default feature type, |
|
135 |
// calculate an alternate name and add it to our type |
|
136 |
int j = 0; |
|
137 |
while (type.getIndex(name) >= 0) { |
|
138 |
name = attrs[i] + "_" + ++j; |
|
139 |
} |
|
140 |
type.add(name, |
|
141 |
type2.getAttributeDescriptor(attrs[i]).getDataType()); |
|
142 |
|
|
143 |
// keep correspondence between original name and transformed name |
|
144 |
this.targetNamesMap.put(attrs[i], name); |
|
145 |
} |
|
146 |
if (this.targetNamesMap.containsKey(keyAttr2)) { |
|
147 |
this.attrsForQuery = this.attrs; |
|
148 |
} else { |
|
149 |
ArrayList list = new ArrayList(this.attrs.length + 1); |
|
150 |
list.addAll(Arrays.asList(this.attrs)); |
|
151 |
list.add(keyAttr2); |
|
152 |
this.attrsForQuery = (String[]) list.toArray(new String[] {}); |
|
153 |
} |
|
154 |
|
|
155 |
// assign calculated feature type as this transform's feature type |
|
156 |
FeatureType[] types = new FeatureType[] { type.getNotEditableCopy() }; |
|
157 |
setFeatureTypes(Arrays.asList(types), types[0]); |
|
158 |
} |
|
159 |
|
|
160 |
/** |
|
161 |
* |
|
162 |
* |
|
163 |
* @param source |
|
164 |
* |
|
165 |
* @param target |
|
166 |
* |
|
167 |
* @throws DataException |
|
168 |
*/ |
|
169 |
public void applyTransform(Feature source, EditableFeature target) |
|
170 |
throws DataException { |
|
171 |
|
|
172 |
// copy the data from store1 into the resulting feature |
|
173 |
this.copySourceToTarget(source, target); |
|
174 |
|
|
175 |
// ask store2 for the specified attributes, filtering by the key |
|
176 |
// attribute value |
|
177 |
// from the source feature |
|
178 |
JoinTransformEvaluator eval = this.getEvaluator(); |
|
179 |
eval.updateValue(source.get(this.keyAttr1)); |
|
180 |
|
|
181 |
FeatureQuery query = this.getFeatureStore().createFeatureQuery(); |
|
182 |
query.setAttributeNames(attrsForQuery); |
|
183 |
query.setFilter(eval); |
|
184 |
|
|
185 |
FeatureSet set = store2.getFeatureSet(query); |
|
186 |
|
|
187 |
// In this join implementation, we will take only the first matching |
|
188 |
// feature found in store2 |
|
189 |
|
|
190 |
FeatureAttributeDescriptor attr; |
|
191 |
Feature feat; |
|
192 |
String targetName; |
|
193 |
|
|
194 |
Iterator itAttr; |
|
195 |
|
|
196 |
DisposableIterator itFeat = set.iterator(); |
|
197 |
if (itFeat.hasNext()) { |
|
198 |
feat = (Feature) itFeat.next(); |
|
199 |
|
|
200 |
// copy all attributes from joined feature to target |
|
201 |
this.copyJoinToTarget(feat, target); |
|
202 |
} |
|
203 |
itFeat.dispose(); |
|
204 |
set.dispose(); |
|
205 |
} |
|
206 |
|
|
207 |
/** |
|
208 |
* @param feat |
|
209 |
* @param target |
|
210 |
*/ |
|
211 |
private void copyJoinToTarget(Feature join, EditableFeature target) { |
|
212 |
Iterator iter = targetNamesMap.entrySet() |
|
213 |
.iterator(); |
|
214 |
Entry entry; |
|
215 |
FeatureType trgType = target.getType(); |
|
216 |
FeatureAttributeDescriptor attr; |
|
217 |
while (iter.hasNext()) { |
|
218 |
entry = (Entry) iter.next(); |
|
219 |
attr = trgType.getAttributeDescriptor((String) entry.getValue()); |
|
220 |
if (attr != null) { |
|
221 |
target.set(attr.getIndex(), join.get((String) entry.getKey())); |
|
222 |
} |
|
223 |
} |
|
224 |
|
|
225 |
|
|
226 |
} |
|
227 |
|
|
228 |
/** |
|
229 |
* @param source |
|
230 |
* @param target |
|
231 |
*/ |
|
232 |
private void copySourceToTarget(Feature source, EditableFeature target) { |
|
233 |
FeatureAttributeDescriptor attr, attrTrg; |
|
234 |
FeatureType ftSrc = source.getType(); |
|
235 |
FeatureType ftTrg = target.getType(); |
|
236 |
|
|
237 |
|
|
238 |
for (int i = 0; i < source.getType().size(); i++) { |
|
239 |
attr = ftSrc.getAttributeDescriptor(i); |
|
240 |
if (ftTrg.getIndex(attr.getName()) > -1) { |
|
241 |
try { |
|
242 |
target.set(attr.getName(), source.get(i)); |
|
243 |
} catch (IllegalArgumentException e) { |
|
244 |
attrTrg = ftTrg.getAttributeDescriptor(attr.getName()); |
|
245 |
target.set(attrTrg.getIndex(), attrTrg.getDefaultValue()); |
|
246 |
} |
|
247 |
|
|
248 |
} |
|
249 |
} |
|
250 |
|
|
251 |
} |
|
252 |
|
|
253 |
private JoinTransformEvaluator getEvaluator() { |
|
254 |
if (this.evaluator == null){ |
|
255 |
this.evaluator = new JoinTransformEvaluator(keyAttr2); |
|
256 |
} |
|
257 |
return evaluator; |
|
258 |
|
|
259 |
} |
|
260 |
|
|
261 |
private class JoinTransformEvaluator implements Evaluator { |
|
262 |
|
|
263 |
private String attribute; |
|
264 |
private Object value; |
|
265 |
private String cql; |
|
266 |
private EvaluatorFieldsInfo info = null; |
|
267 |
|
|
268 |
// private int attributeIndex; |
|
269 |
|
|
270 |
public JoinTransformEvaluator(String attribute) { |
|
271 |
this.attribute = attribute; |
|
272 |
this.value = null; |
|
273 |
this.info = new EvaluatorFieldsInfo(); |
|
274 |
|
|
275 |
// this.attributeIndex = attrIndex; |
|
276 |
} |
|
277 |
|
|
278 |
public void updateValue(Object value) { |
|
279 |
this.value = value; |
|
280 |
this.cql = this.attribute + "= '" + this.value + "'"; |
|
281 |
this.info = new EvaluatorFieldsInfo(); |
|
282 |
this.info.addMatchFieldValue(this.attribute, value); |
|
283 |
} |
|
284 |
|
|
285 |
public Object evaluate(EvaluatorData arg0) throws EvaluatorException { |
|
286 |
Object curValue = arg0.getDataValue(attribute); |
|
287 |
if (curValue == null) { |
|
288 |
return new Boolean(value == null); |
|
289 |
} |
|
290 |
return new Boolean(curValue.equals(value)); |
|
291 |
} |
|
292 |
|
|
293 |
public String getCQL() { |
|
294 |
return this.cql; |
|
295 |
} |
|
296 |
|
|
297 |
public String getDescription() { |
|
298 |
return "Evaluates join transform match"; |
|
299 |
} |
|
300 |
|
|
301 |
public String getName() { |
|
302 |
return "JoinTransformEvaluator"; |
|
303 |
} |
|
304 |
|
|
305 |
public EvaluatorFieldsInfo getFieldsInfo() { |
|
306 |
return this.info; |
|
307 |
} |
|
308 |
|
|
309 |
} |
|
310 |
|
|
311 |
public void saveToState(PersistentState state) throws PersistenceException { |
|
312 |
// TODO Auto-generated method stub |
|
313 |
|
|
314 |
} |
|
315 |
|
|
316 |
public void loadFromState(PersistentState state) throws PersistenceException { |
|
317 |
// TODO Auto-generated method stub |
|
318 |
|
|
319 |
} |
|
320 |
|
|
321 |
public FeatureType getSourceFeatureTypeFrom(FeatureType arg0) { |
|
322 |
EditableFeatureType orgType = originalFeatureType.getEditable(); |
|
323 |
Iterator iter = arg0.iterator(); |
|
324 |
FeatureAttributeDescriptor attr; |
|
325 |
ArrayList toRetain = new ArrayList(); |
|
326 |
while (iter.hasNext()) { |
|
327 |
attr = (FeatureAttributeDescriptor) iter.next(); |
|
328 |
if (this.targetNamesMap.containsValue(attr.getName())) { |
|
329 |
continue; |
|
330 |
} |
|
331 |
toRetain.add(attr.getName()); |
|
332 |
} |
|
333 |
|
|
334 |
if (!toRetain.contains(keyAttr1)) { |
|
335 |
toRetain.add(keyAttr1); |
|
336 |
} |
|
337 |
|
|
338 |
iter = originalFeatureType.iterator(); |
|
339 |
while (iter.hasNext()) { |
|
340 |
attr = (FeatureAttributeDescriptor) iter.next(); |
|
341 |
if (!toRetain.contains(attr.getName())) { |
|
342 |
orgType.remove(attr.getName()); |
|
343 |
} |
|
344 |
|
|
345 |
} |
|
346 |
|
|
347 |
return orgType.getNotEditableCopy(); |
|
348 |
} |
|
349 |
|
|
350 |
public boolean isTransformsOriginalValues() { |
|
351 |
return false; |
|
352 |
} |
|
353 |
} |
|
0 | 354 |
tags/tmp_build/libraries/libFMap_dalfile/src-test/org/gvsig/fmap/dal/store/dbf/TestDBF.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 |
* 2008 IVER T.I. S.A. {{Task}} |
|
26 |
*/ |
|
27 |
|
|
28 |
package org.gvsig.fmap.dal.store.dbf; |
|
29 |
|
|
30 |
import java.io.File; |
|
31 |
import java.util.ArrayList; |
|
32 |
import java.util.Iterator; |
|
33 |
|
|
34 |
import org.gvsig.fmap.dal.DALFileLibrary; |
|
35 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
36 |
import org.gvsig.fmap.dal.exception.DataException; |
|
37 |
import org.gvsig.fmap.dal.feature.BaseTestEditableFeatureStore; |
|
38 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
39 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
|
40 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
41 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
42 |
import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters; |
|
43 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer; |
|
44 |
import org.gvsig.tools.ToolsLocator; |
|
45 |
import org.gvsig.tools.persistence.xmlentity.XMLEntityManager; |
|
46 |
|
|
47 |
public class TestDBF extends BaseTestEditableFeatureStore { |
|
48 |
|
|
49 |
protected boolean testDBFInitialized = false; |
|
50 |
|
|
51 |
|
|
52 |
public static final File dbf_prueba = new File(TestDBF.class.getResource( |
|
53 |
"data/prueba.dbf").getFile()); |
|
54 |
public static final File dbf_prueba_destino= new File(TestDBF.class.getResource( |
|
55 |
"data").getFile()+"/pruebaTemp.dbf"); |
|
56 |
public static final File dbf_pruebaNull = new File(TestDBF.class |
|
57 |
.getResource("data/pruebaNull.dbf").getFile()); |
|
58 |
|
|
59 |
private FilesystemServerExplorer myExplorer = null; |
|
60 |
|
|
61 |
public TestDBF() { |
|
62 |
super(); |
|
63 |
} |
|
64 |
|
|
65 |
/** |
|
66 |
* @param dataManager |
|
67 |
*/ |
|
68 |
public TestDBF(boolean initializeBase, boolean initializeDBF) { |
|
69 |
this.baseTestInitialized = !initializeBase; |
|
70 |
this.testDBFInitialized = !initializeDBF; |
|
71 |
} |
|
72 |
|
|
73 |
protected void setUp() throws Exception { |
|
74 |
super.setUp(); |
|
75 |
if (testDBFInitialized) { |
|
76 |
return; |
|
77 |
} |
|
78 |
ToolsLocator.registerDefaultPersistenceManager(XMLEntityManager.class); |
|
79 |
|
|
80 |
DALFileLibrary libFile = new DALFileLibrary(); |
|
81 |
libFile.initialize(); |
|
82 |
|
|
83 |
DBFLibrary dbfLib = new DBFLibrary(); |
|
84 |
dbfLib.initialize(); |
|
85 |
|
|
86 |
libFile.postInitialize(); |
|
87 |
dbfLib.postInitialize(); |
|
88 |
testDBFInitialized = true; |
|
89 |
} |
|
90 |
|
|
91 |
|
|
92 |
public DataStoreParameters getDefaultDataStoreParameters() throws DataException { |
|
93 |
DBFStoreParameters dbfParameters = null; |
|
94 |
dbfParameters = (DBFStoreParameters) dataManager |
|
95 |
.createStoreParameters(DBFStoreProvider.NAME); |
|
96 |
|
|
97 |
dbfParameters.setFile(dbf_prueba); |
|
98 |
|
|
99 |
return dbfParameters; |
|
100 |
} |
|
101 |
|
|
102 |
public void testExplorerList() throws Exception { |
|
103 |
this.testExplorerList(2); |
|
104 |
} |
|
105 |
|
|
106 |
public void testJoin() throws Exception { |
|
107 |
DBFStoreParameters dbfParameters = null; |
|
108 |
FeatureStore store1, store2; |
|
109 |
|
|
110 |
dbfParameters = (DBFStoreParameters) dataManager |
|
111 |
.createStoreParameters(DBFStoreProvider.NAME); |
|
112 |
|
|
113 |
dbfParameters.setFile(dbf_prueba); |
|
114 |
|
|
115 |
store1 = (FeatureStore) dataManager.createStore(dbfParameters); |
|
116 |
store2 = (FeatureStore) dataManager.createStore(dbfParameters); |
|
117 |
|
|
118 |
JoinTransform join = new JoinTransform(); |
|
119 |
|
|
120 |
ArrayList names = new ArrayList();// <String> |
|
121 |
Iterator iter = store2.getDefaultFeatureType().iterator();// <FeatureAttributeDescriptor> |
|
122 |
while (iter.hasNext()) { |
|
123 |
names.add(((FeatureAttributeDescriptor) iter.next()).getName()); |
|
124 |
} |
|
125 |
|
|
126 |
join.initialize(store1, store2, "NOMBRE", "NOMBRE", null, null, |
|
127 |
(String[]) names.toArray(new String[0])); |
|
128 |
store1.getTransforms().add(join); |
|
129 |
|
|
130 |
this.testSimpleIteration(store1); |
|
131 |
|
|
132 |
FeatureQuery query = store1.createFeatureQuery(); |
|
133 |
FeatureType ftFinal = store1.getDefaultFeatureType(); |
|
134 |
String[] queryNames = new String[] { |
|
135 |
ftFinal.getAttributeDescriptor(0).getName(), |
|
136 |
ftFinal.getAttributeDescriptor(1).getName(), |
|
137 |
ftFinal.getAttributeDescriptor(ftFinal.size() - 1).getName() }; |
|
138 |
query.setAttributeNames(queryNames); |
|
139 |
|
|
140 |
this.testSimpleIteration(store1, query); |
|
141 |
|
|
142 |
queryNames = new String[] { |
|
143 |
ftFinal.getAttributeDescriptor(ftFinal.size() - 1).getName(), |
|
144 |
ftFinal.getAttributeDescriptor(1).getName(), |
|
145 |
ftFinal.getAttributeDescriptor(0).getName(), |
|
146 |
ftFinal.getAttributeDescriptor(ftFinal.size() - 2).getName() }; |
|
147 |
|
|
148 |
query.setAttributeNames(queryNames); |
|
149 |
this.testSimpleIteration(store1, query); |
|
150 |
|
|
151 |
store1.dispose(); |
|
152 |
store2.dispose(); |
|
153 |
|
|
154 |
|
|
155 |
|
|
156 |
|
|
157 |
} |
|
158 |
|
|
159 |
/* |
|
160 |
* (non-Javadoc) |
|
161 |
* |
|
162 |
* @see org.gvsig.fmap.dal.feature.BaseTestFeatureStore#hasExplorer() |
|
163 |
*/ |
|
164 |
public boolean hasExplorer() { |
|
165 |
return true; |
|
166 |
} |
|
167 |
|
|
168 |
/* |
|
169 |
* (non-Javadoc) |
|
170 |
* |
|
171 |
* @seeorg.gvsig.fmap.dal.feature.BaseTestEditableFeatureStore# |
|
172 |
* getDefaultNewDataStoreParameters() |
|
173 |
*/ |
|
174 |
public NewFeatureStoreParameters getDefaultNewDataStoreParameters() |
|
175 |
throws Exception { |
|
176 |
if (this.myExplorer == null) { |
|
177 |
DBFStoreParameters dbfParameters = (DBFStoreParameters) this |
|
178 |
.getDefaultDataStoreParameters(); |
|
179 |
FeatureStore store = (FeatureStore) dataManager |
|
180 |
.createStore(dbfParameters); |
|
181 |
myExplorer = (FilesystemServerExplorer) store.getExplorer(); |
|
182 |
store.dispose(); |
|
183 |
} |
|
184 |
|
|
185 |
return (NewFeatureStoreParameters) myExplorer |
|
186 |
.getAddParameters(dbf_prueba_destino); |
|
187 |
} |
|
188 |
|
|
189 |
public boolean usesResources() { |
|
190 |
return true; |
|
191 |
} |
|
192 |
|
|
193 |
@Override |
|
194 |
public boolean resourcesNotifyChanges() { |
|
195 |
return true; |
|
196 |
} |
|
197 |
|
|
198 |
} |
|
0 | 199 |
tags/tmp_build/libraries/libFMap_dalfile/src-test/org/gvsig/fmap/dal/store/dxf/TestDXF.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 |
* 2008 IVER T.I. S.A. {{Task}} |
|
26 |
*/ |
|
27 |
|
|
28 |
package org.gvsig.fmap.dal.store.dxf; |
|
29 |
|
|
30 |
import java.io.File; |
|
31 |
|
|
32 |
import org.cresques.ProjectionLibrary; |
|
33 |
import org.cresques.impl.CresquesCtsLibrary; |
|
34 |
import org.gvsig.fmap.dal.DALFileLibrary; |
|
35 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
36 |
import org.gvsig.fmap.dal.exception.DataException; |
|
37 |
import org.gvsig.fmap.dal.feature.BaseTestFeatureStore; |
|
38 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
39 |
import org.gvsig.fmap.dal.index.spatial.jts.JTSIndexLibrary; |
|
40 |
import org.gvsig.fmap.dal.store.dxf.legend.DXFLegendLibrary; |
|
41 |
import org.gvsig.fmap.geom.impl.DefaultGeometryLibrary; |
|
42 |
|
|
43 |
public class TestDXF extends BaseTestFeatureStore { |
|
44 |
|
|
45 |
protected boolean testDXFInitialized = false; |
|
46 |
|
|
47 |
public static final File file_prueba = new File(TestDXF.class.getResource( |
|
48 |
"data/prueba.dxf").getFile()); |
|
49 |
|
|
50 |
|
|
51 |
protected void setUp() throws Exception { |
|
52 |
super.setUp(); |
|
53 |
|
|
54 |
if (testDXFInitialized) { |
|
55 |
return; |
|
56 |
} |
|
57 |
|
|
58 |
|
|
59 |
DALFileLibrary libFile = new DALFileLibrary(); |
|
60 |
libFile.initialize(); |
|
61 |
|
|
62 |
DefaultGeometryLibrary defGeomLib = new DefaultGeometryLibrary(); |
|
63 |
defGeomLib.initialize(); |
|
64 |
|
|
65 |
ProjectionLibrary projLib = new ProjectionLibrary(); |
|
66 |
projLib.initialize(); |
|
67 |
|
|
68 |
CresquesCtsLibrary cresquesLib = new CresquesCtsLibrary(); |
|
69 |
cresquesLib.initialize(); |
|
70 |
|
|
71 |
DXFLibrary dxfLib = new DXFLibrary(); |
|
72 |
dxfLib.initialize(); |
|
73 |
|
|
74 |
DXFLegendLibrary dxfLegendLib = new DXFLegendLibrary(); |
|
75 |
dxfLegendLib.initialize(); |
|
76 |
|
|
77 |
JTSIndexLibrary jtsIndex = new JTSIndexLibrary(); |
|
78 |
jtsIndex.initialize(); |
|
79 |
|
|
80 |
defGeomLib.postInitialize(); |
|
81 |
libFile.postInitialize(); |
|
82 |
projLib.postInitialize(); |
|
83 |
cresquesLib.postInitialize(); |
|
84 |
dxfLib.postInitialize(); |
|
85 |
dxfLegendLib.postInitialize(); |
|
86 |
jtsIndex.postInitialize(); |
|
87 |
|
|
88 |
|
|
89 |
testDXFInitialized = true; |
|
90 |
} |
|
91 |
|
|
92 |
/* |
|
93 |
* (non-Javadoc) |
|
94 |
* |
|
95 |
* @see |
|
96 |
* org.gvsig.fmap.dal.feature.BaseTestFeatureStore#getDefaultDataStoreParameters |
|
97 |
* () |
|
98 |
*/ |
|
99 |
public DataStoreParameters getDefaultDataStoreParameters() |
|
100 |
throws DataException { |
|
101 |
DXFStoreParameters dxfParameters = null; |
|
102 |
|
|
103 |
dxfParameters = (DXFStoreParameters) dataManager |
|
104 |
.createStoreParameters(DXFStoreProvider.NAME); |
|
105 |
|
|
106 |
dxfParameters.setFileName(file_prueba.getAbsolutePath()); |
|
107 |
dxfParameters.setSRSID("EPSG:23030"); |
|
108 |
return dxfParameters; |
|
109 |
} |
|
110 |
|
|
111 |
/* |
|
112 |
* (non-Javadoc) |
|
113 |
* |
|
114 |
* @see org.gvsig.fmap.dal.feature.BaseTestFeatureStore#hasExplorer() |
|
115 |
*/ |
|
116 |
public boolean hasExplorer() { |
|
117 |
// TODO Auto-generated method stub |
|
118 |
return false; |
|
119 |
} |
|
120 |
|
|
121 |
public boolean usesResources() { |
|
122 |
return true; |
|
123 |
} |
|
124 |
|
|
125 |
|
|
126 |
public void testLegendAndLabeling() throws Exception { |
|
127 |
FeatureStore store = (FeatureStore) dataManager |
|
128 |
.createStore(getDefaultDataStoreParameters()); |
|
129 |
|
|
130 |
assertNotNull(store.invokeDynMethod("getLegend", null)); |
|
131 |
assertNotNull(store.invokeDynMethod("getLabeling", null)); |
|
132 |
store.dispose(); |
|
133 |
} |
|
134 |
} |
|
0 | 135 |
tags/tmp_build/libraries/libFMap_dalfile/src-test/org/gvsig/fmap/dal/store/dxf/data/prueba.dxf | ||
---|---|---|
1 |
999 |
|
2 |
TRANSLATION BY geo.cresques.io.DxfFile |
|
3 |
999 |
|
4 |
DATE : Thu Mar 13 09:56:42 CET 2008 |
|
5 |
0 |
|
6 |
SECTION |
|
7 |
2 |
|
8 |
HEADER |
|
9 |
9 |
|
10 |
$ACADVER |
|
11 |
1 |
|
12 |
AC1015 |
|
13 |
9 |
|
14 |
$INSBASE |
|
15 |
10 |
|
16 |
0.0 |
|
17 |
20 |
|
18 |
0.0 |
|
19 |
30 |
|
20 |
0.0 |
|
21 |
9 |
|
22 |
$EXTMIN |
|
23 |
10 |
|
24 |
999999999.000000 |
|
25 |
20 |
|
26 |
999999999.000000 |
|
27 |
30 |
|
28 |
0.000000 |
|
29 |
9 |
|
30 |
$EXTMAX |
|
31 |
10 |
|
32 |
-999999999.000000 |
|
33 |
20 |
|
34 |
-999999999.000000 |
|
35 |
30 |
|
36 |
0.000000 |
|
37 |
9 |
|
38 |
$LIMMIN |
|
39 |
10 |
|
40 |
999999999.000000 |
|
41 |
20 |
|
42 |
999999999.000000 |
|
43 |
9 |
|
44 |
$LIMMAX |
|
45 |
10 |
|
46 |
-999999999.000000 |
|
47 |
20 |
|
48 |
-999999999.000000 |
|
49 |
9 |
|
50 |
$ORTHOMODE |
|
51 |
70 |
|
52 |
0 |
|
53 |
9 |
|
54 |
$REGENMODE |
|
55 |
70 |
|
56 |
1 |
|
57 |
9 |
|
58 |
$FILLMODE |
|
59 |
70 |
|
60 |
1 |
|
61 |
9 |
|
62 |
$QTEXTMODE |
|
63 |
70 |
|
64 |
0 |
|
65 |
9 |
|
66 |
$MIRRTEXT |
|
67 |
70 |
|
68 |
1 |
|
69 |
9 |
|
70 |
$DRAGMODE |
|
71 |
70 |
|
72 |
2 |
|
73 |
9 |
|
74 |
$LTSCALE |
|
75 |
40 |
|
76 |
1.0 |
|
77 |
9 |
|
78 |
$OSMODE |
|
79 |
70 |
|
80 |
0 |
|
81 |
9 |
|
82 |
$ATTMODE |
|
83 |
70 |
|
84 |
1 |
|
85 |
9 |
|
86 |
$TEXTSIZE |
|
87 |
40 |
|
88 |
0.2 |
|
89 |
9 |
|
90 |
$TRACEWID |
|
91 |
40 |
|
92 |
0.05 |
|
93 |
9 |
|
94 |
$TEXTSTYLE |
|
95 |
7 |
|
96 |
STANDARD |
|
97 |
9 |
|
98 |
$CLAYER |
|
99 |
8 |
|
100 |
0 |
|
101 |
9 |
|
102 |
$CELTYPE |
|
103 |
6 |
|
104 |
CONTINUOUS |
|
105 |
9 |
|
106 |
$CECOLOR |
|
107 |
62 |
|
108 |
256 |
|
109 |
9 |
|
110 |
$DIMSCALE |
|
111 |
40 |
|
112 |
1.0 |
|
113 |
9 |
|
114 |
$DIMASZ |
|
115 |
40 |
|
116 |
0.18 |
|
117 |
9 |
|
118 |
$DIMEXO |
|
119 |
40 |
|
120 |
0.0625 |
|
121 |
9 |
|
122 |
$DIMDLI |
|
123 |
40 |
|
124 |
0.38 |
|
125 |
9 |
|
126 |
$DIMRND |
|
127 |
40 |
|
128 |
0.0 |
|
129 |
9 |
|
130 |
$DIMDLE |
|
131 |
40 |
|
132 |
0.0 |
|
133 |
9 |
|
134 |
$DIMEXE |
|
135 |
40 |
|
136 |
0.18 |
|
137 |
9 |
|
138 |
$DIMTP |
|
139 |
40 |
|
140 |
0.0 |
|
141 |
9 |
|
142 |
$DIMTM |
|
143 |
40 |
|
144 |
0.0 |
|
145 |
9 |
|
146 |
$DIMTXT |
|
147 |
40 |
|
148 |
0.18 |
|
149 |
9 |
|
150 |
$DIMCEN |
|
151 |
40 |
|
152 |
0.09 |
|
153 |
9 |
|
154 |
$DIMTSZ |
|
155 |
40 |
|
156 |
0.0 |
|
157 |
9 |
|
158 |
$DIMTOL |
|
159 |
70 |
|
160 |
0 |
|
161 |
9 |
|
162 |
$DIMLIM |
|
163 |
70 |
|
164 |
0 |
|
165 |
9 |
|
166 |
$DIMTIH |
|
167 |
70 |
|
168 |
1 |
|
169 |
9 |
|
170 |
$DIMTOH |
|
171 |
70 |
|
172 |
1 |
|
173 |
9 |
|
174 |
$DIMSE1 |
|
175 |
70 |
|
176 |
0 |
|
177 |
9 |
|
178 |
$DIMSE2 |
|
179 |
70 |
|
180 |
0 |
|
181 |
9 |
|
182 |
$DIMTAD |
|
183 |
70 |
Also available in: Unified diff