Skip to content
Snippets Groups Projects
Commit 5444aa5a authored by Tor-Einar Skog's avatar Tor-Einar Skog
Browse files

Added some methods, fixed a bug

parent 02b9820e
Branches
Tags
No related merge requests found
......@@ -252,4 +252,19 @@ public class GISUtil {
};
return gf.createPolygon(coords);
}
public Coordinate convertCoordinate(Coordinate coordinate, String fromProjection, String toProjection)
{
try
{
CoordinateReferenceSystem fromCRS = CRS.decode(fromProjection);
CoordinateReferenceSystem toCRS = CRS.decode(toProjection);
MathTransform transform = CRS.findMathTransform(fromCRS, toCRS, true);
return (Coordinate) JTS.transform(coordinate, new Coordinate(), transform);
}
catch(FactoryException | TransformException ex)
{
return null;
}
}
}
......@@ -21,6 +21,7 @@ package no.nibio.vips.util;
import java.util.Date;
import java.util.List;
import java.util.Optional;
import java.util.OptionalLong;
/**
......@@ -71,6 +72,12 @@ public class DateTimeInterval {
return min.isPresent() ? new Date(min.getAsLong()) : null;
}
public static Boolean isDateInIntervals(Date aDate, List<DateTimeInterval> intervals)
{
Optional<DateTimeInterval> interval = intervals.stream().filter(i -> i != null && i.isDateInInterval(aDate)).findFirst();
return interval.isPresent();
}
/**
* @return the start
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment