Hello,
my objective is to detect the entries and exits of the field of view on the main continents.
So I have a list of polygons which I create from a geojson file I got and I try to union them to have one and then use the FootprintOverlapDetector to detect them but it seems like it cannot make it work.
I’ve seen on another topic that this shouldn’t work with a lot of data points so there’s only 348.
I’m getting nullpointer on the creation of the FootPrintOverlapDetector, I’ve tried to create the polygons in different ways but it always results with the same issue. I can say for sure that when creating only one SphericalPolygonSet (4 points) I have no issue.
Frame earthFrame = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
OneAxisEllipsoid earth = new OneAxisEllipsoid(
WGS84_EARTH_EQUATORIAL_RADIUS,
WGS84_EARTH_FLATTENING,
earthFrame);
Frame satelliteFrame = FramesFactory.getGCRF();
AttitudeProvider pointing = new NadirPointing(satelliteFrame, earth);
SimpleDateFormat sdf =
new SimpleDateFormat("dd-MM-yyyy HH:mm:ss.SSS Z");
Date dateSatelliteInitialDate = sdf.parse("01-01-2021 00:00:00.000 UTC");
AbsoluteDate satelliteInitialDate =
new AbsoluteDate(dateSatelliteInitialDate, TimeScalesFactory.getUTC());
Orbit initialOrbit = new KeplerianOrbit(
EIGEN5C_EARTH_EQUATORIAL_RADIUS + 0.5 * (800e3), // 800e3 = 2*perigee
(400.1e3-400e3)/(400.1e3+400e3)), // (apogee - perigee) / (apogee + perigee)
FastMath.toRadians(90),
FastMath.toRadians(0)
FastMath.toRadians(0),
FastMath.toRadians(0),
PositionAngle.TRUE,
satelliteFrame,
satelliteInitialDate,
EIGEN5C_EARTH_MU
);
Propagator propagator = new EcksteinHechlerPropagator(
initialOrbit,
pointing,
25.0,
EIGEN5C_EARTH_EQUATORIAL_RADIUS,
EIGEN5C_EARTH_MU,
EIGEN5C_EARTH_C20,
EIGEN5C_EARTH_C30,
EIGEN5C_EARTH_C40,
EIGEN5C_EARTH_C50,
EIGEN5C_EARTH_C60
);
// this values are computed before
DoubleDihedraFieldOfView imagerFieldOfView = new DoubleDihedraFieldOfView(Vector3D.PLUS_K, Vector3D.PLUS_I, 0.02742857132361516, Vector3D.PLUS_J, 0.03428571415451895, 0);
double sampling_step = 100000. ;
double hyperplaneThickness = 1.0e-10;
FeatureCollection featureCollection = new ObjectMapper().readValue(getFileFromResourceAsStream("small_continents.geojson"), FeatureCollection.class);
SphericalPolygonsSet sphericalPolygonsSet = null;
List<GeodeticPoint> geodeticPoints = new ArrayList<>();
for (Feature feature : featureCollection.getFeatures()) {
if(feature.getGeometry() instanceof Polygon) {
for (List<LngLatAlt> coordinates : ((Polygon) feature.getGeometry()).getCoordinates()) {
for(LngLatAlt lngLatAlt : coordinates) {
geodeticPoints.add(new GeodeticPoint(FastMath.toRadians(lngLatAlt.getLatitude()), FastMath.toRadians(lngLatAlt.getLongitude()), 0));
}
}
GeodeticPoint[] geodeticPointArray = geodeticPoints.toArray(new GeodeticPoint[]{});
if(sphericalPolygonsSet == null) {
sphericalPolygonsSet = EllipsoidTessellator.buildSimpleZone(hyperplaneThickness, geodeticPointArray);
}else {
sphericalPolygonsSet = (SphericalPolygonsSet) new RegionFactory<Sphere2D>().union(sphericalPolygonsSet, EllipsoidTessellator.buildSimpleZone(hyperplaneThickness, geodeticPointArray));
}
}
}
FootprintOverlapDetector targetLandDetector = new FootprintOverlapDetector(imagerFieldOfViewArray, earth, sphericalPolygonsSet, sampling_step).withHandler((s, detector, increasing) -> {
System.out.println("hello");
return Action.CONTINUE;
});
propagator.addEventDetector(targetLandDetector);
small_continents.geojson (61.1 KB)