mirror of https://github.com/ecmwf/eccodes.git
Mercator: implement nearest
This commit is contained in:
parent
c4da64d8a7
commit
13ba76f3a8
|
@ -64,6 +64,8 @@ iterator mercator(numberOfPoints,missingValue,values,
|
|||
jPointsAreConsecutive,
|
||||
alternativeRowScanning);
|
||||
|
||||
nearest mercator(values,radius,Nx,Ny);
|
||||
|
||||
meta latLonValues latlonvalues(values);
|
||||
alias latitudeLongitudeValues=latLonValues;
|
||||
meta latitudes latitudes(values,0);
|
||||
|
|
|
@ -75,6 +75,8 @@ iterator mercator(numberOfPoints,missingValue,values,
|
|||
iScansNegatively, jScansPositively,
|
||||
jPointsAreConsecutive, alternativeRowScanning);
|
||||
|
||||
nearest mercator(values,radius,Nx,Ny);
|
||||
|
||||
meta latLonValues latlonvalues(values);
|
||||
alias latitudeLongitudeValues=latLonValues;
|
||||
meta latitudes latitudes(values,0);
|
||||
|
|
|
@ -346,6 +346,7 @@ list( APPEND grib_api_srcs
|
|||
grib_nearest_class_latlon_reduced.c
|
||||
grib_nearest_class_sh.c
|
||||
grib_nearest_class_lambert_conformal.c
|
||||
grib_nearest_class_mercator.c
|
||||
grib_nearest_class_polar_stereographic.c
|
||||
grib_iterator_class_polar_stereographic.c
|
||||
grib_iterator_class_lambert_azimuthal_equal_area.c
|
||||
|
|
|
@ -361,6 +361,7 @@ libeccodes_la_prototypes= \
|
|||
grib_nearest_class_latlon_reduced.c \
|
||||
grib_nearest_class_sh.c \
|
||||
grib_nearest_class_lambert_conformal.c \
|
||||
grib_nearest_class_mercator.c \
|
||||
grib_nearest_class_polar_stereographic.c \
|
||||
grib_iterator_class_polar_stereographic.c \
|
||||
grib_iterator_class_lambert_azimuthal_equal_area.c \
|
||||
|
|
|
@ -323,6 +323,11 @@ int grib_nearest_find_generic(
|
|||
return ret;
|
||||
nearest->values_count = nvalues;
|
||||
|
||||
if (grib_is_earth_oblate(h)) {
|
||||
grib_context_log(h->context, GRIB_LOG_ERROR, "Nearest neighbour functionality only supported for spherical earth.");
|
||||
return GRIB_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
if ((ret = grib_get_long_internal(h, radius_keyname, &iradius)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
if (grib_is_missing(h, radius_keyname, &ret)) {
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
extern grib_nearest_class* grib_nearest_class_gen;
|
||||
extern grib_nearest_class* grib_nearest_class_lambert_conformal;
|
||||
extern grib_nearest_class* grib_nearest_class_latlon_reduced;
|
||||
extern grib_nearest_class* grib_nearest_class_mercator;
|
||||
extern grib_nearest_class* grib_nearest_class_polar_stereographic;
|
||||
extern grib_nearest_class* grib_nearest_class_reduced;
|
||||
extern grib_nearest_class* grib_nearest_class_regular;
|
||||
|
|
|
@ -107,9 +107,9 @@ static int find(grib_nearest* nearest, grib_handle* h,
|
|||
{
|
||||
grib_nearest_lambert_conformal* self = (grib_nearest_lambert_conformal*)nearest;
|
||||
return grib_nearest_find_generic(
|
||||
nearest, h, inlat, inlon, flags,
|
||||
nearest, h, inlat, inlon, flags, /* inputs */
|
||||
|
||||
self->values_key,
|
||||
self->values_key, /* outputs to set the 'self' object */
|
||||
self->radius,
|
||||
&(self->lats),
|
||||
&(self->lats_count),
|
||||
|
@ -119,7 +119,7 @@ static int find(grib_nearest* nearest, grib_handle* h,
|
|||
self->Ni,
|
||||
self->Nj,
|
||||
|
||||
outlats, outlons,
|
||||
outlats, outlons, /* outputs of the find function */
|
||||
values, distances, indexes, len);
|
||||
}
|
||||
|
||||
|
|
|
@ -107,9 +107,9 @@ static int find(grib_nearest* nearest, grib_handle* h,
|
|||
{
|
||||
grib_nearest_mercator* self = (grib_nearest_mercator*)nearest;
|
||||
return grib_nearest_find_generic(
|
||||
nearest, h, inlat, inlon, flags,
|
||||
nearest, h, inlat, inlon, flags, /* inputs */
|
||||
|
||||
self->values_key,
|
||||
self->values_key, /* outputs to set the 'self' object */
|
||||
self->radius,
|
||||
&(self->lats),
|
||||
&(self->lats_count),
|
||||
|
@ -119,7 +119,7 @@ static int find(grib_nearest* nearest, grib_handle* h,
|
|||
self->Ni,
|
||||
self->Nj,
|
||||
|
||||
outlats, outlons,
|
||||
outlats, outlons, /* outputs of the find function */
|
||||
values, distances, indexes, len);
|
||||
}
|
||||
|
||||
|
|
|
@ -107,9 +107,9 @@ static int find(grib_nearest* nearest, grib_handle* h,
|
|||
{
|
||||
grib_nearest_polar_stereographic* self = (grib_nearest_polar_stereographic*)nearest;
|
||||
return grib_nearest_find_generic(
|
||||
nearest, h, inlat, inlon, flags,
|
||||
nearest, h, inlat, inlon, flags, /* inputs */
|
||||
|
||||
self->values_key,
|
||||
self->values_key, /* outputs to set the 'self' object */
|
||||
self->radius,
|
||||
&(self->lats),
|
||||
&(self->lats_count),
|
||||
|
@ -119,7 +119,7 @@ static int find(grib_nearest* nearest, grib_handle* h,
|
|||
self->Ni,
|
||||
self->Nj,
|
||||
|
||||
outlats, outlons,
|
||||
outlats, outlons, /* outputs of the find function */
|
||||
values, distances, indexes, len);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
{ "gen", &grib_nearest_class_gen, },
|
||||
{ "lambert_conformal", &grib_nearest_class_lambert_conformal, },
|
||||
{ "latlon_reduced", &grib_nearest_class_latlon_reduced, },
|
||||
{ "mercator", &grib_nearest_class_mercator, },
|
||||
{ "polar_stereographic", &grib_nearest_class_polar_stereographic, },
|
||||
{ "reduced", &grib_nearest_class_reduced, },
|
||||
{ "regular", &grib_nearest_class_regular, },
|
||||
|
|
|
@ -30,5 +30,9 @@ EOF
|
|||
|
||||
${tools_dir}/grib_filter $tempFilter $input
|
||||
|
||||
# Nearest function
|
||||
${tools_dir}/grib_ls -l 19,-97,1 $input > $tempOut
|
||||
grep -q "Point chosen #1 index=618" $tempOut
|
||||
|
||||
# Clean up
|
||||
rm -f $tempFilter $tempOut
|
||||
|
|
Loading…
Reference in New Issue