private Optional<CoverageCoordAxis> subsetLon(LatLonRect llbb, int stride) throws InvalidRangeException { double wantMin = LatLonPointImpl.lonNormalFrom(llbb.getLonMin(), lonAxis.getStartValue()); double wantMax = LatLonPointImpl.lonNormalFrom(llbb.getLonMax(), lonAxis.getStartValue()); double start = lonAxis.getStartValue(); double end = lonAxis.getEndValue(); // use MAMath.MinMax as a container for two values, min and max List<MAMath.MinMax> lonIntvs = subsetLonIntervals(wantMin, wantMax, start, end); if (lonIntvs.size() == 0) return Optional.empty(String.format( "longitude want [%f,%f] does not intersect lon axis [%f,%f]", wantMin, wantMax, start, end)); if (lonIntvs.size() == 1) { MAMath.MinMax lonIntv = lonIntvs.get(0); return lonAxis.subset(lonIntv.min, lonIntv.max, stride); } // this is the seam crossing case return lonAxis.subsetByIntervals(lonIntvs, stride); }
/** * Return a String representation of this object. * <pre>lat= [-90.00,90.00] lon= [0.00,360.00</pre> * * @return a String representation of this object. */ public String toString2() { return " lat= [" + Format.dfrac(getLatMin(), 2) + "," + Format.dfrac(getLatMax(), 2) + "] lon= [" + Format.dfrac(getLonMin(), 2) + "," + Format.dfrac(getLonMax(), 2) + "]"; }
/** * Returns the domain of validity declared by the netCDF projection, or {@code null} if none. * * @see ucar.unidata.geoloc.ProjectionImpl#getDefaultMapAreaLL() */ @Override public Extent getDomainOfValidity() { final LatLonRect domain = ProjectionAdapter.factory(projection).getDefaultMapAreaLL(); if (domain != null) { return new SimpleGeographicBoundingBox( domain.getLonMin(), domain.getLonMax(), domain.getLatMin(), domain.getLatMax()); } return null; }
/** * Return a String representation of this object. * <pre>lat= [-90.00,90.00] lon= [0.00,360.00</pre> * * @return a String representation of this object. */ public String toString2() { return " lat= [" + Format.dfrac(getLatMin(), 2) + "," + Format.dfrac(getLatMax(), 2) + "] lon= [" + Format.dfrac(getLonMin(), 2) + "," + Format.dfrac(getLonMax(), 2) + "]"; }
/** * Return a String representation of this object. * <pre>lat= [-90.00,90.00] lon= [0.00,360.00</pre> * * @return a String representation of this object. */ public String toString2() { return " lat= [" + Format.dfrac(getLatMin(), 2) + "," + Format.dfrac(getLatMax(), 2) + "] lon= [" + Format.dfrac(getLonMin(), 2) + "," + Format.dfrac(getLonMax(), 2) + "]"; }
/** * Return a String representation of this object. * <pre>lat= [-90.00,90.00] lon= [0.00,360.00</pre> * * @return a String representation of this object. */ public String toString2() { return " lat= [" + Format.dfrac(getLatMin(), 2) + "," + Format.dfrac(getLatMax(), 2) + "] lon= [" + Format.dfrac(getLonMin(), 2) + "," + Format.dfrac(getLonMax(), 2) + "]"; } }
private void writeGlobalAttributes(NetcdfFileWriter writer, ucar.nc2.dt.GridDataset gds, LatLonRect llbb) { // global attributes for (Attribute att : gds.getGlobalAttributes()) { if (att.getShortName().equals(CDM.FILE_FORMAT)) continue; if (att.getShortName().equals(_Coordinate._CoordSysBuilder)) continue; writer.addGroupAttribute(null, att); } writer.addGroupAttribute(null, new Attribute(CDM.CONVENTIONS, "CF-1.0")); writer.addGroupAttribute(null, new Attribute("History", "Translated to CF-1.0 Conventions by Netcdf-Java CDM (NetcdfCFWriter)\n" + "Original Dataset = " + gds.getLocationURI() + "; Translation Date = " + new Date())); // this will replace any existing writer.addGroupAttribute(null, new Attribute(CDM.LAT_MIN, llbb.getLatMin())); writer.addGroupAttribute(null, new Attribute(CDM.LAT_MAX, llbb.getLatMax())); writer.addGroupAttribute(null, new Attribute(CDM.LON_MIN, llbb.getLonMin())); writer.addGroupAttribute(null, new Attribute(CDM.LON_MAX, llbb.getLonMax())); }
private Element writeBoundingBox(LatLonRect bb) { Element bbElem = new Element("LatLonBox"); bbElem.addContent(new Element("west").addContent(ucar.unidata.util.Format.dfrac(bb.getLonMin(), 4))); bbElem.addContent(new Element("east").addContent(ucar.unidata.util.Format.dfrac(bb.getLonMax(), 4))); bbElem.addContent(new Element("south").addContent(ucar.unidata.util.Format.dfrac(bb.getLatMin(), 4))); bbElem.addContent(new Element("north").addContent(ucar.unidata.util.Format.dfrac(bb.getLatMax(), 4))); return bbElem; }
private Element writeBoundingBox(LatLonRect bb) { Element bbElem = new Element("LatLonBox"); bbElem.addContent(new Element("west").addContent(ucar.unidata.util.Format.dfrac(bb.getLonMin(), 4))); bbElem.addContent(new Element("east").addContent(ucar.unidata.util.Format.dfrac(bb.getLonMax(), 4))); bbElem.addContent(new Element("south").addContent(ucar.unidata.util.Format.dfrac(bb.getLatMin(), 4))); bbElem.addContent(new Element("north").addContent(ucar.unidata.util.Format.dfrac(bb.getLatMax(), 4))); return bbElem; }
private Element writeBoundingBox(LatLonRect bb) { Element bbElem = new Element("LatLonBox"); // from KML bbElem.addContent(new Element("west").addContent(ucar.unidata.util.Format.dfrac(bb.getLonMin(), 6))); bbElem.addContent(new Element("east").addContent(ucar.unidata.util.Format.dfrac(bb.getLonMax(), 6))); bbElem.addContent(new Element("south").addContent(ucar.unidata.util.Format.dfrac(bb.getLatMin(), 6))); bbElem.addContent(new Element("north").addContent(ucar.unidata.util.Format.dfrac(bb.getLatMax(), 6))); return bbElem; }
private Element writeBoundingBox(LatLonRect bb) { Element bbElem = new Element("LatLonBox"); bbElem.addContent(new Element("west").addContent(ucar.unidata.util.Format.dfrac(bb.getLonMin(), 4))); bbElem.addContent(new Element("east").addContent(ucar.unidata.util.Format.dfrac(bb.getLonMax(), 4))); bbElem.addContent(new Element("south").addContent(ucar.unidata.util.Format.dfrac(bb.getLatMin(), 4))); bbElem.addContent(new Element("north").addContent(ucar.unidata.util.Format.dfrac(bb.getLatMax(), 4))); return bbElem; }
private Element writeBoundingBox(LatLonRect bb) { Element bbElem = new Element("LatLonBox"); // from KML bbElem.addContent(new Element("west").addContent(ucar.unidata.util.Format.dfrac(bb.getLonMin(), 6))); bbElem.addContent(new Element("east").addContent(ucar.unidata.util.Format.dfrac(bb.getLonMax(), 6))); bbElem.addContent(new Element("south").addContent(ucar.unidata.util.Format.dfrac(bb.getLatMin(), 6))); bbElem.addContent(new Element("north").addContent(ucar.unidata.util.Format.dfrac(bb.getLatMax(), 6))); return bbElem; }
private Element writeBoundingBox(LatLonRect bb) { Element bbElem = new Element("LatLonBox"); //LatLonPoint llpt = bb.getLowerLeftPoint(); //LatLonPoint urpt = bb.getUpperRightPoint(); //bbElem.addContent(new Element("west").addContent(ucar.unidata.util.Format.dfrac(llpt.getLongitude(), 4))); bbElem.addContent(new Element("west").addContent(ucar.unidata.util.Format.dfrac(bb.getLonMin() , 4))); //bbElem.addContent(new Element("east").addContent(ucar.unidata.util.Format.dfrac(urpt.getLongitude(), 4))); bbElem.addContent(new Element("east").addContent(ucar.unidata.util.Format.dfrac(bb.getLonMax(), 4))); //bbElem.addContent(new Element("south").addContent(ucar.unidata.util.Format.dfrac(llpt.getLatitude(), 4))); bbElem.addContent(new Element("south").addContent(ucar.unidata.util.Format.dfrac(bb.getLatMin(), 4))); //bbElem.addContent(new Element("north").addContent(ucar.unidata.util.Format.dfrac(urpt.getLatitude(), 4))); bbElem.addContent(new Element("north").addContent(ucar.unidata.util.Format.dfrac(bb.getLatMax(), 4))); return bbElem; }
private Element writeBoundingBox(LatLonRect bb) { Element bbElem = new Element("LatLonBox"); //LatLonPoint llpt = bb.getLowerLeftPoint(); //LatLonPoint urpt = bb.getUpperRightPoint(); //bbElem.addContent(new Element("west").addContent(ucar.unidata.util.Format.dfrac(llpt.getLongitude(), 4))); bbElem.addContent(new Element("west").addContent(ucar.unidata.util.Format.dfrac(bb.getLonMin() , 4))); //bbElem.addContent(new Element("east").addContent(ucar.unidata.util.Format.dfrac(urpt.getLongitude(), 4))); bbElem.addContent(new Element("east").addContent(ucar.unidata.util.Format.dfrac(bb.getLonMax(), 4))); //bbElem.addContent(new Element("south").addContent(ucar.unidata.util.Format.dfrac(llpt.getLatitude(), 4))); bbElem.addContent(new Element("south").addContent(ucar.unidata.util.Format.dfrac(bb.getLatMin(), 4))); //bbElem.addContent(new Element("north").addContent(ucar.unidata.util.Format.dfrac(urpt.getLatitude(), 4))); bbElem.addContent(new Element("north").addContent(ucar.unidata.util.Format.dfrac(bb.getLatMax(), 4))); return bbElem; }
private Element writeBoundingBox(LatLonRect bb) { Element bbElem = new Element("LatLonBox"); //LatLonPoint llpt = bb.getLowerLeftPoint(); //LatLonPoint urpt = bb.getUpperRightPoint(); //bbElem.addContent(new Element("west").addContent(ucar.unidata.util.Format.dfrac(llpt.getLongitude(), 4))); bbElem.addContent(new Element("west").addContent(ucar.unidata.util.Format.dfrac(bb.getLonMin(), 4))); //bbElem.addContent(new Element("east").addContent(ucar.unidata.util.Format.dfrac(urpt.getLongitude(), 4))); bbElem.addContent(new Element("east").addContent(ucar.unidata.util.Format.dfrac(bb.getLonMax(), 4))); //bbElem.addContent(new Element("south").addContent(ucar.unidata.util.Format.dfrac(llpt.getLatitude(), 4))); bbElem.addContent(new Element("south").addContent(ucar.unidata.util.Format.dfrac(bb.getLatMin(), 4))); //bbElem.addContent(new Element("north").addContent(ucar.unidata.util.Format.dfrac(urpt.getLatitude(), 4))); bbElem.addContent(new Element("north").addContent(ucar.unidata.util.Format.dfrac(bb.getLatMax(), 4))); return bbElem; }
private Element writeBoundingBox(LatLonRect bb) { Element bbElem = new Element("LatLonBox"); LatLonPoint llpt = bb.getLowerLeftPoint(); LatLonPoint urpt = bb.getUpperRightPoint(); //bbElem.addContent(new Element("west").addContent(ucar.unidata.util.Format.dfrac(llpt.getLongitude(), 4))); bbElem.addContent(new Element("west").addContent(ucar.unidata.util.Format.dfrac(bb.getLonMin() , 4))); //bbElem.addContent(new Element("east").addContent(ucar.unidata.util.Format.dfrac(urpt.getLongitude(), 4))); bbElem.addContent(new Element("east").addContent(ucar.unidata.util.Format.dfrac(bb.getLonMax(), 4))); //bbElem.addContent(new Element("south").addContent(ucar.unidata.util.Format.dfrac(llpt.getLatitude(), 4))); bbElem.addContent(new Element("south").addContent(ucar.unidata.util.Format.dfrac(bb.getLatMin(), 4))); //bbElem.addContent(new Element("north").addContent(ucar.unidata.util.Format.dfrac(urpt.getLatitude(), 4))); bbElem.addContent(new Element("north").addContent(ucar.unidata.util.Format.dfrac(bb.getLatMax(), 4))); return bbElem; }
@Test public void projToLatLonBB_everything() { // The bounding box includes the entire map. ProjectionPoint lowerLeft = new ProjectionPointImpl(-30000, -30000); ProjectionPoint upperRight = new ProjectionPointImpl(30000, 30000); Sinusoidal proj = new Sinusoidal(); ProjectionRect projBB = new ProjectionRect(lowerLeft, upperRight); LatLonRect latLonBB = proj.projToLatLonBB(projBB); Assert.assertEquals(-180.0, latLonBB.getLonMin(), 0.1); Assert.assertEquals(180.0, latLonBB.getLonMax(), 0.1); Assert.assertEquals(-90.0, latLonBB.getLatMin(), 0.1); Assert.assertEquals(90.0, latLonBB.getLatMax(), 0.1); } }
@Test public void projToLatLonBB_onlyintersects() { // Same bounding box as projToLatLonBB_partiallyValidTop(), but the left and right sides have been // extended completely off the map. None of its corners are on the map, but it intersects the edge at 4 places. ProjectionPoint lowerLeft = new ProjectionPointImpl(-13000, 8342); ProjectionPoint upperRight = new ProjectionPointImpl(15000, 9451); Sinusoidal proj = new Sinusoidal(); ProjectionRect projBB = new ProjectionRect(lowerLeft, upperRight); LatLonRect latLonBB = proj.projToLatLonBB(projBB); Assert.assertEquals(-180.0, latLonBB.getLonMin(), 0.1); Assert.assertEquals(180.0, latLonBB.getLonMax(), 0.1); Assert.assertEquals(75.0, latLonBB.getLatMin(), 0.1); Assert.assertEquals(85.0, latLonBB.getLatMax(), 0.1); }
@Test public void projToLatLonBB_includesNorthPole() { // Same bouding box as projToLatLonBB_partiallyValidTop(), but the top was extended past 90°N. // It intersects the map edge at 2 places and includes the north pole. ProjectionPoint lowerLeft = new ProjectionPointImpl(-4166, 8342); ProjectionPoint upperRight = new ProjectionPointImpl(4021, 11111); Sinusoidal proj = new Sinusoidal(); ProjectionRect projBB = new ProjectionRect(lowerLeft, upperRight); LatLonRect latLonBB = proj.projToLatLonBB(projBB); Assert.assertEquals(-180.0, latLonBB.getLonMin(), 0.1); Assert.assertEquals(180.0, latLonBB.getLonMax(), 0.1); Assert.assertEquals(75.0, latLonBB.getLatMin(), 0.1); Assert.assertEquals(90.0, latLonBB.getLatMax(), 0.1); }
@Test public void projToLatLonBB_onlyintersectsAndPole() { // Same bounding box as projToLatLonBB_partiallyValidTop(), but the left, right, and top sides have been // extended completely off the map. None of its corners are on the map, but it intersects the edge at 2 places // and includes the north pole. ProjectionPoint lowerLeft = new ProjectionPointImpl(-13000, 8342); ProjectionPoint upperRight = new ProjectionPointImpl(15000, 11111); Sinusoidal proj = new Sinusoidal(); ProjectionRect projBB = new ProjectionRect(lowerLeft, upperRight); LatLonRect latLonBB = proj.projToLatLonBB(projBB); Assert.assertEquals(-180.0, latLonBB.getLonMin(), 0.1); Assert.assertEquals(180.0, latLonBB.getLonMax(), 0.1); Assert.assertEquals(75.0, latLonBB.getLatMin(), 0.1); Assert.assertEquals(90.0, latLonBB.getLatMax(), 0.1); }