This commit is contained in:
Gianpaolo Coro 2012-09-27 08:48:00 +00:00
parent 515fcf41b3
commit 6bf14fd823
4 changed files with 25 additions and 9 deletions

View File

@ -259,7 +259,7 @@ public class DBScan implements Clusterer{
@Override
public void compute() throws Exception {
try{
if ((config==null)||epsilon==null||minPoints==null||points==null){
throw new Exception("DBScan: Error incomplete parameters");
}
@ -286,9 +286,15 @@ public class DBScan implements Clusterer{
BuildClusterTable(outputvector);
}catch(Exception e){
AnalysisLogger.getLogger().debug("ERROR "+e.getLocalizedMessage());
e.printStackTrace();
throw e;
}
finally{
shutdown();
status = 100f;
}
}
@ -345,7 +351,7 @@ public class DBScan implements Clusterer{
}
if (bufferRows.length()>0){
// AnalysisLogger.getLogger().trace("DBScan: Inserting Buffer "+DatabaseUtils.insertFromBuffer(OccurrencePointsClusterTable, columnsNames, bufferRows));
// AnalysisLogger.getLogger().debug("DBScan: Inserting Buffer "+DatabaseUtils.insertFromBuffer(OccurrencePointsClusterTable, columnsNames, bufferRows));
AnalysisLogger.getLogger().debug("Writing into DB");
DatabaseFactory.executeSQLUpdate(DatabaseUtils.insertFromBuffer(OccurrencePointsClusterTable, columnsNames, bufferRows),dbHibConnection);
AnalysisLogger.getLogger().debug("Finished with writing into DB");
@ -364,7 +370,8 @@ public class DBScan implements Clusterer{
public void shutdown() {
try{
AnalysisLogger.getLogger().debug("Closing DB Connection ");
dbHibConnection.close();
if (dbHibConnection!=null)
dbHibConnection.close();
}catch(Exception e){
AnalysisLogger.getLogger().debug("Could not shut down connection");
}

View File

@ -244,7 +244,7 @@ public class AquamapsSuitable implements SpatialProbabilityDistributionTable{
@Override
public String getDescription() {
return "Algorithm by Aquamaps";
return "Algorithm for Suitable Distribution by Aquamaps";
}
@Override

View File

@ -65,17 +65,22 @@ public class TestClusterer {
AlgorithmConfiguration config = new AlgorithmConfiguration();
config.setConfigPath("./cfg/");
config.setPersistencePath("./");
config.setParam("OccurrencePointsTable","presence_basking_cluster");
config.setParam("FeaturesColumnNames","centerlat,centerlong");
config.setParam("OccurrencePointsClusterTable","occCluster_2");
config.setParam("OccurrencePointsTable","occurrence_species_id5397d3c4_a7eb_4227_adb4_d9d7d36e8b21");
config.setParam("FeaturesColumnNames","recordedby#basisofrecord#locality");
config.setParam("OccurrencePointsClusterTable","occCluster_gp");
config.setParam("epsilon","10");
config.setParam("minPoints","1");
config.setParam("min_points","1");
config.setConfigPath("./cfg/");
config.setPersistencePath("./");
config.setNumberOfResources(1);
config.setAgent("DBSCAN");
config.setParam("DatabaseUserName","utente");
config.setParam("DatabasePassword","d4science");
config.setParam("DatabaseURL","jdbc:postgresql://dbtest.next.research-infrastructures.eu/testdb");
config.setParam("DatabaseDriver","org.postgresql.Driver");
return config;
}

View File

@ -158,12 +158,16 @@ public class Transformations {
for (int i=0;i<m;i++){
sb.append((int)string.charAt(i));
}
double d = Double.MAX_VALUE;
try{
d = Double.valueOf(sb.toString());
}catch(Exception e){
}
if (d>Integer.MAX_VALUE)
return (indexString(string.substring(0,3)));
return d;
}