コード例 #1
0
ファイル: cu_pc_patch.c プロジェクト: caomw/pointcloud
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
ファイル: cu_pc_schema.c プロジェクト: avances123/pointcloud
static void
test_point_access()
{
	PCPOINT *pt;
	int rv;
	double a1, a2, a3, a4, b1, b2, b3, b4;
	int idx = 0;

	pt = pc_point_make(schema);
	CU_ASSERT( pt != NULL );

	/* One at a time */
	idx = 0;
	a1 = 1.5;
	rv = pc_point_set_double_by_index(pt, idx, a1);
	rv = pc_point_get_double_by_index(pt, idx, &b1);
	// printf("d1=%g, d2=%g\n", a1, b1);
	CU_ASSERT_DOUBLE_EQUAL(a1, b1, 0.0000001);

	idx = 2;
	a2 = 1501500.12;
	rv = pc_point_set_double_by_index(pt, idx, a2);
	rv = pc_point_get_double_by_index(pt, idx, &b2);
	CU_ASSERT_DOUBLE_EQUAL(a2, b2, 0.0000001);

	a3 = 91;
	rv = pc_point_set_double_by_name(pt, "NumberOfReturns", a3);
	rv = pc_point_get_double_by_name(pt, "NumberOfReturns", &b3);
	CU_ASSERT_DOUBLE_EQUAL(a3, b3, 0.0000001);

	pc_point_free(pt);

	/* All at once */
	pt = pc_point_make(schema);
	a1 = 1.5;
	a2 = 1501500.12;
	a3 = 91;
	a4 = 200;
	rv = pc_point_set_double_by_index(pt, 0, a1);
	rv = pc_point_set_double_by_index(pt, 2, a2);
	rv = pc_point_set_double_by_name(pt, "NumberOfReturns", a3);
	rv = pc_point_set_double_by_name(pt, "UserData", a4);
	rv = pc_point_get_double_by_index(pt, 0, &b1);
	rv = pc_point_get_double_by_index(pt, 2, &b2);
	rv = pc_point_get_double_by_name(pt, "NumberOfReturns", &b3);
	rv = pc_point_get_double_by_name(pt, "UserData", &b4);
	CU_ASSERT_DOUBLE_EQUAL(a1, b1, 0.0000001);
	CU_ASSERT_DOUBLE_EQUAL(a2, b2, 0.0000001);
	CU_ASSERT_DOUBLE_EQUAL(a3, b3, 0.0000001);
	CU_ASSERT_DOUBLE_EQUAL(a4, b4, 0.0000001);

	pc_point_free(pt);

}
コード例 #3
0
ファイル: pc_pointlist.c プロジェクト: Remi-C/pointcloud
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;
}
コード例 #4
0
ファイル: cu_pc_patch.c プロジェクト: ldgeo/pointcloud
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);
}
コード例 #5
0
ファイル: cu_pc_patch.c プロジェクト: ldgeo/pointcloud
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);
}
コード例 #6
0
ファイル: cu_pc_patch.c プロジェクト: ldgeo/pointcloud
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);
}
コード例 #7
0
ファイル: cu_pc_patch.c プロジェクト: ldgeo/pointcloud
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);
}
コード例 #8
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);
}
コード例 #9
0
ファイル: cu_pc_patch.c プロジェクト: ldgeo/pointcloud
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);
}
コード例 #10
0
ファイル: cu_pc_patch.c プロジェクト: Remi-C/pointcloud
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
ファイル: cu_pc_patch.c プロジェクト: ldgeo/pointcloud
static void
test_endian_flip()
{
	PCPOINT *pt;
	double a1, a2, a3, a4, b1, b2, b3, b4;
	int rv;
	uint8_t *ptr;

	/* All at once */
	pt = pc_point_make(schema);
	a1 = 1.5;
	a2 = 1501500.12;
	a3 = 19112;
	a4 = 200;
	rv = pc_point_set_double_by_name(pt, "X", a1);
	CU_ASSERT_EQUAL(rv, PC_SUCCESS);
	rv = pc_point_set_double_by_name(pt, "Z", a2);
	CU_ASSERT_EQUAL(rv, PC_SUCCESS);
	rv = pc_point_set_double_by_name(pt, "Intensity", a3);
	CU_ASSERT_EQUAL(rv, PC_SUCCESS);
	rv = pc_point_set_double_by_name(pt, "UserData", a4);
	CU_ASSERT_EQUAL(rv, PC_SUCCESS);
	rv = pc_point_get_double_by_name(pt, "X", &b1);
	CU_ASSERT_EQUAL(rv, PC_SUCCESS);
	rv = pc_point_get_double_by_name(pt, "Z", &b2);
	CU_ASSERT_EQUAL(rv, PC_SUCCESS);
	rv = pc_point_get_double_by_name(pt, "Intensity", &b3);
	CU_ASSERT_EQUAL(rv, PC_SUCCESS);
	rv = pc_point_get_double_by_name(pt, "UserData", &b4);
	CU_ASSERT_EQUAL(rv, PC_SUCCESS);
	CU_ASSERT_DOUBLE_EQUAL(a1, b1, 0.0000001);
	CU_ASSERT_DOUBLE_EQUAL(a2, b2, 0.0000001);
	CU_ASSERT_DOUBLE_EQUAL(a3, b3, 0.0000001);
	CU_ASSERT_DOUBLE_EQUAL(a4, b4, 0.0000001);

	ptr = uncompressed_bytes_flip_endian(pt->data, schema, 1);
	pcfree(pt->data);
	pt->data = uncompressed_bytes_flip_endian(ptr, schema, 1);
	pcfree(ptr);

	rv = pc_point_get_double_by_name(pt, "X", &b1);
	CU_ASSERT_EQUAL(rv, PC_SUCCESS);
	rv = pc_point_get_double_by_name(pt, "Z", &b2);
	CU_ASSERT_EQUAL(rv, PC_SUCCESS);
	rv = pc_point_get_double_by_name(pt, "Intensity", &b3);
	CU_ASSERT_EQUAL(rv, PC_SUCCESS);
	rv = pc_point_get_double_by_name(pt, "UserData", &b4);
	CU_ASSERT_EQUAL(rv, PC_SUCCESS);
	CU_ASSERT_DOUBLE_EQUAL(a1, b1, 0.0000001);
	CU_ASSERT_DOUBLE_EQUAL(a2, b2, 0.0000001);
	CU_ASSERT_DOUBLE_EQUAL(a3, b3, 0.0000001);
	CU_ASSERT_DOUBLE_EQUAL(a4, b4, 0.0000001);

	pc_point_free(pt);
}
コード例 #13
0
ファイル: cu_pc_sort.c プロジェクト: cyrilleberger/pointcloud
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);
}
コード例 #14
0
ファイル: cu_pc_patch.c プロジェクト: ldgeo/pointcloud
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);
}
コード例 #15
0
ファイル: cu_pc_patch.c プロジェクト: ldgeo/pointcloud
/**
* 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);
}
コード例 #16
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);
}
コード例 #17
0
ファイル: cu_pc_patch.c プロジェクト: ldgeo/pointcloud
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);
}
コード例 #18
0
/** get point n, 0-based, positive */
PCPOINT *pc_patch_dimensional_pointn(const PCPATCH_DIMENSIONAL *pdl, int n)
{
	assert(pdl);
	assert(pdl->schema);
	int i;
	int ndims = pdl->schema->ndims;
	PCPOINT *pt = pc_point_make(pdl->schema);
	uint8_t *buf = pt->data;
	for ( i = 0; i < ndims; i++ )
	{
		PCDIMENSION *dim = pc_schema_get_dimension(pdl->schema, i);
		pc_bytes_to_ptr(buf+dim->byteoffset,pdl->bytes[i], n);
	}

	return pt;
}
コード例 #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
ファイル: cu_pc_patch.c プロジェクト: ldgeo/pointcloud
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);
}
コード例 #21
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);
}
コード例 #22
0
ファイル: cu_pc_patch.c プロジェクト: ldgeo/pointcloud
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);
}
コード例 #23
0
ファイル: cu_pc_patch.c プロジェクト: ldgeo/pointcloud
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);
}
コード例 #24
0
ファイル: cu_pc_point.c プロジェクト: LI3DS/pointcloud
static void
test_point_xyzm()
{
	PCPOINT *pt;
	double x = 1;
	double y = 40;
	double z = 160;
	double m = 640;
	double d;

	pt = pc_point_make(schema_xyz);
	CU_ASSERT_PTR_NOT_NULL( pt );

	CU_ASSERT_SUCCESS(pc_point_set_x(pt, x));
	CU_ASSERT_SUCCESS(pc_point_get_double_by_name(pt, "X", &d));
	CU_ASSERT_DOUBLE_EQUAL(d, x, 0.000001);
	CU_ASSERT_SUCCESS(pc_point_get_x(pt, &d));
	CU_ASSERT_DOUBLE_EQUAL(d, x, 0.000001);

	CU_ASSERT_SUCCESS(pc_point_set_y(pt, y));
	CU_ASSERT_SUCCESS(pc_point_get_double_by_name(pt, "Y", &d));
	CU_ASSERT_DOUBLE_EQUAL(d, y, 0.000001);
	CU_ASSERT_SUCCESS(pc_point_get_y(pt, &d));
	CU_ASSERT_DOUBLE_EQUAL(d, y, 0.000001);

	CU_ASSERT_SUCCESS(pc_point_set_z(pt, z));
	CU_ASSERT_SUCCESS(pc_point_get_double_by_name(pt, "Z", &d));
	CU_ASSERT_DOUBLE_EQUAL(d, z, 0.000001);
	CU_ASSERT_SUCCESS(pc_point_get_z(pt, &d));
	CU_ASSERT_DOUBLE_EQUAL(d, z, 0.000001);

	CU_ASSERT_FAILURE(pc_point_set_m(pt, m));
	CU_ASSERT_FAILURE(pc_point_get_double_by_name(pt, "M", &d));
	CU_ASSERT_FAILURE(pc_point_get_m(pt, &d));

	pc_point_free(pt);

	pt = pc_point_make(schema_xyzm);
	CU_ASSERT_PTR_NOT_NULL( pt );

	CU_ASSERT_SUCCESS(pc_point_set_x(pt, x));
	CU_ASSERT_SUCCESS(pc_point_get_double_by_name(pt, "X", &d));
	CU_ASSERT_DOUBLE_EQUAL(d, x, 0.000001);
	CU_ASSERT_SUCCESS(pc_point_get_x(pt, &d));
	CU_ASSERT_DOUBLE_EQUAL(d, x, 0.000001);

	CU_ASSERT_SUCCESS(pc_point_set_y(pt, y));
	CU_ASSERT_SUCCESS(pc_point_get_double_by_name(pt, "Y", &d));
	CU_ASSERT_DOUBLE_EQUAL(d, y, 0.000001);
	CU_ASSERT_SUCCESS(pc_point_get_y(pt, &d));
	CU_ASSERT_DOUBLE_EQUAL(d, y, 0.000001);

	CU_ASSERT_SUCCESS(pc_point_set_z(pt, z));
	CU_ASSERT_SUCCESS(pc_point_get_double_by_name(pt, "Z", &d));
	CU_ASSERT_DOUBLE_EQUAL(d, z, 0.000001);
	CU_ASSERT_SUCCESS(pc_point_get_z(pt, &d));
	CU_ASSERT_DOUBLE_EQUAL(d, z, 0.000001);

	CU_ASSERT_SUCCESS(pc_point_set_m(pt, m));
	CU_ASSERT_SUCCESS(pc_point_get_double_by_name(pt, "M", &d));
	CU_ASSERT_DOUBLE_EQUAL(d, m, 0.000001);
	CU_ASSERT_SUCCESS(pc_point_get_m(pt, &d));
	CU_ASSERT_DOUBLE_EQUAL(d, m, 0.000001);

	pc_point_free(pt);
}
コード例 #25
0
ファイル: cu_pc_patch.c プロジェクト: Remi-C/pointcloud
/**
* 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;

}
コード例 #26
0
ファイル: cu_pc_point.c プロジェクト: achidlow/pointcloud
static void
test_point_access()
{
	PCPOINT *pt;
	int rv;
	double a1, a2, a3, a4, b1, b2, b3, b4;
	int idx = 0;
	double *allvals;

	pt = pc_point_make(schema);
	CU_ASSERT( pt != NULL );

	/* One at a time */
	idx = 0;
	a1 = 1.5;
	rv = pc_point_set_double_by_index(pt, idx, a1);
	rv = pc_point_get_double_by_index(pt, idx, &b1);
	// printf("d1=%g, d2=%g\n", a1, b1);
	CU_ASSERT_DOUBLE_EQUAL(a1, b1, 0.0000001);

	idx = 2;
	a2 = 1501500.12;
	rv = pc_point_set_double_by_index(pt, idx, a2);
	rv = pc_point_get_double_by_index(pt, idx, &b2);
	CU_ASSERT_DOUBLE_EQUAL(a2, b2, 0.0000001);

	a3 = 91;
	rv = pc_point_set_double_by_name(pt, "Intensity", a3);
	rv = pc_point_get_double_by_name(pt, "Intensity", &b3);
	CU_ASSERT_DOUBLE_EQUAL(a3, b3, 0.0000001);

	pc_point_free(pt);

	/* All at once */
	pt = pc_point_make(schema);
	a1 = 1.5;
	a2 = 1501500.12;
	a3 = 91;
	a4 = 200;
	rv = pc_point_set_double_by_index(pt, 0, a1);
	rv = pc_point_set_double_by_index(pt, 1, a2);
	rv = pc_point_set_double_by_name(pt, "Intensity", a3);
	rv = pc_point_set_double_by_name(pt, "Z", a4);
	rv = pc_point_get_double_by_index(pt, 0, &b1);
	rv = pc_point_get_double_by_index(pt, 1, &b2);
	rv = pc_point_get_double_by_name(pt, "Intensity", &b3);
	rv = pc_point_get_double_by_name(pt, "Z", &b4);
	CU_ASSERT_DOUBLE_EQUAL(a1, b1, 0.0000001);
	CU_ASSERT_DOUBLE_EQUAL(a2, b2, 0.0000001);
	CU_ASSERT_DOUBLE_EQUAL(a3, b3, 0.0000001);
	CU_ASSERT_DOUBLE_EQUAL(a4, b4, 0.0000001);

	/* as a double array */
	rv = pc_point_set_double_by_index(pt, 0, a1);
	rv = pc_point_set_double_by_index(pt, 1, a2);
	rv = pc_point_set_double_by_index(pt, 2, a3);
	rv = pc_point_set_double_by_index(pt, 3, a4);
	allvals = pc_point_to_double_array(pt);
	CU_ASSERT_DOUBLE_EQUAL(allvals[0], a1, 0.0000001);
	CU_ASSERT_DOUBLE_EQUAL(allvals[1], a2, 0.0000001);
	//printf("allvals[2]:%g\n", allvals[2]);
	CU_ASSERT_DOUBLE_EQUAL(allvals[2], a3, 0.0000001);
	//printf("allvals[3]:%g\n", allvals[3]);
	CU_ASSERT_DOUBLE_EQUAL(allvals[3], a4, 0.0000001);
	pcfree(allvals);

	pc_point_free(pt);

}
コード例 #27
0
ファイル: cu_pc_patch.c プロジェクト: ldgeo/pointcloud
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);
}
コード例 #28
0
ファイル: cu_pc_patch.c プロジェクト: ldgeo/pointcloud
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);
}