本文整理汇总了C++中CU_ASSERT_DOUBLE_EQUAL函数的典型用法代码示例。如果您正苦于以下问题:C++ CU_ASSERT_DOUBLE_EQUAL函数的具体用法?C++ CU_ASSERT_DOUBLE_EQUAL怎么用?C++ CU_ASSERT_DOUBLE_EQUAL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CU_ASSERT_DOUBLE_EQUAL函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: testGet_seg_size_feature
void testGet_seg_size_feature(){
int lablenum=5,nr=160,nc=160,i=0,j=0;
int size=nr*nc;
int* seglable=NEWA(int,size);
fSegment_size feat;
for(i=0;i<size;++i){
if(i<size/10){
seglable[i]=1;
}
else if(i<2*size/10){
seglable[i]=2;
}
else if(i<4*size/10){
seglable[i]=3;
}
else if(i<6*size/10){
seglable[i]=4;
}
else
seglable[i]=5;
}
feat=get_segsize_feature(seglable,nr,nc,lablenum);
CU_ASSERT_DOUBLE_EQUAL(feat.rmaxsize, 0.4, 0.00001);
CU_ASSERT_DOUBLE_EQUAL(feat.rcontrast, 0.3, 0.00001);
free(seglable);
}
开发者ID:wotiancaibai,项目名称:Features,代码行数:26,代码来源:featureUnitTest.c
示例2: testGet_grayscale_simplicity_feautre
void testGet_grayscale_simplicity_feautre() {
image_gray* gray = image_gray_new(3, 3);
gray->data[0] = 15;
gray->data[1] = 15;
gray->data[2] = 200;
gray->data[3] = 180;
gray->data[4] = 180;
gray->data[5] = 100;
gray->data[6] = 90;
gray->data[7] = 85;
gray->data[8] = 180;
fgray_simplicity feature = get_grayscale_simplicity_feature(gray);
CU_ASSERT_EQUAL(feature.contrast, 186);
CU_ASSERT_EQUAL(feature.sig_pixels_num, 6);
CU_ASSERT_DOUBLE_EQUAL(feature.stdev, 68.01870, 0.00001);
//free(feature);
image_gray* gray2 = image_gray_new(1, 1);
gray2->data[0] = 1;
feature = get_grayscale_simplicity_feature(gray2);
CU_ASSERT_EQUAL(feature.contrast, 1);
CU_ASSERT_EQUAL(feature.sig_pixels_num, 1);
CU_ASSERT_DOUBLE_EQUAL(feature.stdev, 0, 0.00001);
image_gray_delete(gray);
}
开发者ID:wotiancaibai,项目名称:Features,代码行数:28,代码来源:featureUnitTest.c
示例3: test_sagwrite_3x3_zero
extern void test_sagwrite_3x3_zero(void)
{
bbox_t bbox = BBOX(0, 3, 0, 3);
polyline_t p;
CU_ASSERT_EQUAL(polyline_rect(bbox, &p), 0);
domain_t *dom = domain_insert(NULL, &p);
CU_ASSERT_PTR_NOT_NULL(dom);
const char path[] = "tmp/sagwrite-3x3.txt";
CU_ASSERT_EQUAL(sagwrite(path, dom, f0, NULL, 3, 3), 0);
sagread_t sagread;
CU_ASSERT_EQUAL(sagread_open(path, &sagread), 0);
CU_ASSERT_EQUAL_FATAL(sagread.grid.dim, 2);
CU_ASSERT_EQUAL_FATAL(sagread.vector.dim, 2);
double eps = 1e-10;
for (int i = 0 ; i < 2 ; i++)
{
CU_ASSERT_EQUAL_FATAL(sagread.grid.n[i], 3);
CU_ASSERT_DOUBLE_EQUAL(sagread.grid.bnd[i].min, 0.5, eps);
CU_ASSERT_DOUBLE_EQUAL(sagread.grid.bnd[i].max, 2.5, eps);
}
sagread_close(sagread);
domain_destroy(dom);
unlink(path);
}
开发者ID:jjgreen,项目名称:vfplot,代码行数:34,代码来源:test_sagwrite.c
示例4: test_ptarray_signed_area
static void test_ptarray_signed_area()
{
LWLINE *line;
double area;
/* parallelogram */
line = lwgeom_as_lwline(lwgeom_from_text("LINESTRING(0 0,1 1, 2 1, 1 0, 0 0)"));
area = ptarray_signed_area(line->points);
CU_ASSERT_DOUBLE_EQUAL(area, 1.0, 0.0000001);
lwline_free(line);
/* square */
line = lwgeom_as_lwline(lwgeom_from_text("LINESTRING(0 0,0 2, 2 2, 2 0, 0 0)"));
area = ptarray_signed_area(line->points);
CU_ASSERT_DOUBLE_EQUAL(area, 4.0, 0.0000001);
lwline_free(line);
/* square backwares*/
line = lwgeom_as_lwline(lwgeom_from_text("LINESTRING(0 0,2 0, 2 2, 0 2, 0 0)"));
area = ptarray_signed_area(line->points);
//printf("%g\n",area);
CU_ASSERT_DOUBLE_EQUAL(area, -4.0, 0.0000001);
lwline_free(line);
}
开发者ID:NianYue,项目名称:pipelinedb,代码行数:25,代码来源:cu_ptarray.c
示例5: test_schema_xy
/*
* Can we read this example point value?
*/
static void
test_schema_xy()
{
/*
"Intensity", "ReturnNumber", "NumberOfReturns", "ScanDirectionFlag", "EdgeOfFlightLine", "Classification", "ScanAngleRank", "UserData", "PointSourceId", "Time", "Red", "Green", "Blue", "PointID", "BlockID", "X", "Y", "Z"
25, 1, 1, 1, 0, 1, 6, 124, 7327, 246093, 39, 57, 56, 20, 0, -125.0417204, 49.2540081, 128.85
*/
static char *hexpt = "01010000000AE9C90307A1100522A5000019000101010001067C9F1C4953C474650A0E412700390038001400000000000000876B6601962F750155320000";
uint8_t *bytes = bytes_from_hexbytes(hexpt, strlen(hexpt));
PCPOINT *pt;
double val;
pt = pc_point_from_wkb(lasschema, bytes, strlen(hexpt)/2);
pc_point_get_double_by_name(pt, "x", &val);
CU_ASSERT_DOUBLE_EQUAL(val, -125.0417204, 0.00001);
pc_point_free(pt);
pt = pc_point_from_wkb(lasschema, bytes, strlen(hexpt)/2);
pc_point_get_double_by_name(pt, "y", &val);
CU_ASSERT_DOUBLE_EQUAL(val, 49.2540081, 0.00001);
pc_point_free(pt);
pcfree(bytes);
}
开发者ID:ldgeo,项目名称:pointcloud,代码行数:28,代码来源:cu_pc_patch.c
示例6: test_vec_func2d
void test_vec_func2d(void)
{
const unsigned long size_x = 8;
const unsigned long size_y = 9;
double *arg_x = malloc(sizeof(double) * size_x);
double *arg_y = malloc(sizeof(double) * size_y);
for (unsigned long k = 0; k < size_x; ++k)
arg_x[k] = k;
for (unsigned long k = 0; k < size_y; ++k)
arg_y[k] = k;
double *dst = malloc(sizeof(double) * size_x * size_y);
double *arg = malloc(sizeof(double) * size_x * size_y);
py_vec_func2d(dst, py_zero2d, arg_x, size_x, arg_y, size_y);
for (unsigned long i = 0; i < size_x; ++i)
for (unsigned long j = 0; j < size_y; ++j)
CU_ASSERT_DOUBLE_EQUAL(dst[i + j * size_x], 0, TOL);
py_vec_func2d(dst, py_identity2d, arg_x, size_x, arg_y, size_y);
for (unsigned long i = 0; i < size_x; ++i)
for (unsigned long j = 0; j < size_y; ++j)
CU_ASSERT_DOUBLE_EQUAL(dst[i + j * size_x], arg_x[i], TOL);
free(dst);
free(arg);
}
开发者ID:octol,项目名称:paryee,代码行数:28,代码来源:yee_common_tests.c
示例7: testGet_color_coherence_feature
void testGet_color_coherence_feature() {
image_hsv* hsv = image_hsv_new(6, 6);
float data[][6] = {
{0.3, 0.2, 0.3, 0.3, 0.2, 0.2},
{0.3, 0.3, 0.2, 0.3, 0.2, 0.2},
{0.3, 0.2, 0.4, 0.3, 0.2, 0.2},
{0.3, 0.3, 0.3, 0.2, 0.2, 0.3},
{0.3, 0.3, 0.2, 0.2, 0.3, 0.3},
{0.3, 0.3, 0.2, 0.2, 0.3, 0.3}
};
int i, j;
for (i = 0; i < 6; ++i) {
for (j = 0; j < 6; ++j) {
hsv->h[6*i+j] = data[i][j];
hsv->s[6*i+j] = data[i][j];
hsv->v[6*i+j] = data[i][j];
}
}
fcolor_coherence feature = get_color_coherence_feature(hsv);
CU_ASSERT_EQUAL(feature.n_ccc, 3);
CU_ASSERT_DOUBLE_EQUAL(feature.r_lc, 0.55556, 0.00001);
CU_ASSERT_DOUBLE_EQUAL(feature.r_slc, 0.41667, 0.00001);
CU_ASSERT_EQUAL(feature.rank, 2);
CU_ASSERT_EQUAL(feature.s_rank, 1);
// free(feature);
image_hsv_delete(hsv);
}
开发者ID:wotiancaibai,项目名称:Features,代码行数:29,代码来源:featureUnitTest.c
示例8: testGet_color_harmony_feautre
void testGet_color_harmony_feautre() {
image_hsl* hsl1 = image_hsl_new(1, 1);
fcolor_harmony feature;
hsl1->h[0] = 0.39;
hsl1->s[0] = 0.5;
feature = get_color_harmony_feature(hsl1);
CU_ASSERT_DOUBLE_EQUAL(feature.bestfit, 0.1*2*PI*0.5, 0.00001);
CU_ASSERT_DOUBLE_EQUAL(feature.first_two_dev, 0.2*2*PI*0.5, 0.00001);
CU_ASSERT_DOUBLE_EQUAL(feature.avg_dev, 1.436, 0.001);
//free(feature);
/*
image_hsl* hsl2 = image_hsl_new(1, 2);
hsl2->h[0] = 0.11;
hsl2->h[1] = 0.90;
hsl2->s[0] = 1;
hsl2->s[1] = 1;
feature = get_color_harmony_feature(hsl2);
CU_ASSERT_DOUBLE_EQUAL(feature.bestfit, 0, 0.00001);
CU_ASSERT_DOUBLE_EQUAL(feature.first_two_dev, 0, 0.00001);
CU_ASSERT_DOUBLE_EQUAL(feature.avg_dev, 1.1220, 0.02);
//free(feature);
*/
image_hsl_delete(hsl1);
//image_hsl_delete(hsl2);
}
开发者ID:wotiancaibai,项目名称:Features,代码行数:28,代码来源:featureUnitTest.c
示例9: test_statistics
// Test statistics
static void test_statistics() {
// Reseed the RNG
gmcmc_rng_set(rng, 0);
// Create the distribution
gmcmc_prior * lognormal;
CU_ASSERT(gmcmc_prior_create(&lognormal, gmcmc_prior_lognormal, 0.0, 1.0) == GMCMC_SUCCESS);
double x[100000], mean = 0.0, var = 0.0;
for (size_t i = 0; i < 100000; i++) {
x[i] = gmcmc_prior_sample(lognormal, rng);
// Knuth - The Art of Computer Programming (vol 2. 1998 p.232)
double mprev = mean;
mean += (x[i] - mean) / ((double)i + 1.0);
var += (x[i] - mean) * (x[i] - mprev);
}
var /= 100000.0;
// Test mean and variance
CU_ASSERT_DOUBLE_EQUAL(mean, 1.64872127, 0.00531826);
CU_ASSERT_DOUBLE_EQUAL(var, 4.67077427, 0.04173919);
gmcmc_prior_destroy(lognormal);
}
开发者ID:bencalderhead,项目名称:General_MCMC,代码行数:26,代码来源:lognormal.c
示例10: test_gdal_warp
static void test_gdal_warp() {
rt_pixtype pixtype = PT_64BF;
rt_band band = NULL;
rt_raster raster;
rt_raster rast;
uint32_t x;
uint32_t width = 100;
uint32_t y;
uint32_t height = 100;
double value = 0;
char src_srs[] = "PROJCS[\"unnamed\",GEOGCS[\"unnamed ellipse\",DATUM[\"unknown\",SPHEROID[\"unnamed\",6370997,0]],PRIMEM[\"Greenwich\",0],UNIT[\"degree\",0.0174532925199433]],PROJECTION[\"Lambert_Azimuthal_Equal_Area\"],PARAMETER[\"latitude_of_center\",45],PARAMETER[\"longitude_of_center\",-100],PARAMETER[\"false_easting\",0],PARAMETER[\"false_northing\",0],UNIT[\"Meter\",1],AUTHORITY[\"EPSG\",\"2163\"]]";
char dst_srs[] = "PROJCS[\"NAD83 / California Albers\",GEOGCS[\"NAD83\",DATUM[\"North_American_Datum_1983\",SPHEROID[\"GRS 1980\",6378137,298.257222101,AUTHORITY[\"EPSG\",\"7019\"]],AUTHORITY[\"EPSG\",\"6269\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.01745329251994328,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4269\"]],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],PROJECTION[\"Albers_Conic_Equal_Area\"],PARAMETER[\"standard_parallel_1\",34],PARAMETER[\"standard_parallel_2\",40.5],PARAMETER[\"latitude_of_center\",0],PARAMETER[\"longitude_of_center\",-120],PARAMETER[\"false_easting\",0],PARAMETER[\"false_northing\",-4000000],AUTHORITY[\"EPSG\",\"3310\"],AXIS[\"X\",EAST],AXIS[\"Y\",NORTH]]";
raster = rt_raster_new(width, height);
CU_ASSERT(raster != NULL); /* or we're out of virtual memory */
band = cu_add_band(raster, pixtype, 1, 0);
CU_ASSERT(band != NULL);
rt_raster_set_offsets(raster, -500000, 600000);
rt_raster_set_scale(raster, 1000, -1000);
for (x = 0; x < width; x++) {
for (y = 0; y < height; y++) {
rt_band_set_pixel(band, x, y, (((double) x * y) + (x + y) + (x + y * x)) / (x + y + 1), NULL);
}
}
rast = rt_raster_gdal_warp(
raster,
src_srs, dst_srs,
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL, NULL,
GRA_NearestNeighbour, -1
);
CU_ASSERT(rast != NULL);
CU_ASSERT_EQUAL(rt_raster_get_width(rast), 122);
CU_ASSERT_EQUAL(rt_raster_get_height(rast), 116);
CU_ASSERT_NOT_EQUAL(rt_raster_get_num_bands(rast), 0);
band = rt_raster_get_band(rast, 0);
CU_ASSERT(band != NULL);
CU_ASSERT(rt_band_get_hasnodata_flag(band));
rt_band_get_nodata(band, &value);
CU_ASSERT_DOUBLE_EQUAL(value, 0., DBL_EPSILON);
CU_ASSERT_EQUAL(rt_band_get_pixel(band, 0, 0, &value, NULL), ES_NONE);
CU_ASSERT_DOUBLE_EQUAL(value, 0., DBL_EPSILON);
cu_free_raster(rast);
cu_free_raster(raster);
}
开发者ID:ahinz,项目名称:postgis,代码行数:59,代码来源:cu_gdal.c
示例11: get_segcolor_harmony_feature_test
void get_segcolor_harmony_feature_test(){
int width=10,height=15;
image_hsl* imagehsl=image_hsl_new(width,height);
image_hsl* seghsl=image_hsl_new(1,50);
int seglable[width*height];
int lablenum=5;
int i=0,j=0,k=0;
for(i=0;i<height/3;++i){
for(j=width/2;j<width;++j){
imagehsl->l[i*width+j]=0.2;
imagehsl->h[i*width+j]=0.2;
imagehsl->s[i*width+j]=0.2;
seglable[i*width+j]=2;
}
}
for(i=height/3;i<2*height/3;++i){
for(j=0;j<width/2;++j){
imagehsl->l[i*width+j]=0.3;
imagehsl->s[i*width+j]=0.3;
imagehsl->h[i*width+j]=0.3;
seglable[i*width+j]=3;
}
}
for(i=height/3;i<2*height/3;++i){
for(j=width/2;j<width;++j){
imagehsl->l[i*width+j]=0.4;
imagehsl->s[i*width+j]=0.4;
imagehsl->h[i*width+j]=0.4;
seglable[i*width+j]=4;
}
}
for(i=2*height/3;i<height;++i){
for(j=0;j<width;++j){
imagehsl->l[i*width+j]=0.5;
imagehsl->s[i*width+j]=0.5;
imagehsl->h[i*width+j]=0.5;
seghsl->l[k]=0.5;
seghsl->h[k]=0.5;
seghsl->s[k]=0.5;
seglable[i*width+j]=5;
k++;
}
}
fcolor_harmony feat=get_segcolor_harmony_feature(imagehsl,seglable,lablenum);
fcolor_harmony feat_test=get_color_harmony_feature(seghsl);
image_hsl_delete(imagehsl);
image_hsl_delete(seghsl);
CU_ASSERT_DOUBLE_EQUAL(feat.avg_dev,feat_test.avg_dev,0.00001);
CU_ASSERT_DOUBLE_EQUAL(feat.bestfit,feat_test.bestfit,0.00001);
CU_ASSERT_DOUBLE_EQUAL(feat.first_two_dev,feat_test.first_two_dev,0.00001);
//free(feat_test);
}
开发者ID:wotiancaibai,项目名称:Features,代码行数:59,代码来源:featureUnitTest.c
示例12: test_patch_lazperf
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);
}
开发者ID:mbredif,项目名称:pointcloud,代码行数:57,代码来源:cu_pc_patch_lazperf.c
示例13: test_parallel_bond_act_probability
/*
Test that parallel spins have correct bond activation probability
(given by the action).
*/
void test_parallel_bond_act_probability() {
double s1[1];
double s2[1];
double *r = create_spin(1);
s1[0] = 1; s2[0] = 1;
CU_ASSERT_DOUBLE_EQUAL(0.5507,bond_act_probability(s1, s2, r, 0.4, 1),0.0001);
s1[0] = -1; s2[0] = -1;
CU_ASSERT_DOUBLE_EQUAL(0.7981,bond_act_probability(s1, s2, r, 0.8, 1),0.0001);
free(r);
}
开发者ID:Ununquadium,项目名称:cluster,代码行数:14,代码来源:suite_ising_spin.c
示例14: test_evaluation
// Test evaluation
static void test_evaluation() {
// Create the distribution
gmcmc_prior * lognormal;
CU_ASSERT(gmcmc_prior_create(&lognormal, gmcmc_prior_lognormal, 0.0, 1.0) == GMCMC_SUCCESS);
CU_ASSERT_DOUBLE_EQUAL(gmcmc_prior_evaluate(lognormal, 1.0), 0.39894229, 1.e-8);
CU_ASSERT_DOUBLE_EQUAL(gmcmc_prior_evaluate_1st_order(lognormal, 1.0), -1.0, 0.0);
CU_ASSERT_DOUBLE_EQUAL(gmcmc_prior_evaluate_2nd_order(lognormal, 1.0), 0.0, 0.0);
gmcmc_prior_destroy(lognormal);
}
开发者ID:bencalderhead,项目名称:General_MCMC,代码行数:12,代码来源:lognormal.c
示例15: test_patch_dimensional
/**
* 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);
}
开发者ID:ldgeo,项目名称:pointcloud,代码行数:54,代码来源:cu_pc_patch.c
示例16: test_gdal_rasterize
static void test_gdal_rasterize() {
rt_raster raster;
char srs[] = "PROJCS[\"unnamed\",GEOGCS[\"unnamed ellipse\",DATUM[\"unknown\",SPHEROID[\"unnamed\",6370997,0]],PRIMEM[\"Greenwich\",0],UNIT[\"degree\",0.0174532925199433]],PROJECTION[\"Lambert_Azimuthal_Equal_Area\"],PARAMETER[\"latitude_of_center\",45],PARAMETER[\"longitude_of_center\",-100],PARAMETER[\"false_easting\",0],PARAMETER[\"false_northing\",0],UNIT[\"Meter\",1],AUTHORITY[\"EPSG\",\"2163\"]]";
const char wkb_hex[] = "010300000001000000050000000000000080841ec100000000600122410000000080841ec100000000804f22410000000040e81dc100000000804f22410000000040e81dc100000000600122410000000080841ec10000000060012241";
const char *pos = wkb_hex;
unsigned char *wkb = NULL;
int wkb_len = 0;
int i;
double scale_x = 100;
double scale_y = -100;
rt_pixtype pixtype[] = {PT_8BUI};
double init[] = {0};
double value[] = {1};
double nodata[] = {0};
uint8_t nodata_mask[] = {1};
/* hex to byte */
wkb_len = (int) ceil(((double) strlen(wkb_hex)) / 2);
wkb = (unsigned char *) rtalloc(sizeof(unsigned char) * wkb_len);
for (i = 0; i < wkb_len; i++) {
sscanf(pos, "%2hhx", &wkb[i]);
pos += 2;
}
raster = rt_raster_gdal_rasterize(
wkb,
wkb_len, srs,
1, pixtype,
init, value,
nodata, nodata_mask,
NULL, NULL,
&scale_x, &scale_y,
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL
);
CU_ASSERT(raster != NULL);
CU_ASSERT_EQUAL(rt_raster_get_width(raster), 100);
CU_ASSERT_EQUAL(rt_raster_get_height(raster), 100);
CU_ASSERT_NOT_EQUAL(rt_raster_get_num_bands(raster), 0);
CU_ASSERT_DOUBLE_EQUAL(rt_raster_get_x_offset(raster), -500000, DBL_EPSILON);
CU_ASSERT_DOUBLE_EQUAL(rt_raster_get_y_offset(raster), 600000, DBL_EPSILON);
rtdealloc(wkb);
cu_free_raster(raster);
}
开发者ID:ahinz,项目名称:postgis,代码行数:49,代码来源:cu_gdal.c
示例17: test_affine
static void
test_affine()
{
double a, b, c, d, e, f, g, h, i;
double xoff, yoff, zoff;
double angle;
LIBOX4 ibox, *obox;
// create the 4x3 affine matrix
// rotation: pi/4 along x axis
// scale: 2 along x axis
// translation: 1 along x axis
angle = M_PI_4;
a = 2;
b = 0;
c = 0;
xoff = 1;
d = 0;
e = cos(angle);
f = -sin(angle);
yoff = 0;
g = 0;
h = sin(angle);
i = cos(angle);
zoff = 0;
// 3d box centered on (0, 0, 0)
ibox[0][0] = -1.0;
ibox[0][1] = -1.0;
ibox[0][2] = 1.0;
ibox[0][3] = 10.0;
ibox[1][0] = 1.0;
ibox[1][1] = 1.0;
ibox[1][2] = -1.0;
ibox[1][3] = 20.0;
obox = li_box4d_affine(ibox, a, b, c, d, e, f, g, h, i, xoff, yoff, zoff);
CU_ASSERT((*obox)[0][0] == -1.0);
CU_ASSERT_DOUBLE_EQUAL((*obox)[0][1], -sqrt(2.0), 0.000001);
CU_ASSERT_DOUBLE_EQUAL((*obox)[0][2], -sqrt(2.0), 0.000001);
CU_ASSERT((*obox)[0][3] == 10.0);
CU_ASSERT((*obox)[1][0] == 3.0);
CU_ASSERT_DOUBLE_EQUAL((*obox)[1][1], sqrt(2.0), 0.000001);
CU_ASSERT_DOUBLE_EQUAL((*obox)[1][2], sqrt(2.0), 0.000001);
CU_ASSERT((*obox)[1][3] == 20.0);
pcfree(obox);
}
开发者ID:LI3DS,项目名称:pointcloud,代码行数:49,代码来源:cu_li_box4d.c
示例18: get_seglightness_feature_test
void get_seglightness_feature_test(){
int width=10,height=15;
image_hsl* imagehsl=image_hsl_new(width,height);
int seglable[width*height];
int lablenum=5;
int i=0,j=0;
fsegment_lightness feat;
for(i=0;i<height/3;++i){
for(j=0;j<width/2;++j){
imagehsl->l[i*width+j]=0.1;
seglable[i*width+j]=1;
}
}
for(i=0;i<height/3;++i){
for(j=width/2;j<width;++j){
imagehsl->l[i*width+j]=0.2;
seglable[i*width+j]=2;
}
}
for(i=height/3;i<2*height/3;++i){
for(j=0;j<width/2;++j){
imagehsl->l[i*width+j]=0.3;
seglable[i*width+j]=3;
}
}
for(i=height/3;i<2*height/3;++i){
for(j=width/2;j<width;++j){
imagehsl->l[i*width+j]=0.4;
seglable[i*width+j]=4;
}
}
for(i=2*height/3;i<height;++i){
for(j=0;j<width;++j){
imagehsl->l[i*width+j]=0.5;
seglable[i*width+j]=5;
}
}
feat=get_seglightness_feature(imagehsl,seglable,lablenum);
image_hsl_delete(imagehsl);
CU_ASSERT_DOUBLE_EQUAL(feat.mseg_ave,0.5,0.00001);
CU_ASSERT_DOUBLE_EQUAL(feat.seg_ave_std,0.141421356,0.00001);
CU_ASSERT_DOUBLE_EQUAL(feat.seg_ave_contrast,0.4,0.00001);
}
开发者ID:wotiancaibai,项目名称:Features,代码行数:48,代码来源:featureUnitTest.c
示例19: test_raster_replace_band
static void test_raster_replace_band() {
rt_raster raster;
rt_band band;
rt_band rband;
void* mem;
size_t datasize;
uint16_t width;
uint16_t height;
double nodata;
raster = rt_raster_new(10, 10);
CU_ASSERT(raster != NULL); /* or we're out of virtual memory */
band = cu_add_band(raster, PT_8BUI, 0, 0);
CU_ASSERT(band != NULL);
band = cu_add_band(raster, PT_8BUI, 1, 255);
CU_ASSERT(band != NULL);
width = rt_raster_get_width(raster);
height = rt_raster_get_height(raster);
datasize = rt_pixtype_size(PT_8BUI) * width * height;
mem = rtalloc(datasize);
band = rt_band_new_inline(width, height, PT_8BUI, 1, 1, mem);
CU_ASSERT(band != NULL);
rt_band_set_ownsdata_flag(band, 1);
rband = rt_raster_replace_band(raster, band, 0);
CU_ASSERT(rband != NULL);
rt_band_get_nodata(rt_raster_get_band(raster, 0), &nodata);
CU_ASSERT_DOUBLE_EQUAL(nodata, 1, DBL_EPSILON);
rt_band_destroy(rband);
cu_free_raster(raster);
}
开发者ID:ahinz,项目名称:postgis,代码行数:34,代码来源:cu_raster_basics.c
示例20: testGet_sharpness_feautre
void testGet_sharpness_feautre() {
image_hsl* hsl = image_hsl_new(4, 4);
hsl->l[0] = 0.3;
hsl->l[1] = 0.2;
hsl->l[2] = 0.5;
hsl->l[3] = 0.6;
hsl->l[4] = 0.7;
hsl->l[5] = 0.3;
hsl->l[6] = 0.5;
hsl->l[7] = 0.4;
hsl->l[8] = 0.1;
hsl->l[9] = 0.6;
hsl->l[10] = 0.3;
hsl->l[11] = 0.4;
hsl->l[12] = 0.9;
hsl->l[13] = 0.5;
hsl->l[14] = 0.2;
hsl->l[15] = 0.1;
float feature = get_sharpness_feature(hsl);
CU_ASSERT_DOUBLE_EQUAL(feature, -0.39758, 0.00001);
image_hsl_delete(hsl);
}
开发者ID:wotiancaibai,项目名称:Features,代码行数:25,代码来源:featureUnitTest.c
注:本文中的CU_ASSERT_DOUBLE_EQUAL函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论