root / trunk / libraries / libDataSourceBaseDrivers / src / org / gvsig / data / datastores / vectorial / file / dxf / DXFStore.java @ 20501
History | View | Annotate | Download (39.9 KB)
1 |
package org.gvsig.data.datastores.vectorial.file.dxf; |
---|---|
2 |
|
3 |
import java.awt.Color; |
4 |
import java.awt.geom.Point2D; |
5 |
import java.io.File; |
6 |
import java.lang.ref.WeakReference; |
7 |
import java.sql.Types; |
8 |
import java.util.ArrayList; |
9 |
import java.util.Collection; |
10 |
import java.util.Comparator; |
11 |
import java.util.Iterator; |
12 |
import java.util.List; |
13 |
import java.util.TreeSet; |
14 |
import java.util.logging.Logger; |
15 |
|
16 |
import org.cresques.cts.IProjection; |
17 |
import org.cresques.geo.Point3D; |
18 |
import org.cresques.io.DxfFile; |
19 |
import org.cresques.px.IObjList; |
20 |
import org.cresques.px.dxf.DxfFeatureMaker; |
21 |
import org.cresques.px.dxf.DxfHeaderManager; |
22 |
import org.cresques.px.gml.Feature; |
23 |
import org.cresques.px.gml.LineString; |
24 |
import org.cresques.px.gml.LineString3D; |
25 |
import org.cresques.px.gml.Point; |
26 |
import org.cresques.px.gml.Polygon; |
27 |
import org.cresques.px.gml.Polygon3D; |
28 |
import org.gvsig.data.DataManager; |
29 |
import org.gvsig.data.IDataCollection; |
30 |
import org.gvsig.data.IDataExplorer; |
31 |
import org.gvsig.data.IDataExplorerParameters; |
32 |
import org.gvsig.data.IDataStoreParameters; |
33 |
import org.gvsig.data.datastores.vectorial.IFeaturesWriter; |
34 |
import org.gvsig.data.datastores.vectorial.base.MemoryStore; |
35 |
import org.gvsig.data.datastores.vectorial.file.DataExplorerFileParameters; |
36 |
import org.gvsig.data.datastores.vectorial.file.dbf.DBFDataExplorer; |
37 |
import org.gvsig.data.exception.CloseException; |
38 |
import org.gvsig.data.exception.InitializeException; |
39 |
import org.gvsig.data.exception.OpenException; |
40 |
import org.gvsig.data.exception.ReadException; |
41 |
import org.gvsig.data.exception.WriteException; |
42 |
import org.gvsig.data.spatialprovisional.IExtent; |
43 |
import org.gvsig.data.vectorial.DefaultAttributeDescriptor; |
44 |
import org.gvsig.data.vectorial.DefaultFeatureType; |
45 |
import org.gvsig.data.vectorial.FeatureStoreNotification; |
46 |
import org.gvsig.data.vectorial.IFeature; |
47 |
import org.gvsig.data.vectorial.IFeatureAttributeDescriptor; |
48 |
import org.gvsig.data.vectorial.IFeatureCollection; |
49 |
import org.gvsig.data.vectorial.IFeatureID; |
50 |
import org.gvsig.data.vectorial.IFeatureType; |
51 |
import org.gvsig.data.vectorial.IsNotAttributeSettingException; |
52 |
import org.gvsig.data.vectorial.IsNotFeatureSettingException; |
53 |
import org.gvsig.data.vectorial.MemoryFeature; |
54 |
import org.gvsig.data.vectorial.expressionevaluator.FeatureComparator; |
55 |
import org.gvsig.data.vectorial.expressionevaluator.FeatureFilter; |
56 |
import org.gvsig.exceptions.BaseException; |
57 |
import org.gvsig.metadata.IMetadata; |
58 |
import org.gvsig.metadata.IMetadataManager; |
59 |
import org.gvsig.metadata.MetadataManager; |
60 |
|
61 |
import com.iver.cit.gvsig.fmap.core.FPoint2D; |
62 |
import com.iver.cit.gvsig.fmap.core.FShape; |
63 |
import com.iver.cit.gvsig.fmap.core.GeneralPathX; |
64 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
65 |
import com.iver.cit.gvsig.fmap.core.ShapeFactory; |
66 |
import com.iver.cit.gvsig.fmap.core.SymbologyFactory; |
67 |
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
68 |
import com.iver.cit.gvsig.fmap.drivers.DriverAttributes; |
69 |
import com.iver.cit.gvsig.fmap.rendering.LegendFactory; |
70 |
import com.iver.cit.gvsig.fmap.rendering.VectorialUniqueValueLegend; |
71 |
import com.iver.cit.gvsig.fmap.rendering.styling.labeling.AttrInTableLabelingStrategy; |
72 |
|
73 |
public class DXFStore extends MemoryStore{ |
74 |
public static String DATASTORE_NAME = "DXFStore"; |
75 |
protected final static int ID_FIELD_ID = 0; |
76 |
|
77 |
protected final static int ID_FIELD_FSHAPE = 1; |
78 |
|
79 |
protected final static int ID_FIELD_ENTITY = 2; |
80 |
|
81 |
protected final static int ID_FIELD_LAYER = 3; |
82 |
|
83 |
protected final static int ID_FIELD_COLOR = 4; |
84 |
|
85 |
protected final static int ID_FIELD_ELEVATION = 5; |
86 |
|
87 |
protected final static int ID_FIELD_THICKNESS = 6; |
88 |
|
89 |
protected final static int ID_FIELD_TEXT = 7; |
90 |
|
91 |
protected final static int ID_FIELD_HEIGHTTEXT = 8; |
92 |
|
93 |
protected final static int ID_FIELD_ROTATIONTEXT = 9; |
94 |
private DriverAttributes attr = new DriverAttributes(); |
95 |
private DxfFile.EntityFactory featureMaker;
|
96 |
private DxfFile.VarSettings headerManager;
|
97 |
private DxfFile dxfFeatureFile;
|
98 |
private IObjList.vector features;
|
99 |
private AttrInTableLabelingStrategy labeling;
|
100 |
|
101 |
private VectorialUniqueValueLegend defaultLegend;
|
102 |
|
103 |
private IFeatureType featureType;
|
104 |
private List featureTypes = new ArrayList();//<IFeatureType> |
105 |
private File dxfFile; |
106 |
// protected ArrayList featuresAux=new ArrayList();
|
107 |
protected IMetadata metadata;
|
108 |
|
109 |
private IProjection projection;
|
110 |
private DXFStoreParameters dxfParameters;
|
111 |
|
112 |
public void init(IDataStoreParameters parameters) throws InitializeException { |
113 |
super.init(parameters);
|
114 |
dxfParameters=(DXFStoreParameters)parameters; |
115 |
dxfFile=((DXFStoreParameters)parameters).getFile(); |
116 |
projection=((DXFStoreParameters)parameters).getProjection(); |
117 |
} |
118 |
|
119 |
static IFeatureType newFeatureType(){
|
120 |
DefaultFeatureType fType= new DefaultFeatureType();
|
121 |
|
122 |
try{
|
123 |
DefaultAttributeDescriptor descriptorID = new DefaultAttributeDescriptor();
|
124 |
descriptorID.loading(); |
125 |
descriptorID.setType(IFeatureAttributeDescriptor.TYPE_INT); |
126 |
descriptorID.setName("ID");
|
127 |
descriptorID.setDefaultValue(new Integer(0)); |
128 |
descriptorID.stopLoading(); |
129 |
fType.add(descriptorID); |
130 |
|
131 |
DefaultAttributeDescriptor descriptorShape = new DefaultAttributeDescriptor();
|
132 |
descriptorShape.loading(); |
133 |
descriptorShape.setType(IFeatureAttributeDescriptor.TYPE_GEOMETRY); |
134 |
descriptorShape.setName("GEOMETRY");
|
135 |
descriptorShape.setDefaultValue(null);
|
136 |
descriptorShape.stopLoading(); |
137 |
fType.add(descriptorShape); |
138 |
fType.setDefaultGeometry("GEOMETRY");
|
139 |
|
140 |
DefaultAttributeDescriptor descriptorEntity = new DefaultAttributeDescriptor();
|
141 |
descriptorEntity.loading(); |
142 |
descriptorEntity.setType(IFeatureAttributeDescriptor.TYPE_STRING); |
143 |
descriptorEntity.setName("Entity");
|
144 |
descriptorEntity.setDefaultValue("Entity");
|
145 |
descriptorEntity.stopLoading(); |
146 |
fType.add(descriptorEntity); |
147 |
|
148 |
DefaultAttributeDescriptor descriptorLayer = new DefaultAttributeDescriptor();
|
149 |
descriptorLayer.loading(); |
150 |
descriptorLayer.setType(IFeatureAttributeDescriptor.TYPE_STRING); |
151 |
descriptorLayer.setName("Layer");
|
152 |
descriptorLayer.setDefaultValue("default");
|
153 |
descriptorLayer.stopLoading(); |
154 |
fType.add(descriptorLayer); |
155 |
|
156 |
DefaultAttributeDescriptor descriptorColor = new DefaultAttributeDescriptor();
|
157 |
descriptorColor.loading(); |
158 |
descriptorColor.setType(IFeatureAttributeDescriptor.TYPE_INT); |
159 |
descriptorColor.setName("Color");
|
160 |
descriptorColor.setDefaultValue(new Integer(0)); |
161 |
descriptorColor.stopLoading(); |
162 |
fType.add(descriptorColor); |
163 |
|
164 |
DefaultAttributeDescriptor descriptorElevation = new DefaultAttributeDescriptor();
|
165 |
descriptorElevation.loading(); |
166 |
descriptorElevation.setType(IFeatureAttributeDescriptor.TYPE_DOUBLE); |
167 |
descriptorElevation.setName("Elevation");
|
168 |
descriptorElevation.setDefaultValue(new Double(0)); |
169 |
descriptorElevation.stopLoading(); |
170 |
fType.add(descriptorElevation); |
171 |
|
172 |
DefaultAttributeDescriptor descriptorThickness = new DefaultAttributeDescriptor();
|
173 |
descriptorThickness.loading(); |
174 |
descriptorThickness.setType(IFeatureAttributeDescriptor.TYPE_DOUBLE); |
175 |
descriptorThickness.setName("Thickness");
|
176 |
descriptorThickness.setDefaultValue(new Double(0)); |
177 |
descriptorThickness.stopLoading(); |
178 |
fType.add(descriptorThickness); |
179 |
|
180 |
DefaultAttributeDescriptor descriptorText = new DefaultAttributeDescriptor();
|
181 |
descriptorText.loading(); |
182 |
descriptorText.setType(IFeatureAttributeDescriptor.TYPE_STRING); |
183 |
descriptorText.setName("Text");
|
184 |
descriptorText.setDefaultValue("");
|
185 |
descriptorText.stopLoading(); |
186 |
fType.add(descriptorText); |
187 |
|
188 |
DefaultAttributeDescriptor descriptorHeightText = new DefaultAttributeDescriptor();
|
189 |
descriptorHeightText.loading(); |
190 |
descriptorHeightText.setType(IFeatureAttributeDescriptor.TYPE_FLOAT); |
191 |
descriptorHeightText.setName("HeightText");
|
192 |
descriptorHeightText.setDefaultValue(new Float(10)); |
193 |
descriptorHeightText.stopLoading(); |
194 |
fType.add(descriptorHeightText); |
195 |
|
196 |
DefaultAttributeDescriptor descriptorRotationText = new DefaultAttributeDescriptor();
|
197 |
descriptorRotationText.loading(); |
198 |
descriptorRotationText.setType(IFeatureAttributeDescriptor.TYPE_DOUBLE); |
199 |
descriptorRotationText.setName("Rotation");
|
200 |
descriptorRotationText.setDefaultValue(new Double(10)); |
201 |
descriptorRotationText.stopLoading(); |
202 |
fType.add(descriptorRotationText); |
203 |
}catch (IsNotAttributeSettingException e) {
|
204 |
e.printStackTrace(); |
205 |
} |
206 |
|
207 |
return fType;
|
208 |
|
209 |
} |
210 |
|
211 |
private void initializeFeatureType() { |
212 |
featureType= newFeatureType(); |
213 |
} |
214 |
|
215 |
protected void doFinishEdition() throws WriteException, ReadException { |
216 |
IFeaturesWriter writer = getFeaturesWriter(); |
217 |
writer.init(this);
|
218 |
writer.updateFeatureType(featureType); |
219 |
writer.preProcess(); |
220 |
Collection collection=getDataCollection();
|
221 |
Iterator iterator=collection.iterator();
|
222 |
IFeature feature; |
223 |
while (iterator.hasNext()) {
|
224 |
feature= (IFeature) iterator.next(); |
225 |
writer.insertFeature(feature); |
226 |
} |
227 |
writer.postProcess(); |
228 |
|
229 |
} |
230 |
|
231 |
public IDataCollection getDataCollection(IFeatureType type, String filter, String order) throws ReadException { |
232 |
if (type==null){ |
233 |
type=getDefaultFeatureType(); |
234 |
} |
235 |
IFeatureCollection coll; |
236 |
|
237 |
//TODO aplicar filtro, orden e incluso y el featureType
|
238 |
FeatureFilter parser = null;
|
239 |
if (filter!=null){ |
240 |
parser = new FeatureFilter(filter,type);
|
241 |
} |
242 |
ArrayList originalFeatures=this.getFeatures(); |
243 |
int num=0; |
244 |
if (featureManager!=null){ |
245 |
num=featureManager.getNum(); |
246 |
} |
247 |
int originalSize=originalFeatures.size();
|
248 |
Collection allFeatures=null; |
249 |
if (order!=null){ |
250 |
Comparator comparator = new FeatureComparator(type,order); |
251 |
allFeatures = new TreeSet(comparator); |
252 |
}else{
|
253 |
allFeatures=new ArrayList(); |
254 |
} |
255 |
for (int i = 0; i < originalSize+num; i++) { |
256 |
IFeature feature=null;
|
257 |
if (i<this.getFeatureCount()){ |
258 |
feature=this.getFeature(i);
|
259 |
}else{
|
260 |
try {
|
261 |
feature=featureManager.getFeature(i-originalSize,this);
|
262 |
} catch (IsNotFeatureSettingException e) {
|
263 |
throw new ReadException(this.getName(),e); |
264 |
} |
265 |
} |
266 |
if (featureManager == null || !featureManager.isDeleted(feature)){ |
267 |
try {
|
268 |
MemoryFeature auxfeature=new MemoryFeature(type,false); |
269 |
auxfeature.loading(); |
270 |
// auxfeature.setDefaultGeometry(feature.getDefaultGeometry());
|
271 |
Iterator iterator=type.iterator();
|
272 |
while (iterator.hasNext()) {
|
273 |
IFeatureAttributeDescriptor fad = (IFeatureAttributeDescriptor) iterator.next(); |
274 |
int index=((DefaultAttributeDescriptor)fad).originalPosition();
|
275 |
auxfeature.set(index,feature.get(index)); |
276 |
} |
277 |
if (filter==null || parser.match(auxfeature)){ |
278 |
allFeatures.add(auxfeature); |
279 |
} |
280 |
auxfeature.stopLoading(); |
281 |
|
282 |
} catch (ReadException e) {
|
283 |
// TODO Auto-generated catch block
|
284 |
e.printStackTrace(); |
285 |
} |
286 |
} |
287 |
|
288 |
} |
289 |
|
290 |
coll=new DXFFeatureCollection(allFeatures);
|
291 |
this.addObserver(new WeakReference(coll)); |
292 |
return coll;
|
293 |
|
294 |
} |
295 |
|
296 |
public IFeature getFeatureByID(IFeatureID id) throws ReadException { |
297 |
if (this.alterMode){ |
298 |
if (featureManager.contains(id)) {
|
299 |
try {
|
300 |
return featureManager.getFeature(id,this); |
301 |
} catch (IsNotFeatureSettingException e) {
|
302 |
throw new ReadException(this.getName(),e); |
303 |
} |
304 |
} |
305 |
} |
306 |
return id.getFeature(featureType);
|
307 |
} |
308 |
|
309 |
public List getFeatureTypes() { |
310 |
featureTypes.set(0,getDefaultFeatureType());
|
311 |
return featureTypes;
|
312 |
} |
313 |
|
314 |
public IFeatureType getDefaultFeatureType() {
|
315 |
if (isEditing()){
|
316 |
// Aqu? hay que construir un FeatureType con los cambios que se hayan hecho en la edici?n.
|
317 |
return attributeManager.getFeatureType();
|
318 |
} |
319 |
return featureType;
|
320 |
} |
321 |
|
322 |
public boolean isWithDefaultLegend() { |
323 |
return false; |
324 |
} |
325 |
|
326 |
public Object getDefaultLegend() { |
327 |
return null; |
328 |
} |
329 |
|
330 |
public Object getDefaultLabelingStrategy() { |
331 |
return null; |
332 |
} |
333 |
|
334 |
public boolean canAlterFeatureType() { |
335 |
return true; |
336 |
} |
337 |
|
338 |
public String getName() { |
339 |
return DATASTORE_NAME;
|
340 |
} |
341 |
|
342 |
public void open() throws OpenException { |
343 |
this.observable.notifyObservers(
|
344 |
new FeatureStoreNotification(this,FeatureStoreNotification.BEFORE_OPEN) |
345 |
); |
346 |
float heightText = 10; |
347 |
|
348 |
attr.setLoadedInMemory(true);
|
349 |
|
350 |
|
351 |
featureMaker = new DxfFeatureMaker(projection);
|
352 |
headerManager = new DxfHeaderManager();
|
353 |
dxfFeatureFile = new DxfFile(projection, dxfFile.getAbsolutePath(),
|
354 |
featureMaker, headerManager); |
355 |
try {
|
356 |
dxfFeatureFile.load(); |
357 |
} catch (Exception e1) { |
358 |
throw new OpenException(getName(),e1); |
359 |
} |
360 |
features = (IObjList.vector) ((DxfFeatureMaker) featureMaker) |
361 |
.getObjects(); |
362 |
String acadVersion = (String) ((DxfHeaderManager) headerManager) |
363 |
.getAcadVersion(); |
364 |
System.out.println("initialize(): acadVersion = " + acadVersion); |
365 |
if (!featureMaker.isDxf3DFile() && !headerManager.isWritedDxf3D()) { // y no |
366 |
// est?n
|
367 |
// todos
|
368 |
// a
|
369 |
// 9999
|
370 |
Feature[] features2D = new Feature[features.size()]; |
371 |
for (int i = 0; i < features.size(); i++) { |
372 |
Feature fea = (Feature) features.get(i); |
373 |
if (fea.getGeometry() instanceof org.cresques.px.gml.Point3D) { |
374 |
Point point = (Point) fea.getGeometry(); |
375 |
Point point2 = new Point(); |
376 |
for (int j = 0; j < point.pointNr(); j++) { |
377 |
point2.add(point.get(j)); |
378 |
} |
379 |
point2.setTextPoint(point.isTextPoint()); |
380 |
fea.setGeometry(point2); |
381 |
features2D[i] = fea; |
382 |
// } else if (fea.getGeometry() instanceof InsPoint3D) {
|
383 |
// InsPoint insPoint = (InsPoint)fea.getGeometry();
|
384 |
// InsPoint insPoint2 = new InsPoint();
|
385 |
// for (int j=0;j<insPoint.pointNr();j++) {
|
386 |
// insPoint2.add(insPoint.get(j));
|
387 |
// }
|
388 |
// fea.setGeometry(insPoint2);
|
389 |
// features2D[i] = fea;
|
390 |
} else if (fea.getGeometry() instanceof LineString3D) { |
391 |
LineString lineString = (LineString) fea.getGeometry(); |
392 |
LineString lineString2 = new LineString();
|
393 |
for (int j = 0; j < lineString.pointNr(); j++) { |
394 |
lineString2.add(lineString.get(j)); |
395 |
} |
396 |
fea.setGeometry(lineString2); |
397 |
features2D[i] = fea; |
398 |
} else if (fea.getGeometry() instanceof Polygon3D) { |
399 |
Polygon polygon = (Polygon) fea.getGeometry(); |
400 |
Polygon polygon2 = new Polygon(); |
401 |
for (int j = 0; j < polygon.pointNr(); j++) { |
402 |
polygon2.add(polygon.get(j)); |
403 |
} |
404 |
fea.setGeometry(polygon2); |
405 |
features2D[i] = fea; |
406 |
} |
407 |
} |
408 |
features.clear(); |
409 |
for (int i = 0; i < features2D.length; i++) { |
410 |
features.add(features2D[i]); |
411 |
} |
412 |
} |
413 |
// String acadVersion =
|
414 |
// (String)((DxfHeaderManager)headerManager).getAcadVersion();
|
415 |
// System.out.println("initialize(): acadVersion = " + acadVersion);
|
416 |
|
417 |
int nAtt = featureMaker.getAttributes().size();
|
418 |
|
419 |
// Campos de las MemoryLayer:
|
420 |
|
421 |
// Object[] auxRow = new Object[10 + nAtt];
|
422 |
// ArrayList arrayFields = new ArrayList();
|
423 |
// arrayFields.add("ID");
|
424 |
// arrayFields.add("FShape");
|
425 |
// arrayFields.add("Entity");
|
426 |
// arrayFields.add("Layer");
|
427 |
// arrayFields.add("Color");
|
428 |
// arrayFields.add("Elevation");
|
429 |
// arrayFields.add("Thickness");
|
430 |
// arrayFields.add("Text");
|
431 |
// arrayFields.add("HeightText");
|
432 |
// arrayFields.add("RotationText");
|
433 |
initializeFeatureType(); |
434 |
|
435 |
|
436 |
|
437 |
|
438 |
for (int i = 0; i < nAtt; i++) { |
439 |
String att[] = new String[2]; |
440 |
att = (String[]) featureMaker.getAttributes().get(i); |
441 |
|
442 |
DefaultAttributeDescriptor descriptorAux = new DefaultAttributeDescriptor();
|
443 |
try {
|
444 |
descriptorAux.loading(); |
445 |
descriptorAux.setType(IFeatureAttributeDescriptor.TYPE_STRING); |
446 |
descriptorAux.setName(att[0]);
|
447 |
descriptorAux.setDefaultValue("");
|
448 |
descriptorAux.stopLoading(); |
449 |
} catch (IsNotAttributeSettingException e) {
|
450 |
e.printStackTrace(); |
451 |
} |
452 |
featureType.add(descriptorAux); |
453 |
|
454 |
|
455 |
// arrayFields.add(att[0]);
|
456 |
} |
457 |
|
458 |
labeling = new AttrInTableLabelingStrategy();
|
459 |
((AttrInTableLabelingStrategy) labeling).setTextFieldId(ID_FIELD_TEXT); |
460 |
((AttrInTableLabelingStrategy) labeling).setRotationFieldId(ID_FIELD_ROTATIONTEXT); |
461 |
((AttrInTableLabelingStrategy) labeling).setHeightFieldId(ID_FIELD_HEIGHTTEXT); |
462 |
((AttrInTableLabelingStrategy) labeling).setUnit(1); //MapContext.NAMES[1] (meters) |
463 |
|
464 |
// getTableModel().setColumnIdentifiers(arrayFields.toArray());
|
465 |
|
466 |
for (int i = 0; i < features.size(); i++) { |
467 |
|
468 |
MemoryFeature feature = new MemoryFeature(featureType,true); |
469 |
// auxRow[ID_FIELD_HEIGHTTEXT] = new Double(0.0);
|
470 |
// auxRow[ID_FIELD_ROTATIONTEXT] = new Double(0.0);
|
471 |
// auxRow[ID_FIELD_TEXT] = null;
|
472 |
try{
|
473 |
feature.loading(); |
474 |
Feature fea = (Feature) features.get(i); |
475 |
if (fea.getGeometry() instanceof Point |
476 |
&& !(fea.getGeometry() instanceof org.cresques.px.gml.Point3D)) {
|
477 |
Point point = (Point) fea.getGeometry(); |
478 |
Point2D pto = new Point2D.Double(); |
479 |
pto = point.get(0);
|
480 |
FShape nuevoShp; |
481 |
if (point.isTextPoint()) {
|
482 |
feature.set(ID_FIELD_ID,i); |
483 |
// auxRow[ID_FIELD_ID] = new Integer(i);
|
484 |
// feature.set(ID_FIELD_FSHAPE,"Point2D");
|
485 |
// auxRow[ID_FIELD_FSHAPE] = new String("FPoint2D");
|
486 |
feature.set(ID_FIELD_ENTITY,fea.getProp("dxfEntity"));
|
487 |
// auxRow[ID_FIELD_ENTITY] = new String(fea.getProp("dxfEntity"));
|
488 |
feature.set(ID_FIELD_LAYER,fea.getProp("layer"));
|
489 |
// auxRow[ID_FIELD_LAYER] = new String(fea.getProp("layer"));
|
490 |
int auxInt = Integer.parseInt(fea.getProp("color")); |
491 |
feature.set(ID_FIELD_COLOR,auxInt); |
492 |
// auxRow[ID_FIELD_COLOR] = new Integer(auxInt);
|
493 |
feature.set(ID_FIELD_TEXT,fea.getProp("text"));
|
494 |
// auxRow[ID_FIELD_TEXT] = ValueFactory
|
495 |
// .createValue(new String(fea.getProp("text")));
|
496 |
heightText = Float.parseFloat(fea.getProp("textHeight")); |
497 |
feature.set(ID_FIELD_HEIGHTTEXT,heightText); |
498 |
// auxRow[ID_FIELD_HEIGHTTEXT] = ValueFactory
|
499 |
// .createValue(heightText);
|
500 |
double auxR = Double.parseDouble(fea |
501 |
.getProp("textRotation"));
|
502 |
feature.set(ID_FIELD_ROTATIONTEXT,auxR); |
503 |
// auxRow[ID_FIELD_ROTATIONTEXT] = ValueFactory
|
504 |
// .createValue(auxR);
|
505 |
double auxE = Double.parseDouble(fea.getProp("elevation")); |
506 |
feature.set(ID_FIELD_ELEVATION,auxE); |
507 |
// auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(auxE);
|
508 |
double auxT = Double.parseDouble(fea.getProp("thickness")); |
509 |
feature.set(ID_FIELD_THICKNESS,auxT); |
510 |
// auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(auxT);
|
511 |
// Attributes
|
512 |
for (int j = 0; j < nAtt; j++) { |
513 |
String[] attributes = new String[2]; |
514 |
attributes = (String[]) featureMaker.getAttributes() |
515 |
.get(j); |
516 |
feature.set(10+j,attributes[1]); |
517 |
// auxRow[10 + j] = ValueFactory.createValue(new String(
|
518 |
// attributes[1]));
|
519 |
if (!fea.getProp(attributes[0]).equals(attributes[1])) { |
520 |
feature.set(10+j,fea.getProp(attributes[0])); |
521 |
// auxRow[10 + j] = ValueFactory
|
522 |
// .createValue(new String(fea
|
523 |
// .getProp(attributes[0])));
|
524 |
} |
525 |
} |
526 |
IGeometry geom=ShapeFactory.createPoint2D(new FPoint2D(pto.getX(), pto.getY()));
|
527 |
feature.set(ID_FIELD_FSHAPE,geom); |
528 |
// feature.setDefaultGeometry(geom);
|
529 |
addFeature(feature); |
530 |
|
531 |
// addShape(nuevoShp, auxRow);
|
532 |
} else {
|
533 |
feature.set(ID_FIELD_ID,i); |
534 |
// auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
|
535 |
// feature.set(ID_FIELD_FSHAPE,"Point2D");
|
536 |
// auxRow[ID_FIELD_FSHAPE] = ValueFactory
|
537 |
// .createValue(new String("FPoint2D"));
|
538 |
feature.set(ID_FIELD_ENTITY,fea.getProp("dxfEntity"));
|
539 |
// auxRow[ID_FIELD_ENTITY] = ValueFactory
|
540 |
// .createValue(new String(fea.getProp("dxfEntity")));
|
541 |
feature.set(ID_FIELD_LAYER,fea.getProp("layer"));
|
542 |
// auxRow[ID_FIELD_LAYER] = ValueFactory
|
543 |
// .createValue(new String(fea.getProp("layer")));
|
544 |
int auxInt = Integer.parseInt(fea.getProp("color")); |
545 |
feature.set(ID_FIELD_COLOR,auxInt); |
546 |
// auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(auxInt);
|
547 |
double auxE = Double.parseDouble(fea.getProp("elevation")); |
548 |
feature.set(ID_FIELD_ELEVATION,auxE); |
549 |
// auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(auxE);
|
550 |
double auxT = Double.parseDouble(fea.getProp("thickness")); |
551 |
feature.set(ID_FIELD_THICKNESS,auxT); |
552 |
// auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(auxT);
|
553 |
// Attributes
|
554 |
for (int j = 0; j < nAtt; j++) { |
555 |
String[] attributes = new String[2]; |
556 |
attributes = (String[]) featureMaker.getAttributes() |
557 |
.get(j); |
558 |
feature.set(10+j,attributes[1]); |
559 |
// auxRow[10 + j] = ValueFactory.createValue(new String(
|
560 |
// attributes[1]));
|
561 |
if (!fea.getProp(attributes[0]).equals(attributes[1])) { |
562 |
feature.set(10+j,fea.getProp(attributes[0])); |
563 |
// auxRow[10 + j] = ValueFactory
|
564 |
// .createValue(new String(fea
|
565 |
// .getProp(attributes[0])));
|
566 |
} |
567 |
} |
568 |
IGeometry geom=ShapeFactory.createPoint2D(new FPoint2D(pto.getX(), pto.getY()));
|
569 |
feature.set(ID_FIELD_FSHAPE,geom); |
570 |
// feature.setDefaultGeometry(geom);
|
571 |
addFeature(feature); |
572 |
// addShape(nuevoShp, auxRow);
|
573 |
} |
574 |
} else if (fea.getGeometry() instanceof org.cresques.px.gml.Point3D) { |
575 |
org.cresques.px.gml.Point3D point = (org.cresques.px.gml.Point3D) fea |
576 |
.getGeometry(); |
577 |
Point3D pto = new Point3D();
|
578 |
pto = point.getPoint3D(0);
|
579 |
FShape nuevoShp; |
580 |
if (point.isTextPoint()) {
|
581 |
feature.set(ID_FIELD_ID,i); |
582 |
// auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
|
583 |
feature.set(ID_FIELD_FSHAPE,"Point3D");
|
584 |
// auxRow[ID_FIELD_FSHAPE] = ValueFactory
|
585 |
// .createValue(new String("FPoint3D"));
|
586 |
feature.set(ID_FIELD_ENTITY,fea.getProp("dxfEntity"));
|
587 |
// auxRow[ID_FIELD_ENTITY] = ValueFactory
|
588 |
// .createValue(new String(fea.getProp("dxfEntity")));
|
589 |
feature.set(ID_FIELD_LAYER,fea.getProp("layer"));
|
590 |
// auxRow[ID_FIELD_LAYER] = ValueFactory
|
591 |
// .createValue(new String(fea.getProp("layer")));
|
592 |
int auxInt = Integer.parseInt(fea.getProp("color")); |
593 |
feature.set(ID_FIELD_COLOR,auxInt); |
594 |
// auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(auxInt);
|
595 |
feature.set(ID_FIELD_TEXT,fea.getProp("text"));
|
596 |
// auxRow[ID_FIELD_TEXT] = ValueFactory
|
597 |
// .createValue(new String(fea.getProp("text")));
|
598 |
heightText = Float.parseFloat(fea.getProp("textHeight")); |
599 |
feature.set(ID_FIELD_HEIGHTTEXT,heightText); |
600 |
// auxRow[ID_FIELD_HEIGHTTEXT] = ValueFactory
|
601 |
// .createValue(heightText);
|
602 |
double auxR = Double.parseDouble(fea |
603 |
.getProp("textRotation"));
|
604 |
feature.set(ID_FIELD_ROTATIONTEXT,auxR); |
605 |
// auxRow[ID_FIELD_ROTATIONTEXT] = ValueFactory
|
606 |
// .createValue(auxR);
|
607 |
double auxE = Double.parseDouble(fea.getProp("elevation")); |
608 |
feature.set(ID_FIELD_ELEVATION,auxE); |
609 |
// auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(auxE);
|
610 |
double auxT = Double.parseDouble(fea.getProp("thickness")); |
611 |
feature.set(ID_FIELD_THICKNESS,auxT); |
612 |
// auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(auxT);
|
613 |
// Attributes
|
614 |
for (int j = 0; j < nAtt; j++) { |
615 |
String[] attributes = new String[2]; |
616 |
attributes = (String[]) featureMaker.getAttributes() |
617 |
.get(j); |
618 |
feature.set(10+j,attributes[1]); |
619 |
// auxRow[10 + j] = ValueFactory.createValue(new String(
|
620 |
// attributes[1]));
|
621 |
if (!fea.getProp(attributes[0]).equals(attributes[1])) { |
622 |
feature.set(10+j,fea.getProp(attributes[0])); |
623 |
// auxRow[10 + j] = ValueFactory
|
624 |
// .createValue(new String(fea
|
625 |
// .getProp(attributes[0])));
|
626 |
} |
627 |
} |
628 |
IGeometry geom=ShapeFactory.createPoint3D(pto.getX(), pto.getY(), pto.getZ()); |
629 |
feature.set(ID_FIELD_FSHAPE,geom); |
630 |
// feature.setDefaultGeometry(geom);
|
631 |
addFeature(feature); |
632 |
// addShape(nuevoShp, auxRow);
|
633 |
} else {
|
634 |
feature.set(ID_FIELD_ID,i); |
635 |
// auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
|
636 |
feature.set(ID_FIELD_FSHAPE,"Point3D");
|
637 |
// auxRow[ID_FIELD_FSHAPE] = ValueFactory
|
638 |
// .createValue(new String("FPoint3D"));
|
639 |
feature.set(ID_FIELD_ENTITY,fea.getProp("dxfEntity"));
|
640 |
// auxRow[ID_FIELD_ENTITY] = ValueFactory
|
641 |
// .createValue(new String(fea.getProp("dxfEntity")));
|
642 |
feature.set(ID_FIELD_LAYER,fea.getProp("layer"));
|
643 |
// auxRow[ID_FIELD_LAYER] = ValueFactory
|
644 |
// .createValue(new String(fea.getProp("layer")));
|
645 |
int auxInt = Integer.parseInt(fea.getProp("color")); |
646 |
feature.set(ID_FIELD_COLOR,auxInt); |
647 |
// auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(auxInt);
|
648 |
|
649 |
double auxE = Double.parseDouble(fea.getProp("elevation")); |
650 |
feature.set(ID_FIELD_ELEVATION,auxE); |
651 |
// auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(auxE);
|
652 |
double auxT = Double.parseDouble(fea.getProp("thickness")); |
653 |
feature.set(ID_FIELD_THICKNESS,auxT); |
654 |
// auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(auxT);
|
655 |
// Attributes
|
656 |
for (int j = 0; j < nAtt; j++) { |
657 |
String[] attributes = new String[2]; |
658 |
attributes = (String[]) featureMaker.getAttributes() |
659 |
.get(j); |
660 |
feature.set(10+j,attributes[1]); |
661 |
// auxRow[10 + j] = ValueFactory.createValue(new String(
|
662 |
// attributes[1]));
|
663 |
if (!fea.getProp(attributes[0]).equals(attributes[1])) { |
664 |
feature.set(10+j,fea.getProp(attributes[0])); |
665 |
// auxRow[10 + j] = ValueFactory
|
666 |
// .createValue(new String(fea
|
667 |
// .getProp(attributes[0])));
|
668 |
} |
669 |
} |
670 |
IGeometry geom=ShapeFactory.createPoint3D(pto.getX(), pto.getY(), pto.getZ()); |
671 |
feature.set(ID_FIELD_FSHAPE,geom); |
672 |
// feature.setDefaultGeometry(geom);
|
673 |
addFeature(feature); |
674 |
// addShape(nuevoShp, auxRow);
|
675 |
} |
676 |
} else if (fea.getGeometry() instanceof LineString |
677 |
&& !(fea.getGeometry() instanceof LineString3D)) {
|
678 |
GeneralPathX genPathX = new GeneralPathX();
|
679 |
Point2D[] pts = new Point2D[fea.getGeometry().pointNr()]; |
680 |
for (int j = 0; j < fea.getGeometry().pointNr(); j++) { |
681 |
pts[j] = fea.getGeometry().get(j); |
682 |
} |
683 |
genPathX.moveTo(pts[0].getX(), pts[0].getY()); |
684 |
for (int j = 1; j < pts.length; j++) { |
685 |
genPathX.lineTo(pts[j].getX(), pts[j].getY()); |
686 |
} |
687 |
feature.set(ID_FIELD_ID,i); |
688 |
// auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
|
689 |
feature.set(ID_FIELD_FSHAPE,"Polyline2D");
|
690 |
// auxRow[ID_FIELD_FSHAPE] = ValueFactory.createValue(new String(
|
691 |
// "FPolyline2D"));
|
692 |
feature.set(ID_FIELD_ENTITY,fea.getProp("dxfEntity"));
|
693 |
// auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String(
|
694 |
// fea.getProp("dxfEntity")));
|
695 |
feature.set(ID_FIELD_LAYER,fea.getProp("layer"));
|
696 |
// auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String(
|
697 |
// fea.getProp("layer")));
|
698 |
int auxInt = Integer.parseInt(fea.getProp("color")); |
699 |
feature.set(ID_FIELD_COLOR,auxInt); |
700 |
// auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(auxInt);
|
701 |
double auxE = Double.parseDouble(fea.getProp("elevation")); |
702 |
feature.set(ID_FIELD_ELEVATION,auxE); |
703 |
// auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(auxE);
|
704 |
double auxT = Double.parseDouble(fea.getProp("thickness")); |
705 |
feature.set(ID_FIELD_THICKNESS,auxT); |
706 |
// auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(auxT);
|
707 |
// Attributes
|
708 |
for (int j = 0; j < nAtt; j++) { |
709 |
String[] attributes = new String[2]; |
710 |
attributes = (String[]) featureMaker.getAttributes().get(j); |
711 |
feature.set(10+j,attributes[1]); |
712 |
// auxRow[10 + j] = ValueFactory.createValue(new String(
|
713 |
// attributes[1]));
|
714 |
if (!fea.getProp(attributes[0]).equals(attributes[1])) { |
715 |
feature.set(10+j,fea.getProp(attributes[0])); |
716 |
// auxRow[10 + j] = ValueFactory.createValue(new String(
|
717 |
// fea.getProp(attributes[0])));
|
718 |
} |
719 |
} |
720 |
IGeometry geom=ShapeFactory.createPolyline2D(genPathX); |
721 |
feature.set(ID_FIELD_FSHAPE,geom); |
722 |
// feature.setDefaultGeometry(geom);
|
723 |
addFeature(feature); |
724 |
// addShape(nuevoShp, auxRow);
|
725 |
} else if (fea.getGeometry() instanceof LineString3D) { |
726 |
GeneralPathX genPathX = new GeneralPathX();
|
727 |
Point3D[] pts = new Point3D[fea.getGeometry().pointNr()]; |
728 |
for (int j = 0; j < fea.getGeometry().pointNr(); j++) { |
729 |
pts[j] = ((LineString3D) fea.getGeometry()).getPoint3D(j); |
730 |
} |
731 |
genPathX.moveTo(pts[0].getX(), pts[0].getY()); |
732 |
for (int j = 1; j < pts.length; j++) { |
733 |
genPathX.lineTo(pts[j].getX(), pts[j].getY()); |
734 |
} |
735 |
double[] elevations = new double[pts.length]; |
736 |
for (int j = 0; j < pts.length; j++) { |
737 |
elevations[j] = pts[j].getZ(); |
738 |
} |
739 |
feature.set(ID_FIELD_ID,i); |
740 |
// auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
|
741 |
feature.set(ID_FIELD_FSHAPE,"Polyline3D");
|
742 |
// auxRow[ID_FIELD_FSHAPE] = ValueFactory.createValue(new String(
|
743 |
// "FPolyline3D"));
|
744 |
feature.set(ID_FIELD_ENTITY,fea.getProp("dxfEntity"));
|
745 |
// auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String(
|
746 |
// fea.getProp("dxfEntity")));
|
747 |
feature.set(ID_FIELD_LAYER,fea.getProp("layer"));
|
748 |
// auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String(
|
749 |
// fea.getProp("layer")));
|
750 |
int auxInt = Integer.parseInt(fea.getProp("color")); |
751 |
feature.set(ID_FIELD_COLOR,auxInt); |
752 |
// auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(auxInt);
|
753 |
if (fea.getProp("elevation") != null) { |
754 |
double auxE = Double.parseDouble(fea.getProp("elevation")); |
755 |
feature.set(ID_FIELD_ELEVATION,auxE); |
756 |
// auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(auxE);
|
757 |
} |
758 |
double auxT = Double.parseDouble(fea.getProp("thickness")); |
759 |
feature.set(ID_FIELD_THICKNESS,auxT); |
760 |
// auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(auxT);
|
761 |
// Attributes
|
762 |
for (int j = 0; j < nAtt; j++) { |
763 |
String[] attributes = new String[2]; |
764 |
attributes = (String[]) featureMaker.getAttributes().get(j); |
765 |
feature.set(10+j,attributes[1]); |
766 |
// auxRow[10 + j] = ValueFactory.createValue(new String(
|
767 |
// attributes[1]));
|
768 |
if (!fea.getProp(attributes[0]).equals(attributes[1])) { |
769 |
feature.set(10+j,fea.getProp(attributes[0])); |
770 |
// auxRow[10 + j] = ValueFactory.createValue(new String(
|
771 |
// fea.getProp(attributes[0])));
|
772 |
} |
773 |
} |
774 |
IGeometry geom=ShapeFactory.createPolyline3D(genPathX,elevations); |
775 |
feature.set(ID_FIELD_FSHAPE,geom); |
776 |
// feature.setDefaultGeometry(geom);
|
777 |
addFeature(feature); |
778 |
// addShape(nuevoShp, auxRow);
|
779 |
} else if (fea.getGeometry() instanceof Polygon |
780 |
&& !(fea.getGeometry() instanceof Polygon3D)) {
|
781 |
GeneralPathX genPathX = new GeneralPathX();
|
782 |
// 050112: A?ado una posici?n m?s para el punto que cierra y
|
783 |
// creo el objeto firstPt.
|
784 |
Point2D firstPt = new Point2D.Double(); |
785 |
firstPt = fea.getGeometry().get(0);
|
786 |
Point2D[] pts = new Point2D[fea.getGeometry().pointNr() + 1]; |
787 |
for (int j = 0; j < fea.getGeometry().pointNr(); j++) { |
788 |
pts[j] = fea.getGeometry().get(j); |
789 |
} |
790 |
// 050112: A?ado el primer punto al final para cerrar los
|
791 |
// pol?gonos.
|
792 |
pts[fea.getGeometry().pointNr()] = firstPt; |
793 |
genPathX.moveTo(pts[0].getX(), pts[0].getY()); |
794 |
for (int j = 1; j < pts.length; j++) { |
795 |
genPathX.lineTo(pts[j].getX(), pts[j].getY()); |
796 |
} |
797 |
feature.set(ID_FIELD_ID,i); |
798 |
// auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
|
799 |
feature.set(ID_FIELD_FSHAPE,"Polygon2D");
|
800 |
// auxRow[ID_FIELD_FSHAPE] = ValueFactory.createValue(new String(
|
801 |
// "FPolygon2D"));
|
802 |
feature.set(ID_FIELD_ENTITY,fea.getProp("dxfEntity"));
|
803 |
// auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String(
|
804 |
// fea.getProp("dxfEntity")));
|
805 |
feature.set(ID_FIELD_LAYER,fea.getProp("layer"));
|
806 |
// auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String(
|
807 |
// fea.getProp("layer")));
|
808 |
int auxInt = Integer.parseInt(fea.getProp("color")); |
809 |
feature.set(ID_FIELD_COLOR,auxInt); |
810 |
// auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(auxInt);
|
811 |
double auxE = Double.parseDouble(fea.getProp("elevation")); |
812 |
feature.set(ID_FIELD_ELEVATION,auxE); |
813 |
// auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(auxE);
|
814 |
double auxT = Double.parseDouble(fea.getProp("thickness")); |
815 |
feature.set(ID_FIELD_THICKNESS,auxT); |
816 |
// auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(auxT);
|
817 |
// Attributes
|
818 |
for (int j = 0; j < nAtt; j++) { |
819 |
String[] attributes = new String[2]; |
820 |
attributes = (String[]) featureMaker.getAttributes().get(j); |
821 |
feature.set(10+j,attributes[1]); |
822 |
// auxRow[10 + j] = ValueFactory.createValue(new String(
|
823 |
// attributes[1]));
|
824 |
if (!fea.getProp(attributes[0]).equals(attributes[1])) { |
825 |
feature.set(10+j,fea.getProp(attributes[0])); |
826 |
// auxRow[10 + j] = ValueFactory.createValue(new String(
|
827 |
// fea.getProp(attributes[0])));
|
828 |
} |
829 |
} |
830 |
IGeometry geom=ShapeFactory.createPolygon2D(genPathX); |
831 |
feature.set(ID_FIELD_FSHAPE,geom); |
832 |
// feature.setDefaultGeometry(geom);
|
833 |
addFeature(feature); |
834 |
// addShape(nuevoShp, auxRow);
|
835 |
} else if (fea.getGeometry() instanceof Polygon3D) { |
836 |
GeneralPathX genPathX = new GeneralPathX();
|
837 |
// 050112: A?ado una posici?n m?s para el punto que cierra y
|
838 |
// creo el objeto firstPt.
|
839 |
Point3D firstPt = new Point3D();
|
840 |
firstPt = ((Polygon3D) fea.getGeometry()) |
841 |
.getPoint3D(0);
|
842 |
Point3D[] pts = new Point3D[fea.getGeometry().pointNr() + 1]; |
843 |
for (int j = 0; j < fea.getGeometry().pointNr(); j++) { |
844 |
pts[j] = ((Polygon3D) fea.getGeometry()) |
845 |
.getPoint3D(j); |
846 |
} |
847 |
// 050112: A?ado el primer punto al final para cerrar los
|
848 |
// pol?gonos.
|
849 |
pts[fea.getGeometry().pointNr()] = firstPt; |
850 |
genPathX.moveTo(pts[0].getX(), pts[0].getY()); |
851 |
for (int j = 1; j < pts.length; j++) { |
852 |
genPathX.lineTo(pts[j].getX(), pts[j].getY()); |
853 |
} |
854 |
double[] elevations = new double[pts.length]; |
855 |
for (int j = 0; j < pts.length; j++) { |
856 |
elevations[j] = pts[j].getZ(); |
857 |
} |
858 |
feature.set(ID_FIELD_ID,i); |
859 |
// auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
|
860 |
feature.set(ID_FIELD_FSHAPE,"Polygon3D");
|
861 |
// auxRow[ID_FIELD_FSHAPE] = ValueFactory.createValue(new String(
|
862 |
// "FPolygon3D"));
|
863 |
feature.set(ID_FIELD_ENTITY,fea.getProp("dxfEntity"));
|
864 |
// auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String(
|
865 |
// fea.getProp("dxfEntity")));
|
866 |
feature.set(ID_FIELD_LAYER,fea.getProp("layer"));
|
867 |
// auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String(
|
868 |
// fea.getProp("layer")));
|
869 |
int auxInt = Integer.parseInt(fea.getProp("color")); |
870 |
feature.set(ID_FIELD_COLOR,auxInt); |
871 |
// auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(auxInt);
|
872 |
if (fea.getProp("elevation") != null) { |
873 |
double auxE = Double.parseDouble(fea.getProp("elevation")); |
874 |
feature.set(ID_FIELD_ELEVATION,auxE); |
875 |
// auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(auxE);
|
876 |
} |
877 |
double auxT = Double.parseDouble(fea.getProp("thickness")); |
878 |
feature.set(ID_FIELD_THICKNESS,auxT); |
879 |
// auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(auxT);
|
880 |
// Attributes
|
881 |
for (int j = 0; j < nAtt; j++) { |
882 |
String[] attributes = new String[2]; |
883 |
attributes = (String[]) featureMaker.getAttributes().get(j); |
884 |
feature.set(10+j,attributes[1]); |
885 |
// auxRow[10 + j] = ValueFactory.createValue(new String(
|
886 |
// attributes[1]));
|
887 |
if (!fea.getProp(attributes[0]).equals(attributes[1])) { |
888 |
feature.set(10+j,fea.getProp(attributes[0])); |
889 |
// auxRow[10 + j] = ValueFactory.createValue(new String(
|
890 |
// fea.getProp(attributes[0])));
|
891 |
} |
892 |
} |
893 |
IGeometry geom=ShapeFactory.createPolygon3D(genPathX,elevations); |
894 |
feature.set(ID_FIELD_FSHAPE,geom); |
895 |
// feature.setDefaultGeometry(geom);
|
896 |
addFeature(feature); |
897 |
// addShape(nuevoShp, auxRow);
|
898 |
} else {
|
899 |
// System.out.println("Detectado feature desconocido");
|
900 |
} |
901 |
feature.stopLoading(); |
902 |
}catch (IsNotFeatureSettingException e) {
|
903 |
e.printStackTrace(); |
904 |
} |
905 |
} |
906 |
|
907 |
defaultLegend = LegendFactory |
908 |
.createVectorialUniqueValueLegend(FShape.MULTI); |
909 |
defaultLegend.setClassifyingFieldNames(new String[] {"Color"}); |
910 |
defaultLegend.setClassifyingFieldTypes(new int[]{Types.INTEGER,Types.VARCHAR,Types.VARCHAR,Types.VARCHAR,Types.INTEGER,Types.DOUBLE,Types.DOUBLE}); |
911 |
|
912 |
Logger.getAnonymousLogger().info("DXFStore: should check if this is a text symbol"); |
913 |
ISymbol myDefaultSymbol = SymbologyFactory. |
914 |
createDefaultSymbolByShapeType(FShape.MULTI, Color.BLACK);
|
915 |
|
916 |
defaultLegend.setDefaultSymbol(myDefaultSymbol); |
917 |
|
918 |
// ISymbol theSymbol = null;
|
919 |
//
|
920 |
// for (long j = 0; j < featuresAux.size(); j++) {
|
921 |
// IFeature feat=(IFeature)featuresAux.get((int)j);
|
922 |
// int clave=feat.getInt(ID_FIELD_COLOR);
|
923 |
//// clave = (IntValue) rs.getFieldValue(j, ID_FIELD_COLOR);
|
924 |
// if (defaultLegend.getSymbolByValue(clave) == null) {
|
925 |
// theSymbol = SymbologyFactory.
|
926 |
// createDefaultSymbolByShapeType(
|
927 |
// FShape.MULTI,
|
928 |
// AcadColor.getColor(clave.getValue()));
|
929 |
// theSymbol.setDescription(clave.toString());
|
930 |
// // Asigna los colores de Autocad a los
|
931 |
// // bordes
|
932 |
// // de los pol?gonos.
|
933 |
// if (theSymbol instanceof IFillSymbol) {
|
934 |
// ((IFillSymbol) theSymbol).getOutline().setLineColor(AcadColor.getColor(clave
|
935 |
// .getValue()));
|
936 |
//
|
937 |
// }
|
938 |
// defaultLegend.addSymbol(clave, theSymbol);
|
939 |
// }
|
940 |
// } // for
|
941 |
|
942 |
|
943 |
this.observable.notifyObservers(
|
944 |
new FeatureStoreNotification(this,FeatureStoreNotification.AFTER_OPEN) |
945 |
); |
946 |
|
947 |
} |
948 |
|
949 |
public void close() throws CloseException { |
950 |
this.observable.notifyObservers(
|
951 |
new FeatureStoreNotification(this,FeatureStoreNotification.BEFORE_CLOSE) |
952 |
); |
953 |
super.close();
|
954 |
features.clear(); |
955 |
this.observable.notifyObservers(
|
956 |
new FeatureStoreNotification(this,FeatureStoreNotification.AFTER_CLOSE) |
957 |
); |
958 |
|
959 |
} |
960 |
|
961 |
public void dispose() throws CloseException { |
962 |
this.observable.notifyObservers(
|
963 |
new FeatureStoreNotification(this,FeatureStoreNotification.BEFORE_DISPOSE) |
964 |
); |
965 |
close(); |
966 |
this.observable.notifyObservers(
|
967 |
new FeatureStoreNotification(this,FeatureStoreNotification.AFTER_DISPOSE) |
968 |
); |
969 |
} |
970 |
|
971 |
public boolean isEditable() { |
972 |
return false; |
973 |
} |
974 |
|
975 |
public IMetadata getMetadata() throws BaseException { |
976 |
if (metadata==null){ |
977 |
IMetadataManager manager=MetadataManager.getManager(); |
978 |
metadata=manager.create(DATASTORE_NAME); |
979 |
IExtent extent=getFullExtent(); |
980 |
metadata.set("extent",extent);
|
981 |
String srs=getSRS();
|
982 |
metadata.set("srs",srs);
|
983 |
} |
984 |
if (this.alterMode){ |
985 |
IExtent extent=(IExtent)metadata.get("extent");
|
986 |
IFeatureCollection featureCollection=(IFeatureCollection)getDataCollection(); |
987 |
if (spatialManager.isFullExtentDirty()){
|
988 |
if (!featureCollection.isEmpty()){
|
989 |
Iterator featureIterator=featureCollection.iterator();
|
990 |
extent = ((IFeature)featureIterator.next()).getExtent(); |
991 |
while(featureIterator.hasNext()){
|
992 |
IFeature feature=(IFeature)featureIterator.next(); |
993 |
IExtent boundExtent=feature.getExtent(); |
994 |
if (boundExtent!=null) |
995 |
extent.add(boundExtent); |
996 |
} |
997 |
} |
998 |
} |
999 |
metadata.set("extent",extent);
|
1000 |
} |
1001 |
return metadata;
|
1002 |
} |
1003 |
private String getSRS() { |
1004 |
// TODO Auto-generated method stub
|
1005 |
return null; |
1006 |
} |
1007 |
|
1008 |
|
1009 |
protected IFeaturesWriter getFeaturesWriter() {
|
1010 |
IFeaturesWriter writer = new DXFFeaturesWriter();
|
1011 |
// writer.init(this);
|
1012 |
return writer;
|
1013 |
} |
1014 |
public IDataStoreParameters getParameters() {
|
1015 |
return parameters;
|
1016 |
} |
1017 |
|
1018 |
public IDataExplorer getExplorer() {
|
1019 |
DataManager dsm=DataManager.getManager(); |
1020 |
IDataExplorerParameters dsp = dsm.createDataExplorerParameters( |
1021 |
DXFDataExplorer.DATASOURCE_NAME); |
1022 |
((DataExplorerFileParameters)dsp).setSource(dxfParameters.getFile().getParentFile()); |
1023 |
|
1024 |
IDataExplorer src=null;
|
1025 |
try {
|
1026 |
src = dsm.createDataExplorer(dsp); |
1027 |
} catch (InitializeException e1) {
|
1028 |
e1.printStackTrace(); |
1029 |
} |
1030 |
return src;
|
1031 |
} |
1032 |
} |