Commit 28e2f6cd authored by patrick.lambert's avatar patrick.lambert
Browse files

with latitude in export

parent 61fbaa65
...@@ -254,40 +254,34 @@ public class AnalyseFishDistribution extends AquaNismsGroupProcess<DiadromousFis ...@@ -254,40 +254,34 @@ public class AnalyseFishDistribution extends AquaNismsGroupProcess<DiadromousFis
// initialise the distribution range // initialise the distribution range
double southernEdge = northernLimit; double southernEdge = northernLimit;
double northernEdge = southernLimit; double northernEdge = southernLimit;
int southernId = -1;
int northernId = -1; RiverBasin northernBasin = null;
String southernName = ""; RiverBasin southernBasin = null;
String northernName = "";
// String southernName = "";
// String northernName = "";
// initialise for centroid // initialise for centroid
TreeMapForCentile latitudeEffective = new TreeMapForCentile(); TreeMapForCentile latitudeEffective = new TreeMapForCentile();
TreeMapForCentile latitudePresence = new TreeMapForCentile(); TreeMapForCentile latitudePresence = new TreeMapForCentile();
String[][] export = new String[2][6];
for (RiverBasin riverBasin : riverBasins) { for (RiverBasin riverBasin : riverBasins) {
double meanLastRecruitment = riverBasin.getLastRecruitments().getMean(); double meanLastRecruitment = riverBasin.getLastRecruitments().getMean();
if (meanLastRecruitment >= minimumRecruitsForPopulatedBasin) { if (meanLastRecruitment >= minimumRecruitsForPopulatedBasin) {
// the river basin is considered populated // the river basin is considered populated
// NOTE : recruiit number is calulated after thermal tolerance impact // CHECK : recruiit number is calulated after thermal tolerance impact
// (which is intreaged in the stock-recruitment relationship) // (which is intreaged in the stock-recruitment relationship)
// southern edge // southern edge
if (riverBasin.getLatitude() < southernEdge) { if (riverBasin.getLatitude() < southernEdge) {
// the basin is the new southern edge // the basin is the new southern edge
southernEdge = riverBasin.getLatitude(); southernEdge = riverBasin.getLatitude();
southernId = riverBasin.getBasin_id(); southernBasin = riverBasin;
southernName = riverBasin.getName();
} }
// northern edge // northern edge
if (riverBasin.getLatitude() > northernEdge) { if (riverBasin.getLatitude() > northernEdge) {
// the basin is the new northern edge // the basin is the new northern edge
northernEdge = riverBasin.getLatitude(); northernEdge = riverBasin.getLatitude();
northernId = riverBasin.getBasin_id(); northernBasin = riverBasin;
northernName = riverBasin.getName();
} }
// for distribution centroide computation // for distribution centroide computation
...@@ -297,29 +291,41 @@ public class AnalyseFishDistribution extends AquaNismsGroupProcess<DiadromousFis ...@@ -297,29 +291,41 @@ public class AnalyseFishDistribution extends AquaNismsGroupProcess<DiadromousFis
} }
} }
// if the universe is empty (none of basins is populated)
if (southernEdge == northernLimit & northernEdge == southernLimit) {
southernEdge = (northernLimit + southernLimit) / 2.;
northernEdge = southernEdge;
}
// distribution centroids computation // distribution centroids computation
double basinCentroid = latitudePresence.calculateMedian(); double basinCentroid = latitudePresence.calculateMedian();
double effectiveCentroid = latitudeEffective.calculateMedian(); double effectiveCentroid = latitudeEffective.calculateMedian();
// export
String[][] export = new String[2][7];
export[0][0] = "southern_basin_id"; export[0][0] = "southern_basin_id";
export[0][1] = "southern_basin_name"; export[0][1] = "southern_basin_name";
export[0][2] = "northern_basin_id"; export[0][2] = "southern_latitude";
export[0][3] = "northern_basin_name"; export[0][3] = "northern_basin_id";
export[0][4] = "basin_centroid_latitude"; export[0][4] = "northern_basin_name";
export[0][5] = "effective_centroid_latitude"; export[0][5] = "northern_latitude";
export[0][6] = "basin_centroid_latitude";
export[1][0] = String.valueOf(southernId); export[0][7] = "effective_centroid_latitude";
export[1][1] = southernName;
export[1][2] = String.valueOf(northernId); if (southernBasin != null & northernBasin != null) {
export[1][3] = northernName; export[1][0] = String.valueOf(southernBasin.getBasin_id());
export[1][4] = String.valueOf(basinCentroid); export[1][1] = southernBasin.getName();
export[1][5] = String.valueOf(effectiveCentroid); export[1][2] = String.valueOf(southernBasin.getLatitude());
export[1][3] = String.valueOf(northernBasin.getBasin_id());
export[1][4] = northernBasin.getName();
export[1][5] = String.valueOf(northernBasin.getLatitude());
export[1][6] = String.valueOf(basinCentroid);
export[1][7] = String.valueOf(effectiveCentroid);
} else {
export[1][0] = "NA";
export[1][1] = "NA";
export[1][2] = "NA";
export[1][3] = "NA";
export[1][4] = "NA";
export[1][5] = "NA";
export[1][6] = "NA";
export[1][7] = "NA";
}
return export; return export;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment