Revision 306 org.gvsig.projection.jcrs/trunk/org.gvsig.projection.jcrs/org.gvsig.projection.app.jcrs/org.gvsig.projection.app.jcrs.common/src/main/java/org/gvsig/crs/JCRSPluginLibrary.java
JCRSPluginLibrary.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import java.io.File; |
4 | 4 |
import java.io.IOException; |
5 |
import java.util.Collection; |
|
6 |
import java.util.Iterator; |
|
5 | 7 |
|
6 | 8 |
import org.apache.commons.io.FileUtils; |
9 |
import org.apache.commons.io.filefilter.FileFilterUtils; |
|
10 |
import org.apache.commons.io.filefilter.TrueFileFilter; |
|
7 | 11 |
import org.apache.commons.lang3.BooleanUtils; |
8 | 12 |
import org.cresques.ProjectionLibrary; |
9 | 13 |
import org.gvsig.andami.PluginServices; |
... | ... | |
41 | 45 |
CrsFactory.setEnableMemoryCacheOfCRS( |
42 | 46 |
BooleanUtils.isTrue((Boolean) properties.getDynValue("useMemoryCacheForCRSs")) |
43 | 47 |
); |
44 |
CrsFactory.setEpsgDatabaseFile( |
|
45 |
new File((String) properties.getDynValue("epsgDatabase")) |
|
46 |
); |
|
47 |
|
|
48 |
CrsFactory.setEpsgDatabaseFile(this.getDefaultDatabaseFolder(plugin, properties)); |
|
48 | 49 |
|
49 | 50 |
EPSGDatabaseInstallerFactory.registerEPSGDatabaseInstaller(); |
50 | 51 |
} |
51 | 52 |
|
53 |
private File getDefaultDatabaseFolder(PluginServices plugin, DynObject pluginProperties) { |
|
54 |
File dbfolder = new File (plugin.getPluginHomeFolder(),"db"); |
|
55 |
File f2; |
|
56 |
String fname = (String) pluginProperties.getDynValue("epsgDatabase"); |
|
57 |
if( fname!=null ) { |
|
58 |
f2 = new File(dbfolder, fname); |
|
59 |
if( f2.exists() ) { |
|
60 |
return new File(fname); |
|
61 |
} |
|
62 |
} |
|
63 |
File folder = new File(dbfolder,"EPSG"); |
|
64 |
Collection<File> subfolders = FileUtils.listFilesAndDirs( |
|
65 |
folder, |
|
66 |
FileFilterUtils.falseFileFilter(), |
|
67 |
FileFilterUtils.trueFileFilter() |
|
68 |
); |
|
69 |
Iterator<File> it = subfolders.iterator(); |
|
70 |
if( it.hasNext() ) { |
|
71 |
f2 = it.next(); |
|
72 |
return FileUtils.getFile(dbfolder, "EPSG",f2.getName()); |
|
73 |
} |
|
74 |
fname = "EPSG" + File.separator + "EPSG_v8_5"; |
|
75 |
logger.warn("Can't locate a EPSG database in '"+dbfolder+"' use '"+fname+"'."); |
|
76 |
return new File(fname); |
|
77 |
} |
|
78 |
|
|
52 | 79 |
private void initalizeHomeDB(PluginServices plugin) { |
53 | 80 |
|
54 | 81 |
File sourceDBFolder = new File(plugin.getPluginDirectory(), "db"); |
Also available in: Unified diff