Class HorizCoordSys
- java.lang.Object
-
- ucar.nc2.ft2.coverage.HorizCoordSys
-
- Direct Known Subclasses:
HorizCoordSys2D
@Immutable public class HorizCoordSys extends Object
Horizontal CoordSys1) has x,y,proj (1D) isProjection 2) lat,lon (1D) isLatLon1D 3) lat,lon (2D) class HorizCoordSys2D 4) has x,y,proj and lat,lon (2D) LOOK 2D not used ?
Must be exactly one in a CoverageDataset.
- Since:
- 7/11/2015
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
HorizCoordSys.CoordReturn
-
Field Summary
Fields Modifier and Type Field Description protected LatLonAxis2D
latAxis2D
protected LatLonAxis2D
lonAxis2D
-
Constructor Summary
Constructors Modifier Constructor Description protected
HorizCoordSys(CoverageCoordAxis1D xAxis, CoverageCoordAxis1D yAxis, CoverageCoordAxis latAxis, CoverageCoordAxis lonAxis, CoverageTransform transform)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description List<LatLonPointNoNormalize>
calcConnectedLatLonBoundaryPoints()
CallscalcConnectedLatLonBoundaryPoints(int, int)
withInteger.MAX_VALUE
as both arguments.List<LatLonPointNoNormalize>
calcConnectedLatLonBoundaryPoints(int maxPointsInYEdge, int maxPointsInXEdge)
Calculates the latitude/longitude boundary of this coordinate reference system.LatLonRect
calcLatLonBoundingBox()
Calculates the bounding box of this coordinate reference system, in latitude/longitude.List<ProjectionPoint>
calcProjectionBoundaryPoints()
CallscalcProjectionBoundaryPoints(int, int)
withInteger.MAX_VALUE
as both arguments.List<ProjectionPoint>
calcProjectionBoundaryPoints(int maxPointsInYEdge, int maxPointsInXEdge)
Calculates the boundary of this coordinate reference system, in projection coordinates.ProjectionRect
calcProjectionBoundingBox()
Calculates the bounding box of this coordinate reference system, in projection coordinates.static List<LatLonPointNoNormalize>
connectLatLonPoints(List<LatLonPoint> points)
Returns a list of points that is equivalent to the input list, but with longitude values adjusted to ensure that adjacent elements are "connected".static HorizCoordSys
factory(CoverageCoordAxis1D xAxis, CoverageCoordAxis1D yAxis, CoverageCoordAxis latAxis, CoverageCoordAxis lonAxis, CoverageTransform transform)
Optional<HorizCoordSys.CoordReturn>
findXYindexFromCoord(double x, double y)
List<CoverageCoordAxis>
getCoordAxes()
LatLonAxis2D
getLatAxis2D()
LatLonPoint
getLatLon(int yindex, int xindex)
String
getLatLonBoundaryAsGeoJSON()
CallsgetLatLonBoundaryAsGeoJSON(int, int)
withInteger.MAX_VALUE
as both arguments.String
getLatLonBoundaryAsGeoJSON(int maxPointsInYEdge, int maxPointsInXEdge)
Similar togetLatLonBoundaryAsWKT()
, but returns a GeoJSON polygon instead.String
getLatLonBoundaryAsWKT()
CallsgetLatLonBoundaryAsWKT(int, int)
withInteger.MAX_VALUE
as both arguments.String
getLatLonBoundaryAsWKT(int maxPointsInYEdge, int maxPointsInXEdge)
Returns thelatitude/longitude boundary
of this coordinate reference system as a polygon in WKT.LatLonAxis2D
getLonAxis2D()
String
getName()
List<RangeIterator>
getRanges()
CoverageTransform
getTransform()
CoverageCoordAxis1D
getXAxis()
CoverageCoordAxis1D
getYAxis()
boolean
isLatLon2D()
boolean
isProjection()
Optional<HorizCoordSys>
subset(SubsetParams params)
-
-
-
Field Detail
-
latAxis2D
protected final LatLonAxis2D latAxis2D
-
lonAxis2D
protected final LatLonAxis2D lonAxis2D
-
-
Constructor Detail
-
HorizCoordSys
protected HorizCoordSys(CoverageCoordAxis1D xAxis, CoverageCoordAxis1D yAxis, CoverageCoordAxis latAxis, CoverageCoordAxis lonAxis, CoverageTransform transform)
-
-
Method Detail
-
factory
public static HorizCoordSys factory(CoverageCoordAxis1D xAxis, CoverageCoordAxis1D yAxis, CoverageCoordAxis latAxis, CoverageCoordAxis lonAxis, CoverageTransform transform)
-
getName
public String getName()
-
isProjection
public boolean isProjection()
-
isLatLon2D
public boolean isLatLon2D()
-
getCoordAxes
public List<CoverageCoordAxis> getCoordAxes()
-
getTransform
public CoverageTransform getTransform()
-
subset
public Optional<HorizCoordSys> subset(SubsetParams params)
-
getLatLon
public LatLonPoint getLatLon(int yindex, int xindex)
-
getRanges
public List<RangeIterator> getRanges()
-
getXAxis
public CoverageCoordAxis1D getXAxis()
-
getYAxis
public CoverageCoordAxis1D getYAxis()
-
getLonAxis2D
public LatLonAxis2D getLonAxis2D()
-
getLatAxis2D
public LatLonAxis2D getLatAxis2D()
-
findXYindexFromCoord
public Optional<HorizCoordSys.CoordReturn> findXYindexFromCoord(double x, double y)
-
calcProjectionBoundingBox
public ProjectionRect calcProjectionBoundingBox()
Calculates the bounding box of this coordinate reference system, in projection coordinates. If this CRSisn't a projection
, thannull
is returned.- Returns:
- the bounding box of this CRS, in projection coordinates.
-
calcLatLonBoundingBox
public LatLonRect calcLatLonBoundingBox()
Calculates the bounding box of this coordinate reference system, in latitude/longitude. This method properly handles coverages that straddle the international date line by deriving its bounding box from theconnected latitude/longitude boundary
.If this CRS
is a projection
, its lat/lon boundary is computed by converting each point in itsprojection boundary
to latitude/longitude using theprojection
.- Returns:
- the bounding box of this CRS, in latitude/longitude.
-
calcConnectedLatLonBoundaryPoints
public List<LatLonPointNoNormalize> calcConnectedLatLonBoundaryPoints()
CallscalcConnectedLatLonBoundaryPoints(int, int)
withInteger.MAX_VALUE
as both arguments. In effect, the boundary will contain ALL of the points along the edges of the CRS.- Returns:
- the connected latitude/longitude boundary of this CRS.
-
calcConnectedLatLonBoundaryPoints
public List<LatLonPointNoNormalize> calcConnectedLatLonBoundaryPoints(int maxPointsInYEdge, int maxPointsInXEdge)
Calculates the latitude/longitude boundary of this coordinate reference system. The boundary starts at the lower left corner of the coverage--i.e.(y[0], x[0])
--and consists of the points that lie along the bottom, right, top, and left edges, in that order.The
maxPointsInYEdge
parameter establishes a limit on the number of boundary points that'll be included from the right and left edges.maxPointsInXEdge
establishes a similar limit for the bottom and top edges. The size of the returned list will be≤ 2 * maxPointsInYEdge + 2 * maxPointsInXEdge
. Note that the corners are always included, regardless of the arguments. If you wish to include ALL of the points along the edges in the boundary, simply choose values for the parameters that are greater than the lengths of the corresponding axes in the CRS.Integer.MAX_VALUE
works great. In that case, the size of the returned list will be2 * numXcoords + 2 * numYcoords
.If this CRS
is a projection
, the lat/lon boundary is computed by converting each point in itsprojection boundary
to latitude/longitude using theprojection
.Points in the boundary will be
connected
. This facilitates proper interpretation of the boundary if it's rendered as a georeferenced polygon, particularly when the boundary crosses the international date line.- Parameters:
maxPointsInYEdge
- the maximum number of boundary points to include from the right and left edges.maxPointsInXEdge
- the maximum number of boundary points to include from the bottom and top edges.- Returns:
- the connected latitude/longitude boundary of this CRS.
-
calcProjectionBoundaryPoints
public List<ProjectionPoint> calcProjectionBoundaryPoints()
CallscalcProjectionBoundaryPoints(int, int)
withInteger.MAX_VALUE
as both arguments. In effect, the boundary will contain ALL of the points along the edges of the CRS.- Returns:
- the boundary of this coordinate reference system, in projection coordinates.
-
calcProjectionBoundaryPoints
public List<ProjectionPoint> calcProjectionBoundaryPoints(int maxPointsInYEdge, int maxPointsInXEdge)
Calculates the boundary of this coordinate reference system, in projection coordinates. The boundary starts at the lower left corner of the coverage--i.e.(y[0], x[0])
--and consists of the points that lie along the bottom, right, top, and left edges, in that order.The
maxPointsInYEdge
parameter establishes a limit on the number of boundary points that'll be included from the right and left edges.maxPointsInXEdge
establishes a similar limit for the bottom and top edges. The size of the returned list will be≤ 2 * maxPointsInYEdge + 2 * maxPointsInXEdge
. Note that the corners are always included, regardless of the arguments. If you wish to include ALL of the points along the edges in the boundary, simply choose values for the parameters that are greater than the lengths of the corresponding axes in the CRS.Integer.MAX_VALUE
works great. In that case, the size of the returned list will be2 * numXcoords + 2 * numYcoords
.- Parameters:
maxPointsInYEdge
- the maximum number of boundary points to include from the right and left edges.maxPointsInXEdge
- the maximum number of boundary points to include from the bottom and top edges.- Returns:
- the boundary of this coordinate reference system, in projection coordinates.
- Throws:
UnsupportedOperationException
- if this CRS is not a projection.
-
connectLatLonPoints
public static List<LatLonPointNoNormalize> connectLatLonPoints(List<LatLonPoint> points)
Returns a list of points that is equivalent to the input list, but with longitude values adjusted to ensure that adjacent elements are "connected".Two points are "connected" if the absolute difference of their
normalized longitudes
is≤180
. For example, the longitudes112
and124
are connected. So are15
and-27
.Two points may be "disconnected" if they lie on opposite sides of the international date line. For example, the longitudes
175
and-175
are disconnected because their absolute difference is350
, which is>180
. To connect the two points, we adjust the second longitude to an equivalent value in the range[firstLon ± 180]
by adding or subtracting360
. So,-175
would become185
. We perform this adjustment for each pair of adjacent elements in the list.Performing the above adjustment will result in longitudes that lie outside of the normalized range of (
[-180, 180]
). To be precise, if adjustments are necessary, all of the longitudes in the returned list will be in either[-360, 0]
or[0, 360]
. Consequently, adjusted points cannot be returned asLatLonPoint
s; they are returned asLatLonPointNoNormalize
objects instead.Longitudes
lon1
andlon2
are considered equivalent iflon1 == lon2 + 360 * i
, for some integeri
.- Parameters:
points
- a sequence of normalized lat/lon points that potentially crosses the international date line.- Returns:
- an equivalent sequence of points that has been adjusted to be "connected".
-
getLatLonBoundaryAsWKT
public String getLatLonBoundaryAsWKT()
CallsgetLatLonBoundaryAsWKT(int, int)
withInteger.MAX_VALUE
as both arguments. In effect, the boundary will contain ALL of the points along the edges of the CRS.- Returns:
- the latitude/longitude boundary of this CRS as a polygon in WKT.
-
getLatLonBoundaryAsWKT
public String getLatLonBoundaryAsWKT(int maxPointsInYEdge, int maxPointsInXEdge)
Returns thelatitude/longitude boundary
of this coordinate reference system as a polygon in WKT. It is used in the OpenLayers map in NCSS, as well as the "datasetBoundaries" endpoint.- Parameters:
maxPointsInYEdge
- the maximum number of boundary points to include from the right and left edges.maxPointsInXEdge
- the maximum number of boundary points to include from the bottom and top edges.- Returns:
- the latitude/longitude boundary of this CRS as a polygon in WKT.
-
getLatLonBoundaryAsGeoJSON
public String getLatLonBoundaryAsGeoJSON()
CallsgetLatLonBoundaryAsGeoJSON(int, int)
withInteger.MAX_VALUE
as both arguments. In effect, the boundary will contain ALL of the points along the edges of the CRS.- Returns:
- the latitude/longitude boundary of this CRS as a polygon in GeoJSON.
-
getLatLonBoundaryAsGeoJSON
public String getLatLonBoundaryAsGeoJSON(int maxPointsInYEdge, int maxPointsInXEdge)
Similar togetLatLonBoundaryAsWKT()
, but returns a GeoJSON polygon instead.
-
-