diff --git a/caom2-compute/build.gradle b/caom2-compute/build.gradle index c6091299..51a14f7e 100644 --- a/caom2-compute/build.gradle +++ b/caom2-compute/build.gradle @@ -14,7 +14,7 @@ sourceCompatibility = 1.8 group = 'org.opencadc' -version = '2.4.10' +version = '2.4.11' description = 'OpenCADC CAOM compute library' def git_url = 'https://github.com/opencadc/caom2' diff --git a/caom2-compute/src/main/java/ca/nrc/cadc/caom2/compute/PositionUtil.java b/caom2-compute/src/main/java/ca/nrc/cadc/caom2/compute/PositionUtil.java index 30ff8773..ca992669 100644 --- a/caom2-compute/src/main/java/ca/nrc/cadc/caom2/compute/PositionUtil.java +++ b/caom2-compute/src/main/java/ca/nrc/cadc/caom2/compute/PositionUtil.java @@ -79,6 +79,7 @@ import ca.nrc.cadc.caom2.types.Point; import ca.nrc.cadc.caom2.types.Polygon; import ca.nrc.cadc.caom2.types.SegmentType; +import ca.nrc.cadc.caom2.types.Shape; import ca.nrc.cadc.caom2.types.Vertex; import ca.nrc.cadc.caom2.wcs.CoordAxis2D; import ca.nrc.cadc.caom2.wcs.CoordBounds2D; @@ -126,11 +127,10 @@ public static Position compute(Set artifacts) Position p = new Position(); if (productType != null) { - Polygon poly = computeBounds(artifacts, productType); - p.bounds = poly; + p.bounds = computeBounds(artifacts, productType); p.dimension = computeDimensionsFromRange(artifacts, productType); if (p.dimension == null) { - p.dimension = computeDimensionsFromWCS(poly, artifacts, productType); + p.dimension = computeDimensionsFromWCS(p.bounds, artifacts, productType); } p.resolution = computeResolution(artifacts, productType); p.sampleSize = computeSampleSize(artifacts, productType); @@ -140,6 +140,48 @@ public static Position compute(Set artifacts) return p; } + public static Shape generateShape(Set artifacts, ProductType productType) + throws NoSuchKeywordException { + int num = 0; + Chunk chunk = null; + for (Artifact a : artifacts) { + log.debug("generatePolygons: " + a.getURI()); + for (Part p : a.getParts()) { + log.debug("generatePolygons: " + a.getURI() + " " + p.getName()); + for (Chunk c : p.getChunks()) { + log.debug("generatePolygons: " + a.getURI() + " " + p.getName() + " " + c.getID()); + if (Util.useChunk(a.getProductType(), p.productType, c.productType, productType)) { + log.debug("generatePolygons: " + a.getURI() + " " + + a.getProductType() + " " + p.productType + " " + c.productType); + if (c.position != null) { + num++; + chunk = c; + } + } else { + log.debug("generatePolygons SKIP: " + a.getURI() + " " + + a.getProductType() + " " + p.productType + " " + c.productType); + } + } + } + } + if (chunk == null) { + // no spatial + return null; + } + if (num > 1) { + // multiple, assume mosaic w/ polygons + return null; + } + if (chunk.position.getAxis().bounds != null) { + if (chunk.position.getAxis().bounds instanceof CoordCircle2D) { + CoordCircle2D cc = (CoordCircle2D) chunk.position.getAxis().bounds; + return new Circle(new Point(cc.getCenter().coord1, cc.getCenter().coord2), cc.getRadius()); + } + // handle CoordPolygon2D in generatePolygons + } + return null; + } + public static List generatePolygons(Set artifacts, ProductType productType) throws NoSuchKeywordException { List polys = new ArrayList(); @@ -178,31 +220,35 @@ public static List generatePolygons(Set artifacts, Produ } // TODO: change return type to Shape; if we find CoordCircle2D in the SpatialWCS we should return a Circle - public static Polygon computeBounds(Set artifacts, ProductType productType) + public static Shape computeBounds(Set artifacts, ProductType productType) throws NoSuchKeywordException { - // since we compute the union, just blindly use all the polygons - // derived from spatial wcs - List polys = generatePolygons(artifacts, productType); - if (polys.isEmpty()) { - return null; + Shape ret = generateShape(artifacts, productType); + if (ret == null) { + // since we compute the union, just blindly use all the polygons + // derived from spatial wcs + List polys = generatePolygons(artifacts, productType); + if (polys.isEmpty()) { + return null; + } + log.debug("[computeBounds] components: " + polys.size()); + MultiPolygon mp = MultiPolygon.compose(polys); + ret = PolygonUtil.getOuterHull(mp); } - log.debug("[computeBounds] components: " + polys.size()); - MultiPolygon mp = MultiPolygon.compose(polys); - Polygon poly = PolygonUtil.getOuterHull(mp); - log.debug("[computeBounds] done: " + poly); - return poly; + log.debug("[computeBounds] done: " + ret); + return ret; } // this works for mosaic camera data: multiple parts with ~single scale wcs functions - static Dimension2D computeDimensionsFromWCS(Polygon poly, Set artifacts, ProductType productType) + static Dimension2D computeDimensionsFromWCS(Shape bounds, Set artifacts, ProductType productType) throws NoSuchKeywordException { - log.debug("[computeDimensionsFromWCS] " + poly + " " + artifacts.size()); - if (poly == null) { + log.debug("[computeDimensionsFromWCS] " + bounds + " " + artifacts.size()); + if (bounds == null) { return null; } // pick the WCS with the largest pixel size SpatialWCS sw = null; + boolean foundCoordBounds = false; double scale = 0.0; int num = 0; for (Artifact a : artifacts) { @@ -216,6 +262,7 @@ static Dimension2D computeDimensionsFromWCS(Polygon poly, Set artifact scale = ss; sw = c.position; } + foundCoordBounds = foundCoordBounds || c.position.getAxis().bounds != null; } } } @@ -225,12 +272,27 @@ static Dimension2D computeDimensionsFromWCS(Polygon poly, Set artifact return null; } - if (num == 1) { // single WCS solution + if (num == 1) { // single WCS solution, ASSUME CoordBounds2D mask is whole frame // deep copy long ix = sw.getAxis().function.getDimension().naxis1; long iy = sw.getAxis().function.getDimension().naxis2; return new Dimension2D(ix, iy); } + + List points = null; + if (bounds instanceof Polygon) { + Polygon poly = (Polygon) bounds; + points = poly.getPoints(); + } else if (bounds instanceof Circle) { + Circle circ = (Circle) bounds; + MultiPolygon mp = toPolygon(circ); + points = new ArrayList<>(); + for (Vertex v : mp.getVertices()) { + if (!SegmentType.CLOSE.equals(v.getType())) { + points.add(new Point(v.cval1, v.cval2)); + } + } + } WCSWrapper map = new WCSWrapper(sw, 1, 2); Transform transform = new Transform(map); @@ -241,7 +303,7 @@ static Dimension2D computeDimensionsFromWCS(Polygon poly, Set artifact double y2 = -1 * y1; CoordSys csys = inferCoordSys(sw); List pixv = new ArrayList(); - for (Point pt : poly.getPoints()) { + for (Point pt : points) { double[] coords = new double[] {pt.cval1, pt.cval2}; if (csys.swappedAxes) { double tmp = coords[0]; @@ -491,12 +553,13 @@ static MultiPolygon toPolygon(SpatialWCS wcs, CoordPolygon2D cp) static MultiPolygon toPolygon(SpatialWCS wcs, CoordCircle2D cc) throws NoSuchKeywordException { Circle circ = new Circle(new Point(cc.getCenter().coord1, cc.getCenter().coord2), cc.getRadius()); + return toPolygon(circ); + } + + static MultiPolygon toPolygon(Circle circ) { CartesianTransform trans = CartesianTransform.getTransform(circ); - List skyCoords = new ArrayList(); + List skyCoords = new ArrayList<>(); - //if (Math.abs(cc.getCenter().coord2) + cc.getRadius() > 80.0) { // near a pole - // throw new UnsupportedOperationException("cannot convert CoordCircle2D -> MultiPolygon near the pole (" + cc + ")"); - //} Point tcen = trans.transform(circ.getCenter()); double x = tcen.cval1; double y = tcen.cval2; diff --git a/caom2-compute/src/test/java/ca/nrc/cadc/caom2/compute/PositionUtilTest.java b/caom2-compute/src/test/java/ca/nrc/cadc/caom2/compute/PositionUtilTest.java index 844e6130..885d290f 100644 --- a/caom2-compute/src/test/java/ca/nrc/cadc/caom2/compute/PositionUtilTest.java +++ b/caom2-compute/src/test/java/ca/nrc/cadc/caom2/compute/PositionUtilTest.java @@ -75,11 +75,13 @@ import ca.nrc.cadc.caom2.Plane; import ca.nrc.cadc.caom2.ProductType; import ca.nrc.cadc.caom2.ReleaseType; +import ca.nrc.cadc.caom2.types.Circle; import ca.nrc.cadc.caom2.types.IllegalPolygonException; import ca.nrc.cadc.caom2.types.MultiPolygon; import ca.nrc.cadc.caom2.types.Point; import ca.nrc.cadc.caom2.types.Polygon; import ca.nrc.cadc.caom2.types.SegmentType; +import ca.nrc.cadc.caom2.types.Shape; import ca.nrc.cadc.caom2.types.Vertex; import ca.nrc.cadc.caom2.wcs.Axis; import ca.nrc.cadc.caom2.wcs.Coord2D; @@ -517,7 +519,7 @@ public void testComputeBounds() { // coordinate range plane = getTestSetRange(1, 2); - poly = PositionUtil.computeBounds(plane.getArtifacts(), ProductType.SCIENCE); + poly = (Polygon) PositionUtil.computeBounds(plane.getArtifacts(), ProductType.SCIENCE); Assert.assertNotNull(poly); Assert.assertEquals(4, poly.getPoints().size()); Assert.assertEquals(2.0, poly.getArea(), 0.05); @@ -525,7 +527,7 @@ public void testComputeBounds() { Assert.assertEquals(10.5, poly.getCenter().cval2, 0.02); plane = getTestSetRange(1, 2); - poly = PositionUtil.computeBounds(plane.getArtifacts(), ProductType.SCIENCE); + poly = (Polygon) PositionUtil.computeBounds(plane.getArtifacts(), ProductType.SCIENCE); Assert.assertNotNull(poly); Assert.assertEquals(4, poly.getPoints().size()); Assert.assertEquals(2.0, poly.getArea(), 0.05); @@ -533,7 +535,7 @@ public void testComputeBounds() { Assert.assertEquals(10.5, poly.getCenter().cval2, 0.02); plane = getTestSetRange(1, 3); - poly = PositionUtil.computeBounds(plane.getArtifacts(), ProductType.SCIENCE); + poly = (Polygon) PositionUtil.computeBounds(plane.getArtifacts(), ProductType.SCIENCE); Assert.assertNotNull(poly); Assert.assertEquals(4, poly.getPoints().size()); Assert.assertEquals(3.0, poly.getArea(), 0.08); @@ -541,7 +543,7 @@ public void testComputeBounds() { Assert.assertEquals(10.5, poly.getCenter().cval2, 0.02); plane = getTestSetRange(4, 1); - poly = PositionUtil.computeBounds(plane.getArtifacts(), ProductType.SCIENCE); + poly = (Polygon) PositionUtil.computeBounds(plane.getArtifacts(), ProductType.SCIENCE); Assert.assertNotNull(poly); Assert.assertEquals(4, poly.getPoints().size()); Assert.assertEquals(4.0, poly.getArea(), 0.1); @@ -550,15 +552,24 @@ public void testComputeBounds() { // coordinate function plane = getTestSetFunction(1, 1); - poly = PositionUtil.computeBounds(plane.getArtifacts(), ProductType.SCIENCE); + poly = (Polygon) PositionUtil.computeBounds(plane.getArtifacts(), ProductType.SCIENCE); Assert.assertNotNull(poly); Assert.assertEquals(4, poly.getPoints().size()); Assert.assertEquals(1.0, poly.getArea(), 0.05); Assert.assertEquals(20.5, poly.getCenter().cval1, 0.02); Assert.assertEquals(10.5, poly.getCenter().cval2, 0.02); + + // mask with CoordCircle2D; array is 1000x1000 at 1e-3 aka 1x1 deg + Chunk chunk = plane.getArtifacts().iterator().next().getParts().iterator().next().getChunks().iterator().next(); + chunk.position.getAxis().bounds = new CoordCircle2D(new ValueCoord2D(20.5, 10.5), 0.25); + Circle circ = (Circle) PositionUtil.computeBounds(plane.getArtifacts(), ProductType.SCIENCE); + Assert.assertNotNull(circ); + Assert.assertEquals(20.5, circ.getCenter().cval1, 0.02); + Assert.assertEquals(10.5, circ.getCenter().cval2, 0.02); + Assert.assertEquals(0.25, circ.getRadius(), 0.02); plane = getTestSetFunction(1, 2); - poly = PositionUtil.computeBounds(plane.getArtifacts(), ProductType.SCIENCE); + poly = (Polygon) PositionUtil.computeBounds(plane.getArtifacts(), ProductType.SCIENCE); Assert.assertNotNull(poly); log.debug("[testComputeBounds] getTestSetFunction union: " + poly); //Assert.assertEquals(5, poly.getVertices().size()); @@ -567,7 +578,7 @@ public void testComputeBounds() { Assert.assertEquals(10.5, poly.getCenter().cval2, 0.02); plane = getTestSetFunction(1, 3); - poly = PositionUtil.computeBounds(plane.getArtifacts(), ProductType.SCIENCE); + poly = (Polygon) PositionUtil.computeBounds(plane.getArtifacts(), ProductType.SCIENCE); Assert.assertNotNull(poly); log.debug("[testComputeBounds] getTestSetFunction union: " + poly); //Assert.assertEquals(5, poly.getVertices().size()); @@ -576,7 +587,7 @@ public void testComputeBounds() { Assert.assertEquals(10.5, poly.getCenter().cval2, 0.02); plane = getTestSetFunction(4, 1); - poly = PositionUtil.computeBounds(plane.getArtifacts(), ProductType.SCIENCE); + poly = (Polygon) PositionUtil.computeBounds(plane.getArtifacts(), ProductType.SCIENCE); Assert.assertNotNull(poly); log.debug("[testComputeBounds] getTestSetFunction union: " + poly); //Assert.assertEquals(5, poly.getVertices().size()); @@ -597,17 +608,29 @@ public void testComputeDimension() { Dimension2D dim; plane = getTestSetFunction(1, 1); - poly = PositionUtil.computeBounds(plane.getArtifacts(), ProductType.SCIENCE); + poly = (Polygon) PositionUtil.computeBounds(plane.getArtifacts(), ProductType.SCIENCE); Assert.assertNotNull(poly); dim = PositionUtil.computeDimensionsFromWCS(poly, plane.getArtifacts(), ProductType.SCIENCE); log.debug("[testComputeDimension] dim=" + dim); Assert.assertNotNull(dim); Assert.assertEquals(1000L, dim.naxis1, 1L); Assert.assertEquals(1000L, dim.naxis2, 1L); + + // mask with CoordCircle2D; array is 1000x1000 at 1e-3 aka 1x1 deg + Chunk chunk = plane.getArtifacts().iterator().next().getParts().iterator().next().getChunks().iterator().next(); + chunk.position.getAxis().bounds = new CoordCircle2D(new ValueCoord2D(20.5, 10.5), 0.25); + Shape bounds = PositionUtil.computeBounds(plane.getArtifacts(), ProductType.SCIENCE); + Assert.assertNotNull(bounds); + dim = PositionUtil.computeDimensionsFromWCS(bounds, plane.getArtifacts(), ProductType.SCIENCE); + log.debug("[testComputeDimension] dim=" + dim); + Assert.assertNotNull(dim); + // TODO: need to use pixel-aligned "cutout" of circle vs array to get the right dimensions + //Assert.assertEquals(500L, dim.naxis1, 1L); + //Assert.assertEquals(500L, dim.naxis2, 1L); // with GAL <-> ICRS transformations plane = getTestSetFunction(1, 1, true); - poly = PositionUtil.computeBounds(plane.getArtifacts(), ProductType.SCIENCE); + poly = (Polygon) PositionUtil.computeBounds(plane.getArtifacts(), ProductType.SCIENCE); Assert.assertNotNull(poly); dim = PositionUtil.computeDimensionsFromWCS(poly, plane.getArtifacts(), ProductType.SCIENCE); log.debug("[testComputeDimension] dim=" + dim); @@ -616,7 +639,7 @@ public void testComputeDimension() { Assert.assertEquals(1000L, dim.naxis2, 1L); plane = getTestSetFunction(1, 2); - poly = PositionUtil.computeBounds(plane.getArtifacts(), ProductType.SCIENCE); + poly = (Polygon) PositionUtil.computeBounds(plane.getArtifacts(), ProductType.SCIENCE); Assert.assertNotNull(poly); dim = PositionUtil.computeDimensionsFromWCS(poly, plane.getArtifacts(), ProductType.SCIENCE); log.debug("[testComputeDimension] dim=" + dim); @@ -625,7 +648,7 @@ public void testComputeDimension() { Assert.assertEquals(1000L, dim.naxis2, 1L); plane = getTestSetRange(1, 1); - poly = PositionUtil.computeBounds(plane.getArtifacts(), ProductType.SCIENCE); + poly = (Polygon) PositionUtil.computeBounds(plane.getArtifacts(), ProductType.SCIENCE); Assert.assertNotNull(poly); dim = PositionUtil.computeDimensionsFromWCS(poly, plane.getArtifacts(), ProductType.SCIENCE); Assert.assertNull(dim); @@ -636,7 +659,7 @@ public void testComputeDimension() { Assert.assertEquals(1000L, dim.naxis2, 1L); plane = getTestSetRange(1, 3); - poly = PositionUtil.computeBounds(plane.getArtifacts(), ProductType.SCIENCE); + poly = (Polygon) PositionUtil.computeBounds(plane.getArtifacts(), ProductType.SCIENCE); Assert.assertNotNull(poly); dim = PositionUtil.computeDimensionsFromWCS(poly, plane.getArtifacts(), ProductType.SCIENCE); Assert.assertNull(dim); @@ -647,7 +670,7 @@ public void testComputeDimension() { Assert.assertEquals(1000L, dim.naxis2, 1L); plane = getTestSetRange(4, 1); - poly = PositionUtil.computeBounds(plane.getArtifacts(), ProductType.SCIENCE); + poly = (Polygon) PositionUtil.computeBounds(plane.getArtifacts(), ProductType.SCIENCE); Assert.assertNotNull(poly); dim = PositionUtil.computeDimensionsFromWCS(poly, plane.getArtifacts(), ProductType.SCIENCE); Assert.assertNull(dim); @@ -752,7 +775,7 @@ public void testComputeFromCalibration() { aux.getParts().addAll(tmpA.getParts()); plane.getArtifacts().add(aux); - poly = PositionUtil.computeBounds(plane.getArtifacts(), Util.choseProductType(plane.getArtifacts())); + poly = (Polygon) PositionUtil.computeBounds(plane.getArtifacts(), Util.choseProductType(plane.getArtifacts())); Assert.assertNotNull(poly); Assert.assertEquals(4, poly.getPoints().size()); Assert.assertEquals(1.0, poly.getArea(), 0.02); @@ -779,7 +802,7 @@ public void testComputeFromMixed() { aux.getParts().addAll(tmpA.getParts()); plane.getArtifacts().add(aux); - poly = PositionUtil.computeBounds(plane.getArtifacts(), Util.choseProductType(plane.getArtifacts())); + poly = (Polygon) PositionUtil.computeBounds(plane.getArtifacts(), Util.choseProductType(plane.getArtifacts())); Assert.assertNotNull(poly); Assert.assertEquals(4, poly.getPoints().size()); Assert.assertEquals(1.0, poly.getArea(), 0.02); diff --git a/caom2-dm/src/main/ProductType/description.html b/caom2-dm/src/main/ProductType/description.html index 5e8ff6fe..cac7c1d1 100644 --- a/caom2-dm/src/main/ProductType/description.html +++ b/caom2-dm/src/main/ProductType/description.html @@ -1,5 +1,11 @@
Terms from the vocabulary may be used in CAOM instances as values of the caom2:Artifact.productType field. Terms in the base vocabulary are to be -used without the URI prefix (e.g. science instead of http://www.opencadc.org/caom2/productType#science). +used without the URI prefix (e.g. science instead of http://www.opencadc.org/caom2/productType#science) +and (unlike DataLink) without the # symbol. +
+This vocabulary close mirrors the IVOA DataLink core +vocabulary. It currently includes the subset of terms that are sensibly "logical file types" and omits +those that are not used in CAOM (those that are relations with other observations or usually on-the-fly +process oputputs like cutouts). The plan is to deprecate this vocabulary and use DataLink core directly.
diff --git a/caom2-dm/src/main/ProductType/terms.csv b/caom2-dm/src/main/ProductType/terms.csv index 2c4c8b60..2f2cfd42 100644 --- a/caom2-dm/src/main/ProductType/terms.csv +++ b/caom2-dm/src/main/ProductType/terms.csv @@ -1,6 +1,9 @@ #predicate,parent,label,"Description" -science,1,science data,"primary data file for observations that contains the science data (extraterrestrial photons)" +this,1,primary data,"primary data file for observations" +science,1,science data,"primary data file for observations that contains the science data" + +coderived,1,coderived data,"output files produced along with this as additional or alternaticve product" calibration,1,calibration data,"primary file for observations intended for use in removing instrument signature" bias,2,bias frame,"calibration file used to correct for CCD bias" @@ -8,10 +11,14 @@ dark,2,dark frame,"calibration file used to correct for no exposure counts in a flat,2,flat field,"calibration file used to correct for sensitivity variation across a CCD" auxiliary,1,related file,"file that could be useful in interpreting the primary file(s)" -noise,2,noise map,"auxiliary file that provides noise estimates per pixel in the primary file(s)" -weight,2,weight map,"auxiliary file that provides weights that can be used when analysing the primary file(s)" +error,2,error map,"resource with array(s) containing error values" +noise,2,noise map,"file that provides noise estimates per pixel in the primary file(s)" +weight,2,weight map,"file that provides weights that can be used when analysing the primary file(s)" +documentation,1,human-readable information,"extra information about the primary files (e.g. processing logs)" info,1,human-readable information,"extra information about the primary files (e.g. processing logs)" -preview,1,preview image,"a degraded representation of the data useful for display and assessing content" +preview,1,preview,"a degraded representation of the data useful for display and assessing content" +preview-image,2,preview image,"a two-dimension image preview" +preview-plot,2,preview plot,"a preview presented as a plot/graph" thumbnail,2,small preview image,"a highly degraded representation of the data suitable for displaying in a list" diff --git a/caom2-validator/src/main/java/ca/nrc/cadc/caom2/Main.java b/caom2-validator/src/main/java/ca/nrc/cadc/caom2/Main.java index 82485451..4874b1ab 100644 --- a/caom2-validator/src/main/java/ca/nrc/cadc/caom2/Main.java +++ b/caom2-validator/src/main/java/ca/nrc/cadc/caom2/Main.java @@ -72,13 +72,13 @@ import ca.nrc.cadc.util.ArgumentMap; import ca.nrc.cadc.util.Log4jInit; import java.io.File; -import java.io.FileReader; +import java.io.FileInputStream; import java.io.FileWriter; +import java.io.InputStream; import java.util.ArrayList; import java.util.List; import org.apache.log4j.Level; import org.apache.log4j.Logger; -import org.springframework.jdbc.support.MetaDataAccessException; /** * @@ -117,8 +117,9 @@ public static void main(String[] args) { String fname = am.getPositionalArgs().get(0); File f = new File(fname); + InputStream istream = new FileInputStream(f); ObservationReader r = new ObservationReader(); - Observation obs = r.read(new FileReader(f)); + Observation obs = r.read(istream); if (am.isSet("compute")) { MetadataCompute mc = new MetadataCompute(obs); diff --git a/caom2-viz/src/main/java/ca/nrc/cadc/caom2/viz/VizUnion.java b/caom2-viz/src/main/java/ca/nrc/cadc/caom2/viz/VizUnion.java index b6c2f6f2..39a60bb1 100644 --- a/caom2-viz/src/main/java/ca/nrc/cadc/caom2/viz/VizUnion.java +++ b/caom2-viz/src/main/java/ca/nrc/cadc/caom2/viz/VizUnion.java @@ -74,9 +74,7 @@ import ca.nrc.cadc.caom2.Observation; import ca.nrc.cadc.caom2.Part; import ca.nrc.cadc.caom2.Plane; -import ca.nrc.cadc.caom2.Position; import ca.nrc.cadc.caom2.ProductType; -import ca.nrc.cadc.caom2.compute.ComputeUtil; import ca.nrc.cadc.caom2.compute.PolygonUtil; import ca.nrc.cadc.caom2.compute.PositionUtil; import ca.nrc.cadc.caom2.compute.Util; @@ -85,6 +83,7 @@ import ca.nrc.cadc.caom2.types.Point; import ca.nrc.cadc.caom2.types.Polygon; import ca.nrc.cadc.caom2.types.SegmentType; +import ca.nrc.cadc.caom2.types.Shape; import ca.nrc.cadc.caom2.types.Vertex; import ca.nrc.cadc.caom2.xml.ObservationReader; import java.awt.BorderLayout; @@ -140,7 +139,7 @@ public void doit() private void doit(Plane plane) throws Exception { - Polygon bounds = null; + Shape bounds = null; ProductType ptype = Util.choseProductType(plane.getArtifacts()); if (plane.position != null && plane.position.bounds != null && !forceRecompute) { // use polygon from input file @@ -163,15 +162,21 @@ private void doit(Plane plane) log.info("area: " + bounds.getArea()); } - DisplayPane dp = new DisplayPane(); + if (bounds instanceof Polygon) { + Polygon poly = (Polygon) bounds; + DisplayPane dp = new DisplayPane(); + + dp.setPlane(plane, poly); + JFrame f = new JFrame("CAOM-2.0 VizTest : " + plane.getProductID()); + f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + f.getContentPane().add(dp); + f.pack(); + f.setLocation(1000, 200); + f.setVisible(true); + } else { + log.warn("cannot display: " + bounds.getClass().getName()); + } - dp.setPlane(plane, bounds); - JFrame f = new JFrame("CAOM-2.0 VizTest : " + plane.getProductID()); - f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - f.getContentPane().add(dp); - f.pack(); - f.setLocation(1000, 200); - f.setVisible(true); } static class DisplayPane extends JPanel { diff --git a/caom2/build.gradle b/caom2/build.gradle index 3c941269..eecabc7f 100644 --- a/caom2/build.gradle +++ b/caom2/build.gradle @@ -15,7 +15,7 @@ sourceCompatibility = 1.8 group = 'org.opencadc' -version = '2.4.7' +version = '2.4.8' description = 'OpenCADC CAOM library' def git_url = 'https://github.com/opencadc/caom2' diff --git a/caom2/src/main/java/ca/nrc/cadc/caom2/ProductType.java b/caom2/src/main/java/ca/nrc/cadc/caom2/ProductType.java index d9b01bdd..5cde87e7 100644 --- a/caom2/src/main/java/ca/nrc/cadc/caom2/ProductType.java +++ b/caom2/src/main/java/ca/nrc/cadc/caom2/ProductType.java @@ -3,7 +3,7 @@ ******************* CANADIAN ASTRONOMY DATA CENTRE ******************* ************** CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES ************** * -* (c) 2011. (c) 2011. +* (c) 2024. (c) 2024. * Government of Canada Gouvernement du Canada * National Research Council Conseil national de recherches * Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6 @@ -81,21 +81,42 @@ public class ProductType extends VocabularyTerm implements CaomEnum, Serializable { private static final long serialVersionUID = 2017040200800L; - private static final URI CAOM = URI - .create("http://www.opencadc.org/caom2/ProductType"); + private static final URI CAOM = URI.create("http://www.opencadc.org/caom2/ProductType"); + + // IVOA DataLink terms + public static ProductType THIS = new ProductType("this"); - public static ProductType SCIENCE = new ProductType("science"); - public static ProductType CALIBRATION = new ProductType("calibration"); public static ProductType AUXILIARY = new ProductType("auxiliary"); - public static ProductType INFO = new ProductType("info"); - public static ProductType PREVIEW = new ProductType("preview"); - public static ProductType NOISE = new ProductType("noise"); - public static ProductType WEIGHT = new ProductType("weight"); - public static ProductType THUMBNAIL = new ProductType("thumbnail"); public static ProductType BIAS = new ProductType("bias"); + public static ProductType CALIBRATION = new ProductType("calibration"); + public static ProductType CODERIVED = new ProductType("coderived"); public static ProductType DARK = new ProductType("dark"); + public static ProductType DOCUMENTATION = new ProductType("documentation"); + public static ProductType ERROR = new ProductType("error"); public static ProductType FLAT = new ProductType("flat"); - + public static ProductType NOISE = new ProductType("noise"); + public static ProductType PREVIEW = new ProductType("preview"); + public static ProductType PREVIEW_IMAGE = new ProductType("preview-image"); + public static ProductType PREVIEW_PLOT = new ProductType("preview-plot"); + public static ProductType THUMBNAIL = new ProductType("thumbnail"); + public static ProductType WEIGHT = new ProductType("weight"); + + // DataLink terms explicitly not included + // counterpart + // cutout + // derivation + // detached-header + // package + // proc + // progenitor + + // CAOM specific terms + public static ProductType SCIENCE = new ProductType("science"); // this + + @Deprecated + public static ProductType INFO = new ProductType("info"); // documentation + + /** * @deprecated */ diff --git a/caom2/src/test/java/ca/nrc/cadc/caom2/ProductTypeTest.java b/caom2/src/test/java/ca/nrc/cadc/caom2/ProductTypeTest.java index 4b07742a..6ce924e3 100644 --- a/caom2/src/test/java/ca/nrc/cadc/caom2/ProductTypeTest.java +++ b/caom2/src/test/java/ca/nrc/cadc/caom2/ProductTypeTest.java @@ -141,8 +141,9 @@ public void testRoundtripCustom() { try { - String s1 = "http://example.com/foo#bar"; - DataProductType c2 = DataProductType.toValue(s1); + // a datalink core extension we have not included yet + String s1 = "http://www.example.net/rdf/topic#flibble"; + ProductType c2 = ProductType.toValue(s1); String s2 = c2.getValue(); log.info(s1 + " == " + s2); Assert.assertEquals(s1, s2);