Revision 23233
branches/v2_0_0_prep/libraries/libFMap_data_dwg/build.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<!-- ====================================================================== |
|
3 |
09/01/2008 13:02:25 |
|
4 |
|
|
5 |
libFMap_data_dwg |
|
6 |
Build library libFMap_data_dwg |
|
7 |
|
|
8 |
jmvivo |
|
9 |
====================================================================== --> |
|
10 |
<project name="libFMap_data_dwg" default="batch-build"> |
|
11 |
<description> |
|
12 |
Build del libDataStore |
|
13 |
</description> |
|
14 |
<dirname file="${ant.file.libFMap_dataFile}" property="proyectDir"/> |
|
15 |
<import file="${proyectDir}/../binaries/ant/utilities.xml"/> |
|
16 |
|
|
17 |
<property name="src" location="${proyectDir}/src"/> |
|
18 |
<property name="src-test" location="${proyectDir}/src-test"/> |
|
19 |
<property name="build" location="${proyectDir}/bin"/> |
|
20 |
<property name="build-test" location="${proyectDir}/bin-test"/> |
|
21 |
<property name="dist" location="${proyectDir}/dist"/> |
|
22 |
<property name="lib" location="${proyectDir}/lib"/> |
|
23 |
|
|
24 |
<!-- dwg --> |
|
25 |
<property name="dwg-jarName" value="org.gvsig.fmap.data.file.dwg.jar"/> |
|
26 |
<property name="dwg-jarIncludes" value="org/gvsig/fmap/data/feature/file/dwg/**/**"/> |
|
27 |
<property name="dwg-jarExcludes" value="org/gvsig/fmap/data/feature/file/dwg/operation/**/**"/> |
|
28 |
|
|
29 |
<property name="dwg-operation-jarName" value="org.gvsig.fmap.data.file.dwg.operations.jar"/> |
|
30 |
<property name="dwg-operation-jarIncludes" value="${dwg-jarExcludes}"/> |
|
31 |
<property name="dwg-operation-jarExcludes" value=""/> |
|
32 |
|
|
33 |
<!-- ================================= |
|
34 |
target: generate-source |
|
35 |
================================= --> |
|
36 |
<target name="generate-source" description="--> genera el tar de fuentes"> |
|
37 |
<!-- TODO --> |
|
38 |
<echo level="warning">TODO!!!!</echo> |
|
39 |
</target> |
|
40 |
|
|
41 |
|
|
42 |
<!-- ================================= |
|
43 |
target: compile |
|
44 |
================================= --> |
|
45 |
<target name="compile" depends="update-referenced-libraries" description="--> Compile sources"> |
|
46 |
<mkdir dir="${build}"/> |
|
47 |
<mkdir dir="${build-test}"/> |
|
48 |
<!-- Compile the Java code from ${src} to ${build} --> |
|
49 |
<loadEclipseClasspath project="${basedir}"/> |
|
50 |
<gvSIG-javac |
|
51 |
classpath="${eclipseClasspath}"/> |
|
52 |
<gvSIG-javac |
|
53 |
classpath="${eclipseClasspath}" |
|
54 |
srcdir="${src-test}" |
|
55 |
destdir="${build-test}"/> |
|
56 |
|
|
57 |
</target> |
|
58 |
|
|
59 |
<!-- ================================= |
|
60 |
target: batch-build |
|
61 |
================================= --> |
|
62 |
<target name="batch-build" |
|
63 |
depends="update-referenced-libraries,compile,generate-dwg,generate-dwg-operation" |
|
64 |
description="--> Prepare library"> |
|
65 |
</target> |
|
66 |
|
|
67 |
<target name="generate-dwg" depends="compile"> |
|
68 |
<mkdir dir="${dist}"/> |
|
69 |
<jar destfile="${dist}/${dwg-jarName}" |
|
70 |
basedir="${build}" |
|
71 |
includes="${dwg-jarIncludes}" |
|
72 |
excludes="${dwg-jarExcludes}"/> |
|
73 |
</target> |
|
74 |
|
|
75 |
<target name="generate-dwg-operation" depends="update-referenced-libraries,compile,generate-dwg"> |
|
76 |
<mkdir dir="${dist}"/> |
|
77 |
<jar destfile="${dist}/${dwg-operation-jarName}" |
|
78 |
basedir="${build}" |
|
79 |
includes="${dwg-operation-jarIncludes}" |
|
80 |
excludes="${dwg-operation-jarExcludes}"/> |
|
81 |
</target> |
|
82 |
|
|
83 |
|
|
84 |
<target name="update-referenced-libraries"> |
|
85 |
<copy todir="${lib}" failonerror="false"> |
|
86 |
<fileset dir="${workspaceDir}/libDwg/dist" includes="*.jar,*.zip"/> |
|
87 |
</copy> |
|
88 |
</target> |
|
89 |
|
|
90 |
<!-- ================================= |
|
91 |
target: clean |
|
92 |
================================= --> |
|
93 |
<target name="clean" depends="" description="--> Clean proyect"> |
|
94 |
<delete> |
|
95 |
<fileset dir="${build}"> |
|
96 |
<include name="***"/> |
|
97 |
<exclude name=".svn"/> |
|
98 |
</fileset> |
|
99 |
<fileset dir="${build-test}"> |
|
100 |
<include name="***"/> |
|
101 |
<exclude name=".svn"/> |
|
102 |
</fileset> |
|
103 |
|
|
104 |
</delete> |
|
105 |
<delete dir="${dist}" includes="*.jar"/> |
|
106 |
</target> |
|
107 |
|
|
108 |
</project> |
|
0 | 109 |
branches/v2_0_0_prep/libraries/libFMap_data_dwg/.classpath | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<classpath> |
|
3 |
<classpathentry kind="src" path="src"/> |
|
4 |
<classpathentry kind="src" output="bin-test" path="src-test"/> |
|
5 |
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> |
|
6 |
<classpathentry combineaccessrules="false" kind="src" path="/libFMap_data"/> |
|
7 |
<classpathentry combineaccessrules="false" kind="src" path="/libFMap_dataFile"/> |
|
8 |
<classpathentry combineaccessrules="false" kind="src" path="/libIverUtiles"/> |
|
9 |
<classpathentry combineaccessrules="false" kind="src" path="/libTools"/> |
|
10 |
<classpathentry combineaccessrules="false" kind="src" path="/libFMap_geometries"/> |
|
11 |
<classpathentry combineaccessrules="false" kind="src" path="/libMetadata"/> |
|
12 |
<classpathentry combineaccessrules="false" kind="src" path="/libFMap_mapcontext"/> |
|
13 |
<classpathentry combineaccessrules="false" kind="src" path="/libInternationalization"/> |
|
14 |
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3.8.1"/> |
|
15 |
<classpathentry combineaccessrules="false" kind="src" path="/libFMap_data_eval_SQLJEP"/> |
|
16 |
<classpathentry kind="lib" path="lib/jdwglib.jar" sourcepath="/libDwg"/> |
|
17 |
<classpathentry kind="output" path="bin"/> |
|
18 |
</classpath> |
|
0 | 19 |
branches/v2_0_0_prep/libraries/libFMap_data_dwg/.project | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<projectDescription> |
|
3 |
<name>libFMap_data_dwg</name> |
|
4 |
<comment></comment> |
|
5 |
<projects> |
|
6 |
</projects> |
|
7 |
<buildSpec> |
|
8 |
<buildCommand> |
|
9 |
<name>org.eclipse.jdt.core.javabuilder</name> |
|
10 |
<arguments> |
|
11 |
</arguments> |
|
12 |
</buildCommand> |
|
13 |
</buildSpec> |
|
14 |
<natures> |
|
15 |
<nature>org.eclipse.jdt.core.javanature</nature> |
|
16 |
</natures> |
|
17 |
</projectDescription> |
|
0 | 18 |
branches/v2_0_0_prep/libraries/libFMap_data_dwg/src-test/org/gvsig/fmap/data/feature/file/dwg/DwgTest.java | ||
---|---|---|
1 |
package org.gvsig.fmap.data.feature.file.dwg; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import java.util.Iterator; |
|
5 |
|
|
6 |
import org.gvsig.fmap.data.CloseException; |
|
7 |
import org.gvsig.fmap.data.DataManager; |
|
8 |
import org.gvsig.fmap.data.InitializeException; |
|
9 |
import org.gvsig.fmap.data.ReadException; |
|
10 |
import org.gvsig.fmap.data.feature.Feature; |
|
11 |
import org.gvsig.fmap.data.feature.FeatureAttributeDescriptor; |
|
12 |
import org.gvsig.fmap.data.feature.FeatureCollection; |
|
13 |
import org.gvsig.fmap.data.feature.FeatureType; |
|
14 |
import org.gvsig.fmap.data.feature.file.DataStoreTest; |
|
15 |
import org.gvsig.fmap.data.feature.file.dwg.Register; |
|
16 |
|
|
17 |
import junit.framework.TestCase; |
|
18 |
|
|
19 |
public class DwgTest extends TestCase { |
|
20 |
|
|
21 |
public static final File dwgFile2000 = new File(DwgTest.class.getResource("data/V2000.dwg").getFile()); |
|
22 |
public static final File dwgFile2004 = new File(DwgTest.class.getResource("data/V2004.dwg").getFile()); |
|
23 |
|
|
24 |
public void test2000(){ |
|
25 |
test(dwgFile2000); |
|
26 |
} |
|
27 |
public void test2004(){ |
|
28 |
test(dwgFile2004); |
|
29 |
DataStoreTest.doFileResourceTest(getParams(dwgFile2004)); |
|
30 |
} |
|
31 |
public DWGStoreParameters getParams(File dwgFile){ |
|
32 |
Register.selfRegister(); |
|
33 |
DataManager manager = DataManager.getManager(); |
|
34 |
DWGStoreParameters dwgParameters=null; |
|
35 |
try { |
|
36 |
dwgParameters=(DWGStoreParameters)manager.createDataStoreParameters(DWGStore.DATASTORE_NAME); |
|
37 |
} catch (InitializeException e1) { |
|
38 |
e1.printStackTrace(); |
|
39 |
fail(); |
|
40 |
} |
|
41 |
dwgParameters.setFile(dwgFile); |
|
42 |
return dwgParameters; |
|
43 |
} |
|
44 |
public void test(File dwgFile){ |
|
45 |
DataManager manager = DataManager.getManager(); |
|
46 |
DWGStore store = null; |
|
47 |
|
|
48 |
DWGStoreParameters dwgParameters=getParams(dwgFile); |
|
49 |
try { |
|
50 |
store = (DWGStore)manager.createDataStore(dwgParameters); |
|
51 |
} catch (InitializeException e) { |
|
52 |
// TODO Auto-generated catch block |
|
53 |
e.printStackTrace(); |
|
54 |
} |
|
55 |
|
|
56 |
FeatureType ft=store.getDefaultFeatureType(); |
|
57 |
FeatureCollection featureCollection=null; |
|
58 |
try { |
|
59 |
featureCollection = (FeatureCollection)store.getDataCollection(ft,null,null); |
|
60 |
} catch (ReadException e) { |
|
61 |
// TODO Auto-generated catch block |
|
62 |
e.printStackTrace(); |
|
63 |
} |
|
64 |
Iterator iter = featureCollection.iterator(); |
|
65 |
while (iter.hasNext()) { |
|
66 |
Feature feature = (Feature)iter.next(); |
|
67 |
System.out.println("DWG Feature ------------------- "); |
|
68 |
Iterator iterator=ft.iterator(); |
|
69 |
while (iterator.hasNext()) { |
|
70 |
FeatureAttributeDescriptor descriptor = (FeatureAttributeDescriptor) iterator.next(); |
|
71 |
int i=descriptor.ordinal(); |
|
72 |
String type=descriptor.getDataType(); |
|
73 |
if (type.equals(FeatureAttributeDescriptor.TYPE_BOOLEAN)){ |
|
74 |
System.out.println(descriptor.getName()+"(Boolean) -->\t\t "+ feature.getBoolean(i)); |
|
75 |
}else if (type.equals(FeatureAttributeDescriptor.TYPE_BYTE)){ |
|
76 |
System.out.println(descriptor.getName()+"(Byte) -->\t\t "+ feature.getByte(i)); |
|
77 |
}else if (type.equals(FeatureAttributeDescriptor.TYPE_DATE)){ |
|
78 |
System.out.println(descriptor.getName()+"(Date) -->\t\t "+ feature.getDate(i)); |
|
79 |
}else if (type.equals(FeatureAttributeDescriptor.TYPE_DOUBLE)){ |
|
80 |
System.out.println(descriptor.getName()+"(Double) -->\t\t "+ feature.getDouble(i)); |
|
81 |
}else if (type.equals(FeatureAttributeDescriptor.TYPE_FLOAT)){ |
|
82 |
System.out.println(descriptor.getName()+"(Float) -->\t\t "+ feature.getFloat(i)); |
|
83 |
}else if (type.equals(FeatureAttributeDescriptor.TYPE_INT)){ |
|
84 |
System.out.println(descriptor.getName()+"(Integer) -->\t\t "+ feature.getInt(i)); |
|
85 |
}else if (type.equals(FeatureAttributeDescriptor.TYPE_LONG)){ |
|
86 |
System.out.println(descriptor.getName()+"(Long) -->\t\t "+ feature.getLong(i)); |
|
87 |
}else if (type.equals(FeatureAttributeDescriptor.TYPE_STRING)){ |
|
88 |
System.out.println(descriptor.getName()+"(String) -->\t\t "+ feature.getString(i)); |
|
89 |
}else if (type.equals(FeatureAttributeDescriptor.TYPE_GEOMETRY)){ |
|
90 |
System.out.println("Geometry ----- "+ feature.getGeometry(i)); |
|
91 |
} else { |
|
92 |
System.out.println(descriptor.getName()+"==> "+type); |
|
93 |
} |
|
94 |
} |
|
95 |
} |
|
96 |
iter = null; |
|
97 |
featureCollection.dispose(); |
|
98 |
|
|
99 |
try { |
|
100 |
store.dispose(); |
|
101 |
} catch (CloseException e) { |
|
102 |
// TODO Auto-generated catch block |
|
103 |
e.printStackTrace(); |
|
104 |
} |
|
105 |
|
|
106 |
} |
|
107 |
} |
|
0 | 108 |
branches/v2_0_0_prep/libraries/libFMap_data_dwg/src/org/gvsig/fmap/data/feature/file/dwg/DWGFeatureCollection.java | ||
---|---|---|
1 |
package org.gvsig.fmap.data.feature.file.dwg; |
|
2 |
|
|
3 |
import java.util.Collection; |
|
4 |
|
|
5 |
import org.gvsig.fmap.data.DataStore; |
|
6 |
import org.gvsig.fmap.data.feature.FeatureStore; |
|
7 |
import org.gvsig.fmap.data.feature.FeatureType; |
|
8 |
import org.gvsig.fmap.data.feature.MemoryFeatureCollection; |
|
9 |
|
|
10 |
public class DWGFeatureCollection extends MemoryFeatureCollection { |
|
11 |
|
|
12 |
public boolean isFromStore(DataStore store) { |
|
13 |
return this.store.equals(store); |
|
14 |
} |
|
15 |
|
|
16 |
public DWGFeatureCollection(FeatureStore store, FeatureType type, |
|
17 |
Collection features) { |
|
18 |
super(store, type); |
|
19 |
this.addAll(features); |
|
20 |
this.allowmodify = false; |
|
21 |
} |
|
22 |
|
|
23 |
public void dispose() { |
|
24 |
super.dispose(); |
|
25 |
this.store = null; |
|
26 |
this.features = null; |
|
27 |
} |
|
28 |
|
|
29 |
|
|
30 |
} |
|
0 | 31 |
branches/v2_0_0_prep/libraries/libFMap_data_dwg/src/org/gvsig/fmap/data/feature/file/dwg/DWGResource.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 {{Task}} |
|
26 |
*/ |
|
27 |
|
|
28 |
/** |
|
29 |
* |
|
30 |
*/ |
|
31 |
package org.gvsig.fmap.data.feature.file.dwg; |
|
32 |
|
|
33 |
import java.awt.geom.AffineTransform; |
|
34 |
import java.awt.geom.Arc2D; |
|
35 |
import java.awt.geom.Rectangle2D; |
|
36 |
import java.io.File; |
|
37 |
import java.io.IOException; |
|
38 |
import java.util.ArrayList; |
|
39 |
import java.util.List; |
|
40 |
|
|
41 |
import org.gvsig.fmap.data.DataException; |
|
42 |
import org.gvsig.fmap.data.OpenException; |
|
43 |
import org.gvsig.fmap.data.ReadException; |
|
44 |
import org.gvsig.fmap.data.feature.Feature; |
|
45 |
import org.gvsig.fmap.data.feature.FeatureAttributeDescriptor; |
|
46 |
import org.gvsig.fmap.data.feature.FeatureType; |
|
47 |
import org.gvsig.fmap.data.feature.IsNotFeatureSettingException; |
|
48 |
import org.gvsig.fmap.data.feature.UnsupportedVersionException; |
|
49 |
import org.gvsig.fmap.data.feature.file.FileMemoryResource; |
|
50 |
import org.gvsig.fmap.data.feature.file.FileStoreParameters; |
|
51 |
//import org.gvsig.fmap.data.feature.file.dgn.utils.DGNElemArc; |
|
52 |
//import org.gvsig.fmap.data.feature.file.dgn.utils.DGNElemComplexHeader; |
|
53 |
//import org.gvsig.fmap.data.feature.file.dgn.utils.DGNElemCore; |
|
54 |
//import org.gvsig.fmap.data.feature.file.dgn.utils.DGNElemMultiPoint; |
|
55 |
//import org.gvsig.fmap.data.feature.file.dgn.utils.DGNElemText; |
|
56 |
//import org.gvsig.fmap.data.feature.file.dgn.utils.DGNFileHeader; |
|
57 |
//import org.gvsig.fmap.data.feature.file.dgn.utils.DGNReader; |
|
58 |
import org.gvsig.fmap.geom.Geometry; |
|
59 |
import org.gvsig.fmap.geom.GeometryFactory; |
|
60 |
import org.gvsig.fmap.geom.GeometryManager; |
|
61 |
import org.gvsig.fmap.geom.primitive.DefaultEnvelope; |
|
62 |
import org.gvsig.fmap.geom.primitive.Envelope; |
|
63 |
import org.gvsig.fmap.geom.primitive.GeneralPathX; |
|
64 |
import org.gvsig.fmap.mapcontext.rendering.legend.LegendFactory; |
|
65 |
import org.gvsig.fmap.mapcontext.rendering.legend.VectorialUniqueValueLegend; |
|
66 |
import org.gvsig.fmap.mapcontext.rendering.legend.styling.AttrInTableLabelingStrategy; |
|
67 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
|
68 |
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbologyFactory; |
|
69 |
import org.gvsig.i18n.Messages; |
|
70 |
|
|
71 |
import com.iver.cit.jdwglib.dwg.DwgFile; |
|
72 |
import com.iver.cit.jdwglib.dwg.DwgObject; |
|
73 |
import com.iver.cit.jdwglib.dwg.DwgVersionNotSupportedException; |
|
74 |
import com.iver.cit.jdwglib.dwg.IDwg2FMap; |
|
75 |
import com.iver.cit.jdwglib.dwg.IDwg3DTestable; |
|
76 |
import com.iver.cit.jdwglib.dwg.objects.DwgMText; |
|
77 |
import com.iver.cit.jdwglib.dwg.objects.DwgText; |
|
78 |
|
|
79 |
/** |
|
80 |
* @author jmvivo |
|
81 |
* |
|
82 |
*/ |
|
83 |
public class DWGResource extends FileMemoryResource { |
|
84 |
|
|
85 |
private final int ID_FIELD_ID = 0; |
|
86 |
private final int ID_FIELD_FSHAPE = 1; |
|
87 |
private final int ID_FIELD_ENTITY = 2; |
|
88 |
private final int ID_FIELD_LAYER = 3; |
|
89 |
private final int ID_FIELD_COLOR = 4; |
|
90 |
private final int ID_FIELD_ELEVATION = 5; |
|
91 |
private final int ID_FIELD_THICKNESS = 6; |
|
92 |
private final int ID_FIELD_HEIGHTTEXT = 7; |
|
93 |
private final int ID_FIELD_ROTATIONTEXT = 8; |
|
94 |
private final int ID_FIELD_TEXT = 9; |
|
95 |
private final int ID_FIELD_GEOMETRY = 10; |
|
96 |
|
|
97 |
|
|
98 |
|
|
99 |
|
|
100 |
private FeatureType featureType; |
|
101 |
|
|
102 |
private AttrInTableLabelingStrategy labeling; |
|
103 |
private VectorialUniqueValueLegend defaultLegend; |
|
104 |
|
|
105 |
private Envelope fullEnvelope; |
|
106 |
|
|
107 |
/** |
|
108 |
* @param params |
|
109 |
*/ |
|
110 |
DWGResource(FileStoreParameters params) { |
|
111 |
super(params); |
|
112 |
} |
|
113 |
|
|
114 |
/* (non-Javadoc) |
|
115 |
* @see org.gvsig.fmap.data.Resource#getName() |
|
116 |
*/ |
|
117 |
public String getName() { |
|
118 |
return "DWG"; |
|
119 |
} |
|
120 |
|
|
121 |
private void initializeFeatureType() throws DataException { |
|
122 |
this.featureType= DWGStore.newFeatureType(); |
|
123 |
} |
|
124 |
|
|
125 |
|
|
126 |
/* (non-Javadoc) |
|
127 |
* @see org.gvsig.fmap.data.feature.file.FileMemoryResource#load() |
|
128 |
*/ |
|
129 |
protected void load() throws DataException { |
|
130 |
// float heightText = 10; |
|
131 |
// attr.setLoadedInMemory(true); |
|
132 |
initializeFeatureType(); |
|
133 |
fullEnvelope = new DefaultEnvelope(2); |
|
134 |
File file = this.getFile(); |
|
135 |
DwgFile dwg = new DwgFile(file.getAbsolutePath()); |
|
136 |
try { |
|
137 |
dwg.read(); |
|
138 |
} catch (DwgVersionNotSupportedException e1) { |
|
139 |
String autodeskUrl = "<a href=\"http://usa.autodesk.com/adsk/servlet/item?siteID=123112&id=7024151\">" |
|
140 |
+ "http://usa.autodesk.com/adsk/servlet/item?siteID=123112&id=7024151</a>"; |
|
141 |
throw new UnsupportedVersionException("la version ("+e1.getDwgVersion().toString()+ |
|
142 |
") del fichero '"+file.getName()+"' no esta soportada por gvSIG.\n"+ |
|
143 |
Messages.getText("Probe_to_convert")+"\n"+ |
|
144 |
Messages.getText("Autodesk_converter")+"\n"+autodeskUrl, e1); |
|
145 |
} catch (IOException e) { |
|
146 |
throw new ReadException(DWGStore.DATASTORE_NAME, e); |
|
147 |
} |
|
148 |
|
|
149 |
dwg.calculateGisModelDwgPolylines(); |
|
150 |
dwg.blockManagement2(); |
|
151 |
List dwgObjects = dwg.getDwgObjects(); |
|
152 |
//Each dwg file has two headers vars, EXTMIN and EXTMAX |
|
153 |
//that marks bounds of the file. |
|
154 |
//Also, it could have spureus entities (deleted objects |
|
155 |
//dont removed from the DWG database) |
|
156 |
double[] extMin = (double[]) dwg.getHeader("MSPACE_EXTMIN"); |
|
157 |
double[] extMax = (double[]) dwg.getHeader("MSPACE_EXTMAX"); |
|
158 |
if(extMin != null && extMax != null){ |
|
159 |
if(extMin.length >= 2 && extMax.length >= 2){ |
|
160 |
double xmin = extMin[0]; |
|
161 |
double ymin = extMin[1]; |
|
162 |
double xmax = extMax[0]; |
|
163 |
double ymax = extMax[1]; |
|
164 |
Envelope roi = new |
|
165 |
DefaultEnvelope(xmin-100, ymin-100, |
|
166 |
(xmax-xmin)+100, (ymax-ymin)+100); |
|
167 |
this.fullEnvelope.add(roi); |
|
168 |
} |
|
169 |
} |
|
170 |
|
|
171 |
|
|
172 |
boolean is3dFile = dwg.isDwg3DFile(); |
|
173 |
|
|
174 |
for (int i = 0; i < dwgObjects.size(); i++) { |
|
175 |
try { |
|
176 |
DwgObject entity = (DwgObject) dwgObjects.get(i); |
|
177 |
|
|
178 |
if(entity instanceof IDwg2FMap){ |
|
179 |
|
|
180 |
IDwg2FMap dwgEnt = (IDwg2FMap)entity; |
|
181 |
Geometry geometry = dwgEnt.toFMapGeometry(is3dFile); |
|
182 |
if (geometry == null) |
|
183 |
continue; |
|
184 |
//we check for Region of Interest of the CAD file |
|
185 |
if(!this.fullEnvelope.contains(geometry.getEnvelope())) |
|
186 |
continue; |
|
187 |
DWGFeature feature = new DWGFeature(this.featureType, false); |
|
188 |
|
|
189 |
feature.loading(); |
|
190 |
|
|
191 |
feature.set(ID_FIELD_ID, i); |
|
192 |
|
|
193 |
feature.set(ID_FIELD_ENTITY, dwgEnt.toString()); |
|
194 |
|
|
195 |
feature.set(ID_FIELD_FSHAPE, geometry.getGeometryType().getName()); |
|
196 |
|
|
197 |
feature.set(ID_FIELD_LAYER, dwg.getLayerName(entity)); |
|
198 |
|
|
199 |
int colorByLayer = dwg.getColorByLayer(entity); |
|
200 |
int color = entity.getColor(); |
|
201 |
if(color < 0) |
|
202 |
color = Math.abs(color); |
|
203 |
if(color > 255) |
|
204 |
color = colorByLayer; |
|
205 |
feature.set(ID_FIELD_COLOR, color); |
|
206 |
|
|
207 |
if(entity instanceof IDwg3DTestable){ |
|
208 |
feature.set(ID_FIELD_ELEVATION, ((IDwg3DTestable)entity).getZ()); |
|
209 |
} |
|
210 |
|
|
211 |
feature.set(ID_FIELD_THICKNESS, 0.0); |
|
212 |
feature.set(ID_FIELD_HEIGHTTEXT, 0.0); |
|
213 |
feature.set(ID_FIELD_ROTATIONTEXT, 0.0); |
|
214 |
feature.set(ID_FIELD_TEXT, ""); |
|
215 |
|
|
216 |
if(entity instanceof DwgMText){ |
|
217 |
DwgMText mtext = (DwgMText) entity; |
|
218 |
feature.set(ID_FIELD_HEIGHTTEXT, mtext.getHeight()); |
|
219 |
feature.set(ID_FIELD_TEXT, mtext.getText()); |
|
220 |
}else if(entity instanceof DwgText){ |
|
221 |
DwgText text = (DwgText) entity; |
|
222 |
feature.set(ID_FIELD_THICKNESS, text.getThickness()); |
|
223 |
feature.set(ID_FIELD_HEIGHTTEXT, text.getHeight()); |
|
224 |
feature.set(ID_FIELD_ROTATIONTEXT, text.getRotationAngle()); |
|
225 |
feature.set(ID_FIELD_TEXT, text.getText()); |
|
226 |
}//if-else |
|
227 |
|
|
228 |
feature.setGeometry(ID_FIELD_GEOMETRY, geometry); |
|
229 |
|
|
230 |
this.addFeature(new DWGFeature(feature)); |
|
231 |
|
|
232 |
}//if instanceof |
|
233 |
} catch (ReadException e) { |
|
234 |
throw new OpenException(this.description(),e); |
|
235 |
} |
|
236 |
|
|
237 |
|
|
238 |
}//for |
|
239 |
} |
|
240 |
|
|
241 |
/* (non-Javadoc) |
|
242 |
* @see org.gvsig.fmap.data.feature.file.IFileResource#getTotalFiles() |
|
243 |
*/ |
|
244 |
public int getTotalFiles() { |
|
245 |
return 1; |
|
246 |
} |
|
247 |
|
|
248 |
protected FeatureType getFeatureType() throws ReadException{ |
|
249 |
this.checkOpen(); |
|
250 |
return this.featureType; |
|
251 |
} |
|
252 |
|
|
253 |
/** |
|
254 |
* @return |
|
255 |
* @throws ReadException |
|
256 |
*/ |
|
257 |
protected Object getDefaultLegend() throws ReadException { |
|
258 |
this.checkOpen(); |
|
259 |
return this.defaultLegend; |
|
260 |
} |
|
261 |
|
|
262 |
/* (non-Javadoc) |
|
263 |
* @see org.gvsig.fmap.data.feature.file.FileMemoryResource#getFeatureCount() |
|
264 |
*/ |
|
265 |
protected int getFeatureCount() throws ReadException { |
|
266 |
return super.getFeatureCount(); |
|
267 |
} |
|
268 |
|
|
269 |
/* (non-Javadoc) |
|
270 |
* @see org.gvsig.fmap.data.feature.file.FileMemoryResource#getFullExtent() |
|
271 |
*/ |
|
272 |
protected Envelope getFullExtent() throws ReadException { |
|
273 |
return super.getFullExtent(); |
|
274 |
} |
|
275 |
|
|
276 |
/* (non-Javadoc) |
|
277 |
* @see org.gvsig.fmap.data.feature.file.FileMemoryResource#getFeature(int) |
|
278 |
*/ |
|
279 |
protected Feature getFeature(int index) throws ReadException { |
|
280 |
return super.getFeature(index); |
|
281 |
} |
|
282 |
|
|
283 |
protected AttrInTableLabelingStrategy getDefaultLabelingStrategy() throws ReadException { |
|
284 |
this.checkOpen(); |
|
285 |
return labeling; |
|
286 |
} |
|
287 |
|
|
288 |
} |
|
289 |
|
|
0 | 290 |
branches/v2_0_0_prep/libraries/libFMap_data_dwg/src/org/gvsig/fmap/data/feature/file/dwg/DWGDataExplorer.java | ||
---|---|---|
1 |
package org.gvsig.fmap.data.feature.file.dwg; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import java.util.ArrayList; |
|
5 |
|
|
6 |
import org.gvsig.fmap.data.DataException; |
|
7 |
import org.gvsig.fmap.data.DataExplorerParameters; |
|
8 |
import org.gvsig.fmap.data.DataStoreParameters; |
|
9 |
import org.gvsig.fmap.data.InitializeException; |
|
10 |
import org.gvsig.fmap.data.ReadException; |
|
11 |
import org.gvsig.fmap.data.feature.FeatureType; |
|
12 |
import org.gvsig.fmap.data.feature.file.FileExplorer; |
|
13 |
import org.gvsig.fmap.data.feature.file.FileNotFoundException; |
|
14 |
|
|
15 |
public class DWGDataExplorer extends FileExplorer { |
|
16 |
|
|
17 |
public static String DATASOURCE_NAME="DWGDataExplorer"; |
|
18 |
|
|
19 |
protected DWGDataExplorerParameters parameters; |
|
20 |
protected File path; |
|
21 |
|
|
22 |
|
|
23 |
public DataStoreParameters[] list() throws ReadException { |
|
24 |
if (!this.path.exists()){ |
|
25 |
new FileNotFoundException(this.getName()+": Path not found '"+this.path+"'",new Exception()); |
|
26 |
} |
|
27 |
// DataManager dsm=DataManager.getManager(); |
|
28 |
|
|
29 |
String files[] = this.path.list(); |
|
30 |
int i; |
|
31 |
File theFile; |
|
32 |
ArrayList fileList = new ArrayList(); |
|
33 |
DataStoreParameters dsp = null; |
|
34 |
|
|
35 |
for (i=0;i<files.length;i++){ |
|
36 |
theFile = new File(this.path,files[i]); |
|
37 |
|
|
38 |
if (this.isValid(theFile)){ |
|
39 |
dsp= this.newParameter(theFile); |
|
40 |
|
|
41 |
|
|
42 |
fileList.add(dsp); |
|
43 |
|
|
44 |
} |
|
45 |
|
|
46 |
|
|
47 |
} |
|
48 |
DataStoreParameters[] x = new DataStoreParameters[1]; |
|
49 |
x[0]=dsp; |
|
50 |
return (DataStoreParameters[])fileList.toArray(x); |
|
51 |
} |
|
52 |
|
|
53 |
protected DataStoreParameters newParameter(File file){ |
|
54 |
DWGStoreParameters param = new DWGStoreParameters(); |
|
55 |
param.setFile(file); |
|
56 |
return param; |
|
57 |
} |
|
58 |
|
|
59 |
protected boolean isValid(String file){ |
|
60 |
return this.isValid(new File(file)); |
|
61 |
|
|
62 |
} |
|
63 |
|
|
64 |
protected boolean isValid(File file){ |
|
65 |
if (!file.exists()){ |
|
66 |
return false; |
|
67 |
} |
|
68 |
return (file.getName().toLowerCase().endsWith(".dwg")); |
|
69 |
} |
|
70 |
|
|
71 |
public String getName() { |
|
72 |
return DATASOURCE_NAME; |
|
73 |
} |
|
74 |
|
|
75 |
public void init(DataExplorerParameters parameters) |
|
76 |
throws InitializeException { |
|
77 |
super.init(parameters); |
|
78 |
this.path = this.parameters.getSource(); |
|
79 |
} |
|
80 |
|
|
81 |
public FeatureType[] getFeatureTypes(DataStoreParameters dsp) throws ReadException { |
|
82 |
try { |
|
83 |
return new FeatureType[] {DWGStore.newFeatureType()}; |
|
84 |
} catch (DataException e) { |
|
85 |
throw new ReadException(this.getName(),e); |
|
86 |
} |
|
87 |
} |
|
88 |
|
|
89 |
|
|
90 |
|
|
91 |
} |
|
0 | 92 |
branches/v2_0_0_prep/libraries/libFMap_data_dwg/src/org/gvsig/fmap/data/feature/file/dwg/DWGFeature.java | ||
---|---|---|
1 |
package org.gvsig.fmap.data.feature.file.dwg; |
|
2 |
|
|
3 |
import org.gvsig.fmap.data.DataException; |
|
4 |
import org.gvsig.fmap.data.ReadException; |
|
5 |
import org.gvsig.fmap.data.feature.Feature; |
|
6 |
import org.gvsig.fmap.data.feature.FeatureType; |
|
7 |
import org.gvsig.fmap.data.feature.MemoryFeature; |
|
8 |
|
|
9 |
public class DWGFeature extends MemoryFeature{ |
|
10 |
|
|
11 |
|
|
12 |
public DWGFeature(Feature feature) throws ReadException{ |
|
13 |
super(feature); |
|
14 |
} |
|
15 |
public DWGFeature(FeatureType type, boolean defaultValues) throws ReadException { |
|
16 |
super(type, defaultValues); |
|
17 |
} |
|
18 |
|
|
19 |
protected Feature cloneFeature() throws DataException { |
|
20 |
return new DWGFeature(this); |
|
21 |
} |
|
22 |
} |
|
0 | 23 |
branches/v2_0_0_prep/libraries/libFMap_data_dwg/src/org/gvsig/fmap/data/feature/file/dwg/DWGStore.java | ||
---|---|---|
1 |
package org.gvsig.fmap.data.feature.file.dwg; |
|
2 |
|
|
3 |
import java.lang.ref.WeakReference; |
|
4 |
import java.security.KeyException; |
|
5 |
import java.util.ArrayList; |
|
6 |
import java.util.Collection; |
|
7 |
import java.util.Comparator; |
|
8 |
import java.util.Iterator; |
|
9 |
import java.util.List; |
|
10 |
import java.util.TreeSet; |
|
11 |
|
|
12 |
import org.gvsig.fmap.data.CloseException; |
|
13 |
import org.gvsig.fmap.data.DataCollection; |
|
14 |
import org.gvsig.fmap.data.DataException; |
|
15 |
import org.gvsig.fmap.data.DataExplorer; |
|
16 |
import org.gvsig.fmap.data.DataExplorerParameters; |
|
17 |
import org.gvsig.fmap.data.DataManager; |
|
18 |
import org.gvsig.fmap.data.DataStoreParameters; |
|
19 |
import org.gvsig.fmap.data.InitializeException; |
|
20 |
import org.gvsig.fmap.data.OpenException; |
|
21 |
import org.gvsig.fmap.data.ReadException; |
|
22 |
import org.gvsig.fmap.data.ResourceManager; |
|
23 |
import org.gvsig.fmap.data.WriteException; |
|
24 |
import org.gvsig.fmap.data.feature.AttributeDescriptor; |
|
25 |
import org.gvsig.fmap.data.feature.DefaultFeatureType; |
|
26 |
import org.gvsig.fmap.data.feature.Feature; |
|
27 |
import org.gvsig.fmap.data.feature.FeatureAttributeDescriptor; |
|
28 |
import org.gvsig.fmap.data.feature.FeatureCollection; |
|
29 |
import org.gvsig.fmap.data.feature.FeatureID; |
|
30 |
import org.gvsig.fmap.data.feature.FeatureType; |
|
31 |
import org.gvsig.fmap.data.feature.FeaturesWriter; |
|
32 |
import org.gvsig.fmap.data.feature.expressionevaluator.Filter; |
|
33 |
import org.gvsig.fmap.data.feature.file.FileExplorerParameters; |
|
34 |
import org.gvsig.fmap.data.feature.file.FileStore; |
|
35 |
import org.gvsig.fmap.geom.Geometry; |
|
36 |
import org.gvsig.fmap.geom.primitive.Envelope; |
|
37 |
import org.gvsig.metadata.IMetadata; |
|
38 |
import org.gvsig.metadata.IMetadataManager; |
|
39 |
import org.gvsig.metadata.MetadataManager; |
|
40 |
import org.gvsig.tools.exception.BaseException; |
|
41 |
|
|
42 |
public class DWGStore extends FileStore{ |
|
43 |
public static String DATASTORE_NAME = "DWGStore"; |
|
44 |
|
|
45 |
private List featureTypes = new ArrayList();//<FeatureType> |
|
46 |
protected IMetadata metadata; |
|
47 |
private DWGStoreParameters dwgParameters=null; |
|
48 |
|
|
49 |
private DWGResource dwg; |
|
50 |
|
|
51 |
public void init(DataStoreParameters parameters) throws InitializeException { |
|
52 |
|
|
53 |
dwgParameters=(DWGStoreParameters)parameters; |
|
54 |
try { |
|
55 |
DWGResource tmpResource = new DWGResource(dwgParameters); |
|
56 |
ResourceManager resMan = ResourceManager.getResourceManager(); |
|
57 |
|
|
58 |
try { |
|
59 |
this.dwg = (DWGResource)resMan.addResource(tmpResource); |
|
60 |
} catch (DataException e1) { |
|
61 |
throw new InitializeException(this.getName(),e1); |
|
62 |
} |
|
63 |
|
|
64 |
super.init(parameters,this.dwg); |
|
65 |
|
|
66 |
|
|
67 |
this.defaultFeatureType = this.dwg.getFeatureType(); |
|
68 |
} catch (ReadException e) { |
|
69 |
throw new InitializeException(this.getName(),e); |
|
70 |
} catch (DataException e) { |
|
71 |
throw new InitializeException(this.getName(),e); |
|
72 |
} |
|
73 |
|
|
74 |
} |
|
75 |
|
|
76 |
|
|
77 |
static FeatureType newFeatureType() throws DataException{ |
|
78 |
DefaultFeatureType fType= new DefaultFeatureType(); |
|
79 |
AttributeDescriptor descriptorID = (AttributeDescriptor) fType.createAttributeDescriptor(); |
|
80 |
descriptorID.loading(); |
|
81 |
descriptorID.setType(FeatureAttributeDescriptor.TYPE_INT); |
|
82 |
descriptorID.setName("ID"); |
|
83 |
descriptorID.setDefaultValue(new Integer(0)); |
|
84 |
descriptorID.stopLoading(); |
|
85 |
fType.add(descriptorID); |
|
86 |
fType.setFieldsId(new String[] {"ID"}); |
|
87 |
|
|
88 |
AttributeDescriptor descriptorFShape = (AttributeDescriptor) fType.createAttributeDescriptor(); |
|
89 |
descriptorFShape.loading(); |
|
90 |
descriptorFShape.setType(FeatureAttributeDescriptor.TYPE_STRING); |
|
91 |
descriptorFShape.setName("FShape"); |
|
92 |
descriptorFShape.setDefaultValue("FShape"); |
|
93 |
descriptorFShape.stopLoading(); |
|
94 |
fType.add(descriptorFShape); |
|
95 |
|
|
96 |
AttributeDescriptor descriptorEntity = (AttributeDescriptor) fType.createAttributeDescriptor(); |
|
97 |
descriptorEntity.loading(); |
|
98 |
descriptorEntity.setType(FeatureAttributeDescriptor.TYPE_STRING); |
|
99 |
descriptorEntity.setName("Entity"); |
|
100 |
descriptorEntity.setDefaultValue("Entity"); |
|
101 |
descriptorEntity.stopLoading(); |
|
102 |
fType.add(descriptorEntity); |
|
103 |
|
|
104 |
AttributeDescriptor descriptorLayer = (AttributeDescriptor) fType.createAttributeDescriptor(); |
|
105 |
descriptorLayer.loading(); |
|
106 |
descriptorLayer.setType(FeatureAttributeDescriptor.TYPE_STRING); |
|
107 |
descriptorLayer.setName("Layer"); |
|
108 |
descriptorLayer.setDefaultValue(""); |
|
109 |
descriptorLayer.stopLoading(); |
|
110 |
fType.add(descriptorLayer); |
|
111 |
|
|
112 |
AttributeDescriptor descriptorColor = (AttributeDescriptor) fType.createAttributeDescriptor(); |
|
113 |
descriptorColor.loading(); |
|
114 |
descriptorColor.setType(FeatureAttributeDescriptor.TYPE_INT); |
|
115 |
descriptorColor.setName("Color"); |
|
116 |
descriptorColor.setDefaultValue(new Integer(0)); |
|
117 |
descriptorColor.stopLoading(); |
|
118 |
fType.add(descriptorColor); |
|
119 |
|
|
120 |
AttributeDescriptor descriptorElevation = (AttributeDescriptor) fType.createAttributeDescriptor(); |
|
121 |
descriptorElevation.loading(); |
|
122 |
descriptorElevation.setType(FeatureAttributeDescriptor.TYPE_DOUBLE); |
|
123 |
descriptorElevation.setName("Elevation"); |
|
124 |
descriptorElevation.setDefaultValue(new Double(0)); |
|
125 |
fType.add(descriptorElevation); |
|
126 |
|
|
127 |
AttributeDescriptor descriptorThickness = (AttributeDescriptor) fType.createAttributeDescriptor(); |
|
128 |
descriptorThickness.loading(); |
|
129 |
descriptorThickness.setType(FeatureAttributeDescriptor.TYPE_DOUBLE); |
|
130 |
descriptorThickness.setName("Thickness"); |
|
131 |
descriptorThickness.setDefaultValue(new Double(0)); |
|
132 |
fType.add(descriptorThickness); |
|
133 |
|
|
134 |
AttributeDescriptor descriptorHeightText = (AttributeDescriptor) fType.createAttributeDescriptor(); |
|
135 |
descriptorHeightText.loading(); |
|
136 |
descriptorHeightText.setType(FeatureAttributeDescriptor.TYPE_DOUBLE); |
|
137 |
descriptorHeightText.setName("HeightText"); |
|
138 |
descriptorHeightText.setDefaultValue(new Double(0)); |
|
139 |
descriptorHeightText.stopLoading(); |
|
140 |
fType.add(descriptorHeightText); |
|
141 |
|
|
142 |
AttributeDescriptor descriptorRotationText = (AttributeDescriptor) fType.createAttributeDescriptor(); |
|
143 |
descriptorRotationText.loading(); |
|
144 |
descriptorRotationText.setType(FeatureAttributeDescriptor.TYPE_DOUBLE); |
|
145 |
descriptorRotationText.setName("RotationText"); |
|
146 |
descriptorRotationText.setDefaultValue(new Double(0)); |
|
147 |
descriptorRotationText.stopLoading(); |
|
148 |
fType.add(descriptorRotationText); |
|
149 |
|
|
150 |
AttributeDescriptor descriptorText = (AttributeDescriptor) fType.createAttributeDescriptor(); |
|
151 |
descriptorText.loading(); |
|
152 |
descriptorText.setType(FeatureAttributeDescriptor.TYPE_STRING); |
|
153 |
descriptorText.setName("Text"); |
|
154 |
descriptorText.setDefaultValue(""); |
|
155 |
descriptorText.stopLoading(); |
|
156 |
fType.add(descriptorText); |
|
157 |
|
|
158 |
AttributeDescriptor descriptorShape = (AttributeDescriptor) fType.createAttributeDescriptor(); |
|
159 |
descriptorShape.loading(); |
|
160 |
|
|
161 |
descriptorShape.setType(FeatureAttributeDescriptor.TYPE_GEOMETRY); |
|
162 |
|
|
163 |
descriptorShape.setName("GEOMETRY"); |
|
164 |
descriptorShape.setDefaultValue(null); |
|
165 |
descriptorShape.stopLoading(); |
|
166 |
fType.add(descriptorShape); |
|
167 |
fType.setDefaultGeometry("GEOMETRY"); |
|
168 |
fType.setGeometryTypes(new int[]{Geometry.TYPES.GEOMETRY}); |
|
169 |
return fType; |
|
170 |
|
|
171 |
|
|
172 |
} |
|
173 |
|
|
174 |
protected void doFinishEdition() throws WriteException, ReadException{ |
|
175 |
|
|
176 |
} |
|
177 |
|
|
178 |
public DataCollection getDataCollection(FeatureType type, String filter, String order) throws ReadException { |
|
179 |
if (type==null){ |
|
180 |
type=getDefaultFeatureType(); |
|
181 |
}else{ |
|
182 |
if (!type.isSubtypeOf(this.getDefaultFeatureType())){ |
|
183 |
throw new ReadException("invalid type",this.getName()); |
|
184 |
} |
|
185 |
} |
|
186 |
FeatureCollection coll; |
|
187 |
|
|
188 |
DataManager manager = DataManager.getManager(); |
|
189 |
//TODO aplicar filtro, orden e incluso y el featureType |
|
190 |
Filter parser = null; |
|
191 |
if (filter!=null){ |
|
192 |
parser = manager.getExpressionParser().parseFilter(filter); |
|
193 |
} |
|
194 |
// ArrayList originalFeatures=this.getFeatures(); |
|
195 |
int num=0; |
|
196 |
if (featureManager!=null){ |
|
197 |
num=featureManager.getNum(); |
|
198 |
} |
|
199 |
int originalSize=this.dwg.getFeatureCount(); |
|
200 |
Collection allFeatures = null; |
|
201 |
if (order!=null){ |
|
202 |
Comparator comparator = manager.getExpressionParser() |
|
203 |
.parseComparator(order); |
|
204 |
allFeatures = new TreeSet(comparator); |
|
205 |
}else{ |
|
206 |
allFeatures=new ArrayList(); |
|
207 |
} |
|
208 |
// int j=0; |
|
209 |
for (int i = 0; i < originalSize+num; i++) { |
|
210 |
Feature feature=null; |
|
211 |
if (i<this.dwg.getFeatureCount()){ |
|
212 |
feature=this.dwg.getFeature(i); |
|
213 |
}else{ |
|
214 |
feature=featureManager.getFeature(i-originalSize,this,type); |
|
215 |
} |
|
216 |
if (featureManager == null || !featureManager.isDeleted(feature)){ |
|
217 |
|
|
218 |
if (filter == null || parser.evaluate(feature)) { |
|
219 |
// System.err.println(i); |
|
220 |
// j++; |
|
221 |
// System.err.println("j= "+j); |
|
222 |
if (!allFeatures.add(feature)) { |
|
223 |
//???? |
|
224 |
// System.err.println("Fallo " +auxfeature); |
|
225 |
}else{ |
|
226 |
// System.out.println("Correcto " +auxfeature); |
|
227 |
} |
|
228 |
} |
|
229 |
|
|
230 |
} |
|
231 |
|
|
232 |
} |
|
233 |
|
|
234 |
coll = new DWGFeatureCollection(this, type, allFeatures); |
|
235 |
this.addObserver(new WeakReference(coll)); |
|
236 |
return coll; |
|
237 |
} |
|
238 |
|
|
239 |
public Feature getFeatureByID(FeatureID id,FeatureType featureType) throws ReadException { |
|
240 |
if (featureType==null){ |
|
241 |
featureType=getDefaultFeatureType(); |
|
242 |
}else{ |
|
243 |
if (!featureType.isSubtypeOf(this.getDefaultFeatureType())){ |
|
244 |
throw new ReadException("invalid type",this.getName()); |
|
245 |
} |
|
246 |
} |
|
247 |
|
|
248 |
if (this.alterMode){ |
|
249 |
if (featureManager.contains(id)) { |
|
250 |
return featureManager.getFeature(id,this,featureType); |
|
251 |
|
|
252 |
} |
|
253 |
} |
|
254 |
return id.getFeature(featureType); |
|
255 |
} |
|
256 |
|
|
257 |
public List getFeatureTypes() { |
|
258 |
featureTypes.clear(); |
|
259 |
featureTypes.add(getDefaultFeatureType()); |
|
260 |
return featureTypes; |
|
261 |
} |
|
262 |
|
|
263 |
public Object getDefaultLegend() throws ReadException { |
|
264 |
return this.dwg.getDefaultLegend(); |
|
265 |
} |
|
266 |
|
|
267 |
public boolean canAlterFeatureType() { |
|
268 |
return false; |
|
269 |
} |
|
270 |
|
|
271 |
public String getName() { |
|
272 |
return DATASTORE_NAME; |
|
273 |
} |
|
274 |
|
|
275 |
protected void doOpen() throws OpenException { |
|
276 |
|
|
277 |
} |
|
278 |
|
|
279 |
protected void doClose() throws CloseException { |
|
280 |
this.dwg.close(); |
|
281 |
} |
|
282 |
|
|
283 |
protected void doDispose() throws CloseException { |
|
284 |
super.doDispose(); |
|
285 |
ResourceManager resMan = ResourceManager.getResourceManager(); |
|
286 |
|
|
287 |
try { |
|
288 |
resMan.remove(this.dwg); |
|
289 |
} catch (DataException e1) { |
|
290 |
throw new CloseException(this.getName(),e1); |
|
291 |
} catch (KeyException e) { |
|
292 |
throw new CloseException(this.getName(),e); |
|
293 |
} |
|
294 |
|
|
295 |
this.dwg = null; |
|
296 |
this.defaultFeatureType=null; |
|
297 |
this.metadata=null; |
|
298 |
} |
|
299 |
|
|
300 |
public boolean isEditable() { |
|
301 |
return false; |
|
302 |
} |
|
303 |
|
|
304 |
public IMetadata getMetadata() throws BaseException { |
|
305 |
if (metadata==null){ |
|
306 |
IMetadataManager manager=MetadataManager.getManager(); |
|
307 |
metadata=manager.create(DATASTORE_NAME); |
|
308 |
Envelope extent=this.dwg.getFullExtent(); |
|
309 |
metadata.set("extent",extent); |
|
310 |
String srs=getSRS(); |
|
311 |
metadata.set("srs",srs); |
|
312 |
metadata.set("WithDefaultLegend", Boolean.TRUE); |
|
313 |
} |
|
314 |
if (this.alterMode){ |
|
315 |
Envelope extent=(Envelope)metadata.get("extent"); |
|
316 |
FeatureCollection featureCollection=(FeatureCollection)getDataCollection(); |
|
317 |
if (spatialManager.isFullExtentDirty()){ |
|
318 |
if (!featureCollection.isEmpty()){ |
|
319 |
Iterator featureIterator=featureCollection.iterator(); |
|
320 |
extent = ((Feature)featureIterator.next()).getExtent(); |
|
321 |
while(featureIterator.hasNext()){ |
|
322 |
Feature feature=(Feature)featureIterator.next(); |
|
323 |
Envelope boundExtent=feature.getExtent(); |
|
324 |
if (boundExtent!=null) { |
|
325 |
extent.add(boundExtent); |
|
326 |
} |
|
327 |
} |
|
328 |
} |
|
329 |
} |
|
330 |
metadata.set("extent",extent); |
|
331 |
} |
|
332 |
return metadata; |
|
333 |
} |
|
334 |
private String getSRS() { |
|
335 |
// TODO Auto-generated method stub |
|
336 |
return null; |
|
337 |
} |
|
338 |
|
|
339 |
|
|
340 |
protected FeaturesWriter getFeaturesWriter() { |
|
341 |
return null; |
|
342 |
} |
|
343 |
public DataStoreParameters getParameters() { |
|
344 |
return parameters; |
|
345 |
} |
|
346 |
|
|
347 |
public DataExplorer getExplorer() throws InitializeException { |
|
348 |
DataManager dsm=DataManager.getManager(); |
|
349 |
DataExplorerParameters dsp = dsm.createDataExplorerParameters( |
|
350 |
DWGDataExplorer.DATASOURCE_NAME); |
|
351 |
((FileExplorerParameters)dsp).setSource(dwgParameters.getFile().getParentFile()); |
|
352 |
|
|
353 |
DataExplorer src=null; |
|
354 |
try { |
|
355 |
src = dsm.createDataExplorer(dsp); |
|
356 |
} catch (InitializeException e1) { |
|
357 |
e1.printStackTrace(); |
|
358 |
} |
|
359 |
return src; |
|
360 |
} |
|
361 |
|
|
362 |
|
|
363 |
|
|
364 |
/* (non-Javadoc) |
|
365 |
* @see org.gvsig.fmap.data.feature.FeatureStore#doRefresh() |
|
366 |
*/ |
|
367 |
protected void doRefresh() throws OpenException, InitializeException { |
|
368 |
// TODO Auto-generated method stub |
|
369 |
} |
|
370 |
|
|
371 |
public boolean canWriteGeometry(int gvSIGgeometryType) { |
|
372 |
return false; |
|
373 |
} |
|
374 |
|
|
375 |
public Object getDefaultLabelingStrategy() throws ReadException { |
|
376 |
return this.dwg.getDefaultLabelingStrategy(); |
|
377 |
} |
|
378 |
|
|
379 |
} |
|
0 | 380 |
branches/v2_0_0_prep/libraries/libFMap_data_dwg/src/org/gvsig/fmap/data/feature/file/dwg/DWGDataExplorerParameters.java | ||
---|---|---|
1 |
package org.gvsig.fmap.data.feature.file.dwg; |
|
2 |
|
|
3 |
import org.gvsig.fmap.data.feature.file.FileExplorerParameters; |
|
4 |
|
|
5 |
public class DWGDataExplorerParameters extends FileExplorerParameters { |
|
6 |
|
|
7 |
public String getDataExplorerName() { |
|
8 |
return DWGDataExplorer.DATASOURCE_NAME; |
|
9 |
} |
|
10 |
|
|
11 |
public String getDescription() { |
|
12 |
return "DWG Files"; |
|
13 |
} |
|
14 |
} |
|
0 | 15 |
branches/v2_0_0_prep/libraries/libFMap_data_dwg/src/org/gvsig/fmap/data/feature/file/dwg/operation/DefaultLabelingStrategyOperation.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.data.feature.file.dwg.operation; |
|
29 |
|
|
30 |
import org.gvsig.fmap.data.DataManager; |
|
31 |
import org.gvsig.fmap.data.DataStore; |
|
32 |
import org.gvsig.fmap.data.ReadException; |
|
33 |
import org.gvsig.fmap.data.feature.file.dwg.DWGStore; |
|
34 |
import org.gvsig.fmap.data.operation.DataStoreOperation; |
|
35 |
import org.gvsig.fmap.data.operation.DataStoreOperationContext; |
|
36 |
import org.gvsig.fmap.data.operation.DataStoreOperationException; |
|
37 |
|
|
38 |
public class DefaultLabelingStrategyOperation extends DataStoreOperation { |
|
39 |
|
|
40 |
public static final String NAME = "defaultLabelingStrategy"; |
|
41 |
public static final int CODE = |
|
42 |
DataManager.getManager().registerDataStoreOperation( |
|
43 |
DWGStore.DATASTORE_NAME, |
|
44 |
NAME, |
|
45 |
new DefaultLabelingStrategyOperation()); |
|
46 |
|
|
47 |
public int getOperationIndex() { |
|
48 |
return CODE; |
|
49 |
} |
|
50 |
|
|
51 |
public Object invoke(DataStore store, DataStoreOperationContext ctx) |
|
52 |
throws DataStoreOperationException { |
|
53 |
try { |
|
54 |
return ((DWGStore)store).getDefaultLabelingStrategy(); |
|
55 |
} catch (ReadException e) { |
|
56 |
throw new DataStoreOperationException( |
|
57 |
CODE,NAME,store.getName(),e); |
|
58 |
} |
|
59 |
} |
|
60 |
|
|
61 |
} |
|
0 | 62 |
branches/v2_0_0_prep/libraries/libFMap_data_dwg/src/org/gvsig/fmap/data/feature/file/dwg/operation/DefaultLegendOperation.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.data.feature.file.dwg.operation; |
|
29 |
|
|
30 |
import org.gvsig.fmap.data.DataManager; |
|
31 |
import org.gvsig.fmap.data.DataStore; |
|
32 |
import org.gvsig.fmap.data.ReadException; |
|
33 |
import org.gvsig.fmap.data.feature.file.dwg.DWGStore; |
|
34 |
import org.gvsig.fmap.data.operation.DataStoreOperation; |
|
35 |
import org.gvsig.fmap.data.operation.DataStoreOperationContext; |
|
36 |
import org.gvsig.fmap.data.operation.DataStoreOperationException; |
|
37 |
|
|
38 |
public class DefaultLegendOperation extends DataStoreOperation { |
|
39 |
|
|
40 |
public static final String NAME ="defaultLegend"; |
|
41 |
public static final int CODE = |
|
42 |
DataManager.getManager() |
|
43 |
.registerDataStoreOperation( |
|
44 |
DWGStore.DATASTORE_NAME, |
|
45 |
NAME, |
|
46 |
new DefaultLegendOperation()); |
|
47 |
|
|
48 |
public int getOperationIndex() { |
|
49 |
return CODE; |
|
50 |
} |
|
51 |
|
|
52 |
public Object invoke(DataStore store, DataStoreOperationContext ctx) |
|
53 |
throws DataStoreOperationException { |
|
54 |
try{ |
|
55 |
return ((DWGStore)store).getDefaultLegend(); |
|
56 |
} catch (ReadException e) { |
|
57 |
throw new DataStoreOperationException( |
|
58 |
CODE,NAME,store.getName(),e); |
|
59 |
} |
|
60 |
} |
|
61 |
|
|
62 |
} |
|
0 | 63 |
branches/v2_0_0_prep/libraries/libFMap_data_dwg/src/org/gvsig/fmap/data/feature/file/dwg/operation/Register.java | ||
---|---|---|
1 |
package org.gvsig.fmap.data.feature.file.dwg.operation; |
|
2 |
|
|
3 |
|
|
4 |
public class Register { |
|
5 |
public static void selfRegister() { |
|
6 |
//Register operations |
|
7 |
if (DefaultLegendOperation.CODE < 0){ |
|
8 |
throw new RuntimeException("Register Operation exception"); |
|
9 |
} |
|
10 |
|
|
11 |
if (DefaultLabelingStrategyOperation.CODE < 0){ |
|
12 |
throw new RuntimeException("Register Operation exception"); |
|
13 |
} |
|
14 |
|
|
15 |
} |
|
16 |
} |
|
0 | 17 |
branches/v2_0_0_prep/libraries/libFMap_data_dwg/src/org/gvsig/fmap/data/feature/file/dwg/DWGStoreParameters.java | ||
---|---|---|
1 |
package org.gvsig.fmap.data.feature.file.dwg; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
|
|
5 |
import org.gvsig.fmap.data.AbstractDataStoreParameters; |
|
6 |
import org.gvsig.fmap.data.InitializeException; |
|
7 |
import org.gvsig.fmap.data.feature.file.FileStoreParameters; |
|
8 |
|
|
9 |
import com.iver.utiles.NotExistInXMLEntity; |
|
10 |
import com.iver.utiles.XMLEntity; |
|
11 |
|
|
12 |
|
|
13 |
public class DWGStoreParameters extends AbstractDataStoreParameters implements |
|
14 |
FileStoreParameters { |
|
15 |
private File dwgfile; |
|
16 |
public String getDataStoreName() { |
|
17 |
return DWGStore.DATASTORE_NAME; |
|
18 |
} |
|
19 |
public boolean isValid() { |
|
20 |
return dwgfile != null; |
|
21 |
} |
|
22 |
/* (non-Javadoc) |
|
23 |
* @see org.gvsig.fmap.data.feature.file.FileStoreParameters#getFile() |
|
24 |
*/ |
|
25 |
public File getFile() { |
|
26 |
return dwgfile; |
|
27 |
} |
|
28 |
/* (non-Javadoc) |
|
29 |
* @see org.gvsig.fmap.data.feature.file.FileStoreParameters#setFile(java.io.File) |
|
30 |
*/ |
|
31 |
public void setFile(File aFile) { |
|
32 |
this.dwgfile = aFile; |
|
33 |
} |
|
34 |
public boolean fileAccept(File f) { |
|
35 |
return f.getAbsolutePath().toLowerCase().endsWith(".dwg"); |
|
36 |
} |
|
37 |
|
|
38 |
public String getDescription() { |
|
39 |
return "DWG File"; |
|
40 |
} |
|
41 |
|
|
42 |
|
|
43 |
public XMLEntity getXMLEntity() { |
|
44 |
XMLEntity xmlEntity = super.getXMLEntity(); |
|
45 |
xmlEntity.putProperty("dwgfile", this.dwgfile.getPath()); |
|
46 |
return xmlEntity; |
|
47 |
} |
|
48 |
|
|
49 |
public void loadFromXMLEntity(XMLEntity xmlEntity) |
|
50 |
throws InitializeException { |
|
51 |
try { |
|
52 |
this.dwgfile = new File(xmlEntity.getStringProperty("dwgfile")); |
|
53 |
} catch (NotExistInXMLEntity e) { |
|
54 |
throw new InitializeException("dwnfile property not found", this |
|
55 |
.getDataStoreName()); |
|
56 |
} |
|
57 |
} |
|
58 |
|
|
59 |
} |
|
0 | 60 |
branches/v2_0_0_prep/libraries/libFMap_data_dwg/src/org/gvsig/fmap/data/feature/file/dwg/Register.java | ||
---|---|---|
1 |
package org.gvsig.fmap.data.feature.file.dwg; |
|
2 |
|
|
3 |
import org.gvsig.fmap.data.DataManager; |
|
4 |
|
|
5 |
public class Register { |
|
6 |
public static void selfRegister() { |
|
7 |
DataManager dsm = DataManager.getManager(); |
|
8 |
org.gvsig.fmap.data.feature.expressionevaluator.sqljep.Register |
|
9 |
.selfRegister(); |
|
10 |
dsm.registerDataStore(DWGStore.DATASTORE_NAME, |
|
11 |
DWGStore.class, |
|
12 |
DWGStoreParameters.class |
|
13 |
); |
|
14 |
} |
|
15 |
} |
Also available in: Unified diff