Revision 42464 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.shp/src/main/java/org/gvsig/fmap/dal/store/shp/SHPStoreParameters.java
SHPStoreParameters.java | ||
---|---|---|
25 | 25 |
package org.gvsig.fmap.dal.store.shp; |
26 | 26 |
|
27 | 27 |
import java.io.File; |
28 |
import java.io.IOException; |
|
29 |
|
|
30 |
import org.apache.commons.io.FileUtils; |
|
28 | 31 |
import org.apache.commons.lang3.BooleanUtils; |
32 |
import org.cresques.cts.ICRSFactory; |
|
33 |
import org.cresques.cts.IProjection; |
|
29 | 34 |
|
30 |
import org.cresques.cts.IProjection;
|
|
35 |
import org.gvsig.fmap.crs.CRSFactory;
|
|
31 | 36 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
32 | 37 |
import org.gvsig.fmap.dal.store.dbf.DBFStoreParameters; |
33 | 38 |
import org.gvsig.fmap.dal.store.shp.utils.SHP; |
... | ... | |
51 | 56 |
fixParameters(); |
52 | 57 |
super.validate(); |
53 | 58 |
} |
54 |
|
|
59 |
|
|
55 | 60 |
public void fixParameters() { |
56 | 61 |
File file = this.getSHPFile(); |
57 | 62 |
if( file!=null ) { |
... | ... | |
63 | 68 |
} |
64 | 69 |
} |
65 | 70 |
} |
66 |
|
|
71 |
|
|
67 | 72 |
public SHPStoreParameters(String parametersDefinitionName) { |
68 | 73 |
super(parametersDefinitionName, SHPStoreProvider.NAME); |
69 | 74 |
} |
... | ... | |
82 | 87 |
public void setFile(String fileName) { |
83 | 88 |
this.setSHPFile(fileName); |
84 | 89 |
} |
85 |
|
|
86 |
|
|
90 |
|
|
91 |
|
|
87 | 92 |
public String getSHPFileName() { |
88 | 93 |
if( this.getSHPFile()==null ) { |
89 | 94 |
return null; |
... | ... | |
103 | 108 |
if (this.getSHXFile() == null) { |
104 | 109 |
this.setSHXFile(SHP.getShxFile(file)); |
105 | 110 |
} |
111 |
if (getCRS() == null){ |
|
112 |
String wktEsri = loadPrj(file); |
|
113 |
if (wktEsri != null) { |
|
114 |
IProjection proj = CRSFactory.getCRSFactory().get(ICRSFactory.FORMAT_WKT_ESRI, wktEsri); |
|
115 |
setCRS(proj); |
|
116 |
} |
|
117 |
} |
|
118 |
|
|
106 | 119 |
} |
107 | 120 |
|
108 | 121 |
public void setSHPFile(String fileName) { |
... | ... | |
114 | 127 |
if (this.getSHXFile() == null) { |
115 | 128 |
this.setSHXFile(SHP.getShxFile(file)); |
116 | 129 |
} |
130 |
if (getCRS() == null){ |
|
131 |
String wktEsri = loadPrj(file); |
|
132 |
if (wktEsri != null) { |
|
133 |
IProjection proj = CRSFactory.getCRSFactory().get(ICRSFactory.FORMAT_WKT_ESRI, wktEsri); |
|
134 |
setCRS(proj); |
|
135 |
} |
|
136 |
} |
|
117 | 137 |
} |
118 | 138 |
|
139 |
private String loadPrj(File shpFile){ |
|
140 |
File prjFile = SHP.getPrjFile(shpFile); |
|
141 |
if (prjFile.exists()) { |
|
142 |
try { |
|
143 |
return FileUtils.readFileToString(prjFile); |
|
144 |
} catch (IOException e) { |
|
145 |
return null; |
|
146 |
} |
|
147 |
} |
|
148 |
return null; |
|
149 |
} |
|
150 |
|
|
119 | 151 |
public String getSHXFileName() { |
120 | 152 |
if( this.getSHXFile()==null ) { |
121 | 153 |
return null; |
Also available in: Unified diff