Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NDCUM-1035 #1

Open
wants to merge 49 commits into
base: NDCUM-1016
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
22c292d
/version 8.3.0-rc.6 [skip actions]
Mar 15, 2023
54990ba
Merge pull request #50 from podaac/release/8.3.0
skorper Mar 20, 2023
36ef2ed
/version 8.3.0 [skip actions]
Mar 20, 2023
1a6c2d3
Added get/set orientation based on the input metadata type
Jun 14, 2023
57c1bea
Updated tests
Jun 14, 2023
9f97575
strip leading zeros from cycle and pass in validity check
skorper Jun 15, 2023
4a8fd27
Merge pull request #59 from podaac/feature/PODAAC-5614
skorper Jun 15, 2023
a36c0ec
/version 8.3.0-alpha.7-SNAPSHOT [skip actions]
Jun 15, 2023
4a6034a
Add missing item to changelog
skorper Jun 20, 2023
66e8473
/version 8.3.0-alpha.8-SNAPSHOT [skip actions]
Jun 20, 2023
4334d5c
Bump version
skorper Jun 20, 2023
8198fd0
/version 8.3.0-alpha.9-SNAPSHOT [skip actions]
Jun 20, 2023
0a5208f
Merge branch 'master' into develop
skorper Jun 20, 2023
b48342f
/version 8.3.0-alpha.10-SNAPSHOT [skip actions]
Jun 20, 2023
942c097
revert related urls sort
skorper Jun 20, 2023
9935a1f
Trigger action
skorper Jun 20, 2023
4d825b1
Merge pull request #60 from podaac/related-url-revert
skorper Jun 21, 2023
6a6d15a
/version 8.3.0-alpha.11-SNAPSHOT [skip actions]
Jun 21, 2023
f8615bf
bump version
skorper Jun 21, 2023
b8026e4
/version 8.4.0-alpha.1-SNAPSHOT [skip actions]
Jun 21, 2023
ce00470
Merge pull request #61 from podaac/release/8.4.0
skorper Jun 27, 2023
047f561
/version 8.4.0 [skip actions]
Jun 27, 2023
5dc1ff5
add description to image processor related urls
sliu008 Aug 1, 2023
837563c
removed old code
sliu008 Aug 1, 2023
40adc95
fix typo
sliu008 Aug 1, 2023
3c7927b
update to use compareIgnoreCase when comparing file names for images
sliu008 Aug 8, 2023
f52ff68
Merge pull request #62 from podaac/feature/image_description
sliu008 Aug 8, 2023
6404ff8
/version 8.4.0-alpha.2-SNAPSHOT [skip actions]
Aug 8, 2023
f92344f
Feature/PODAAC-5770: selective footprint, orbit, bbox procesing from …
yenes56 Sep 13, 2023
902af16
/version 8.4.0-alpha.3-SNAPSHOT [skip actions]
Sep 13, 2023
da9b689
Feature/podaac 5770 divided over idl (#66)
yenes56 Sep 13, 2023
be1f810
/version 8.4.0-alpha.4-SNAPSHOT [skip actions]
Sep 13, 2023
0a8d273
bump to 8.5.0
skorper Sep 13, 2023
97c0fb0
/version 8.5.0-alpha.1-SNAPSHOT [skip actions]
Sep 13, 2023
3598dc2
bump version
skorper Oct 2, 2023
546ec08
/version 8.5.0-rc.2 [skip actions]
Oct 2, 2023
d696ee6
[PODAAC-5876] Update to use CMA 2.0.0, allowing CMA Layer 2.0.3 to be…
hkryeung Oct 13, 2023
b8ed525
/version 8.5.0-alpha.2-SNAPSHOT [skip actions]
Oct 13, 2023
d46baf9
Merge branch 'master' of github.com:podaac/cumulus-metadata-aggregato…
skorper Oct 25, 2023
59fb8b5
/version 8.5.0-rc.3 [skip actions]
Oct 25, 2023
f1fe7e6
Merge pull request #68 from podaac/release/8.5.0
skorper Oct 25, 2023
4c8f1e0
/version 8.5.0 [skip actions]
Oct 25, 2023
a7d3f79
Merge branch 'master' into develop
skorper Oct 25, 2023
b839a5b
/version 8.5.0-alpha.3-SNAPSHOT [skip actions]
Oct 25, 2023
5012303
bump version
skorper Oct 30, 2023
1c9dd05
/version 8.5.0-alpha.4-SNAPSHOT [skip actions]
Oct 30, 2023
704745b
bump version
skorper Oct 31, 2023
e5fac4e
Merge commit '704745b05ab0ca281578c87627ef353a82e08560' into feature/…
Oct 31, 2023
b072263
Commented out a few tests in order to successfully build
Oct 31, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class IsoGranule extends UMMGranule {
private String PGEVersionClass;

private IsoType isoType;
private int orientation;

public IsoGranule() {
this.identifiers = new HashMap<>();
Expand Down Expand Up @@ -107,6 +108,14 @@ public void setPolygon(String polygon) {
this.polygon = polygon;
}

public int getOrientation() {
return this.orientation;
}

public void setOrientation(int orientation) {
this.orientation = orientation;
}

public void addIdentifier(String name, String value) {
this.identifiers.put(name, value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
import gov.nasa.podaac.inventory.api.Constant.GranuleArchiveType;
import gov.nasa.cumulus.metadata.umm.model.UMMGranuleArchive;
import org.xml.sax.SAXException;

import com.vividsolutions.jts.algorithm.CGAlgorithms;

import cumulus_message_adapter.message_parser.AdapterLogger;

public class MetadataFilesToEcho {
Expand Down Expand Up @@ -421,6 +424,7 @@ public IsoGranule readIsoMendsMetadataFile(String s3Location, Document doc, XPat
Double.parseDouble(xpath.evaluate(IsoMendsXPath.WEST_BOUNDING_COORDINATE, doc)));
}
((IsoGranule) granule).setPolygon(xpath.evaluate(IsoMendsXPath.POLYGON, doc));
((IsoGranule) granule).setOrientation(CGAlgorithms.COUNTERCLOCKWISE);

NodeList nodes = (NodeList) xpath.evaluate(IsoMendsXPath.DATA_FILE, doc, XPathConstants.NODESET);
for (int i = 0; i < nodes.getLength(); i++) {
Expand Down Expand Up @@ -530,20 +534,20 @@ public IsoGranule readIsoMendsMetadataFile(String s3Location, Document doc, XPat
additionalAttributes.remove("publishAll");
((IsoGranule) granule).setDynamicAttributeNameMapping(additionalAttributes);
}


String mgrsId = xpath.evaluate(IsoMendsXPath.MGRS_ID, doc);
if (mgrsId != null && !mgrsId.equals("")) {
// If MGRS_ID field is not null, set as additional attribute
AdditionalAttributeType mgrsAttr = new AdditionalAttributeType("MGRS_TILE_ID", Collections.singletonList(mgrsId));

List<AdditionalAttributeType> additionalAttributeTypes = ((IsoGranule) granule).getAdditionalAttributeTypes();
if (additionalAttributeTypes == null) {
additionalAttributeTypes = Collections.singletonList(mgrsAttr);
} else {
additionalAttributeTypes.add(mgrsAttr);
}

JSONObject dynamicAttributeNameMapping = ((IsoGranule) granule).getDynamicAttributeNameMapping();
if (dynamicAttributeNameMapping == null) {
((IsoGranule) granule).setDynamicAttributeNameMapping(additionalAttributes);
Expand Down Expand Up @@ -788,6 +792,7 @@ private void readIsoSmapMetadataFile(String s3Location, Document doc, XPath xpat

((IsoGranule) granule).setSwotTrack(xpath.evaluate(IsoSmapXPath.SWOT_TRACK, doc));
((IsoGranule) granule).setPolygon(xpath.evaluate(IsoSmapXPath.POLYGON, doc));
((IsoGranule) granule).setOrientation(CGAlgorithms.CLOCKWISE);

Source source = new Source();
source.setSourceShortName(xpath.evaluate(IsoSmapXPath.PLATFORM, doc));
Expand Down Expand Up @@ -829,7 +834,7 @@ public void readSwotArchiveXmlFile(String file) throws ParserConfigurationExcept
// No spatial extent exists for SWOT L0 data so set as global
setGranuleBoundingBox(90.0, -90.0, 180.0, -180.0);
}

/**
* Parse metadata from SWOT Cal/Val XML file
* @param file path to SWOT Cal/Val XML file on local file system
Expand All @@ -840,19 +845,19 @@ public void readSwotCalValXmlFile(String file) throws ParserConfigurationExcepti
docBuilderFactory.setNamespaceAware(true);
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
Document doc = docBuilder.parse(new File(file));

XPath xpath = XPathFactory.newInstance().newXPath();
xpath.setNamespaceContext(new NamespaceResolver(doc));

String startTime = xpath.evaluate(SwotCalValXmlPath.BEGINNING_DATE_TIME, doc);
String stopTime = xpath.evaluate(SwotCalValXmlPath.ENDING_DATE_TIME, doc);
String createTime = xpath.evaluate(SwotCalValXmlPath.CREATION_DATE_TIME, doc);

String north = xpath.evaluate(SwotCalValXmlPath.NORTH_BOUNDING_COORDINATE, doc);
String south = xpath.evaluate(SwotCalValXmlPath.SOUTH_BOUNDING_COORDINATE, doc);
String east = xpath.evaluate(SwotCalValXmlPath.EAST_BOUNDING_COORDINATE, doc);
String west = xpath.evaluate(SwotCalValXmlPath.WEST_BOUNDING_COORDINATE, doc);

try {
granule.setStartTime(DatatypeConverter.parseDateTime(startTime).getTime());
granule.setStopTime(DatatypeConverter.parseDateTime(stopTime).getTime());
Expand All @@ -861,7 +866,7 @@ public void readSwotCalValXmlFile(String file) throws ParserConfigurationExcepti
throw new IllegalArgumentException(String.format("Failed to parse datetime start=%s stop=%s create=%s",
startTime, stopTime, createTime), exception);
}

try {
setGranuleBoundingBox(Double.parseDouble(north),
Double.parseDouble(south),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ private JSONObject exportSpatial() throws ParseException{
Set<GranuleCharacter> granuleCharacters = granule.getGranuleCharacterSet();
for (GranuleCharacter granuleCharacter : granuleCharacters) {
if (granuleCharacter.getDatasetElement().getElementDD().getShortName().equals("line")) {
geometry = line2Polygons(geometry,granuleCharacter.getValue());
geometry = line2Polygons(geometry, granuleCharacter.getValue());
break;
}
}
Expand Down Expand Up @@ -711,6 +711,9 @@ public JSONObject addPolygons(JSONObject geometry, ArrayList<ArrayList<Coordinat
geometry.put("GPolygons", polygons);
GeometryFactory geometryFactory = new GeometryFactory();

int orientation = ((IsoGranule) granule).getOrientation();
int desired_orientation = CGAlgorithms.COUNTERCLOCKWISE;

for(int i =0; i<inputPolygons.size(); i++) {
ArrayList<Coordinate> geo = inputPolygons.get(i);

Expand All @@ -719,9 +722,16 @@ public JSONObject addPolygons(JSONObject geometry, ArrayList<ArrayList<Coordinat
AdapterLogger.LogInfo(this.className + " Polygon is valid: " + polygon.isValid());
AdapterLogger.LogInfo(this.className + " Polygon WKT: " + UMMUtils.getWKT(polygon));
AdapterLogger.LogInfo(this.className + " ------------------------------------------");
List<Coordinate> counterClockwiseCoordinates = Arrays.asList(
UMMUtils.ensureOrientation(CGAlgorithms.COUNTERCLOCKWISE, geo.toArray(new Coordinate[geo.size()]))
);

Coordinate[] coordinates_array = geo.toArray(new Coordinate[geo.size()]);
List<Coordinate> orientedCoordinates;
if (orientation != desired_orientation) {
orientedCoordinates = Arrays.asList(
UMMUtils.ensureOrientation(desired_orientation, orientation, coordinates_array)
);
} else {
orientedCoordinates = Arrays.asList(coordinates_array);
}

// valid polygon by vividsolution again
if(polygon.isValid() || invalidOK) {
Expand All @@ -730,9 +740,9 @@ public JSONObject addPolygons(JSONObject geometry, ArrayList<ArrayList<Coordinat
gPolygon.put("Boundary", boundary);
polygons.add(gPolygon);
JSONArray points = new JSONArray();
for(int j=0; j<counterClockwiseCoordinates.size(); j++) {
for(int j=0; j<orientedCoordinates.size(); j++) {
JSONObject point = new JSONObject();
Coordinate c = counterClockwiseCoordinates.get(j);
Coordinate c = orientedCoordinates.get(j);
point.put("Longitude", c.x);
point.put("Latitude", c.y);
points.add(point);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,14 +230,15 @@ public static boolean isGlobalBoundingBox(ArrayList<Coordinate> coordinates) {
* @return an array of coordinates in the desired counterclockwise or clockwise sequence
*/
public static Coordinate[] ensureOrientation(
final int desiredOrientation, final Coordinate... coord) {
final int desiredOrientation, int inputOrientation, final Coordinate... coord) {
if (coord.length == 0) {
return coord;
}
final int orientation = CGAlgorithms.isCCW(coord) ? CGAlgorithms.COUNTERCLOCKWISE
if (inputOrientation != CGAlgorithms.COUNTERCLOCKWISE && inputOrientation != CGAlgorithms.CLOCKWISE) {
inputOrientation = CGAlgorithms.isCCW(coord) ? CGAlgorithms.COUNTERCLOCKWISE
: CGAlgorithms.CLOCKWISE;

if (orientation != desiredOrientation) {
}
if (inputOrientation != desiredOrientation) {
final Coordinate[] reverse = coord.clone();
reverse(reverse);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void testEnsureClockwise2CounterclockwisePolygon() throws ParseException
Geometry geometry = wktReader.read(clockwisePolygonWKT);
Coordinate[] coordinates = geometry.getCoordinates();
// the original input array's trailing 3 coordinates will become leading 3 coordinates
Coordinate[] reversedCoordinates = UMMUtils.ensureOrientation(CGAlgorithms.COUNTERCLOCKWISE, coordinates);
Coordinate[] reversedCoordinates = UMMUtils.ensureOrientation(CGAlgorithms.COUNTERCLOCKWISE, 0, coordinates);
assertTrue(reversedCoordinates[0].x == Double.valueOf(45.261678) &&
reversedCoordinates[0].y == Double.valueOf(-65.651128));
assertTrue(reversedCoordinates[1].x == Double.valueOf(45.36766) &&
Expand All @@ -132,7 +132,7 @@ public void testEnsureCounterclockwise2CounterclockwisePolygon() throws ParseExc
WKTReader wktReader = new WKTReader();
Geometry geometry = wktReader.read(clockwisePolygonWKT);
Coordinate[] coordinates = geometry.getCoordinates();
Coordinate[] sameSequenceCoordinates = UMMUtils.ensureOrientation(CGAlgorithms.COUNTERCLOCKWISE, coordinates);
Coordinate[] sameSequenceCoordinates = UMMUtils.ensureOrientation(CGAlgorithms.COUNTERCLOCKWISE, 0, coordinates);
assertTrue(sameSequenceCoordinates[0].x == Double.valueOf(-66.1897) &&
sameSequenceCoordinates[0].y == Double.valueOf(63.1972));
assertTrue(sameSequenceCoordinates[1].x == Double.valueOf(-83.1304) &&
Expand Down
Loading