Revision 23602 branches/v2_0_0_prep/libraries/libFMap_dataFile/src/org/gvsig/fmap/data/feature/file/shp/SHPStoreParameters.java
SHPStoreParameters.java | ||
---|---|---|
10 | 10 |
import com.iver.utiles.NotExistInXMLEntity; |
11 | 11 |
import com.iver.utiles.XMLEntity; |
12 | 12 |
public class SHPStoreParameters extends DBFStoreParameters { |
13 |
private File shpfile; |
|
14 |
private File shxfile; |
|
15 |
private String srs = null; |
|
16 | 13 |
|
14 |
protected Map createDefaultValuesMap() { |
|
15 |
Map defaultValues = super.createDefaultValuesMap(); |
|
16 |
defaultValues.put("srs", "EPSG:23030"); |
|
17 |
defaultValues.put("shxfile", null); |
|
18 |
defaultValues.put("shpfile", null); |
|
19 |
return defaultValues; |
|
20 |
} |
|
21 |
|
|
17 | 22 |
public boolean isValid() { |
18 |
return super.isValid() && ( shpfile != null ) && (shxfile != null ); |
|
23 |
return super.isValid() && (this.getSHPFile() != null) |
|
24 |
&& (this.getSHXFile() != null); |
|
19 | 25 |
} |
20 | 26 |
public String getDataStoreName() { |
21 | 27 |
return SHPStore.DATASTORE_NAME; |
... | ... | |
30 | 36 |
} |
31 | 37 |
|
32 | 38 |
public void setSHPFile(File aFile){ |
33 |
shpfile=aFile;
|
|
39 |
this.put("shpfile", aFile);
|
|
34 | 40 |
if (super.getDBFFile() == null){ |
35 |
super.setFile(SHP.getDbfFile(this.shpfile));
|
|
41 |
super.setFile(SHP.getDbfFile(aFile));
|
|
36 | 42 |
} |
37 |
if (this.shxfile == null){
|
|
38 |
this.shxfile = SHP.getShxFile(this.shpfile);
|
|
43 |
if (this.getSHXFile() == null) {
|
|
44 |
this.setSHXFile(SHP.getShxFile(aFile));
|
|
39 | 45 |
} |
40 |
this.file = aFile;
|
|
46 |
this.put("file", aFile);
|
|
41 | 47 |
|
42 | 48 |
} |
43 | 49 |
|
44 | 50 |
protected File getSHPFile(){ |
45 |
return this.shpfile;
|
|
51 |
return (File) this.get("shpfile");
|
|
46 | 52 |
} |
47 | 53 |
|
48 | 54 |
protected File getSHXFile(){ |
49 |
return this.shxfile;
|
|
55 |
return (File) this.get("shxfile");
|
|
50 | 56 |
} |
51 | 57 |
|
52 | 58 |
protected void setSHXFile(File file){ |
53 |
this.shxfile = file; |
|
54 |
super.clearInternalMap(); |
|
59 |
this.put("shxfile", file); |
|
55 | 60 |
} |
56 | 61 |
/** |
57 | 62 |
* @return the srs |
58 | 63 |
*/ |
59 | 64 |
public String getSRS() { |
60 |
return srs;
|
|
65 |
return (String) this.get("srs");
|
|
61 | 66 |
} |
62 | 67 |
/** |
63 | 68 |
* @param srs the srs to set |
64 | 69 |
*/ |
65 | 70 |
public void setSRS(String srs) { |
66 |
this.srs = srs; |
|
67 |
super.clearInternalMap(); |
|
71 |
this.put("srs", srs); |
|
68 | 72 |
} |
69 | 73 |
/* (non-Javadoc) |
70 | 74 |
* @see org.gvsig.fmap.data.feature.file.dbf.DBFStoreParameters#getDBFFile() |
... | ... | |
88 | 92 |
|
89 | 93 |
public XMLEntity getXMLEntity() { |
90 | 94 |
XMLEntity xmlEntity = super.getXMLEntity(); |
91 |
xmlEntity.putProperty("shpfile", this.shpfile.getPath());
|
|
92 |
xmlEntity.putProperty("shxfile", this.shxfile.getPath());
|
|
93 |
xmlEntity.putProperty("srs", this.srs);
|
|
95 |
xmlEntity.putProperty("shpfile", this.getSHPFile().getPath());
|
|
96 |
xmlEntity.putProperty("shxfile", this.getSHXFile().getPath());
|
|
97 |
xmlEntity.putProperty("srs", this.getSRS());
|
|
94 | 98 |
return xmlEntity; |
95 | 99 |
} |
96 | 100 |
|
... | ... | |
98 | 102 |
throws InitializeException { |
99 | 103 |
super.loadFromXMLEntity(xmlEntity); |
100 | 104 |
try { |
101 |
this.shpfile = new File(xmlEntity.getStringProperty("shpfile"));
|
|
105 |
this.setSHPFile(new File(xmlEntity.getStringProperty("shpfile")));
|
|
102 | 106 |
} catch (NotExistInXMLEntity e) { |
103 | 107 |
throw new InitializeException("shpfile property not found", this |
104 | 108 |
.getDataStoreName()); |
105 | 109 |
} |
106 | 110 |
|
107 | 111 |
try { |
108 |
this.shxfile = new File(xmlEntity.getStringProperty("shxfile"));
|
|
112 |
this.setSHXFile(new File(xmlEntity.getStringProperty("shxfile")));
|
|
109 | 113 |
} catch (NotExistInXMLEntity e) { |
110 | 114 |
throw new InitializeException("shpfile property not found", this |
111 | 115 |
.getDataStoreName()); |
112 | 116 |
} |
113 | 117 |
|
114 | 118 |
try { |
115 |
this.srs = xmlEntity.getStringProperty("srs");
|
|
119 |
this.setSRS(xmlEntity.getStringProperty("srs"));
|
|
116 | 120 |
} catch (NotExistInXMLEntity e) { |
117 |
throw new InitializeException("shpfile property not found", this |
|
118 |
.getDataStoreName()); |
|
121 |
this.remove("srs"); |
|
119 | 122 |
} |
120 | 123 |
|
121 | 124 |
} |
122 |
|
|
123 |
protected Map getInternalMap() { |
|
124 |
Map map = super.getInternalMap(); |
|
125 |
map.put("srs", this.srs); |
|
126 |
map.put("shpfile", this.shpfile.getPath()); |
|
127 |
map.put("shxfile", this.shxfile.getPath()); |
|
128 |
return map; |
|
129 |
} |
|
130 |
|
|
131 | 125 |
} |
Also available in: Unified diff