PCPOINTLIST * pc_pointlist_from_patch(const PCPATCH *patch) { switch ( patch->type ) { case PC_NONE: { return pc_pointlist_from_uncompressed((PCPATCH_UNCOMPRESSED*)patch); } case PC_GHT: { return pc_pointlist_from_ght((PCPATCH_GHT*)patch); } case PC_DIMENSIONAL: { return pc_pointlist_from_dimensional((PCPATCH_DIMENSIONAL*)patch); } case PC_LAZPERF: { return pc_pointlist_from_lazperf((PCPATCH_LAZPERF*)patch); } } /* Don't get here */ pcerror("pc_pointlist_from_patch: unsupported compression type %d", patch->type); return NULL; }
static void test_pointlist_lazperf() { PCPOINT *pt; int i; int npts = 400; PCPOINTLIST *pl1, *pl2; PCPATCH_LAZPERF *pch1; PCPATCH_UNCOMPRESSED *pa1, *pa2; char *wkt1, *wkt2; // build a list of points pl1 = pc_pointlist_make(npts); for ( i = 0; i < npts; i++ ) { pt = pc_point_make(simpleschema); pc_point_set_double_by_name(pt, "x", i*2.0); pc_point_set_double_by_name(pt, "y", i*1.9); pc_point_set_double_by_name(pt, "Z", i*0.34); pc_point_set_double_by_name(pt, "intensity", 10); pc_pointlist_add_point(pl1, pt); } // compress the list in a lazperf patch pch1 = pc_patch_lazperf_from_pointlist( pl1 ); // decompress the lazperf patch in a pointlist pl2 = pc_pointlist_from_lazperf(pch1); // test that the string representation of pointlist is equal pa1 = pc_patch_uncompressed_from_pointlist( pl1 ); pa2 = pc_patch_uncompressed_from_lazperf( pch1 ); wkt1 = pc_patch_uncompressed_to_string(pa1); wkt2 = pc_patch_uncompressed_to_string(pa2); CU_ASSERT_STRING_EQUAL(wkt1, wkt2); pc_patch_free((PCPATCH*) pch1 ); pc_patch_free((PCPATCH*) pa1); pc_patch_free((PCPATCH*) pa2); pc_pointlist_free(pl1); pc_pointlist_free(pl2); pcfree(wkt1); pcfree(wkt2); }