Java Code Examples for ucar.unidata.geoloc.LatLonRect#getUpperRightPoint()
The following examples show how to use
ucar.unidata.geoloc.LatLonRect#getUpperRightPoint() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ThreddsMetadata.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 5 votes |
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 ?? }
Example 2
Source File: CdmrfWriter.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 5 votes |
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; }
Example 3
Source File: WcsRequest.java From tds with BSD 3-Clause "New" or "Revised" License | 5 votes |
protected Element genLonLatEnvelope(CoverageCollection gcd, CoverageCoordSys gcs) { // <CoverageOfferingBrief>/lonLatEnvelope Element lonLatEnvelopeElem = new Element("lonLatEnvelope", wcsNS); lonLatEnvelopeElem.setAttribute("srsName", "urn:ogc:def:crs:OGC:1.3:CRS84"); LatLonRect llbb = gcd.getLatlonBoundingBox(); LatLonPoint llpt = llbb.getLowerLeftPoint(); LatLonPoint urpt = llbb.getUpperRightPoint(); // <CoverageOfferingBrief>/lonLatEnvelope/gml:pos String firstPosition = llpt.getLongitude() + " " + llpt.getLatitude(); double lon = llpt.getLongitude() + llbb.getWidth(); String secondPosition = lon + " " + urpt.getLatitude(); // ToDo WCS 1.0Plus - Add vertical (Deal with conversion to meters. Yikes!!) // CoordinateAxis1D vertAxis = gcs.getVerticalAxis(); // if ( vertAxis != null ) // { // // See verAxis.getUnitsString() // firstPosition += " " + vertAxis.getCoordValue( 0); // secondPostion += " " + vertAxis.getCoordValue( ((int)vertAxis.getSize()) - 1); // } lonLatEnvelopeElem.addContent(new Element("pos", gmlNS).addContent(firstPosition)); lonLatEnvelopeElem.addContent(new Element("pos", gmlNS).addContent(secondPosition)); // <CoverageOfferingBrief>/lonLatEnvelope/gml:timePostion [2] CoverageCoordAxis timeCoord = gcs.getTimeAxis(); if (timeCoord != null) { CalendarDateRange dr = timeCoord.getDateRange(); if (dr != null) { lonLatEnvelopeElem.addContent(new Element("timePosition", gmlNS).addContent(dr.getStart().toString())); lonLatEnvelopeElem.addContent(new Element("timePosition", gmlNS).addContent(dr.getEnd().toString())); } } return lonLatEnvelopeElem; }
Example 4
Source File: ThreddsMetadata.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 4 votes |
public GeospatialCoverage(LatLonRect bb, CoordinateAxis1D vaxis, double dX, double dY) { if (bb == null) { this.eastwest = null; this.northsouth = null; this.isGlobal = false; this.names = null; } else { LatLonPoint llpt = bb.getLowerLeftPoint(); LatLonPoint urpt = bb.getUpperRightPoint(); double height = urpt.getLatitude() - llpt.getLatitude(); this.eastwest = new GeospatialRange(llpt.getLongitude(), bb.getWidth(), dX, CDM.LON_UNITS); this.northsouth = new GeospatialRange(llpt.getLatitude(), height, dY, CDM.LAT_UNITS); if ((bb.getWidth() >= (360 - dX)) && (height >= (180 - dY))) { this.isGlobal = true; // serialize isGlobal this.names = new ArrayList<>(); this.names.add(new Vocab("global", null)); } else { this.isGlobal = false; this.names = null; } } if (vaxis == null) { this.updown = null; this.zpositive = null; } else { int n = (int) vaxis.getSize(); double size = vaxis.getCoordValue(n - 1) - vaxis.getCoordValue(0); double resolution = vaxis.getIncrement(); String units = vaxis.getUnitsString(); this.updown = new GeospatialRange(vaxis.getCoordValue(0), size, resolution, units); if (units != null) { boolean isPositive = SimpleUnit.isCompatible("m", units); this.zpositive = isPositive ? CF.POSITIVE_UP : CF.POSITIVE_DOWN; } else { this.zpositive = CF.POSITIVE_UP; } } }
Example 5
Source File: HorizCoordSys2D.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 4 votes |
Optional<List<RangeIterator>> computeBoundsExhaustive(LatLonRect rect, int horizStride) { LatLonPoint llpt = rect.getLowerLeftPoint(); LatLonPoint urpt = rect.getUpperRightPoint(); double miny = llpt.getLatitude(); double maxy = urpt.getLatitude(); // normalize to [minLon,minLon+360], edge already normalized to this double minx = LatLonPoints.lonNormalFrom(llpt.getLongitude(), lonMinMax.min); double maxx = LatLonPoints.lonNormalFrom(urpt.getLongitude(), lonMinMax.min); int[] shape = lonAxis2D.getShape(); int ny = shape[0]; int nx = shape[1]; int minCol = Integer.MAX_VALUE, minRow = Integer.MAX_VALUE; int maxCol = -1, maxRow = -1; boolean allX = (minx > lonMinMax.max && maxx > lonMinMax.max && minx > maxx); boolean allY = (miny <= latMinMax.min && maxy >= latMinMax.max); if (allX && allY) { // return full set return Optional.of(getRanges()); } if (minx > lonMinMax.max && maxx > lonMinMax.max && minx < maxx) { // otherwise ignoring minx > maxx return Optional.empty("no intersection"); } else if (minx > lonMinMax.max && maxx > lonMinMax.max && minx > maxx) { minCol = 0; // all of x maxCol = nx; minx = lonMinMax.min; } else if (minx > lonMinMax.min && maxx > lonMinMax.max) { maxCol = nx; } else if (minx > lonMinMax.max && maxx < lonMinMax.max) { minCol = 0; minx = lonMinMax.min; } // probably not needed if (miny <= latMinMax.min) { minRow = 0; } else if (maxy >= latMinMax.max) { maxRow = ny; } // brute force, examine every point LOOK BAD for (int row = 0; row <= ny; row++) { for (int col = 0; col <= nx; col++) { double lat = latEdge.get(row, col); double lon = lonEdge.get(row, col); if ((lat >= miny) && (lat <= maxy) && (lon >= minx) && (lon <= maxx)) { if (col > maxCol) maxCol = col; if (col < minCol) minCol = col; if (row > maxRow) maxRow = row; if (row < minRow) minRow = row; } } } try { List<RangeIterator> list = new ArrayList<>(); list.add(new Range(minRow, maxRow - 1, horizStride)); list.add(new Range(minCol, maxCol - 1, horizStride)); return Optional.of(list); } catch (InvalidRangeException e) { throw new RuntimeException(e); } }