Commit 525ef09d authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

gridCompare: refactored.

parent a8435a03
......@@ -2159,18 +2159,9 @@ bool compareXYvals2(grid_t *gridRef, grid_t *gridTest)
}
static
bool gridCompare(int gridID, const grid_t *grid, bool coord_compare)
bool compare_lonlat_and_projection(int gridID, const grid_t *grid, const grid_t *gridRef)
{
bool differ = true;
const grid_t *gridRef = grid_to_pointer(gridID);
if ( grid->type == gridRef->type || grid->type == GRID_GENERIC )
{
if ( grid->size == gridRef->size )
{
differ = false;
if ( grid->type == GRID_LONLAT || grid->type == GRID_PROJECTION )
{
bool differ = false;
/*
printf("gridID %d\n", gridID);
printf("grid.xdef %d\n", grid->x.flag);
......@@ -2216,9 +2207,19 @@ bool gridCompare(int gridID, const grid_t *grid, bool coord_compare)
}
else
differ = true;
}
else if ( grid->type == GRID_GENERIC )
if (!differ && grid->type == GRID_PROJECTION)
{
}
return differ;
}
static
bool compare_generic(const grid_t *grid, const grid_t *gridRef)
{
bool differ = false;
if ( grid->x.size == gridRef->x.size && grid->y.size == gridRef->y.size )
{
if ( grid->x.flag == 1 && grid->y.flag == 1
......@@ -2231,9 +2232,15 @@ bool gridCompare(int gridID, const grid_t *grid, bool coord_compare)
}
else
differ = true;
}
else if ( grid->type == GRID_GAUSSIAN )
{
return differ;
}
static
bool compare_gaussian(int gridID, const grid_t *grid, const grid_t *gridRef)
{
bool differ = false;
if ( grid->x.size == gridRef->x.size && grid->y.size == gridRef->y.size )
{
if ( grid->x.flag == 2 && grid->y.flag == 2 )
......@@ -2252,9 +2259,15 @@ bool gridCompare(int gridID, const grid_t *grid, bool coord_compare)
}
else
differ = true;
}
else if ( grid->type == GRID_CURVILINEAR )
{
return differ;
}
static
bool compare_curvilinear(const grid_t *grid, const grid_t *gridRef)
{
bool differ = false;
/*
printf("gridID %d\n", gridID);
printf("grid.xsize %d\n", grid->x.size);
......@@ -2272,9 +2285,15 @@ bool gridCompare(int gridID, const grid_t *grid, bool coord_compare)
*/
if ( grid->x.size == gridRef->x.size && grid->y.size == gridRef->y.size )
differ = gridRef->vtable->compareXYAO((grid_t *)gridRef, (grid_t *)grid);
}
else if ( grid->type == GRID_UNSTRUCTURED )
{
return differ;
}
static
bool compare_unstructured(const grid_t *grid, const grid_t *gridRef, bool coord_compare)
{
bool differ = false;
unsigned char uuid1[CDI_UUID_SIZE]; memset(uuid1, 0, CDI_UUID_SIZE);
unsigned char uuid2[CDI_UUID_SIZE]; memset(uuid2, 0, CDI_UUID_SIZE);
int length = CDI_UUID_SIZE;
......@@ -2313,6 +2332,40 @@ bool gridCompare(int gridID, const grid_t *grid, bool coord_compare)
}
}
}
return differ;
}
static
bool gridCompare(int gridID, const grid_t *grid, bool coord_compare)
{
bool differ = true;
const grid_t *gridRef = grid_to_pointer(gridID);
if ( grid->type == gridRef->type || grid->type == GRID_GENERIC )
{
if ( grid->size == gridRef->size )
{
differ = false;
if ( grid->type == GRID_LONLAT || grid->type == GRID_PROJECTION )
{
differ = compare_lonlat_and_projection(gridID, grid, gridRef);
}
else if ( grid->type == GRID_GENERIC )
{
differ = compare_generic(grid, gridRef);
}
else if ( grid->type == GRID_GAUSSIAN )
{
differ = compare_gaussian(gridID, grid, gridRef);
}
else if ( grid->type == GRID_CURVILINEAR )
{
differ = compare_curvilinear(grid, gridRef);
}
else if ( grid->type == GRID_UNSTRUCTURED )
{
differ = compare_unstructured(grid, gridRef, coord_compare);
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment