Changeset: 60c2ad50ad30 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=60c2ad50ad30
Modified Files:
        geom/monetdb5/geom.c
        geom/monetdb5/geom.mal
        monetdb5/optimizer/opt_geospatial.c
Branch: geo
Log Message:

renamed the filtering function to reflect the spatial relation checked


diffs (109 lines):

diff --git a/geom/monetdb5/geom.c b/geom/monetdb5/geom.c
--- a/geom/monetdb5/geom.c
+++ b/geom/monetdb5/geom.c
@@ -129,7 +129,7 @@ geom_export str wkbRelate(bit*, wkb**, w
 geom_export str wkbCovers(bit *out, wkb **geomWKB_a, wkb **geomWKB_b);
 geom_export str wkbCoveredBy(bit *out, wkb **geomWKB_a, wkb **geomWKB_b);
 
-geom_export str wkbFilter_bat(int* aBATfiltered_id, int* bBATfiltered_id, int* 
aBAT_id, int* bBAT_id);
+geom_export str wkbContainsFilter_bat(int* aBATfiltered_id, int* 
bBATfiltered_id, int* aBAT_id, int* bBAT_id);
 
 //LocateAlong
 //LocateBetween
@@ -2826,15 +2826,13 @@ str wkbContains_bat_bat(int* outBAT_id, 
 /**
  * It filters the geometry in the second BAT with respect to the MBR of the 
geometry in the first BAT.
  **/
-str wkbFilter_bat(int* aBATfiltered_id, int* bBATfiltered_id, int* aBAT_id, 
int* bBAT_id) {
+str wkbContainsFilter_bat(int* aBATfiltered_id, int* bBATfiltered_id, int* 
aBAT_id, int* bBAT_id) {
        BAT *aBATfiltered = NULL, *bBATfiltered = NULL, *aBAT = NULL, *bBAT = 
NULL;
        wkb *aWKB = NULL, *bWKB = NULL;
        bit outBIT;
        BATiter aBAT_iter, bBAT_iter;
        BUN i=0;
 
-       mbr *aMBR=NULL, *bMBR=NULL;
-
        //get the descriptor of the BAT
        if ((aBAT = BATdescriptor(*aBAT_id)) == NULL) {
                throw(MAL, "batgeom.MBRfilter", RUNTIME_OBJECT_MISSING);
@@ -2877,8 +2875,8 @@ str wkbFilter_bat(int* aBATfiltered_id, 
                aWKB = (wkb*) BUNtail(aBAT_iter, i + BUNfirst(aBAT));
                bWKB = (wkb*) BUNtail(bBAT_iter, i + BUNfirst(bBAT));
 
-               //create the MBRs of the two geometries
-               if((err = wkbMBR(&aMBR, &aWKB)) != MAL_SUCCEED) {
+               //check the containment of the MBRs
+               if((err = mbrContains_wkb(&outBIT, &aWKB, &bWKB)) != 
MAL_SUCCEED) {
                        str msg;
                        BBPreleaseref(aBAT->batCacheid);
                        BBPreleaseref(bBAT->batCacheid);
@@ -2888,30 +2886,6 @@ str wkbFilter_bat(int* aBATfiltered_id, 
                        GDKfree(err);
                        return msg;
                }
-               if((err = wkbMBR(&bMBR, &bWKB)) != MAL_SUCCEED) {
-                       str msg;
-                       BBPreleaseref(aBAT->batCacheid);
-                       BBPreleaseref(bBAT->batCacheid);
-                       BBPreleaseref(aBATfiltered->batCacheid);
-                       BBPreleaseref(bBATfiltered->batCacheid);
-                       msg = createException(MAL, "batgeom.wkbFilter", "%s", 
err);
-                       GDKfree(err);
-                       GDKfree(aMBR);
-                       return msg;
-               }
-               //check the containment of the MBRs
-               if((err = mbrContains(&outBIT, &aMBR, &bMBR)) != MAL_SUCCEED) {
-                       str msg;
-                       BBPreleaseref(aBAT->batCacheid);
-                       BBPreleaseref(bBAT->batCacheid);
-                       BBPreleaseref(aBATfiltered->batCacheid);
-                       BBPreleaseref(bBATfiltered->batCacheid);
-                       msg = createException(MAL, "batgeom.wkbFilter", "%s", 
err);
-                       GDKfree(err);
-                       GDKfree(aMBR);
-                       GDKfree(bMBR);
-                       return msg;
-               }
                if(outBIT) {
                        BUNappend(aBATfiltered,&aWKB, TRUE); //add the result 
to the aBAT
                        BUNappend(bBATfiltered,&bWKB, TRUE); //add the result 
to the bBAT
@@ -2932,10 +2906,6 @@ str wkbFilter_bat(int* aBATfiltered_id, 
        BBPkeepref(*aBATfiltered_id = aBATfiltered->batCacheid);
        BBPkeepref(*bBATfiltered_id = bBATfiltered->batCacheid);
        
-       //free the MBRs
-       GDKfree(aMBR);
-       GDKfree(bMBR);
-
        return MAL_SUCCEED;
 
 
diff --git a/geom/monetdb5/geom.mal b/geom/monetdb5/geom.mal
--- a/geom/monetdb5/geom.mal
+++ b/geom/monetdb5/geom.mal
@@ -414,8 +414,9 @@ geom.prelude();
 
 module batgeom;
 
-command MBRfilter{unsafe}(a:bat[:oid,:wkb], b:bat[:oid,:wkb]) 
(aFiltered:bat[:oid,:wkb], bFiltered:bat[:oid,:wkb]) address wkbFilter_bat
-comment "Filters the points in the bats according to the MBR of the other bat. 
The BAT with more that one geometries is the one filtered";
+command ContainsFilter{unsafe}(a:bat[:oid,:wkb], b:bat[:oid,:wkb]) 
(aFiltered:bat[:oid,:wkb], bFiltered:bat[:oid,:wkb]) address 
wkbContainsFilter_bat
+comment "Filters the points in the bats according to the MBR of the other 
bat.";
+
 #command point(x:bat[:oid,:dbl],y:bat[:oid,:dbl]) :bat[:oid,:wkb]
 #address wkbcreatepoint_bat
 #comment "Construct a point-BAT from two geometry-BATs";
diff --git a/monetdb5/optimizer/opt_geospatial.c 
b/monetdb5/optimizer/opt_geospatial.c
--- a/monetdb5/optimizer/opt_geospatial.c
+++ b/monetdb5/optimizer/opt_geospatial.c
@@ -29,7 +29,7 @@ int OPTgeospatialImplementation(Client c
                        if(strcasecmp(getFunctionId(oldInstrPtr[i]), 
"contains") == 0) {
 
                                //create the new instruction
-                               newInstrPtr = newStmt(mb, "batgeom", 
"MBRfilter");
+                               newInstrPtr = newStmt(mb, "batgeom", 
"ContainsFilter");
                                //create the return variables of the new 
instruction
                                aBATreturnId = newVariable(mb, 
GDKstrdup("aBAT_filtered"), newBatType(TYPE_oid, 
getArgType(mb,oldInstrPtr[i],1)));
                                bBATreturnId = newVariable(mb, 
GDKstrdup("bBAT_filtered"), newBatType(TYPE_oid, 
getArgType(mb,oldInstrPtr[i],2)));
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to