Revision 25789 branches/v2_0_0_prep/libraries/libFMap_dalfile/src/org/gvsig/fmap/dal/store/shp/SHPStoreProvider.java
SHPStoreProvider.java | ||
---|---|---|
56 | 56 |
import org.gvsig.fmap.dal.store.dbf.DBFStoreProvider; |
57 | 57 |
import org.gvsig.fmap.dal.store.shp.utils.SHPFile; |
58 | 58 |
import org.gvsig.fmap.geom.primitive.Envelope; |
59 |
import org.gvsig.tools.ToolsLocator; |
|
60 |
import org.gvsig.tools.dynobject.DelegatedDynObject; |
|
61 |
import org.gvsig.tools.dynobject.DynClass; |
|
62 |
import org.gvsig.tools.dynobject.DynField; |
|
63 |
import org.gvsig.tools.dynobject.DynObjectManager; |
|
59 | 64 |
import org.gvsig.tools.persistence.PersistenceException; |
60 | 65 |
import org.gvsig.tools.persistence.PersistentState; |
61 | 66 |
|
... | ... | |
66 | 71 |
private ResourceProvider shpResource; |
67 | 72 |
private SHPStoreParameters shpParams; |
68 | 73 |
protected static final String GEOMETRY_ATTIBUTE_NAME = "GEOMETRY"; |
74 |
protected static final String DYNFIELD_SRSORIGINALPARAMETERS_NAME = "SRSOriginalParameters"; |
|
75 |
private static final String DYNCLASS_NAME = "SHPStore"; |
|
76 |
protected static DynClass DYNCLASS = null; |
|
77 |
|
|
69 | 78 |
private SHPFeatureWriter writer = null; |
70 | 79 |
|
71 | 80 |
public SHPStoreProvider(SHPStoreParameters params) |
... | ... | |
77 | 86 |
new Object[] { this.shpParams.getSHPFileName() }); |
78 | 87 |
shpResource.addConsumer(this); |
79 | 88 |
|
80 |
//DBFResource tmpResource = new DBFResource(dbfParameters); |
|
81 |
// |
|
82 |
//try { |
|
83 |
// this.dbf = (DBFResource) this.store.addResource(tmpResource); |
|
84 |
//} catch (DataException e1) { |
|
85 |
// throw new InitializeException(this.getName(), e1); |
|
86 |
//} |
|
89 |
// FIXME |
|
90 |
this.dynObject = this.dynObject = (DelegatedDynObject) ToolsLocator |
|
91 |
.getDynObjectManager().createDynObject(DYNCLASS); |
|
87 | 92 |
|
88 | 93 |
this.shpFile = new SHPFile(this.shpParams); |
89 | 94 |
} |
90 | 95 |
|
96 |
protected static void registerDynClass() { |
|
97 |
DynObjectManager dynman = ToolsLocator.getDynObjectManager(); |
|
98 |
DynClass dynClass; |
|
99 |
DynField field; |
|
100 |
if (DYNCLASS == null) { |
|
101 |
|
|
102 |
DynClass dbfDynClass = DBFStoreProvider.DYNCLASS; |
|
103 |
dynClass = dynman.add(DYNCLASS_NAME); |
|
104 |
|
|
105 |
|
|
106 |
field = dynClass.addDynField(DYNFIELD_SRSORIGINALPARAMETERS_NAME); |
|
107 |
|
|
108 |
field.setType(DataTypes.STRING); |
|
109 |
field.setDescription("SRS original parameters"); |
|
110 |
|
|
111 |
// The SHP store parameters extend the DBF store parameters |
|
112 |
dynClass.extend(dbfDynClass); |
|
113 |
|
|
114 |
DYNCLASS = dynClass; |
|
115 |
} |
|
116 |
|
|
117 |
} |
|
118 |
|
|
119 |
|
|
91 | 120 |
protected static EditableFeatureAttributeDescriptor addGeometryColumn( |
92 | 121 |
EditableFeatureType fType) { |
93 | 122 |
|
... | ... | |
242 | 271 |
this.shpFile.open(); |
243 | 272 |
this.shpResource.notifyOpen(); |
244 | 273 |
|
274 |
|
|
275 |
// load metadata |
|
276 |
this.dynObject.setDynValue( |
|
277 |
DYNFIELD_SRSORIGINALPARAMETERS_NAME, |
|
278 |
this.shpFile.getSRSParameters()); |
|
279 |
|
|
280 |
this.dynObject.setDynValue("Envelope", shpFile.getFullExtent()); |
|
281 |
|
|
245 | 282 |
} catch (UnsupportedVersionException e) { |
246 | 283 |
throw new OpenException(this.getName(), e); |
247 | 284 |
} catch (ResourceNotifyOpenException e) { |
... | ... | |
307 | 344 |
FeatureSet set = this.store.getFeatureSet(); |
308 | 345 |
// this.shpResource.begin(); |
309 | 346 |
writer = new SHPFeatureWriter(this.getName()); |
347 |
|
|
310 | 348 |
writer.begin(this.shpParams, fType, dbfFtype, set.getSize()); |
311 | 349 |
|
312 | 350 |
// Iterator iter1 = set.iterator(); |
... | ... | |
322 | 360 |
Feature feature=(Feature) iter.next(); |
323 | 361 |
writer.write(feature); |
324 | 362 |
} |
363 |
|
|
325 | 364 |
writer.end(); |
365 |
|
|
326 | 366 |
shpResource.notifyChanges(); |
327 | 367 |
} catch (Exception e) { |
328 | 368 |
throw new PerformEditingException(this.getName(), e); |
... | ... | |
394 | 434 |
e.printStackTrace(); |
395 | 435 |
} |
396 | 436 |
} |
437 |
|
|
438 |
/* |
|
439 |
* (non-Javadoc) |
|
440 |
* |
|
441 |
* @see org.gvsig.metadata.Metadata#getMetadataName() |
|
442 |
*/ |
|
443 |
public String getMetadataName() { |
|
444 |
return this.shpParams.getSHPFile().getName(); |
|
445 |
} |
|
446 |
|
|
397 | 447 |
} |
Also available in: Unified diff