Exemple #1
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);
}
Exemple #2
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);
}
Exemple #3
0
/**
* Convert struct to byte array.
* Userdata is currently only PCDIMSTATS, hopefully updated across
* a number of iterations and saved.
*/
SERIALIZED_PATCH *
pc_patch_serialize(const PCPATCH *patch_in, void *userdata)
{
	PCPATCH *patch = (PCPATCH*)patch_in;
	SERIALIZED_PATCH *serpatch = NULL;
	/*
	* Ensure the patch has stats calculated before going on
	*/
	if ( ! patch->stats )
	{
		pcerror("%s: patch is missing stats", __func__);
		return NULL;
	}
	/*
	* Convert the patch to the final target compression,
	* which is the one in the schema.
	*/
	if ( patch->type != patch->schema->compression )
	{
		patch = pc_patch_compress(patch_in, userdata);
	}

	switch( patch->type )
	{
	case PC_NONE:
	{
		serpatch = pc_patch_uncompressed_serialize(patch);
		break;
	}
	case PC_DIMENSIONAL:
	{
		serpatch = pc_patch_dimensional_serialize(patch);
		break;
	}
	case PC_GHT:
	{
		serpatch = pc_patch_ght_serialize(patch);
		break;
	}
	default:
	{
		pcerror("%s: unsupported compression type %d", __func__, patch->type);
	}
	}

	if ( patch != patch_in )
		pc_patch_free(patch);

	return serpatch;
}
Exemple #4
0
/**
* Convert struct to byte array.
* Userdata is currently only PCDIMSTATS, hopefully updated across
* a number of iterations and saved.
*/
SERIALIZED_PATCH * 
pc_patch_serialize(const PCPATCH *patch_in, void *userdata)
{   
    PCPATCH *patch = (PCPATCH*)patch_in;
    SERIALIZED_PATCH *serpatch;
    /* 
    * Convert the patch to the final target compression,
    * which is the one in the schema.
    */
    if ( patch->type != patch->schema->compression )
    {
        patch = pc_patch_compress(patch_in, userdata);
    }
    
    switch( patch->type )
    {
        case PC_NONE:
            serpatch = pc_patch_uncompressed_serialize(patch);
            break;
        case PC_DIMENSIONAL:
        {
            serpatch = pc_patch_dimensional_serialize(patch);
            break;
        }
        case PC_GHT:
        {
            pcerror("pc_patch_serialize: GHT compression currently unsupported");
            break;
        }
        default:
        {
            pcerror("pc_patch_serialize: unsupported compression type %d", patch->type);
        }
    }
    
    if ( patch != patch_in )
        pc_patch_free(patch);
    
    return serpatch;
}