version 1.1

This commit is contained in:
2024-10-09 15:06:56 +02:00
parent d81fb678e3
commit 836a412a6d
536 changed files with 63922 additions and 0 deletions
+52
View File
@@ -0,0 +1,52 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>fr.cenra.rhomeo</groupId>
<artifactId>rhomeo</artifactId>
<version>1.2-SNAPSHOT</version>
</parent>
<groupId>fr.cenra.rhomeo</groupId>
<artifactId>protocol</artifactId>
<packaging>jar</packaging>
<name>Protocols</name>
<dependencies>
<dependency>
<groupId>fr.cenra.rhomeo</groupId>
<artifactId>core</artifactId>
<version>${project.version}</version>
</dependency>
<!-- TESTS -->
<dependency>
<groupId>fr.cenra.rhomeo</groupId>
<artifactId>core</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.sis.core</groupId>
<artifactId>sis-utility</artifactId>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
@@ -0,0 +1,209 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol;
import fr.cenra.rhomeo.api.annotations.RefersTo;
import fr.cenra.rhomeo.api.data.Statement;
import fr.cenra.rhomeo.api.process.ProcessContext;
import fr.cenra.rhomeo.core.Session;
import fr.cenra.rhomeo.core.data.reference.FloreBassinReference;
import fr.cenra.rhomeo.core.data.reference.OrthopteraIndicatorReference;
import fr.cenra.rhomeo.core.data.reference.Taxref;
import fr.cenra.rhomeo.core.util.RelationResolver;
import java.beans.IntrospectionException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.WeakHashMap;
import java.util.stream.Stream;
import javafx.beans.InvalidationListener;
import org.apache.sis.util.ArgumentChecks;
/**
*
* @author Alexis Manin (Geomatys)
* @param <T> Type of statements managed by current operator.
*/
public class TaxonOperator<T extends Statement> {
protected static final WeakHashMap<ProcessContext, TaxonOperator> CACHED_OPERATORS = new WeakHashMap<>(2);
protected final ProcessContext processContext;
private List<T> processData;
protected Map<Integer, Taxref> cdNomTaxrefMapping;
protected Map<Integer, Integer> cdNomCdRefMapping;
protected Map<String, Set<Integer>> odonataByCounty;
protected Map<Integer, FloreBassinReference> floreRefByCdNom;
protected Map<Integer, OrthopteraIndicatorReference> orthoRefByCdNom;
protected TaxonOperator(ProcessContext processContext) {
ArgumentChecks.ensureNonNull("Process context", processContext);
this.processContext = processContext;
}
public ProcessContext getProcessContext() {
return processContext;
}
/**
* Return an ordered (by date) list of statements present in this operator's
* process context.
*
* Returned list is a copy of actual dataset, no a view.
*
* @return List of data to base computing on.
*/
public synchronized List<T> getProcessData() throws Exception {
if (processData == null) {
processData = new ArrayList<>(processContext.getData().getItems());
processData.sort((o1, o2) -> o1.getDate().compareTo(o2.getDate()));
}
return processData;
}
/**
* Return the species identifier (cd_ref) associated to given taxon identifier (cd_nom).
* @param cdNom The name to get a species identifier for.
* @return A species identifier. Can be null.
* @throws ReflectiveOperationException
* @throws IntrospectionException
*/
@RefersTo(type = Taxref.class, property = "cd_nom")
public synchronized Taxref getTaxref(final int cdNom) throws ReflectiveOperationException, IntrospectionException {
if (cdNomTaxrefMapping == null) {
final RefersTo reference = TaxonOperator.class.getMethod("getTaxref", Integer.TYPE).getAnnotation(RefersTo.class);
Set<Taxref> refs = Session.getInstance().getBean(RelationResolver.class).getTargetObjects(reference);
cdNomTaxrefMapping = new HashMap<>(refs.size());
for (final Taxref ref : refs) {
cdNomTaxrefMapping.put(ref.getCd_nom(), ref);
}
}
return cdNomTaxrefMapping.get(cdNom);
}
/**
* Return the species identifier (cd_ref) associated to given taxon identifier (cd_nom).
* @param cdNom The name to get a species identifier for.
* @return A species identifier. Can be null.
* @throws ReflectiveOperationException
* @throws IntrospectionException
*/
@RefersTo(type = Taxref.class, property = "cd_ref")
public synchronized Integer getCdRef(final int cdNom) throws ReflectiveOperationException, IntrospectionException {
if (cdNomCdRefMapping == null) {
final RefersTo reference = TaxonOperator.class.getMethod("getCdRef", Integer.TYPE).getAnnotation(RefersTo.class);
Set<Taxref> refs = Session.getInstance().getBean(RelationResolver.class).getTargetObjects(reference);
cdNomCdRefMapping = new HashMap<>(refs.size());
for (final Taxref ref : refs) {
cdNomCdRefMapping.put(ref.getCd_nom(), ref.getCd_ref());
}
}
return cdNomCdRefMapping.get(cdNom);
}
@RefersTo(type = FloreBassinReference.class, property = "cd_nom")
public synchronized FloreBassinReference getFloreReference(final int cdNom) throws ReflectiveOperationException, IntrospectionException {
if (floreRefByCdNom == null) {
final RefersTo reference = TaxonOperator.class.getMethod("getFloreReference", Integer.TYPE).getAnnotation(RefersTo.class);
Set<FloreBassinReference> refs = Session.getInstance().getBean(RelationResolver.class).getTargetObjects(reference);
floreRefByCdNom = new HashMap<>(refs.size());
for (final FloreBassinReference ref : refs) {
floreRefByCdNom.put(ref.getCd_nom(), ref);
}
}
return floreRefByCdNom.get(cdNom);
}
private synchronized Map<Integer, OrthopteraIndicatorReference> getOrthopteraByCdRef() throws ReflectiveOperationException, IntrospectionException {
if (orthoRefByCdNom == null) {
final RefersTo reference = TaxonOperator.class.getMethod("getOrthopteraReference", Integer.TYPE).getAnnotation(RefersTo.class);
Set<OrthopteraIndicatorReference> refs = Session.getInstance().getBean(RelationResolver.class).getTargetObjects(reference);
orthoRefByCdNom = new HashMap<>(refs.size());
for (final OrthopteraIndicatorReference ref : refs) {
orthoRefByCdNom.put(ref.getCd_ref(), ref);
}
}
return orthoRefByCdNom;
}
@RefersTo(type = OrthopteraIndicatorReference.class, property = "cd_ref")
public synchronized OrthopteraIndicatorReference getOrthopteraReference(final int cdRef) throws ReflectiveOperationException, IntrospectionException {
return getOrthopteraByCdRef().get(cdRef);
}
/**
* Return all known orthoptera references.
*
* @return A stream of references available for the zone. Never null, but
* can be empty.
* @throws ReflectiveOperationException
* @throws IntrospectionException
*/
public Stream<OrthopteraIndicatorReference> getOrthopteraReferences() throws ReflectiveOperationException, IntrospectionException {
return getOrthopteraByCdRef().values().stream();
}
/**
* Find or initialize an operator which will work with given processing context.
* @param ctx The context to use this operator with.
* @return An operator valid for given context, either new or previously initiated.
*/
public static TaxonOperator getOrCreate(final ProcessContext ctx) {
synchronized (CACHED_OPERATORS) {
return CACHED_OPERATORS.computeIfAbsent(ctx, TaxonOperator::createOperator);
}
}
private static TaxonOperator createOperator(final ProcessContext ctx) {
// if source dataset or user selection change, we must create a new taxon operator to clear cached data.
final InvalidationListener listener = obs -> CACHED_OPERATORS.remove(ctx);
ctx.getSourceDataset().getItems().addListener(listener);
ctx.filterProperty().addListener(listener);
return new TaxonOperator(ctx);
}
}
@@ -0,0 +1,97 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p01;
import fr.cenra.rhomeo.api.process.Indicator;
import fr.cenra.rhomeo.api.result.DefaultIndex;
import fr.cenra.rhomeo.api.result.Index;
import fr.cenra.rhomeo.api.result.IndexSpi;
import java.util.Collection;
import java.util.Collections;
import javax.measure.quantity.Dimensionless;
import javax.measure.unit.Unit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
/**
* The definition of {@link I01} {@link Index}es.
*
* @author Samuel Andrés (Geomatys)
*/
@Component(AnnualAverageSoilHumidity.NAME)
public class AnnualAverageSoilHumidity implements IndexSpi<Double, Integer> {
public static final String NAME = "fr.cenra.rhomeo.protocol.p01.AnnualAverageSoilHumidity";
@Autowired
@Qualifier(I01.NAME)
private Indicator indicator;
@Override
public Unit<Dimensionless> getUnit() {
return Unit.ONE;
}
@Override
public Indicator getIndicator() {
return indicator;
}
@Override
public Index<Double> createIndex(final Double value, final Integer year) {
return new DefaultIndex<>(value, this, year);
}
@Override
public String getName() {
return NAME;
}
@Override
public Collection<String> getAlias() {
return Collections.singleton("I01");
}
@Override
public String getRemarks() {
return null;
}
}
@@ -0,0 +1,98 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p01;
import fr.cenra.rhomeo.api.InternationalDescription;
import fr.cenra.rhomeo.api.InternationalResource;
import fr.cenra.rhomeo.api.data.TrackingPoint;
import fr.cenra.rhomeo.api.process.Indicator;
import fr.cenra.rhomeo.api.result.Index;
import fr.cenra.rhomeo.api.result.IndexSpi;
import java.util.Collection;
import java.util.Collections;
import javax.measure.unit.Unit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
/**
* The definition of {@link I01} {@link Index}es.
*
* @author Samuel Andrés (Geomatys)
*/
@Component(AnnualPointAverageSoilHumidity.NAME)
public class AnnualPointAverageSoilHumidity implements IndexSpi<Double, TrackingPoint>, InternationalResource, InternationalDescription {
public static final String NAME = "fr.cenra.rhomeo.protocol.p01.AnnualPointAverageSoilHumidity";
@Autowired
@Qualifier(I01.NAME)
private Indicator indicator;
@Override
public Unit<?> getUnit() {
return Unit.ONE;
}
@Override
public Indicator getIndicator() {
return indicator;
}
@Override
public Index createIndex(final Double value, final TrackingPoint trackingPoint) {
return new AnnualPointAverageSoilHumidityIndex(value, this, trackingPoint);
}
@Override
public String getName() {
return NAME;
}
@Override
public Collection<String> getAlias() {
return Collections.singleton("I01");
}
@Override
public String getRemarks() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
}
@@ -0,0 +1,68 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p01;
import fr.cenra.rhomeo.api.data.TrackingPoint;
import fr.cenra.rhomeo.api.result.AbstractParametrableIndex;
import fr.cenra.rhomeo.api.result.Index;
import fr.cenra.rhomeo.api.result.TrackingPointIndex;
/**
* A specific {@link Index} for {@link I01}.
*
* @author Samuel Andrés (Geomatys)
*
* @see AnnualAverageSoilHumidity
*/
public class AnnualPointAverageSoilHumidityIndex extends AbstractParametrableIndex<Double, TrackingPoint> implements TrackingPointIndex<Double> {
public AnnualPointAverageSoilHumidityIndex(final Double value, final AnnualPointAverageSoilHumidity indexSpi, final TrackingPoint trackingPoint) {
super(value, indexSpi, trackingPoint, TrackingPoint.class);
}
@Override
public int getYear() {
return base.getYear();
}
@Override
public TrackingPoint getPoint() {
return base;
}
}
@@ -0,0 +1,447 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p01;
import fr.cenra.rhomeo.api.data.Protocol;
import fr.cenra.rhomeo.api.data.TrackingPoint;
import fr.cenra.rhomeo.api.process.Indicator;
import fr.cenra.rhomeo.api.process.Process;
import fr.cenra.rhomeo.api.process.ProcessContext;
import fr.cenra.rhomeo.api.result.Index;
import fr.cenra.rhomeo.api.process.AbstractIndicator;
import fr.cenra.rhomeo.core.util.TrackingPointComparator;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.OptionalDouble;
import java.util.Set;
import javafx.collections.transformation.SortedList;
import org.apache.sis.util.ArgumentChecks;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
/**
*
* @author Samuel Andrés (Geomatys)
*/
@Component(I01.NAME)
public class I01 extends AbstractIndicator {
public static final String NAME = "I01";
public static final String REMARKS = "Niveau d'humidité du sol - Pédologie";
/**
* Comparator used to compare {@link PedologyStatement} depths.
*/
private static final Comparator<PedologyStatement> ASCENDING_DEPTH = (o1, o2) -> o1.getDepth() - o2.getDepth();
@Autowired
@Qualifier(P01.NAME)
private Protocol protocol;
@Autowired
private AnnualAverageSoilHumidity annualSpi;
@Autowired
private AnnualPointAverageSoilHumidity pointSpi;
public I01() {
super(NAME, REMARKS);
}
@Override
public Protocol getProtocol() {
return protocol;
}
@Override
public Set<Process> createProcesses(final ProcessContext c) {
ArgumentChecks.ensureNonNull("processContext", c);
return Collections.singleton(new I01Process(c));
}
/**
* Determine if the given statement can be used for computation for {@link I01}.
*
* Relational selection of the temporary table t1 used in expertise.pedo_hygromorphie_par_site view.
*
* WITH t1 AS ( SELECT ### FROM expertise.pedo_obs_type_horizon t
* WHERE t.profondeur_min IS NOT NULL
* AND t.b1_couleur IS NOT NULL
* AND t.b2_value IS NOT NULL
* AND t.b3_chroma IS NOT NULL
* AND t.c_texture IS NOT NULL
* AND t.d_structure IS NOT NULL
* AND t.e_elements_grossiers IS NOT NULL
* AND t.f_racines IS NOT NULL
* AND t.g_taches IS NOT NULL)
*
* (Source : rhomeo_base_install.sql)
*
* This function determines if the {@link PedologyStatement} is computable.
*
* The purpose of t1 table used in expertise.pedo_hygromorphie_par_site view
* is to select expertise.pedo_obs_type_horizon computable tuples.
*
* @param ps The statement to check.
* @return
*/
public static boolean checkIfComputable(final PedologyStatement ps) {
return ps.getDepth() > 0 &&
ps.getColor() != null &&
ps.getValue() != null &&
ps.getChroma() != null &&
ps.getTexture() > 0 &&
ps.getStructure() > 0 &&
ps.getRawElements() > 0 &&
ps.getRoots() > 0 &&
ps.getStains() > 0;
}
@Override
public String getDefaultIndex() {
return AnnualAverageSoilHumidity.NAME;
}
/**
* CASE
* WHEN t2.profondeur_min :: INTEGER < 25 THEN t2.hz * 2
* ELSE t2.hz
* END AS hz_max,
*
* (Source : rhomeo_base_install.sql)
*
* @param hz of the statement.
* @param depth of the statement corresponding to given Hz.
*/
private static int weightByDepth(final int hz, final int depth) {
if (depth < 25)
return hz * 2;
return hz;
}
/**
* Compute average humidity by tracking point and for each year available.
*/
private class I01Process extends Process {
public I01Process(final ProcessContext c) {
super(c);
}
@Override
protected Set<? extends Index> call() throws Exception {
updateTitle("Calcul d'humidité");
updateMessage("Analyse des données");
final Set<Index> indices = new HashSet<>();
/**
* First, we sort data by year and tracking point. For each point,
* we'll compute an index.
*/
final ArrayList<TrackingPoint> tPoints = new ArrayList<>(ctx.getTrackingPoints());
final Map<TrackingPoint, Collection<Integer>> datasetHzMaxByTrackingPoint = new HashMap<>();
tPoints.sort(new TrackingPointComparator());
TrackingPoint lastTrackingPoint = null;
int lastDepth;
int currentDepth;
Collection<Integer> tpHZs = new ArrayList<>();
final long totalProgress = tPoints.size() * 2 + 1;
long progress = 0;
for (final TrackingPoint tp : tPoints) {
updateMessage(new StringBuilder("Hydromorphie des relevés pour ").append(tp.getName()).append(" (").append(tp.getYear()).append(')').toString());
updateProgress(progress++, totalProgress);
lastDepth = 0;
currentDepth = 0;
if (!tp.equals(lastTrackingPoint)) {
if (lastTrackingPoint != null && tpHZs.isEmpty()) {
//datasetHzMaxByTrackingPoint.remove(lastTrackingPoint, tpHZs);
}
lastTrackingPoint = tp;
tpHZs = new ArrayList<>();
datasetHzMaxByTrackingPoint.put(tp, tpHZs);
}
final SortedList<PedologyStatement> statements = ctx.getData().getSubSet(tp).sorted(ASCENDING_DEPTH);
for (final PedologyStatement statement : statements) {
if (statement.getDepth() > currentDepth) {
lastDepth = currentDepth;
}
if (checkIfComputable(statement)) {
tpHZs.add(weightByDepth(getHzCandidate(statement, lastDepth), lastDepth));
}
currentDepth = statement.getDepth();
}
}
// Compute indice for each years, based on results found for points.
// We compute the average of all retained values for each point of a year,
final HashMap<Integer, int[]> sumsByYear = new HashMap<>();
int[] sum;
for (final TrackingPoint pt : datasetHzMaxByTrackingPoint.keySet()) {
updateMessage(new StringBuilder("Hydromorphie moyenne pour ").append(pt.getName()).append(" (").append(pt.getYear()).append(')').toString());
updateProgress(progress++, totalProgress);
final OptionalDouble optValue = datasetHzMaxByTrackingPoint.get(pt).stream().mapToInt(i -> i).average();
if (optValue.isPresent()) {
indices.add(pointSpi.createIndex(optValue.getAsDouble(), pt));
}
sum = sumsByYear.computeIfAbsent(pt.getYear(), i -> new int[]{0, 0});
for (final Integer i : datasetHzMaxByTrackingPoint.get(pt)) {
sum[0] += i;
sum[1]++;
}
}
updateMessage("Calcul des hydromorphies par année");
updateProgress(progress++, totalProgress);
for (final Map.Entry<Integer, int[]> year : sumsByYear.entrySet()) {
indices.add(annualSpi.createIndex(year.getValue()[0] / (double) year.getValue()[1], year.getKey()));
}
return indices;
}
@Override
public Indicator getIndicator() {
return I01.this;
}
}
// Color
private static final String GLEY1 = "GLEY1";
private static final String GLEY2 = "GLEY2";
// Von-Post
private static final String H1 = "H1";
private static final String H2 = "H2";
private static final String H3 = "H3";
private static final String H4 = "H4";
private static final String H5 = "H5";
private static final String H6 = "H6";
private static final String H7 = "H7";
private static final String H8 = "H8";
private static final String H9 = "H9";
private static final String H10 = "H10";
/**
* CASE
* WHEN obs_pedo.f_racines > 1 AND obs_pedo.c_texture = 1 AND obs_pedo.numero = 1 AND obs_pedo.q_von_post IS NULL THEN '1'::text
* ELSE '0'::text
* END AS "L"
*
* (Source : rhomeo_base_install.sql)
*/
static int getL(final PedologyStatement ps, int minDepth) {
return ps.getRoots() > 1 && ps.getTexture()==1 && minDepth <= 0 && ps.getVonPost()==null ? 1 : 0;
};
/**
* CASE
* WHEN obs_pedo.c_texture > 1 AND (obs_pedo.g_taches = 3 OR obs_pedo.b1_couleur = 'GLEY1'::text AND obs_pedo.b2_value <> '7'::text AND obs_pedo.b2_value <> '8'::text OR obs_pedo.b1_couleur = 'GLEY2'::text AND obs_pedo.b2_value <> '7'::text AND obs_pedo.b2_value <> '8'::text) THEN '2'::text
* ELSE '0'::text
* END AS "Gr"
*
* (Source : rhomeo_base_install.sql)
*/
static int getGr(final PedologyStatement ps) {
return ps.getTexture() > 1
&& (ps.getStains()==3
|| GLEY1.equals(ps.getColor())
&& !"7".equals(ps.getValue())
&& !"8".equals(ps.getValue())
|| GLEY2.equals(ps.getColor())
&& !"7".equals(ps.getValue())
&& !"8".equals(ps.getValue())) ? 2 : 0;
};
/**
* CASE
* WHEN obs_pedo.c_texture > 1 AND obs_pedo.g_taches = 2 AND obs_pedo.h_abondance > 0 THEN '1'::text
* ELSE '0'::text
* END AS "Go"
*
* (Source : rhomeo_base_install.sql)
*/
static int getGo(final PedologyStatement ps) {
return ps.getTexture() > 1 && ps.getStains()==2 && ps.getAbundance()>0 ? 1 : 0;
};
/**
* CASE
* WHEN obs_pedo.c_texture > 1 AND obs_pedo.c_texture < 4 AND obs_pedo.o_friabilite > 2 AND obs_pedo.d_structure = 1 THEN '1'::text
* ELSE '0'::text
* END AS "J"
*
* (Source : rhomeo_base_install.sql)
*/
static int getJ(final PedologyStatement ps) {
return ps.getTexture()>1 && ps.getTexture()<4 && ps.getFriability()>2 && ps.getStructure()==1 ? 1 : 0;
};
/**
* CASE
* WHEN obs_pedo.b2_value::numeric > 4.5 AND obs_pedo.q_von_post IS NULL AND obs_pedo.o_friabilite < 2 AND obs_pedo.m_plasticite = 1 THEN '3'::text
* ELSE '0'::text
* END AS "T"
*
* (Source : rhomeo_base_install.sql)
*
* @throws IllegalArgumentException if the statement "value" field is null.
* @throws NumberFormatException if the string does not contain a parsable number.
*/
static int getT(final PedologyStatement ps) {
// Missing fields
if (ps.getValue() == null || ps.getFriability() < 1)
return 0;
return (Float.valueOf(ps.getValue())>4.5 && ps.getVonPost()==null && ps.getFriability()<2 && ps.getPlasticity()==1) ? 3 : 0;
};
/**
* CASE
* WHEN obs_pedo.c_texture = 1 AND obs_pedo.d_structure > 10 AND (obs_pedo.q_von_post = 'H1'::text OR obs_pedo.q_von_post = 'H2'::text OR obs_pedo.q_von_post = 'H3'::text) THEN '3'::text
* ELSE '0'::text
* END AS "Hf"
*
* (Source : rhomeo_base_install.sql)
*/
static int getHf(final PedologyStatement ps) {
return ps.getTexture()==1
&& ps.getStructure()>10
&& (H1.equals(ps.getVonPost())
|| H2.equals(ps.getVonPost())
|| H3.equals(ps.getVonPost())) ? 3 : 0;
};
/**
* CASE
* WHEN obs_pedo.c_texture = 1 AND (obs_pedo.q_von_post = 'H3'::text OR obs_pedo.q_von_post = 'H4'::text OR obs_pedo.q_von_post = 'H5'::text OR obs_pedo.q_von_post = 'H6'::text OR obs_pedo.q_von_post = 'H7'::text) THEN '2'::text
* ELSE '0'::text
* END AS "Hm"
*
* (Source : rhomeo_base_install.sql)
*/
static int getHm(final PedologyStatement ps) {
return ps.getTexture()==1 && (H3.equals(ps.getVonPost())
|| H4.equals(ps.getVonPost()) || H5.equals(ps.getVonPost())
|| H6.equals(ps.getVonPost()) || H7.equals(ps.getVonPost())) ? 2 : 0;
};
/**
* CASE
* WHEN obs_pedo.c_texture = 1 AND (obs_pedo.q_von_post = 'H8'::text OR obs_pedo.q_von_post = 'H9'::text OR obs_pedo.q_von_post = 'H10'::text)
* OR obs_pedo.c_texture >= 3 AND (obs_pedo.q_von_post = 'H3'::text OR obs_pedo.q_von_post = 'H4'::text OR obs_pedo.q_von_post = 'H5'::text OR obs_pedo.q_von_post = 'H6'::text OR obs_pedo.q_von_post = 'H7'::text OR obs_pedo.q_von_post = 'H8'::text OR obs_pedo.q_von_post = 'H9'::text OR obs_pedo.q_von_post = 'H10'::text) THEN '2'::text
* ELSE '0'::text
* END AS "Hs"
*
* (Source : rhomeo_base_install.sql)
*/
static int getHs(final PedologyStatement ps) {
return ps.getTexture()==1 && (H8.equals(ps.getVonPost()) || H9.equals(ps.getVonPost())
|| H10.equals(ps.getVonPost()))
|| ps.getTexture()>=3 && (H3.equals(ps.getVonPost()) || H4.equals(ps.getVonPost())
|| H5.equals(ps.getVonPost()) || H6.equals(ps.getVonPost())
|| H7.equals(ps.getVonPost()) || H8.equals(ps.getVonPost())
|| H9.equals(ps.getVonPost()) || H10.equals(ps.getVonPost())) ? 2 : 0;
};
/**
* CASE
* WHEN obs_pedo.g_taches = 1 AND obs_pedo.q_von_post IS NULL AND (obs_pedo.c_texture = 1 AND obs_pedo.d_structure < 10 AND obs_pedo.d_structure > 3 OR obs_pedo.c_texture > 1 AND obs_pedo.d_structure > 10) THEN '2'::text
* ELSE '0'::text
* END AS "Org"
*
* (Source : rhomeo_base_install.sql)
*/
static int getOrg(final PedologyStatement ps) {
return ps.getStains()==1 && ps.getVonPost()==null
&& (ps.getTexture()==1 && ps.getStructure()<10 && ps.getStructure()>3
|| ps.getTexture()>1 && ps.getStructure()>10) ? 2 : 0;
};
/**
* CASE
* WHEN obs_pedo.c_texture = 1 AND obs_pedo.q_von_post IS NULL AND obs_pedo.k_humidite <= 3 AND (obs_pedo.d_structure <= 3 OR obs_pedo.d_structure = 11) THEN '1'::text
* ELSE '0'::text
* END AS "Ha_LH"
*
* (Source : rhomeo_base_install.sql)
*/
static int getHa_LH(final PedologyStatement ps) {
// Missing fields
if (ps.getHumidity() < 1 || ps.getStructure() < 1)
return 0;
return ps.getTexture()==1
&& ps.getVonPost()==null
&& ps.getHumidity()<=3
&& (ps.getStructure()<=3 || ps.getStructure()==11) ? 1 : 0;
};
/**
* Greatest(t1."l", t1."gr", t1."go", t1."j", t1."t", t1."hf", t1."hm", t1."hs", t1."org", t1."ha_lh"))
*
* (Source : rhomeo_base_install.sql)
*/
static Integer getHzCandidate(final PedologyStatement ps, int lastDepth) {
final int[] candidates = new int[]{
getL(ps, lastDepth),
getGr(ps),
getGo(ps),
getJ(ps),
getT(ps),
getHf(ps),
getHm(ps),
getHs(ps),
getOrg(ps),
getHa_LH(ps)
};
Arrays.sort(candidates);
return candidates[candidates.length -1];
}
}
@@ -0,0 +1,58 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p01;
import fr.cenra.rhomeo.api.data.AbstractProtocol;
import org.springframework.stereotype.Component;
/**
* Pedology protocol.
*
* @author Samuel Andrés (Geomatys)
*/
@Component(P01.NAME)
public class P01 extends AbstractProtocol {
public static final String NAME = "P01";
public static final String REMARKS = "Pédologie";
public P01(){
super(NAME, REMARKS, PedologyStatement.class);
}
}
@@ -0,0 +1,843 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p01;
import fr.cenra.rhomeo.api.annotations.RefersTo;
import fr.cenra.rhomeo.api.data.Statement;
import fr.cenra.rhomeo.api.data.Warning;
import fr.cenra.rhomeo.core.list.VonPost;
import fr.cenra.rhomeo.protocol.p01.list.Abundance;
import fr.cenra.rhomeo.protocol.p01.list.Adhesiveness;
import fr.cenra.rhomeo.protocol.p01.list.AlterationMO;
import fr.cenra.rhomeo.protocol.p01.list.Chroma;
import fr.cenra.rhomeo.protocol.p01.list.Clarity;
import fr.cenra.rhomeo.protocol.p01.list.Color;
import fr.cenra.rhomeo.protocol.p01.list.Compacity;
import fr.cenra.rhomeo.protocol.p01.list.Friability;
import fr.cenra.rhomeo.protocol.p01.list.Humidity;
import fr.cenra.rhomeo.protocol.p01.list.Limits;
import fr.cenra.rhomeo.protocol.p01.list.Plasticity;
import fr.cenra.rhomeo.protocol.p01.list.RawElements;
import fr.cenra.rhomeo.protocol.p01.list.Roots;
import fr.cenra.rhomeo.protocol.p01.list.Shape;
import fr.cenra.rhomeo.protocol.p01.list.Size;
import fr.cenra.rhomeo.protocol.p01.list.Stains;
import fr.cenra.rhomeo.protocol.p01.list.Structure;
import fr.cenra.rhomeo.protocol.p01.list.Texture;
import java.time.LocalDate;
import java.util.Objects;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.NotBlank;
/**
*
* @author Samuel Andrés (Geomatys)
*/
public class PedologyStatement extends Statement {
private final IntegerProperty numberHProperty = new SimpleIntegerProperty();
private final SimpleObjectProperty<Integer> depthProperty = new SimpleObjectProperty();
private final IntegerProperty limitsProperty = new SimpleIntegerProperty();
private final StringProperty colorProperty = new SimpleStringProperty();
private final StringProperty valueProperty = new SimpleStringProperty();
private final StringProperty chromaProperty = new SimpleStringProperty();
private final IntegerProperty textureProperty = new SimpleIntegerProperty();
private final IntegerProperty structureProperty = new SimpleIntegerProperty();
private final IntegerProperty rawElementsProperty = new SimpleIntegerProperty();
private final IntegerProperty rootsProperty = new SimpleIntegerProperty();
private final IntegerProperty stainsProperty = new SimpleIntegerProperty();
private final IntegerProperty abundanceProperty = new SimpleIntegerProperty();
private final IntegerProperty sizeProperty = new SimpleIntegerProperty();
private final IntegerProperty shapeProperty = new SimpleIntegerProperty();
private final IntegerProperty humidityProperty = new SimpleIntegerProperty();
private final IntegerProperty compactnessProperty = new SimpleIntegerProperty();
private final IntegerProperty plasticityProperty = new SimpleIntegerProperty();
private final IntegerProperty adhesivenessProperty = new SimpleIntegerProperty();
private final IntegerProperty friabilityProperty = new SimpleIntegerProperty();
private final IntegerProperty alterationMoProperty = new SimpleIntegerProperty();
private final StringProperty vonPostProperty = new SimpleStringProperty();
public PedologyStatement() {
}
/**
*
* @param trackingPoint
* @param date
* @param remarks
* @param numberH
* @param depth
* @param limits
* @param color
* @param value
* @param chroma
* @param texture
* @param structure
* @param rawElements
* @param roots
* @param stains
* @param abundance Not null. Set to 0 for no abundance value.
* @param size
* @param shape
* @param humidity
* @param compactness
* @param plasticity
* @param adhesiveness
* @param friability
* @param alterationMo
* @param vonPost
*/
public PedologyStatement(final String trackingPoint, final LocalDate date,
final String remarks, final int numberH, final int depth,
final int limits, final String color, final String value,
final String chroma, final int texture, final int structure,
final int rawElements, final int roots, final int stains,
final int abundance, final int size, final int shape,
final int humidity, final int compactness, final int plasticity,
final int adhesiveness, final int friability,
final int alterationMo, final String vonPost) {
super(trackingPoint, date);
this.remarksProperty.set(remarks);
this.numberHProperty.set(numberH);
this.depthProperty.set(depth);
this.limitsProperty.set(limits);
this.colorProperty.set(color);
this.valueProperty.set(value);
this.chromaProperty.set(chroma);
this.textureProperty.set(texture);
this.structureProperty.set(structure);
this.rawElementsProperty.set(rawElements);
this.rootsProperty.set(roots);
this.stainsProperty.set(stains);
this.abundanceProperty.set(abundance);
this.sizeProperty.set(size);
this.shapeProperty.set(shape);
this.humidityProperty.set(humidity);
this.compactnessProperty.set(compactness);
this.plasticityProperty.set(plasticity);
this.adhesivenessProperty.set(adhesiveness);
this.friabilityProperty.set(friability);
this.alterationMoProperty.set(alterationMo);
this.vonPostProperty.set(vonPost);
}
public IntegerProperty numberHProperty(){return numberHProperty;}
public SimpleObjectProperty<Integer> depthProperty(){return depthProperty;}
public IntegerProperty limitsProperty(){return limitsProperty;}
public StringProperty colorProperty(){return colorProperty;}
public StringProperty valueProperty(){return valueProperty;}
public StringProperty chromaProperty(){return chromaProperty;}
public IntegerProperty textureProperty(){return textureProperty;}
public IntegerProperty structureProperty(){return structureProperty;}
public IntegerProperty rawElementsProperty(){return rawElementsProperty;}
public IntegerProperty rootsProperty(){return rootsProperty;}
public IntegerProperty stainsProperty(){return stainsProperty;}
public IntegerProperty abundanceProperty(){return abundanceProperty;}
public IntegerProperty sizeProperty(){return sizeProperty;}
public IntegerProperty shapeProperty(){return shapeProperty;}
public IntegerProperty humidityProperty(){return humidityProperty;}
public IntegerProperty compactnessProperty(){return compactnessProperty;}
public IntegerProperty plasticityProperty(){return plasticityProperty;}
public IntegerProperty adhesivenessProperty(){return adhesivenessProperty;}
public IntegerProperty friabilityProperty(){return friabilityProperty;}
public IntegerProperty alterationMoProperty(){return alterationMoProperty;}
public StringProperty vonPostProperty(){return vonPostProperty;}
public void setNumberH(final int numberH){numberHProperty.set(numberH);}
public void setDepth(final int depth){depthProperty.set(depth);}
public void setDepth(final Integer depth){depthProperty.set(depth);}
public void setLimits(final int limits){limitsProperty.set(limits);}
public void setColor(final String color){colorProperty.set(color);}
public void setValue(final String value){valueProperty.set(value);}
public void setChroma(final String chroma){chromaProperty.set(chroma);}
public void setTexture(final int texture){textureProperty.set(texture);}
public void setStructure(final int structure){structureProperty.set(structure);}
public void setRawElements(final int rawElements){rawElementsProperty.set(rawElements);}
public void setRoots(final int roots){rootsProperty.set(roots);}
public void setStains(final int stains){stainsProperty.set(stains);}
public void setAbundance(final int abundance){abundanceProperty.set(abundance);}
public void setSize(final int size){sizeProperty.set(size);}
public void setShape(final int shape){shapeProperty.set(shape);}
public void setHumidity(final int humidity){humidityProperty.set(humidity);}
public void setCompactness(final int compactness){compactnessProperty.set(compactness);}
public void setPlasticity(final int plasticity){plasticityProperty.set(plasticity);}
public void setAdhesiveness(final int adhesiveness){adhesivenessProperty.set(adhesiveness);}
public void setFriability(final int friability){friabilityProperty.set(friability);}
public void setAlterationMo(final int alterationMo){alterationMoProperty.set(alterationMo);}
public void setVonPost(final String vonPost){vonPostProperty.set(vonPost);}
/**
* NUMERO_H.
*
* (Source : CCTP)
*
* "Numéro du prélèvement de sol [(horizon)]."
*
* (Source : rhomeo_base_install.sql)
*
* @return
*/
@Min(1)
@NotNull
public int getNumberH() {
return numberHProperty.get();
}
/**
* PROFONDEUR.
*
* (Source : CCTP)
*
* "Profondeur maximale [d'un] horizon."
*
* (Source : Boîte à outils complète)
*
* @return
*/
@Min(value = 1, payload = Warning.class)
public int getDepth() {
// If depth is null, we consider we're on a bottom one, where user might not know max depth.
return depthProperty.get() == null? Integer.MAX_VALUE : depthProperty.get();
}
/**
* LIMITES.
*
* (Source : CCTP)
*
* Bloc A.
*
* Codes :
* 1 => régulière
* 2 => ondulée
* 3 => irrégulière
* 4 => interrompue
*
* (Source : Boîte à outils complète)
*
* @return
*/
@RefersTo(type = Limits.class, property="code", payload = Warning.class)
@NotNull(payload=Warning.class)
public int getLimits() {
return limitsProperty.get();
}
/**
* COLOR.
*
* (Source : CCTP)
*
* "teinte 'hue'."
*
* (Source : Boîte à outils complète)
*
* @return
*/
@RefersTo(type = Color.class, property="code", payload = Warning.class)
@NotBlank(payload=Warning.class)
public String getColor() {
return colorProperty.get();
}
/**
* VALUE.
*
* (Source : CCTP)
*
* "clarté 'value' […] de la charte Munsell."
*
* (Source : Boîte à outils complète)
*
* @return
*/
@RefersTo(type = Clarity.class, property="code", payload = Warning.class)
@NotBlank(payload=Warning.class)
public String getValue() {
return valueProperty.get();
}
/**
* CHROMA.
*
* (Source : CCTP)
*
* "pureté 'chroma' […] de la charte Munsell."
*
* (Source : Boîte à outils complète)
*
* @return
*/
@RefersTo(type = Chroma.class, property="code", payload = Warning.class)
@NotBlank(payload=Warning.class)
public String getChroma() {
return chromaProperty.get();
}
/**
* TEXTURE.
*
* (Source : CCTP)
*
* Bloc C.
*
* Codes :
* 1 => organique
* 2 => sableuse
* 3 => limoneuse
* 4 => argileuse
*
* (Source : Boîte à outils complète)
*
* @return
*/
@RefersTo(type = Texture.class, property="code", payload = Warning.class)
@NotNull(payload=Warning.class)
public int getTexture() {
return textureProperty.get();
}
/**
* STRUCTURE.
*
* (Source : CCTP)
*
* Bloc D.
*
* Codes :
* 1 => particulaire
* 2 => grumeleuse
* 3 => grenue
* 4 => massive
* 5 => lammellaire
* 6 => prismatique
* 7 => en colonnes
* 8 => polyédrique
* 9 => blocs cubique
* 10 => en fuseaux
* 11 => fibreuse
* 12 => feuillettée
* 13 => lithologique
*
* (Source : Boîte à outils complète)
*
* @return
*/
@RefersTo(type = Structure.class, property="code", payload = Warning.class)
@NotNull(payload=Warning.class)
public int getStructure() {
return structureProperty.get();
}
/**
* ELEMENTS_GROSSIERS.
*
* (Source : CCTP)
*
* Bloc E.
*
* Codes :
* 1 => sans
* 2 => Graviers < 2cm
* 3 => Cailloux 2 à 6cm
* 4 => Pierres et blocs > 6cm
*
* (Source : Boîte à outils complète)
*
* @return
*/
@RefersTo(type = RawElements.class, property="code", payload = Warning.class)
@NotNull(payload=Warning.class)
public int getRawElements() {
return rawElementsProperty.get();
}
/**
* RACINES.
*
* (Source : CCTP)
*
* Bloc F.
*
* Codes :
* 1 => sans
* 2 => < 8/dm²
* 3 => 8 à 32 / dm²
* 4 => > 32 /dm²
*
* (Source : Boîte à outils complète)
*
* @return
*/
@RefersTo(type = Roots.class, property="code", payload = Warning.class)
@NotNull(payload=Warning.class)
public int getRoots() {
return rootsProperty.get();
}
/**
* TACHES.
*
* (Source : CCTP)
*
* Bloc G.
*
* Codes :
* 1 => sans
* 2 => oxydation
* 3 => réduction
*
* (Source : Boîte à outils complète)
*
* @return
*/
@RefersTo(type = Stains.class, property="code", payload = Warning.class)
@NotNull(payload=Warning.class)
public int getStains() {
return stainsProperty.get();
}
/**
* ABONDANCE.
*
* (Source : CCTP)
*
* "…descripteur noté [uniquement] en présence de taches d'oxydation ([G]=2)."
*
* Bloc H.
*
* Codes :
* 1 => < 5%
* 2 => 5 à 15 %
* 3 => 15 à 40 %
* 4 => > 40 %
*
* (Source : Boîte à outils complète)
*
* @return
*/
@RefersTo(type = Abundance.class, property="code", payload = Warning.class)
@NotNull(payload=Warning.class)
public int getAbundance() {
return abundanceProperty.get();
}
/**
* TAILLE.
*
* (Source : CCTP)
*
* "…descripteur noté [uniquement] en présence de taches d'oxydation ([G]=2)."
*
* Bloc I.
*
* Codes :
* 1 => < 2 mm
* 2 => 2 à 6 mm
* 3 => 6 à 20 mm
* 4 => > 20 mm
*
* (Source : Boîte à outils complète)
*
* @return
*/
@RefersTo(type = Size.class, property="code", payload = Warning.class)
@NotNull(payload=Warning.class)
public int getSize() {
return sizeProperty.get();
}
/**
* FORME.
*
* (Source : CCTP)
*
* "…descripteur noté [uniquement] en présence de taches d'oxydation ([G]=2)."
*
* Bloc J.
*
* Codes :
* 1 => irrégulières
* 2 => arrondis
* 3 => trainées horizontales
* 4 => trainées verticales
*
* (Source : Boîte à outils complète)
*
* @return
*/
@RefersTo(type = Shape.class, property="code", payload = Warning.class)
@NotNull(payload=Warning.class)
public int getShape() {
return shapeProperty.get();
}
/**
* HUMIDITE.
*
* (Source : CCTP)
*
* Bloc K.
*
* Codes :
* 1 => sec
* 2 => frais
* 3 => humide
* 4 => saturé
*
* (Source : Boîte à outils complète)
*
* @return
*/
@RefersTo(type = Humidity.class, property="code", payload = Warning.class)
@NotNull(payload=Warning.class)
public int getHumidity() {
return humidityProperty.get();
}
/**
* COMPACITE.
*
* (Source : CCTP)
*
* Bloc L.
*
* Codes (couteau) :
* 1 => pénétré sans effort
* 2 => avec effort
* 3 => incomplètement
* 4 => pas ou de quelques mm
*
* (Source : Boîte à outils complète)
*
* @return
*/
@RefersTo(type = Compacity.class, property="code", payload = Warning.class)
@NotNull(payload=Warning.class)
public int getCompactness() {
return compactnessProperty.get();
}
/**
* PLASTICITE.
*
* (Source : CCTP)
*
* Bloc M.
*
* Codes (boudin) :
* 1 => impossible de le former
* 2 => se brise sous son poids
* 3 => sous faible déformation
* 4 => ne rompt pas
*
* (Source : Boîte à outils complète)
*
* @return
*/
@RefersTo(type = Plasticity.class, property="code", payload = Warning.class)
@NotNull(payload=Warning.class)
public int getPlasticity() {
return plasticityProperty.get();
}
/**
* ADHESIVITE.
*
* (Source : CCTP)
*
* Bloc N.
*
* Codes (pouce/index) :
* 1 => non collant
* 2 => colle sans adhérer
* 3 => adhère aux doigts
* 4 => s'étire nettement
*
* (Source : Boîte à outils complète)
*
* @return
*/
@RefersTo(type = Adhesiveness.class, property="code", payload = Warning.class)
@NotNull(payload=Warning.class)
public int getAdhesiveness() {
return adhesivenessProperty.get();
}
/**
* FRIABILITE.
*
* (Source : CCTP)
*
* Bloc O.
*
* Codes (pouce/index) :
* 1 => ne s'effrite pas
* 2 => sous forte pression
* 3 => s'effrite facilement
* 4 => très légère pression
*
* (Source : Boîte à outils complète)
*
* @return
*/
@RefersTo(type = Friability.class, property="code", payload = Warning.class)
@NotNull(payload=Warning.class)
public int getFriability() {
return friabilityProperty.get();
}
/**
* ALTERATION_MO.
*
* (Source : CCTP)
*
* "…altération de la [matière organique]."
*
* Bloc P.
*
* Codes :
* 1 => végétaux identifiables
* 2 => identifiables avec traces de décomposition
* 3 => peu d'organes végétaux identifiables
* 4 => non identifiable
*
* (Source : Boîte à outils complète)
*
* @return
*/
@RefersTo(type = AlterationMO.class, property="code", payload = Warning.class)
@NotNull(payload=Warning.class)
public int getAlterationMo() {
return alterationMoProperty.get();
}
/**
* VON_POST.
*
* (Source : CCTP)
*
* "Indice de Von-Post."
*
* Bloc Q.
*
* Codes :
* H1 => eau limpide
* H2 => eau peu colorée
* H3 => eau trouble pâle
* H4 => eau trouble foncée
* H5 => eau trouble et particules
* H6 => 1/3 du matériel passe entre les doigts
* H7 => 1/2du matériel passe entre les doigts
* H8 => 2/3 du matériel passe entre les doigts
* H9 => Presque tout le matériel
* H10 => Tout le matériel
*
* (Source : Boîte à outils complète)
*
* @return
*/
@RefersTo(type = VonPost.class, property = "code", payload = Warning.class)
@NotBlank(payload=Warning.class)
public String getVonPost(){
return vonPostProperty.get();
}
/**
*
* @return
*
* @see PedologyStatement#equals(java.lang.Object)
*/
@Override
public int hashCode() {
Integer hash = 7;
hash = 37 * hash + Objects.hashCode(this.getDate());
hash = 37 * hash + Objects.hashCode(this.getTrackingPoint());
hash = 37 * hash + getNumberH();
hash = 37 * hash + getDepth();
return hash;
}
/**
* {@link PedologyStatement} equality is determined by the horizon number at
* a given date and at a given tracking point.
*
* @param obj
* @return
*/
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final PedologyStatement other = (PedologyStatement) obj;
return
// Compare first elements which are most likely to differ.
getDepth() == other.getDepth() &&
getNumberH() == other.getNumberH() &&
Objects.equals(getTrackingPoint(), other.getTrackingPoint()) &&
Objects.equals(getDate(), other.getDate()) &&
// Other, alphabetically
getAbundance() == other.getAbundance() &&
getAdhesiveness() == other.getAdhesiveness() &&
getAlterationMo() == other.getAlterationMo() &&
Objects.equals(getChroma(), other.getChroma()) &&
Objects.equals(getColor(), other.getColor()) &&
getCompactness() == other.getCompactness() &&
getFriability() == other.getFriability() &&
getHumidity() == other.getHumidity() &&
getLimits() == other.getLimits() &&
getPlasticity() == other.getPlasticity() &&
getRawElements() == other.getRawElements() &&
Objects.equals(getRemarks(), other.getRemarks()) &&
getRoots() == other.getRoots() &&
getShape() == other.getShape() &&
getSize() == other.getSize() &&
getStains() == other.getStains() &&
getStructure() == other.getStructure() &&
getTexture() == other.getTexture() &&
Objects.equals(getValue(), other.getValue()) &&
Objects.equals(getVonPost(), other.getVonPost());
}
@Override
public String toString() {
return new StringBuilder("PedologyStatement{")
.append("remarks=").append(getRemarks())
.append(", numberH=").append(getNumberH())
.append(", depth=").append(getDepth())
.append(", limits=").append(getLimits())
.append(", color=").append(getColor())
.append(", value=").append(getValue())
.append(", chroma=").append(getChroma())
.append(", texture=").append(getTexture())
.append(", structure=").append(getStructure())
.append(", rawElements=").append(getRawElements())
.append(", roots=").append(getRoots())
.append(", stains=").append(getStains())
.append(", abundance=").append(getAbundance())
.append(", size=").append(getSize())
.append(", shape=").append(getShape())
.append(", humidity=").append(getHumidity())
.append(", compactness=").append(getCompactness())
.append(", plasticity=").append(getPlasticity())
.append(", adhesiveness=").append(getAdhesiveness())
.append(", friability=").append(getFriability())
.append(", alterationMo=").append(getAlterationMo())
.append(", vonPost=").append(getVonPost())
.append('}').toString();
}
}
@@ -0,0 +1,75 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p01.list;
import fr.cenra.rhomeo.core.list.CodeValue;
/**
*
* @author Alexis Manin (Geomatys)
*/
public enum Abundance implements CodeValue {
NOT(1, "< 5 %"),
FEW(2, "5 à 15 %"),
MED(3, "15 à 40 %"),
LOT(4, "40 %");
private final int code;
private final String title;
private Abundance(int code, String title) {
this.code = code;
this.title = title;
}
@Override
public Integer getCode() {
return code;
}
@Override
public String getValue() {
return title;
}
@Override
public String toString() {
return new StringBuilder().append(code).append(" ").append(title).toString();
}
}
@@ -0,0 +1,75 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p01.list;
import fr.cenra.rhomeo.core.list.CodeValue;
/**
*
* @author Alexis Manin (Geomatys)
*/
public enum Adhesiveness implements CodeValue {
FIR(1, "Non collant"),
SEC(2, "Colle sans adhérer"),
THI(3, "Adhère aux doigts"),
FOU(4, "S'étire nettement");
private final int code;
private final String title;
private Adhesiveness(int code, String title) {
this.code = code;
this.title = title;
}
@Override
public Integer getCode() {
return code;
}
@Override
public String getValue() {
return title;
}
@Override
public String toString() {
return new StringBuilder().append(code).append(" ").append(title).toString();
}
}
@@ -0,0 +1,75 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p01.list;
import fr.cenra.rhomeo.core.list.CodeValue;
/**
*
* @author Alexis Manin (Geomatys)
*/
public enum AlterationMO implements CodeValue {
FIR(1, "Végétaux identifiables"),
SEC(2, "Identifiables avec trace de décomposition"),
THI(3, "Peu d'organes végétaux identifiables"),
FOU(4, "Non identifiable");
private final int code;
private final String title;
private AlterationMO(int code, String title) {
this.code = code;
this.title = title;
}
@Override
public Integer getCode() {
return code;
}
@Override
public String getValue() {
return title;
}
@Override
public String toString() {
return new StringBuilder().append(code).append(" ").append(title).toString();
}
}
@@ -0,0 +1,86 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p01.list;
import fr.cenra.rhomeo.core.list.CodeValue;
/**
*
* @author Alexis Manin (Geomatys)
*/
public enum Chroma implements CodeValue {
FIR("1"),
SEC("2"),
THR("3"),
FOU("4"),
FIF("6"),
SIX("8"),
SEV("N"),
EIG("10B"),
NIN("10BG"),
TEN("10G"),
ELE("10GY"),
TWE("10Y"),
THI("5B"),
FOR("5BG"),
FIT("5G"),
SIT("5GY"),
SET("5PB");
private final String code;
private Chroma(String code) {
this.code = code;
}
@Override
public String getCode() {
return code;
}
@Override
public String getValue() {
return code;
}
@Override
public String toString() {
return code;
}
}
@@ -0,0 +1,77 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p01.list;
import fr.cenra.rhomeo.core.list.CodeValue;
/**
*
* @author Alexis Manin (Geomatys)
*/
public enum Clarity implements CodeValue {
FIR("2"),
SEC("2.5"),
THI("3"),
FOU("4"),
FIF("5"),
SIX("6"),
SEV("7"),
EIG("8");
private final String code;
private Clarity(String code) {
this.code = code;
}
@Override
public String getCode() {
return code;
}
@Override
public String getValue() {
return code;
}
@Override
public String toString() {
return code;
}
}
@@ -0,0 +1,78 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p01.list;
import fr.cenra.rhomeo.core.list.CodeValue;
/**
*
* @author Alexis Manin (Geomatys)
*/
public enum Color implements CodeValue {
GLEY1("GLEY1"),
GLEY2("GLEY2"),
_10R("10R"),
_2_5YR("2.5YR"),
_5YR("5YR"),
_7_5YR("7.5YR"),
_10YR("10YR"),
_2_5Y("2.5Y"),
_5Y("5Y");
private final String code;
private Color(String code) {
this.code = code;
}
@Override
public String getCode() {
return code;
}
@Override
public String getValue() {
return code;
}
@Override
public String toString() {
return code;
}
}
@@ -0,0 +1,75 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p01.list;
import fr.cenra.rhomeo.core.list.CodeValue;
/**
*
* @author Alexis Manin (Geomatys)
*/
public enum Compacity implements CodeValue {
FIR(1, "Pénètre sans effort"),
SEC(2, "Avec effort"),
THI(3, "incomplètement"),
FOU(4, "Pas ou de quelques mm");
private final int code;
private final String title;
private Compacity(int code, String title) {
this.code = code;
this.title = title;
}
@Override
public Integer getCode() {
return code;
}
@Override
public String getValue() {
return title;
}
@Override
public String toString() {
return new StringBuilder().append(code).append(" ").append(title).toString();
}
}
@@ -0,0 +1,75 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p01.list;
import fr.cenra.rhomeo.core.list.CodeValue;
/**
*
* @author Alexis Manin (Geomatys)
*/
public enum Friability implements CodeValue {
FIR(1, "Ne s'effrite pas"),
SEC(2, "Sous forte pression"),
THI(3, "S'effrite facilement"),
FOU(4, "Très légère pression");
private final int code;
private final String title;
private Friability(int code, String title) {
this.code = code;
this.title = title;
}
@Override
public Integer getCode() {
return code;
}
@Override
public String getValue() {
return title;
}
@Override
public String toString() {
return new StringBuilder().append(code).append(" ").append(title).toString();
}
}
@@ -0,0 +1,75 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p01.list;
import fr.cenra.rhomeo.core.list.CodeValue;
/**
*
* @author Alexis Manin (Geomatys)
*/
public enum Humidity implements CodeValue {
DRY(1, "Sec"),
DRE(2, "Frais"),
HUM(3, "Humide"),
SAT(4, "Saturé");
private final int code;
private final String title;
private Humidity(int code, String title) {
this.code = code;
this.title = title;
}
@Override
public Integer getCode() {
return code;
}
@Override
public String getValue() {
return title;
}
@Override
public String toString() {
return new StringBuilder().append(code).append(" ").append(title).toString();
}
}
@@ -0,0 +1,75 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p01.list;
import fr.cenra.rhomeo.core.list.CodeValue;
/**
*
* @author Alexis Manin (Geomatys)
*/
public enum Limits implements CodeValue {
REGULAR(1, "Régulière"),
OND(2, "Ondulée"),
IRREG(3, "Irrégulière"),
INT(4, "Interrompue");
private final int code;
private final String title;
private Limits(int code, String title) {
this.code = code;
this.title = title;
}
@Override
public Integer getCode() {
return code;
}
@Override
public String getValue() {
return title;
}
@Override
public String toString() {
return new StringBuilder().append(code).append(" ").append(title).toString();
}
}
@@ -0,0 +1,75 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p01.list;
import fr.cenra.rhomeo.core.list.CodeValue;
/**
*
* @author Alexis Manin (Geomatys)
*/
public enum Plasticity implements CodeValue {
FIR(1, "Impossible de le former"),
SEC(2, "Se brise sous son poids"),
THI(3, "Sous faible déformation"),
FOU(4, "Ne rompt pas");
private final int code;
private final String title;
private Plasticity(int code, String title) {
this.code = code;
this.title = title;
}
@Override
public Integer getCode() {
return code;
}
@Override
public String getValue() {
return title;
}
@Override
public String toString() {
return new StringBuilder().append(code).append(" ").append(title).toString();
}
}
@@ -0,0 +1,75 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p01.list;
import fr.cenra.rhomeo.core.list.CodeValue;
/**
*
* @author Alexis Manin (Geomatys)
*/
public enum RawElements implements CodeValue {
NOT(1, "Sans"),
GRA(2, "Graviers < 2cm"),
CAI(3, "Cailloux 2 à 6cm"),
PEB(4, "Pierres et blocs > 6cm");
private final int code;
private final String title;
private RawElements(int code, String title) {
this.code = code;
this.title = title;
}
@Override
public Integer getCode() {
return code;
}
@Override
public String getValue() {
return title;
}
@Override
public String toString() {
return new StringBuilder().append(code).append(" ").append(title).toString();
}
}
@@ -0,0 +1,75 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p01.list;
import fr.cenra.rhomeo.core.list.CodeValue;
/**
*
* @author Alexis Manin (Geomatys)
*/
public enum Roots implements CodeValue {
NOT(1, "Sans"),
FEW(2, "< 8 / dm2"),
MED(3, "8 à 32 / dm2"),
LOT(4, "> 32 / dm2");
private final int code;
private final String title;
private Roots(int code, String title) {
this.code = code;
this.title = title;
}
@Override
public Integer getCode() {
return code;
}
@Override
public String getValue() {
return title;
}
@Override
public String toString() {
return new StringBuilder().append(code).append(" ").append(title).toString();
}
}
@@ -0,0 +1,75 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p01.list;
import fr.cenra.rhomeo.core.list.CodeValue;
/**
*
* @author Alexis Manin (Geomatys)
*/
public enum Shape implements CodeValue {
IRR(1, "Irrégulières"),
CUR(2, "Arrondis"),
HOR(3, "Trainées horizontales"),
VER(4, "Trainées verticales");
private final int code;
private final String title;
private Shape(int code, String title) {
this.code = code;
this.title = title;
}
@Override
public Integer getCode() {
return code;
}
@Override
public String getValue() {
return title;
}
@Override
public String toString() {
return new StringBuilder().append(code).append(" ").append(title).toString();
}
}
@@ -0,0 +1,75 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p01.list;
import fr.cenra.rhomeo.core.list.CodeValue;
/**
*
* @author Alexis Manin (Geomatys)
*/
public enum Size implements CodeValue {
TWO(1, "< 2 mm"),
SIX(2, "2 à 6 mm"),
TWE(3, "6 à 20 mm"),
LOT(4, "> 20 mm");
private final int code;
private final String title;
private Size(int code, String title) {
this.code = code;
this.title = title;
}
@Override
public Integer getCode() {
return code;
}
@Override
public String getValue() {
return title;
}
@Override
public String toString() {
return new StringBuilder().append(code).append(" ").append(title).toString();
}
}
@@ -0,0 +1,74 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p01.list;
import fr.cenra.rhomeo.core.list.CodeValue;
/**
*
* @author Alexis Manin (Geomatys)
*/
public enum Stains implements CodeValue {
NOT(1, "Sans"),
OXY(2, "Oxydation"),
MED(3, "Réduction");
private final int code;
private final String title;
private Stains(int code, String title) {
this.code = code;
this.title = title;
}
@Override
public Integer getCode() {
return code;
}
@Override
public String getValue() {
return title;
}
@Override
public String toString() {
return new StringBuilder().append(code).append(" ").append(title).toString();
}
}
@@ -0,0 +1,84 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p01.list;
import fr.cenra.rhomeo.core.list.CodeValue;
/**
*
* @author Alexis Manin (Geomatys)
*/
public enum Structure implements CodeValue {
PART(1, "Particulière"),
GRUM(2, "Grumeleuse"),
GREN(3, "Grenue"),
MASS(4, "Massive"),
LAMM(5, "Lammelaire"),
PRIS(6, "Prismatique"),
COLO(7, "En colonne"),
POLY(8, "Polyédrique"),
BLOC(9, "Blocs cubiques"),
FUSE(10, "En fuseaux"),
FIBR(11, "Fibreuse"),
FEUI(12, "Feuilletée"),
LITH(13, "Lithologique");
private final int code;
private final String title;
private Structure(int code, String title) {
this.code = code;
this.title = title;
}
@Override
public Integer getCode() {
return code;
}
@Override
public String getValue() {
return title;
}
@Override
public String toString() {
return new StringBuilder().append(code).append(" ").append(title).toString();
}
}
@@ -0,0 +1,75 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p01.list;
import fr.cenra.rhomeo.core.list.CodeValue;
/**
*
* @author Alexis Manin (Geomatys)
*/
public enum Texture implements CodeValue {
ORGA(1, "Organique"),
SABL(2, "Sableuse"),
LIMO(3, "Limoneuse"),
ARGI(4, "Argileuse");
private final int code;
private final String title;
private Texture(int code, String title) {
this.code = code;
this.title = title;
}
@Override
public Integer getCode() {
return code;
}
@Override
public String getValue() {
return title;
}
@Override
public String toString() {
return new StringBuilder().append(code).append(" ").append(title).toString();
}
}
@@ -0,0 +1,187 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p02;
import fr.cenra.rhomeo.api.annotations.RefersTo;
import fr.cenra.rhomeo.api.data.Statement;
import fr.cenra.rhomeo.api.data.Warning;
import fr.cenra.rhomeo.core.data.reference.FloreBassinReference;
import fr.cenra.rhomeo.protocol.p02.list.AbundanceFlore;
import fr.cenra.rhomeo.protocol.p02.list.PhysionomyFlore;
import fr.cenra.rhomeo.protocol.p02.validation.DeterminedFloreSpecies;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import java.time.LocalDate;
import java.util.Objects;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.SimpleIntegerProperty;
import org.hibernate.validator.constraints.NotBlank;
/**
* @author Cédric Briançon (Geomatys)
*/
public class FloreStatement extends Statement {
private final StringProperty physionomyProperty = new SimpleStringProperty();
private final IntegerProperty cd_nomProperty = new SimpleIntegerProperty();
private final StringProperty abundanceProperty = new SimpleStringProperty();
public FloreStatement() {
}
public FloreStatement(String trackingPoint, LocalDate date, String remarks, String physionomy, int speciesName, String abundance) {
super(trackingPoint, date);
this.remarksProperty.set(remarks);
this.physionomyProperty.set(physionomy);
this.cd_nomProperty.set(speciesName);
this.abundanceProperty.set(abundance);
}
public StringProperty physionomyProperty() {
return physionomyProperty;
}
public void setPhysionomy(final String physionomy) {
this.physionomyProperty.set(physionomy);
}
public IntegerProperty cd_nomProperty() {
return cd_nomProperty;
}
public void setCd_nom(final int cd_nom) {
this.cd_nomProperty.set(cd_nom);
}
public StringProperty abundanceProperty() {
return abundanceProperty;
}
public void setAbundance(final String abundance) {
this.abundanceProperty.set(abundance);
}
/**
* PHYSIONOMIE
*
* (Source : CCTP)
*
* @return
*/
@NotBlank
@RefersTo(type = PhysionomyFlore.class, property = "code")
public String getPhysionomy() {
return physionomyProperty.get();
}
/**
* NOM_ESPECES
* (Source : CCTP)
*
* @return
*/
@RefersTo(type=FloreBassinReference.class, property = "cd_nom")
@DeterminedFloreSpecies(payload=Warning.class)
public int getCd_nom() {
return cd_nomProperty.get();
}
/**
* ABONDANCE.
*
* Codes :
* De + à 5
*
* (Source : Boîte à outils complète)
*
* D'après le SQL :
* CASE
* WHEN obs_especes.abondance = '+'::text THEN '0.5'::text
* WHEN obs_especes.abondance = '1'::text THEN '3'::text
* WHEN obs_especes.abondance = '2'::text THEN '15'::text
* WHEN obs_especes.abondance = '3'::text THEN '37.5'::text
* WHEN obs_especes.abondance = '4'::text THEN '67.5'::text
* WHEN obs_especes.abondance = '5'::text THEN '87.5'::text
* ELSE '0'::text
* END
*
* TODO: Il y a des valeurs "5+" dans cette table pour abondance or d'après le sql, ça rentrerait dans le cas ELSE '0', je trouve ça bizarre.
*
* @return
*/
@NotBlank
@RefersTo(type = AbundanceFlore.class, property = "code")
public String getAbundance() {
return abundanceProperty.get();
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final FloreStatement other = (FloreStatement) obj;
return
// Compare first elements which are most likely to differ.
getCd_nom() == other.getCd_nom() &&
Objects.equals(getAbundance(), other.getAbundance()) &&
Objects.equals(getPhysionomy(), other.getPhysionomy()) &&
Objects.equals(getTrackingPoint(), other.getTrackingPoint()) &&
Objects.equals(getDate(), other.getDate());
}
@Override
public int hashCode() {
Integer hash = 7;
hash = 37 * hash + Objects.hashCode(this.getDate());
hash = 37 * hash + Objects.hashCode(this.getTrackingPoint());
hash = 37 * hash + Objects.hashCode(getAbundance());
hash = 37 * hash + Objects.hashCode(getCd_nom());
return hash;
}
}
@@ -0,0 +1,107 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p02;
import fr.cenra.rhomeo.protocol.p02.index.AnnualFloreEngorgement;
import fr.cenra.rhomeo.api.data.Protocol;
import fr.cenra.rhomeo.api.process.Process;
import fr.cenra.rhomeo.api.process.ProcessContext;
import fr.cenra.rhomeo.api.process.AbstractIndicator;
import java.beans.IntrospectionException;
import java.util.HashSet;
import java.util.Set;
import fr.cenra.rhomeo.core.RhomeoRuntimeException;
import fr.cenra.rhomeo.protocol.TaxonOperator;
import fr.cenra.rhomeo.protocol.p02.additional.AdditionalProcess;
import org.apache.sis.util.ArgumentChecks;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
/**
*
* @author Samuel Andrés (Geomatys)
*/
@Component(I02.NAME)
public class I02 extends AbstractIndicator {
public static final String NAME = "I02";
public static final String REMARKS = "Indice floristique d’engorgement";
@Autowired
@Qualifier(P02.NAME)
private P02 protocol;
public I02() {
super(NAME, REMARKS);
}
@Override
public Protocol getProtocol() {
return protocol;
}
@Override
public Set<Process> createProcesses(ProcessContext ctx) {
ArgumentChecks.ensureNonNull("processContext", ctx);
final Set<Integer> availableSpecies;
try {
availableSpecies = I02I06Process.getAvailableSpecies();
} catch (IntrospectionException ex) {
throw new RhomeoRuntimeException(ex);
}
final TaxonOperator operator = TaxonOperator.getOrCreate(ctx);
final Set<Process> processes = new HashSet<>();
processes.add(new I02I06Process(ctx, this, availableSpecies, ValueType.Humidité, true, operator));
processes.add(new I02I06Process(ctx, this, availableSpecies, ValueType.Humidité, false, operator));
processes.add(new AdditionalProcess(protocol.session, this, operator, ValueType.Humidité));
return processes;
}
@Override
public String getDefaultIndex() {
return AnnualFloreEngorgement.NAME;
}
}
@@ -0,0 +1,314 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p02;
import fr.cenra.rhomeo.protocol.p02.index.AnnualFloreFertile;
import fr.cenra.rhomeo.protocol.p02.index.AnnualFloreFertilePoint;
import fr.cenra.rhomeo.protocol.p02.index.AnnualFloreEngorgement;
import fr.cenra.rhomeo.protocol.p02.index.AnnualFloreEngorgementPoint;
import fr.cenra.rhomeo.api.Version;
import fr.cenra.rhomeo.api.data.DataContext;
import fr.cenra.rhomeo.api.data.TrackingPoint;
import fr.cenra.rhomeo.api.process.Indicator;
import fr.cenra.rhomeo.api.process.Process;
import fr.cenra.rhomeo.api.process.ProcessContext;
import fr.cenra.rhomeo.api.result.Index;
import fr.cenra.rhomeo.api.result.IndexSpi;
import fr.cenra.rhomeo.core.RhomeoCore;
import fr.cenra.rhomeo.core.RhomeoRuntimeException;
import fr.cenra.rhomeo.core.Session;
import fr.cenra.rhomeo.core.data.ReferenceManager;
import fr.cenra.rhomeo.core.data.TrackingPointValue;
import fr.cenra.rhomeo.core.data.reference.FloreBassinReference;
import fr.cenra.rhomeo.core.data.reference.FloreBassinReferenceDescription;
import fr.cenra.rhomeo.protocol.TaxonOperator;
import fr.cenra.rhomeo.protocol.p02.list.AbundanceFlore;
import java.beans.IntrospectionException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import org.apache.sis.util.collection.Cache;
/**
* Processes to use for {@link I02} and {@link I06}.
*
* @author Cédric Briançon (Geomatys)
*/
class I02I06Process extends Process {
private final Indicator indicator;
private final Set<Integer> availableSpecies;
private final ValueType type;
private final boolean byYear;
private final TaxonOperator operator;
/**
* A cache to put computed tracking point indices, as they're used both for
* results by year and by tracking point.
*/
private final Cache<TrackingPoint, Double> tpIndices = new Cache(12, 0, true);
I02I06Process(final ProcessContext ctx, final Indicator indicator, final Set<Integer> availableSpecies, final ValueType type, final boolean byYear, final TaxonOperator operator){
super(ctx);
this.indicator = indicator;
this.availableSpecies = availableSpecies;
this.type = type;
this.byYear = byYear;
this.operator = operator;
}
@Override
public Indicator getIndicator() {
return indicator;
}
@Override
protected Set<? extends Index> call() throws Exception {
return byYear ? algorithmByYear() : algorithmByTrackingPoint();
}
/**
* Generates indexes filtered by year.
*
* @return indexes of results, never {@code null}
*/
private Set<? extends Index> algorithmByYear() {
updateTitle("Calcul par année");
final int totalProgress = 2;
updateProgress(0, totalProgress);
updateMessage("Tri par année");
final Set<Index> indices = new HashSet<>();
final List<TrackingPoint> tPoints = new ArrayList<>(ctx.getTrackingPoints());
final Map<Integer,List<TrackingPointValue>> valuesForTrackingPointByYear = new HashMap<>();
// Sort tracking point values by year.
for (final TrackingPoint tp : tPoints) {
final double value = getTrackingPointValue(tp);
final TrackingPointValue tpValue = new TrackingPointValue(tp, value);
if (valuesForTrackingPointByYear.containsKey(tp.getYear())) {
valuesForTrackingPointByYear.get(tp.getYear()).add(new TrackingPointValue(tp, value));
} else {
final List<TrackingPointValue> newList = new ArrayList<>();
newList.add(tpValue);
valuesForTrackingPointByYear.put(tp.getYear(), newList);
}
}
updateMessage("Génération des indices de calcul");
updateProgress(1, totalProgress);
// generates index by year, keeping only the median value if several for the same year.
final IndexSpi indexSpi = (ValueType.Humidité.equals(type)) ? Session.getInstance().getBean(AnnualFloreEngorgement.class) :
Session.getInstance().getBean(AnnualFloreFertile.class);
for (final Map.Entry<Integer,List<TrackingPointValue>> valuesForYear : valuesForTrackingPointByYear.entrySet()) {
final List<TrackingPointValue> values = valuesForYear.getValue();
if (values.isEmpty()) {
continue;
}
if (values.size() == 1) {
final TrackingPointValue tempVal = values.get(0);
indices.add(indexSpi.createIndex(tempVal.getValue(), valuesForYear.getKey()));
} else {
final List<Double> allValuesForYear = values.stream().map(TrackingPointValue::getValue).collect(Collectors.toList());
Collections.sort(allValuesForYear);
final int size = allValuesForYear.size();
final double[] vals = new double[size];
for (int i=0; i<size; i++) {
vals[i] = allValuesForYear.get(i);
}
final double quantileVal = RhomeoCore.quantile(vals, 0.5f);
indices.add(indexSpi.createIndex(Math.rint(quantileVal * 100) / 100d, valuesForYear.getKey()));
}
}
updateProgress(2, totalProgress);
return indices;
}
/**
* Generates indexes filtered by tracking points.
*
* @return indexes of results, never {@code null}
* @throws IntrospectionException
*/
private Set<? extends Index> algorithmByTrackingPoint() {
updateTitle("Calcul par points de suivi");
final Set<Index> indices = new HashSet<>();
final List<TrackingPoint> tPoints = new ArrayList<>(ctx.getTrackingPoints());
final int size = tPoints.size();
int initialStep = 0;
updateProgress(initialStep, size);
updateMessage("Tri par points de suivi");
final IndexSpi indexSpi = (ValueType.Humidité.equals(type)) ? Session.getInstance().getBean(AnnualFloreEngorgementPoint.class) :
Session.getInstance().getBean(AnnualFloreFertilePoint.class);
for (final TrackingPoint tp : tPoints) {
final double value = getTrackingPointValue(tp);
// Now round the value with only 4 decimal digits.
indices.add(indexSpi.createIndex(Math.rint(value * 100) / 100d, tp));
updateProgress(initialStep++, size);
}
return indices;
}
/**
* Retrieve previously computed index for given tracking point, or compute
* it if needed.
* @param tp Tracking point to get index value for.
* @return Index value.
*/
private double getTrackingPointValue(final TrackingPoint tp) {
try {
return tpIndices.getOrCreate(tp, () -> computeTrackingPointValue(tp));
} catch (Exception ex) {
throw new RhomeoRuntimeException(ex);
}
}
/**
* Calculate the indicator value for the given tracking point.
*
* @param tp Tracking point to consider.
* @return The value calculated for this tracking point.
*/
private double computeTrackingPointValue(final TrackingPoint tp) throws IntrospectionException, ReflectiveOperationException {
final Map<Integer, List<FloreStatement>> stmtsForSpecies = new HashMap<>();
final List<FloreStatement> stmts = ctx.getData().getSubSet(tp);
// Get available species name to ensure statements species names are valid and not empty
// group statements on species names and keep only aquatic species
stmts.stream()
.filter(stmt -> availableSpecies.contains(stmt.getCd_nom()) &&
!("AQ".equals(stmt.getPhysionomy())))
.forEach(stmt -> {
if (stmtsForSpecies.containsKey(stmt.getCd_nom())) {
stmtsForSpecies.get(stmt.getCd_nom()).add(stmt);
} else {
final List<FloreStatement> newList = new ArrayList<>();
newList.add(stmt);
stmtsForSpecies.put(stmt.getCd_nom(), newList);
}
});
// regroup species and maximum of overlap
final Map<Integer, Double> maxOverlapSpecies = new HashMap<>();
stmtsForSpecies.entrySet().forEach(entry -> {
final Optional<Double> max = entry.getValue().stream()
.map(I02I06Process::getOverlap).max(Double::compareTo);
max.ifPresent(m -> maxOverlapSpecies.put(entry.getKey(), m));
});
// calculate rs as the sum(max(overlaps))
// and nrs as sum(humidity * maxOverlap)
double nrs = 0;
double rs = 0;
for (final Map.Entry<Integer,Double> maxForSpecies : maxOverlapSpecies.entrySet()) {
if (maxForSpecies.getValue() > 0) {
final Integer humidOrNutriVal = getHumidityOrNutrimentForSpecies(maxForSpecies.getKey());
if (humidOrNutriVal != null) {
rs += maxForSpecies.getValue();
nrs += humidOrNutriVal * maxForSpecies.getValue();
}
}
}
return nrs/rs;
}
/**
* Get the overlap value for the given statement.
*
* @param stmt
* @return
*/
static double getOverlap(final FloreStatement stmt) {
final Optional<AbundanceFlore> opt = RhomeoCore.getByCode(AbundanceFlore.class, stmt.getAbundance());
if (opt.isPresent())
return opt.get().getDoubleValue();
return 0;
}
/**
*
* @param speciesName
* @param type Indicator type
* @return The humidity value for this species for I02, or the nutriment value for I06, may be null if not found.
* @throws IntrospectionException
*/
private Integer getHumidityOrNutrimentForSpecies(final Integer speciesName) throws IntrospectionException, ReflectiveOperationException {
final FloreBassinReference ref = operator.getFloreReference(speciesName);
if (ref != null)
return type.extractor.apply(ref);
return null;
}
static List<FloreBassinReference> getFloreBassinValues() throws IntrospectionException {
final ReferenceManager<FloreBassinReference> referenceManager = ReferenceManager.getOrCreate(new FloreBassinReferenceDescription());
final DataContext dc = Session.getInstance().getDataContext();
final Version versionSel = dc.getReferences().get(FloreBassinReference.class);
return referenceManager.getValues(versionSel != null ? versionSel : referenceManager.getInstalledVersions().iterator().next());
}
/**
* Find all available species from the references list.
*
* @return
* @throws IntrospectionException
*/
static Set<Integer> getAvailableSpecies() throws IntrospectionException {
final List<FloreBassinReference> references = getFloreBassinValues();
return references.stream().map(FloreBassinReference::getCd_nom).collect(Collectors.toSet());
}
}
@@ -0,0 +1,107 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p02;
import fr.cenra.rhomeo.protocol.p02.index.AnnualFloreFertile;
import fr.cenra.rhomeo.api.data.Protocol;
import fr.cenra.rhomeo.api.process.Process;
import fr.cenra.rhomeo.api.process.ProcessContext;
import fr.cenra.rhomeo.api.process.AbstractIndicator;
import java.beans.IntrospectionException;
import java.util.HashSet;
import java.util.Set;
import fr.cenra.rhomeo.core.RhomeoRuntimeException;
import fr.cenra.rhomeo.protocol.TaxonOperator;
import fr.cenra.rhomeo.protocol.p02.additional.AdditionalProcess;
import org.apache.sis.util.ArgumentChecks;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
/**
*
* @author Samuel Andrés (Geomatys)
*/
@Component(I06.NAME)
public class I06 extends AbstractIndicator {
public static final String NAME = "I06";
public static final String REMARKS = "Indice floristique de fertilité du sol";
@Autowired
@Qualifier(P02.NAME)
private P02 protocol;
public I06() {
super(NAME, REMARKS);
}
@Override
public Protocol getProtocol() {
return protocol;
}
@Override
public Set<Process> createProcesses(ProcessContext ctx) {
ArgumentChecks.ensureNonNull("processContext", ctx);
final Set<Integer> availableSpecies;
try {
availableSpecies = I02I06Process.getAvailableSpecies();
} catch (IntrospectionException ex) {
throw new RhomeoRuntimeException(ex);
}
final TaxonOperator operator = TaxonOperator.getOrCreate(ctx);
final Set<Process> processes = new HashSet<>();
processes.add(new I02I06Process(ctx, this, availableSpecies, ValueType.Nutriment, true, operator));
processes.add(new I02I06Process(ctx, this, availableSpecies, ValueType.Nutriment, false, operator));
processes.add(new AdditionalProcess(protocol.session, this, operator, ValueType.Nutriment));
return processes;
}
@Override
public String getDefaultIndex() {
return AnnualFloreFertile.NAME;
}
}
@@ -0,0 +1,287 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p02;
import fr.cenra.rhomeo.protocol.p02.index.AnnualFloreQuality;
import fr.cenra.rhomeo.protocol.p02.index.AnnualFloreQualityPoint;
import fr.cenra.rhomeo.api.data.Protocol;
import fr.cenra.rhomeo.api.data.TrackingPoint;
import fr.cenra.rhomeo.api.process.Indicator;
import fr.cenra.rhomeo.api.process.Process;
import fr.cenra.rhomeo.api.process.ProcessContext;
import fr.cenra.rhomeo.api.process.AbstractIndicator;
import java.beans.IntrospectionException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import fr.cenra.rhomeo.api.result.Index;
import fr.cenra.rhomeo.api.result.IndexSpi;
import fr.cenra.rhomeo.core.RhomeoCore;
import fr.cenra.rhomeo.core.RhomeoRuntimeException;
import fr.cenra.rhomeo.core.Session;
import fr.cenra.rhomeo.core.data.TrackingPointValue;
import fr.cenra.rhomeo.core.data.reference.FloreBassinReference;
import fr.cenra.rhomeo.protocol.TaxonOperator;
import fr.cenra.rhomeo.protocol.p02.additional.AdditionalProcess;
import org.apache.sis.util.ArgumentChecks;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
/**
*
* @author Samuel Andrés (Geomatys)
*/
@Component(I08.NAME)
public class I08 extends AbstractIndicator {
public static final String NAME = "I08";
public static final String REMARKS = "Indice de qualité floristique";
@Autowired
@Qualifier(P02.NAME)
private P02 protocol;
public I08() {
super(NAME, REMARKS);
}
@Override
public Protocol getProtocol() {
return protocol;
}
@Override
public Set<Process> createProcesses(ProcessContext ctx) {
ArgumentChecks.ensureNonNull("processContext", ctx);
final Set<Integer> availableSpecies;
try {
availableSpecies = I02I06Process.getAvailableSpecies();
} catch (IntrospectionException ex) {
throw new RhomeoRuntimeException(ex);
}
final TaxonOperator operator = TaxonOperator.getOrCreate(ctx);
final Set<Process> processes = new HashSet<>();
processes.add(new I08Process(ctx, this, availableSpecies, true, operator));
processes.add(new I08Process(ctx, this, availableSpecies, false, operator));
processes.add(new AdditionalProcess(protocol.session, this, operator, ValueType.Conservatisme));
return processes;
}
@Override
public String getDefaultIndex() {
return AnnualFloreQuality.NAME;
}
private class I08Process extends Process {
private final Indicator indicator;
private final boolean byYear;
private final Set<Integer> availableSpecies;
private final TaxonOperator operator;
I08Process(final ProcessContext ctx, final Indicator indicator, final Set<Integer> availableSpecies, final boolean byYear, final TaxonOperator operator) {
super(ctx);
this.indicator = indicator;
this.availableSpecies = availableSpecies;
this.byYear = byYear;
this.operator = operator;
}
@Override
public Indicator getIndicator() {
return indicator;
}
@Override
protected Set<? extends Index> call() throws Exception {
return byYear ? algorithmByYear() : algorithmByTrackingPoint();
}
/**
* Generates indexes filtered by year.
*
* @return indexes of results, never {@code null}
*/
private Set<? extends Index> algorithmByYear() throws IntrospectionException, ReflectiveOperationException {
updateTitle("Calcul par année");
final int totalProgress = 2;
updateProgress(0, totalProgress);
updateMessage("Tri par année");
final Set<Index> indices = new HashSet<>();
final List<TrackingPoint> tPoints = new ArrayList<>(ctx.getTrackingPoints());
final Map<Integer,List<TrackingPointValue>> valuesForTrackingPointByYear = new HashMap<>();
// Sort tracking point values by year.
for (final TrackingPoint tp : tPoints) {
final double value = getTrackingPointValues(tp);
final TrackingPointValue tpValue = new TrackingPointValue(tp, value);
if (valuesForTrackingPointByYear.containsKey(tp.getYear())) {
valuesForTrackingPointByYear.get(tp.getYear()).add(new TrackingPointValue(tp, value));
} else {
final List<TrackingPointValue> newList = new ArrayList<>();
newList.add(tpValue);
valuesForTrackingPointByYear.put(tp.getYear(), newList);
}
}
updateMessage("Génération des indices de calcul");
updateProgress(1, totalProgress);
// generates index by year, keeping only the median value if several for the same year.
final IndexSpi indexSpi = Session.getInstance().getBean(AnnualFloreQuality.class);
for (final Map.Entry<Integer,List<TrackingPointValue>> valuesForYear : valuesForTrackingPointByYear.entrySet()) {
final List<TrackingPointValue> values = valuesForYear.getValue();
if (values.isEmpty()) {
continue;
}
if (values.size() == 1) {
final TrackingPointValue tempVal = values.get(0);
indices.add(indexSpi.createIndex(tempVal.getValue(), valuesForYear.getKey()));
} else {
final List<Double> allValuesForYear = values.stream().map(TrackingPointValue::getValue).collect(Collectors.toList());
Collections.sort(allValuesForYear);
final int size = allValuesForYear.size();
final double[] vals = new double[size];
for (int i=0; i<size; i++) {
vals[i] = allValuesForYear.get(i);
}
final double quantileVal = RhomeoCore.quantile(vals, 0.5f);
indices.add(indexSpi.createIndex(Math.rint(quantileVal * 100d) / 100d, valuesForYear.getKey()));
}
}
updateProgress(2, totalProgress);
return indices;
}
/**
* Generates indexes filtered by tracking points.
*
* @return indexes of results, never {@code null}
* @throws IntrospectionException
*/
private Set<? extends Index> algorithmByTrackingPoint() throws IntrospectionException, ReflectiveOperationException {
updateTitle("Calcul par points de suivi");
final Set<Index> indices = new HashSet<>();
final List<TrackingPoint> tPoints = new ArrayList<>(ctx.getTrackingPoints());
final int size = tPoints.size();
int initialStep = 0;
updateProgress(initialStep, size);
updateMessage("Tri par points de suivi");
final IndexSpi indexSpi = Session.getInstance().getBean(AnnualFloreQualityPoint.class);
for (final TrackingPoint tp : tPoints) {
final double value = getTrackingPointValues(tp);
indices.add(indexSpi.createIndex(Math.rint(value * 100d) / 100d, tp));
updateProgress(initialStep++, size);
}
return indices;
}
private double getTrackingPointValues(final TrackingPoint tp) throws IntrospectionException, ReflectiveOperationException {
final List<FloreStatement> stmts = ctx.getData().getSubSet(tp);
final Map<Integer,List<FloreStatement>> stmtsForSpecies = new HashMap<>();
// Get available species name to ensure statements species names are valid and not empty
// group statements on species names and keep only aquatic species
stmts.stream()
.filter(stmt -> availableSpecies.contains(stmt.getCd_nom()))
.forEach(stmt -> {
if (stmtsForSpecies.containsKey(stmt.getCd_nom())) {
stmtsForSpecies.get(stmt.getCd_nom()).add(stmt);
} else {
final List<FloreStatement> newList = new ArrayList<>();
newList.add(stmt);
stmtsForSpecies.put(stmt.getCd_nom(), newList);
}
});
// regroup species and maximum of overlap
final Map<Integer, Double> maxOverlapSpecies = new HashMap<>();
stmtsForSpecies.entrySet().forEach(entry -> {
final Optional<Double> max = entry.getValue().stream()
.map(I02I06Process::getOverlap).max(Double::compareTo);
max.ifPresent(m -> maxOverlapSpecies.put(entry.getKey(), m));
});
final double sqrtNbObs = Math.sqrt(maxOverlapSpecies.size());
// calculate rs as the sum(max(overlaps))
double rs = 0;
double qfrs = 0;
for (final Map.Entry<Integer,Double> maxForSpecies : maxOverlapSpecies.entrySet()) {
if (maxForSpecies.getValue() > 0) {
final Integer cc = getCcForSpecies(maxForSpecies.getKey());
if (cc != null) {
rs += maxForSpecies.getValue();
qfrs += cc * maxForSpecies.getValue();
}
}
}
return qfrs / rs * sqrtNbObs;
}
private Integer getCcForSpecies(final Integer speciesName) throws IntrospectionException, ReflectiveOperationException {
final FloreBassinReference ref = operator.getFloreReference(speciesName);
if (ref != null)
return ref.getCc();
return null;
}
}
}
@@ -0,0 +1,69 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p02;
import fr.cenra.rhomeo.api.data.AbstractProtocol;
import fr.cenra.rhomeo.api.data.Warning;
import fr.cenra.rhomeo.core.Session;
import fr.cenra.rhomeo.core.data.reference.FloreBassinReference;
import fr.cenra.rhomeo.core.data.reference.FloreBassinReferenceDescription;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import fr.cenra.rhomeo.protocol.validation.IndicatorTaxon;
/**
* Flore protocol.
*
* @author Samuel Andrés (Geomatys)
*/
@Component(P02.NAME)
@IndicatorTaxon(type = FloreBassinReference.class, payload = Warning.class)
public class P02 extends AbstractProtocol {
public static final String NAME = "P02";
public static final String REMARKS = "Flore";
@Autowired
protected Session session;
@Autowired
public P02(final FloreBassinReferenceDescription ref){
super(NAME, REMARKS, FloreStatement.class, ref);
}
}
@@ -0,0 +1,140 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p02;
import fr.cenra.rhomeo.api.data.ObjectWrapper;
import fr.cenra.rhomeo.core.RhomeoCore;
import fr.cenra.rhomeo.core.data.ReferenceManager;
import fr.cenra.rhomeo.core.data.reference.FloreBassinReference;
import fr.cenra.rhomeo.core.data.reference.FloreBassinReferenceDescription;
import java.time.LocalDate;
import java.util.List;
import java.util.Optional;
import java.util.logging.Level;
import org.apache.sis.util.collection.Cache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
*
* @author Alexis Manin (Geomatys)
*/
@Component
public class P02Wrapper implements ObjectWrapper<FloreStatement, P02Wrapper.CustomFloreStatement> {
private final Cache<Integer, String> cache = new Cache<>(100, 0, true);
@Autowired
FloreBassinReferenceDescription refDesciption;
@Override
public Class<FloreStatement> getInputType() {
return FloreStatement.class;
}
@Override
public Class<P02Wrapper.CustomFloreStatement> getOutputType() {
return P02Wrapper.CustomFloreStatement.class;
}
@Override
public CustomFloreStatement apply(FloreStatement t) {
return new CustomFloreStatement(t);
}
private String getName(final int cdNom) {
try {
return cache.getOrCreate(cdNom, () -> {
Optional<List<FloreBassinReference>> lastLoaded = ReferenceManager.getOrCreate(refDesciption).getLastLoaded();
if (lastLoaded.isPresent()) {
final List<FloreBassinReference> refs = lastLoaded.get();
for (final FloreBassinReference ref : refs) {
if (ref.getCd_nom() == cdNom)
return ref.getNom();
}
}
return null;
});
} catch (Exception ex) {
RhomeoCore.LOGGER.log(Level.FINE, "Cannot compute name", ex);
return null;
}
}
public class CustomFloreStatement {
final FloreStatement wrapped;
private CustomFloreStatement(final FloreStatement input) {
wrapped = input;
}
public LocalDate getDate() {
return wrapped.getDate();
}
public String getTrackingPoint() {
return wrapped.getTrackingPoint();
}
public String getRemarks() {
return wrapped.getRemarks();
}
public String getPhysionomy() {
return wrapped.getPhysionomy();
}
public int getCd_nom() {
return wrapped.getCd_nom();
}
public String getAbundance() {
return wrapped.getAbundance();
}
public String getNom_complet() {
if (wrapped.getCd_nom() > 0) {
return getName(wrapped.getCd_nom());
}
return null;
}
}
}
@@ -0,0 +1,58 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p02;
import fr.cenra.rhomeo.core.data.reference.FloreBassinReference;
import java.util.function.Function;
/**
* Describe indicator values found in {@link FloreBassinReference} referential.
* Also contains extractors for each value.
* @author Alexis Manin (Geomatys)
*/
public enum ValueType {
Conservatisme(input -> input.getCc()),
Humidité(input -> input.getHumidite()),
Nutriment(input -> input.getNutriment());
public final Function<FloreBassinReference, Integer> extractor;
private ValueType(final Function<FloreBassinReference, Integer> extractor) {
this.extractor = extractor;
}
}
@@ -0,0 +1,165 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p02.additional;
import fr.cenra.rhomeo.protocol.p02.ValueType;
import fr.cenra.rhomeo.api.process.Indicator;
import fr.cenra.rhomeo.api.process.Process;
import fr.cenra.rhomeo.api.result.Index;
import fr.cenra.rhomeo.core.Session;
import fr.cenra.rhomeo.core.data.reference.FloreBassinReference;
import fr.cenra.rhomeo.protocol.TaxonOperator;
import fr.cenra.rhomeo.protocol.p02.FloreStatement;
import java.beans.IntrospectionException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Function;
/**
*
* @author Alexis Manin (Geomatys)
*/
public class AdditionalProcess extends Process {
private static final Function<Integer, Set<Integer>> SET_VALUE_COMPUTER = key -> new HashSet<>();
final Session session;
final Indicator indic;
final TaxonOperator<FloreStatement> operator;
final ValueType type;
public AdditionalProcess(final Session session, final Indicator indic, final TaxonOperator operator, final ValueType valueType) {
super(operator.getProcessContext());
this.session = session;
this.indic = indic;
this.operator = operator;
this.type = valueType;
}
@Override
public Indicator getIndicator() {
return indic;
}
@Override
protected Set<? extends Index> call() throws Exception {
updateTitle("Calcul du nombre d'observations par valeur indicatrice");
final int total = 3;
int progress = 0;
updateMessage("Tri des données");
updateProgress(progress++, total);
final List<FloreStatement> data = operator.getProcessData();
if (data == null || data.isEmpty())
return Collections.EMPTY_SET;
updateMessage("Parcours des données");
updateProgress(progress++, total);
int year = data.get(0).getDate().getYear();
List<NbComputer> computers = new ArrayList<>();
NbComputer computer = new NbComputer(operator, year, type);
computers.add(computer);
for (final FloreStatement st : data) {
if (st.getDate().getYear() != year) {
year = st.getDate().getYear();
computer = new NbComputer(operator, year, type);
computers.add(computer);
}
computer.accept(st);
}
updateMessage("Compilation des résultats");
updateProgress(progress++, total);
for (final NbComputer nbc : computers) {
session.getAdditionalValues().add(nbc.getValue());
}
return Collections.EMPTY_SET;
}
/**
* Count distinct species found for each indicator value (See {@link FloreBassinReference#getHumidite() }, {@link FloreBassinReference#getNutriment() () }, {@link FloreBassinReference#getCc() ()
* }).
*/
private static class NbComputer {
final int year;
final ValueType type;
final Map<Integer, Set<Integer>> values = new HashMap<>();
final TaxonOperator operator;
public NbComputer(final TaxonOperator operator, final int year, final ValueType toCompute) {
this.operator = operator;
this.year = year;
type = toCompute;
}
/**
* Update current state by integrating given statement in counting.
*
* @param st
* @throws ReflectiveOperationException
* @throws IntrospectionException
*/
void accept(final FloreStatement st) throws ReflectiveOperationException, IntrospectionException {
final FloreBassinReference ref = operator.getFloreReference(st.getCd_nom());
if (ref == null)
return;
Integer refValue;
refValue = type.extractor.apply(ref);
if (refValue != null)
values.computeIfAbsent(refValue, SET_VALUE_COMPUTER).add(ref.getCd_ref());
}
Value getValue() {
final Value v = new Value(year, type.name());
for (final Map.Entry<Integer, Set<Integer>> entry : values.entrySet()) {
v.allValues()[entry.getKey()] = entry.getValue().size();
}
return v;
}
}
}
@@ -0,0 +1,197 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p02.additional;
import fr.cenra.rhomeo.api.result.AdditionalValue;
import java.util.Objects;
/**
* Contains a set of 11 values indexed from 0 to 10. It's identified by a name
* and a year given at built.
* Equality method considers only name and years, as they should be primary keys.
* @author Alexis Manin (Geomatys)
*/
public class Value implements AdditionalValue {
private final int[] values;
private int year;
private String name;
public Value() {
this(0, null);
}
public Value(final int year, final String name) {
this.year = year;
this.name = name;
values = new int[11];
}
public int[] allValues() {
return values;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getYear() {
return year;
}
public void setYear(int year) {
this.year = year;
}
public int get0() {
return values[0];
}
public void set0(final int value) {
values[0] = value;
}
public int get1() {
return values[1];
}
public void set1(final int value) {
values[1] = value;
}
public int get2() {
return values[2];
}
public void set2(final int value) {
values[2] = value;
}
public int get3() {
return values[3];
}
public void set3(final int value) {
values[3] = value;
}
public int get4() {
return values[4];
}
public void set4(final int value) {
values[4] = value;
}
public int get5() {
return values[5];
}
public void set5(final int value) {
values[5] = value;
}
public int get6() {
return values[6];
}
public void set6(final int value) {
values[6] = value;
}
public int get7() {
return values[7];
}
public void set7(final int value) {
values[7] = value;
}
public int get8() {
return values[8];
}
public void set8(final int value) {
values[8] = value;
}
public int get9() {
return values[9];
}
public void set9(final int value) {
values[9] = value;
}
public int get10() {
return values[10];
}
public void set10(final int value) {
values[10] = value;
}
@Override
public int hashCode() {
int hash = 5;
hash = 89 * hash + this.year;
hash = 89 * hash + Objects.hashCode(this.name);
return hash;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
final Value other = (Value) obj;
if (this.year != other.year)
return false;
if (!Objects.equals(this.name, other.name))
return false;
return true;
}
}
@@ -0,0 +1,93 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p02.additional;
import fr.cenra.rhomeo.api.result.AdditionalValue;
import fr.cenra.rhomeo.api.result.AdditionalValueMapper;
import fr.cenra.rhomeo.core.CSVDecoder;
import fr.cenra.rhomeo.core.CSVEncoder;
import java.beans.IntrospectionException;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import org.springframework.stereotype.Component;
/**
*
* @author Alexis Manin (Geomatys)
*/
@Component
public class ValueMapper implements AdditionalValueMapper {
private static final String FILE_NAME = "speciesPerIndicatorValue.csv";
@Override
public Set<AdditionalValue> readValues(Path folder) throws IOException {
final Path file = getTargetFile(folder);
if (Files.isReadable(file)) {
try {
return new HashSet<>(new CSVDecoder(file, Value.class, StandardCharsets.UTF_8).decode());
} catch (IntrospectionException | ReflectiveOperationException ex) {
throw new IOException(ex);
}
}
return Collections.EMPTY_SET;
}
@Override
public boolean writeValues(Path folder, Set<AdditionalValue> toWrite) throws IOException {
if (toWrite == null || toWrite.isEmpty() || !(toWrite.iterator().next() instanceof Value))
return false;
try {
new CSVEncoder(folder.resolve(FILE_NAME), Value.class, StandardCharsets.UTF_8).encode(toWrite, true);
} catch (IntrospectionException ex) {
throw new IOException(ex);
}
return true;
}
private Path getTargetFile(final Path folder) {
return folder.resolve(FILE_NAME);
}
}
@@ -0,0 +1,107 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p02.additional;
import fr.cenra.rhomeo.api.data.Protocol;
import fr.cenra.rhomeo.api.result.AdditionalValue;
import fr.cenra.rhomeo.api.ui.AdditionalResultSpi;
import fr.cenra.rhomeo.protocol.p02.P02;
import fr.cenra.rhomeo.protocol.p02.additional.Value;
import java.util.Collection;
import java.util.Optional;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.collections.FXCollections;
import javafx.scene.Node;
import javafx.scene.control.Label;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.layout.BorderPane;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
*
* @author Alexis Manin (Geomatys)
*/
@Component
public class ValueTableSpi implements AdditionalResultSpi {
@Autowired
P02 protocol;
@Override
public Protocol getProtocol() {
return protocol;
}
@Override
public Optional<Node> getResultNode(Collection<AdditionalValue> values) {
if (values == null || values.isEmpty() || !(values.iterator().next() instanceof Value))
return Optional.empty();
final Label label = new Label("Nombre d'observations par valeur indicatrice");
label.getStyleClass().add("text-bold");
return Optional.of(new BorderPane(createTable((Collection)values), label, null, null, null));
}
private TableView<Value> createTable(final Collection<Value> items) {
final TableView<Value> table = new TableView<>();
table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
table.setEditable(false);
final TableColumn<Value, Integer> yearColumn = new TableColumn<>("Année");
yearColumn.setCellValueFactory(param -> new SimpleIntegerProperty(param.getValue().getYear()).asObject());
table.getColumns().add(yearColumn);
final TableColumn<Value, String> nameColumn = new TableColumn<>("Nom");
nameColumn.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getName()));
table.getColumns().add(nameColumn);
for (int i = 0; i < 11; i++) {
final TableColumn<Value, Integer> column = new TableColumn<>(Integer.toString(i));
final int idx = i;
column.setCellValueFactory(param -> new SimpleIntegerProperty(param.getValue().allValues()[idx]).asObject());
table.getColumns().add(column);
}
table.setItems(FXCollections.observableArrayList(items));
return table;
}
}
@@ -0,0 +1,94 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p02.index;
import fr.cenra.rhomeo.api.process.Indicator;
import fr.cenra.rhomeo.api.result.DefaultIndex;
import fr.cenra.rhomeo.api.result.Index;
import fr.cenra.rhomeo.api.result.IndexSpi;
import fr.cenra.rhomeo.protocol.p02.I02;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import javax.measure.unit.Unit;
import java.util.Collection;
import java.util.Collections;
/**
* @author Cédric Briançon (Geomatys)
*/
@Component(AnnualFloreEngorgement.NAME)
public class AnnualFloreEngorgement implements IndexSpi<Double, Integer> {
public static final String NAME = "fr.cenra.rhomeo.protocol.p02.AnnualFloreEngorgement";
@Autowired
@Qualifier(I02.NAME)
private Indicator indicator;
@Override
public Unit<?> getUnit() {
return Unit.ONE;
}
@Override
public Indicator getIndicator() {
return indicator;
}
@Override
public Index<Double> createIndex(final Double value, final Integer year) {
return new DefaultIndex<>(value, this, year);
}
@Override
public String getName() {
return NAME;
}
@Override
public Collection<String> getAlias() {
return Collections.singleton("I02");
}
@Override
public String getRemarks() {
return "Indice floristique d'engorgement";
}
}
@@ -0,0 +1,96 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p02.index;
import fr.cenra.rhomeo.api.InternationalDescription;
import fr.cenra.rhomeo.api.InternationalResource;
import fr.cenra.rhomeo.api.data.TrackingPoint;
import fr.cenra.rhomeo.api.process.Indicator;
import fr.cenra.rhomeo.api.result.IndexSpi;
import fr.cenra.rhomeo.protocol.p02.I02;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import javax.measure.unit.Unit;
import java.util.Collection;
import java.util.Collections;
/**
* @author Cédric Briançon (Geomatys)
*/
@Component(AnnualFloreEngorgementPoint.NAME)
public class AnnualFloreEngorgementPoint implements IndexSpi<Double, TrackingPoint>, InternationalResource, InternationalDescription {
public static final String NAME = "fr.cenra.rhomeo.protocol.p02.AnnualFloreEngorgementPoint";
@Autowired
@Qualifier(I02.NAME)
private Indicator indicator;
@Override
public Unit<?> getUnit() {
return Unit.ONE;
}
@Override
public Indicator getIndicator() {
return indicator;
}
@Override
public AnnualFloreEngorgementPointIndex createIndex(Double value, TrackingPoint entity) {
return new AnnualFloreEngorgementPointIndex(value, this, entity);
}
@Override
public String getName() {
return NAME;
}
@Override
public Collection<String> getAlias() {
return Collections.singleton("I02");
}
@Override
public String getRemarks() {
return "Indice floristique d'engorgement";
}
}
@@ -0,0 +1,62 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p02.index;
import fr.cenra.rhomeo.api.data.TrackingPoint;
import fr.cenra.rhomeo.api.result.AbstractParametrableIndex;
import fr.cenra.rhomeo.api.result.TrackingPointIndex;
/**
* @author Cédric Briançon (Geomatys)
*/
public class AnnualFloreEngorgementPointIndex extends AbstractParametrableIndex<Double, TrackingPoint> implements TrackingPointIndex<Double> {
public AnnualFloreEngorgementPointIndex(final Double value, final AnnualFloreEngorgementPoint indexSpi, final TrackingPoint trackingPoint) {
super(value, indexSpi, trackingPoint, TrackingPoint.class);
}
@Override
public int getYear() {
return base.getYear();
}
@Override
public TrackingPoint getPoint() {
return base;
}
}
@@ -0,0 +1,94 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p02.index;
import fr.cenra.rhomeo.api.process.Indicator;
import fr.cenra.rhomeo.api.result.DefaultIndex;
import fr.cenra.rhomeo.api.result.Index;
import fr.cenra.rhomeo.api.result.IndexSpi;
import fr.cenra.rhomeo.protocol.p02.I06;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import javax.measure.unit.Unit;
import java.util.Collection;
import java.util.Collections;
/**
* @author Cédric Briançon (Geomatys)
*/
@Component(AnnualFloreFertile.NAME)
public class AnnualFloreFertile implements IndexSpi<Double, Integer> {
public static final String NAME = "fr.cenra.rhomeo.protocol.p02.AnnualFloreFertile";
@Autowired
@Qualifier(I06.NAME)
private Indicator indicator;
@Override
public Unit<?> getUnit() {
return Unit.ONE;
}
@Override
public Indicator getIndicator() {
return indicator;
}
@Override
public Index<Double> createIndex(final Double value, final Integer year) {
return new DefaultIndex<>(value, this, year);
}
@Override
public String getName() {
return NAME;
}
@Override
public Collection<String> getAlias() {
return Collections.singleton("I06");
}
@Override
public String getRemarks() {
return "Indice floristique de fertilité du sol";
}
}
@@ -0,0 +1,95 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p02.index;
import fr.cenra.rhomeo.api.InternationalDescription;
import fr.cenra.rhomeo.api.InternationalResource;
import fr.cenra.rhomeo.api.data.TrackingPoint;
import fr.cenra.rhomeo.api.process.Indicator;
import fr.cenra.rhomeo.api.result.IndexSpi;
import fr.cenra.rhomeo.protocol.p02.I06;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import javax.measure.unit.Unit;
import java.util.Collection;
import java.util.Collections;
/**
* @author Cédric Briançon (Geomatys)
*/
@Component(AnnualFloreFertilePoint.NAME)
public class AnnualFloreFertilePoint implements IndexSpi<Double, TrackingPoint>, InternationalResource, InternationalDescription {
public static final String NAME = "fr.cenra.rhomeo.protocol.p02.AnnualFloreFertilePoint";
@Autowired
@Qualifier(I06.NAME)
private Indicator indicator;
@Override
public Unit<?> getUnit() {
return Unit.ONE;
}
@Override
public Indicator getIndicator() {
return indicator;
}
@Override
public AnnualFloreFertilePointIndex createIndex(Double value, TrackingPoint entity) {
return new AnnualFloreFertilePointIndex(value, this, entity);
}
@Override
public String getName() {
return NAME;
}
@Override
public Collection<String> getAlias() {
return Collections.singleton("I06");
}
@Override
public String getRemarks() {
return "Indice floristique de fertilité du sol";
}
}
@@ -0,0 +1,62 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p02.index;
import fr.cenra.rhomeo.api.data.TrackingPoint;
import fr.cenra.rhomeo.api.result.AbstractParametrableIndex;
import fr.cenra.rhomeo.api.result.TrackingPointIndex;
/**
* @author Cédric Briançon (Geomatys)
*/
public class AnnualFloreFertilePointIndex extends AbstractParametrableIndex<Double, TrackingPoint> implements TrackingPointIndex<Double> {
public AnnualFloreFertilePointIndex(final Double value, final AnnualFloreFertilePoint indexSpi, final TrackingPoint trackingPoint) {
super(value, indexSpi, trackingPoint, TrackingPoint.class);
}
@Override
public int getYear() {
return base.getYear();
}
@Override
public TrackingPoint getPoint() {
return base;
}
}
@@ -0,0 +1,94 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p02.index;
import fr.cenra.rhomeo.api.process.Indicator;
import fr.cenra.rhomeo.api.result.DefaultIndex;
import fr.cenra.rhomeo.api.result.Index;
import fr.cenra.rhomeo.api.result.IndexSpi;
import fr.cenra.rhomeo.protocol.p02.I08;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import javax.measure.unit.Unit;
import java.util.Collection;
import java.util.Collections;
/**
* @author Cédric Briançon (Geomatys)
*/
@Component(AnnualFloreQuality.NAME)
public class AnnualFloreQuality implements IndexSpi<Double, Integer> {
public static final String NAME = "fr.cenra.rhomeo.protocol.p02.AnnualFloreQuality";
@Autowired
@Qualifier(I08.NAME)
private Indicator indicator;
@Override
public Unit<?> getUnit() {
return Unit.ONE;
}
@Override
public Indicator getIndicator() {
return indicator;
}
@Override
public Index<Double> createIndex(final Double value, final Integer year) {
return new DefaultIndex<>(value, this, year);
}
@Override
public String getName() {
return NAME;
}
@Override
public Collection<String> getAlias() {
return Collections.singleton("I08");
}
@Override
public String getRemarks() {
return "Indice de qualité floristique";
}
}
@@ -0,0 +1,95 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p02.index;
import fr.cenra.rhomeo.api.InternationalDescription;
import fr.cenra.rhomeo.api.InternationalResource;
import fr.cenra.rhomeo.api.data.TrackingPoint;
import fr.cenra.rhomeo.api.process.Indicator;
import fr.cenra.rhomeo.api.result.IndexSpi;
import fr.cenra.rhomeo.protocol.p02.I08;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import javax.measure.unit.Unit;
import java.util.Collection;
import java.util.Collections;
/**
* @author Cédric Briançon (Geomatys)
*/
@Component(AnnualFloreQualityPoint.NAME)
public class AnnualFloreQualityPoint implements IndexSpi<Double, TrackingPoint>, InternationalResource, InternationalDescription {
public static final String NAME = "fr.cenra.rhomeo.protocol.p02.AnnualFloreQualityPoint";
@Autowired
@Qualifier(I08.NAME)
private Indicator indicator;
@Override
public Unit<?> getUnit() {
return Unit.ONE;
}
@Override
public Indicator getIndicator() {
return indicator;
}
@Override
public AnnualFloreQualityPointIndex createIndex(Double value, TrackingPoint entity) {
return new AnnualFloreQualityPointIndex(value, this, entity);
}
@Override
public String getName() {
return NAME;
}
@Override
public Collection<String> getAlias() {
return Collections.singleton("I08");
}
@Override
public String getRemarks() {
return "Indice de qualité floristique";
}
}
@@ -0,0 +1,62 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p02.index;
import fr.cenra.rhomeo.api.data.TrackingPoint;
import fr.cenra.rhomeo.api.result.AbstractParametrableIndex;
import fr.cenra.rhomeo.api.result.TrackingPointIndex;
/**
* @author Cédric Briançon (Geomatys)
*/
public class AnnualFloreQualityPointIndex extends AbstractParametrableIndex<Double, TrackingPoint> implements TrackingPointIndex<Double> {
public AnnualFloreQualityPointIndex(final Double value, final AnnualFloreQualityPoint indexSpi, final TrackingPoint trackingPoint) {
super(value, indexSpi, trackingPoint, TrackingPoint.class);
}
@Override
public int getYear() {
return base.getYear();
}
@Override
public TrackingPoint getPoint() {
return base;
}
}
@@ -0,0 +1,81 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p02.list;
import fr.cenra.rhomeo.core.list.CodeValue;
/**
*
* @author Alexis Manin (Geomatys)
*/
public enum AbundanceFlore implements CodeValue {
PLUS("+", 0.5),
ONE("1", 3),
TWO("2", 15),
THREE("3", 37.5),
FOUR("4", 67.5),
FIVE("5", 87.5);
private final String code;
private final double value;
private AbundanceFlore(String code, double value) {
this.code = code;
this.value = value;
}
@Override
public String getCode() {
return code;
}
@Override
public Double getValue() {
return value;
}
public double getDoubleValue() {
return value;
}
@Override
public String toString() {
return code;
}
}
@@ -0,0 +1,87 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p02.list;
import fr.cenra.rhomeo.core.list.CodeValue;
/**
*
* @author Alexis Manin (Geomatys)
*/
public enum PhysionomyFlore implements CodeValue {
// Herbacée aquatique et terrestre rase
AL("Alluvions"),
AQ("Végétation aquatique"),
EC("Bordure d'eaux courantes"),
EX("Grèves exondées"),
FO("Végétation fontinale"),
RB("Oenanthion aquaticae"),
// Herbacée moyenne et haute
BM("Bas-marais et marais de transition"),
HM("Haut-marais"),
GH("Grands hélophytes"),
MC("Magnocariçaie"),
PH("Prairie humide"),
MG("Mégaphorbiaie"),
CN("Combe à neige"),
// Landes ou fourrés
LA("Lande"),
FU("Fourré humide"),
//Boisements
BFH("Boisement feuillu humide"),
BCH("Boisement de conifère humide");
private final String title;
PhysionomyFlore(final String value) {
this.title = value;
}
@Override
public String getCode() {
return name();
}
@Override
public String getValue() {
return title;
}
}
@@ -0,0 +1,116 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p02.validation;
import fr.cenra.rhomeo.api.data.Statement;
import fr.cenra.rhomeo.api.process.ProcessContext;
import fr.cenra.rhomeo.core.RhomeoRuntimeException;
import fr.cenra.rhomeo.core.Session;
import fr.cenra.rhomeo.core.data.reference.FloreBassinReference;
import fr.cenra.rhomeo.protocol.TaxonOperator;
import fr.cenra.rhomeo.protocol.p02.validation.DeterminedFloreSpecies.Validator;
import java.beans.IntrospectionException;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import javax.validation.Constraint;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import javax.validation.Payload;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
/**
* A constraint annotation to check if a given {@link FloreBassinReference#getCd_nom() }
* is known as species or gender.
*
* @author Alexis Manin (Geomatys)
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@Constraint(validatedBy = Validator.class)
@Documented
public @interface DeterminedFloreSpecies {
static final String INVALID_SUFFIX = "sp.";
String message() default "L'espèce n'est pas déterminante";
Class<?>[] groups() default {};
Class<? extends Payload>[] payload() default {};
@Component
@Scope("prototype")
static class Validator implements ConstraintValidator<DeterminedFloreSpecies, Integer> {
@Autowired
Session session;
TaxonOperator<Statement> operator;
@Override
public void initialize(DeterminedFloreSpecies constraintAnnotation) {
operator = TaxonOperator.getOrCreate(new ProcessContext(session.getDataset(), session.getDataContext()));
}
@Override
public boolean isValid(Integer value, ConstraintValidatorContext context) {
final FloreBassinReference ref;
try {
if (value == null || (ref = operator.getFloreReference(value)) == null)
return true; // Not our job to check null values / unkown species.
} catch (ReflectiveOperationException | IntrospectionException ex) {
throw new RhomeoRuntimeException(ex);
}
if (ref.getNom() != null && ref.getNom().toLowerCase().endsWith(INVALID_SUFFIX)) {
context.buildConstraintViolationWithTemplate(
"Les espèces déterminées au genre ne sont pas prises en compte dans les calculs : ".concat(ref.getNom())
).addConstraintViolation().disableDefaultConstraintViolation();
return false;
}
return true;
}
}
}
@@ -0,0 +1,213 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p03;
import fr.cenra.rhomeo.api.data.Protocol;
import fr.cenra.rhomeo.api.process.Process;
import fr.cenra.rhomeo.api.process.ProcessContext;
import fr.cenra.rhomeo.api.process.AbstractIndicator;
import fr.cenra.rhomeo.api.process.Indicator;
import fr.cenra.rhomeo.api.result.Index;
import fr.cenra.rhomeo.core.RhomeoCore;
import fr.cenra.rhomeo.protocol.p03.index.FirstDecileSpi;
import fr.cenra.rhomeo.protocol.p03.index.FirstQuartileSpi;
import fr.cenra.rhomeo.protocol.p03.index.LastDecileSpi;
import fr.cenra.rhomeo.protocol.p03.index.MaxSpi;
import fr.cenra.rhomeo.protocol.p03.index.MedianeSpi;
import fr.cenra.rhomeo.protocol.p03.index.MinSpi;
import fr.cenra.rhomeo.protocol.p03.index.ThirdQuartileSpi;
import java.time.LocalDate;
import java.time.Month;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
/**
*
* @author Samuel Andrés (Geomatys)
*/
@Component(I03.NAME)
public class I03 extends AbstractIndicator {
public static final String NAME = "I03";
public static final String REMARKS = "Dynamique hydrologique - piézomètre";
@Autowired
@Qualifier(P03.NAME)
private Protocol protocol;
@Autowired
MinSpi minSpi;
@Autowired
FirstDecileSpi fdSpi;
@Autowired
FirstQuartileSpi fqSpi;
@Autowired
MedianeSpi medianeSpi;
@Autowired
ThirdQuartileSpi tqSpi;
@Autowired
LastDecileSpi tdSpi;
@Autowired
MaxSpi maxSpi;
public I03() {
super(NAME, REMARKS);
}
@Override
public Protocol getProtocol() {
return protocol;
}
@Override
public Set<Process> createProcesses(ProcessContext ctx) {
return Collections.singleton(new I03Process(ctx));
}
@Override
public String getDefaultIndex() {
return MedianeSpi.NAME;
}
/**
* Compute all annual indices for I03 indicator.
* TODO : multi-thread (One process per year) ?
*/
private final class I03Process extends Process {
public I03Process(final ProcessContext pctx) {
super(pctx);
}
@Override
public Indicator getIndicator() {
return I03.this;
}
@Override
protected Set<? extends Index> call() throws Exception {
updateTitle("Calcul piézomètre");
updateMessage("Analyse des données");
final HashSet<Index> indices = new HashSet<>();
final ArrayList<P03Statement> data = new ArrayList<>(ctx.getData().getItems());
data.sort(I03::compare);
if (data.isEmpty())
return Collections.EMPTY_SET;
LocalDate date = data.get(0).getDate();
int previousYear = date.getMonthValue() < Month.SEPTEMBER.getValue()? date.getYear() : date.getYear() + 1;
int year;
int startIndex = 0;
updateMessage("Calcul de l'année ".concat(String.valueOf(previousYear)));
for (int i = 1 ; i < data.size() ; i++) {
updateProgress(i, data.size());
date = data.get(i).getDate();
year = date.getMonthValue() < Month.SEPTEMBER.getValue()? date.getYear() : date.getYear() + 1;
if (previousYear < year) {
indices.addAll(computeYear(previousYear, data.subList(startIndex, i)));
startIndex = i;
previousYear = year;
updateMessage("Calcul de l'année ".concat(String.valueOf(previousYear)));
}
}
if (startIndex < data.size() -1) {
indices.addAll(computeYear(previousYear, data.subList(startIndex, data.size())));
}
return indices;
}
}
/**
* Compute all hygrometric indices for a year.
* /!\ Input list MUST CONTAIN ONLY THE TARGET YEAR DATA !
* @param year Year to compute.
* @param yearStatements data of the year to compute.
* @return A set of hygrometric indices.
*/
private Collection<Index> computeYear(final int year, final List<P03Statement> yearData) {
final float[] heights = new float[yearData.size()];
for (int i = 0 ; i < heights.length ; i++) {
heights[i] = yearData.get(i).getHeight();
}
Arrays.sort(heights);
final ArrayList<Index> result = new ArrayList<>(9);
result.add(minSpi.createIndex(heights[0], year));
result.add(fdSpi.createIndex(RhomeoCore.quantile(heights, 0.10f), year));
result.add(fqSpi.createIndex(RhomeoCore.quantile(heights, 0.25f), year));
result.add(medianeSpi.createIndex(RhomeoCore.quantile(heights, 0.5f), year));
result.add(tqSpi.createIndex(RhomeoCore.quantile(heights, 0.75f), year));
result.add(tdSpi.createIndex(RhomeoCore.quantile(heights, 0.90f), year));
result.add(maxSpi.createIndex(heights[heights.length - 1], year));
return result;
}
/**
* Sort statement by date.
* @param first First term in the comparison.
* @param second Second term of the comparison.
* @return comparison result.
*/
private static int compare(final P03Statement first, P03Statement second) {
if (first.getDate()== null && second.getDate() == null) {
return 0;
} else if (first.getDate() == null) {
return 1;
} else if (second.getDate() == null) {
return -1;
} else return first.getDate().compareTo(second.getDate());
}
}
@@ -0,0 +1,112 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p03;
import fr.cenra.rhomeo.api.data.AbstractProtocol;
import fr.cenra.rhomeo.api.data.Dataset;
import fr.cenra.rhomeo.api.data.Statement;
import fr.cenra.rhomeo.api.data.TrackingPoint;
import fr.cenra.rhomeo.protocol.p03.validation.DataCoverage;
import fr.cenra.rhomeo.protocol.p03.validation.SinglePoint;
import java.time.LocalDate;
import java.time.Month;
import java.time.MonthDay;
import java.time.temporal.ChronoUnit;
import java.util.HashSet;
import java.util.List;
import org.springframework.stereotype.Component;
/**
* Piezometry protocol.
*
* @author Samuel Andrés (Geomatys)
*/
@SinglePoint
@DataCoverage
@Component(P03.NAME)
public class P03 extends AbstractProtocol {
public static final String NAME = "P03";
public static final String REMARKS = "Piézométrie";
static final MonthDay YEAR_START = MonthDay.of(Month.SEPTEMBER, 1);
static final MonthDay YEAR_END = MonthDay.of(Month.AUGUST, 31);
public P03(){
super(NAME, REMARKS, P03Statement.class);
}
@Override
public TrackingPoint createTrackingPoint(String name, int year) {
return new TrackingPoint(name, year, YEAR_START.atYear(year -1), YEAR_END.atYear(year));
}
@Override
public TrackingPoint createTrackingPoint(String name, LocalDate statementDate) {
final int year;
if (statementDate.getMonthValue() < Month.SEPTEMBER.getValue()) {
year = statementDate.getYear();
} else {
year = statementDate.getYear() + 1;
}
return createTrackingPoint(name, year);
}
/**
* Compute data coverage for the given tracking point over input dataset.
* @param target
* @param dataset
* @return Percent of days in the given tracking point in which at least one
* statement can be found.
*/
public static float computeDataCoverage(final TrackingPoint target, final List<Statement> dataset) {
if (target == null || dataset == null || dataset.isEmpty()) {
return 0f;
} else {
// To get numbered of covered days in the year, we get all distinct
// dates present in the tracking point, which accept only data over one year.
final HashSet<LocalDate> dates = new HashSet<>(Math.min(dataset.size(), 365));
for (final Statement st : dataset) {
if (Dataset.belongToPoint(target, st))
dates.add(st.getDate());
}
return (float) dates.size() / target.getYearStart().until(target.getYearEnd().plusDays(1), ChronoUnit.DAYS) * 100; // Convert to %
}
}
}
@@ -0,0 +1,92 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p03;
import fr.cenra.rhomeo.api.data.Statement;
import java.util.Objects;
import javafx.beans.property.FloatProperty;
import javafx.beans.property.SimpleFloatProperty;
/**
*
* @author Alexis Manin (Geomatys)
*/
public class P03Statement extends Statement {
/**
* Measured height in cm.
*/
private final FloatProperty height = new SimpleFloatProperty();
public P03Statement() {
setTrackingPoint("AUTO");
}
public float getHeight() {
return height.get();
}
public void setHeight(final float f) {
height.set(f);
}
public FloatProperty heightProperty() {
return height;
}
/**
* As we should not have two statements on the same date, we base our equal
* method on this single parameter.
* @param obj
* @return
*/
@Override
public boolean equals(Object obj) {
if (!(obj instanceof P03Statement))
return false;
final P03Statement other = (P03Statement) obj;
return Objects.equals(this.getDate(), other.getDate());
}
@Override
public int hashCode() {
return getDate() == null? 0 : getDate().hashCode();
}
}
@@ -0,0 +1,232 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p03;
import fr.cenra.rhomeo.api.data.Dataset;
import fr.cenra.rhomeo.api.data.Statement;
import fr.cenra.rhomeo.api.data.TrackingPoint;
import fr.cenra.rhomeo.api.data.TrackingPointFilter;
import fr.cenra.rhomeo.api.ui.FilterTable;
import fr.cenra.rhomeo.core.RhomeoCore;
import fr.cenra.rhomeo.core.Session;
import java.time.LocalDate;
import java.util.HashSet;
import java.util.Iterator;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import javafx.beans.binding.Bindings;
import javafx.beans.binding.ObjectBinding;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.collections.ListChangeListener;
import javafx.collections.ObservableList;
import javafx.collections.transformation.FilteredList;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
/**
* A simple table to present hydrology data related to tracking points.
*
* @author Alexis Manin (Geomatys)
*/
class PointTable extends FilterTable<TrackingPointFilter> {
/**
* List of statements present in the session, sorted by date (from older to
* earliest).
*
* /!\ Only dated elements are present in this list !
*/
final FilteredList<Statement> items;
final Session session;
final Dataset dataset;
final ObservableList<TrackingPoint> filteredPoints;
final ObservableList<TrackingPointFilter> filters;
PointTable(final Session session) {
this.session = session;
final TableColumn<TrackingPointFilter, String> nameColumn = new TableColumn("Nom");
nameColumn.setCellValueFactory(input -> new SimpleStringProperty(input.getValue().point == null ? null : input.getValue().point.getName()));
final TableColumn<TrackingPointFilter, LocalDate> startDateColumn = new TableColumn("Date de début");
startDateColumn.setCellValueFactory(this::initStartDate);
final TableColumn<TrackingPointFilter, LocalDate> endDateColumn = new TableColumn("Date de fin");
endDateColumn.setCellValueFactory(this::initEndDate);
final TableColumn<TrackingPointFilter, Integer> yearColumn = new TableColumn("Année hydrologique");
yearColumn.setCellValueFactory(input -> (ObservableValue) new SimpleIntegerProperty(input.getValue().point == null ? null : input.getValue().point.getYear()));
final TableColumn<TrackingPointFilter, Float> nbColumn = new TableColumn("% données");
nbColumn.setCellValueFactory(this::initDataCoverage);
nbColumn.setCellFactory(RhomeoCore.ROUNDING_CELL_FACTORY);
getColumns().addAll(nameColumn, startDateColumn, endDateColumn, yearColumn, nbColumn);
setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
items = ((ObservableList<Statement>) session.getDataset().getItems())
.filtered(input -> input.getDate() != null)
.sorted((o1, o2) -> o1.getDate().compareTo(o2.getDate())).filtered(null);
dataset = new Dataset(session.getDataset().getProtocol());
dataset.getItems().setAll(items);
items.addListener(this::synchronizeDataset);
filteredPoints = dataset.getTrackingPoints();
filters = FXCollections.observableArrayList(filteredPoints.stream().map(input -> new TrackingPointFilter(input)).collect(Collectors.toList()));
filteredPoints.addListener(this::synchronizeFilters);
setItems(filters);
}
/**
* Report changes from {@link #items} into internal {@link #dataset}. It
* allows us to keep an up to date list of tracking points.
*
* @param c
*/
private void synchronizeDataset(final ListChangeListener.Change<? extends Statement> c) {
while (c.next()) {
dataset.getItems().removeAll(c.getRemoved());
dataset.getItems().addAll(c.getAddedSubList());
}
}
/**
* Report changes from {@link #items} into internal {@link #dataset}. It
* allows us to keep an up to date list of tracking points.
*
* @param c
*/
private void synchronizeFilters(final ListChangeListener.Change<? extends TrackingPoint> c) {
while (c.next()) {
final HashSet<TrackingPoint> set = new HashSet<>(c.getRemoved());
final Iterator<TrackingPointFilter> it = filters.iterator();
while (it.hasNext()) {
if (set.contains(it.next().point))
it.remove();
}
filters.addAll(c.getAddedSubList().stream().map(input -> new TrackingPointFilter(input)).collect(Collectors.toList()));
}
}
@Override
public Predicate<? super Statement> getPreFilter() {
return items.getPredicate();
}
@Override
public void setPreFilter(final Predicate<Statement> filter) {
items.setPredicate(filter);
}
@Override
public ObjectProperty<Predicate<? super Statement>> preFilterProperty() {
return items.predicateProperty();
}
/**
* Find and maintain oldest date in the list of statements associated with
* given tracking point.
*
* @param input The cell feature containing target tracking point.
* @return An observable value which represents latest date on the given
* tracking point.
*/
private ObjectBinding<LocalDate> initStartDate(final TableColumn.CellDataFeatures<TrackingPointFilter, LocalDate> input) {
return Bindings.createObjectBinding(() -> {
if (items.isEmpty() || input.getValue().point == null) {
return null;
} else
for (final Statement st : items) {
if (Dataset.belongToPoint(input.getValue().point, st))
return st.getDate();
}
return null;
}, items);
}
/**
* Find and maintain newest date in the list of statements associated with
* given tracking point.
*
* @param input The cell feature containing target tracking point.
* @return An observable value which represents earliest date on the given
* tracking point.
*/
private ObjectBinding<LocalDate> initEndDate(final TableColumn.CellDataFeatures<TrackingPointFilter, LocalDate> input) {
return Bindings.createObjectBinding(() -> {
if (items.isEmpty() || input.getValue().point == null) {
return null;
} else
for (int i = items.size() - 1; i > 0; i--) {
final Statement st = items.get(i);
if (Dataset.belongToPoint(input.getValue().point, st))
return st.getDate();
}
return null;
}, items);
}
/**
* Create an observable value which computes percentage of days with data in
* a given tracking point.
*
* @param input The target tracking point.
* @return An observable value which represents data coverage on the given
* tracking point.
*/
public ObjectBinding<Float> initDataCoverage(final TableColumn.CellDataFeatures<TrackingPointFilter, Float> input) {
return Bindings.createObjectBinding(() -> {
final TrackingPoint point;
if (input.getValue() == null || (point = input.getValue().point) == null)
return null;
else
return P03.computeDataCoverage(point, session.getDataset().getItems());
}, items);
}
}
@@ -0,0 +1,70 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p03;
import fr.cenra.rhomeo.api.data.Protocol;
import fr.cenra.rhomeo.api.ui.FilterTable;
import fr.cenra.rhomeo.core.Session;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import fr.cenra.rhomeo.api.ui.FilterTableSpi;
/**
*
* @author Alexis Manin (Geomatys)
*/
@Component
public class PointTableSpi implements FilterTableSpi {
@Autowired
P03 p;
@Autowired
Session session;
@Override
public Protocol getProtocol() {
return p;
}
@Override
public FilterTable createEmptyTable() {
return new PointTable(session);
}
}
@@ -0,0 +1,91 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p03.index;
import fr.cenra.rhomeo.api.process.Indicator;
import fr.cenra.rhomeo.api.result.DefaultIndex;
import fr.cenra.rhomeo.api.result.Index;
import fr.cenra.rhomeo.api.result.IndexSpi;
import fr.cenra.rhomeo.protocol.p03.I03;
import java.util.Collection;
import java.util.Collections;
import javax.measure.unit.SI;
import javax.measure.unit.Unit;
import org.springframework.beans.factory.annotation.Autowired;
/**
*
* @author Alexis Manin (Geomatys)
*/
public abstract class AbstractP03IndexSpi implements IndexSpi<Float, Integer> {
@Autowired
I03 indicator;
@Override
public Unit<?> getUnit() {
return SI.CENTIMETRE;
}
@Override
public Indicator getIndicator() {
return indicator;
}
@Override
public Index<Float> createIndex(Float value, Integer entity) {
return new DefaultIndex<>(value, this, entity);
}
@Override
public Collection<String> getAlias() {
return Collections.EMPTY_SET;
}
protected abstract int getPriority();
@Override
public int compareTo(IndexSpi o) {
if (o instanceof AbstractP03IndexSpi) {
return getPriority() - ((AbstractP03IndexSpi)o).getPriority();
}
return IndexSpi.super.compareTo(o);
}
}
@@ -0,0 +1,74 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p03.index;
import java.util.Collection;
import java.util.Collections;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
/**
*
* @author Alexis Manin (Geomatys)
*/
@Component
@Qualifier(FirstDecileSpi.NAME)
public class FirstDecileSpi extends AbstractP03IndexSpi {
static final String NAME = "P03 first decile index";
@Override
public String getName() {
return NAME;
}
@Override
public Collection<String> getAlias() {
return Collections.singleton("Premier décile");
}
@Override
public String getRemarks() {
return "Indice de piézométrie annuel : premier décile";
}
@Override
protected int getPriority() {
return 1;
}
}
@@ -0,0 +1,74 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p03.index;
import java.util.Collection;
import java.util.Collections;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
/**
*
* @author Alexis Manin (Geomatys)
*/
@Component
@Qualifier(FirstQuartileSpi.NAME)
public class FirstQuartileSpi extends AbstractP03IndexSpi {
static final String NAME = "P03 first quartile index";
@Override
public String getName() {
return NAME;
}
@Override
public Collection<String> getAlias() {
return Collections.singleton("Premier quartile");
}
@Override
public String getRemarks() {
return "Indice de piézométrie annuel : premier quartile";
}
@Override
protected int getPriority() {
return 2;
}
}
@@ -0,0 +1,74 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p03.index;
import java.util.Collection;
import java.util.Collections;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
/**
*
* @author Alexis Manin (Geomatys)
*/
@Component
@Qualifier(LastDecileSpi.NAME)
public class LastDecileSpi extends AbstractP03IndexSpi {
static final String NAME = "P03 last decile index";
@Override
public String getName() {
return NAME;
}
@Override
public Collection<String> getAlias() {
return Collections.singleton("Dernier décile");
}
@Override
public String getRemarks() {
return "Indice de piézométrie annuel : dernier décile";
}
@Override
protected int getPriority() {
return 5;
}
}
@@ -0,0 +1,74 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p03.index;
import java.util.Collection;
import java.util.Collections;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
/**
*
* @author Alexis Manin (Geomatys)
*/
@Component
@Qualifier(MaxSpi.NAME)
public class MaxSpi extends AbstractP03IndexSpi {
static final String NAME = "P03 max index";
@Override
public String getName() {
return NAME;
}
@Override
public Collection<String> getAlias() {
return Collections.singleton("Maximum");
}
@Override
public String getRemarks() {
return "Indice de piézométrie annuel : maximum";
}
@Override
protected int getPriority() {
return 6;
}
}
@@ -0,0 +1,74 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p03.index;
import java.util.Collection;
import java.util.Collections;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
/**
*
* @author Alexis Manin (Geomatys)
*/
@Component
@Qualifier(MedianeSpi.NAME)
public class MedianeSpi extends AbstractP03IndexSpi {
public static final String NAME = "P03 mediane index";
@Override
public String getName() {
return NAME;
}
@Override
public Collection<String> getAlias() {
return Collections.singleton("I03");
}
@Override
public String getRemarks() {
return "Indice de piézométrie annuel : médiane";
}
@Override
protected int getPriority() {
return 3;
}
}
@@ -0,0 +1,74 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p03.index;
import java.util.Collection;
import java.util.Collections;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
/**
*
* @author Alexis Manin (Geomatys)
*/
@Component
@Qualifier(MinSpi.NAME)
public class MinSpi extends AbstractP03IndexSpi {
static final String NAME = "P03 min index";
@Override
public String getName() {
return NAME;
}
@Override
public Collection<String> getAlias() {
return Collections.singleton("Minimum");
}
@Override
public String getRemarks() {
return "Indice de piézométrie annuel : médiane";
}
@Override
protected int getPriority() {
return 0;
}
}
@@ -0,0 +1,74 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p03.index;
import java.util.Collection;
import java.util.Collections;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
/**
*
* @author Alexis Manin (Geomatys)
*/
@Component
@Qualifier(ThirdQuartileSpi.NAME)
public class ThirdQuartileSpi extends AbstractP03IndexSpi {
static final String NAME = "P03 third quartile index";
@Override
public String getName() {
return NAME;
}
@Override
public Collection<String> getAlias() {
return Collections.singleton("Troisième quartile");
}
@Override
public String getRemarks() {
return "Indice de piézométrie annuel : troisième quartile";
}
@Override
protected int getPriority() {
return 4;
}
}
@@ -0,0 +1,78 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p03.validation;
import fr.cenra.rhomeo.api.data.Dataset;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import javax.validation.Constraint;
import javax.validation.Payload;
/**
* Specifies that into current {@link Dataset}, the tracking points should
* contain statements covering at a least a given percentage of its validity
* period.
*
* Ex : if a tracking point is valid 365 days (from january the 1st to december
* the 31st of 2016), and it have statements covering half of this days, the
* data coverage is 50%.
*
* @author Alexis Manin (Geomatys)
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Constraint(validatedBy = DataCoverageValidator.class)
@Documented
public @interface DataCoverage {
String message() default "La couverture de données sur l'année est insufisante.";
Class<?>[] groups() default {};
Class<? extends Payload>[] payload() default {};
/**
*
* @return The minimum data coverage needed on the protocol (default to 90 %).
*/
float min() default 90;
}
@@ -0,0 +1,98 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p03.validation;
import fr.cenra.rhomeo.api.data.Dataset;
import fr.cenra.rhomeo.api.data.Protocol;
import fr.cenra.rhomeo.api.data.TrackingPoint;
import fr.cenra.rhomeo.core.Session;
import fr.cenra.rhomeo.protocol.p03.P03;
import fr.cenra.rhomeo.protocol.p03.PointTableSpi;
import java.util.List;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
/**
* Check that current session {@link Dataset} contains only one {@link TrackingPoint}
* each year. More over, the tracking points MUST have the same name each year.
*
* @author Alexis Manin (Geomatys)
*/
@Component
@Scope("prototype")
public class DataCoverageValidator implements ConstraintValidator<DataCoverage, Protocol> {
@Autowired
Session session;
@Autowired
PointTableSpi tableSpi;
float min = Float.NaN;
@Override
public void initialize(DataCoverage constraintAnnotation) {
min = constraintAnnotation.min();
}
@Override
public boolean isValid(Protocol value, ConstraintValidatorContext context) {
final Dataset dataset = session.getDataset();
boolean result = true;
for (final TrackingPoint tp : ((List<TrackingPoint>)dataset.getTrackingPoints())) {
if (P03.computeDataCoverage(tp, dataset.getItems()) < min) {
context.disableDefaultConstraintViolation();
context.buildConstraintViolationWithTemplate(
new StringBuilder("Le quota de données est insuffisant pour l'année ")
.append(tp.getYear())
.append(". Minimum attendu : ")
.append(min)
.toString()
).addConstraintViolation();
result = false;
}
}
return result;
}
}
@@ -0,0 +1,64 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p03.validation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import javax.validation.Constraint;
import javax.validation.Payload;
/**
*
* @author Alexis Manin (Geomatys)
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Constraint(validatedBy = SinglePointValidator.class)
@Documented
public @interface SinglePoint {
String message() default "Un et un seul point de suivi doit être présent dans le lot de données.";
Class<?>[] groups() default {};
Class<? extends Payload>[] payload() default {};
}
@@ -0,0 +1,86 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p03.validation;
import fr.cenra.rhomeo.api.data.Dataset;
import fr.cenra.rhomeo.api.data.Protocol;
import fr.cenra.rhomeo.api.data.TrackingPoint;
import fr.cenra.rhomeo.core.Session;
import java.util.Iterator;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
/**
* Check that current session {@link Dataset} contains only one {@link TrackingPoint}
* each year. More over, the tracking points MUST have the same name each year.
*
* @author Alexis Manin (Geomatys)
*/
@Component
@Scope("prototype")
public class SinglePointValidator implements ConstraintValidator<SinglePoint, Protocol> {
@Autowired
Session session;
@Override
public void initialize(SinglePoint constraintAnnotation) {}
@Override
public boolean isValid(Protocol value, ConstraintValidatorContext context) {
final Iterator<TrackingPoint> it;
if (session.getDataset() == null || !(it = session.getDataset().getTrackingPoints().iterator()).hasNext()) {
context.disableDefaultConstraintViolation();
context.buildConstraintViolationWithTemplate("Aucun point de suivi présent dans le lot de données.").addConstraintViolation();
return false;
}
final String pointName = it.next().getName();
while (it.hasNext()) {
if (!pointName.equals(it.next().getName()))
return false;
}
return true;
}
}
@@ -0,0 +1,78 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p04;
import fr.cenra.rhomeo.api.result.DefaultIndex;
import fr.cenra.rhomeo.api.result.Index;
import fr.cenra.rhomeo.api.result.IndexSpi;
import java.util.Collection;
import java.util.Collections;
import javax.measure.unit.Unit;
/**
*
* @author Alexis Manin (Geomatys)
*/
public abstract class AbstractHabitatNbSpi implements IndexSpi<Integer, Integer> {
@Override
public Unit<?> getUnit() {
return Unit.ONE;
}
@Override
public Index<Integer> createIndex(Integer value, Integer year) {
return new DefaultIndex<>(value, this, year);
}
@Override
public String getName() {
return "I04";
}
@Override
public Collection<String> getAlias() {
return Collections.singleton("I04 - habitats");
}
@Override
public String getRemarks() {
return "Nombre d'habitats renseignés pour l'année en cours.";
}
}
@@ -0,0 +1,102 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p04;
import fr.cenra.rhomeo.api.data.TrackingPoint;
import fr.cenra.rhomeo.api.process.Indicator;
import fr.cenra.rhomeo.api.result.DefaultTrackingPointIndex;
import fr.cenra.rhomeo.api.result.Index;
import fr.cenra.rhomeo.api.result.IndexSpi;
import java.util.Collection;
import java.util.Collections;
import javax.measure.unit.Unit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
*
* @author Alexis Manin (Geomatys)
*/
@Component
public class AcidIndexSpi implements IndexSpi<Double, TrackingPoint> {
@Autowired
private I04 i04;
@Override
public Unit<?> getUnit() {
return Unit.ONE;
}
@Override
public Indicator getIndicator() {
return i04;
}
@Override
public Index<Double> createIndex(Double value, TrackingPoint entity) {
return new DefaultTrackingPointIndex<>(value, entity, this);
}
/**
* Create an index from data data hold by given statement. The tracking
* point name will be the {@link P04Statement#getHabitat() }.
*
* @param input The statement holding index value.
* @return a new index matching input data.
*/
public Index<Double> createIndex(final P04Statement input) {
return createIndex(input.getAcids(), new TrackingPoint(input.getHabitat(), input.getYear()));
}
@Override
public String getName() {
return "AH/AF";
}
@Override
public Collection<String> getAlias() {
return Collections.singleton("I04 - AH/AF");
}
@Override
public String getRemarks() {
return "Ratio acides humiques sur acides fulviques";
}
}
@@ -0,0 +1,102 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p04;
import fr.cenra.rhomeo.api.data.TrackingPoint;
import fr.cenra.rhomeo.api.process.Indicator;
import fr.cenra.rhomeo.api.result.DefaultTrackingPointIndex;
import fr.cenra.rhomeo.api.result.Index;
import fr.cenra.rhomeo.api.result.IndexSpi;
import java.util.Collection;
import java.util.Collections;
import javax.measure.unit.Unit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
*
* @author Alexis Manin (Geomatys)
*/
@Component
public class CotIndexSpi implements IndexSpi<Double, TrackingPoint> {
@Autowired
private I07 i07;
@Override
public Unit<?> getUnit() {
return Unit.ONE;
}
@Override
public Indicator getIndicator() {
return i07;
}
@Override
public Index<Double> createIndex(Double value, TrackingPoint entity) {
return new DefaultTrackingPointIndex<>(value, entity, this);
}
/**
* Create an index from data data hold by given statement. The tracking
* point name will be the {@link P04Statement#getHabitat() }.
*
* @param input The statement holding index value.
* @return a new index matching input data.
*/
public Index<Double> createIndex(final P04Statement input) {
return createIndex(input.getCot(), new TrackingPoint(input.getHabitat(), input.getYear()));
}
@Override
public String getName() {
return "COT";
}
@Override
public Collection<String> getAlias() {
return Collections.singleton("I07 - COT");
}
@Override
public String getRemarks() {
return "Quantité de carbone organique total (COT en g/kg de sol sec)";
}
}
@@ -0,0 +1,103 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p04;
import fr.cenra.rhomeo.api.data.TrackingPoint;
import fr.cenra.rhomeo.api.process.Indicator;
import fr.cenra.rhomeo.api.result.DefaultTrackingPointIndex;
import fr.cenra.rhomeo.api.result.Index;
import fr.cenra.rhomeo.api.result.IndexSpi;
import java.util.Collection;
import java.util.Collections;
import javax.measure.unit.NonSI;
import javax.measure.unit.Unit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
*
* @author Alexis Manin (Geomatys)
*/
@Component
public class HumineIndexSpi implements IndexSpi<Double, TrackingPoint> {
@Autowired
private I04 i04;
@Override
public Unit<?> getUnit() {
return NonSI.PERCENT;
}
@Override
public Indicator getIndicator() {
return i04;
}
@Override
public Index<Double> createIndex(Double value, TrackingPoint entity) {
return new DefaultTrackingPointIndex<>(value, entity, this);
}
/**
* Create an index from data data hold by given statement. The tracking
* point name will be the {@link P04Statement#getHabitat() }.
*
* @param input The statement holding index value.
* @return a new index matching input data.
*/
public Index<Double> createIndex(final P04Statement input) {
return createIndex(input.getHumine(), new TrackingPoint(input.getHabitat(), input.getYear()));
}
@Override
public String getName() {
return "humine";
}
@Override
public Collection<String> getAlias() {
return Collections.singleton("I04 - % humine");
}
@Override
public String getRemarks() {
return "";
}
}
@@ -0,0 +1,142 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p04;
import fr.cenra.rhomeo.api.data.Protocol;
import fr.cenra.rhomeo.api.process.Process;
import fr.cenra.rhomeo.api.process.ProcessContext;
import fr.cenra.rhomeo.core.list.HumidZoneType;
import fr.cenra.rhomeo.api.process.AbstractIndicator;
import fr.cenra.rhomeo.api.process.Indicator;
import fr.cenra.rhomeo.api.result.Index;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
/**
*
* @author Samuel Andrés (Geomatys)
*/
@Component(I04.NAME)
public class I04 extends AbstractIndicator {
public static final String NAME = "I04";
public static final String REMARKS = "Dynamique hydrologique - substances humiques";
@Autowired
@Qualifier(P04.NAME)
private Protocol protocol;
@Autowired
HumineIndexSpi humineSpi;
@Autowired
AcidIndexSpi acidSpi;
@Autowired
I04NbSpi nbSpi;
public I04() {
super(NAME, REMARKS);
}
@Override
public Protocol getProtocol() {
return protocol;
}
@Override
public Set<Process> createProcesses(final ProcessContext ctx) {
return Collections.singleton(new Process(ctx) {
@Override
public Indicator getIndicator() {
return I04.this;
}
@Override
protected Set<? extends Index> call() throws Exception {
final Set<Index> result = new HashSet<>();
final Map<Integer, Set<String>> nbPerYear = new HashMap<>();
for (final P04Statement st : (List<P04Statement>) ctx.getData().getItems()) {
nbPerYear.computeIfAbsent(st.getYear(), (in) -> new HashSet<>()).add(st.getHabitat());
result.add(humineSpi.createIndex(st));
result.add(acidSpi.createIndex(st));
}
for (final Map.Entry<Integer, Set<String>> entry : nbPerYear.entrySet()) {
result.add(nbSpi.createIndex(entry.getValue().size(), entry.getKey()));
}
return result;
}
});
}
@Override
public String getDefaultIndex() {
return nbSpi.getName();
}
/**
*
* @return
*/
@Override
public Set<String> getZoneTypeCodes() {
final Set<String> result = new HashSet<>();
for(final HumidZoneType type : HumidZoneType.values()){
if(!type.equals(HumidZoneType.GRANDS_ESTUAIRES)
&& !type.equals(HumidZoneType.BAIES_ESTUAIRES)
&& !type.equals(HumidZoneType.MARAIS_LAGUNES)
&& !type.equals(HumidZoneType.MARAIS_LAGUNES_PERI_LAGUN)
&& !type.equals(HumidZoneType.MARAIS_LAGUNES_PERI_LAGUN_EAU)
&& !type.equals(HumidZoneType.MARAIS_SAUMATRES)
&& !type.equals(HumidZoneType.MARAIS_LANDES_PRES)
&& !type.equals(HumidZoneType.ZH_PONCT_MARE_SAUMATRE))
result.add(type.getCode());
}
return result;
}
}
@@ -0,0 +1,60 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p04;
/**
*
* @author Alexis Manin (Geomatys)
*/
import fr.cenra.rhomeo.api.process.Indicator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class I04NbSpi extends AbstractHabitatNbSpi {
@Autowired
private I04 i04;
@Override
public Indicator getIndicator() {
return i04;
}
}
@@ -0,0 +1,142 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p04;
import fr.cenra.rhomeo.api.data.Protocol;
import fr.cenra.rhomeo.api.process.Process;
import fr.cenra.rhomeo.api.process.ProcessContext;
import fr.cenra.rhomeo.core.list.HumidZoneType;
import fr.cenra.rhomeo.api.process.AbstractIndicator;
import fr.cenra.rhomeo.api.process.Indicator;
import fr.cenra.rhomeo.api.result.Index;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
/**
*
* @author Samuel Andrés (Geomatys)
*/
@Component(I07.NAME)
public class I07 extends AbstractIndicator {
public static final String NAME = "I07";
public static final String REMARKS = "Vulnérabilité à l'eutrophisation - phosphore";
@Autowired
@Qualifier(P04.NAME)
private Protocol protocol;
@Autowired
PtIndexSpi ptSpi;
@Autowired
CotIndexSpi cotSpi;
@Autowired
I07NbSpi nbSpi;
public I07() {
super(NAME, REMARKS);
}
@Override
public Protocol getProtocol() {
return protocol;
}
@Override
public Set<Process> createProcesses(ProcessContext ctx) {
return Collections.singleton(new Process(ctx) {
@Override
public Indicator getIndicator() {
return I07.this;
}
@Override
protected Set<? extends Index> call() throws Exception {
final Set<Index> result = new HashSet<>();
final Map<Integer, Set<String>> nbPerYear = new HashMap<>();
for (final P04Statement st : (List<P04Statement>) ctx.getData().getItems()) {
nbPerYear.computeIfAbsent(st.getYear(), (in) -> new HashSet<>()).add(st.getHabitat());
result.add(ptSpi.createIndex(st));
result.add(cotSpi.createIndex(st));
}
for (final Map.Entry<Integer, Set<String>> entry : nbPerYear.entrySet()) {
result.add(nbSpi.createIndex(entry.getValue().size(), entry.getKey()));
}
return result;
}
});
}
@Override
public String getDefaultIndex() {
return nbSpi.getName();
}
/**
*
* @return
*/
@Override
public Set<String> getZoneTypeCodes() {
final Set<String> result = new HashSet<>();
for(final HumidZoneType type : HumidZoneType.values()){
if(!type.equals(HumidZoneType.GRANDS_ESTUAIRES)
&& !type.equals(HumidZoneType.BAIES_ESTUAIRES)
&& !type.equals(HumidZoneType.MARAIS_LAGUNES)
&& !type.equals(HumidZoneType.MARAIS_LAGUNES_PERI_LAGUN)
&& !type.equals(HumidZoneType.MARAIS_LAGUNES_PERI_LAGUN_EAU)
&& !type.equals(HumidZoneType.MARAIS_SAUMATRES)
&& !type.equals(HumidZoneType.MARAIS_LANDES_PRES)
&& !type.equals(HumidZoneType.ZH_PONCT_MARE_SAUMATRE))
result.add(type.getCode());
}
return result;
}
}
@@ -0,0 +1,60 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p04;
/**
*
* @author Alexis Manin (Geomatys)
*/
import fr.cenra.rhomeo.api.process.Indicator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class I07NbSpi extends AbstractHabitatNbSpi {
@Autowired
private I07 i07;
@Override
public Indicator getIndicator() {
return i07;
}
}
@@ -0,0 +1,58 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p04;
import fr.cenra.rhomeo.api.data.AbstractProtocol;
import org.springframework.stereotype.Component;
/**
* Chimical analysis of soils protocol.
*
* @author Samuel Andrés (Geomatys)
*/
@Component(P04.NAME)
public class P04 extends AbstractProtocol {
public static final String NAME = "P04";
public static final String REMARKS = "Analyse chimique des sols";
public P04(){
super(NAME, REMARKS, P04Statement.class);
}
}
@@ -0,0 +1,176 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p04;
import fr.cenra.rhomeo.api.data.Statement;
import fr.cenra.rhomeo.api.data.Warning;
import java.time.LocalDate;
import java.util.Objects;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import org.hibernate.validator.constraints.NotBlank;
import org.hibernate.validator.constraints.Range;
/**
*
* @author Alexis Manin (Geomatys)
*/
@P04Validation
public class P04Statement extends Statement {
private final SimpleIntegerProperty year = new SimpleIntegerProperty();
/**
* Note : Code extracted from a public document : Corine Biotope
*/
private final SimpleStringProperty habitatProperty = new SimpleStringProperty();
private final SimpleDoubleProperty humineProperty = new SimpleDoubleProperty();
private final SimpleDoubleProperty acidsProperty = new SimpleDoubleProperty();
private final SimpleDoubleProperty ptProperty = new SimpleDoubleProperty();
private final SimpleDoubleProperty cotProperty = new SimpleDoubleProperty();
// Set a default constructor setting a valid date, to succeed on constraint validation.
public P04Statement() {
date.set(LocalDate.now());
}
@Range(min = 2000, max = 2100, payload = Warning.class, message = "L'année saisie n'appartient pas au 21ᵉ siècle")
public int getYear() {
return year.get();
}
@NotBlank(message = "Un habitat doit être saisi")
public String getHabitat() {
return habitatProperty.get();
}
public double getHumine() {
return humineProperty.get();
}
public double getAcids() {
return acidsProperty.get();
}
public double getPt() {
return ptProperty.get();
}
public double getCot() {
return cotProperty.get();
}
public void setYear(final int year) {
this.year.set(year);
}
public void setHabitat(final String habitat) {
habitatProperty.set(habitat);
}
public void setHumine(final double humine) {
humineProperty.set(humine);
}
public void setAcids(final double acids) {
acidsProperty.set(acids);
}
public void setPt(final double pt) {
ptProperty.set(pt);
}
public void setCot(final double cot) {
cotProperty.set(cot);
}
public IntegerProperty yearProperty() {
return year;
}
public StringProperty habitatProperty() {
return habitatProperty;
}
public DoubleProperty humineProperty() {
return humineProperty;
}
public DoubleProperty acidsProperty() {
return acidsProperty;
}
public SimpleDoubleProperty ptProperty() {
return ptProperty;
}
public SimpleDoubleProperty cotProperty() {
return cotProperty;
}
/**
* We must have only one statement per year and "habitat", so they're the
* only terms of the equation.
*
* @param obj
* @return
*/
@Override
public boolean equals(Object obj) {
if (obj instanceof P04Statement) {
final P04Statement other = (P04Statement) obj;
return year.get() == other.year.get() && Objects.equals(habitatProperty.get(), other.habitatProperty.get());
}
return false;
}
@Override
public int hashCode() {
return habitatProperty.get() == null ? year.get() : year.get() + 7 * habitatProperty.get().hashCode();
}
}
@@ -0,0 +1,64 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p04;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import javax.validation.Constraint;
import javax.validation.Payload;
/**
*
* @author Alexis Manin (Geomatys)
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Constraint(validatedBy = P04Validator.class)
@Documented
public @interface P04Validation {
String message() default "Les deux champs de I04 ou les deux champs de I07 doivent être remplis pour que l'entrée soit valide.";
Class<?>[] groups() default {};
Class<? extends Payload>[] payload() default {};
}
@@ -0,0 +1,60 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p04;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
/**
*
* @author Alexis Manin (Geomatys)
*/
public class P04Validator implements ConstraintValidator<P04Validation, P04Statement> {
@Override
public void initialize(P04Validation constraintAnnotation) {}
@Override
public boolean isValid(P04Statement value, ConstraintValidatorContext context) {
final boolean validI04 = value.getHumine() > 0 && value.getAcids() > 0;
final boolean validI07 = value.getCot() > 0 && value.getPt() > 0;
return validI04 || validI07;
}
}
@@ -0,0 +1,102 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p04;
import fr.cenra.rhomeo.api.data.TrackingPoint;
import fr.cenra.rhomeo.api.process.Indicator;
import fr.cenra.rhomeo.api.result.DefaultTrackingPointIndex;
import fr.cenra.rhomeo.api.result.Index;
import fr.cenra.rhomeo.api.result.IndexSpi;
import java.util.Collection;
import java.util.Collections;
import javax.measure.unit.Unit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
*
* @author Alexis Manin (Geomatys)
*/
@Component
public class PtIndexSpi implements IndexSpi<Double, TrackingPoint> {
@Autowired
private I07 i07;
@Override
public Unit<?> getUnit() {
return Unit.ONE;
}
@Override
public Indicator getIndicator() {
return i07;
}
@Override
public Index<Double> createIndex(Double value, TrackingPoint entity) {
return new DefaultTrackingPointIndex<>(value, entity, this);
}
/**
* Create an index from data data hold by given statement. The tracking
* point name will be the {@link P04Statement#getHabitat() }.
*
* @param input The statement holding index value.
* @return a new index matching input data.
*/
public Index<Double> createIndex(final P04Statement input) {
return createIndex(input.getPt(), new TrackingPoint(input.getHabitat(), input.getYear()));
}
@Override
public String getName() {
return "PT";
}
@Override
public Collection<String> getAlias() {
return Collections.singleton("I07 - PT");
}
@Override
public String getRemarks() {
return "Quantité de phosphore total (PT en g/kg de sol sec)";
}
}
@@ -0,0 +1,170 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p05;
import fr.cenra.rhomeo.api.data.DataContext;
import fr.cenra.rhomeo.api.data.Protocol;
import fr.cenra.rhomeo.api.data.Site;
import fr.cenra.rhomeo.api.data.TrackingPoint;
import fr.cenra.rhomeo.api.process.AbstractIndicator;
import fr.cenra.rhomeo.api.process.ProcessContext;
import fr.cenra.rhomeo.api.result.IndexSpi;
import fr.cenra.rhomeo.core.data.reference.OrthopteraIndicatorReference;
import fr.cenra.rhomeo.core.data.reference.OrthopteraIndicatorReferenceDescription;
import fr.cenra.rhomeo.core.data.reference.TaxrefDescription;
import fr.cenra.rhomeo.core.list.OrthoptereZoneBio;
import java.util.Collections;
import java.util.Optional;
import java.util.Set;
import org.apache.sis.util.ArgumentChecks;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
/**
* An abstraction of {@link I05} and {@link I09} indicators.
*
* @author Samuel Andrés (Geomatys) <samuel.andres at geomatys.com>
*/
public abstract class AbstractP05Indicator extends AbstractIndicator {
@Autowired
@Qualifier(P05.NAME)
private Protocol protocol;
@Autowired
protected OrthopteraIndicatorReferenceDescription referenceDescription;
@Autowired
protected TaxrefDescription taxref;
public AbstractP05Indicator(String name, String remarks) {
super(name, remarks);
}
@Override
public Protocol getProtocol() {
return protocol;
}
/**
*
* @param reference
*
* @return The correct value of the reference according to the indicator.
*/
abstract protected int getIndicatorValue(final OrthopteraIndicatorReference reference);
/**
*
* @return The correct {@link IndexSpi} according to the indicator for the annual index.
*/
abstract protected IndexSpi getAnnualIndexSpi();
/**
*
* @return The correct {@link IndexSpi} according to the indicator for the annual index by {@link TrackingPoint}.
*/
abstract protected IndexSpi getAnnualPointIndexSpi();
/**
* Checks if the statement is compatible to the specified zone.
*
* WHERE […]
* AND
* (
* ortho_indicateurs.mediterraneen1_ml = 1 AND ortho_zbio.zbio::text = 'mediterraneen1_ml'::text
* OR
* ortho_indicateurs.mediterraneen1_ma = 1 AND ortho_zbio.zbio::text = 'mediterraneen1_ma'::text
* OR
* ortho_indicateurs.mediterraneen2_ma = 1 AND ortho_zbio.zbio::text = 'mediterraneen2_ma'::text
* OR
* ortho_indicateurs.mediterraneen2_tb = 1 AND ortho_zbio.zbio::text = 'mediterraneen2_tb'::text
* OR
* ortho_indicateurs.alpin_ma = 1 AND ortho_zbio.zbio::text = 'alpin_ma'::text
* OR
* ortho_indicateurs.alpin_tb = 1 AND ortho_zbio.zbio::text = 'alpin_tb'::text
* OR
* ortho_indicateurs.continental_ma = 1 AND ortho_zbio.zbio::text = 'continental_ma'::text
* OR
* ortho_indicateurs.continental_tb = 1 AND ortho_zbio.zbio::text = 'continental_tb'::text
* )
*
* (Source : CCTP)
*
* Note : les options 'continental_*' ne sont pas supportées car non spécifiées dans la liste
* {@link OrthoptereZoneBio}.
*
* @param reference
* @param zone
* @return true if there is a compatibility found between the {@link OrthopteraIndicatorReference}
* and the given {@link OrthoptereZoneBio}.
*/
public static boolean checkZoneConsistency(final OrthopteraIndicatorReference reference, final OrthoptereZoneBio zone) {
switch(zone){
case MED1_MARAIS_LITTORAL:
return reference.getMediterraneen1_ml()==1;
case MED1_MARAIS_ALLUVIAL:
return reference.getMediterraneen1_ma()==1;
case MED2_MARAIS_ALLUVIAL:
return reference.getMediterraneen2_ma()==1;
case MED2_TOURBIERE:
return reference.getMediterraneen2_tb()==1;
case ALPIN_MARAIS_ALLUVIAL:
return reference.getAlpin_ma()==1;
case ALPIN_TOURBIERE:
return reference.getAlpin_tb()==1;
default:
return false;
}
}
@Override
public Set<fr.cenra.rhomeo.api.process.Process> createProcesses(final ProcessContext ctx) {
ArgumentChecks.ensureNonNull("processContext", ctx);
final String zoneCode = Optional.ofNullable(ctx.getDataCtx())
.map(DataContext::getSite)
.map(Site::getZoneType)
.orElseThrow(() -> new IllegalStateException("Le contexte est invalide : impossible de déterminer le type de zone pour le site de travail"));
if (getZoneTypeCodes().contains(zoneCode)) {
return Collections.singleton(new Processor(ctx, this));
} else return Collections.EMPTY_SET;
}
}
@@ -0,0 +1,99 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p05;
import fr.cenra.rhomeo.api.InternationalDescription;
import fr.cenra.rhomeo.api.InternationalResource;
import fr.cenra.rhomeo.api.data.TrackingPoint;
import fr.cenra.rhomeo.api.process.Indicator;
import fr.cenra.rhomeo.api.result.Index;
import fr.cenra.rhomeo.api.result.IndexSpi;
import java.util.Collection;
import java.util.Collections;
import javax.measure.quantity.Dimensionless;
import javax.measure.unit.NonSI;
import javax.measure.unit.Unit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
/**
*
* @author Samuel Andrés (Geomatys) <samuel.andres at geomatys.com>
*/
@Component(AnnualPointRateEnvironmentHumidity.NAME)
public class AnnualPointRateEnvironmentHumidity implements IndexSpi<Double, TrackingPoint>, InternationalResource, InternationalDescription {
public static final String NAME = "fr.cenra.rhomeo.protocol.p05.AnnualPointRateEnvironmentHumidity";
@Autowired
@Qualifier(I09.NAME)
private Indicator indicator;
@Override
public Unit<Dimensionless> getUnit() {
return NonSI.PERCENT;
}
@Override
public Indicator getIndicator() {
return indicator;
}
@Override
public Index<Double> createIndex(Double value, TrackingPoint point) {
return new AnnualPointRateEnvironmentHumidityIndex(value, this, point);
}
@Override
public String getName() {
return NAME;
}
@Override
public Collection<String> getAlias() {
return Collections.singletonList("I09");
}
@Override
public String getRemarks() {
return null;
}
}
@@ -0,0 +1,65 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p05;
import fr.cenra.rhomeo.api.data.TrackingPoint;
import fr.cenra.rhomeo.api.result.AbstractParametrableIndex;
import fr.cenra.rhomeo.api.result.TrackingPointIndex;
/**
*
* @author Samuel Andrés (Geomatys) <samuel.andres at geomatys.com>
*/
public class AnnualPointRateEnvironmentHumidityIndex extends AbstractParametrableIndex<Double, TrackingPoint> implements TrackingPointIndex<Double> {
public AnnualPointRateEnvironmentHumidityIndex(final Double value, final AnnualPointRateEnvironmentHumidity indexSpi, final TrackingPoint trackingPoint) {
super(value, indexSpi, trackingPoint, TrackingPoint.class);
}
@Override
public int getYear() {
return base.getYear();
}
@Override
public TrackingPoint getPoint() {
return base;
}
}
@@ -0,0 +1,98 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p05;
import fr.cenra.rhomeo.api.InternationalDescription;
import fr.cenra.rhomeo.api.InternationalResource;
import fr.cenra.rhomeo.api.data.TrackingPoint;
import fr.cenra.rhomeo.api.process.Indicator;
import fr.cenra.rhomeo.api.result.Index;
import fr.cenra.rhomeo.api.result.IndexSpi;
import java.util.Collection;
import java.util.Collections;
import javax.measure.quantity.Dimensionless;
import javax.measure.unit.NonSI;
import javax.measure.unit.Unit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
/**
*
* @author Samuel Andrés (Geomatys) <samuel.andres at geomatys.com>
*/
@Component(AnnualPointRateSedimentaryDynamics.NAME)
public class AnnualPointRateSedimentaryDynamics implements IndexSpi<Double, TrackingPoint>, InternationalResource, InternationalDescription {
public static final String NAME = "fr.cenra.rhomeo.protocol.p05.AnnualPointRateSedimentaryDynamics";
@Autowired
@Qualifier(I05.NAME)
private Indicator indicator;
@Override
public Unit<Dimensionless> getUnit() {
return NonSI.PERCENT;
}
@Override
public Indicator getIndicator() {
return indicator;
}
@Override
public Index<Double> createIndex(Double value, TrackingPoint point) {
return new AnnualPointRateSedimentaryDynamicsIndex(value, this, point);
}
@Override
public String getName() {
return NAME;
}
@Override
public Collection<String> getAlias() {
return Collections.singletonList("I05");
}
@Override
public String getRemarks() {
return null;
}
}
@@ -0,0 +1,64 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p05;
import fr.cenra.rhomeo.api.data.TrackingPoint;
import fr.cenra.rhomeo.api.result.AbstractParametrableIndex;
import fr.cenra.rhomeo.api.result.TrackingPointIndex;
/**
*
* @author Samuel Andrés (Geomatys) <samuel.andres at geomatys.com>
*/
public class AnnualPointRateSedimentaryDynamicsIndex extends AbstractParametrableIndex<Double, TrackingPoint> implements TrackingPointIndex<Double> {
public AnnualPointRateSedimentaryDynamicsIndex(final Double value, final AnnualPointRateSedimentaryDynamics indexSpi, final TrackingPoint trackingPoint) {
super(value, indexSpi, trackingPoint, TrackingPoint.class);
}
@Override
public int getYear() {
return base.getYear();
}
@Override
public TrackingPoint getPoint() {
return base;
}
}
@@ -0,0 +1,97 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p05;
import fr.cenra.rhomeo.api.process.Indicator;
import fr.cenra.rhomeo.api.result.DefaultIndex;
import fr.cenra.rhomeo.api.result.Index;
import fr.cenra.rhomeo.api.result.IndexSpi;
import java.util.Collection;
import java.util.Collections;
import javax.measure.quantity.Dimensionless;
import javax.measure.unit.NonSI;
import javax.measure.unit.Unit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
/**
*
* @author Samuel Andrés (Geomatys) <samuel.andres at geomatys.com>
*/
@Component(AnnualRateEnvironmentHumidity.NAME)
public class AnnualRateEnvironmentHumidity implements IndexSpi<Double, Integer> {
public static final String NAME = "fr.cenra.rhomeo.protocol.p05.AnnualRateEnvironmentHumidity";
@Autowired
@Qualifier(I09.NAME)
private Indicator indicator;
@Override
public Unit<Dimensionless> getUnit() {
return NonSI.PERCENT;
}
@Override
public Indicator getIndicator() {
return indicator;
}
@Override
public Index<Double> createIndex(Double value, Integer year) {
return new DefaultIndex<>(value, this, year);
}
@Override
public String getName() {
return NAME;
}
@Override
public Collection<String> getAlias() {
return Collections.singletonList("I09");
}
@Override
public String getRemarks() {
return null;
}
}
@@ -0,0 +1,96 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p05;
import fr.cenra.rhomeo.api.process.Indicator;
import fr.cenra.rhomeo.api.result.DefaultIndex;
import fr.cenra.rhomeo.api.result.Index;
import fr.cenra.rhomeo.api.result.IndexSpi;
import java.util.Collection;
import java.util.Collections;
import javax.measure.quantity.Dimensionless;
import javax.measure.unit.NonSI;
import javax.measure.unit.Unit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
/**
*
* @author Samuel Andrés (Geomatys) <samuel.andres at geomatys.com>
*/
@Component(AnnualRateSedimentaryDynamics.NAME)
public class AnnualRateSedimentaryDynamics implements IndexSpi<Double, Integer> {
public static final String NAME = "fr.cenra.rhomeo.protocol.p05.AnnualRateSedimentaryDynamics";
@Autowired
@Qualifier(I05.NAME)
private Indicator indicator;
@Override
public Unit<Dimensionless> getUnit() {
return NonSI.PERCENT;
}
@Override
public Indicator getIndicator() {
return indicator;
}
@Override
public Index<Double> createIndex(Double value, Integer year) {
return new DefaultIndex<>(value, this, year);
}
@Override
public String getName() {
return NAME;
}
@Override
public Collection<String> getAlias() {
return Collections.singletonList("I05");
}
@Override
public String getRemarks() {
return null;
}
}
@@ -0,0 +1,107 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p05;
import fr.cenra.rhomeo.core.list.HumidZoneType;
import fr.cenra.rhomeo.api.result.IndexSpi;
import fr.cenra.rhomeo.core.data.reference.OrthopteraIndicatorReference;
import java.util.HashSet;
import java.util.Set;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
*
* @author Samuel Andrés (Geomatys)
*/
@Component(I05.NAME)
public class I05 extends AbstractP05Indicator {
public static final String NAME = "I05";
public static final String REMARKS = "Dynamique sédimentaire - orthoptères";
@Autowired
private AnnualRateSedimentaryDynamics annualIndexSpi;
@Autowired
private AnnualPointRateSedimentaryDynamics annualPointIndexSpi;
public I05() {
super(NAME, REMARKS);
}
@Override
protected int getIndicatorValue(final OrthopteraIndicatorReference reference) {
return reference.getDm_val();
}
@Override
public String getDefaultIndex() {
return AnnualRateSedimentaryDynamics.NAME;
}
/**
*
* @return
*/
@Override
public Set<String> getZoneTypeCodes() {
final Set<String> result = new HashSet<>();
for(final HumidZoneType type : HumidZoneType.values()){
if(type.equals(HumidZoneType.GRANDS_ESTUAIRES)
|| type.equals(HumidZoneType.BAIES_ESTUAIRES)
|| type.equals(HumidZoneType.MARAIS_LAGUNES)
|| type.equals(HumidZoneType.MARAIS_LAGUNES_PERI_LAGUN)
|| type.equals(HumidZoneType.MARAIS_LAGUNES_PERI_LAGUN_EAU)
|| type.equals(HumidZoneType.BORDURES_COURS_EAU))
result.add(type.getCode());
}
return result;
}
@Override
protected IndexSpi getAnnualIndexSpi() {
return annualIndexSpi;
}
@Override
protected IndexSpi getAnnualPointIndexSpi() {
return annualPointIndexSpi;
}
}
@@ -0,0 +1,103 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p05;
import fr.cenra.rhomeo.core.list.HumidZoneType;
import fr.cenra.rhomeo.api.result.IndexSpi;
import fr.cenra.rhomeo.core.data.reference.OrthopteraIndicatorReference;
import java.util.HashSet;
import java.util.Set;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
*
* @author Samuel Andrés (Geomatys)
*/
@Component(I09.NAME)
public class I09 extends AbstractP05Indicator {
public static final String NAME = "I09";
public static final String REMARKS = "Humidité du milieu - orthoptères";
@Autowired
private AnnualRateEnvironmentHumidity annualIndexSpi;
@Autowired
private AnnualPointRateEnvironmentHumidity annualPointIndexSpi;
public I09() {
super(NAME, REMARKS);
}
@Override
public String getDefaultIndex() {
return AnnualRateEnvironmentHumidity.NAME;
}
@Override
protected int getIndicatorValue(final OrthopteraIndicatorReference reference) {
return reference.getHs_val();
}
/**
*
* @return
*/
@Override
public Set<String> getZoneTypeCodes() {
final Set<String> result = new HashSet<>();
for(final HumidZoneType type : HumidZoneType.values()){
if(!type.equals(HumidZoneType.GRANDS_ESTUAIRES)
&& !type.equals(HumidZoneType.BAIES_ESTUAIRES))
result.add(type.getCode());
}
return result;
}
@Override
protected IndexSpi getAnnualIndexSpi() {
return annualIndexSpi;
}
@Override
protected IndexSpi getAnnualPointIndexSpi() {
return annualPointIndexSpi;
}
}
@@ -0,0 +1,145 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p05;
import fr.cenra.rhomeo.api.annotations.RefersTo;
import fr.cenra.rhomeo.api.data.Statement;
import fr.cenra.rhomeo.api.data.Warning;
import fr.cenra.rhomeo.core.data.reference.Taxref;
import fr.cenra.rhomeo.protocol.validation.DeterminedSpecies;
import java.time.LocalDate;
import java.util.Objects;
import java.util.function.Predicate;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javax.validation.constraints.NotNull;
/**
*
* @author Samuel Andrés (Geomatys)
*
* @see Taxref
*/
public class OrthopteraStatement extends Statement {
private final IntegerProperty cd_nomProperty = new SimpleIntegerProperty();
public OrthopteraStatement() {
}
/**
*
* @param trackingPoint Tracking point's name.
* @param date Statement date.
* @param remarks
* @param speciesName CD_NOM (TAXREF) ({@link Taxref}) which is expected to be a CD_REF.
*/
public OrthopteraStatement(final String trackingPoint, final LocalDate date, final String remarks, final int speciesName) {
super(trackingPoint, date, remarks);
this.cd_nomProperty.set(speciesName);
}
public IntegerProperty cd_nomProperty() {
return cd_nomProperty;
}
public void setCd_nom(final int speciesName) {
this.cd_nomProperty.set(speciesName);
}
/**
* NOM_ESPECES.
*
* (Source : CCTP)
*
* […] FROM […]
* […] expertise.obs_especes […]
* JOIN referentiels_non_geo.taxref ON obs_especes.cd_ref = taxref.cd_nom::text
*
* (Source : I05 and I09 description from the CCTP)
*
* A cd_nom which is potentially used to reference the corresponding cd_ref
* into the processes. Old statements have several taxonomic ids, but we need
* here a taxonomic id referencing taxref.cd_nom.
*
* @return
*/
@NotNull // Used for fx editor only
@RefersTo(type=Taxref.class, property = Taxref.ATT_CD_NOM, filterClass = OrthopteraOnly.class)
@DeterminedSpecies(payload=Warning.class)
public int getCd_nom() {
return cd_nomProperty.get();
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final OrthopteraStatement other = (OrthopteraStatement) obj;
return
// Compare first elements which are most likely to differ.
Objects.equals(getCd_nom(), other.getCd_nom()) &&
Objects.equals(getTrackingPoint(), other.getTrackingPoint()) &&
Objects.equals(getDate(), other.getDate());
}
@Override
public int hashCode() {
Integer hash = 7;
hash = 37 * hash + Objects.hashCode(getDate());
hash = 37 * hash + Objects.hashCode(getTrackingPoint());
hash = 37 * hash + Objects.hashCode(getCd_nom());
return hash;
}
public static class OrthopteraOnly implements Predicate<Taxref> {
@Override
public boolean test(Taxref t) {
return "orthoptera".equalsIgnoreCase(t.getOrdre());
}
}
}
@@ -0,0 +1,78 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p05;
import fr.cenra.rhomeo.api.data.AbstractProtocol;
import fr.cenra.rhomeo.api.data.Site;
import fr.cenra.rhomeo.api.data.Warning;
import fr.cenra.rhomeo.core.RhomeoCore;
import fr.cenra.rhomeo.core.data.reference.OrthopteraIndicatorReference;
import fr.cenra.rhomeo.core.data.reference.OrthopteraIndicatorReferenceDescription;
import fr.cenra.rhomeo.core.data.reference.TaxrefDescription;
import fr.cenra.rhomeo.core.list.OrthoptereZoneBio;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import fr.cenra.rhomeo.protocol.validation.IndicatorTaxon;
/**
* Orthoptera protocol.
*
* @author Samuel Andrés (Geomatys)
*/
@Component(P05.NAME)
@IndicatorTaxon(type = OrthopteraIndicatorReference.class, payload=Warning.class)
public class P05 extends AbstractProtocol {
public static final String NAME = "P05";
public static final String REMARKS = "Orthoptères";
@Autowired
public P05(final TaxrefDescription ref, final OrthopteraIndicatorReferenceDescription oird){
super(NAME, REMARKS, OrthopteraStatement.class, ref, oird);
}
@Override
public boolean isCompatible(Site site) {
if (site != null && RhomeoCore.getByCode(OrthoptereZoneBio.class, site.getOrthoptereType()).isPresent()) {
return super.isCompatible(site);
}
return false;
}
}
@@ -0,0 +1,132 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p05;
import fr.cenra.rhomeo.api.data.ObjectWrapper;
import fr.cenra.rhomeo.core.RhomeoCore;
import fr.cenra.rhomeo.core.data.ReferenceManager;
import fr.cenra.rhomeo.core.data.reference.Taxref;
import fr.cenra.rhomeo.core.data.reference.TaxrefDescription;
import java.time.LocalDate;
import java.util.List;
import java.util.Optional;
import java.util.logging.Level;
import org.apache.sis.util.collection.Cache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
*
* @author Alexis Manin (Geomatys)
*/
@Component
public class P05Wrapper implements ObjectWrapper<OrthopteraStatement, P05Wrapper.CustomStatement> {
private final Cache<Integer, String> cache = new Cache<>(100, 0, true);
@Autowired
TaxrefDescription refDesciption;
@Override
public Class<OrthopteraStatement> getInputType() {
return OrthopteraStatement.class;
}
@Override
public Class<P05Wrapper.CustomStatement> getOutputType() {
return P05Wrapper.CustomStatement.class;
}
@Override
public CustomStatement apply(OrthopteraStatement t) {
return new CustomStatement(t);
}
private String getName(final int cdNom) {
try {
return cache.getOrCreate(cdNom, () -> {
Optional<List<Taxref>> lastLoaded = ReferenceManager.getOrCreate(refDesciption).getLastLoaded();
if (lastLoaded.isPresent()) {
final List<Taxref> refs = lastLoaded.get();
for (final Taxref ref : refs) {
if (ref.getCd_nom() == cdNom)
return ref.getLb_nom();
}
}
return null;
});
} catch (Exception ex) {
RhomeoCore.LOGGER.log(Level.FINE, "Cannot compute name", ex);
return null;
}
}
public class CustomStatement {
final OrthopteraStatement wrapped;
private CustomStatement(final OrthopteraStatement input) {
wrapped = input;
}
public LocalDate getDate() {
return wrapped.getDate();
}
public String getTrackingPoint() {
return wrapped.getTrackingPoint();
}
public String getRemarks() {
return wrapped.getRemarks();
}
public int getCd_nom() {
return wrapped.getCd_nom();
}
public String getNom_complet() {
if (wrapped.getCd_nom() > 0) {
return getName(wrapped.getCd_nom());
}
return null;
}
}
}
@@ -0,0 +1,219 @@
package fr.cenra.rhomeo.protocol.p05;
import fr.cenra.rhomeo.api.data.TrackingPoint;
import fr.cenra.rhomeo.api.process.Indicator;
import fr.cenra.rhomeo.core.data.reference.OrthopteraIndicatorReference;
import fr.cenra.rhomeo.core.list.OrthoptereZoneBio;
import fr.cenra.rhomeo.protocol.TaxonOperator;
import java.beans.IntrospectionException;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import fr.cenra.rhomeo.api.data.Dataset;
import fr.cenra.rhomeo.api.process.Process;
import fr.cenra.rhomeo.api.process.ProcessContext;
import fr.cenra.rhomeo.api.result.Index;
import fr.cenra.rhomeo.core.RhomeoRuntimeException;
import java.util.HashSet;
import java.util.Set;
import fr.cenra.rhomeo.core.data.reference.Taxref;
import java.util.Collections;
/**
* Computes {@link P05} related indicators (see {@link I05} and {@link I09}).
* This indicator is a bit special, because it computes a single index for
* multiple years, and send it back as the result for only one year, the most
* recent from input. For more information, see <a href="https://gitlab.geomatys.com/rhomeo-group/rhomeo/issues/87">issue 87</a>.
*
* @author Alexis Manin (Geomatys)
*/
class Processor extends Process {
static final String USED_YEARS = "Années prises en compte";
final TaxonOperator operator;
final AbstractP05Indicator indic;
public Processor(final ProcessContext ctx, final AbstractP05Indicator indicator) {
super(ctx);
indic = indicator;
operator = TaxonOperator.getOrCreate(ctx);
}
/**
* Search for orthoptera references matching given observations. The mapping
* is based on {@link Taxref#getCd_ref() } code. For each observation, we
* try to acquire a cd_ref, and for each distinct cd_ref found, we'll take
* the corresponding reference in {@link OrthopteraIndicatorReference} list.
*
* @param statements Observations to get a referent for.
* @return Stream of available references, no doublon.
*/
Stream<OrthopteraIndicatorReference> findMatchingReferences(final Stream<OrthopteraStatement> statements) {
return statements
// Get distinct rhomeo species codes for each observation
.mapToInt(OrthopteraStatement::getCd_nom)
.distinct()
// Find distinct species identifiers corresponding to above rhomeo codes
.map(this::getCdRef)
.filter(cdRef -> cdRef > 0)
.distinct()
// Find orthoptera reference corresponding to given cd_refs
.mapToObj(this::getReference)
.filter(Objects::nonNull);
}
/**
* Filter input references to keep only the ones valid in given zone, and
* then perform a sum of their indicator values.
*
* @param references References to use in computing.
* @param zone Zone to filter references with.
* @return Sum of retained refrence indicator values
*/
int sum(final Stream<OrthopteraIndicatorReference> references, final OrthoptereZoneBio zone) {
return references
// Keep only references consistent with given zone
.filter(ref -> AbstractP05Indicator.checkZoneConsistency(ref, zone))
// Extract indicator value from retained references
.mapToInt(indic::getIndicatorValue)
.sum();
}
private int getCdRef(final int cdNom) {
try {
final Integer tmp = operator.getCdRef(cdNom);
return tmp == null ? -1 : tmp;
} catch (ReflectiveOperationException | IntrospectionException ex) {
throw new RuntimeException("Cannot perform cd_nom -> cd_ref mapping", ex);
}
}
private OrthopteraIndicatorReference getReference(final int cdRef) {
try {
return operator.getOrthopteraReference(cdRef);
} catch (ReflectiveOperationException | IntrospectionException ex) {
throw new RuntimeException("Cannot perform cd_ref -> orthoptera mapping", ex);
}
}
@Override
public Indicator getIndicator() {
return indic;
}
/**
* Generic algorithm to compute both {@link I05} and {@link I09} rates.
*
* The computing for those indicators is a bit special. We do not make a
* result by year, but aggregate multiple years in a single result (see
* <a href="https://gitlab.geomatys.com/rhomeo-group/rhomeo/issues/87">issue
* 87</a> for details).
*
* @return A set of {@link AnnualRateSedimentaryDynamics}.
* @throws java.beans.IntrospectionException
* @throws IllegalStateException if the data context is null, or if its site
* is null, of if the "orthoptere type" of its site is null.
* @throws RhomeoRuntimeException if the orthoptere type of the site cannot
* be converted to an {@link OrthoptereZoneBio}.
*/
@Override
protected Set<? extends Index> call() throws Exception {
updateTitle("Calcul ".concat(indic.getTitle()));
final long totalProgress = 6;
long progress = 0;
updateMessage("Analyse du site");
updateProgress(progress++, totalProgress);
if (ctx.getDataCtx() == null)
throw new IllegalStateException("The data context must not be null.");
else if (ctx.getDataCtx().getSite() == null)
throw new IllegalStateException("The data context must specify a site.");
else if (ctx.getDataCtx().getSite().getOrthoptereType() == null)
throw new IllegalStateException("The site of the data context must specify an type of orthoptera bio zone.");
// Get the orthoptere biozone of the site
final OrthoptereZoneBio siteBioZone = OrthoptereZoneBio.getByCode(ctx.getDataCtx().getSite().getOrthoptereType());
if (siteBioZone == null) {
throw new RhomeoRuntimeException("The orthoptere type of current site cannot be converted to an orthoptera biozone.");
}
/*
* 1- Loop over statements to compute sum for observed species.
* ==========================================================*/
// By year
updateMessage("Analyse des observations annuelles");
updateProgress(progress++, totalProgress);
final TaxonOperator<?> op = TaxonOperator.getOrCreate(ctx);
Stream dataStream = ctx.getData().getItems().stream();
dataStream = findMatchingReferences(dataStream);
final int yearSum = sum(dataStream, siteBioZone);
// By tracking point
updateMessage("Analyse des observations par point de suivi");
updateProgress(progress++, totalProgress);
final Map<TrackingPoint, List<OrthopteraStatement>> dataByPoint
= ((Dataset<OrthopteraStatement>) ctx.getData()).groupByPoint();
/*
* 2- Loop over indicators to compute sum for expected species.
* ==========================================================*/
updateMessage("Indice de zone");
updateProgress(progress++, totalProgress);
int expectedSum = sum(op.getOrthopteraReferences(), siteBioZone);
final Set<Index> indices = new HashSet<>();
/*
* 3- Compute indices.
* =================*/
/* HACK (#87) : We have to determine the most recent year to use for
* annual index. Thing is : We could parse input data to find maximum
* year, or sort it and then get the year of the last element. But, it's
* costly operations. So, an alternative is to wait tracking point
* grouping, and then parse them to find the point with the most recent
* year. It allows to parse less elements to find what year should be
* retained.
*/
updateMessage("Calcul de l'indicateur par point de suivi");
updateProgress(progress++, totalProgress);
final List<Integer> years = dataByPoint.keySet().stream()
.mapToInt(TrackingPoint::getYear)
.distinct()
.sorted()
.boxed()
.collect(Collectors.toList());
if (years.size() < 1)
return Collections.EMPTY_SET;
ctx.getDataCtx().getUserData().put(USED_YEARS, years);
List<Index> pointIndices = dataByPoint.entrySet().parallelStream()
.map(entry -> {
final Stream<OrthopteraStatement> pointData = entry.getValue().stream();
final Stream<OrthopteraIndicatorReference> pointRefs = findMatchingReferences(pointData);
final int pointSum = sum(pointRefs, siteBioZone);
return indic.getAnnualPointIndexSpi().createIndex(100 * (pointSum / (double) expectedSum), entry.getKey());
})
.collect(Collectors.toList());
indices.addAll(pointIndices);
updateMessage("Calcul annuel de l'indicateur");
updateProgress(progress++, totalProgress);
indices.add(indic.getAnnualIndexSpi()
.createIndex(100 * (yearSum / (double) expectedSum), years.get(years.size() - 1)));
return indices;
}
}
@@ -0,0 +1,105 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p06;
import fr.cenra.rhomeo.api.InternationalDescription;
import fr.cenra.rhomeo.api.InternationalResource;
import fr.cenra.rhomeo.api.process.Indicator;
import fr.cenra.rhomeo.api.result.DefaultIndex;
import fr.cenra.rhomeo.api.result.Index;
import fr.cenra.rhomeo.api.result.IndexSpi;
import java.util.Collection;
import java.util.Collections;
import javax.measure.quantity.Dimensionless;
import javax.measure.unit.Unit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
/**
*
* @author Samuel Andrés (Geomatys) <samuel.andres at geomatys.com>
*/
@Component(AnnualNbOfExpectedSpecies.NAME)
public class AnnualNbOfExpectedSpecies implements IndexSpi<Integer, Integer>, InternationalResource, InternationalDescription {
public static final String NAME = "fr.cenra.rhomeo.protocol.p06.AnnualNbOfExpectedSpecies";
@Autowired
@Qualifier(I10.NAME)
private Indicator indicator;
@Override
public Unit<Dimensionless> getUnit() {
return Unit.ONE;
}
@Override
public Indicator getIndicator() {
return indicator;
}
@Override
public Index<Integer> createIndex(Integer value, Integer point) {
return new DefaultIndex<>(value, this, point);
}
@Override
public String getName() {
return NAME;
}
@Override
public Collection<String> getAlias() {
return Collections.singletonList("Nb espèces attendues");
}
@Override
public String getRemarks() {
return null;
}
@Override
public int compareTo(IndexSpi o) {
final int comparison = IndexSpi.super.compareTo(o);
if (comparison == 0)
return -1;
return comparison;
}
}
@@ -0,0 +1,97 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p06;
import fr.cenra.rhomeo.api.process.Indicator;
import fr.cenra.rhomeo.api.result.DefaultIndex;
import fr.cenra.rhomeo.api.result.Index;
import fr.cenra.rhomeo.api.result.IndexSpi;
import java.util.Collection;
import java.util.Collections;
import javax.measure.quantity.Dimensionless;
import javax.measure.unit.NonSI;
import javax.measure.unit.Unit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
/**
*
* @author Samuel Andrés (Geomatys) <samuel.andres at geomatys.com>
*/
@Component(AnnualRatePopulationIntegrity.NAME)
public class AnnualRatePopulationIntegrity implements IndexSpi<Double, Integer> {
public static final String NAME = "fr.cenra.rhomeo.protocol.p06.AnnualRatePopulationIntegrity";
@Autowired
@Qualifier(I10.NAME)
private Indicator indicator;
@Override
public Unit<Dimensionless> getUnit() {
return NonSI.PERCENT;
}
@Override
public Indicator getIndicator() {
return indicator;
}
@Override
public Index<Double> createIndex(Double value, Integer year) {
return new DefaultIndex<>(value, this, year);
}
@Override
public String getName() {
return NAME;
}
@Override
public Collection<String> getAlias() {
return Collections.singletonList("I10 (%)");
}
@Override
public String getRemarks() {
return null;
}
}
@@ -0,0 +1,112 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p06;
import fr.cenra.rhomeo.api.InternationalDescription;
import fr.cenra.rhomeo.api.InternationalResource;
import fr.cenra.rhomeo.api.process.Indicator;
import fr.cenra.rhomeo.api.result.DefaultIndex;
import fr.cenra.rhomeo.api.result.Index;
import fr.cenra.rhomeo.api.result.IndexSpi;
import java.util.Collection;
import java.util.Collections;
import javax.measure.quantity.Dimensionless;
import javax.measure.unit.NonSI;
import javax.measure.unit.Unit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
/**
*
* @author Samuel Andrés (Geomatys) <samuel.andres at geomatys.com>
*/
@Component(AnnualRateRichness.NAME)
public class AnnualRateRichness implements IndexSpi<Double, Integer>, InternationalResource, InternationalDescription {
public static final String NAME = "fr.cenra.rhomeo.protocol.p06.AnnualRateRichness";
@Autowired
@Qualifier(I10.NAME)
private Indicator indicator;
@Override
public Unit<Dimensionless> getUnit() {
return NonSI.PERCENT;
}
@Override
public Indicator getIndicator() {
return indicator;
}
@Override
public Index<Double> createIndex(Double value, Integer point) {
return new DefaultIndex<>(value, this, point);
}
@Override
public String getName() {
return NAME;
}
@Override
public Collection<String> getAlias() {
return Collections.singletonList("Sobs/Strue (%)");
}
@Override
public String getRemarks() {
return null;
}
@Override
public int compareTo(IndexSpi o) {
final int comparison = IndexSpi.super.compareTo(o);
if (comparison == 0) {
if (o instanceof AnnualNbOfExpectedSpecies)
return 1;
else if (o instanceof BehaviorSpi)
return -1;
}
return comparison;
}
}
@@ -0,0 +1,79 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p06;
import fr.cenra.rhomeo.core.list.CodeValue;
/**
*
* @author Alexis Manin (Geomatys)
*/
public enum Behavior implements CodeValue {
OTH(1, "Autre"),
M_F(2, "Mâles + femelles"),
TAN(3, "Tandem"),
TER(4, "Territoriale"),
ACC(5, "Accouplement"),
PON(6, "Ponte"),
IMM(7, "Immature"),
EXU(8, "Exuvie/émergent");
private final int code;
private final String title;
private Behavior(int code, String title) {
this.code = code;
this.title = title;
}
@Override
public Integer getCode() {
return code;
}
@Override
public String getValue() {
return title;
}
@Override
public String toString() {
return new StringBuilder().append(code).append(" ").append(title).toString();
}
}
@@ -0,0 +1,63 @@
package fr.cenra.rhomeo.protocol.p06;
import fr.cenra.rhomeo.api.process.Indicator;
import fr.cenra.rhomeo.api.result.DefaultIndex;
import fr.cenra.rhomeo.api.result.Index;
import fr.cenra.rhomeo.api.result.IndexSpi;
import java.util.Collection;
import java.util.Collections;
import javax.measure.unit.NonSI;
import javax.measure.unit.Unit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
*
* @author Alexis Manin (Geomatys)
*/
@Component
public class BehaviorSpi implements IndexSpi<Float, Integer> {
@Autowired
I10 indic;
@Override
public Unit<?> getUnit() {
return NonSI.PERCENT;
}
@Override
public Indicator getIndicator() {
return indic;
}
@Override
public Index<Float> createIndex(Float value, Integer entity) {
return new DefaultIndex<>(value, this, entity);
}
@Override
public String getName() {
return "behaviorIndex";
}
@Override
public Collection<String> getAlias() {
return Collections.singleton("Niveau d'autochtonie (%)");
}
@Override
public String getRemarks() {
return "Pourcentage de comportements immature, de ponte ou d'exuvie observé";
}
@Override
public int compareTo(IndexSpi o) {
final int comparison = IndexSpi.super.compareTo(o);
if (comparison == 0)
return 1;
return comparison;
}
}
@@ -0,0 +1,115 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p06;
import fr.cenra.rhomeo.core.list.CodeValue;
/**
*
* @author Alexis Manin (Geomatys)
*/
public enum Habitat implements CodeValue {
_1("1", "--- Petits bassins et écoulements (permanents) des sources ---"),
_2("1a", "Zones des sources - Sources de plaine"),
_3("1b", "Zones des sources - Sources d'altitude"),
_4("2", "Ruisselets/ruisseaux fermés"),
_5("3", "Rivières à eaux vives"),
_6("4a", "Grands cours d’eau vifs - Cours principal des grands cours d’eau vifs"),
_7("4b", "Grands cours d’eau vifs - Annexes perturbées avec flux entrant par l’amont"),
_8("4c", "Grands cours d’eau vifs - Annexes perturbées avec flux rétrograde par l’aval"),
_9("4d", "Grands cours d’eau vifs - Annexes peu perturbées avec flux rétrograde par l’aval"),
_10("5a", "Grands cours d’eau calmes - Cours principal des grands cours d’eau calmes"),
_11("5b", "Grands cours d’eau calmes - Annexes lentes ou stagnantes perturbées"),
_12("5c", "Grands cours d’eau calmes - Annexes lentes ou stagnantes peu perturbées"),
_13("5d", "XXXXX"),
_14("5f", "XXXXX"),
_15("6", "Canaux navigables"),
_16("7", "Fossés alimentés"),
_17("8", "Suintements"),
_18("9", "--- Petits étangs, mares, fossés, annexes hydrauliques stagnantes ---"),
_19("9a", "Milieux temporaires de plaine"),
_20("9b", "Milieux temporaires d'altitude"),
_21("10", "--- Mares, abreuvoirs, lavoirs, lavognes anciennes ---"),
_22("10a", "Mares ouvertes - Mares pauvres en végétation aquatique"),
_23("10b", "Mares ouvertes - Mares avec présence de végétation aquatique"),
_24("11", "Mares fermées"),
_25("12", "Milieux saumâtres"),
_26("13", "Milieux artificiels"),
_27("14", "Etangs «naturels» ouverts (annexes comprises)"),
_28("15a", "Etangs «naturels» fermés (annexes comprises) - Absence de queues tourbeuses et ceinture d’hélophyte haute"),
_29("15b", "Etangs «naturels» fermés (annexes comprises) - Absence de queues tourbeuses et ceinture d’hélophyte basse"),
_30("15c", "Etangs «naturels» fermés (annexes comprises) - Présence de queues tourbeuses"),
_31("16", "Marais de plaine"),
_32("17", "Tourbières acides de plaine"),
_33("18", "--- Tourbières acides d'altitude ---"),
_34("18a", "Tourbières acides d’altitude - avec présence de surfaces significatives d’eau libre"),
_35("18b", "Tourbières acides d’altitude - Tourbières acides avec gouilles seulement"),
_36("19", "Milieux stagnants d’altitude"),
_37("20", "Lacs et grands réservoirs"),
_38("21", "Rivières d’altitude"),
_39("22", "Rivières méditerranéennes"),
_40("23", "Ruisselets/ruisseaux ouverts"),
_41("24", "Rivières à eaux calmes"),
_42("25", "Milieux aquatiques cultivés"),
_43("27", "Bassins lagunaires"),
_44("29", "Prairies humides");
public final String code;
public final String value;
private Habitat(String code, String value) {
this.code = code;
this.value = value;
}
@Override
public String getCode() {
return code;
}
@Override
public String getValue() {
return value;
}
@Override
public String toString() {
return new StringBuilder(code).append(' ').append(value).toString();
}
}
@@ -0,0 +1,821 @@
/**
* Copyright © CENRA (2016)
*
* remi.clement@espaces-naturels.fr
*
* This software is a multi-platform and portable application based on
* the scientifical toolbox to monitor wetlands. With this toolbox it’s
* possible to calculate indicators «RhoMéO» to monitor quality,
* fonctionalities and urban and agricultural pressures of wetlands.
* Indicators are calculated using naturalist data entered and/or imported,
* and geographic data downloaded from a geographic server.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p06;
import fr.cenra.rhomeo.api.data.Protocol;
import fr.cenra.rhomeo.api.data.Site;
import fr.cenra.rhomeo.api.process.Process;
import fr.cenra.rhomeo.api.process.ProcessContext;
import fr.cenra.rhomeo.core.list.HumidZoneType;
import fr.cenra.rhomeo.api.process.AbstractIndicator;
import fr.cenra.rhomeo.api.process.Indicator;
import fr.cenra.rhomeo.api.result.Index;
import fr.cenra.rhomeo.core.RhomeoRuntimeException;
import fr.cenra.rhomeo.core.data.reference.OdonataDepartmentReference;
import fr.cenra.rhomeo.core.data.reference.OdonataDepartmentReferenceDescription;
import fr.cenra.rhomeo.core.data.reference.OdonataHabitatReference;
import fr.cenra.rhomeo.core.data.reference.OdonataHabitatReferenceDescription;
import fr.cenra.rhomeo.core.data.reference.TaxrefDescription;
import fr.cenra.rhomeo.core.list.OdonateZoneBio;
import fr.cenra.rhomeo.protocol.TaxonOperator;
import static fr.cenra.rhomeo.protocol.p05.AbstractP05Indicator.getReferences;
import fr.cenra.rhomeo.protocol.p06.validation.BehaviorCoverageValidator;
import java.beans.IntrospectionException;
import java.util.AbstractMap;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.function.Function;
import org.apache.sis.util.ArgumentChecks;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
/**
*
* @author Samuel Andrés (Geomatys)
*/
@Component(I10.NAME)
public class I10 extends AbstractIndicator {
public static final String NAME = "I10";
public static final String REMARKS = "Intégrité du peuplement d'odonates";
@Autowired
@Qualifier(P06.NAME)
private Protocol protocol;
@Autowired
protected AnnualRatePopulationIntegrity indexSpi;
@Autowired
protected AnnualNbOfExpectedSpecies nbSpeciesIndexSpi;
@Autowired
protected AnnualRateRichness annualRateRichness;
@Autowired
protected BehaviorSpi behaviorSpi;
@Autowired
protected OdonataHabitatReferenceDescription habitatReferenceDescription;
@Autowired
protected OdonataDepartmentReferenceDescription departmentReferenceDescription;
@Autowired
protected TaxrefDescription taxrefDescription;
public I10() {
super(NAME, REMARKS);
}
@Override
public Protocol getProtocol() {
return protocol;
}
@Override
public Set<Process> createProcesses(ProcessContext ctx) {
ArgumentChecks.ensureNonNull("processContext", ctx);
final TaxonOperator operator = TaxonOperator.getOrCreate(ctx);
return new HashSet<>(Arrays.asList(new Process[]{new I10Process(operator), new RichnessProcess(operator, this)}));
}
@Override
public String getDefaultIndex() {
return AnnualRatePopulationIntegrity.NAME;
}
/**
*
* @return
*/
@Override
public Set<String> getZoneTypeCodes() {
final Set<String> result = new HashSet<>();
for(final HumidZoneType type : HumidZoneType.values()){
if(!type.equals(HumidZoneType.GRANDS_ESTUAIRES)
&& !type.equals(HumidZoneType.BAIES_ESTUAIRES)
&& !type.equals(HumidZoneType.ZH_BAS_FOND_ALTITUDE))
result.add(type.getCode());
}
return result;
}
private static OdonateZoneBio getOdonateZoneBio(final Site site){
return OdonateZoneBio.getByCode(site.getOdonateType());
}
/**
* "Expected" {@link OdonataHabitatReference} computed from observations.
*
* A) Consistency constraints for the {@link OdonataHabitatReference}s :
* ---------------------------------------------------------------------
*
* - the observed habitats of the species must be referenced;
* - the {@link OdonataHabitatReference#zbio} must be coherent with the {@link Site#getOdonateType() };
* - the department of the site must be referenced;
* - the {@link OdonataHabitatReference#cd_ref} and {@link OdonataDepartmentReference#zbio} must be coherent.
*
* B) Consistency constraints for the {@link OdonataHabitatReference}s :
* ---------------------------------------------------------------------
* - the {@link OdonataDepartmentReference#valeur} must be < 2.
* - the {@link OdonataHabitatReference#valeur} must be > 3.
*
*
* C) Query
* --------
*
* -- t1 restreint les observations d'habitats d'odonates aux types d'habitat des relevés.
* -- De plus, ces types d'habitats doivent être compatibles avec la 'zone bio odonates' du site et doivent concerner des espèces potentiellement localisées dans le département du site,
* -- Enfin, les valeurs des références 'odo_especes_par_dept' et 'odo_dependance_habitat' doivent respecter certaines contraintes.
*
* WITH t1 AS (
*
* -- t récupère les valeurs d'habitat pour les relevés d'odonates.
* WITH t AS (
*
* SELECT
* sites.dept, -- 1 seul site / group by indirect
* sites.zbio, -- 1 seul site / group by indirect
* […]
* releves_valeurs.id_attribut, -- 1 seul valeur filtrée / group by
* releves_valeurs.valeur AS habitat, -- group by
* "left"(releves.date::text, 4) AS annee, -- group by
* […]
*
* FROM sites
* JOIN points_de_suivis ON sites.id_site = points_de_suivis.id_site
* JOIN releves ON points_de_suivis.id_point_suivi = releves.id_point_suivi
* JOIN releves_valeurs ON releves.id_releve = releves_valeurs.id_releve
*
* WHERE
* releves_valeurs.id_attribut = 'habitats_odo'::text
*
* GROUP BY
* […]
* releves_valeurs.id_attribut,
* releves_valeurs.valeur,
* ("left"(releves.date::text, 4)),
* […]
* )
*
*
* -- récupère la valeur minimale de l'habitat de l'espèce en filtrant sur les valeurs de présence par département et sur la valeur d'habitat
* -- il s'avère que la valeur minimale semble inutilisée : ce sont les espèces filtrées qui sont utilisées
* SELECT
* t.dept, -- group by site
* […]
* t.zbio, -- group by site
* […]
* odo_dependance_habitat.espece AS sp_attendue, --group by
* min(odo_dependance_habitat.valeur::text) AS min_valeur,
* odo_dependance_habitat.cd_ref, -- group by
* t.annee, -- group by
* […]
* FROM t,
* odo_dependance_habitat,
* odo_especes_par_dept
*
* WHERE
* odo_especes_par_dept.valeur > 2::double precision -- filtre sur odo_especes_par_dept
* AND odo_dependance_habitat.valeur::integer < 3 -- filtre sur odo_dependance_habitat
*
* AND t.dept = odo_especes_par_dept.id_dept::text -- jointure -> odo_especes_par_dept
* AND t.zbio = odo_dependance_habitat.zbio::text -- jointure -> odo_dependance_habitat
* AND t.habitat = odo_dependance_habitat.habitat::text -- jointure -> odo_dependance_habitat
* AND odo_dependance_habitat.cd_ref = odo_especes_par_dept.cd_ref -- jointure odo_dependance_habitat <-> odo_especes_par_dept pour être cohérent au niveau espèce.
*
* GROUP BY
* t.dept, -- vient du site
* […]
* t.zbio, -- vient du site
* […]
* odo_dependance_habitat.espece,
* odo_dependance_habitat.cd_ref,
* t.annee,
* […]
* )
*
* @param statements
* @param site
* @return
* @throws IntrospectionException
*/
protected Map<Integer, Set<OdonataHabitatReference>> t1(final Iterable<OdonataStatement> statements, final Site site) throws IntrospectionException{
final Map<Integer, Set<OdonataHabitatReference>> expectedSpeciesByYear = new HashMap<>();
// Get the consistent pair of habitat reference / departement reference.
// "JOIN" t.dept = odo_especes_par_dept.id_dept::text
// "JOIN" t.zbio = odo_dependance_habitat.zbio::text
// "JOIN" odo_dependance_habitat.cd_ref = odo_especes_par_dept.cd_ref
final Map<String, Set<Map.Entry<OdonataHabitatReference, OdonataDepartmentReference>>> consistents = getConsistentReferences(site);
// Loop over statements
final Function<Integer, Set<OdonataHabitatReference>> creator = input -> new HashSet();
for(final OdonataStatement statement : statements){
final int year = statement.getDate().getYear();
final Set<Map.Entry<OdonataHabitatReference, OdonataDepartmentReference>> consistentsSet = consistents.get(statement.getHabitat());
if(consistentsSet!=null){
// Loop over consistent reference pairs for the habitat of the current statement.
// ("JOIN" t.habitat = odo_dependance_habitat.habitat::text)
for(final Map.Entry<OdonataHabitatReference, OdonataDepartmentReference> consistent : consistentsSet){
// Get the referencies.
final OdonataHabitatReference habReference = consistent.getKey();
final OdonataDepartmentReference deptReference = consistent.getValue();
// filter on reference values :
// odo_especes_par_dept.valeur > 2::double precision -- filtre sur odo_especes_par_dept
// AND odo_dependance_habitat.valeur::integer < 3 -- filtre sur odo_dependance_habitat
if(habReference.getValeur()<3
&& deptReference.getValeur()>2){
expectedSpeciesByYear.computeIfAbsent(year, creator).add(habReference);
}
}
}
}
return expectedSpeciesByYear;
}
/**
* Count the result of {@link I10#t1(java.lang.Iterable, fr.cenra.rhomeo.api.data.Site) }, by year.
*
* -- Compte le nombre d'espèces attendues selon le filtrage de t1... et... et... et... ? Quoi d'autre ???
* -- En fait, on ne voi pas ce qu'il y a à compter…
* t2 AS (
*
* SELECT
* […]
* count(t1.sp_attendue) AS nb_attendues,
* t1.annee, -- group by
* […]
*
* FROM t1
*
* GROUP BY
* […]
* t1.annee,
* […]
* )
*
* @param t1 Result of {@link I10#t1(java.lang.Iterable, fr.cenra.rhomeo.api.data.Site) }.
* @return
*
* @see I10#t1(java.lang.Iterable, fr.cenra.rhomeo.api.data.Site)
*/
protected static Map<Integer, Integer> t2(final Map<Integer, Set<OdonataHabitatReference>> t1){
final Map<Integer, Integer> result = new HashMap<>();
for(final Map.Entry<Integer, Set<OdonataHabitatReference>> entry : t1.entrySet()){
final Set<Integer> diffSpecies = new HashSet<>();
for(final OdonataHabitatReference habRef : entry.getValue()){
diffSpecies.add(habRef.getCd_ref());
}
result.put(entry.getKey(), diffSpecies.size());
}
return result;
}
/**
* Observed species by year.
*
* WITH t4 AS (
*
* SELECT
* […]
* CASE
* WHEN taxref.rang = 'SSES'::text THEN taxref.cd_taxsup::text
* ELSE taxref.cd_ref::text
* END AS cd_ref,
* taxref.nom_complet, -- group by
* taxref.rang, -- group by
* "left"(releves.date::text, 4) AS annee, -- group by
* taxref.cd_taxsup -- group by
*
* FROM
* […]
* points_de_suivis […]
* JOIN releves ON releves.id_point_suivi = points_de_suivis.id_point_suivi
* JOIN obs_especes ON releves.id_releve = obs_especes.id_releve
* JOIN taxref ON obs_especes.cd_ref = taxref.cd_nom::text
*
* -- Filtrage sur les observations d'odonates
* WHERE obs_especes.code_thematique = 'odonates'::text
*
* GROUP BY
* […]
* taxref.cd_ref,
* taxref.nom_complet,
* taxref.rang,
* ("left"(releves.date::text, 4)),
* taxref.cd_taxsup
* )
*
* (Source : base issue du script RhoMéO_Geomatys.backup)
*
* @param statements
* @return
* @throws IntrospectionException
*/
protected Map<Integer, Set<Integer>> t4(final Iterable<OdonataStatement> statements, final TaxonOperator operator) throws IntrospectionException, ReflectiveOperationException {
final Map<Integer, Set<Integer>> observedSpeciesByYear = new HashMap<>();
final Function<Integer, Set<Integer>> creator = input -> new HashSet<>();
for (final OdonataStatement statement : statements) {
final Integer taxref = operator.getCdRef(statement.getCd_nom());
// "INNER JOIN" taxref
if (taxref != null) {
observedSpeciesByYear.computeIfAbsent(statement.getDate().getYear(), creator).add(taxref);
}
}
return observedSpeciesByYear;
}
/**
* Get the {@link OdonataHabitatReference#cd_ref}s present in the result of
* {@link I10#t1(java.lang.Iterable, fr.cenra.rhomeo.api.data.Site) }.
*
* @param t1 Result of {@link I10#t1(java.lang.Iterable, fr.cenra.rhomeo.api.data.Site) }.
* @return
*
* @see I10#t1(java.lang.Iterable, fr.cenra.rhomeo.api.data.Site)
*/
protected static Set<Integer> getCdRefs(final Map<Integer, Set<OdonataHabitatReference>> t1){
// Must be a set to avoid duplicated.
final Set<Integer> result = new HashSet<>();
for(final Collection<OdonataHabitatReference> set : t1.values()){
for(final OdonataHabitatReference ref : set){
result.add(ref.getCd_ref());
}
}
return result;
}
/**
* Number of observed {@link T4ObservedSpecies} among expected {@link OdonataHabitatReference} by year.
*
* t3 AS (
*
* -- Récupération de l'espèce des odonates observés (on remonte à cd_taxsup pour les sous-espèces de manière à avoir l'espèce)
* WITH t4 AS (
*
* SELECT
* […]
* CASE
* WHEN taxref.rang = 'SSES'::text THEN taxref.cd_taxsup::text
* ELSE taxref.cd_ref::text
* END AS cd_ref,
* taxref.nom_complet, -- group by
* […]
* "left"(releves.date::text, 4) AS annee, -- group by
* […]
*
* FROM
* […]
* JOIN points_de_suivis […]
* JOIN releves ON releves.id_point_suivi = points_de_suivis.id_point_suivi
* JOIN obs_especes ON releves.id_releve = obs_especes.id_releve
* JOIN taxref ON obs_especes.cd_ref = taxref.cd_nom::text
*
* -- Filtrage sur les observations d'odonates
* WHERE obs_especes.code_thematique = 'odonates'::text
*
* GROUP BY
* […]
* taxref.cd_ref,
* taxref.nom_complet,
* taxref.rang,
* ("left"(releves.date::text, 4)),
* taxref.cd_taxsup
* )
*
*
* -- On compte le nombre d'espèces observées qui étaient attendues
* SELECT
* […]
* t4.annee, -- group by
* count(DISTINCT t4.nom_complet) AS nb_sp_vues
*
* FROM t4
* -- Jointure sur l'espèce entre les habitats odonates observés et attendus
* JOIN t1 ON […] AND t1.cd_ref::text = t4.cd_ref
*
* GROUP BY
* […]
* t4.annee
* […]
* )
*
* @param t1 Result of {@link I10#t1(java.lang.Iterable, fr.cenra.rhomeo.api.data.Site) }.
* @param t4 Result of {@link I10#t4(java.lang.Iterable) }.
* @return
*
* @see I10#t1(java.lang.Iterable, fr.cenra.rhomeo.api.data.Site)
* @see I10#t4(java.lang.Iterable)
*/
static Map<Integer, Integer> t3(final Map<Integer, Set<OdonataHabitatReference>> t1,
final Map<Integer, Set<Integer>> t4){
final Map<Integer, Integer> result = new HashMap<>();
final Set<Integer> expectedCdRefs = getCdRefs(t1);
// For each year of observed species.
for(final Map.Entry<Integer, Set<Integer>> observedSpecies : t4.entrySet()){
final Collection<Integer> observedCol = observedSpecies.getValue();
// Must be a set to avoid duplicated.
final Set<Integer> obsRefs = new HashSet<>();
// Loop over observed species of the current year.
for(final Integer observed : observedCol){
// Get the list of "expected" for the current observed species. (i.e. "JOIN" condition)
if(expectedCdRefs.contains(observed)){
// Add "nom_complet"
obsRefs.add(observed);
}
}
// Count distinct "nom_complet" of observed
result.put(observedSpecies.getKey(), obsRefs.size());
}
return result;
}
/**
* -- Pourcentage du nombre d'espèces vues qui étaient attendues par rappor au nombre d'espèces attendues, par site et par an.
* SELECT
* […]
* t2.annee,
* […]
* round(t3.nb_sp_vues::numeric * 100::numeric / t2.nb_attendues::numeric, 2) AS pour_vues_attendues,
* […]
*
* FROM t2
* FULL JOIN […] t3.annee = t2.annee
* […]
*
* @param t2
* @param t3
* @return
*/
protected Set<Index> rate(final Map<Integer, Integer> t2, final Map<Integer, Integer> t3){
final Set<Index> indices = new HashSet<>();
for(final Integer year : t3.keySet()){
final Integer expected = t2.get(year);
// Get the nb of "expected" species (i.e. "JOIN")
if(expected!=null){
indices.add(indexSpi.createIndex(100.*(t3.get(year)/(double)t2.get(year)), year));
}
}
return indices;
}
/**
* "Group by" clause of the t2 relation.
*
* GROUP BY […] odo_dependance_habitat.espece, odo_dependance_habitat.cd_ref
*
* @param t2
* @return
*/
protected Set<Index> expectedSpecies(final Map<Integer, Integer> t2){
final Set<Index> indices = new HashSet<>();
for(final Integer year : t2.keySet()){
indices.add(nbSpeciesIndexSpi.createIndex(t2.get(year), year));
}
return indices;
}
/**
*
* Retrieves {@link List}s of pairs of {@link OdonataHabitatReference}
* and {@link OdonataDepartmentReference} indexed by habitat. The pairs are
* consistent with the given {@link Site} and consistent each other.
*
* In case no consistent pair is found, returns an empty {@link Optional}.
*
* @param habitat
* @param site
* @return
* @throws IntrospectionException
* @see I10#getConsistentReferences(fr.cenra.rhomeo.core.list.OdonateZoneBio, java.lang.String)
*/
private Map<String, Set<Map.Entry<OdonataHabitatReference, OdonataDepartmentReference>>>
getConsistentReferences(final Site site) throws IntrospectionException {
return getConsistentReferences(getOdonateZoneBio(site), site.getCountyCode());
}
/**
* -- t1 restreint les observations d'habitats d'odonates aux attentes en fonction du type d'habitat et du département
* WITH t1 AS (
*
* -- t récupère les valeurs d'habitat pour les relevés d'odonates.
* WITH t AS (
*
* SELECT
* sites.dept, -- 1 seul site / group by indirect
* sites.zbio, -- 1 seul site / group by indirect
* […]
*
* FROM sites
* […]
*
* GROUP BY
* sites.id_site,
* […]
* )
*
* - récupère la valeur minimale de l'habitat de l'espèce en filtrant sur les valeurs de présence par département et sur la valeur d'habitat
* -- il s'avère que la valeur minimale semble inutilisée : ce sont les espèces filtrées qui sont utilisées
* SELECT
* t.dept, -- group by site
* […]
* t.zbio, -- group by site
* […]
* odo_dependance_habitat.cd_ref, -- group by
* […]
* FROM t,
* odo_dependance_habitat,
* odo_especes_par_dept
*
* WHERE
*
* AND t.dept = odo_especes_par_dept.id_dept::text -- jointure -> odo_especes_par_dept
* AND t.zbio = odo_dependance_habitat.zbio::text -- jointure -> odo_dependance_habitat
* […]
* AND odo_dependance_habitat.cd_ref = odo_especes_par_dept.cd_ref -- jointure odo_dependance_habitat <-> odo_especes_par_dept pour être cohérent au niveau espèce.
* […]
* )
*
*
* =========================================================================
* Note on the following "skipped" join :
*
* AND t.habitat = odo_dependance_habitat.habitat::text -- jointure -> odo_dependance_habitat
*
* This method skip the following "JOIN", because t.habitat comes from
* statements. So, in order to get all references only once by dataset,
* this "JOIN" has to be made after the method has been called.
*
*
* @param zoneBio
* @param id_dept
* @return
* @throws IntrospectionException
* @see I10#getConsistentReferences(fr.cenra.rhomeo.api.data.Site)
*/
protected Map<String, Set<Map.Entry<OdonataHabitatReference, OdonataDepartmentReference>>>
getConsistentReferences(final OdonateZoneBio zoneBio, final String id_dept) throws IntrospectionException {
// Get the habitat references for the biozone of the site. ("JOIN" t.zbio = odo_dependance_habitat.zbio::text)
final Map<String, Set<OdonataHabitatReference>> habReferences = getHabitatReferences(zoneBio);
// Get the department references for the department of the site. ("JOIN" t.dept = odo_especes_par_dept.id_dept::text)
final Map<Integer, Set<OdonataDepartmentReference>> deptReferences = getDepartmentReferences(id_dept);
// Prepare the structure lists of consistent combinations of habitat references and department references, indexed by habitat.
final Map<String, Set<Map.Entry<OdonataHabitatReference, OdonataDepartmentReference>>> consistent = new HashMap<>();
// Loop over the habitat references.
for(final Map.Entry<String, Set<OdonataHabitatReference>> habRefs : habReferences.entrySet()){
// Create the consistent list of consistent pairs for the current habitat
final Set<Map.Entry<OdonataHabitatReference, OdonataDepartmentReference>> cl = new HashSet<>();
// Loop over habitat references of the current habitat
for(final OdonataHabitatReference habReference : habRefs.getValue()){
// Get the department references of the species for the current habitat reference, of the current habitat.
// ("JOIN" odo_dependance_habitat.cd_ref = odo_especes_par_dept.cd_ref)
final Collection<OdonataDepartmentReference> deptRefs = deptReferences.get(habReference.getCd_ref());
if(deptRefs!=null){
// Loop over department references to create consistent pairs.
for(final OdonataDepartmentReference deptReference : deptRefs){
cl.add(new AbstractMap.SimpleImmutableEntry(habReference, deptReference));
}
}
}
consistent.put(habRefs.getKey(), cl);
}
return consistent;
}
/**
* Retrieves {@link Set}s of {@link OdonataHabitatReference}s, indexed by
* {@link OdonataHabitatReference#habitat}, for a given {@link OdonateZoneBio}.
*
* The values of the result {@link Map} are {@link Collection}s because
* {@link OdonataHabitatReference#habitat} is not a primary key of
* {@link OdonataHabitatReference}s. So, it is possible to retrive several
* {@link OdonataHabitatReference}s for a given {@link OdonataHabitatReference#habitat},
* (which have different {@link OdonataHabitatReference#cd_nom}). Note that,
* on the contrary, {@link OdonataHabitatReference#zbio} is fixed because of
* the method paramater.
*
* @param zonebio
* @return The values of {@link OdonataHabitatReference} for species which
* {@link OdonataHabitatReference#zbio} is given as a parameter, indexed by
* their {@link OdonataHabitatReference#habitat}.
* @throws IntrospectionException
*/
protected Map<String, Set<OdonataHabitatReference>> getHabitatReferences(final OdonateZoneBio zonebio) throws IntrospectionException {
// Get habitat references.
final List<OdonataHabitatReference> references = getReferences(habitatReferenceDescription);
// Prepare the result structure.
final Map<String, Set<OdonataHabitatReference>> result = new HashMap<>();
final Function<String, Set<OdonataHabitatReference>> creator = input -> new HashSet<>();
// Loop over habitat references.
for (final OdonataHabitatReference reference : references) {
if (zonebio.getZbio().equals(reference.getZbio())) {
result.computeIfAbsent(reference.getHabitat(), creator).add(reference);
}
}
return result;
}
/**
* Retrieves {@link Set}s of {@link OdonataDepartmentReference}s, indexed by
* {@link OdonataDepartmentReference#cd_ref}, for a given department id.
*
* The values of the result {@link Map} are {@link Collection}s because
* {@link OdonataDepartmentReference#cd_ref} is not a primary key of
* {@link OdonataDepartmentReference}s. So, it is theoretically possible to retrive several
* {@link OdonataDepartmentReference}s for a given {@link OdonataDepartmentReference#cd_ref},
* (which have different {@link OdonataDepartmentReference#cd_nom}). Note that,
* on the contrary, {@link OdonataDepartmentReference#id_dept} is fixed because of
* the method paramater.
*
* @param id_dept
* @return The values of {@link OdonataDepartmentReference} for species
* which {@link OdonataDepartmentReference#id_dept} is given as a parameter,
* indexed by their {@link OdonataDepartmentReference#cd_ref}.
* @throws IntrospectionException
*/
protected Map<Integer, Set<OdonataDepartmentReference>> getDepartmentReferences(final String id_dept) throws IntrospectionException {
// Get department references.
final List<OdonataDepartmentReference> references = getReferences(departmentReferenceDescription);
// Prepare the result structure.
final Map<Integer, Set<OdonataDepartmentReference>> result = new HashMap<>();
// Loop over departement refenreces.
for (final OdonataDepartmentReference reference : references) {
if (id_dept.equals(reference.getId_dept())) {
if(result.get(reference.getCd_ref())==null){
result.put(reference.getCd_ref(), new HashSet<>());
}
result.get(reference.getCd_ref()).add(reference);
}
}
return result;
}
private class I10Process extends Process {
final TaxonOperator<OdonataStatement> operator;
private I10Process(final TaxonOperator operator) {
super(operator.getProcessContext());
this.operator = operator;
}
@Override
public Indicator getIndicator() {
return I10.this;
}
@Override
protected Set<? extends Index> call() throws Exception {
updateTitle("Calcul ".concat(I10.this.getTitle()));
final long totalProgress = 8;
long progress = 0;
updateMessage("Analyse du site");
updateProgress(progress++, totalProgress);
if (ctx.getDataCtx() == null)
throw new IllegalStateException("The data context must not be null.");
else if (ctx.getDataCtx().getSite() == null)
throw new IllegalStateException("The data context must specify a site.");
else if (ctx.getDataCtx().getSite().getOdonateType() == null)
throw new IllegalStateException("The site of the data context must specify an type of odonata bio zone.");
final Site site = ctx.getDataCtx().getSite();
// Get the orthoptere biozone of the site
final OdonateZoneBio siteBioZone = getOdonateZoneBio(site);
if (siteBioZone == null) {
throw new RhomeoRuntimeException("The odonata type of current site cannot be converted to an odonata biozone.");
}
final Iterable<OdonataStatement> statements = operator.getProcessData();
/*
0- Preliminary calculus.
======================*/
updateMessage("Discrimination des espèces");
updateProgress(progress++, totalProgress);
final Map<Integer, Set<OdonataHabitatReference>> t1 = t1(statements, site);
updateMessage("Regroupement des espèces observées par année");
updateProgress(progress++, totalProgress);
final Map<Integer, Set<Integer>> t4 = t4(statements, operator);
/*
1- Loop over statements to compute numbers of observed species, by year.
======================================================================*/
updateMessage("Somme des observations annuelles");
updateProgress(progress++, totalProgress);
final Map<Integer, Integer> observedSumByYear = t3(t1, t4);
/*
2- Loop over indicators to compute number of expected species among observed, by year.
====================================================================================*/
updateMessage("Calcul des sommes annuelles de référence");
updateProgress(progress++, totalProgress);
final Map<Integer, Integer> expectedSumByYear = t2(t1);
/*
4- Compute indices.
=================*/
updateMessage("Calcul d'intégrité de population");
updateProgress(progress++, totalProgress);
final Set<Index> indices = rate(expectedSumByYear, observedSumByYear);
updateMessage("Calcul des espèces attendues");
updateProgress(progress++, totalProgress);
indices.addAll(expectedSpecies(expectedSumByYear));
updateMessage("Calcul du niveau d'autochtonie");
updateProgress(progress, totalProgress);
indices.addAll(BehaviorCoverageValidator.computeBehaviorIndices(ctx, operator, behaviorSpi));
return indices;
}
}
}

Some files were not shown because too many files have changed in this diff Show More