git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/EcologicalEngineGeoSpatialExtension@76475 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
43b33c0788
commit
607b06167a
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue