Revision 20719
trunk/libraries/libFMap_dataFile/src-test/org/gvsig/data/datastores/vectorial/file/dgn/DGNTest.java | ||
---|---|---|
7 | 7 |
|
8 | 8 |
import org.gvsig.data.DataManager; |
9 | 9 |
import org.gvsig.data.datastores.vectorial.file.DataStoreTest; |
10 |
import org.gvsig.data.datastores.vectorial.file.dgn.DGNStore; |
|
11 |
import org.gvsig.data.datastores.vectorial.file.dgn.DGNStoreParameters; |
|
12 |
import org.gvsig.data.datastores.vectorial.file.dgn.Register; |
|
13 | 10 |
import org.gvsig.data.exception.CloseException; |
14 | 11 |
import org.gvsig.data.exception.InitializeException; |
15 | 12 |
import org.gvsig.data.exception.OpenException; |
16 | 13 |
import org.gvsig.data.exception.ReadException; |
17 |
import org.gvsig.data.vectorial.FeatureManager; |
|
18 | 14 |
import org.gvsig.data.vectorial.IFeature; |
19 | 15 |
import org.gvsig.data.vectorial.IFeatureAttributeDescriptor; |
20 | 16 |
import org.gvsig.data.vectorial.IFeatureCollection; |
21 | 17 |
import org.gvsig.data.vectorial.IFeatureType; |
22 |
import org.gvsig.data.vectorial.IsNotFeatureSettingException; |
|
23 |
import org.gvsig.data.vectorial.expansionadapter.MemoryExpansionAdapter; |
|
24 | 18 |
|
25 | 19 |
public class DGNTest extends TestCase { |
26 | 20 |
|
... | ... | |
105 | 99 |
e.printStackTrace(); |
106 | 100 |
} |
107 | 101 |
} |
102 |
|
|
103 |
public void test_Resources(){ |
|
104 |
|
|
105 |
DataManager manager = DataManager.getManager(); |
|
106 |
Register.selfRegister(); |
|
107 |
|
|
108 |
DGNStoreParameters parameters; |
|
109 |
|
|
110 |
parameters=(DGNStoreParameters)manager.createDataStoreParameters(DGNStore.DATASTORE_NAME); |
|
111 |
parameters.setFile(file); |
|
112 |
|
|
113 |
|
|
114 |
DataStoreTest.doFileResourceTest(parameters); |
|
115 |
} |
|
116 |
|
|
108 | 117 |
} |
trunk/libraries/libFMap_dataFile/src/org/gvsig/data/datastores/vectorial/file/dxf/DXFResource.java | ||
---|---|---|
32 | 32 |
|
33 | 33 |
import java.awt.Color; |
34 | 34 |
import java.awt.geom.Point2D; |
35 |
import java.io.File; |
|
36 | 35 |
import java.sql.Types; |
37 | 36 |
import java.util.logging.Logger; |
38 | 37 |
|
... | ... | |
48 | 47 |
import org.cresques.px.gml.Polygon; |
49 | 48 |
import org.cresques.px.gml.Polygon3D; |
50 | 49 |
import org.gvsig.data.datastores.vectorial.file.FileMemoryResource; |
51 |
import org.gvsig.data.exception.CloseException; |
|
52 | 50 |
import org.gvsig.data.exception.DataException; |
53 | 51 |
import org.gvsig.data.exception.OpenException; |
54 | 52 |
import org.gvsig.data.exception.ReadException; |
... | ... | |
101 | 99 |
|
102 | 100 |
private VectorialUniqueValueLegend defaultLegend; |
103 | 101 |
|
104 |
private DXFStoreParameters parameters; |
|
105 |
|
|
106 | 102 |
private IFeatureType featureType; |
107 | 103 |
|
108 |
/** |
|
109 |
* @param aFile |
|
110 |
*/ |
|
104 |
|
|
111 | 105 |
DXFResource(DXFStoreParameters params) { |
112 | 106 |
super(params); |
113 |
this.parameters = params; |
|
114 | 107 |
} |
115 | 108 |
|
116 | 109 |
private void initializeFeatureType() { |
... | ... | |
127 | 120 |
* @see org.gvsig.data.datastores.vectorial.file.FileMemoryResource#getFeature(int) |
128 | 121 |
*/ |
129 | 122 |
protected IFeature getFeature(int index) throws ReadException { |
130 |
// TODO Auto-generated method stub |
|
131 | 123 |
return super.getFeature(index); |
132 | 124 |
} |
133 | 125 |
|
... | ... | |
135 | 127 |
* @see org.gvsig.data.datastores.vectorial.file.FileMemoryResource#getFeatureCount() |
136 | 128 |
*/ |
137 | 129 |
protected int getFeatureCount() throws ReadException { |
138 |
// TODO Auto-generated method stub |
|
139 | 130 |
return super.getFeatureCount(); |
140 | 131 |
} |
141 | 132 |
|
... | ... | |
143 | 134 |
* @see org.gvsig.data.datastores.vectorial.file.FileMemoryResource#getFullExtent() |
144 | 135 |
*/ |
145 | 136 |
protected IExtent getFullExtent() throws ReadException { |
146 |
// TODO Auto-generated method stub |
|
147 | 137 |
return super.getFullExtent(); |
148 | 138 |
} |
149 | 139 |
|
... | ... | |
153 | 143 |
protected void load() throws DataException { |
154 | 144 |
float heightText = 10; |
155 | 145 |
DxfFile dxfFeatureFile; |
156 |
DxfFile.EntityFactory featureMaker = new DxfFeatureMaker(parameters.getProjection());
|
|
146 |
DxfFile.EntityFactory featureMaker = new DxfFeatureMaker(((DXFStoreParameters)this.params).getProjection());
|
|
157 | 147 |
DxfFile.VarSettings headerManager = new DxfHeaderManager(); |
158 |
dxfFeatureFile = new DxfFile(parameters.getProjection(), this.getFile().getAbsolutePath(),
|
|
148 |
dxfFeatureFile = new DxfFile(((DXFStoreParameters)this.params).getProjection(), this.getFile().getAbsolutePath(),
|
|
159 | 149 |
featureMaker, headerManager); |
160 | 150 |
try { |
161 | 151 |
dxfFeatureFile.load(); |
... | ... | |
287 | 277 |
Point point = (Point) fea.getGeometry(); |
288 | 278 |
Point2D pto = new Point2D.Double(); |
289 | 279 |
pto = point.get(0); |
290 |
FShape nuevoShp; |
|
280 |
// FShape nuevoShp;
|
|
291 | 281 |
if (point.isTextPoint()) { |
292 | 282 |
feature.set(ID_FIELD_ID,i); |
293 | 283 |
// auxRow[ID_FIELD_ID] = new Integer(i); |
... | ... | |
386 | 376 |
.getGeometry(); |
387 | 377 |
Point3D pto = new Point3D(); |
388 | 378 |
pto = point.getPoint3D(0); |
389 |
FShape nuevoShp; |
|
379 |
// FShape nuevoShp;
|
|
390 | 380 |
if (point.isTextPoint()) { |
391 | 381 |
feature.set(ID_FIELD_ID,i); |
392 | 382 |
// auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
... | ... | |
778 | 768 |
return 1; |
779 | 769 |
} |
780 | 770 |
|
771 |
/* (non-Javadoc) |
|
772 |
* @see org.gvsig.data.datastores.vectorial.file.FileResource#editing() |
|
773 |
*/ |
|
774 |
protected void editing() { |
|
775 |
super.editing(); |
|
776 |
} |
|
777 |
|
|
778 |
/* (non-Javadoc) |
|
779 |
* @see org.gvsig.data.datastores.vectorial.file.FileResource#isEditing() |
|
780 |
*/ |
|
781 |
protected boolean isEditing() { |
|
782 |
return super.isEditing(); |
|
783 |
} |
|
784 |
|
|
785 |
/* (non-Javadoc) |
|
786 |
* @see org.gvsig.data.datastores.vectorial.file.FileResource#stopEditing() |
|
787 |
*/ |
|
788 |
protected void stopEditing() { |
|
789 |
super.stopEditing(); |
|
790 |
} |
|
791 |
|
|
781 | 792 |
} |
782 | 793 |
|
trunk/libraries/libFMap_dataFile/src/org/gvsig/data/datastores/vectorial/file/dxf/DXFFeature.java | ||
---|---|---|
4 | 4 |
import org.gvsig.data.exception.ReadException; |
5 | 5 |
import org.gvsig.data.vectorial.IFeature; |
6 | 6 |
import org.gvsig.data.vectorial.IFeatureType; |
7 |
import org.gvsig.data.vectorial.IsNotFeatureSettingException; |
|
8 | 7 |
import org.gvsig.data.vectorial.MemoryFeature; |
9 | 8 |
|
10 | 9 |
public class DXFFeature extends MemoryFeature{ |
trunk/libraries/libFMap_dataFile/src/org/gvsig/data/datastores/vectorial/file/dxf/DXFStore.java | ||
---|---|---|
1 | 1 |
package org.gvsig.data.datastores.vectorial.file.dxf; |
2 | 2 |
|
3 |
import java.awt.Color; |
|
4 |
import java.awt.geom.Point2D; |
|
5 |
import java.io.File; |
|
6 | 3 |
import java.lang.ref.WeakReference; |
7 | 4 |
import java.security.KeyException; |
8 |
import java.sql.Types; |
|
9 | 5 |
import java.util.ArrayList; |
10 | 6 |
import java.util.Collection; |
11 | 7 |
import java.util.Comparator; |
12 | 8 |
import java.util.Iterator; |
13 | 9 |
import java.util.List; |
14 | 10 |
import java.util.TreeSet; |
15 |
import java.util.logging.Logger; |
|
16 | 11 |
|
17 |
import org.cresques.cts.IProjection; |
|
18 |
import org.cresques.geo.Point3D; |
|
19 |
import org.cresques.io.DxfFile; |
|
20 |
import org.cresques.px.IObjList; |
|
21 |
import org.cresques.px.dxf.DxfFeatureMaker; |
|
22 |
import org.cresques.px.dxf.DxfHeaderManager; |
|
23 |
import org.cresques.px.gml.Feature; |
|
24 |
import org.cresques.px.gml.LineString; |
|
25 |
import org.cresques.px.gml.LineString3D; |
|
26 |
import org.cresques.px.gml.Point; |
|
27 |
import org.cresques.px.gml.Polygon; |
|
28 |
import org.cresques.px.gml.Polygon3D; |
|
29 | 12 |
import org.gvsig.data.DataManager; |
30 | 13 |
import org.gvsig.data.IDataCollection; |
31 | 14 |
import org.gvsig.data.IDataExplorer; |
... | ... | |
59 | 42 |
import org.gvsig.metadata.IMetadataManager; |
60 | 43 |
import org.gvsig.metadata.MetadataManager; |
61 | 44 |
|
62 |
import com.iver.cit.gvsig.fmap.core.FPoint2D; |
|
63 |
import com.iver.cit.gvsig.fmap.core.FShape; |
|
64 |
import com.iver.cit.gvsig.fmap.core.GeneralPathX; |
|
65 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
66 |
import com.iver.cit.gvsig.fmap.core.ShapeFactory; |
|
67 |
import com.iver.cit.gvsig.fmap.core.SymbologyFactory; |
|
68 |
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
|
69 |
import com.iver.cit.gvsig.fmap.rendering.LegendFactory; |
|
70 |
import com.iver.cit.gvsig.fmap.rendering.styling.labeling.AttrInTableLabelingStrategy; |
|
71 |
|
|
72 | 45 |
public class DXFStore extends FeatureStore{ |
73 | 46 |
public static String DATASTORE_NAME = "DXFStore"; |
74 | 47 |
|
75 | 48 |
private IFeatureType featureType; |
76 | 49 |
private List featureTypes = new ArrayList(); |
77 |
private File dxfFile; |
|
78 | 50 |
protected IMetadata metadata; |
79 | 51 |
|
80 |
private IProjection projection; |
|
52 |
|
|
81 | 53 |
private DXFStoreParameters dxfParameters; |
82 | 54 |
|
83 | 55 |
private DXFResource dxf; |
... | ... | |
85 | 57 |
public void init(IDataStoreParameters parameters) throws InitializeException { |
86 | 58 |
|
87 | 59 |
dxfParameters=(DXFStoreParameters)parameters; |
88 |
dxfFile=((DXFStoreParameters)parameters).getFile(); |
|
89 |
projection=((DXFStoreParameters)parameters).getProjection(); |
|
90 | 60 |
|
91 | 61 |
DXFResource tmpResource = new DXFResource(dxfParameters); |
92 | 62 |
|
... | ... | |
205 | 175 |
IFeaturesWriter writer = getFeaturesWriter(); |
206 | 176 |
writer.init(this); |
207 | 177 |
writer.updateFeatureType(featureType); |
178 |
this.dxf.editing(); |
|
208 | 179 |
writer.preProcess(); |
209 | 180 |
Collection collection=getDataCollection(); |
210 | 181 |
Iterator iterator=collection.iterator(); |
... | ... | |
214 | 185 |
writer.insertFeature(feature); |
215 | 186 |
} |
216 | 187 |
writer.postProcess(); |
188 |
this.dxf.stopEditing(); |
|
217 | 189 |
this.dxf.changed(this); |
218 | 190 |
|
219 | 191 |
} |
... | ... | |
318 | 290 |
} |
319 | 291 |
|
320 | 292 |
public boolean canAlterFeatureType() { |
321 |
return true;
|
|
293 |
return false;
|
|
322 | 294 |
} |
323 | 295 |
|
324 | 296 |
public String getName() { |
... | ... | |
342 | 314 |
} catch (DataException e1) { |
343 | 315 |
throw new CloseException(this.getName(),e1); |
344 | 316 |
} catch (KeyException e) { |
345 |
// TODO Auto-generated catch block |
|
346 | 317 |
throw new CloseException(this.getName(),e); |
347 | 318 |
} |
348 | 319 |
|
... | ... | |
352 | 323 |
} |
353 | 324 |
|
354 | 325 |
public boolean isEditable() { |
355 |
return false;
|
|
326 |
return this.dxf.isEditable();
|
|
356 | 327 |
} |
357 | 328 |
|
358 | 329 |
public IMetadata getMetadata() throws BaseException { |
trunk/libraries/libFMap_dataFile/src/org/gvsig/data/datastores/vectorial/file/dgn/DGNStore.java | ||
---|---|---|
1 | 1 |
package org.gvsig.data.datastores.vectorial.file.dgn; |
2 | 2 |
|
3 |
import java.awt.geom.AffineTransform; |
|
4 |
import java.awt.geom.Arc2D; |
|
5 | 3 |
import java.io.File; |
6 | 4 |
import java.lang.ref.WeakReference; |
7 |
import java.sql.Types;
|
|
5 |
import java.security.KeyException;
|
|
8 | 6 |
import java.util.ArrayList; |
9 | 7 |
import java.util.Collection; |
10 | 8 |
import java.util.Comparator; |
... | ... | |
17 | 15 |
import org.gvsig.data.IDataExplorer; |
18 | 16 |
import org.gvsig.data.IDataExplorerParameters; |
19 | 17 |
import org.gvsig.data.IDataStoreParameters; |
18 |
import org.gvsig.data.ResourceManager; |
|
20 | 19 |
import org.gvsig.data.datastores.vectorial.IFeaturesWriter; |
21 |
import org.gvsig.data.datastores.vectorial.base.MemoryStore; |
|
22 | 20 |
import org.gvsig.data.datastores.vectorial.file.DataExplorerFileParameters; |
23 |
import org.gvsig.data.datastores.vectorial.file.dbf.DBFDataExplorer; |
|
24 |
import org.gvsig.data.datastores.vectorial.file.dgn.utils.DGNElemArc; |
|
25 |
import org.gvsig.data.datastores.vectorial.file.dgn.utils.DGNElemCellHeader; |
|
26 |
import org.gvsig.data.datastores.vectorial.file.dgn.utils.DGNElemComplexHeader; |
|
27 |
import org.gvsig.data.datastores.vectorial.file.dgn.utils.DGNElemCore; |
|
28 |
import org.gvsig.data.datastores.vectorial.file.dgn.utils.DGNElemMultiPoint; |
|
29 |
import org.gvsig.data.datastores.vectorial.file.dgn.utils.DGNElemText; |
|
30 |
import org.gvsig.data.datastores.vectorial.file.dgn.utils.DGNFileHeader; |
|
31 |
import org.gvsig.data.datastores.vectorial.file.dgn.utils.DGNReader; |
|
32 | 21 |
import org.gvsig.data.exception.CloseException; |
22 |
import org.gvsig.data.exception.DataException; |
|
33 | 23 |
import org.gvsig.data.exception.InitializeException; |
34 | 24 |
import org.gvsig.data.exception.OpenException; |
35 | 25 |
import org.gvsig.data.exception.ReadException; |
36 | 26 |
import org.gvsig.data.exception.WriteException; |
37 | 27 |
import org.gvsig.data.spatialprovisional.IExtent; |
38 | 28 |
import org.gvsig.data.vectorial.AttributeDescriptor; |
29 |
import org.gvsig.data.vectorial.FeatureStore; |
|
39 | 30 |
import org.gvsig.data.vectorial.FeatureType; |
40 |
import org.gvsig.data.vectorial.Feature; |
|
41 |
import org.gvsig.data.vectorial.FeatureStoreNotification; |
|
42 | 31 |
import org.gvsig.data.vectorial.IFeature; |
43 | 32 |
import org.gvsig.data.vectorial.IFeatureAttributeDescriptor; |
44 | 33 |
import org.gvsig.data.vectorial.IFeatureCollection; |
45 | 34 |
import org.gvsig.data.vectorial.IFeatureID; |
46 | 35 |
import org.gvsig.data.vectorial.IFeatureType; |
47 | 36 |
import org.gvsig.data.vectorial.IsNotAttributeSettingException; |
48 |
import org.gvsig.data.vectorial.IsNotFeatureSettingException; |
|
49 | 37 |
import org.gvsig.data.vectorial.expressionevaluator.FeatureComparator; |
50 | 38 |
import org.gvsig.data.vectorial.expressionevaluator.FeatureFilter; |
51 | 39 |
import org.gvsig.exceptions.BaseException; |
... | ... | |
53 | 41 |
import org.gvsig.metadata.IMetadataManager; |
54 | 42 |
import org.gvsig.metadata.MetadataManager; |
55 | 43 |
|
56 |
import com.iver.cit.gvsig.fmap.core.FShape; |
|
57 |
import com.iver.cit.gvsig.fmap.core.GeneralPathX; |
|
58 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
59 |
import com.iver.cit.gvsig.fmap.core.ShapeFactory; |
|
60 |
import com.iver.cit.gvsig.fmap.core.SymbologyFactory; |
|
61 |
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
|
62 |
import com.iver.cit.gvsig.fmap.rendering.LegendFactory; |
|
63 |
import com.iver.cit.gvsig.fmap.rendering.VectorialUniqueValueLegend; |
|
64 |
import com.iver.cit.gvsig.fmap.rendering.styling.labeling.AttrInTableLabelingStrategy; |
|
65 |
|
|
66 |
public class DGNStore extends MemoryStore{ |
|
44 |
public class DGNStore extends FeatureStore{ |
|
67 | 45 |
public static String DATASTORE_NAME = "DGNStore"; |
68 |
private final int ID_FIELD_ID = 0; |
|
69 |
private final int ID_FIELD_ENTITY = 1; |
|
70 |
private final int ID_FIELD_LAYER = 2; |
|
71 |
private final int ID_FIELD_COLOR = 3; |
|
72 |
private final int ID_FIELD_HEIGHTTEXT = 4; |
|
73 |
private final int ID_FIELD_ROTATIONTEXT = 5; |
|
74 |
private final int ID_FIELD_TEXT = 6; |
|
75 |
private final int ID_FIELD_GEOMETRY = 7; |
|
76 | 46 |
|
77 | 47 |
private List featureTypes = new ArrayList();//<IFeatureType> |
78 | 48 |
private IFeatureType featureType; |
79 | 49 |
protected IMetadata metadata; |
80 | 50 |
private DGNStoreParameters dgnParameters=null; |
81 |
private File dgnFile; |
|
82 |
private AttrInTableLabelingStrategy labeling; |
|
83 |
private VectorialUniqueValueLegend defaultLegend; |
|
84 | 51 |
|
52 |
private DGNResource dgn; |
|
53 |
|
|
85 | 54 |
public void init(IDataStoreParameters parameters) throws InitializeException { |
86 |
super.init(parameters); |
|
55 |
|
|
87 | 56 |
dgnParameters=(DGNStoreParameters)parameters; |
88 |
dgnFile=dgnParameters.getFile(); |
|
57 |
|
|
58 |
DGNResource tmpResource = new DGNResource(dgnParameters); |
|
59 |
|
|
60 |
ResourceManager resMan = ResourceManager.getResourceManager(); |
|
61 |
|
|
62 |
try { |
|
63 |
this.dgn = (DGNResource)resMan.addResource(tmpResource); |
|
64 |
} catch (DataException e1) { |
|
65 |
throw new InitializeException(this.getName(),e1); |
|
66 |
} |
|
67 |
|
|
68 |
super.init(parameters,this.dgn); |
|
69 |
|
|
70 |
try { |
|
71 |
this.featureType = this.dgn.getFeatureType(); |
|
72 |
} catch (ReadException e) { |
|
73 |
throw new InitializeException(this.getName(),e); |
|
74 |
} |
|
75 |
|
|
89 | 76 |
} |
90 | 77 |
|
91 | 78 |
static IFeatureType newFeatureType(){ |
... | ... | |
178 | 165 |
|
179 | 166 |
} |
180 | 167 |
|
181 |
private void initializeFeatureType() { |
|
182 |
featureType = newFeatureType(); |
|
183 |
} |
|
184 |
|
|
185 | 168 |
protected void doFinishEdition() throws WriteException, ReadException{ |
186 |
IFeaturesWriter writer = getFeaturesWriter(); |
|
187 |
writer.init(this); |
|
188 |
writer.updateFeatureType(featureType); |
|
189 |
writer.preProcess(); |
|
190 |
Collection collection=getDataCollection(); |
|
191 |
Iterator iterator=collection.iterator(); |
|
192 |
IFeature feature; |
|
193 |
while (iterator.hasNext()) { |
|
194 |
feature= (IFeature) iterator.next(); |
|
195 |
writer.insertFeature(feature); |
|
196 |
} |
|
197 |
writer.postProcess(); |
|
198 | 169 |
|
199 | 170 |
} |
200 | 171 |
|
... | ... | |
209 | 180 |
if (filter!=null){ |
210 | 181 |
parser = new FeatureFilter(filter,type); |
211 | 182 |
} |
212 |
ArrayList originalFeatures=this.getFeatures(); |
|
183 |
// ArrayList originalFeatures=this.getFeatures();
|
|
213 | 184 |
int num=0; |
214 | 185 |
if (featureManager!=null){ |
215 | 186 |
num=featureManager.getNum(); |
216 | 187 |
} |
217 |
int originalSize=originalFeatures.size();
|
|
188 |
int originalSize=this.dgn.getFeatureCount();
|
|
218 | 189 |
Collection allFeatures=null; |
219 | 190 |
if (order!=null){ |
220 | 191 |
Comparator comparator = new FeatureComparator(type,order); |
... | ... | |
222 | 193 |
}else{ |
223 | 194 |
allFeatures=new ArrayList(); |
224 | 195 |
} |
225 |
int j=0; |
|
196 |
// int j=0;
|
|
226 | 197 |
for (int i = 0; i < originalSize+num; i++) { |
227 | 198 |
IFeature feature=null; |
228 |
if (i<this.getFeatureCount()){ |
|
229 |
feature=this.getFeature(i); |
|
199 |
if (i<this.dgn.getFeatureCount()){
|
|
200 |
feature=this.dgn.getFeature(i);
|
|
230 | 201 |
}else{ |
231 | 202 |
feature=featureManager.getFeature(i-originalSize,this); |
232 | 203 |
} |
... | ... | |
278 | 249 |
} |
279 | 250 |
|
280 | 251 |
public boolean isWithDefaultLegend() { |
281 |
return false;
|
|
252 |
return true;
|
|
282 | 253 |
} |
283 | 254 |
|
284 |
public Object getDefaultLegend() { |
|
285 |
return null;
|
|
255 |
public Object getDefaultLegend() throws ReadException {
|
|
256 |
return this.dgn.getDefaultLegend();
|
|
286 | 257 |
} |
287 | 258 |
|
288 | 259 |
public Object getDefaultLabelingStrategy() { |
... | ... | |
290 | 261 |
} |
291 | 262 |
|
292 | 263 |
public boolean canAlterFeatureType() { |
293 |
return true;
|
|
264 |
return false;
|
|
294 | 265 |
} |
295 | 266 |
|
296 | 267 |
public String getName() { |
... | ... | |
298 | 269 |
} |
299 | 270 |
|
300 | 271 |
protected void doOpen() throws OpenException { |
301 |
float heightText = 10; |
|
302 |
// attr.setLoadedInMemory(true); |
|
303 |
initializeFeatureType(); |
|
304 |
DGNReader m_DgnReader; |
|
305 |
try { |
|
306 |
m_DgnReader = new DGNReader(dgnFile.getAbsolutePath()); |
|
307 |
} catch (ReadException e) { |
|
308 |
throw new OpenException(getName(),e); |
|
309 |
} |
|
310 | 272 |
|
311 |
try{ |
|
312 |
// Value[] auxRow = new Value[7]; |
|
313 |
// Value[] cellRow = new Value[7]; |
|
314 |
// Value[] complexRow = new Value[7]; |
|
315 |
DGNFeature auxFeature=new DGNFeature(featureType,true); |
|
316 |
auxFeature.loading(); |
|
317 |
DGNFeature cellFeature=new DGNFeature(featureType,false); |
|
318 |
cellFeature.loading(); |
|
319 |
DGNFeature complexFeature=new DGNFeature(featureType,false); |
|
320 |
complexFeature.loading(); |
|
321 |
initializeFeatureType(); |
|
322 |
// ArrayList arrayFields = new ArrayList(); |
|
323 |
// arrayFields.add("ID"); |
|
324 |
// arrayFields.add("Entity"); |
|
325 |
// arrayFields.add("Layer"); |
|
326 |
// arrayFields.add("Color"); |
|
327 |
// arrayFields.add("HeightText"); |
|
328 |
// arrayFields.add("RotationText"); |
|
329 |
// arrayFields.add("Text"); |
|
330 |
|
|
331 |
// getTableModel().setColumnIdentifiers(arrayFields.toArray()); |
|
332 |
|
|
333 |
// jaume |
|
334 |
labeling = new AttrInTableLabelingStrategy(); |
|
335 |
((AttrInTableLabelingStrategy) labeling).setTextFieldId(featureType.getFieldIndex("Text")); |
|
336 |
((AttrInTableLabelingStrategy) labeling).setRotationFieldId(featureType.getFieldIndex("RotationText")); |
|
337 |
((AttrInTableLabelingStrategy) labeling).setHeightFieldId(featureType.getFieldIndex("HeightText")); |
|
338 |
((AttrInTableLabelingStrategy) labeling).setUnit(1); //MapContext.NAMES[1] (meters) |
|
339 |
|
|
340 |
|
|
341 |
// Ahora las rellenamos. |
|
342 |
// FShape aux; |
|
343 |
boolean bElementoCompuesto = false; |
|
344 |
boolean bEsPoligono = false; |
|
345 |
boolean bInsideCell = false; |
|
346 |
boolean bFirstHoleEntity = false; |
|
347 |
boolean bConnect = false; // Se usa para que los pol?gonos cierren bien cuando son formas compuestas |
|
348 |
// int contadorSubElementos = 0; |
|
349 |
// int numSubElementos = 0; |
|
350 |
int complex_index_fill_color = -1; |
|
351 |
int nClass; // Para filtrar los elementos de construcci?n, etc. |
|
352 |
GeneralPathX elementoCompuesto = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD); |
|
353 |
|
|
354 |
for (int id = 0; id < m_DgnReader.getNumEntities(); id++) { |
|
355 |
|
|
356 |
// System.out.println("Elemento " + id + " de " + m_DgnReader.getNumEntities()); |
|
357 |
m_DgnReader.DGNGotoElement(id); |
|
358 |
|
|
359 |
DGNElemCore elemento = m_DgnReader.DGNReadElement(); |
|
360 |
nClass = 0; |
|
361 |
// auxRow[ID_FIELD_HEIGHTTEXT] = ValueFactory.createValue(0); |
|
362 |
// auxRow[ID_FIELD_ROTATIONTEXT] = ValueFactory.createValue(0); |
|
363 |
// auxRow[ID_FIELD_TEXT] = ValueFactory.createNullValue(); |
|
364 |
|
|
365 |
if (elemento.properties != 0) { |
|
366 |
nClass = elemento.properties & DGNFileHeader.DGNPF_CLASS; |
|
367 |
} |
|
368 |
|
|
369 |
if ((elemento != null) && (elemento.deleted == 0) && (nClass == 0)) //Leer un elemento |
|
370 |
{ |
|
371 |
// aux = null; |
|
372 |
|
|
373 |
// if ((elemento.element_id > 3800) && (elemento.element_id < 3850)) |
|
374 |
// m_DgnReader.DGNDumpElement(m_DgnReader.getInfo(),elemento,""); |
|
375 |
if ((elemento.stype == DGNFileHeader.DGNST_MULTIPOINT) || |
|
376 |
(elemento.stype == DGNFileHeader.DGNST_ARC) || |
|
377 |
(elemento.stype == DGNFileHeader.DGNST_CELL_HEADER) || |
|
378 |
(elemento.stype == DGNFileHeader.DGNST_SHARED_CELL_DEFN) || |
|
379 |
(elemento.stype == DGNFileHeader.DGNST_COMPLEX_HEADER)) { |
|
380 |
if (elemento.complex != 0) { |
|
381 |
bElementoCompuesto = true; |
|
382 |
} else { |
|
383 |
if (bElementoCompuesto) { |
|
384 |
if (bInsideCell) { |
|
385 |
auxFeature.set(ID_FIELD_ENTITY,cellFeature.get(ID_FIELD_ENTITY)); |
|
386 |
// auxRow[ID_FIELD_ENTITY] = cellRow[ID_FIELD_ENTITY]; |
|
387 |
} else { |
|
388 |
auxFeature=complexFeature; |
|
389 |
// auxRow = complexRow; |
|
390 |
} |
|
391 |
|
|
392 |
// System.err.println("Entidad compuesta. bInsideCell = " + bInsideCell + " auxRow = " + auxRow[ID_FIELD_ENTITY]); |
|
393 |
IGeometry geom=ShapeFactory.createPolyline2D(elementoCompuesto); |
|
394 |
auxFeature.set(ID_FIELD_GEOMETRY,geom); |
|
395 |
// auxFeature.setDefaultGeometry(geom); |
|
396 |
addDGNFeature(auxFeature); |
|
397 |
// addShape(new FPolyline2D(elementoCompuesto), auxRow); |
|
398 |
|
|
399 |
if (bEsPoligono) { |
|
400 |
if (complex_index_fill_color != -1) { |
|
401 |
auxFeature.set(ID_FIELD_COLOR,complex_index_fill_color); |
|
402 |
// auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(complex_index_fill_color); |
|
403 |
} |
|
404 |
geom=ShapeFactory.createPolygon2D(elementoCompuesto); |
|
405 |
auxFeature.set(ID_FIELD_GEOMETRY,geom); |
|
406 |
// auxFeature.setDefaultGeometry(geom); |
|
407 |
addDGNFeature(auxFeature); |
|
408 |
// addShape(new FPolygon2D(elementoCompuesto), auxRow); |
|
409 |
} |
|
410 |
|
|
411 |
elementoCompuesto = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD); |
|
412 |
} |
|
413 |
|
|
414 |
// System.err.println("Entidad simple"); |
|
415 |
bElementoCompuesto = false; |
|
416 |
bEsPoligono = false; |
|
417 |
bConnect = false; |
|
418 |
|
|
419 |
// elementoCompuesto = new GeneralPathX(); |
|
420 |
bInsideCell = false; |
|
421 |
} |
|
422 |
} |
|
423 |
|
|
424 |
switch (elemento.stype) { |
|
425 |
case DGNFileHeader.DGNST_SHARED_CELL_DEFN: |
|
426 |
bInsideCell = true; |
|
427 |
cellFeature.set(ID_FIELD_ID,elemento.element_id); |
|
428 |
// cellRow[ID_FIELD_ID] = ValueFactory.createValue(elemento.element_id); |
|
429 |
cellFeature.set(ID_FIELD_LAYER,elemento.level); |
|
430 |
// cellRow[ID_FIELD_LAYER] = ValueFactory.createValue(elemento.level); |
|
431 |
cellFeature.set(ID_FIELD_COLOR,elemento.color); |
|
432 |
// cellRow[ID_FIELD_COLOR] = ValueFactory.createValue(elemento.color); |
|
433 |
cellFeature.set(ID_FIELD_ENTITY,"Shared Cell"); |
|
434 |
// cellRow[ID_FIELD_ENTITY] = ValueFactory.createValue( |
|
435 |
// "Shared Cell"); |
|
436 |
|
|
437 |
break; |
|
438 |
|
|
439 |
case DGNFileHeader.DGNST_CELL_HEADER: |
|
440 |
bInsideCell = true; |
|
441 |
|
|
442 |
DGNElemCellHeader psCellHeader = (DGNElemCellHeader) elemento; |
|
443 |
cellFeature.set(ID_FIELD_ID,elemento.element_id); |
|
444 |
// cellRow[ID_FIELD_ID] = ValueFactory.createValue(elemento.element_id); |
|
445 |
cellFeature.set(ID_FIELD_LAYER,elemento.level); |
|
446 |
// cellRow[ID_FIELD_LAYER] = ValueFactory.createValue(elemento.level); |
|
447 |
cellFeature.set(ID_FIELD_COLOR,elemento.color); |
|
448 |
// cellRow[ID_FIELD_COLOR] = ValueFactory.createValue(elemento.color); |
|
449 |
cellFeature.set(ID_FIELD_ENTITY,"Cell"); |
|
450 |
// cellRow[ID_FIELD_ENTITY] = ValueFactory.createValue( |
|
451 |
// "Cell"); |
|
452 |
complex_index_fill_color = m_DgnReader.DGNGetShapeFillInfo(elemento); |
|
453 |
|
|
454 |
// System.err.println("Cell Header " + complex_index_fill_color); |
|
455 |
break; |
|
456 |
|
|
457 |
case DGNFileHeader.DGNST_COMPLEX_HEADER: |
|
458 |
|
|
459 |
// bElementoCompuesto = true; |
|
460 |
// System.err.println("Complex Header"); |
|
461 |
// contadorSubElementos = 0; |
|
462 |
|
|
463 |
DGNElemComplexHeader psComplexHeader = (DGNElemComplexHeader) elemento; |
|
464 |
// numSubElementos = psComplexHeader.numelems; |
|
465 |
complexFeature.set(ID_FIELD_ID,elemento.element_id); |
|
466 |
// complexRow[ID_FIELD_ID] = ValueFactory.createValue(elemento.element_id); |
|
467 |
complexFeature.set(ID_FIELD_LAYER,elemento.level); |
|
468 |
// complexRow[ID_FIELD_LAYER] = ValueFactory.createValue(elemento.level); |
|
469 |
complexFeature.set(ID_FIELD_COLOR,elemento.color); |
|
470 |
// complexRow[ID_FIELD_COLOR] = ValueFactory.createValue(elemento.color); |
|
471 |
complexFeature.set(ID_FIELD_ENTITY,"Complex"); |
|
472 |
// complexRow[ID_FIELD_ENTITY] = ValueFactory.createValue( |
|
473 |
// "Complex"); |
|
474 |
|
|
475 |
if (psComplexHeader.type == DGNFileHeader.DGNT_COMPLEX_SHAPE_HEADER) { |
|
476 |
bEsPoligono = true; |
|
477 |
|
|
478 |
// Si es un agujero, no conectamos con el anterior |
|
479 |
if ((psComplexHeader.properties & 0x8000) != 0) { |
|
480 |
bFirstHoleEntity = true; |
|
481 |
} else { |
|
482 |
// Miramos si tiene color de relleno |
|
483 |
// complex_index_fill_color = -1; |
|
484 |
// if (elemento.attr_bytes > 0) { |
|
485 |
complex_index_fill_color = m_DgnReader.DGNGetShapeFillInfo(elemento); |
|
486 |
|
|
487 |
// System.err.println("complex shape fill color = " + elemento.color); |
|
488 |
// } |
|
489 |
} |
|
490 |
|
|
491 |
bConnect = true; |
|
492 |
} else { |
|
493 |
bEsPoligono = false; |
|
494 |
bConnect = false; |
|
495 |
} |
|
496 |
|
|
497 |
break; |
|
498 |
|
|
499 |
case DGNFileHeader.DGNST_MULTIPOINT: |
|
500 |
|
|
501 |
// OJO: Si lo que viene en este multipoint es un elemento con type=11 (curve), se trata de una "parametric |
|
502 |
// spline curve". La vamos a tratar como si no fuera curva, pero seg?n la documentaci?n, los 2 primeros puntos |
|
503 |
// y los 2 ?ltimos puntos definen "endpoint derivatives" y NO se muestran. |
|
504 |
// TODAV?A HAY UN PEQUE?O FALLO CON EL FICHERO dgn-sample.dgn, pero lo dejo por ahora. |
|
505 |
// Es posible que tenga que ver con lo de los arcos (arco distorsionado), que |
|
506 |
// todav?a no est? metido. |
|
507 |
DGNElemMultiPoint psLine = (DGNElemMultiPoint) elemento; |
|
508 |
auxFeature.set(ID_FIELD_ID,elemento.element_id); |
|
509 |
// auxRow[ID_FIELD_ID] = ValueFactory.createValue(elemento.element_id); |
|
510 |
auxFeature.set(ID_FIELD_ENTITY,"Multipoint"); |
|
511 |
// auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue( |
|
512 |
// "Multipoint"); |
|
513 |
auxFeature.set(ID_FIELD_LAYER,elemento.level); |
|
514 |
// auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(elemento.level); |
|
515 |
auxFeature.set(ID_FIELD_COLOR,elemento.color); |
|
516 |
// auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(elemento.color); |
|
517 |
|
|
518 |
if ((psLine.num_vertices == 2) && |
|
519 |
(psLine.vertices[0].x == psLine.vertices[1].x) && |
|
520 |
(psLine.vertices[0].y == psLine.vertices[1].y)) { |
|
521 |
auxFeature.set(ID_FIELD_ENTITY,"Point"); |
|
522 |
// auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue( |
|
523 |
// "Point"); |
|
524 |
|
|
525 |
IGeometry geom=ShapeFactory.createPoint3D(psLine.vertices[0].x, |
|
526 |
psLine.vertices[0].y, psLine.vertices[0].z); |
|
527 |
auxFeature.set(ID_FIELD_GEOMETRY,geom); |
|
528 |
// auxFeature.setDefaultGeometry(geom); |
|
529 |
addDGNFeature(auxFeature); |
|
530 |
|
|
531 |
// addShape(new FPoint3D(psLine.vertices[0].x, |
|
532 |
// psLine.vertices[0].y, psLine.vertices[0].z), |
|
533 |
// auxRow); |
|
534 |
} else { |
|
535 |
GeneralPathX elShape = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD); |
|
536 |
|
|
537 |
if (psLine.type == DGNFileHeader.DGNT_CURVE) { |
|
538 |
psLine.num_vertices = psLine.num_vertices - 4; |
|
539 |
|
|
540 |
for (int aux_n = 0; |
|
541 |
aux_n < psLine.num_vertices; aux_n++) { |
|
542 |
psLine.vertices[aux_n] = psLine.vertices[aux_n + |
|
543 |
2]; |
|
544 |
} |
|
545 |
} |
|
546 |
|
|
547 |
if ((psLine.type == DGNFileHeader.DGNT_SHAPE) && |
|
548 |
((psLine.properties & 0x8000) != 0)) { |
|
549 |
// Invertimos el orden porque es un agujero |
|
550 |
elShape.moveTo(psLine.vertices[psLine.num_vertices - |
|
551 |
1].x, |
|
552 |
psLine.vertices[psLine.num_vertices - 1].y); |
|
553 |
|
|
554 |
for (int i = psLine.num_vertices - 2; i >= 0; |
|
555 |
i--) |
|
556 |
elShape.lineTo(psLine.vertices[i].x, |
|
557 |
psLine.vertices[i].y); |
|
558 |
} else { |
|
559 |
elShape.moveTo(psLine.vertices[0].x, |
|
560 |
psLine.vertices[0].y); |
|
561 |
|
|
562 |
for (int i = 1; i < psLine.num_vertices; i++) |
|
563 |
elShape.lineTo(psLine.vertices[i].x, |
|
564 |
psLine.vertices[i].y); |
|
565 |
} |
|
566 |
|
|
567 |
if ((psLine.vertices[0].x == psLine.vertices[psLine.num_vertices - |
|
568 |
1].x) && |
|
569 |
(psLine.vertices[0].y == psLine.vertices[psLine.num_vertices - |
|
570 |
1].y)) { |
|
571 |
// Lo a?adimos tambi?n como pol?gono |
|
572 |
bEsPoligono = true; |
|
573 |
|
|
574 |
// Miramos si tiene color de relleno |
|
575 |
if (elemento.attr_bytes > 0) { |
|
576 |
elemento.color = m_DgnReader.DGNGetShapeFillInfo(elemento); |
|
577 |
|
|
578 |
// System.err.println("fill color = " + elemento.color); |
|
579 |
if (elemento.color != -1) { |
|
580 |
auxFeature.set(ID_FIELD_COLOR,elemento.color); |
|
581 |
// auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(elemento.color); |
|
582 |
} |
|
583 |
} |
|
584 |
|
|
585 |
if (elemento.complex == 0) { |
|
586 |
IGeometry geom=ShapeFactory.createPolygon2D(elShape); |
|
587 |
auxFeature.set(ID_FIELD_GEOMETRY,geom); |
|
588 |
// auxFeature.setDefaultGeometry(geom); |
|
589 |
addDGNFeature(auxFeature); |
|
590 |
// addShape(new FPolygon2D(elShape), auxRow); |
|
591 |
} |
|
592 |
} |
|
593 |
|
|
594 |
if (elemento.complex != 0) { |
|
595 |
// Si es un agujero o |
|
596 |
// es la primera entidad del agujero, lo a?adimos sin unir al anterior |
|
597 |
if (bFirstHoleEntity || |
|
598 |
((psLine.type == DGNFileHeader.DGNT_SHAPE) && |
|
599 |
((psLine.properties & 0x8000) != 0))) { |
|
600 |
elementoCompuesto.append(elShape, false); |
|
601 |
bFirstHoleEntity = false; |
|
602 |
} else { |
|
603 |
elementoCompuesto.append(elShape, bConnect); |
|
604 |
} |
|
605 |
} else { |
|
606 |
IGeometry geom=ShapeFactory.createPolyline2D(elShape); |
|
607 |
auxFeature.set(ID_FIELD_GEOMETRY,geom); |
|
608 |
// auxFeature.setDefaultGeometry(geom); |
|
609 |
addDGNFeature(auxFeature); |
|
610 |
// addShape(new FPolyline2D(elShape), auxRow); |
|
611 |
} |
|
612 |
} |
|
613 |
|
|
614 |
break; |
|
615 |
|
|
616 |
case DGNFileHeader.DGNST_ARC: |
|
617 |
|
|
618 |
// m_DgnReader.DGNDumpElement(m_DgnReader.getInfo(), elemento,""); |
|
619 |
DGNElemArc psArc = (DGNElemArc) elemento; |
|
620 |
|
|
621 |
// La definici?n de arco de MicroStation es distinta a la de Java. |
|
622 |
// En el dgn el origin se entiende que es el centro del arco, |
|
623 |
// y a la hora de crear un Arc2D las 2 primeras coordenadas son |
|
624 |
// la esquina inferior izquierda del rect?ngulo que rodea al arco. |
|
625 |
// 1.- Creamos la elipse sin rotaci?n. |
|
626 |
// 2.- Creamos el arco |
|
627 |
// 3.- Rotamos el resultado |
|
628 |
|
|
629 |
/* System.out.println("Arco con primari axis: " + psArc.primary_axis + |
|
630 |
" start angle: " + psArc.startang + " sweepang = " + psArc.sweepang); |
|
631 |
System.out.println("secondaria axis: " + psArc.secondary_axis + |
|
632 |
" rotation = " + psArc.rotation); */ |
|
633 |
AffineTransform mT = AffineTransform.getRotateInstance(Math.toRadians( |
|
634 |
psArc.rotation), psArc.origin.x, |
|
635 |
psArc.origin.y); |
|
636 |
|
|
637 |
// mT.preConcatenate(AffineTransform.getScaleInstance(100.0,100.0)); |
|
638 |
Arc2D.Double elArco = new Arc2D.Double(psArc.origin.x - |
|
639 |
psArc.primary_axis, |
|
640 |
psArc.origin.y - psArc.secondary_axis, |
|
641 |
2.0 * psArc.primary_axis, |
|
642 |
2.0 * psArc.secondary_axis, -psArc.startang, |
|
643 |
-psArc.sweepang, Arc2D.OPEN); |
|
644 |
|
|
645 |
// Ellipse2D.Double elArco = new Ellipse2D.Double(psArc.origin.x - psArc.primary_axis, |
|
646 |
// psArc.origin.y - psArc.secondary_axis,2.0 * psArc.primary_axis, 2.0 * psArc.secondary_axis); |
|
647 |
GeneralPathX elShapeArc = new GeneralPathX(elArco); |
|
648 |
|
|
649 |
// Transformamos el GeneralPahtX porque si transformamos elArco nos lo convierte |
|
650 |
// a GeneralPath y nos guarda las coordenadas en float, con la correspondiente p?rdida de precisi?n |
|
651 |
elShapeArc.transform(mT); |
|
652 |
|
|
653 |
if (m_DgnReader.getInfo().dimension == 3) { |
|
654 |
//Aqu? podr?amos hacer cosas con la coordenada Z |
|
655 |
} |
|
656 |
|
|
657 |
auxFeature.set(ID_FIELD_ID,elemento.element_id); |
|
658 |
// auxRow[ID_FIELD_ID] = ValueFactory.createValue(elemento.element_id); |
|
659 |
auxFeature.set(ID_FIELD_ENTITY,"Arc"); |
|
660 |
// auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue( |
|
661 |
// "Arc"); |
|
662 |
auxFeature.set(ID_FIELD_LAYER,elemento.level); |
|
663 |
// auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(elemento.level); |
|
664 |
auxFeature.set(ID_FIELD_COLOR,elemento.color); |
|
665 |
// auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(elemento.color); |
|
666 |
|
|
667 |
/* Line2D.Double ejeMayor = new Line2D.Double(psArc.origin.x - psArc.primary_axis, psArc.origin.y, |
|
668 |
psArc.origin.x + psArc.primary_axis, psArc.origin.y); |
|
669 |
|
|
670 |
lyrLines.addShape(new FShape(FConstant.SHAPE_TYPE_POLYLINE, new GeneralPathX(ejeMayor)), auxRow); */ |
|
671 |
|
|
672 |
// lyrLines.addShape(new FShape(FConstant.SHAPE_TYPE_POLYLINE, elShapeArc), auxRow); |
|
673 |
if (elemento.complex != 0) { |
|
674 |
// Esto es una posible fuente de fallos si detr?s de una |
|
675 |
// elipse vienen m?s cosas pegadas. Deber?amos volver |
|
676 |
// a conectar una vez pasada la elipse. |
|
677 |
if (elemento.type == DGNFileHeader.DGNT_ELLIPSE) { |
|
678 |
bConnect = false; |
|
679 |
} |
|
680 |
|
|
681 |
// SI LA ELIPSE ES UN AGUJERO, SE A?ADE SIN PEGAR |
|
682 |
// Y EL ELEMENTO ES UN POLIGONO |
|
683 |
if (bFirstHoleEntity || |
|
684 |
((elemento.type == DGNFileHeader.DGNT_SHAPE) && |
|
685 |
((elemento.properties & 0x8000) != 0))) { |
|
686 |
elementoCompuesto.append(elShapeArc, false); |
|
687 |
bFirstHoleEntity = false; |
|
688 |
} else { |
|
689 |
elementoCompuesto.append(elShapeArc, bConnect); |
|
690 |
} |
|
691 |
} else { |
|
692 |
IGeometry geom=ShapeFactory.createPolyline2D(elShapeArc); |
|
693 |
auxFeature.set(ID_FIELD_GEOMETRY,geom); |
|
694 |
// auxFeature.setDefaultGeometry(geom); |
|
695 |
addDGNFeature(auxFeature); |
|
696 |
|
|
697 |
// addShape(new FPolyline2D(elShapeArc), auxRow); |
|
698 |
|
|
699 |
if (psArc.type == DGNFileHeader.DGNT_ELLIPSE) { |
|
700 |
geom=ShapeFactory.createPolygon2D(elShapeArc); |
|
701 |
auxFeature.set(ID_FIELD_GEOMETRY,geom); |
|
702 |
// auxFeature.setDefaultGeometry(geom); |
|
703 |
addDGNFeature(auxFeature); |
|
704 |
// addShape(new FPolygon2D(elShapeArc), auxRow); |
|
705 |
} |
|
706 |
} |
|
707 |
|
|
708 |
// System.err.println("Entra un Arco"); |
|
709 |
break; |
|
710 |
|
|
711 |
case DGNFileHeader.DGNST_TEXT: |
|
712 |
|
|
713 |
DGNElemText psText = (DGNElemText) elemento; |
|
714 |
|
|
715 |
|
|
716 |
auxFeature.set(ID_FIELD_ID,elemento.element_id); |
|
717 |
// auxRow[ID_FIELD_ID] = ValueFactory.createValue(elemento.element_id); |
|
718 |
auxFeature.set(ID_FIELD_ENTITY,"Text"); |
|
719 |
// auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue( |
|
720 |
// "Text"); |
|
721 |
auxFeature.set(ID_FIELD_LAYER,elemento.level); |
|
722 |
// auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(elemento.level); |
|
723 |
auxFeature.set(ID_FIELD_COLOR,elemento.color); |
|
724 |
// auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(elemento.color); |
|
725 |
heightText = (float) psText.height_mult; |
|
726 |
auxFeature.set(ID_FIELD_HEIGHTTEXT,heightText); |
|
727 |
// auxRow[ID_FIELD_HEIGHTTEXT] = ValueFactory.createValue(heightText); |
|
728 |
auxFeature.set(ID_FIELD_ROTATIONTEXT,psText.rotation); |
|
729 |
// auxRow[ID_FIELD_ROTATIONTEXT] = ValueFactory.createValue(psText.rotation); |
|
730 |
auxFeature.set(ID_FIELD_TEXT,psText.string); |
|
731 |
// auxRow[ID_FIELD_TEXT] = ValueFactory.createValue(psText.string); // .trim(); |
|
732 |
|
|
733 |
IGeometry geom=ShapeFactory.createPoint3D(psText.origin.x, |
|
734 |
psText.origin.y, psText.origin.z); |
|
735 |
auxFeature.set(ID_FIELD_GEOMETRY,geom); |
|
736 |
// auxFeature.setDefaultGeometry(geom); |
|
737 |
addDGNFeature(auxFeature); |
|
738 |
|
|
739 |
// addShape(elShapeTxt, auxRow); |
|
740 |
|
|
741 |
// System.out.println("Rotaci?n texto: " + psText.rotation + "Altura Texto = " + heightText); |
|
742 |
|
|
743 |
/* System.out.println(" origin=(" + psText.origin.x + |
|
744 |
", " + psText.origin.y + ") rotation=" + |
|
745 |
psText.rotation + "\n" + " font=" + |
|
746 |
psText.font_id + " just=" + |
|
747 |
psText.justification + "length_mult=" + |
|
748 |
psText.length_mult + " height_mult=" + |
|
749 |
psText.height_mult + "\n" + " string =" + |
|
750 |
new String(psText.string).toString().trim() + |
|
751 |
"\n"); */ |
|
752 |
break; |
|
753 |
|
|
754 |
/* default: |
|
755 |
m_DgnReader.DGNDumpElement(m_DgnReader.getInfo(), elemento, ""); |
|
756 |
*/ |
|
757 |
} // switch |
|
758 |
} // if |
|
759 |
} // for |
|
760 |
|
|
761 |
if (bElementoCompuesto) { |
|
762 |
if (bInsideCell) { |
|
763 |
auxFeature=cellFeature; |
|
764 |
// auxRow = cellRow; |
|
765 |
} else { |
|
766 |
auxFeature=complexFeature; |
|
767 |
// auxRow = complexRow; |
|
768 |
} |
|
769 |
|
|
770 |
// System.err.println("Entidad compuesta. bInsideCell = " + bInsideCell + " auxRow = " + auxRow[ID_FIELD_ENTITY]); |
|
771 |
IGeometry geom=ShapeFactory.createPolyline2D(elementoCompuesto); |
|
772 |
auxFeature.set(ID_FIELD_GEOMETRY,geom); |
|
773 |
// auxFeature.setDefaultGeometry(geom); |
|
774 |
addDGNFeature(auxFeature); |
|
775 |
|
|
776 |
// addShape(new FPolyline2D(elementoCompuesto), auxRow); |
|
777 |
|
|
778 |
if (bEsPoligono) { |
|
779 |
if (complex_index_fill_color != -1) { |
|
780 |
auxFeature.set(ID_FIELD_COLOR,complex_index_fill_color); |
|
781 |
// auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(complex_index_fill_color); |
|
782 |
} |
|
783 |
geom=ShapeFactory.createPolygon2D(elementoCompuesto); |
|
784 |
auxFeature.set(ID_FIELD_GEOMETRY,geom); |
|
785 |
// auxFeature.setDefaultGeometry(geom); |
|
786 |
addDGNFeature(auxFeature); |
|
787 |
// addShape(new FPolygon2D(elementoCompuesto), auxRow); |
|
788 |
} |
|
789 |
} |
|
790 |
cellFeature.stopLoading(); |
|
791 |
auxFeature.stopLoading(); |
|
792 |
complexFeature.stopLoading(); |
|
793 |
defaultLegend = LegendFactory.createVectorialUniqueValueLegend(FShape.MULTI); |
|
794 |
defaultLegend.setClassifyingFieldNames(new String[] {"Color"} ); |
|
795 |
defaultLegend.setClassifyingFieldTypes(new int[]{Types.INTEGER,Types.VARCHAR,Types.INTEGER,Types.INTEGER,Types.FLOAT,Types.DOUBLE,Types.VARCHAR}); |
|
796 |
|
|
797 |
|
|
798 |
ISymbol myDefaultSymbol = SymbologyFactory. |
|
799 |
createDefaultSymbolByShapeType(FShape.MULTI); |
|
800 |
|
|
801 |
defaultLegend.setDefaultSymbol(myDefaultSymbol); |
|
802 |
}catch (IsNotFeatureSettingException e) { |
|
803 |
throw new OpenException(this.getName(),e); |
|
804 |
} catch (ReadException e) { |
|
805 |
throw new OpenException(this.getName(),e); |
|
806 |
} |
|
807 |
|
|
808 |
// ISymbol theSymbol = null; |
|
809 |
|
|
810 |
// try { |
|
811 |
// for (long j = 0; j < getFeatureCount(); j++) { |
|
812 |
// IFeature feat=(IFeature)getFeature((int)j); |
|
813 |
// int clave=feat.getInt(ID_FIELD_COLOR); |
|
814 |
// if (defaultLegend.getSymbolByValue(clave) == null) { |
|
815 |
|
|
816 |
// Color c = m_DgnReader.DGNLookupColor( |
|
817 |
// clave.getValue()); |
|
818 |
// theSymbol = SymbologyFactory. |
|
819 |
// createDefaultSymbolByShapeType(featureType.getGeometryTypes()[0], c); |
|
820 |
// theSymbol.setDescription(clave.toString()); |
|
821 |
|
|
822 |
// if (theSymbol instanceof IMarkerSymbol) { |
|
823 |
// ((IMarkerSymbol) theSymbol).setSize(1); |
|
824 |
// } |
|
825 |
|
|
826 |
// if (theSymbol instanceof ILineSymbol) { |
|
827 |
// ((ILineSymbol) theSymbol).setLineWidth(1); |
|
828 |
// } |
|
829 |
|
|
830 |
// if (theSymbol instanceof IFillSymbol) { |
|
831 |
// ((IFillSymbol) theSymbol).getOutline().setLineColor(c); |
|
832 |
// ((IFillSymbol) theSymbol).getOutline().setLineWidth(1); |
|
833 |
// ((IFillSymbol) theSymbol).setFillColor(null); |
|
834 |
// } |
|
835 |
|
|
836 |
// // theSymbol.setStyle(FConstant.SYMBOL_STYLE_FILL_TRANSPARENT); |
|
837 |
// defaultLegend.addSymbol(clave, theSymbol); |
|
838 |
// } |
|
839 |
|
|
840 |
// if ("Text".equalsIgnoreCase(((StringValue) rs.getFieldValue(j, ID_FIELD_ENTITY)).toString())) { |
|
841 |
|
|
842 |
// } |
|
843 |
|
|
844 |
|
|
845 |
// } // for |
|
846 |
// } catch (ReadException e) { |
|
847 |
// throw new OpenException(getName(),e); |
|
848 |
// } |
|
849 |
|
|
850 |
|
|
851 | 273 |
} |
852 | 274 |
|
853 | 275 |
protected void doClose() throws CloseException { |
854 |
super.doClose(); |
|
855 |
|
|
276 |
this.dgn.close(); |
|
856 | 277 |
} |
857 | 278 |
|
858 | 279 |
protected void doDispose() throws CloseException { |
859 |
close(); |
|
860 | 280 |
super.doDispose(); |
861 |
this.metadata=null; |
|
862 |
this.featureType=null; |
|
863 |
this.defaultLegend=null; |
|
281 |
ResourceManager resMan = ResourceManager.getResourceManager(); |
|
864 | 282 |
|
283 |
try { |
|
284 |
resMan.remove(this.dgn); |
|
285 |
} catch (DataException e1) { |
|
286 |
throw new CloseException(this.getName(),e1); |
|
287 |
} catch (KeyException e) { |
|
288 |
throw new CloseException(this.getName(),e); |
|
289 |
} |
|
290 |
|
|
291 |
this.dgn = null; |
|
292 |
this.featureType=null; |
|
293 |
this.metadata=null; |
|
865 | 294 |
} |
866 | 295 |
|
867 | 296 |
public boolean isEditable() { |
... | ... | |
872 | 301 |
if (metadata==null){ |
873 | 302 |
IMetadataManager manager=MetadataManager.getManager(); |
874 | 303 |
metadata=manager.create(DATASTORE_NAME); |
875 |
IExtent extent=getFullExtent(); |
|
304 |
IExtent extent=this.dgn.getFullExtent();
|
|
876 | 305 |
metadata.set("extent",extent); |
877 | 306 |
String srs=getSRS(); |
878 | 307 |
metadata.set("srs",srs); |
... | ... | |
924 | 353 |
return src; |
925 | 354 |
} |
926 | 355 |
|
927 |
private void addDGNFeature(IFeature feature) throws ReadException{ |
|
928 |
this.addFeature(new DGNFeature(feature)); |
|
929 |
} |
|
930 | 356 |
|
357 |
|
|
931 | 358 |
/* (non-Javadoc) |
932 | 359 |
* @see org.gvsig.data.vectorial.FeatureStore#doRefresh() |
933 | 360 |
*/ |
trunk/libraries/libFMap_dataFile/src/org/gvsig/data/datastores/vectorial/file/dgn/DGNResource.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.data.datastores.vectorial.file.dgn; |
|
32 |
|
|
33 |
import java.awt.geom.AffineTransform; |
|
34 |
import java.awt.geom.Arc2D; |
|
35 |
import java.sql.Types; |
|
36 |
|
|
37 |
import org.gvsig.data.datastores.vectorial.file.FileMemoryResource; |
|
38 |
import org.gvsig.data.datastores.vectorial.file.IFileStoreParameters; |
|
39 |
import org.gvsig.data.datastores.vectorial.file.dgn.utils.DGNElemArc; |
|
40 |
import org.gvsig.data.datastores.vectorial.file.dgn.utils.DGNElemComplexHeader; |
|
41 |
import org.gvsig.data.datastores.vectorial.file.dgn.utils.DGNElemCore; |
|
42 |
import org.gvsig.data.datastores.vectorial.file.dgn.utils.DGNElemMultiPoint; |
|
43 |
import org.gvsig.data.datastores.vectorial.file.dgn.utils.DGNElemText; |
|
44 |
import org.gvsig.data.datastores.vectorial.file.dgn.utils.DGNFileHeader; |
|
45 |
import org.gvsig.data.datastores.vectorial.file.dgn.utils.DGNReader; |
|
46 |
import org.gvsig.data.datastores.vectorial.file.dxf.DXFStore; |
|
47 |
import org.gvsig.data.exception.DataException; |
|
48 |
import org.gvsig.data.exception.OpenException; |
|
49 |
import org.gvsig.data.exception.ReadException; |
|
50 |
import org.gvsig.data.spatialprovisional.IExtent; |
|
51 |
import org.gvsig.data.vectorial.AttributeDescriptor; |
|
52 |
import org.gvsig.data.vectorial.FeatureType; |
|
53 |
import org.gvsig.data.vectorial.IFeature; |
|
54 |
import org.gvsig.data.vectorial.IFeatureAttributeDescriptor; |
|
55 |
import org.gvsig.data.vectorial.IFeatureType; |
|
56 |
import org.gvsig.data.vectorial.IsNotAttributeSettingException; |
|
57 |
import org.gvsig.data.vectorial.IsNotFeatureSettingException; |
|
58 |
|
|
59 |
import com.iver.cit.gvsig.fmap.core.FShape; |
|
60 |
import com.iver.cit.gvsig.fmap.core.GeneralPathX; |
|
61 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
62 |
import com.iver.cit.gvsig.fmap.core.ShapeFactory; |
|
63 |
import com.iver.cit.gvsig.fmap.core.SymbologyFactory; |
|
64 |
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
|
65 |
import com.iver.cit.gvsig.fmap.rendering.LegendFactory; |
|
66 |
import com.iver.cit.gvsig.fmap.rendering.VectorialUniqueValueLegend; |
|
67 |
import com.iver.cit.gvsig.fmap.rendering.styling.labeling.AttrInTableLabelingStrategy; |
|
68 |
|
|
69 |
/** |
|
70 |
* @author jmvivo |
|
71 |
* |
|
72 |
*/ |
|
73 |
public class DGNResource extends FileMemoryResource { |
|
74 |
|
|
75 |
|
|
76 |
private final int ID_FIELD_ID = 0; |
|
77 |
private final int ID_FIELD_ENTITY = 1; |
|
78 |
private final int ID_FIELD_LAYER = 2; |
|
79 |
private final int ID_FIELD_COLOR = 3; |
|
80 |
private final int ID_FIELD_HEIGHTTEXT = 4; |
|
81 |
private final int ID_FIELD_ROTATIONTEXT = 5; |
|
82 |
private final int ID_FIELD_TEXT = 6; |
|
83 |
private final int ID_FIELD_GEOMETRY = 7; |
|
84 |
|
|
85 |
|
|
86 |
private IFeatureType featureType; |
|
87 |
|
|
88 |
private AttrInTableLabelingStrategy labeling; |
|
89 |
private VectorialUniqueValueLegend defaultLegend; |
|
90 |
|
|
91 |
/** |
|
92 |
* @param params |
|
93 |
*/ |
|
94 |
DGNResource(IFileStoreParameters params) { |
|
95 |
super(params); |
|
96 |
} |
|
97 |
|
|
98 |
private void initializeFeatureType() { |
|
99 |
this.featureType= DGNStore.newFeatureType(); |
|
100 |
} |
|
101 |
|
|
102 |
/* (non-Javadoc) |
|
103 |
* @see org.gvsig.data.datastores.vectorial.file.FileMemoryResource#load() |
|
104 |
*/ |
|
105 |
protected void load() throws DataException { |
|
106 |
float heightText = 10; |
|
107 |
// attr.setLoadedInMemory(true); |
|
108 |
initializeFeatureType(); |
|
109 |
DGNReader m_DgnReader; |
|
110 |
try { |
|
111 |
m_DgnReader = new DGNReader(this.params.getFile().getAbsolutePath()); |
|
112 |
} catch (ReadException e) { |
|
113 |
throw new OpenException(this.description(),e); |
|
114 |
} |
|
115 |
|
|
116 |
try{ |
|
117 |
// Value[] auxRow = new Value[7]; |
|
118 |
// Value[] cellRow = new Value[7]; |
|
119 |
// Value[] complexRow = new Value[7]; |
|
120 |
DGNFeature auxFeature=new DGNFeature(featureType,true); |
|
121 |
auxFeature.loading(); |
|
122 |
DGNFeature cellFeature=new DGNFeature(featureType,false); |
|
123 |
cellFeature.loading(); |
|
124 |
DGNFeature complexFeature=new DGNFeature(featureType,false); |
|
125 |
complexFeature.loading(); |
|
126 |
initializeFeatureType(); |
|
127 |
// ArrayList arrayFields = new ArrayList(); |
|
128 |
// arrayFields.add("ID"); |
|
129 |
// arrayFields.add("Entity"); |
|
130 |
// arrayFields.add("Layer"); |
|
131 |
// arrayFields.add("Color"); |
|
132 |
// arrayFields.add("HeightText"); |
|
133 |
// arrayFields.add("RotationText"); |
|
134 |
// arrayFields.add("Text"); |
|
135 |
|
|
136 |
// getTableModel().setColumnIdentifiers(arrayFields.toArray()); |
|
137 |
|
|
138 |
// jaume |
|
139 |
labeling = new AttrInTableLabelingStrategy(); |
|
140 |
((AttrInTableLabelingStrategy) labeling).setTextFieldId(featureType.getFieldIndex("Text")); |
|
141 |
((AttrInTableLabelingStrategy) labeling).setRotationFieldId(featureType.getFieldIndex("RotationText")); |
|
142 |
((AttrInTableLabelingStrategy) labeling).setHeightFieldId(featureType.getFieldIndex("HeightText")); |
|
143 |
((AttrInTableLabelingStrategy) labeling).setUnit(1); //MapContext.NAMES[1] (meters) |
|
144 |
|
|
145 |
|
|
146 |
// Ahora las rellenamos. |
|
147 |
// FShape aux; |
|
148 |
boolean bElementoCompuesto = false; |
|
149 |
boolean bEsPoligono = false; |
|
150 |
boolean bInsideCell = false; |
|
151 |
boolean bFirstHoleEntity = false; |
|
152 |
boolean bConnect = false; // Se usa para que los pol?gonos cierren bien cuando son formas compuestas |
|
153 |
// int contadorSubElementos = 0; |
|
154 |
// int numSubElementos = 0; |
|
155 |
int complex_index_fill_color = -1; |
|
156 |
int nClass; // Para filtrar los elementos de construcci?n, etc. |
|
157 |
GeneralPathX elementoCompuesto = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD); |
|
158 |
|
|
159 |
for (int id = 0; id < m_DgnReader.getNumEntities(); id++) { |
|
160 |
|
|
161 |
// System.out.println("Elemento " + id + " de " + m_DgnReader.getNumEntities()); |
|
162 |
m_DgnReader.DGNGotoElement(id); |
|
163 |
|
|
164 |
DGNElemCore elemento = m_DgnReader.DGNReadElement(); |
|
165 |
nClass = 0; |
|
166 |
// auxRow[ID_FIELD_HEIGHTTEXT] = ValueFactory.createValue(0); |
|
167 |
// auxRow[ID_FIELD_ROTATIONTEXT] = ValueFactory.createValue(0); |
|
168 |
// auxRow[ID_FIELD_TEXT] = ValueFactory.createNullValue(); |
|
169 |
|
|
170 |
if (elemento.properties != 0) { |
|
171 |
nClass = elemento.properties & DGNFileHeader.DGNPF_CLASS; |
|
172 |
} |
|
173 |
|
|
174 |
if ((elemento != null) && (elemento.deleted == 0) && (nClass == 0)) //Leer un elemento |
|
175 |
{ |
|
176 |
// aux = null; |
|
177 |
|
|
178 |
// if ((elemento.element_id > 3800) && (elemento.element_id < 3850)) |
|
179 |
// m_DgnReader.DGNDumpElement(m_DgnReader.getInfo(),elemento,""); |
|
180 |
if ((elemento.stype == DGNFileHeader.DGNST_MULTIPOINT) || |
|
181 |
(elemento.stype == DGNFileHeader.DGNST_ARC) || |
|
182 |
(elemento.stype == DGNFileHeader.DGNST_CELL_HEADER) || |
|
183 |
(elemento.stype == DGNFileHeader.DGNST_SHARED_CELL_DEFN) || |
|
184 |
(elemento.stype == DGNFileHeader.DGNST_COMPLEX_HEADER)) { |
|
185 |
if (elemento.complex != 0) { |
|
186 |
bElementoCompuesto = true; |
|
187 |
} else { |
|
188 |
if (bElementoCompuesto) { |
|
189 |
if (bInsideCell) { |
|
190 |
auxFeature.set(ID_FIELD_ENTITY,cellFeature.get(ID_FIELD_ENTITY)); |
|
191 |
// auxRow[ID_FIELD_ENTITY] = cellRow[ID_FIELD_ENTITY]; |
|
192 |
} else { |
|
193 |
auxFeature=complexFeature; |
|
194 |
// auxRow = complexRow; |
|
195 |
} |
|
196 |
|
|
197 |
// System.err.println("Entidad compuesta. bInsideCell = " + bInsideCell + " auxRow = " + auxRow[ID_FIELD_ENTITY]); |
|
198 |
IGeometry geom=ShapeFactory.createPolyline2D(elementoCompuesto); |
|
199 |
auxFeature.set(ID_FIELD_GEOMETRY,geom); |
|
200 |
// auxFeature.setDefaultGeometry(geom); |
|
201 |
addDGNFeature(auxFeature); |
|
202 |
// addShape(new FPolyline2D(elementoCompuesto), auxRow); |
|
203 |
|
|
204 |
if (bEsPoligono) { |
|
205 |
if (complex_index_fill_color != -1) { |
|
206 |
auxFeature.set(ID_FIELD_COLOR,complex_index_fill_color); |
|
207 |
// auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(complex_index_fill_color); |
|
208 |
} |
|
209 |
geom=ShapeFactory.createPolygon2D(elementoCompuesto); |
|
210 |
auxFeature.set(ID_FIELD_GEOMETRY,geom); |
|
211 |
// auxFeature.setDefaultGeometry(geom); |
|
212 |
addDGNFeature(auxFeature); |
|
213 |
// addShape(new FPolygon2D(elementoCompuesto), auxRow); |
|
214 |
} |
|
215 |
|
|
216 |
elementoCompuesto = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD); |
|
217 |
} |
|
218 |
|
|
219 |
// System.err.println("Entidad simple"); |
|
220 |
bElementoCompuesto = false; |
|
221 |
bEsPoligono = false; |
|
222 |
bConnect = false; |
|
223 |
|
|
224 |
// elementoCompuesto = new GeneralPathX(); |
|
225 |
bInsideCell = false; |
|
226 |
} |
|
227 |
} |
|
228 |
|
|
229 |
switch (elemento.stype) { |
|
230 |
case DGNFileHeader.DGNST_SHARED_CELL_DEFN: |
|
231 |
bInsideCell = true; |
|
232 |
cellFeature.set(ID_FIELD_ID,elemento.element_id); |
|
233 |
// cellRow[ID_FIELD_ID] = ValueFactory.createValue(elemento.element_id); |
|
234 |
cellFeature.set(ID_FIELD_LAYER,elemento.level); |
|
235 |
// cellRow[ID_FIELD_LAYER] = ValueFactory.createValue(elemento.level); |
|
236 |
cellFeature.set(ID_FIELD_COLOR,elemento.color); |
|
237 |
// cellRow[ID_FIELD_COLOR] = ValueFactory.createValue(elemento.color); |
|
238 |
cellFeature.set(ID_FIELD_ENTITY,"Shared Cell"); |
|
239 |
// cellRow[ID_FIELD_ENTITY] = ValueFactory.createValue( |
|
240 |
// "Shared Cell"); |
|
241 |
|
|
242 |
break; |
|
243 |
|
|
244 |
case DGNFileHeader.DGNST_CELL_HEADER: |
|
245 |
bInsideCell = true; |
|
246 |
|
|
247 |
// DGNElemCellHeader psCellHeader = (DGNElemCellHeader) elemento; |
|
248 |
cellFeature.set(ID_FIELD_ID,elemento.element_id); |
|
249 |
// cellRow[ID_FIELD_ID] = ValueFactory.createValue(elemento.element_id); |
|
250 |
cellFeature.set(ID_FIELD_LAYER,elemento.level); |
|
251 |
// cellRow[ID_FIELD_LAYER] = ValueFactory.createValue(elemento.level); |
|
252 |
cellFeature.set(ID_FIELD_COLOR,elemento.color); |
|
253 |
// cellRow[ID_FIELD_COLOR] = ValueFactory.createValue(elemento.color); |
|
254 |
cellFeature.set(ID_FIELD_ENTITY,"Cell"); |
|
255 |
// cellRow[ID_FIELD_ENTITY] = ValueFactory.createValue( |
|
256 |
// "Cell"); |
|
257 |
complex_index_fill_color = m_DgnReader.DGNGetShapeFillInfo(elemento); |
|
258 |
|
|
259 |
// System.err.println("Cell Header " + complex_index_fill_color); |
|
260 |
break; |
|
261 |
|
|
262 |
case DGNFileHeader.DGNST_COMPLEX_HEADER: |
|
263 |
|
|
264 |
// bElementoCompuesto = true; |
|
265 |
// System.err.println("Complex Header"); |
|
266 |
// contadorSubElementos = 0; |
|
267 |
|
|
268 |
DGNElemComplexHeader psComplexHeader = (DGNElemComplexHeader) elemento; |
|
269 |
// numSubElementos = psComplexHeader.numelems; |
|
270 |
complexFeature.set(ID_FIELD_ID,elemento.element_id); |
|
271 |
// complexRow[ID_FIELD_ID] = ValueFactory.createValue(elemento.element_id); |
|
272 |
complexFeature.set(ID_FIELD_LAYER,elemento.level); |
|
273 |
// complexRow[ID_FIELD_LAYER] = ValueFactory.createValue(elemento.level); |
|
274 |
complexFeature.set(ID_FIELD_COLOR,elemento.color); |
|
275 |
// complexRow[ID_FIELD_COLOR] = ValueFactory.createValue(elemento.color); |
|
276 |
complexFeature.set(ID_FIELD_ENTITY,"Complex"); |
|
277 |
// complexRow[ID_FIELD_ENTITY] = ValueFactory.createValue( |
|
278 |
// "Complex"); |
|
279 |
|
|
280 |
if (psComplexHeader.type == DGNFileHeader.DGNT_COMPLEX_SHAPE_HEADER) { |
|
281 |
bEsPoligono = true; |
|
282 |
|
|
283 |
// Si es un agujero, no conectamos con el anterior |
|
284 |
if ((psComplexHeader.properties & 0x8000) != 0) { |
|
285 |
bFirstHoleEntity = true; |
|
286 |
} else { |
|
287 |
// Miramos si tiene color de relleno |
|
288 |
// complex_index_fill_color = -1; |
|
289 |
// if (elemento.attr_bytes > 0) { |
|
290 |
complex_index_fill_color = m_DgnReader.DGNGetShapeFillInfo(elemento); |
|
291 |
|
|
292 |
// System.err.println("complex shape fill color = " + elemento.color); |
|
293 |
// } |
|
294 |
} |
|
295 |
|
|
296 |
bConnect = true; |
|
297 |
} else { |
|
298 |
bEsPoligono = false; |
|
299 |
bConnect = false; |
|
300 |
} |
|
301 |
|
|
302 |
break; |
|
303 |
|
|
304 |
case DGNFileHeader.DGNST_MULTIPOINT: |
|
305 |
|
|
306 |
// OJO: Si lo que viene en este multipoint es un elemento con type=11 (curve), se trata de una "parametric |
|
307 |
// spline curve". La vamos a tratar como si no fuera curva, pero seg?n la documentaci?n, los 2 primeros puntos |
|
308 |
// y los 2 ?ltimos puntos definen "endpoint derivatives" y NO se muestran. |
|
309 |
// TODAV?A HAY UN PEQUE?O FALLO CON EL FICHERO dgn-sample.dgn, pero lo dejo por ahora. |
|
310 |
// Es posible que tenga que ver con lo de los arcos (arco distorsionado), que |
|
311 |
// todav?a no est? metido. |
|
312 |
DGNElemMultiPoint psLine = (DGNElemMultiPoint) elemento; |
|
313 |
auxFeature.set(ID_FIELD_ID,elemento.element_id); |
|
314 |
// auxRow[ID_FIELD_ID] = ValueFactory.createValue(elemento.element_id); |
|
315 |
auxFeature.set(ID_FIELD_ENTITY,"Multipoint"); |
|
316 |
// auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue( |
|
317 |
// "Multipoint"); |
|
318 |
auxFeature.set(ID_FIELD_LAYER,elemento.level); |
|
319 |
// auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(elemento.level); |
|
320 |
auxFeature.set(ID_FIELD_COLOR,elemento.color); |
|
321 |
// auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(elemento.color); |
|
322 |
|
|
323 |
if ((psLine.num_vertices == 2) && |
|
324 |
(psLine.vertices[0].x == psLine.vertices[1].x) && |
|
325 |
(psLine.vertices[0].y == psLine.vertices[1].y)) { |
|
326 |
auxFeature.set(ID_FIELD_ENTITY,"Point"); |
|
327 |
// auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue( |
|
328 |
// "Point"); |
|
329 |
|
|
330 |
IGeometry geom=ShapeFactory.createPoint3D(psLine.vertices[0].x, |
|
331 |
psLine.vertices[0].y, psLine.vertices[0].z); |
|
332 |
auxFeature.set(ID_FIELD_GEOMETRY,geom); |
|
333 |
// auxFeature.setDefaultGeometry(geom); |
|
334 |
addDGNFeature(auxFeature); |
|
335 |
|
|
336 |
// addShape(new FPoint3D(psLine.vertices[0].x, |
|
337 |
// psLine.vertices[0].y, psLine.vertices[0].z), |
|
338 |
// auxRow); |
|
339 |
} else { |
|
340 |
GeneralPathX elShape = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD); |
|
341 |
|
|
342 |
if (psLine.type == DGNFileHeader.DGNT_CURVE) { |
|
343 |
psLine.num_vertices = psLine.num_vertices - 4; |
|
344 |
|
|
345 |
for (int aux_n = 0; |
|
346 |
aux_n < psLine.num_vertices; aux_n++) { |
|
347 |
psLine.vertices[aux_n] = psLine.vertices[aux_n + |
|
348 |
2]; |
|
349 |
} |
|
350 |
} |
|
351 |
|
|
352 |
if ((psLine.type == DGNFileHeader.DGNT_SHAPE) && |
|
353 |
((psLine.properties & 0x8000) != 0)) { |
|
354 |
// Invertimos el orden porque es un agujero |
|
355 |
elShape.moveTo(psLine.vertices[psLine.num_vertices - |
|
356 |
1].x, |
|
357 |
psLine.vertices[psLine.num_vertices - 1].y); |
|
358 |
|
|
359 |
for (int i = psLine.num_vertices - 2; i >= 0; |
|
360 |
i--) |
|
361 |
elShape.lineTo(psLine.vertices[i].x, |
|
362 |
psLine.vertices[i].y); |
|
363 |
} else { |
|
364 |
elShape.moveTo(psLine.vertices[0].x, |
|
365 |
psLine.vertices[0].y); |
|
366 |
|
|
367 |
for (int i = 1; i < psLine.num_vertices; i++) |
|
368 |
elShape.lineTo(psLine.vertices[i].x, |
|
369 |
psLine.vertices[i].y); |
|
370 |
} |
|
371 |
|
|
372 |
if ((psLine.vertices[0].x == psLine.vertices[psLine.num_vertices - |
|
373 |
1].x) && |
|
374 |
(psLine.vertices[0].y == psLine.vertices[psLine.num_vertices - |
|
375 |
1].y)) { |
|
376 |
// Lo a?adimos tambi?n como pol?gono |
|
377 |
bEsPoligono = true; |
|
378 |
|
|
379 |
// Miramos si tiene color de relleno |
|
380 |
if (elemento.attr_bytes > 0) { |
|
381 |
elemento.color = m_DgnReader.DGNGetShapeFillInfo(elemento); |
|
382 |
|
|
383 |
// System.err.println("fill color = " + elemento.color); |
|
384 |
if (elemento.color != -1) { |
|
385 |
auxFeature.set(ID_FIELD_COLOR,elemento.color); |
|
386 |
// auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(elemento.color); |
|
387 |
} |
|
388 |
} |
|
389 |
|
|
390 |
if (elemento.complex == 0) { |
|
391 |
IGeometry geom=ShapeFactory.createPolygon2D(elShape); |
|
392 |
auxFeature.set(ID_FIELD_GEOMETRY,geom); |
|
393 |
// auxFeature.setDefaultGeometry(geom); |
|
394 |
addDGNFeature(auxFeature); |
|
395 |
// addShape(new FPolygon2D(elShape), auxRow); |
|
396 |
} |
|
397 |
} |
|
398 |
|
|
399 |
if (elemento.complex != 0) { |
|
400 |
// Si es un agujero o |
|
401 |
// es la primera entidad del agujero, lo a?adimos sin unir al anterior |
|
402 |
if (bFirstHoleEntity || |
|
403 |
((psLine.type == DGNFileHeader.DGNT_SHAPE) && |
|
404 |
((psLine.properties & 0x8000) != 0))) { |
|
405 |
elementoCompuesto.append(elShape, false); |
Also available in: Unified diff