Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mpim-sw
libcdi
Commits
55b2062c
Commit
55b2062c
authored
Aug 03, 2016
by
Uwe Schulzweida
Browse files
Added function gridVerifyProj().
parent
d5f89159
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/cdf_write.c
View file @
55b2062c
...
...
@@ -624,9 +624,9 @@ int cdfDefVar(stream_t *streamptr, int varID)
char
gmapvarname
[
CDI_MAX_NAME
];
gmapvarname
[
0
]
=
0
;
if
(
gridtype
==
GRID_SINUSOIDAL
)
strcpy
(
gmapvarname
,
"
s
inusoidal"
);
else
if
(
gridtype
==
GRID_LAEA
)
strcpy
(
gmapvarname
,
"
laea
"
);
else
if
(
gridtype
==
GRID_LCC2
)
strcpy
(
gmapvarname
,
"Lambert_C
onformal
"
);
if
(
gridtype
==
GRID_SINUSOIDAL
)
strcpy
(
gmapvarname
,
"
S
inusoidal"
);
else
if
(
gridtype
==
GRID_LAEA
)
strcpy
(
gmapvarname
,
"
Lambert_AEA
"
);
else
if
(
gridtype
==
GRID_LCC2
)
strcpy
(
gmapvarname
,
"Lambert_C
C
"
);
else
if
(
gridtype
==
GRID_LONLAT
&&
gridIsRotated
(
gridID
)
)
strcpy
(
gmapvarname
,
"rotated_pole"
);
else
cdf_get_gmapvarname
(
gridID
,
gmapvarname
);
...
...
src/cdi.h
View file @
55b2062c
...
...
@@ -145,6 +145,7 @@ extern "C" {
#define CDI_PROJ_RLL 21
/* Rotated Latitude Longitude */
#define CDI_PROJ_LCC 22
/* Lambert Conformal Conic */
#define CDI_PROJ_LAEA 23
/* Lambert Azimuthal Equal Area */
#define CDI_PROJ_SINU 24
/* Sinusoidal */
/* ZAXIS types */
...
...
@@ -724,12 +725,12 @@ void gridDestroy(int gridID);
/* gridDuplicate: Duplicate a Grid */
int
gridDuplicate
(
int
gridID
);
/* gridDefProj: Define the projection ID of a Grid */
void
gridDefProj
(
int
gridID
,
int
projID
);
/* gridInqProj: Get the projection ID of a Grid */
int
gridInqProj
(
int
gridID
);
/* gridDefProjType: Define the projection type */
void
gridDefProjType
(
int
gridID
,
int
projtype
);
/* gridInqProjType: Get the projection type */
int
gridInqProjType
(
int
gridID
);
...
...
src/grid.c
View file @
55b2062c
...
...
@@ -200,8 +200,8 @@ void grid_free(grid_t *gridptr)
grid_init
(
gridptr
);
}
static
grid_t
*
gridNewEntry
(
cdiResH
resH
)
static
grid_t
*
gridNewEntry
(
cdiResH
resH
)
{
grid_t
*
gridptr
=
(
grid_t
*
)
Malloc
(
sizeof
(
grid_t
));
grid_init
(
gridptr
);
...
...
@@ -270,28 +270,31 @@ void gridGetString(char *name, const char *gridstrname, size_t len)
name
[
len
-
1
]
=
0
;
}
static
inline
void
gridSetName
(
char
*
gridstrname
,
const
char
*
name
)
static
inline
void
gridSetName
(
char
*
gridstrname
,
const
char
*
name
)
{
strncpy
(
gridstrname
,
name
,
CDI_MAX_NAME
);
gridstrname
[
CDI_MAX_NAME
-
1
]
=
0
;
}
void
cdiGridTypeInit
(
grid_t
*
gridptr
,
int
gridtype
,
int
size
)
void
cdiGridTypeInit
(
grid_t
*
gridptr
,
int
gridtype
,
int
size
)
{
gridptr
->
type
=
gridtype
;
gridptr
->
size
=
size
;
if
(
gridtype
==
GRID_CURVILINEAR
)
gridptr
->
nvertex
=
4
;
else
if
(
gridtype
==
GRID_UNSTRUCTURED
)
gridptr
->
x
.
size
=
size
;
switch
(
gridtype
)
{
case
GRID_CURVILINEAR
:
gridptr
->
nvertex
=
4
;
/* Fall through */
case
GRID_LONLAT
:
case
GRID_GAUSSIAN
:
case
GRID_GAUSSIAN_REDUCED
:
case
GRID_TRAJECTORY
:
case
GRID_CURVILINEAR
:
case
GRID_UNSTRUCTURED
:
case
GRID_GME
:
{
if
(
gridtype
==
GRID_TRAJECTORY
)
{
...
...
@@ -303,71 +306,36 @@ cdiGridTypeInit(grid_t *gridptr, int gridtype, int size)
if
(
gridptr
->
x
.
name
[
0
]
==
0
)
gridSetName
(
gridptr
->
x
.
name
,
"lon"
);
if
(
gridptr
->
y
.
name
[
0
]
==
0
)
gridSetName
(
gridptr
->
y
.
name
,
"lat"
);
}
gridSetName
(
gridptr
->
x
.
longname
,
"longitude"
);
gridSetName
(
gridptr
->
y
.
longname
,
"latitude"
);
/*
if ( gridtype == GRID_CURVILINEAR )
{
gridptr->x.stdname = xystdname_tab[grid_xystdname_grid_latlon][0];
gridptr->y.stdname = xystdname_tab[grid_xystdname_grid_latlon][1];
gridDefXunits(gridID, "degrees");
gridDefYunits(gridID, "degrees");
}
else
*/
{
gridptr
->
x
.
stdname
=
xystdname_tab
[
grid_xystdname_latlon
][
0
];
gridptr
->
y
.
stdname
=
xystdname_tab
[
grid_xystdname_latlon
][
1
];
gridSetName
(
gridptr
->
x
.
units
,
"degrees_east"
);
gridSetName
(
gridptr
->
y
.
units
,
"degrees_north"
);
}
break
;
}
case
GRID_UNSTRUCTURED
:
gridptr
->
x
.
size
=
size
;
/* Fall through */
case
GRID_GME
:
{
if
(
gridptr
->
x
.
name
[
0
]
==
0
)
gridSetName
(
gridptr
->
x
.
name
,
"lon"
);
if
(
gridptr
->
y
.
name
[
0
]
==
0
)
gridSetName
(
gridptr
->
y
.
name
,
"lat"
);
gridptr
->
x
.
stdname
=
xystdname_tab
[
grid_xystdname_latlon
][
0
];
gridptr
->
y
.
stdname
=
xystdname_tab
[
grid_xystdname_latlon
][
1
];
gridSetName
(
gridptr
->
x
.
units
,
"degrees_east"
);
gridSetName
(
gridptr
->
y
.
units
,
"degrees_north"
);
break
;
}
case
GRID_GENERIC
:
case
GRID_PROJECTION
:
case
GRID_LCC2
:
case
GRID_SINUSOIDAL
:
case
GRID_LAEA
:
{
if
(
gridptr
->
x
.
name
[
0
]
==
0
)
gridSetName
(
gridptr
->
x
.
name
,
"x"
);
if
(
gridptr
->
y
.
name
[
0
]
==
0
)
gridSetName
(
gridptr
->
y
.
name
,
"y"
);
if
(
gridtype
==
GRID_PROJECTION
)
{
gridSetName
(
gridptr
->
mapname
,
"Projection"
);
}
/*
strcpy(gridptr->x.stdname, "grid_longitude");
strcpy(gridptr->y.stdname, "grid_latitude");
gridptr->x.stdname = xystdname_tab[grid_xystdname_grid_latlon][0];
gridptr->y.stdname = xystdname_tab[grid_xystdname_grid_latlon][1];
gridDefXunits(gridID, "degrees");
gridDefYunits(gridID, "degrees");
*/
break
;
}
case
GRID_LCC2
:
case
GRID_SINUSOIDAL
:
case
GRID_LAEA
:
{
if
(
gridptr
->
x
.
name
[
0
]
==
0
)
gridSetName
(
gridptr
->
x
.
name
,
"x"
);
if
(
gridptr
->
y
.
name
[
0
]
==
0
)
gridSetName
(
gridptr
->
y
.
name
,
"y"
);
gridptr
->
x
.
stdname
=
xystdname_tab
[
grid_xystdname_projection
][
0
];
gridptr
->
y
.
stdname
=
xystdname_tab
[
grid_xystdname_projection
][
1
];
gridSetName
(
gridptr
->
x
.
units
,
"m"
);
gridSetName
(
gridptr
->
y
.
units
,
"m"
);
if
(
gridtype
!=
GRID_GENERIC
)
{
gridptr
->
x
.
stdname
=
xystdname_tab
[
grid_xystdname_projection
][
0
];
gridptr
->
y
.
stdname
=
xystdname_tab
[
grid_xystdname_projection
][
1
];
gridSetName
(
gridptr
->
x
.
units
,
"m"
);
gridSetName
(
gridptr
->
y
.
units
,
"m"
);
}
break
;
}
}
...
...
@@ -1037,6 +1005,22 @@ int gridInqProjType(int gridID)
return
projtype
;
}
void
gridVerifyProj
(
int
gridID
)
{
grid_t
*
gridptr
=
gridID2Ptr
(
gridID
);
int
projtype
=
gridInqProjType
(
gridID
);
if
(
projtype
==
CDI_PROJ_RLL
)
{
gridptr
->
x
.
stdname
=
xystdname_tab
[
grid_xystdname_grid_latlon
][
0
];
gridptr
->
y
.
stdname
=
xystdname_tab
[
grid_xystdname_grid_latlon
][
1
];
gridSetName
(
gridptr
->
x
.
units
,
"degrees"
);
gridSetName
(
gridptr
->
y
.
units
,
"degrees"
);
}
}
/*
@Function gridInqType
@Title Get the type of a Grid
...
...
src/grid.h
View file @
55b2062c
...
...
@@ -146,6 +146,8 @@ extern const struct gridVirtTable cdiGridVtable;
unsigned
cdiGridCount
(
void
);
void
gridVerifyProj
(
int
gridID
);
const
double
*
gridInqXvalsPtr
(
int
gridID
);
const
double
*
gridInqYvalsPtr
(
int
gridID
);
...
...
src/stream_cdf_i.c
View file @
55b2062c
...
...
@@ -2725,6 +2725,7 @@ void cdf_define_all_grids(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int
const
char
*
gmapname
=
ncvars
[
gmapvarid
].
name
;
cdf_read_mapping_atts
(
ncid
,
gmapvarid
,
projID
,
gmapname
);
cdiGridDefKeyStr
(
projID
,
CDI_KEY_MAPNAME
,
(
int
)(
strlen
(
gmapname
)
+
1
),
gmapname
);
gridVerifyProj
(
projID
);
}
if
(
grid
->
type
==
GRID_UNSTRUCTURED
&&
gridfile
[
0
]
!=
0
)
...
...
src/stream_cdf_o.c
View file @
55b2062c
...
...
@@ -1961,7 +1961,7 @@ void cdfDefMapping(stream_t *streamptr, int gridID)
if
(
gridInqType
(
gridID
)
==
GRID_SINUSOIDAL
)
{
static
const
char
varname
[]
=
"
s
inusoidal"
;
static
const
char
varname
[]
=
"
S
inusoidal"
;
static
const
char
mapname
[]
=
"sinusoidal"
;
cdf_redef
(
fileID
);
...
...
@@ -1980,7 +1980,7 @@ void cdfDefMapping(stream_t *streamptr, int gridID)
}
else
if
(
gridInqType
(
gridID
)
==
GRID_LAEA
)
{
static
const
char
varname
[]
=
"
laea
"
;
static
const
char
varname
[]
=
"
Lambert_AEA
"
;
static
const
char
mapname
[]
=
"lambert_azimuthal_equal_area"
;
cdf_redef
(
fileID
);
...
...
@@ -2002,7 +2002,7 @@ void cdfDefMapping(stream_t *streamptr, int gridID)
}
else
if
(
gridInqType
(
gridID
)
==
GRID_LCC2
)
{
static
const
char
varname
[]
=
"Lambert_C
onformal
"
;
static
const
char
varname
[]
=
"Lambert_C
C
"
;
static
const
char
mapname
[]
=
"lambert_conformal_conic"
;
cdf_redef
(
fileID
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment