Test for GHT patch

This commit is contained in:
Paul Ramsey 2013-05-06 13:49:36 -07:00
parent 824dff7b27
commit 0b30dc5d0b
7 changed files with 163 additions and 18 deletions

View File

@ -11,7 +11,8 @@ OBJS = \
cu_tester.o \
cu_pc_schema.o \
cu_pc_point.o \
cu_pc_patch.o
cu_pc_patch.o \
cu_pc_patch_ght.o
# Build the unit tester
all: $(EXE)

101
lib/cunit/cu_pc_patch_ght.c Normal file
View File

@ -0,0 +1,101 @@
/***********************************************************************
* cu_pc_schema.c
*
* Testing for the schema API functions
*
* Portions Copyright (c) 2012, OpenGeo
*
***********************************************************************/
#include "CUnit/Basic.h"
#include "cu_tester.h"
/* GLOBALS ************************************************************/
static PCSCHEMA *simpleschema = NULL;
static const char *simplexmlfile = "data/simple-schema-fine.xml";
/* Setup/teardown for this suite */
static int
init_suite(void)
{
char *xmlstr = file_to_str(simplexmlfile);
int rv = pc_schema_from_xml(xmlstr, &simpleschema);
pcfree(xmlstr);
if ( rv == PC_FAILURE ) return 1;
return 0;
}
static int
clean_suite(void)
{
pc_schema_free(simpleschema);
return 0;
}
/* TESTS **************************************************************/
#ifdef HAVE_LIBGHT
static void
test_patch_ght()
{
PCPOINT *pt;
int i;
int npts = 100;
PCPOINTLIST *pl1, *pl2;
PCPATCH_GHT *pag;
PCPATCH_UNCOMPRESSED *pu;
pl1 = pc_pointlist_make(npts);
for ( i = 0; i < npts; i++ )
{
pt = pc_point_make(simpleschema);
pc_point_set_double_by_name(pt, "x", 45 + i*0.000004);
pc_point_set_double_by_name(pt, "y", 45 + i*0.000001666);
pc_point_set_double_by_name(pt, "Z", 10 + i*0.34);
pc_point_set_double_by_name(pt, "intensity", 10);
pc_pointlist_add_point(pl1, pt);
}
pag = pc_patch_ght_from_pointlist(pl1);
pu = pc_patch_uncompressed_from_ght(pag);
CU_ASSERT_EQUAL(npts, pag->npoints);
CU_ASSERT_EQUAL(npts, pu->npoints);
CU_ASSERT_DOUBLE_EQUAL(pag->xmax, 45.0004, 0.0001);
CU_ASSERT_DOUBLE_EQUAL(pag->ymax, 45.000165, 0.000001);
// pl2 = pc_pointlist_from_uncompressed(pu);
// for ( i = 0; i < npts; i++ )
// {
// PCPOINT *pt = pc_pointlist_get_point(pl2, i);
// double x, y, z, ints;
// pc_point_get_double_by_name(pt, "x", &x);
// pc_point_get_double_by_name(pt, "y", &y);
// pc_point_get_double_by_name(pt, "Z", &z);
// pc_point_get_double_by_name(pt, "intensity", &ints);
// printf("(%g %g %g) %g\n", x, y, z, ints);
// }
// pc_pointlist_free(pl2);
pc_patch_uncompressed_free(pu);
pc_patch_ght_free(pag);
pc_pointlist_free(pl1);
}
#endif /* HAVE_LIBGHT */
/* REGISTER ***********************************************************/
CU_TestInfo ght_tests[] = {
#ifdef HAVE_LIBGHT
PC_TEST(test_patch_ght),
#endif
CU_TEST_INFO_NULL
};
CU_SuiteInfo ght_suite = {"ght", init_suite, clean_suite, ght_tests};

View File

@ -16,6 +16,7 @@
extern CU_SuiteInfo schema_suite;
extern CU_SuiteInfo patch_suite;
extern CU_SuiteInfo point_suite;
extern CU_SuiteInfo ght_suite;
/*
** The main() function for setting up and running the tests.
@ -30,6 +31,7 @@ int main(int argc, char *argv[])
schema_suite,
patch_suite,
point_suite,
ght_suite,
CU_SUITE_INFO_NULL
};

View File

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<pc:PointCloudSchema xmlns:pc="http://pointcloud.org/schemas/PC/1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<pc:dimension>
<pc:position>1</pc:position>
<pc:size>4</pc:size>
<pc:description>X coordinate as a long integer. You must use the scale and offset information of the header to determine the double value.</pc:description>
<pc:name>X</pc:name>
<pc:interpretation>int32_t</pc:interpretation>
<pc:scale>0.000001</pc:scale>
</pc:dimension>
<pc:dimension>
<pc:position>2</pc:position>
<pc:size>4</pc:size>
<pc:description>Y coordinate as a long integer. You must use the scale and offset information of the header to determine the double value.</pc:description>
<pc:name>Y</pc:name>
<pc:interpretation>int32_t</pc:interpretation>
<pc:scale>0.000001</pc:scale>
</pc:dimension>
<pc:dimension>
<pc:position>3</pc:position>
<pc:size>4</pc:size>
<pc:description>Z coordinate as a long integer. You must use the scale and offset information of the header to determine the double value.</pc:description>
<pc:name>Z</pc:name>
<pc:interpretation>int32_t</pc:interpretation>
<pc:scale>0.01</pc:scale>
</pc:dimension>
<pc:dimension>
<pc:position>4</pc:position>
<pc:size>2</pc:size>
<pc:description>The intensity value is the integer representation of the pulse return magnitude. This value is optional and system specific. However, it should always be included if available.</pc:description>
<pc:name>Intensity</pc:name>
<pc:interpretation>uint16_t</pc:interpretation>
<pc:scale>1</pc:scale>
</pc:dimension>
<pc:metadata>
<Metadata name="compression">dimensional</Metadata>
<Metadata name="ght_xmin"></Metadata>
<Metadata name="ght_ymin"></Metadata>
<Metadata name="ght_xmax"></Metadata>
<Metadata name="ght_ymax"></Metadata>
<Metadata name="ght_keylength"></Metadata>
<Metadata name="ght_depth"></Metadata>
<Metadata name="spatialreference" type="id">4326</Metadata>
</pc:metadata>
</pc:PointCloudSchema>

View File

@ -220,10 +220,6 @@ void pc_set_handlers(pc_allocator allocator, pc_reallocator reallocator,
pc_deallocator deallocator, pc_message_handler error_handler,
pc_message_handler info_handler, pc_message_handler warning_handler);
void pc_set_ght_handlers(pc_allocator allocator, pc_reallocator reallocator,
pc_deallocator deallocator, pc_message_handler error_handler,
pc_message_handler info_handler, pc_message_handler warning_handler);
/** Set program to use system memory allocators and messaging */
void pc_install_default_handlers(void);

View File

@ -88,8 +88,15 @@ void pc_install_default_handlers(void)
pc_context.realloc = default_reallocator;
pc_context.free = default_freeor;
pc_context.err = default_error_handler;
pc_context.warn = default_warn_handler;
pc_context.info = default_info_handler;
pc_context.warn = default_warn_handler;
#ifdef HAVE_LIBGHT
ght_set_handlers((void *)default_allocator, (void *)default_reallocator,
(void *)default_freeor, (void *)default_error_handler,
(void *)default_info_handler, (void *)default_warn_handler);
#endif
}
void pc_set_handlers(pc_allocator allocator, pc_reallocator reallocator,
@ -102,18 +109,15 @@ void pc_set_handlers(pc_allocator allocator, pc_reallocator reallocator,
pc_context.err = error_handler;
pc_context.warn = warn_handler;
pc_context.info = info_handler;
}
void pc_set_ght_handlers(pc_allocator allocator, pc_reallocator reallocator,
pc_deallocator deallocator, pc_message_handler error_handler,
pc_message_handler info_handler, pc_message_handler warn_handler)
{
#ifdef HAVE_LIBGHT
ght_set_handlers((void *)allocator, (void *)reallocator,
(void *)deallocator, (void *)error_handler,
ght_set_handlers((void *)allocator, (void *)reallocator,
(void *)deallocator, (void *)error_handler,
(void *)info_handler, (void *)warn_handler);
#endif
return;
}

View File

@ -104,10 +104,6 @@ _PG_init(void)
pgsql_free, pgsql_error,
pgsql_info, pgsql_warn);
/* This will just no-op if LibGHT is not present */
pc_set_ght_handlers(pgsql_alloc, pgsql_realloc,
pgsql_free, pgsql_error,
pgsql_info, pgsql_warn);
}
/* Module unload callback */