Search in sources :

Example 1 with LatLonPoint

use of ucar.unidata.geoloc.LatLonPoint in project ncWMS by Unidata.

the class CdmUtils method getBbox.

/**
 * Converts the given LatLonRect to a GeographicBoundingBox.
 *
 * @todo Should probably be an Extent or a BoundingBox (I think Extent is
 *       more accurate - see the GeoAPI spec document. Extents do not cross
 *       the anti-meridian). Also do we need to return a more precise CRS?
 *       GeographicBoundingBox is deliberately approximate so doesn't use a
 *       CRS.
 */
public static GeographicBoundingBox getBbox(LatLonRect latLonRect) {
    // TODO: should take into account the cell bounds
    LatLonPoint lowerLeft = latLonRect.getLowerLeftPoint();
    LatLonPoint upperRight = latLonRect.getUpperRightPoint();
    double minLon = lowerLeft.getLongitude();
    double maxLon = upperRight.getLongitude();
    double minLat = lowerLeft.getLatitude();
    double maxLat = upperRight.getLatitude();
    // crosses the date line
    if (latLonRect.crossDateline() || minLon >= maxLon) {
        minLon = -180.0;
        maxLon = 180.0;
    }
    if (minLat >= maxLat) {
        minLat = -90.0;
        maxLat = 90.0;
    }
    // Sometimes the bounding boxes can be NaN, e.g. for a VerticalPerspectiveView
    // that encompasses more than the Earth's disc
    minLon = Double.isNaN(minLon) ? -180.0 : minLon;
    minLat = Double.isNaN(minLat) ? -90.0 : minLat;
    maxLon = Double.isNaN(maxLon) ? 180.0 : maxLon;
    maxLat = Double.isNaN(maxLat) ? 90.0 : maxLat;
    return new DefaultGeographicBoundingBox(minLon, maxLon, minLat, maxLat);
}
Also used : DefaultGeographicBoundingBox(org.geotoolkit.metadata.iso.extent.DefaultGeographicBoundingBox) LatLonPoint(ucar.unidata.geoloc.LatLonPoint)

Example 2 with LatLonPoint

use of ucar.unidata.geoloc.LatLonPoint in project ncWMS by Unidata.

the class ProjectedGrid method transformCoordinatesNoBoundsCheck.

@Override
protected LonLatPosition transformCoordinatesNoBoundsCheck(int i, int j) {
    double x = this.xAxis.getCoordinateValue(i);
    double y = this.yAxis.getCoordinateValue(j);
    // Translate this point to lon-lat coordinates
    LatLonPoint latLon = this.proj.projToLatLon(x, y);
    return new LonLatPositionImpl(latLon.getLongitude(), latLon.getLatitude());
}
Also used : LonLatPositionImpl(uk.ac.rdg.resc.edal.geometry.impl.LonLatPositionImpl) LatLonPoint(ucar.unidata.geoloc.LatLonPoint)

Aggregations

LatLonPoint (ucar.unidata.geoloc.LatLonPoint)2 DefaultGeographicBoundingBox (org.geotoolkit.metadata.iso.extent.DefaultGeographicBoundingBox)1 LonLatPositionImpl (uk.ac.rdg.resc.edal.geometry.impl.LonLatPositionImpl)1