/* Can any range from range_box be contained by this argument? */ static bool contained2D(RangeBox *range_box, Range *query) { return FPle(range_box->left.low, query->high) && FPge(range_box->left.high, query->low) && FPle(range_box->right.low, query->high) && FPge(range_box->right.high, query->low); }
Datum BOX2D_contained(PG_FUNCTION_ARGS) { GBOX *box1 =(GBOX *) PG_GETARG_POINTER(0); GBOX *box2 = (GBOX *) PG_GETARG_POINTER(1); PG_RETURN_BOOL(FPle(box1->xmax, box2->xmax) && FPge(box1->xmin, box2->xmin) && FPle(box1->ymax, box2->ymax) && FPge(box1->ymin, box2->ymin)); }
Datum BOX2D_contain(PG_FUNCTION_ARGS) { BOX2DFLOAT4 *box1 = (BOX2DFLOAT4 *) PG_GETARG_POINTER(0); BOX2DFLOAT4 *box2 = (BOX2DFLOAT4 *) PG_GETARG_POINTER(1); PG_RETURN_BOOL(FPge(box1->xmax, box2->xmax) && FPle(box1->xmin, box2->xmin) && FPge(box1->ymax, box2->ymax) && FPle(box1->ymin, box2->ymin)); }
Datum BOX2D_overabove(PG_FUNCTION_ARGS) { GBOX *box1 = (GBOX *) PG_GETARG_POINTER(0); GBOX *box2 = (GBOX *) PG_GETARG_POINTER(1); PG_RETURN_BOOL(FPge(box1->ymin, box2->ymin)); }
Datum BOX2D_overright(PG_FUNCTION_ARGS) { BOX2DFLOAT4 *box1 = (BOX2DFLOAT4 *) PG_GETARG_POINTER(0); BOX2DFLOAT4 *box2 = (BOX2DFLOAT4 *) PG_GETARG_POINTER(1); PG_RETURN_BOOL(FPge(box1->xmin, box2->xmin)); }
int32 * spherebox_gen_key ( int32 * key , const SBOX * box ) { static SPoint p; static float8 d; key[0] = key[1] = key[2] = MAXCVALUE; key[3] = key[4] = key[5] = -MAXCVALUE; // add the 4 edges key_add_point( key, &box->sw ); key_add_point( key, &box->ne ); p.lng = box->sw.lng; p.lat = box->ne.lat; key_add_point( key, &p ); p.lng = box->ne.lng; p.lat = box->sw.lat; key_add_point( key, &p ); // latitude closest to equator if ( FPge(box->ne.lat,0.0) && FPle(box->sw.lat,0.0) ){ p.lat=0.0; } else if ( fabs(box->ne.lat) > fabs(box->sw.lat) ){ p.lat = box->sw.lat; } else { p.lat = box->ne.lat; } for ( d = 0.0; d<(PID-0.1); d+=PIH ){ p.lng = d; if ( sbox_cont_point( box, &p ) ){ key_add_point( key, &p ); } } return key; }
Datum BOX2D_overlap(PG_FUNCTION_ARGS) { GBOX *box1 = (GBOX *) PG_GETARG_POINTER(0); GBOX *box2 = (GBOX *) PG_GETARG_POINTER(1); bool result; result = ((FPge(box1->xmax, box2->xmax) && FPle(box1->xmin, box2->xmax)) || (FPge(box2->xmax, box1->xmax) && FPle(box2->xmin, box1->xmax))) && ((FPge(box1->ymax, box2->ymax) && FPle(box1->ymin, box2->ymax)) || (FPge(box2->ymax, box1->ymax) && FPle(box2->ymin, box1->ymax))); PG_RETURN_BOOL(result); }
static bool gist_point_consistent_internal(StrategyNumber strategy, bool isLeaf, BOX *key, Point *query) { bool result = false; switch (strategy) { case RTLeftStrategyNumber: result = FPlt(key->low.x, query->x); break; case RTRightStrategyNumber: result = FPgt(key->high.x, query->x); break; case RTAboveStrategyNumber: result = FPgt(key->high.y, query->y); break; case RTBelowStrategyNumber: result = FPlt(key->low.y, query->y); break; case RTSameStrategyNumber: if (isLeaf) { /* key.high must equal key.low, so we can disregard it */ result = (FPeq(key->low.x, query->x) && FPeq(key->low.y, query->y)); } else { result = (FPle(query->x, key->high.x) && FPge(query->x, key->low.x) && FPle(query->y, key->high.y) && FPge(query->y, key->low.y)); } break; default: elog(ERROR, "unrecognized strategy number: %d", strategy); result = false; /* keep compiler quiet */ break; } return result; }
Datum spherecircle_overlap_neg (PG_FUNCTION_ARGS) { SCIRCLE * c1 = ( SCIRCLE * ) PG_GETARG_POINTER ( 0 ) ; SCIRCLE * c2 = ( SCIRCLE * ) PG_GETARG_POINTER ( 1 ) ; float8 dist = spoint_dist ( &c1->center, &c2->center ); if ( scircle_eq( c1, c2 ) ){ PG_RETURN_BOOL ( FALSE ); } else if ( FPge( ( c1->radius + c2->radius ) , dist ) ) { PG_RETURN_BOOL ( FALSE ); } else { PG_RETURN_BOOL ( TRUE ) ; } }
Datum spherepoly_area(PG_FUNCTION_ARGS) { SPOLY * poly = PG_GETARG_SPOLY( 0 ) ; int32 i; SPoint s[poly->npts + 2]; SPoint stmp[2]; SEuler se; float8 sum = 0.0; memcpy( (void*)&s[1], (void*)&poly->p[0] , poly->npts * sizeof( SPoint ) ); memcpy( (void*)&s[0], (void*)&s[poly->npts] , sizeof( SPoint ) ); memcpy( (void*)&s[poly->npts+1], (void*)&s[1] , sizeof( SPoint ) ); se.psi = 0; se.phi_a = EULER_AXIS_Z; se.theta_a = EULER_AXIS_X; se.psi_a = EULER_AXIS_Z; for ( i=1; i<=poly->npts; i++ ){ se.phi = -PIH - s[i].lng ; se.theta = s[i].lat - PIH ; euler_spoint_trans( &stmp[0] , &s[i-1] , &se ); euler_spoint_trans( &stmp[1] , &s[i+1] , &se ); stmp[1].lng -= stmp[0].lng; if ( FPlt(stmp[1].lng,0.0) ){ stmp[1].lng += PID; } sum += stmp[1].lng ; } sum -= ( PI * ( poly->npts - 2 ) ) ; if ( FPge(sum,PID) ){ sum = 2*PID - sum; } if ( FPzero(sum) ){ sum = 0.0; } PG_RETURN_FLOAT8 ( sum ); }
/* Can any range from range_box overlap with this argument? */ static bool overlap2D(RangeBox *range_box, Range *query) { return FPge(range_box->right.high, query->low) && FPle(range_box->left.low, query->high); }
long box_ge(BOX *box1, BOX *box2) { return( FPge(box_ar(box1), box_ar(box2)) ); }