Gianpaolo Coro 2013-05-29 15:09:07 +00:00
parent 43b33c0788
commit 607b06167a
1 changed files with 10 additions and 6 deletions

View File

@ -31,9 +31,12 @@ public class RasterTable {
private AlgorithmConfiguration configuration;
private String tablename = "rstr" + ("" + UUID.randomUUID()).replace("-", "");
static String createTableStatement = "CREATE TABLE %1$s (csquarecode character varying, x real, y real, z real, probability real)";
static String createTableStatement = "CREATE TABLE %1$s (id serial, csquarecode character varying, x real, y real, z real, probability real)";
static String columnsnames = "csquarecode, x , y , z , probability";
public static String csquareColumn = "csquarecode";
public static String probabilityColumn = "probability";
public static String idColumn = "id";
public String getTablename() {
return tablename;
}
@ -75,24 +78,25 @@ public class RasterTable {
Tuple<Double> cset = coordinates.get(i);
double x = cset.getElements().get(0);
double y = cset.getElements().get(1);
String csquare = CSquareCodesConverter.convertAtResolution(x, y, xResolution);
String csquare = CSquareCodesConverter.convertAtResolution(y,x, xResolution);
Double value = values.get(i);
//we do not use NaNs in this case every value will be filled
if (value.isNaN())
value = 0d;
sb.append("('" + csquare + "'," + x + "," + y + "," + z + ",'" + value + "')");
if (i % 5000 == 0) {
AnalysisLogger.getLogger().debug("Partial Inserting Buffer of " + sb.length() + " Values");
// AnalysisLogger.getLogger().debug("Partial Inserting Buffer of " + sb.length() + " Values");
String insertStatement = DatabaseUtils.insertFromBuffer(tablename, columnsnames, sb);
DatabaseFactory.executeSQLUpdate(insertStatement, dbconnection);
AnalysisLogger.getLogger().debug("Partial Insertion completed with Success!");
// AnalysisLogger.getLogger().debug("Partial Insertion completed with Success!");
sb = new StringBuffer();
} else if (i < triplets - 1)
sb.append(",");
}
AnalysisLogger.getLogger().debug("Inserting Buffer of " + sb.length() + " Values");
AnalysisLogger.getLogger().debug("Inserting Final Buffer of " + sb.length() + " Values");
// save all the strings on the table
if (sb.length() > 0) {
String insertStatement = DatabaseUtils.insertFromBuffer(tablename, columnsnames, sb);