/** * Copy Constructor * * @param r rectangle to copy */ public LatLonRect(LatLonRect r) { this(r.getLowerLeftPoint(), r.getUpperRightPoint().getLatitude() - r.getLowerLeftPoint().getLatitude(), r.getWidth()); }
/** * Copy Constructor * * @param r rectangle to copy */ public LatLonRect(LatLonRect r) { this(r.getLowerLeftPoint(), r.getUpperRightPoint().getLatitude() - r.getLowerLeftPoint().getLatitude(), r.getWidth()); }
/** * Copy Constructor * * @param r rectangle to copy */ public LatLonRect(LatLonRect r) { this(r.getLowerLeftPoint(), r.getUpperRightPoint().getLatitude() - r.getLowerLeftPoint().getLatitude(), r.getWidth()); }
/** * Returns {@code true} if this rectangle is nearly equal to {@code other}. The "near equality" of corners is * determined using {@link LatLonPoint#nearlyEquals(LatLonPoint, double)}, with the specified maxRelDiff. * * @param other the other rectangle to check. * @param maxRelDiff the maximum {@link Misc#relativeDifference relative difference} that two corners may have. * @return {@code true} if this rectangle is nearly equal to {@code other}. */ public boolean nearlyEquals(LatLonRect other, double maxRelDiff) { return this.getLowerLeftPoint() .nearlyEquals(other.getLowerLeftPoint(), maxRelDiff) && this.getUpperRightPoint().nearlyEquals(other.getUpperRightPoint(), maxRelDiff); }
/** * Copy Constructor * * @param r rectangle to copy */ public LatLonRect(LatLonRect r) { this(r.getLowerLeftPoint(), r.getUpperRightPoint().getLatitude() - r.getLowerLeftPoint().getLatitude(), r.getWidth()); }
/** * determine whether two bounding boxes are equal in values * * @param other other bounding box * @return true if this represents the same bounding box as other */ public boolean equals(LatLonRect other) { return lowerLeft.equals(other.getLowerLeftPoint()) && upperRight.equals(other.getUpperRightPoint()); }
/** * get whether two bounding boxes are equal in values * * @param other other bounding box * @return true if this represents the same bounding box as other */ public boolean equals(LatLonRect other) { return lowerLeft.equals(other.getLowerLeftPoint()) && upperRight.equals(other.getUpperRightPoint()); }
/** * get whether two bounding boxes are equal in values * * @param other other bounding box * @return true if this represents the same bounding box as other */ public boolean equals(LatLonRect other) { return lowerLeft.equals(other.getLowerLeftPoint()) && upperRight.equals(other.getUpperRightPoint()); }
private String makeBB( LatLonRect bb) { return latVar.getFullName()+">="+bb.getLowerLeftPoint().getLatitude()+"&"+ latVar.getFullName()+"<="+bb.getUpperRightPoint().getLatitude()+"&"+ lonVar.getFullName()+">="+bb.getLowerLeftPoint().getLongitude()+"&"+ lonVar.getFullName()+"<="+bb.getUpperRightPoint().getLongitude(); }
private String makeBB( LatLonRect bb) { return latVar.getShortName()+">="+bb.getLowerLeftPoint().getLatitude()+"&"+ latVar.getShortName()+"<="+bb.getUpperRightPoint().getLatitude()+"&"+ lonVar.getShortName()+">="+bb.getLowerLeftPoint().getLongitude()+"&"+ lonVar.getShortName()+"<="+bb.getUpperRightPoint().getLongitude(); }
public static LatLonRect getBoundingBox(List<? extends Station> stnList) { Station s = stnList.get(0); LatLonPointImpl llpt = new LatLonPointImpl(); llpt.set(s.getLatitude(), s.getLongitude()); LatLonRect rect = new LatLonRect(llpt, 0, 0); for (int i = 1; i < stnList.size(); i++) { s = stnList.get(i); llpt.set(s.getLatitude(), s.getLongitude()); rect.extend(llpt); } // To give a little "wiggle room", we're going to slightly expand the bounding box. double newLowerLeftLat = rect.getLowerLeftPoint().getLatitude() - .0005; double newLowerLeftLon = rect.getLowerLeftPoint().getLongitude() - .0005; LatLonPointImpl newLowerLeftPoint = new LatLonPointImpl(newLowerLeftLat, newLowerLeftLon); double newUpperRightLat = rect.getUpperRightPoint().getLatitude() + .0005; double newUpperRightLon = rect.getUpperRightPoint().getLongitude() + .0005; LatLonPointImpl newUpperRightPoint = new LatLonPointImpl(newUpperRightLat, newUpperRightLon); rect.extend(newLowerLeftPoint); rect.extend(newUpperRightPoint); return rect; }
protected void finishCalcBounds() { if (!calcBounds) return; if ((bb != null) && bb.crossDateline() && (bb.getWidth() > 350.0)) { // call it global - less confusing double lat_min = bb.getLowerLeftPoint().getLatitude(); double deltaLat = bb.getUpperLeftPoint().getLatitude() - lat_min; bb = new LatLonRect(new LatLonPointImpl(lat_min, -180.0), deltaLat, 360.0); } info.bbox = bb; info.minTime = minTime; info.maxTime = maxTime; info.nobs = count; info.nfeatures = count; info.setComplete(); }
public void setBoundingBox(LatLonRect bb) { LatLonPointImpl llpt = bb.getLowerLeftPoint(); LatLonPointImpl urpt = bb.getUpperRightPoint(); double height = urpt.getLatitude() - llpt.getLatitude(); this.eastwest = new Range(llpt.getLongitude(), bb.getWidth(), 0.0, CDM.LON_UNITS); this.northsouth = new Range(llpt.getLatitude(), height, 0.0, CDM.LAT_UNITS); if ((bb.getWidth() > 358) && (height > 178)) setGlobal(true); // LOOK ?? }
public void setBoundingBox(LatLonRect bb) { LatLonPointImpl llpt = bb.getLowerLeftPoint(); LatLonPointImpl urpt = bb.getUpperRightPoint(); double height = urpt.getLatitude() - llpt.getLatitude(); this.eastwest = new Range(llpt.getLongitude(), bb.getWidth(), 0.0, CDM.LON_UNITS); this.northsouth = new Range(llpt.getLatitude(), height, 0.0, CDM.LAT_UNITS); if ((bb.getWidth() > 358) && (height > 178)) setGlobal(true); // LOOK ?? }
public void setBoundingBox(LatLonRect bb) { LatLonPointImpl llpt = bb.getLowerLeftPoint(); LatLonPointImpl urpt = bb.getUpperRightPoint(); double height = urpt.getLatitude() - llpt.getLatitude(); this.eastwest = new Range(llpt.getLongitude(), bb.getWidth(), 0.0, CDM.LON_UNITS); this.northsouth = new Range(llpt.getLatitude(), height, 0.0, CDM.LAT_UNITS); if ((bb.getWidth() > 358) && (height > 178)) setGlobal(true); // LOOK ?? }
CdmrFeatureProto.Rectangle.Builder encodeRectangle(LatLonRect rect) { CdmrFeatureProto.Rectangle.Builder builder = CdmrFeatureProto.Rectangle.newBuilder(); // this(r.getLowerLeftPoint(), r.getUpperRightPoint().getLatitude() - r.getLowerLeftPoint().getLatitude(), r.getWidth()); LatLonPoint ll = rect.getLowerLeftPoint(); LatLonPoint ur = rect.getUpperRightPoint(); builder.setStartx(ll.getLongitude()); builder.setStarty(ll.getLatitude()); builder.setIncx(rect.getWidth()); builder.setIncy(ur.getLatitude() - ll.getLatitude()); return builder; }
public void finish() throws IOException { if (llbb != null) { writer.updateAttribute(null, new Attribute(ACDD.LAT_MIN, llbb.getLowerLeftPoint().getLatitude())); writer.updateAttribute(null, new Attribute(ACDD.LAT_MAX, llbb.getUpperRightPoint().getLatitude())); writer.updateAttribute(null, new Attribute(ACDD.LON_MIN, llbb.getLowerLeftPoint().getLongitude())); writer.updateAttribute(null, new Attribute(ACDD.LON_MAX, llbb.getUpperRightPoint().getLongitude())); } if (!noTimeCoverage) { if (minDate == null) minDate = CalendarDate.present(); if (maxDate == null) maxDate = CalendarDate.present(); writer.updateAttribute(null, new Attribute(ACDD.TIME_START, CalendarDateFormatter.toDateTimeStringISO(minDate))); writer.updateAttribute(null, new Attribute(ACDD.TIME_END, CalendarDateFormatter.toDateTimeStringISO(maxDate))); } writer.close(); }
public void finish() throws IOException { if (llbb != null) { writer.updateAttribute(null, new Attribute(ACDD.LAT_MIN, llbb.getLowerLeftPoint().getLatitude())); writer.updateAttribute(null, new Attribute(ACDD.LAT_MAX, llbb.getUpperRightPoint().getLatitude())); writer.updateAttribute(null, new Attribute(ACDD.LON_MIN, llbb.getLowerLeftPoint().getLongitude())); writer.updateAttribute(null, new Attribute(ACDD.LON_MAX, llbb.getUpperRightPoint().getLongitude())); } if (!noTimeCoverage) { if (minDate == null) minDate = CalendarDate.present(); if (maxDate == null) maxDate = CalendarDate.present(); writer.updateAttribute(null, new Attribute(ACDD.TIME_START, CalendarDateFormatter.toDateTimeStringISO(minDate))); writer.updateAttribute(null, new Attribute(ACDD.TIME_END, CalendarDateFormatter.toDateTimeStringISO(maxDate))); } writer.close(); }
public void finish() throws IOException { writer.updateAttribute(null, new Attribute(CDM.LAT_MIN, llbb.getLowerLeftPoint().getLatitude())); writer.updateAttribute(null, new Attribute(CDM.LAT_MAX, llbb.getUpperRightPoint().getLatitude())); writer.updateAttribute(null, new Attribute(CDM.LON_MIN, llbb.getLowerLeftPoint().getLongitude())); writer.updateAttribute(null, new Attribute(CDM.LON_MAX, llbb.getUpperRightPoint().getLongitude())); if((writer.getNetcdfFile().findAttribute("@"+CDM.TIME_START) != null) && (writer.getNetcdfFile().findAttribute("@"+CDM.TIME_END) != null )){ if (minDate == null) minDate = CalendarDate.present(); if (maxDate == null) maxDate = CalendarDate.present(); writer.updateAttribute(null, new Attribute(CDM.TIME_START, CalendarDateFormatter.toDateTimeStringISO(minDate))); writer.updateAttribute(null, new Attribute(CDM.TIME_END, CalendarDateFormatter.toDateTimeStringISO(maxDate))); } writer.close(); }
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; }