Union of SphericalPolygonsSet

Hi all,

I’m using orekit 12.1.2.
I am trying to obtain a SphericalPolygonsSet that is the union of 2 SphericalPolygonsSet.
The input SphericalPolygonsSet are 2 areas not touching each other. I obtain an empty union result: the tree attribute has null cut and the size is 0.
Even with the last version of orekit, I obtain same results.
Here an example of a code that generates an empty union result.

 double points1[][] = new double[][]{
            { 0,0 },
            { 10,0 },
            { 10,10 },
            { 0,10 },
            { 0,0 }
    };
    final S2Point[] vertices1 = new S2Point[5];
    for (int i = 0; i < 5; ++i) {
        vertices1[i] = new S2Point(FastMath.toRadians(points1[i][1]),         
                FastMath.toRadians(90.0 - points1[i][0])); 
    }
    SphericalPolygonsSet spher1 = new SphericalPolygonsSet(1e-10, vertices1);

    double points2[][] = new double[][]{
            { 20,20 },
            { 30,20 },
            { 30,30 },
            { 20,30 },
            { 20,20 }
    };
    final S2Point[] vertices2 = new S2Point[points2.length];
    for (int i = 0; i < points2.length; ++i) {
        vertices2[i] = new S2Point(FastMath.toRadians(points2[i][1]),         // points[i][1] is longitude
                FastMath.toRadians(90.0 - points2[i][0])); // points[i][0] is latitude
    }
    SphericalPolygonsSet spher2 = new SphericalPolygonsSet(1e-10, vertices2);
    SphericalPolygonsSet unionSpher = (SphericalPolygonsSet) new RegionFactory<Sphere2D>().union(spher1, spher2);

Could someone please report a working code for SphericalPolygonsSet union?
Thanks in advance

Hi @Spugna,

Welcome to the forum !

There are working examples in SphericalPoylgonsSetTest.
For example the test testGeographicalMap.
I’m not sure you need to repeat the first point as the last one of your arrays (e.g. 0,0 for the first polygon).

Hope this helps,
Maxime