root / branches / v2_0_0_prep / extensions / extDwg / src / org / gvsig / dwg / fmap / dal / store / dwg / DWGStoreProvider.java @ 29326
History | View | Annotate | Download (19.3 KB)
1 |
package org.gvsig.dwg.fmap.dal.store.dwg; |
---|---|
2 |
|
3 |
import java.io.File; |
4 |
import java.io.IOException; |
5 |
import java.util.ArrayList; |
6 |
import java.util.HashMap; |
7 |
import java.util.Iterator; |
8 |
import java.util.List; |
9 |
import java.util.Map; |
10 |
|
11 |
import org.cresques.cts.IProjection; |
12 |
import org.gvsig.dwg.lib.DwgFile; |
13 |
import org.gvsig.dwg.lib.DwgObject; |
14 |
import org.gvsig.dwg.lib.DwgVersionNotSupportedException; |
15 |
import org.gvsig.dwg.lib.IDwg2FMap; |
16 |
import org.gvsig.dwg.lib.IDwg3DTestable; |
17 |
import org.gvsig.dwg.lib.objects.DwgMText; |
18 |
import org.gvsig.dwg.lib.objects.DwgText; |
19 |
import org.gvsig.fmap.dal.DALLocator; |
20 |
import org.gvsig.fmap.dal.DataManager; |
21 |
import org.gvsig.fmap.dal.DataServerExplorer; |
22 |
import org.gvsig.fmap.dal.DataStoreNotification; |
23 |
import org.gvsig.fmap.dal.DataTypes; |
24 |
import org.gvsig.fmap.dal.exception.DataException; |
25 |
import org.gvsig.fmap.dal.exception.InitializeException; |
26 |
import org.gvsig.fmap.dal.exception.OpenException; |
27 |
import org.gvsig.fmap.dal.exception.ReadException; |
28 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
29 |
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor; |
30 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
31 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
32 |
import org.gvsig.fmap.dal.feature.FeatureType; |
33 |
import org.gvsig.fmap.dal.feature.exception.CreateGeometryException; |
34 |
import org.gvsig.fmap.dal.feature.exception.PerformEditingException; |
35 |
import org.gvsig.fmap.dal.feature.spi.FeatureProvider; |
36 |
import org.gvsig.fmap.dal.feature.spi.FeatureStoreProviderServices; |
37 |
import org.gvsig.fmap.dal.feature.spi.memory.AbstractMemoryStoreProvider; |
38 |
import org.gvsig.fmap.dal.resource.exception.AccessResourceException; |
39 |
import org.gvsig.fmap.dal.resource.exception.ResourceBeginException; |
40 |
import org.gvsig.fmap.dal.resource.file.FileResource; |
41 |
import org.gvsig.fmap.dal.resource.spi.ResourceConsumer; |
42 |
import org.gvsig.fmap.dal.resource.spi.ResourceProvider; |
43 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer; |
44 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorerParameters; |
45 |
import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
46 |
import org.gvsig.fmap.geom.Geometry; |
47 |
import org.gvsig.fmap.geom.GeometryLocator; |
48 |
import org.gvsig.fmap.geom.GeometryManager; |
49 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
50 |
import org.gvsig.fmap.geom.exception.CreateEnvelopeException; |
51 |
import org.gvsig.fmap.geom.primitive.Envelope; |
52 |
import org.gvsig.fmap.geom.primitive.Point; |
53 |
import org.gvsig.tools.ToolsLocator; |
54 |
import org.gvsig.tools.dynobject.DynClass; |
55 |
import org.gvsig.tools.dynobject.DynField; |
56 |
import org.gvsig.tools.dynobject.DynObjectManager; |
57 |
import org.gvsig.tools.dynobject.exception.DynMethodException; |
58 |
import org.gvsig.tools.exception.NotYetImplemented; |
59 |
import org.gvsig.tools.persistence.PersistenceException; |
60 |
import org.gvsig.tools.persistence.PersistentState; |
61 |
import org.slf4j.Logger; |
62 |
import org.slf4j.LoggerFactory; |
63 |
|
64 |
public class DWGStoreProvider extends AbstractMemoryStoreProvider implements |
65 |
ResourceConsumer { |
66 |
private static final Logger logger = LoggerFactory.getLogger(DWGStoreProvider.class); |
67 |
|
68 |
public static final String NAME = "DWG"; |
69 |
public static final String DESCRIPTION = "DWG file"; |
70 |
public static final String DYNCLASS_NAME = "DWGStore"; |
71 |
protected static DynClass DYNCLASS = null; |
72 |
|
73 |
public static final String NAME_FIELD_ID = "ID"; |
74 |
public static final String NAME_FIELD_GEOMETRY = "Geometry"; |
75 |
public static final String NAME_FIELD_ENTITY = "Entity"; |
76 |
public static final String NAME_FIELD_LAYER = "Layer"; |
77 |
public static final String NAME_FIELD_COLOR = "Color"; |
78 |
public static final String NAME_FIELD_ELEVATION = "Elevation"; |
79 |
public static final String NAME_FIELD_THICKNESS = "Thickness"; |
80 |
public static final String NAME_FIELD_TEXT = "Text"; |
81 |
public static final String NAME_FIELD_HEIGHTTEXT = "HeightText"; |
82 |
public static final String NAME_FIELD_ROTATIONTEXT = "Rotation"; |
83 |
|
84 |
private int ID_FIELD_ID = 0; |
85 |
private int ID_FIELD_GEOMETRY = 1; |
86 |
private int ID_FIELD_ENTITY = 2; |
87 |
private int ID_FIELD_LAYER = 3; |
88 |
private int ID_FIELD_COLOR = 4; |
89 |
private int ID_FIELD_ELEVATION = 5; |
90 |
private int ID_FIELD_THICKNESS = 6; |
91 |
private int ID_FIELD_TEXT = 7; |
92 |
private int ID_FIELD_HEIGHTTEXT = 8; |
93 |
private int ID_FIELD_ROTATIONTEXT = 9; |
94 |
|
95 |
private IProjection projection;
|
96 |
private ResourceProvider resource;
|
97 |
private LegendBuilder legendBuilder;
|
98 |
|
99 |
private long counterNewsOIDs = 0; |
100 |
protected GeometryManager geomManager = GeometryLocator.getGeometryManager();
|
101 |
|
102 |
|
103 |
|
104 |
|
105 |
public DWGStoreProvider(DWGStoreParameters parameters,
|
106 |
DataStoreProviderServices storeServices) throws InitializeException {
|
107 |
super(parameters,storeServices,ToolsLocator
|
108 |
.getDynObjectManager() |
109 |
.createDynObject(DYNCLASS)); |
110 |
|
111 |
counterNewsOIDs = 0;
|
112 |
// projection = CRSFactory.getCRS(getParameters().getSRSID());
|
113 |
|
114 |
File file = getDWGParameters().getFile();
|
115 |
resource = this.createResource(
|
116 |
FileResource.NAME, |
117 |
new Object[] { file.getAbsolutePath() } |
118 |
); |
119 |
|
120 |
resource.addConsumer(this);
|
121 |
|
122 |
this.projection = this.getDWGParameters().getSRS(); |
123 |
|
124 |
|
125 |
try {
|
126 |
legendBuilder = (LegendBuilder) this.invokeDynMethod(
|
127 |
LegendBuilder.DYNMETHOD_BUILDER_NAME, null);
|
128 |
} catch (DynMethodException e) {
|
129 |
legendBuilder = null;
|
130 |
} catch (Exception e) { |
131 |
throw new InitializeException(e); |
132 |
} |
133 |
|
134 |
this.initializeFeatureTypes();
|
135 |
|
136 |
|
137 |
} |
138 |
|
139 |
private DWGStoreParameters getDWGParameters() {
|
140 |
return (DWGStoreParameters) this.getParameters(); |
141 |
} |
142 |
|
143 |
|
144 |
public String getName() { |
145 |
return NAME;
|
146 |
} |
147 |
|
148 |
public boolean allowWrite() { |
149 |
return false; |
150 |
} |
151 |
|
152 |
public Object getLegend() throws OpenException { |
153 |
this.open();
|
154 |
if (legendBuilder == null) { |
155 |
return null; |
156 |
} |
157 |
return legendBuilder.getLegend();
|
158 |
} |
159 |
|
160 |
public Object getLabeling() throws OpenException { |
161 |
this.open();
|
162 |
if (legendBuilder == null) { |
163 |
return null; |
164 |
} |
165 |
return legendBuilder.getLabeling();
|
166 |
} |
167 |
|
168 |
private class DWGData { |
169 |
public ArrayList data = null; |
170 |
public FeatureType defaultFType = null; |
171 |
public List fTypes = null; |
172 |
public Envelope envelope = null; |
173 |
public IProjection projection;
|
174 |
public LegendBuilder legendBuilder = null; |
175 |
public Envelope getEnvelopeCopy() throws CreateEnvelopeException { |
176 |
if (envelope == null) { |
177 |
return null; |
178 |
} |
179 |
Envelope newEnvelope; |
180 |
if (envelope.getDimension() == 2) { |
181 |
newEnvelope = geomManager.createEnvelope(SUBTYPES.GEOM2D); |
182 |
} else {
|
183 |
newEnvelope = geomManager.createEnvelope(SUBTYPES.GEOM3D); |
184 |
|
185 |
} |
186 |
newEnvelope.setLowerCorner(envelope.getLowerCorner()); |
187 |
newEnvelope.setUpperCorner(envelope.getUpperCorner()); |
188 |
return newEnvelope;
|
189 |
} |
190 |
} |
191 |
|
192 |
public void open() throws OpenException { |
193 |
if (this.data != null) { |
194 |
return;
|
195 |
} |
196 |
try {
|
197 |
this.resource.begin();
|
198 |
} catch (ResourceBeginException e2) {
|
199 |
try {
|
200 |
throw new OpenException(resource.getName(), e2); |
201 |
} catch (AccessResourceException e1) {
|
202 |
throw new OpenException(this.getName(), e2); |
203 |
} |
204 |
|
205 |
} |
206 |
try {
|
207 |
DWGData dwgData = null;
|
208 |
FeatureStoreProviderServices store = getStoreServices(); |
209 |
if (this.resource.getData() != null) { |
210 |
dwgData = (DWGData) ((Map) this.resource.getData()) |
211 |
.get(this.projection
|
212 |
.getAbrev()); // OJO no es del todo correcto (puede
|
213 |
// llevar reproyeccion)
|
214 |
} else {
|
215 |
this.resource.setData(new HashMap()); |
216 |
} |
217 |
if (dwgData == null) { |
218 |
dwgData = new DWGData();
|
219 |
dwgData.data = new ArrayList(); |
220 |
this.data = dwgData.data;
|
221 |
this.counterNewsOIDs = 0; |
222 |
Reader reader = new Reader().initialice( |
223 |
this,
|
224 |
new File((String) this.resource.get()), |
225 |
projection, |
226 |
this.legendBuilder
|
227 |
); |
228 |
reader.begin(store); |
229 |
dwgData.defaultFType = reader.getDefaultType() |
230 |
.getNotEditableCopy(); |
231 |
ArrayList types = new ArrayList(); |
232 |
Iterator it = reader.getTypes().iterator();
|
233 |
EditableFeatureType fType; |
234 |
while (it.hasNext()) {
|
235 |
fType = (EditableFeatureType) it.next(); |
236 |
if (fType.getId().equals(dwgData.defaultFType.getId())) {
|
237 |
types.add(dwgData.defaultFType); |
238 |
} else {
|
239 |
types.add(fType.getNotEditableCopy()); |
240 |
} |
241 |
} |
242 |
dwgData.fTypes = types; |
243 |
dwgData.legendBuilder = this.legendBuilder;
|
244 |
|
245 |
resource.notifyOpen(); |
246 |
store.setFeatureTypes(dwgData.fTypes, dwgData.defaultFType); |
247 |
reader.load(); |
248 |
// this.envelope = reader.getEnvelope();
|
249 |
|
250 |
dwgData.envelope = reader.getEnvelope(); |
251 |
|
252 |
|
253 |
dwgData.projection = this.projection;
|
254 |
|
255 |
reader.end(); |
256 |
resource.notifyClose(); |
257 |
((Map) this.resource.getData()).put(this.projection.getAbrev(), |
258 |
dwgData); // OJO la reproyeccion
|
259 |
} |
260 |
|
261 |
this.data = dwgData.data;
|
262 |
store.setFeatureTypes(dwgData.fTypes, dwgData.defaultFType); |
263 |
this.legendBuilder = dwgData.legendBuilder;
|
264 |
this.setDynValue("Envelope", dwgData.getEnvelopeCopy()); |
265 |
this.setDynValue("DefaultSRS", this.projection.getAbrev()); |
266 |
this.counterNewsOIDs = this.data.size(); |
267 |
} catch (Exception e) { |
268 |
this.data = null; |
269 |
try {
|
270 |
throw new OpenException(resource.getName(), e); |
271 |
} catch (AccessResourceException e1) {
|
272 |
throw new OpenException(this.getName(), e); |
273 |
} |
274 |
} finally {
|
275 |
this.resource.end();
|
276 |
} |
277 |
} |
278 |
|
279 |
|
280 |
public DataServerExplorer getExplorer() throws ReadException { |
281 |
DataManager manager = DALLocator.getDataManager(); |
282 |
FilesystemServerExplorerParameters params; |
283 |
try {
|
284 |
params = (FilesystemServerExplorerParameters) manager |
285 |
.createServerExplorerParameters(FilesystemServerExplorer.NAME); |
286 |
params.setRoot(this.getDWGParameters().getFile().getParent());
|
287 |
return manager.createServerExplorer(params);
|
288 |
} catch (DataException e) {
|
289 |
throw new ReadException(this.getName(), e); |
290 |
} catch (ValidateDataParametersException e) {
|
291 |
throw new ReadException(this.getName(), e); |
292 |
} |
293 |
|
294 |
} |
295 |
|
296 |
|
297 |
|
298 |
public void performChanges(Iterator deleteds, Iterator inserteds, Iterator updateds, Iterator originalFeatureTypesUpdated) throws PerformEditingException { |
299 |
// FIXME Exception
|
300 |
throw new UnsupportedOperationException(); |
301 |
} |
302 |
|
303 |
public class Reader { |
304 |
private File file; |
305 |
private String fileName; |
306 |
private IProjection projection;
|
307 |
private List types; |
308 |
private LegendBuilder leyendBuilder;
|
309 |
private AbstractMemoryStoreProvider store;
|
310 |
private Envelope envelope;
|
311 |
|
312 |
public Reader initialice(AbstractMemoryStoreProvider store, File file, |
313 |
IProjection projection, |
314 |
LegendBuilder leyendBuilder) { |
315 |
this.store = store;
|
316 |
this.file = file;
|
317 |
this.fileName = file.getAbsolutePath();
|
318 |
this.projection = projection;
|
319 |
this.leyendBuilder = leyendBuilder;
|
320 |
if (leyendBuilder != null) { |
321 |
leyendBuilder.initialize(store); |
322 |
} |
323 |
return this; |
324 |
} |
325 |
|
326 |
public Envelope getEnvelope() {
|
327 |
return this.envelope; |
328 |
} |
329 |
|
330 |
public void begin(FeatureStoreProviderServices store) { |
331 |
|
332 |
EditableFeatureType featureType = store.createFeatureType(); |
333 |
|
334 |
featureType.setHasOID(true);
|
335 |
|
336 |
ID_FIELD_ID = featureType.add(NAME_FIELD_ID, DataTypes.INT) |
337 |
.setDefaultValue(Integer.valueOf(0)) |
338 |
.getIndex(); |
339 |
|
340 |
EditableFeatureAttributeDescriptor attr = featureType.add( |
341 |
NAME_FIELD_GEOMETRY, DataTypes.GEOMETRY); |
342 |
attr.setSRS(this.projection);
|
343 |
attr.setGeometryType(Geometry.TYPES.GEOMETRY); |
344 |
ID_FIELD_GEOMETRY = attr.getIndex(); |
345 |
|
346 |
featureType.setDefaultGeometryAttributeName(NAME_FIELD_GEOMETRY); |
347 |
|
348 |
// FIXME: Cual es el size y el valor por defecto para Entity ?
|
349 |
ID_FIELD_ENTITY = featureType.add(NAME_FIELD_ENTITY, |
350 |
DataTypes.STRING, 100)
|
351 |
.setDefaultValue("")
|
352 |
.getIndex(); |
353 |
|
354 |
// FIXME: Cual es el size de Layer ?
|
355 |
ID_FIELD_LAYER = featureType.add(NAME_FIELD_LAYER, |
356 |
DataTypes.STRING, 100)
|
357 |
.setDefaultValue( |
358 |
"default").getIndex();
|
359 |
|
360 |
ID_FIELD_COLOR = featureType.add(NAME_FIELD_COLOR, |
361 |
DataTypes.INT) |
362 |
.setDefaultValue( |
363 |
Integer.valueOf(0)).getIndex(); |
364 |
|
365 |
ID_FIELD_ELEVATION = featureType.add(NAME_FIELD_ELEVATION, |
366 |
DataTypes.DOUBLE) |
367 |
.setDefaultValue( |
368 |
Double.valueOf(0)).getIndex(); |
369 |
|
370 |
ID_FIELD_THICKNESS = featureType.add(NAME_FIELD_THICKNESS, |
371 |
DataTypes.DOUBLE) |
372 |
.setDefaultValue( |
373 |
Double.valueOf(0)).getIndex(); |
374 |
|
375 |
// FIXME: Cual es el size de Text ?
|
376 |
ID_FIELD_TEXT = featureType.add(NAME_FIELD_TEXT, |
377 |
DataTypes.STRING, 100)
|
378 |
.setDefaultValue("")
|
379 |
.getIndex(); |
380 |
|
381 |
ID_FIELD_HEIGHTTEXT = featureType.add(NAME_FIELD_HEIGHTTEXT, |
382 |
DataTypes.DOUBLE).setDefaultValue( |
383 |
Double.valueOf(10)).getIndex(); |
384 |
|
385 |
ID_FIELD_ROTATIONTEXT = featureType.add(NAME_FIELD_ROTATIONTEXT, |
386 |
DataTypes.DOUBLE).setDefaultValue( |
387 |
Double.valueOf(0)).getIndex(); |
388 |
|
389 |
|
390 |
|
391 |
// FIXME: Parece que el DXF puede tener mas atributos opcionales.
|
392 |
// Habria que ver de pillarlos ?
|
393 |
|
394 |
types = new ArrayList(); |
395 |
types.add(featureType); |
396 |
|
397 |
if (leyendBuilder != null) { |
398 |
leyendBuilder.begin(); |
399 |
} |
400 |
|
401 |
} |
402 |
|
403 |
public void end() { |
404 |
if (leyendBuilder != null) { |
405 |
leyendBuilder.end(); |
406 |
} |
407 |
} |
408 |
|
409 |
public List getTypes() { |
410 |
return types;
|
411 |
} |
412 |
|
413 |
public EditableFeatureType getDefaultType() {
|
414 |
return (EditableFeatureType) types.get(0); |
415 |
} |
416 |
|
417 |
private Double toDouble(String value) { |
418 |
if (value == null) { |
419 |
return Double.valueOf(0); |
420 |
} |
421 |
return Double.valueOf(value); |
422 |
} |
423 |
|
424 |
public void load() throws DataException { |
425 |
|
426 |
this.envelope = null; |
427 |
|
428 |
DwgFile dwgFeatureFile = new DwgFile(file.getAbsolutePath());
|
429 |
|
430 |
try {
|
431 |
dwgFeatureFile.read(); |
432 |
} catch (DwgVersionNotSupportedException e1) {
|
433 |
throw new UnsupportedDWGVersionException(file.getName(), e1); |
434 |
} catch (IOException e) { |
435 |
throw new ReadException(NAME, e); |
436 |
} |
437 |
|
438 |
|
439 |
dwgFeatureFile.calculateGisModelDwgPolylines(); |
440 |
dwgFeatureFile.blockManagement2(); |
441 |
List entities = dwgFeatureFile.getDwgObjects();
|
442 |
|
443 |
int id = -1; |
444 |
try{
|
445 |
int envelopeSubType = Geometry.SUBTYPES.GEOM2D;
|
446 |
boolean is3dFile = dwgFeatureFile.isDwg3DFile();
|
447 |
// if (is3dFile) {
|
448 |
// envelopeSubType = Geometry.SUBTYPES.GEOM3D;
|
449 |
// }
|
450 |
|
451 |
this.envelope = geomManager.createEnvelope(envelopeSubType);
|
452 |
|
453 |
boolean updateEnvelope = true; |
454 |
|
455 |
double[] extMin = (double[]) dwgFeatureFile |
456 |
.getHeader("MSPACE_EXTMIN");
|
457 |
double[] extMax = (double[]) dwgFeatureFile |
458 |
.getHeader("MSPACE_EXTMAX");
|
459 |
if (extMin != null && extMax != null) { |
460 |
updateEnvelope = false;
|
461 |
Point point = (Point) geomManager.create( |
462 |
Geometry.TYPES.POINT, envelopeSubType); |
463 |
point.setCoordinates(extMin); |
464 |
this.envelope.setLowerCorner(point);
|
465 |
point = (Point) geomManager.create(Geometry.TYPES.POINT,
|
466 |
envelopeSubType); |
467 |
point.setCoordinates(extMax); |
468 |
this.envelope.setUpperCorner(point);
|
469 |
} |
470 |
|
471 |
|
472 |
Iterator iter = entities.iterator();
|
473 |
|
474 |
FeatureProvider featureProvider; |
475 |
Envelope gEnvelope; |
476 |
|
477 |
while (iter.hasNext()) {
|
478 |
id++; |
479 |
DwgObject entity = (DwgObject) iter.next(); |
480 |
|
481 |
if (!(entity instanceof IDwg2FMap)) { |
482 |
logger |
483 |
.warn( |
484 |
"load: entity type {}(id:{}) not loadded",
|
485 |
new Object[] { entity |
486 |
.getType() }, |
487 |
id); |
488 |
|
489 |
continue;
|
490 |
} |
491 |
|
492 |
IDwg2FMap dwgEnt = (IDwg2FMap) entity; |
493 |
Geometry geometry = dwgEnt.toFMapGeometry(is3dFile); |
494 |
if (geometry == null) { // || geometry.getGeneralPath() == |
495 |
// null) {
|
496 |
logger |
497 |
.warn( |
498 |
"load: entity {}(id:{}) with null geometry",
|
499 |
new Object[] { |
500 |
entity |
501 |
.getType(), |
502 |
id }); |
503 |
|
504 |
continue;
|
505 |
} |
506 |
// FIXME: Estas 6 lineas es por si la geometr??a no se ha
|
507 |
// creado correctamente
|
508 |
gEnvelope = null;
|
509 |
try {
|
510 |
gEnvelope = geometry.getEnvelope(); |
511 |
} catch (Exception e) { |
512 |
gEnvelope = null;
|
513 |
} |
514 |
if (gEnvelope == null) { |
515 |
logger |
516 |
.warn( |
517 |
"load: entity {}(id:{}) with null envelope",
|
518 |
new Object[] { entity.getType(), id }); |
519 |
|
520 |
continue;
|
521 |
} |
522 |
// we check for Region of Interest of the CAD file
|
523 |
if (!this.envelope.intersects(geometry.getEnvelope())) { |
524 |
logger |
525 |
.warn( |
526 |
"load: entity {}(id:{}) out of envelope",
|
527 |
new Object[] { entity.getType(), id }); |
528 |
continue;
|
529 |
} |
530 |
featureProvider = store.createFeatureProvider(store |
531 |
.getStoreServices().getDefaultFeatureType()); |
532 |
|
533 |
featureProvider.set(ID_FIELD_ID, id); |
534 |
|
535 |
featureProvider.set(ID_FIELD_ENTITY, dwgEnt.toString()); |
536 |
|
537 |
featureProvider.set(ID_FIELD_LAYER, dwgFeatureFile |
538 |
.getLayerName(entity)); |
539 |
|
540 |
int colorByLayer = dwgFeatureFile.getColorByLayer(entity);
|
541 |
int color = entity.getColor();
|
542 |
if (color < 0) { |
543 |
color = Math.abs(color);
|
544 |
} |
545 |
if (color > 255) { |
546 |
color = colorByLayer; |
547 |
} |
548 |
|
549 |
featureProvider.set(ID_FIELD_COLOR, color); |
550 |
|
551 |
if (entity instanceof IDwg3DTestable) { |
552 |
featureProvider.set(ID_FIELD_ELEVATION, |
553 |
((IDwg3DTestable) entity).getZ()); |
554 |
} |
555 |
|
556 |
featureProvider.set(ID_FIELD_THICKNESS, 0.0);
|
557 |
featureProvider.set(ID_FIELD_HEIGHTTEXT, 0.0);
|
558 |
featureProvider.set(ID_FIELD_ROTATIONTEXT, 0.0);
|
559 |
featureProvider.set(ID_FIELD_TEXT, "");
|
560 |
|
561 |
if (entity instanceof DwgMText) { |
562 |
DwgMText mtext = (DwgMText) entity; |
563 |
featureProvider.set(ID_FIELD_HEIGHTTEXT, mtext.getHeight()); |
564 |
featureProvider.set(ID_FIELD_TEXT, mtext.getText()); |
565 |
} else if (entity instanceof DwgText) { |
566 |
DwgText text = (DwgText) entity; |
567 |
featureProvider |
568 |
.set(ID_FIELD_THICKNESS, text.getThickness()); |
569 |
featureProvider.set(ID_FIELD_HEIGHTTEXT, text.getHeight()); |
570 |
featureProvider.set(ID_FIELD_ROTATIONTEXT, text |
571 |
.getRotationAngle()); |
572 |
featureProvider.set(ID_FIELD_TEXT, text.getText()); |
573 |
}// if-else
|
574 |
|
575 |
featureProvider.setDefaultGeometry(geometry); |
576 |
|
577 |
store.addFeatureProvider(featureProvider); |
578 |
if (this.leyendBuilder != null) { |
579 |
this.leyendBuilder.process(featureProvider);
|
580 |
} |
581 |
|
582 |
} |
583 |
|
584 |
} catch (org.gvsig.fmap.geom.exception.CreateGeometryException e) {
|
585 |
throw new CreateGeometryException(e); |
586 |
} catch (org.gvsig.fmap.geom.exception.CreateEnvelopeException e) {
|
587 |
throw new CreateGeometryException(e); |
588 |
} |
589 |
|
590 |
} |
591 |
|
592 |
} |
593 |
|
594 |
|
595 |
public boolean closeResourceRequested(ResourceProvider resource) { |
596 |
return true; |
597 |
} |
598 |
|
599 |
public int getOIDType() { |
600 |
return DataTypes.LONG;
|
601 |
} |
602 |
|
603 |
public boolean supportsAppendMode() { |
604 |
return false; |
605 |
} |
606 |
|
607 |
public void append(FeatureProvider featureProvider) { |
608 |
// FIXME Exception
|
609 |
throw new UnsupportedOperationException(); |
610 |
} |
611 |
|
612 |
public void beginAppend() { |
613 |
// FIXME Exception
|
614 |
throw new UnsupportedOperationException(); |
615 |
|
616 |
} |
617 |
|
618 |
public void endAppend() { |
619 |
// FIXME Exception
|
620 |
throw new UnsupportedOperationException(); |
621 |
} |
622 |
|
623 |
public void saveToState(PersistentState state) throws PersistenceException { |
624 |
// TODO Auto-generated method stub
|
625 |
throw new NotYetImplemented(); |
626 |
} |
627 |
|
628 |
public void loadFromState(PersistentState state) throws PersistenceException { |
629 |
// TODO Auto-generated method stub
|
630 |
throw new NotYetImplemented(); |
631 |
} |
632 |
|
633 |
public Object createNewOID() { |
634 |
return new Long(counterNewsOIDs++); |
635 |
} |
636 |
|
637 |
protected void initializeFeatureTypes() throws InitializeException { |
638 |
try {
|
639 |
this.open();
|
640 |
} catch (OpenException e) {
|
641 |
throw new InitializeException(this.getName(), e); |
642 |
} |
643 |
} |
644 |
|
645 |
public Envelope getEnvelope() throws DataException { |
646 |
this.open();
|
647 |
return (Envelope) this.getDynValue("Envelope"); |
648 |
} |
649 |
|
650 |
|
651 |
/*
|
652 |
* (non-Javadoc)
|
653 |
*
|
654 |
* @see
|
655 |
* org.gvsig.fmap.dal.resource.spi.ResourceConsumer#resourceChanged(org.
|
656 |
* gvsig.fmap.dal.resource.spi.ResourceProvider)
|
657 |
*/
|
658 |
public void resourceChanged(ResourceProvider resource) { |
659 |
this.getStoreServices().notifyChange(
|
660 |
DataStoreNotification.RESOURCE_CHANGED, |
661 |
resource); |
662 |
} |
663 |
|
664 |
protected static void registerDynClass() { |
665 |
DynObjectManager dynman = ToolsLocator.getDynObjectManager(); |
666 |
DynClass dynClass; |
667 |
DynField field; |
668 |
if (DYNCLASS == null) { |
669 |
dynClass = dynman.add(DYNCLASS_NAME, "DXF File Store");
|
670 |
dynClass.extend(dynman.get(FeatureStore.DYNCLASS_NAME)); |
671 |
|
672 |
DYNCLASS = dynClass; |
673 |
} |
674 |
|
675 |
} |
676 |
|
677 |
public Object getSourceId() { |
678 |
return this.getDWGParameters().getFile(); |
679 |
} |
680 |
|
681 |
} |