static void test_dimension_get() { PCDIMENSION *d; d = pc_schema_get_dimension(schema, 0); CU_ASSERT_EQUAL(d->position, 0); CU_ASSERT_STRING_EQUAL(d->name, "X"); d = pc_schema_get_dimension(schema, 1); CU_ASSERT_EQUAL(d->position, 1); CU_ASSERT_STRING_EQUAL(d->name, "Y"); d = pc_schema_get_dimension_by_name(schema, "nothinghere"); CU_ASSERT_EQUAL(d, NULL); d = pc_schema_get_dimension_by_name(schema, "Z"); CU_ASSERT_EQUAL(d->position, 2); CU_ASSERT_STRING_EQUAL(d->name, "Z"); d = pc_schema_get_dimension_by_name(schema, "z"); CU_ASSERT_EQUAL(d->position, 2); CU_ASSERT_STRING_EQUAL(d->name, "Z"); d = pc_schema_get_dimension_by_name(schema, "y"); // printf("name %s\n", d->name); // printf("position %d\n", d->position); CU_ASSERT_EQUAL(d->position, 1); CU_ASSERT_STRING_EQUAL(d->name, "Y"); }
int pc_point_set_double_by_name(PCPOINT *pt, const char *name, double val) { PCDIMENSION *d; d = pc_schema_get_dimension_by_name(pt->schema, name); return pc_point_set_double(pt, d, val); }
int pc_point_get_double_by_name(const PCPOINT *pt, const char *name, double *val) { PCDIMENSION *dim; dim = pc_schema_get_dimension_by_name(pt->schema, name); return pc_point_get_double(pt, dim, val); }
int pc_point_get_double_by_name(const PCPOINT *pt, const char *name, double *d) { PCDIMENSION *dim; dim = pc_schema_get_dimension_by_name(pt->schema, name); if ( ! dim ) return PC_FAILURE; return pc_point_get_double(pt, dim, d); }
PCPATCH * pc_patch_filter_equal_by_name(const PCPATCH *pa, const char *name, double val) { /* Error out if we can't find the name */ PCDIMENSION *d = pc_schema_get_dimension_by_name(pa->schema, name); if ( ! d ) return NULL; return pc_patch_filter(pa, d->position, PC_EQUAL, val, val); }
/** * This function returns the position of a dimension of the given name, or -1 if there is no dimension of the given name * * */ uint32_t pc_schema_get_dimension_position_by_name(const PCSCHEMA *s, const char *name) { PCDIMENSION * temp ; temp = pc_schema_get_dimension_by_name(s, name); if(temp == NULL) { return -1; pcerror("error, the dimension %s doesn't exit in the schema %s \n",name,pc_schema_to_json(s)); } else { return temp->position; } }
PCPATCH * pc_patch_filter_between_by_name(const PCPATCH *pa, const char *name, double val1, double val2) { /* Ensure val1 < val2 always */ if ( val1 > val2 ) { double tmp = val1; val1 = val2; val2 = tmp; } /* Error out if we can't find the name */ PCDIMENSION *d = pc_schema_get_dimension_by_name(pa->schema, name); if ( ! d ) return NULL; return pc_patch_filter(pa, d->position, PC_BETWEEN, val1, val2); }