Revision 43758 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.spi/src/main/java/org/gvsig/fmap/dal/spi/AbstractDataParameters.java

View differences:

AbstractDataParameters.java
22 22
 */
23 23
package org.gvsig.fmap.dal.spi;
24 24

  
25
import java.io.File;
26
import java.io.IOException;
25 27
import java.util.Iterator;
28
import java.util.List;
29
import org.apache.commons.io.FileUtils;
30
import org.apache.commons.io.FilenameUtils;
31
import org.apache.commons.lang3.StringUtils;
32
import org.cresques.cts.ICRSFactory;
33
import org.cresques.cts.IProjection;
34
import org.gvsig.fmap.crs.CRSFactory;
26 35

  
27 36
import org.slf4j.Logger;
28 37
import org.slf4j.LoggerFactory;
......
178 187
        }
179 188
    }
180 189

  
190
    protected void loadPRJ(File file, String parameterName) {
191
        File prjFile = new File(FilenameUtils.removeExtension(file.getAbsolutePath()) + ".prj");
192
        if (prjFile.exists()) {
193
            try {
194
                String contentFile = FileUtils.readFileToString(prjFile);
195
                if (StringUtils.isNotEmpty(contentFile)) {
196
                    IProjection crs = CRSFactory.getCRSFactory().get(ICRSFactory.FORMAT_WKT_ESRI, contentFile);
197
                    this.setDynValue(parameterName, crs);
198
                }
199
            } catch (IOException e) {
200
                logger.warn("Couldn't read prj file ''{}''", prjFile.getAbsolutePath());
201
            }
202
        }
203
    }
204

  
205
    protected void loadWLD(File file, String parameterName) {
206
        File wldFile = new File(FilenameUtils.removeExtension(file.getAbsolutePath()) + ".wld");
207
        if (wldFile.exists()) {
208
            try {
209
                List<String> lines = FileUtils.readLines(wldFile);
210
                if (lines != null && lines.size() == 6) {
211
                    this.setDynValue(parameterName, lines);
212
                }
213

  
214
            } catch (IOException e) {
215
                logger.warn("Couldn't read wld file ''{}''", wldFile.getAbsolutePath());
216
            }
217
        }
218
    }
219

  
181 220
    /**
182 221
     * Returns an instance of the {@link DynObject} to delegate to.
183 222
     *

Also available in: Unified diff