Skip to content

Commit

Permalink
Fix path to epsg database on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
lesserwhirls committed Sep 13, 2021
1 parent a878cea commit d9addb0
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions common/src/main/java/uk/ac/rdg/resc/edal/util/GISUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
package uk.ac.rdg.resc.edal.util;

import java.lang.reflect.Field;
import java.nio.file.FileSystems;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
Expand Down Expand Up @@ -1386,6 +1387,15 @@ public Object getObjectInstance(Object obj, Name name, Context nameCtx,
String path;
if (EpsgDatabasePath.DB_PATH == null) {
path = System.getProperty("java.io.tmpdir");
String separator = FileSystems.getDefault().getSeparator();
// fix windows path, otherwise:
// May 27, 2021 12:31:50 PM org.apache.sis.referencing.factory.sql.EPSGDataAccess getAuthority
// java.net.URISyntaxException: Illegal character in opaque part at index 10:
// jdbc:h2:C:\tmp\path\/.h2/epsg.db
if (separator.equals("\\")) {
path = path.replaceAll("\\\\", "/");
path = "file:" + path;
}
} else {
path = EpsgDatabasePath.DB_PATH;
}
Expand Down

0 comments on commit d9addb0

Please sign in to comment.