use of org.eol.globi.geo.EcoregionFinderException in project eol-globi-data by jhpoelen.
the class NodeFactoryNeo4j method associateWithEcoRegions.
private List<Ecoregion> associateWithEcoRegions(Location location) throws NodeFactoryException {
List<Ecoregion> associatedEcoregions = new ArrayList<Ecoregion>();
try {
EcoregionFinder finder = getEcoregionFinder();
if (finder != null) {
Collection<Ecoregion> ecoregions = finder.findEcoregion(location.getLatitude(), location.getLongitude());
for (Ecoregion ecoregion : ecoregions) {
associateLocationWithEcoRegion(location, ecoregion);
associatedEcoregions.add(ecoregion);
}
}
} catch (EcoregionFinderException e) {
throw new NodeFactoryException("problem finding eco region for location (lat,lng):(" + location.getLatitude() + "," + location.getLongitude() + ")");
}
return associatedEcoregions;
}
use of org.eol.globi.geo.EcoregionFinderException in project eol-globi-data by jhpoelen.
the class NormalizerTest method createNormalizer.
private Normalizer createNormalizer() {
Normalizer dataNormalizationTool = new Normalizer();
dataNormalizationTool.setEcoregionFinder(new EcoregionFinder() {
@Override
public Collection<Ecoregion> findEcoregion(double lat, double lng) throws EcoregionFinderException {
final Ecoregion ecoregion = new Ecoregion();
ecoregion.setName("some name");
ecoregion.setPath("some | path");
ecoregion.setId("someId");
ecoregion.setGeometry("POINT(1,2)");
return new ArrayList<Ecoregion>() {
{
add(ecoregion);
}
};
}
@Override
public void shutdown() {
}
});
return dataNormalizationTool;
}
use of org.eol.globi.geo.EcoregionFinderException in project eol-globi-data by jhpoelen.
the class GraphDBTestCase method createNodeFactory.
NodeFactory createNodeFactory() {
NodeFactoryNeo4j nodeFactoryNeo4j = new NodeFactoryNeo4j(getGraphDb());
nodeFactoryNeo4j.setEcoregionFinder(new EcoregionFinder() {
@Override
public Collection<Ecoregion> findEcoregion(double lat, double lng) throws EcoregionFinderException {
final Ecoregion ecoregion = new Ecoregion();
ecoregion.setName("some eco region");
ecoregion.setPath("some | eco | region | path");
ecoregion.setId("some:id");
ecoregion.setGeometry("POINT(0,0)");
return new ArrayList<Ecoregion>() {
{
add(ecoregion);
}
};
}
@Override
public void shutdown() {
}
});
nodeFactoryNeo4j.setEnvoLookupService(getEnvoLookupService());
nodeFactoryNeo4j.setTermLookupService(getTermLookupService());
return nodeFactoryNeo4j;
}
Aggregations