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