Lambert azimuthal
@@ -145,7 +145,18 @@ static int get_native_type(grib_accessor* a)
{
return GRIB_TYPE_STRING;
}
-
+#if 0
+static int proj_mercator(grib_handle* h, char* result)
+{
+ int err = 0;
+ double LaDInDegrees = 0;
+ if ((err = grib_get_double_internal(h, "LaDInDegrees", &LaDInDegrees)) != GRIB_SUCCESS)
+ return err;
+ sprintf(result, "+proj=merc +lat_ts=%lf +lat_0=0 +lon_0=0 +x_0=0 +y_0=0 +a=%lf +b=%lf",
+ LaDInDegrees, earthMajorAxisInMetres, earthMinorAxisInMetres);
+ return GRIB_SUCCESS;
+}
+#endif
static int unpack_string(grib_accessor* a, char* v, size_t* len)
{
grib_accessor_proj_string* self = (grib_accessor_proj_string*)a;
@@ -167,6 +178,9 @@ static int unpack_string(grib_accessor* a, char* v, size_t* len)
earthMinorAxisInMetres = earthMajorAxisInMetres = radius;
}
+ /* Default: lat/lon grid */
+ sprintf(v,"+proj=latlong +a=%lf +b=%lf", earthMajorAxisInMetres, earthMinorAxisInMetres);
+
if (strcmp(grid_type, "mercator") == 0) {
double LaDInDegrees = 0;
if ((err = grib_get_double_internal(h, "LaDInDegrees", &LaDInDegrees)) != GRIB_SUCCESS)
@@ -201,12 +215,23 @@ static int unpack_string(grib_accessor* a, char* v, size_t* len)
sprintf(v,"+proj=lcc +lon_0=%lf +lat_0=%lf +lat_1=%lf +lat_2=%lf +a=%lf +b=%lf",LoVInDegrees,
LaDInDegrees, Latin1InDegrees,Latin2InDegrees, earthMajorAxisInMetres, earthMinorAxisInMetres);
}
+ else if (strcmp(grid_type, "lambert_azimuthal_equal_area") == 0) {
+ double standardParallel, centralLongitude;
+ if ((err = grib_get_double_internal(h, "standardParallel", &standardParallel)) != GRIB_SUCCESS)
+ return err;
+ if ((err = grib_get_double_internal(h, "centralLongitude", &centralLongitude)) != GRIB_SUCCESS)
+ return err;
+ sprintf(v,"+proj=laea +lon_0=%lf +lat_0=%lf +a=%lf +b=%lf",
+ centralLongitude, standardParallel, earthMajorAxisInMetres, earthMinorAxisInMetres);
+ }
else {
grib_context_log(a->context, GRIB_LOG_ERROR, "proj string for grid '%s' not implemented", grid_type);
*len = 0;
return GRIB_NOT_IMPLEMENTED;
}
- *len = strlen(v) + 1;
+ size = strlen(v);
+ Assert(size > 0);
+ *len = size + 1;
return err;
}
