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