Skip to content

Commit

Permalink
Provide an option to allow "invalid" polygon generation
Browse files Browse the repository at this point in the history
SMAP footprint polygons are technically invalid when they cross the
antimeridian. Such polygons should probably be split, but all
past SMAP data has been processed as single, invalid polygons where
there was an antimeridian crossing. For consistency, an option has
been added for allowing the invalid polygons to pass the validity
check.

Testing has show that CMR, as well as a number of visualization
tools, properly account for the antimeridian crossing even with
invalid polygons.
  • Loading branch information
colecu committed Feb 10, 2024
1 parent 5160a1e commit a15ad9b
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,9 @@ public JSONObject line2Polygons(JSONObject geometry, String line) {
// use the original coordinate array instead of splittedGeos.get(0)
// for the original coordinate array is "un-damaged
polygons.add(coordinates);
geometry = addPolygons(geometry, polygons);

boolean addInvalidPolygons = (this.granule.getIsoType() == IsoType.SMAP);
geometry = addPolygons(geometry, polygons, addInvalidPolygons);
} else if (dividedSize == 2) {
// dont know how to process. Create global bounding box
AdapterLogger.LogError(this.className + " split divided to more than 2 geos. Creating global bounding box");
Expand Down Expand Up @@ -795,6 +797,10 @@ public JSONObject addGlobalBoundingBox2Geometry(JSONObject geometry) {
}

public JSONObject addPolygons(JSONObject geometry, ArrayList<ArrayList<Coordinate>> inputPolygons) {
return addPolygons(geometry, inputPolygons, false);
}

public JSONObject addPolygons(JSONObject geometry, ArrayList<ArrayList<Coordinate>> inputPolygons, boolean addInvalid) {
JSONArray polygons = new JSONArray();
geometry.put("GPolygons", polygons);
GeometryFactory geometryFactory = new GeometryFactory();
Expand All @@ -812,7 +818,7 @@ public JSONObject addPolygons(JSONObject geometry, ArrayList<ArrayList<Coordinat
);

// valid polygon by vividsolution again
if(polygon.isValid()) {
if(polygon.isValid() || addInvalid) {
JSONObject gPolygon = new JSONObject();
JSONObject boundary = new JSONObject();
gPolygon.put("Boundary", boundary);
Expand Down

0 comments on commit a15ad9b

Please sign in to comment.