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