예제 #1
0
static void
test_patch_filter()
{
    int i;
    int npts = 20;
    PCPOINTLIST *pl1, *pl2;
    PCPATCH *pa1, *pa2, *pa3, *pa4;
    char *str1, *str2;

    pl1 = pc_pointlist_make(npts);
    pl2 = pc_pointlist_make(npts);

    for ( i = 0; i < npts; i++ )
    {
        PCPOINT *pt1 = pc_point_make(simpleschema);
        PCPOINT *pt2 = pc_point_make(simpleschema);
        pc_point_set_double_by_name(pt1, "x", i);
        pc_point_set_double_by_name(pt1, "y", i);
        pc_point_set_double_by_name(pt1, "Z", i*0.1);
        pc_point_set_double_by_name(pt1, "intensity", 100-i);
        pc_pointlist_add_point(pl1, pt1);
        pc_point_set_double_by_name(pt2, "x", i);
        pc_point_set_double_by_name(pt2, "y", i);
        pc_point_set_double_by_name(pt2, "Z", i*0.1);
        pc_point_set_double_by_name(pt2, "intensity", 100-i);
        pc_pointlist_add_point(pl2, pt2);
    }

    // PCPATCH* pc_patch_filter(const PCPATCH *pa, uint32_t dimnum, PC_FILTERTYPE filter, double val1, double val2);

    pa1 = (PCPATCH*)pc_patch_dimensional_from_pointlist(pl1);
    // printf("pa1\n%s\n", pc_patch_to_string(pa1));
    pa2 = pc_patch_filter(pa1, 0, PC_GT, 17, 20);
    str1 = pc_patch_to_string(pa2);
    // printf("pa2\n%s\n", str1);
    CU_ASSERT_STRING_EQUAL(str1, "{\"pcid\":0,\"pts\":[[18,18,1.8,82],[19,19,1.9,81]]}");

    pa3 = (PCPATCH*)pc_patch_uncompressed_from_pointlist(pl2);
    // printf("\npa3\n%s\n", pc_patch_to_string(pa3));
    pa4 = pc_patch_filter(pa3, 0, PC_GT, 17, 20);
    str2 = pc_patch_to_string(pa4);
    // printf("\npa4\n%s\n", str2);
    CU_ASSERT_STRING_EQUAL(str2, "{\"pcid\":0,\"pts\":[[18,18,1.8,82],[19,19,1.9,81]]}");

    pcfree(str1);
    pcfree(str2);

    pc_pointlist_free(pl1);
    pc_pointlist_free(pl2);
    pc_patch_free(pa1);
    pc_patch_free(pa3);
    pc_patch_free(pa4);
    pc_patch_free(pa2);
    
    return;



}
예제 #2
0
static void
test_patch_compress_from_ght_to_lazperf()
{
	PCPOINT *point;
	PCPOINTLIST *pointlist;
	PCPATCH_GHT *patch_ght;
	PCPATCH_LAZPERF *patch_lazperf;

	pointlist = pc_pointlist_make(1);
	point = pc_point_make(simplelazschema);
	pc_point_set_double_by_name(point, "x", 2.0);
	pc_point_set_double_by_name(point, "y", 1.9);
	pc_point_set_double_by_name(point, "Z", 0.34);
	pc_point_set_double_by_name(point, "intensity", 10);
	pc_pointlist_add_point(pointlist, point);

	patch_ght = pc_patch_ght_from_pointlist(pointlist);
	CU_ASSERT(patch_ght->type == PC_GHT);

	patch_lazperf = (PCPATCH_LAZPERF *)pc_patch_compress((PCPATCH *)patch_ght, NULL);
	CU_ASSERT(patch_lazperf != NULL);
	CU_ASSERT(patch_lazperf->type == PC_LAZPERF);

	pc_pointlist_free(pointlist);
	pc_patch_free((PCPATCH *)patch_ght);
	pc_patch_free((PCPATCH *)patch_lazperf);
}
예제 #3
0
static void
test_patch_range_compression_none_with_full_range()
{
	int i;
	int npts = 4;
	PCPOINTLIST *pl;
	PCPATCH *pa;
	PCPATCH *par;
	char *str;

	pl = pc_pointlist_make(npts);

	for ( i = 0; i < npts; i++ )
	{
		PCPOINT *pt = pc_point_make(simpleschema);
		pc_point_set_double_by_name(pt, "X", i);
		pc_point_set_double_by_name(pt, "Y", i);
		pc_point_set_double_by_name(pt, "Z", i * 0.1);
		pc_point_set_double_by_name(pt, "Intensity", 100 - i);
		pc_pointlist_add_point(pl, pt);
	}

	pa = (PCPATCH*)pc_patch_uncompressed_from_pointlist(pl);
	par = pc_patch_range(pa, 1, npts);
	CU_ASSERT(pa == par);

	str = pc_patch_to_string(par);
	CU_ASSERT_STRING_EQUAL(str,
	"{\"pcid\":0,\"pts\":[[0,0,0,100],[1,1,0.1,99],[2,2,0.2,98],[3,3,0.3,97]]}");

	pcfree(str);
	pc_patch_free(pa);
	pc_pointlist_free(pl);
}
예제 #4
0
static void
test_patch_range_compression_none_with_bad_arguments(int first, int count)
{
	int i;
	int npts = 20;
	PCPOINTLIST *pl;
	PCPATCH *pa;
	PCPATCH *par;

	pl = pc_pointlist_make(npts);

	for ( i = 0; i < npts; i++ )
	{
		PCPOINT *pt = pc_point_make(simpleschema);
		pc_point_set_double_by_name(pt, "X", i);
		pc_point_set_double_by_name(pt, "Y", i);
		pc_point_set_double_by_name(pt, "Z", i * 0.1);
		pc_point_set_double_by_name(pt, "Intensity", 100 - i);
		pc_pointlist_add_point(pl, pt);
	}

	pa = (PCPATCH*)pc_patch_uncompressed_from_pointlist(pl);
	par = pc_patch_range(pa, first, count);
	CU_ASSERT(par == NULL);

	pc_patch_free(pa);
	pc_pointlist_free(pl);
}
예제 #5
0
static void
test_patch_filter_lazperf_zero_point()
{
	PCPOINT *pt;
	int i;
	int npts = 5;
	PCPOINTLIST *pl;
	PCPATCH_LAZPERF *pal;
	PCPATCH *pa;

	// build a list of points
	pl = 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(pl, pt);
	}

	// build patch lazperf
	pal = pc_patch_lazperf_from_pointlist(pl);

	// filter with a resulting patch of 0 point(s)
	pa = pc_patch_filter((PCPATCH*) pal, 0, PC_BETWEEN, 0.0, 0.0);
	CU_ASSERT_EQUAL(pa->npoints, 0);

	pc_patch_free((PCPATCH*) pal);
	pc_patch_free((PCPATCH*) pa);
	pc_pointlist_free(pl);
}
예제 #6
0
static void
test_patch_range_compression_lazperf()
{
	int i;
	int npts = 20;
	PCPOINTLIST *pl;
	PCPATCH *pa;
	PCPATCH *par;
	char *str;

	pl = pc_pointlist_make(npts);

	for ( i = 0; i < npts; i++ )
	{
		PCPOINT *pt = pc_point_make(simpleschema);
		pc_point_set_double_by_name(pt, "X", i);
		pc_point_set_double_by_name(pt, "Y", i);
		pc_point_set_double_by_name(pt, "Z", i * 0.1);
		pc_point_set_double_by_name(pt, "Intensity", 100 - i);
		pc_pointlist_add_point(pl, pt);
	}

	pa = (PCPATCH*)pc_patch_lazperf_from_pointlist(pl);
	par = pc_patch_range(pa, 16, 4);
	str = pc_patch_to_string(par);

	CU_ASSERT_STRING_EQUAL(str,
	"{\"pcid\":0,\"pts\":[[15,15,1.5,85],[16,16,1.6,84],[17,17,1.7,83],[18,18,1.8,82]]}");

	pcfree(str);
	pc_patch_free(par);
	pc_patch_free(pa);
	pc_pointlist_free(pl);
}
예제 #7
0
PCPOINTLIST *
pc_pointlist_from_dimensional(const PCPATCH_DIMENSIONAL *pdl)
{
	PCPOINTLIST *pl;
	PCPATCH_DIMENSIONAL *pdl_uncompressed;
	const PCSCHEMA *schema = pdl->schema;
	int i, j, ndims, npoints;
	assert(pdl);

	pdl_uncompressed = pc_patch_dimensional_decompress(pdl);

	ndims = schema->ndims;
	npoints = pdl->npoints;
	pl = pc_pointlist_make(npoints);

	for ( i = 0; i < npoints; i++ )
	{
		PCPOINT *pt = pc_point_make(schema);
		for ( j = 0; j < ndims; j++ )
		{
			PCDIMENSION *dim = pc_schema_get_dimension(schema, j);

			uint8_t *in = pdl_uncompressed->bytes[j].bytes + dim->size * i;
			uint8_t *out = pt->data + dim->byteoffset;
			memcpy(out, in, dim->size);
		}
		pc_pointlist_add_point(pl, pt);
	}
	pc_patch_dimensional_free(pdl_uncompressed);

	return pl;
}
예제 #8
0
static void
test_patch_union()
{
	int i;
	int npts = 20;
	PCPOINTLIST *pl1;
	PCPATCH *pu;
	PCPATCH **palist;

	pl1 = pc_pointlist_make(npts);

	for ( i = 0; i < npts; i++ )
	{
		PCPOINT *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);
	}

	palist = pcalloc(2*sizeof(PCPATCH*));

	palist[0] = (PCPATCH*)pc_patch_dimensional_from_pointlist(pl1);
	palist[1] = (PCPATCH*)pc_patch_uncompressed_from_pointlist(pl1);

	pu = pc_patch_from_patchlist(palist, 2);
	CU_ASSERT_EQUAL(pu->npoints, 2*npts);

	pc_pointlist_free(pl1);
	pc_patch_free(pu);
	pc_patch_free(palist[0]);
	pc_patch_free(palist[1]);
	pcfree(palist);
}
예제 #9
0
/*
* Write an uncompressed patch out to hex
*/
static void
test_patch_hex_out()
{
	// 00 endian
	// 00000000 pcid
	// 00000000 compression
	// 00000002 npoints
	// 0000000200000003000000050006 pt1 (XYZi)
	// 0000000200000003000000050008 pt2 (XYZi)

	static char *wkt_result = "{\"pcid\":0,\"pts\":[[0.02,0.03,0.05,6],[0.02,0.03,0.05,8]]}";
	static char *hexresult_xdr =
	   "0000000000000000000000000200000002000000030000000500060000000200000003000000050008";
	static char *hexresult_ndr =
	   "0100000000000000000200000002000000030000000500000006000200000003000000050000000800";

	double d0[4] = { 0.02, 0.03, 0.05, 6 };
	double d1[4] = { 0.02, 0.03, 0.05, 8 };

	PCPOINT *pt0 = pc_point_from_double_array(simpleschema, d0, 4);
	PCPOINT *pt1 = pc_point_from_double_array(simpleschema, d1, 4);

	PCPATCH_UNCOMPRESSED *pa;
	uint8_t *wkb;
	size_t wkbsize;
	char *hexwkb;
	char *wkt;

	PCPOINTLIST *pl = pc_pointlist_make(2);
	pc_pointlist_add_point(pl, pt0);
	pc_pointlist_add_point(pl, pt1);

	pa = pc_patch_uncompressed_from_pointlist(pl);
	wkb = pc_patch_uncompressed_to_wkb(pa, &wkbsize);
	// printf("wkbsize %zu\n", wkbsize);
	hexwkb = hexbytes_from_bytes(wkb, wkbsize);

	// printf("hexwkb %s\n", hexwkb);
	// printf("hexresult_ndr %s\n", hexresult_ndr);
	// printf("machine_endian %d\n", machine_endian());
	if ( machine_endian() == PC_NDR )
	{
		CU_ASSERT_STRING_EQUAL(hexwkb, hexresult_ndr);
	}
	else
	{
		CU_ASSERT_STRING_EQUAL(hexwkb, hexresult_xdr);
	}

	wkt = pc_patch_uncompressed_to_string(pa);
	// printf("wkt %s\n", wkt);
	CU_ASSERT_STRING_EQUAL(wkt, wkt_result);

	pc_patch_free((PCPATCH*)pa);
	pc_pointlist_free(pl);
	pcfree(hexwkb);
	pcfree(wkb);
	pcfree(wkt);
}
예제 #10
0
static void
test_patch_wkb()
{
    int i;
    int npts = 20;
    PCPOINTLIST *pl1;
    PCPATCH_UNCOMPRESSED *pu1, *pu2;
    PCPATCH *pa1, *pa2, *pa3, *pa4;
    PCDIMSTATS *pds = NULL;
    size_t z1, z2;
    uint8_t *wkb1, *wkb2;
    char *str;

    pl1 = pc_pointlist_make(npts);

    for ( i = 0; i < npts; i++ )
    {
        PCPOINT *pt = pc_point_make(simpleschema);
        pc_point_set_double_by_name(pt, "x", i*2.123);
        pc_point_set_double_by_name(pt, "y", i*2.9);
        pc_point_set_double_by_name(pt, "Z", i*0.3099);
        pc_point_set_double_by_name(pt, "intensity", 13);
        pc_pointlist_add_point(pl1, pt);
    }

    pa1 = (PCPATCH*)pc_patch_dimensional_from_pointlist(pl1);
    wkb1 = pc_patch_to_wkb(pa1, &z1);
    str = hexbytes_from_bytes(wkb1, z1);
    // printf("str\n%s\n",str);
    pa2 = pc_patch_from_wkb(simpleschema, wkb1, z1);

    // printf("pa2\n%s\n",pc_patch_to_string(pa2));

    pa3 = pc_patch_compress(pa2, NULL);

    // printf("pa3\n%s\n",pc_patch_to_string(pa3));

    wkb2 = pc_patch_to_wkb(pa3, &z2);
    pa4 = pc_patch_from_wkb(simpleschema, wkb2, z2);

    // printf("pa4\n%s\n",pc_patch_to_string(pa4));

    pu1 = (PCPATCH_UNCOMPRESSED*)pc_patch_uncompressed_from_dimensional((PCPATCH_DIMENSIONAL*)pa1);
    pu2 = (PCPATCH_UNCOMPRESSED*)pc_patch_uncompressed_from_dimensional((PCPATCH_DIMENSIONAL*)pa4);

    // printf("pu1\n%s\n", pc_patch_to_string((PCPATCH*)pu1));
    // printf("pu2\n%s\n", pc_patch_to_string((PCPATCH*)pu2));

    CU_ASSERT_EQUAL(pu1->datasize, pu2->datasize);
    CU_ASSERT_EQUAL(pu1->npoints, pu2->npoints);
    CU_ASSERT(memcmp(pu1->data, pu2->data, pu1->datasize) == 0);


    pc_pointlist_free(pl1);
    pc_patch_free(pa1);
    pc_patch_free(pa2);
    pcfree(wkb1);
}
예제 #11
0
static void
test_patch_lazperf()
{
	PCPOINT *pt;
	int i;
	int npts = 400;
	PCPOINTLIST *pl;
	PCPATCH_LAZPERF *pal;
	PCPATCH_UNCOMPRESSED *paul, *pauref;

	// build a list of points
	pl = 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(pl, pt);
	}

	// compress the list in a lazperf patch
	pal = pc_patch_lazperf_from_pointlist( pl );

	// get an uncompressed patch from the lazperf patch
	paul = pc_patch_uncompressed_from_lazperf( pal );

	// get an uncompressed patch directly from the pointlist
	pauref = pc_patch_uncompressed_from_pointlist( pl );

	// test the number of points
	CU_ASSERT_EQUAL(pal->npoints, pauref->npoints);
	CU_ASSERT_EQUAL(paul->npoints, pauref->npoints);

	// test bounds
	CU_ASSERT_DOUBLE_EQUAL(pal->bounds.xmax, pauref->bounds.xmax, 0.0001);
	CU_ASSERT_DOUBLE_EQUAL(paul->bounds.ymax, pauref->bounds.ymax, 0.000001);

	// test type
	CU_ASSERT_EQUAL(pal->type, PC_LAZPERF);
	CU_ASSERT_EQUAL(paul->type, pauref->type);

	// test readonly
	CU_ASSERT_EQUAL(pauref->readonly, paul->readonly);
	CU_ASSERT_EQUAL(pauref->readonly, pal->readonly);

	// test datasize
	CU_ASSERT_EQUAL(paul->datasize, pauref->datasize);

	// free
	pc_pointlist_free(pl);
	pc_patch_free( (PCPATCH*) pal );
	pc_patch_free((PCPATCH*) paul);
	pc_patch_free((PCPATCH*) pauref);
}
예제 #12
0
static void
test_sort_patch_is_sorted_compression_dimensional(enum DIMCOMPRESSIONS dimcomp)
{
	// init data
	PCPATCH_DIMENSIONAL *padim1, *padim2, *padimsort;
	PCPOINT *pt;
	PCPOINTLIST *pl;
	int i;
	int ndims = 1;
	int npts = PCDIMSTATS_MIN_SAMPLE+1; // force to keep custom compression
	const char *X[] = {"X"};

	// build a dimensional patch
	pl = pc_pointlist_make(npts);

	for ( i = npts; i >= 0; i-- )
	{
		pt = pc_point_make(schema);
		pc_point_set_double_by_name(pt, "x", i);
		pc_point_set_double_by_name(pt, "y", i);
		pc_point_set_double_by_name(pt, "Z", i);
		pc_point_set_double_by_name(pt, "intensity", 10);
		pc_pointlist_add_point(pl, pt);
	}

	padim1 = pc_patch_dimensional_from_pointlist(pl);

	// set dimensional compression for each dimension
	PCDIMSTATS *stats = pc_dimstats_make(schema);
	pc_dimstats_update(stats, padim1);
	for ( i = 0; i<padim1->schema->ndims; i++ )
		stats->stats[i].recommended_compression = dimcomp;

	// compress patch
	padim2 = pc_patch_dimensional_compress(padim1, stats);

	// test that patch is not sorted
	CU_ASSERT_EQUAL(pc_patch_is_sorted((PCPATCH*) padim2, X, ndims, PC_FALSE), PC_FALSE);
	CU_ASSERT_EQUAL(pc_patch_is_sorted((PCPATCH*) padim2, X, ndims, PC_TRUE), PC_FALSE);

	// sort
	padimsort = (PCPATCH_DIMENSIONAL*) pc_patch_sort((PCPATCH*) padim2, X, 1);

	// test that resulting data is sorted
	CU_ASSERT_EQUAL(pc_patch_is_sorted((PCPATCH*) padimsort, X, ndims, PC_TRUE), PC_TRUE);

	// free
	pc_dimstats_free(stats);
	pc_patch_free((PCPATCH *)padim1);
	pc_patch_free((PCPATCH *)padim2);
	pc_patch_free((PCPATCH *)padimsort);
	pc_pointlist_free(pl);
}
예제 #13
0
static void
test_patch_set_schema_dimensional_compression(enum DIMCOMPRESSIONS dimcomp)
{
	// init data
	PCPATCH_DIMENSIONAL *padim1, *padim2;
	PCPATCH *pat;
	PCPOINT *pt;
	PCPOINTLIST *pl;
	char *str;
	int i;
	int npts = PCDIMSTATS_MIN_SAMPLE+1; // force to keep custom compression

	// build a patch
	pl = pc_pointlist_make(npts);

	for ( i = npts; i >= 0; i-- )
	{
		pt = pc_point_make(simpleschema);
		pc_point_set_double_by_name(pt, "X", i * 0.1);
		pc_point_set_double_by_name(pt, "Y", i * 0.2);
		pc_point_set_double_by_name(pt, "Z", i * 0.3);
		pc_point_set_double_by_name(pt, "Intensity", 10);
		pc_pointlist_add_point(pl, pt);
	}

	padim1 = pc_patch_dimensional_from_pointlist(pl);

	// set dimensional compression for each dimension
	PCDIMSTATS *stats = pc_dimstats_make(simpleschema);
	pc_dimstats_update(stats, padim1);
	for ( i = 0; i<padim1->schema->ndims; i++ )
		stats->stats[i].recommended_compression = dimcomp;

	// compress patch
	padim2 = pc_patch_dimensional_compress(padim1, stats);

	// assign a valid schema to the patch
	pat = pc_patch_set_schema((PCPATCH*) padim2, simpleschema_nointensity, 0.0);
	CU_ASSERT(pat != NULL);
	pt = pc_patch_pointn(pat, 1);
	str = pc_point_to_string(pt);
	CU_ASSERT_STRING_EQUAL(str,"{\"pcid\":0,\"pt\":[1000.1,2000.2,3000.3]}");
	pcfree(str);
	pc_point_free(pt);
	pc_patch_free(pat);

	pc_pointlist_free(pl);
	pc_dimstats_free(stats);
	pc_patch_free((PCPATCH *)padim1);
	pc_patch_free((PCPATCH *)padim2);
}
예제 #14
0
/**
* Pivot a pointlist into a dimlist and back.
* Test for data loss or alteration.
*/
static void
test_patch_dimensional()
{
	PCPOINT *pt;
	int i;
	int npts = 10;
	PCPOINTLIST *pl1, *pl2;
	PCPATCH_DIMENSIONAL *pdl;
	PCDIMSTATS *pds;

	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);
	}

	pdl = pc_patch_dimensional_from_pointlist(pl1);
	pl2 = pc_pointlist_from_dimensional(pdl);

	for ( i = 0; i < npts; i++ )
	{
		pt = pc_pointlist_get_point(pl2, i);
		double v1, v2, v3, v4;
		pc_point_get_double_by_name(pt, "x", &v1);
		pc_point_get_double_by_name(pt, "y", &v2);
		pc_point_get_double_by_name(pt, "Z", &v3);
		pc_point_get_double_by_name(pt, "intensity", &v4);
		// printf("%g\n", v4);
		CU_ASSERT_DOUBLE_EQUAL(v1, i*2.0, 0.001);
		CU_ASSERT_DOUBLE_EQUAL(v2, i*1.9, 0.001);
		CU_ASSERT_DOUBLE_EQUAL(v3, i*0.34, 0.001);
		CU_ASSERT_DOUBLE_EQUAL(v4, 10, 0.001);
	}

	pds = pc_dimstats_make(simpleschema);
	pc_dimstats_update(pds, pdl);
	pc_dimstats_update(pds, pdl);


	pc_patch_free((PCPATCH*)pdl);
	pc_pointlist_free(pl1);
	pc_pointlist_free(pl2);
	pc_dimstats_free(pds);
}
예제 #15
0
static void
test_wkb_lazperf()
{
	PCPOINT *pt;
	int i;
	int npts = 400;
	PCPOINTLIST *pl;
	PCPATCH_LAZPERF *pal1, *pal2;
	PCPATCH_UNCOMPRESSED *pau;
	uint8_t *wkb1, *wkb2;
	size_t wkbsize;

	// build a list of points
	pl = 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(pl, pt);
	}

	// build patch lazperf
	pal1 = pc_patch_lazperf_from_pointlist(pl);

	// get the corresponding wkb
	wkb1 = pc_patch_lazperf_to_wkb(pal1, &wkbsize);

	// rebuild a lazperf patch thanks to the wkb
	pal2 = (PCPATCH_LAZPERF*) pc_patch_lazperf_from_wkb( pal1->schema, wkb1, wkbsize);

	// get the wkb reference
	pau = pc_patch_uncompressed_from_pointlist(pl);
	wkb2 = pc_patch_uncompressed_to_wkb( pau, &wkbsize );

	// compare wkb
	CU_ASSERT_STRING_EQUAL(wkb1, wkb2);

	// free
	pc_patch_free((PCPATCH*) pal1);
	pc_patch_free((PCPATCH*) pal2);
	pc_patch_free((PCPATCH*) pau);
	pc_pointlist_free(pl);
	pcfree(wkb1);
	pcfree(wkb2);
}
예제 #16
0
static void
test_patch_range_compression_dimensional(enum DIMCOMPRESSIONS dimcomp)
{
	int i;
	PCPOINTLIST *pl;
	PCPATCH *pa;
	PCPATCH *par;
	PCPATCH_DIMENSIONAL *pad;
	PCPOINT *pt;
	char *str;
	int npts = PCDIMSTATS_MIN_SAMPLE+1; // force to keep custom compression

	// build a dimensional patch
	pl = pc_pointlist_make(npts);

	for ( i = npts; i >= 0; i-- )
	{
		pt = pc_point_make(simpleschema);
		pc_point_set_double_by_name(pt, "X", i);
		pc_point_set_double_by_name(pt, "Y", i);
		pc_point_set_double_by_name(pt, "Z", i);
		pc_point_set_double_by_name(pt, "Intensity", 10);
		pc_pointlist_add_point(pl, pt);
	}

	pad = pc_patch_dimensional_from_pointlist(pl);

	// set dimensional compression for each dimension
	PCDIMSTATS *stats = pc_dimstats_make(simpleschema);
	pc_dimstats_update(stats, pad);
	for ( i = 0; i<pad->schema->ndims; i++ )
		stats->stats[i].recommended_compression = dimcomp;

	// compress patch
	pa = (PCPATCH*) pc_patch_dimensional_compress(pad, stats);

	par = pc_patch_range(pa, 16, 4);
	str = pc_patch_to_string(par);

	CU_ASSERT_STRING_EQUAL(str,
		"{\"pcid\":0,\"pts\":[[9986,9986,9986,10],[9985,9985,9985,10],[9984,9984,9984,10],[9983,9983,9983,10]]}");

	pcfree(str);
	pc_patch_free(par);
	pc_patch_free((PCPATCH *)pad);
	pc_dimstats_free(stats);
	pc_patch_free(pa);
	pc_pointlist_free(pl);
}
예제 #17
0
PCPOINTLIST *
pc_pointlist_from_uncompressed(const PCPATCH_UNCOMPRESSED *patch)
{
	int i;
	PCPOINTLIST *pl;
	size_t pt_size = patch->schema->size;
	uint32_t npoints = patch->npoints;

	pl = pc_pointlist_make(npoints);
	for ( i = 0; i < npoints; i++ )
	{
		pc_pointlist_add_point(pl, pc_point_from_data(patch->schema, patch->data + i*pt_size));
	}
	return pl;
}
예제 #18
0
static void
test_patch_set_schema_compression_ght()
{
	// init data
	PCPATCH_GHT *pag;
	PCPATCH *pat0, *pat1;
	PCPOINTLIST *pl;
	PCPOINT *pt;
	char *str;
	int i;
	int npts = 4;

	// build a patch
	pl = pc_pointlist_make(npts);

	for ( i = npts; i >= 0; i-- )
	{
		pt = pc_point_make(simpleschema);
		pc_point_set_double_by_name(pt, "X", i * 0.1);
		pc_point_set_double_by_name(pt, "Y", i * 0.2);
		pc_point_set_double_by_name(pt, "Z", i * 0.3);
		pc_point_set_double_by_name(pt, "Intensity", 10);
		pc_pointlist_add_point(pl, pt);
	}

	pag = pc_patch_ght_from_pointlist(pl);

	// assign a valid schema to the patch
	pat0 = pc_patch_set_schema((PCPATCH*) pag, simpleschema_nointensity, 0.0);
	CU_ASSERT(pat0 != NULL);
	str = pc_patch_to_string(pat0);
	CU_ASSERT_STRING_EQUAL(str, "{\"pcid\":0,\"pts\":[[0.4,0.8,1.2],[0.3,0.6,0.9],[0.2,0.4,0.6],[0.1,0.2,0.3],[0,0,0]]}");
	pcfree(str);

	// assign a schema with unknown dimension to the patch
	pat1 = pc_patch_set_schema(pat0, simpleschema, 0.0);
	CU_ASSERT(pat1 != NULL);
	str = pc_patch_to_string(pat1);
	CU_ASSERT_STRING_EQUAL(str, "{\"pcid\":0,\"pts\":[[0.4,0.8,1.2,0],[0.3,0.6,0.9,0],[0.2,0.4,0.6,0],[0.1,0.2,0.3,0],[0,0,0,0]]}");
	pcfree(str);

	pc_patch_free(pat0);
	pc_patch_free(pat1);

	pc_patch_free((PCPATCH*) pag);
	pc_pointlist_free(pl);
}
예제 #19
0
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);
}
예제 #20
0
static void
test_to_string_lazperf()
{
	PCPOINT *pt;
	int i;
	int npts = 400;
	PCPOINTLIST *pl;
	PCPATCH_LAZPERF *pal;
	PCPATCH_UNCOMPRESSED *pau;
	char *str1, *str2;

	// build a list of points
	pl = 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(pl, pt);
	}

	// build patch
	pau = pc_patch_uncompressed_from_pointlist(pl);
	pal = pc_patch_lazperf_from_pointlist(pl);

	// get string
	str1 = pc_patch_uncompressed_to_string(pau);
	str2 = pc_patch_lazperf_to_string(pal);

	// compare
	CU_ASSERT_STRING_EQUAL(str1, str2);

	// free
	pc_patch_free((PCPATCH*) pal);
	pc_patch_free((PCPATCH*) pau);
	pc_pointlist_free(pl);
	pcfree(str1);
	pcfree(str2);
}
예제 #21
0
static void
test_patch_set_schema_compression_none_offset()
{
	// init data
	PCPATCH_UNCOMPRESSED *pau;
	PCPATCH *pat;
	PCPOINTLIST *pl;
	PCPOINT *pt;
	PCSCHEMA *new_schema;
	char *str;
	int i;
	int npts = 4;

	// build a patch
	pl = pc_pointlist_make(npts);
	for ( i = npts; i >= 0; i-- )
	{
		pt = pc_point_make(simpleschema_nointensity);
		pc_point_set_double_by_name(pt, "X", i * 0.1);
		pc_point_set_double_by_name(pt, "Y", i * 0.2);
		pc_point_set_double_by_name(pt, "Z", i * 0.3);
		pc_pointlist_add_point(pl, pt);
	}
	pau = pc_patch_uncompressed_from_pointlist(pl);

	new_schema = pc_schema_clone(simpleschema);
	new_schema->dims[3]->offset = 10;

	// assign a valid schema to the patch
	pat = pc_patch_set_schema((PCPATCH *) pau, new_schema, 0.0);
	CU_ASSERT(pat != NULL);
	str = pc_patch_to_string(pat);
	CU_ASSERT_STRING_EQUAL(str, "{\"pcid\":0,\"pts\":[[0.4,0.8,1.2,10],[0.3,0.6,0.9,10],[0.2,0.4,0.6,10],[0.1,0.2,0.3,10],[0,0,0,10]]}");
	pcfree(str);

	pc_patch_free(pat);
	pc_schema_free(new_schema);
	pc_patch_free((PCPATCH*) pau);
	pc_pointlist_free(pl);
}
예제 #22
0
static void
test_patch_dimensional_extent()
{
	PCPOINT *pt;
	int i, rv;
	int npts = 2;
	PCPOINTLIST *pl1;
	PCPATCH_DIMENSIONAL *pch1;

	pl1 = pc_pointlist_make(npts);

	for ( i = 1; i <= npts; i++ )
	{
		pt = pc_point_make(simpleschema);
		pc_point_set_double_by_name(pt, "x", 5+i*1);
		pc_point_set_double_by_name(pt, "y", -i*10);
		pc_point_set_double_by_name(pt, "Z", i*0.2);
		pc_point_set_double_by_name(pt, "intensity", -5);
		pc_pointlist_add_point(pl1, pt);
	}

	pch1 = pc_patch_dimensional_from_pointlist(pl1);
		CU_ASSERT_EQUAL(pch1->bounds.xmin, 6);
		CU_ASSERT_EQUAL(pch1->bounds.xmax, 7);
		CU_ASSERT_EQUAL(pch1->bounds.ymin, -20);
		CU_ASSERT_EQUAL(pch1->bounds.ymax, -10);

	rv = pc_patch_dimensional_compute_extent(pch1);
	CU_ASSERT_EQUAL(rv, PC_SUCCESS);
		CU_ASSERT_EQUAL(pch1->bounds.xmin, 6);
		CU_ASSERT_EQUAL(pch1->bounds.xmax, 7);
		CU_ASSERT_EQUAL(pch1->bounds.ymin, -20);
		CU_ASSERT_EQUAL(pch1->bounds.ymax, -10);

	pc_patch_free((PCPATCH*)pch1);
	pc_pointlist_free(pl1);
}
예제 #23
0
static void
test_patch_transform_compression_none()
{
	// init data
	PCPATCH_UNCOMPRESSED *pau;
	PCSCHEMA *nschema;
	PCPOINTLIST *pl;
	PCPATCH *pa;
	PCPOINT *pt;
	char *str;
	int i;
	int npts = 5;
	uint8_t *wkb;
	size_t wkbsize;

	// build a patch
	pl = pc_pointlist_make(npts);
	for ( i = (npts - 1); i >= 0; i-- )
	{
		pt = pc_point_make(simpleschema);
		pc_point_set_double_by_name(pt, "X", i * 0.1);
		pc_point_set_double_by_name(pt, "Y", i * 0.2);
		pc_point_set_double_by_name(pt, "Z", i * 0.3);
		pc_point_set_double_by_name(pt, "Intensity", 10);
		pc_pointlist_add_point(pl, pt);
	}
	pau = pc_patch_uncompressed_from_pointlist(pl);

	// create a new schema, and use 0.02 scale values for x, y and z
	nschema = pc_schema_clone(simpleschema);
	nschema->xdim->scale = 0.02;
	nschema->ydim->scale = 0.02;
	nschema->zdim->scale = 0.02;

	// transform the patch
	pa = pc_patch_transform((PCPATCH*) pau, nschema, 0.0);
	CU_ASSERT(pa != NULL);

	// check point 1
	// expected: x=hex(20)=0x14, y=hex(40)=0x28, z=hex(60)=0x3C, I=hex(10)=0x0A
	pt = pc_patch_pointn(pa, 1);
	wkb = pc_point_to_wkb(pt, &wkbsize);
	str = hexbytes_from_bytes(wkb, wkbsize);
	CU_ASSERT_STRING_EQUAL(str, "010000000014000000280000003C0000000A00");
	pcfree(str);
	pcfree(wkb);
	pc_point_free(pt);

	// check point 2
	// expected: x=hex(15)=0x0F, y=hex(30)=0x1E, z=hex(45)=0x2D, I=hex(10)=0x0A
	pt = pc_patch_pointn(pa, 2);
	wkb = pc_point_to_wkb(pt, &wkbsize);
	str = hexbytes_from_bytes(wkb, wkbsize);
	CU_ASSERT_STRING_EQUAL(str, "01000000000F0000001E0000002D0000000A00");
	pcfree(str);
	pcfree(wkb);
	pc_point_free(pt);

	// check point 3
	// expected: x=hex(10)=0x0A, y=hex(20)=0x14, z=hex(30)=0x1E, I=hex(10)=0x0A
	pt = pc_patch_pointn(pa, 3);
	wkb = pc_point_to_wkb(pt, &wkbsize);
	str = hexbytes_from_bytes(wkb, wkbsize);
	CU_ASSERT_STRING_EQUAL(str, "01000000000A000000140000001E0000000A00");
	pcfree(str);
	pcfree(wkb);
	pc_point_free(pt);

	// check point 4
	// expected: x=hex(5)=0x05, y=hex(10)=0x0A, z=hex(15)=0x0F, I=hex(10)=0x0A
	pt = pc_patch_pointn(pa, 4);
	wkb = pc_point_to_wkb(pt, &wkbsize);
	str = hexbytes_from_bytes(wkb, wkbsize);
	CU_ASSERT_STRING_EQUAL(str, "0100000000050000000A0000000F0000000A00");
	pcfree(str);
	pcfree(wkb);
	pc_point_free(pt);

	// check point 5
	// expected: x=hex(0)=0x00, y=hex(0)=0x00, z=hex(0)=0x00, I=hex(10)=0x0A
	pt = pc_patch_pointn(pa, 5);
	wkb = pc_point_to_wkb(pt, &wkbsize);
	str = hexbytes_from_bytes(wkb, wkbsize);
	CU_ASSERT_STRING_EQUAL(str, "01000000000000000000000000000000000A00");
	pcfree(str);
	pcfree(wkb);
	pc_point_free(pt);

	pc_patch_free(pa);
	pc_schema_free(nschema);
	pc_patch_free((PCPATCH*) pau);
	pc_pointlist_free(pl);
}
예제 #24
0
/**
* Test the function which clone a patch keeping only a part of dimensions, numerous print to see what happens
*/
static void
test_patch_subset()
{
    int i;
    int npts = 20;
    PCPOINTLIST *pl1,*pl2 ;
    PCPATCH_UNCOMPRESSED *pu1, *pu2;
    PCPATCH *pa1, *pa2, *pa3, *pa4;
    PCDIMSTATS *pds = NULL;
    size_t z1, z2;
    uint8_t *wkb1, *wkb2;
    char *str1;

	//getting a test patch
	
    pl1 = pc_pointlist_make(npts);
    pl2 = pc_pointlist_make(npts);

    for ( i = 0; i < npts; i++ )
    {
        PCPOINT *pt1 = pc_point_make(simpleschema);
        PCPOINT *pt2 = pc_point_make(simpleschema);
        pc_point_set_double_by_name(pt1, "x", i*2.8);
        pc_point_set_double_by_name(pt1, "y", i*1.3);
        pc_point_set_double_by_name(pt1, "Z", i*0.1);
        pc_point_set_double_by_name(pt1, "intensity", 100-i);
        pc_pointlist_add_point(pl1, pt1);
        pc_point_set_double_by_name(pt2, "x", i);
        pc_point_set_double_by_name(pt2, "y", i);
        pc_point_set_double_by_name(pt2, "Z", i*0.1);
        pc_point_set_double_by_name(pt2, "intensity", 100-i);
        pc_pointlist_add_point(pl2, pt2);
    }

    // PCPATCH* pc_patch_filter(const PCPATCH *pa, uint32_t dimnum, PC_FILTERTYPE filter, double val1, double val2);

    pa1 = (PCPATCH*)pc_patch_dimensional_from_pointlist(pl1);


    //printf("pa1\n%s\n", pc_patch_to_string(pa1));
 
    
    //testing the function :
   // printf("testing the dimension-reduction function\n");
    //printf("\n\n	position of x : %i \n\n",pc_schema_get_dimension_position_by_name(pa1->schema, "x"));
    uint32_t new_dim_number = 2; 
	char *dim_to_keep[] = {  "y", "x" }; 
	uint32_t dim_position[2];
	int i2 ;
	
	//test of pc_schema_get_dimension_position_by_name
	/*
		for(i2=0;i2<new_dim_number;i2++)
		{
			dim_position[i2] = pc_schema_get_dimension_position_by_name(pa1->schema, dim_to_keep[i2]);
			printf("\n dimension %s has position %d",dim_to_keep[i2],dim_position[i2] );
		}
	printf("\n");
	* */
	 //printf("\n the original schema to json : %s",pc_schema_to_json(pa1->schema));
	 //test of pc_bounds_to_string(PCBOUNDS *b) 
	 
	 //testing the function pc_patch_dimensional_bytes_array_to_string
	 //printf(" the original PCBYTES array :%s",pc_patch_dimensional_bytes_array_to_string((PCPATCH_DIMENSIONAL*)pa1));
    
    //testing dimstat function :
		//creating dimstats
		//pds = pc_dimstats_make(simpleschema);
		//pc_dimstats_update(pds, (PCPATCH_DIMENSIONAL*)pa1);
		//testing function : 
		//PCDIMSTATS * o_dimstats = pc_dimstats_clone_subset(pds,dim_position, new_dim_number);
	
	//testing reduce_dimension function
    //printf("\n \n beginning test of patch_reduce_dimension \n ");
    pa3 = pc_patch_reduce_dimension(pa1, dim_to_keep, new_dim_number);
    
    //printf("\n the schema to json : %s",pc_schema_to_json(pa3->schema));
   // printf("\n the stats to json : %s",pc_stats_to_json(pa3->stats));
   // printf("\n \n \n the patch to json : %s" , pc_patch_to_string(pa3));
    
	//printf(" the  pa3 PCBYTES array :%s",pc_patch_dimensional_bytes_array_to_string((PCPATCH_DIMENSIONAL*)pa3)); 
   
    //test of the serialize / deserialize function to emulate the pc_acess top function
    
    //test on the result pathc :
		 //test of pc_bounds_to_string(PCBOUNDS *b)
			//printf("the bounds of pa3 : %s \n",  pc_bounds_to_string( &(pa3->bounds) ) );
		 
	//the test on result patch : should return a new patch with only Y and X dimension
	
	// printf("%s",pc_patch_to_string( pa3));
	
	 CU_ASSERT_STRING_EQUAL(pc_patch_to_string( pa3), "{\"pcid\":0,\"pts\":[[0,0],[1.3,2.8],[2.6,5.6],[3.9,8.4],[5.2,11.2],[6.5,14],[7.8,16.8],[9.1,19.6],[10.4,22.4],[11.7,25.2],[13,28],[14.3,30.8],[15.6,33.6],[16.9,36.4],[18.2,39.2],[19.5,42],[20.8,44.8],[22.1,47.6],[23.4,50.4],[24.7,53.2]]}");
 
    return;
		//test on schema :
		
		
		
	printf("%s",pc_schema_to_json(pa3->schema ));
     printf("pa1\n%s\n", pc_patch_to_string(pa3));
    
    //cleaning
    pc_pointlist_free(pl1);
    pc_pointlist_free(pl2);
    pc_patch_free(pa1);
    pc_patch_free(pa3);
    //pc_patch_free(pa4);
    //pc_patch_free(pa2);
    
    return;

}
예제 #25
0
static PCPATCH *
pcpatch_from_point_array(ArrayType *array, FunctionCallInfoData *fcinfo)
{
	int nelems;
	bits8 *bitmap;
	int bitmask;
	size_t offset = 0;
	int i;
    uint32 pcid = 0;
	PCPATCH *pa;
	PCPOINTLIST *pl;
    PCSCHEMA *schema = 0;

	/* How many things in our array? */
	nelems = ArrayGetNItems(ARR_NDIM(array), ARR_DIMS(array));

	/* PgSQL supplies a bitmap of which array entries are null */
	bitmap = ARR_NULLBITMAP(array);

	/* Empty array? Null return */
	if ( nelems == 0 ) 
        return NULL;
	
	/* Make our holder */
	pl = pc_pointlist_make(nelems);

	offset = 0;
	bitmap = ARR_NULLBITMAP(array);
	bitmask = 1;
	for ( i = 0; i < nelems; i++ )
	{
		/* Only work on non-NULL entries in the array */
		if ( ! array_get_isnull(bitmap, i) )
		{
			SERIALIZED_POINT *serpt = (SERIALIZED_POINT *)(ARR_DATA_PTR(array)+offset);
			PCPOINT *pt;
			
			if ( ! schema )
			{
                schema = pc_schema_from_pcid(serpt->pcid, fcinfo);
		    }
			
			if ( ! pcid ) 
			{
				pcid = serpt->pcid;
			}
			else if ( pcid != serpt->pcid )
			{
				elog(ERROR, "pcpatch_from_point_array: pcid mismatch (%d != %d)", serpt->pcid, pcid);
			}
			
			pt = pc_point_deserialize(serpt, schema);
			if ( ! pt )
			{
				elog(ERROR, "pcpatch_from_point_array: point deserialization failed");
			}
			
			pc_pointlist_add_point(pl, pt);

			offset += INTALIGN(VARSIZE(serpt));			
		}

	}
	
	if ( pl->npoints == 0 )
		return NULL;

	pa = pc_patch_from_pointlist(pl);
	pc_pointlist_free(pl);
    return pa;
}
예제 #26
0
static void
test_patch_dimensional_compression()
{
	PCPOINT *pt;
	int i;
	int npts = 400;
	PCPOINTLIST *pl1, *pl2;
	PCPATCH_DIMENSIONAL *pch1, *pch2;
	PCDIMSTATS *pds = NULL;
	//size_t z1, z2;
	char *str;

	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);
	}

	pch1 = pc_patch_dimensional_from_pointlist(pl1);
	// z1 = pc_patch_dimensional_serialized_size(pch1);
	// printf("z1 %ld\n", z1);

	pds = pc_dimstats_make(simpleschema);
	pc_dimstats_update(pds, pch1);
	pc_dimstats_update(pds, pch1);
	pch2 = pc_patch_dimensional_compress(pch1, pds);
	// z2 = pc_patch_dimensional_serialized_size(pch2);
	// printf("z2 %ld\n", z2);

	str = pc_dimstats_to_string(pds);
	CU_ASSERT_STRING_EQUAL(str, "{\"ndims\":4,\"total_points\":1200,\"total_patches\":3,\"dims\":[{\"total_runs\":1200,\"total_commonbits\":45,\"recommended_compression\":2},{\"total_runs\":1200,\"total_commonbits\":45,\"recommended_compression\":2},{\"total_runs\":1200,\"total_commonbits\":54,\"recommended_compression\":2},{\"total_runs\":3,\"total_commonbits\":48,\"recommended_compression\":1}]}");
	// printf("%s\n", str);
	pcfree(str);

	pl2 = pc_pointlist_from_dimensional(pch2);

	for ( i = 0; i < npts; i++ )
	{
		pt = pc_pointlist_get_point(pl2, i);
		double v1, v2, v3, v4;
		pc_point_get_double_by_name(pt, "x", &v1);
		pc_point_get_double_by_name(pt, "y", &v2);
		pc_point_get_double_by_name(pt, "Z", &v3);
		pc_point_get_double_by_name(pt, "intensity", &v4);
		// printf("%g\n", v4);
		CU_ASSERT_DOUBLE_EQUAL(v1, i*2.0, 0.001);
		CU_ASSERT_DOUBLE_EQUAL(v2, i*1.9, 0.001);
		CU_ASSERT_DOUBLE_EQUAL(v3, i*0.34, 0.001);
		CU_ASSERT_DOUBLE_EQUAL(v4, 10, 0.001);
	}

	pc_patch_free((PCPATCH*)pch1);
	pc_patch_free((PCPATCH*)pch2);
	pc_pointlist_free(pl1);
	pc_pointlist_free(pl2);
	if ( pds ) pc_dimstats_free(pds);
}