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