[fdo-commits] r198 - in branches/3.2.x/Providers/SDF/Src: Provider
UnitTest
svn_fdo at osgeo.org
svn_fdo at osgeo.org
Wed Jan 31 16:45:29 EST 2007
Author: badreddinekaroui
Date: 2007-01-31 16:45:22 -0500 (Wed, 31 Jan 2007)
New Revision: 198
Modified:
branches/3.2.x/Providers/SDF/Src/Provider/RTree.cpp
branches/3.2.x/Providers/SDF/Src/Provider/SdfFilterCapabilities.cpp
branches/3.2.x/Providers/SDF/Src/Provider/SdfQueryOptimizer.cpp
branches/3.2.x/Providers/SDF/Src/UnitTest/MasterTest.cpp
branches/3.2.x/Providers/SDF/Src/UnitTest/MasterTest.h
Log:
Fixed 2 SDF issues:
1) An Rtree rebalancing issue where the root node get deleted and the new root node is not persisted.
2) Fixed the SDF filter capability to advertise that it supports the spatial inside operator. The SDF provider inherit this operator from the fdo common library but it does not publish that through its capability.
Modified: branches/3.2.x/Providers/SDF/Src/Provider/RTree.cpp
===================================================================
--- branches/3.2.x/Providers/SDF/Src/Provider/RTree.cpp 2007-01-29 17:47:32 UTC (rev 197)
+++ branches/3.2.x/Providers/SDF/Src/Provider/RTree.cpp 2007-01-31 21:45:22 UTC (rev 198)
@@ -852,8 +852,28 @@
DeleteNode(*rootRecno);
//set new root
- *rootNode = tmpNode;
- *rootRecno = tmpRecno;
+ if( *rootRecno == m_rootRecno )
+ {
+ // a special handling is required if we delete the root record.
+ m_rootNode = *rootNode = tmpNode;
+ m_rootRecno = *rootRecno = tmpRecno;
+ // The old root node record is deleted, we need save the new root node record in the boot
+ // record
+ REC_NO bootRecno = 1;
+ SQLiteData keyboot(&bootRecno, sizeof(REC_NO));
+ SQLiteData databoot(&m_rootRecno, sizeof(REC_NO));
+
+ if (m_db->put(0, &keyboot, &databoot, 0) != 0)
+ throw FdoException::Create(NlsMsgGetMain(FDO_NLSID(SDFPROVIDER_19_SPATIAL_INDEX_ERROR)));
+
+ m_oldRootRecno = m_rootRecno;
+
+ }
+ else
+ {
+ *rootNode = tmpNode;
+ *rootRecno = tmpRecno;
+ }
}
return 0;
}
Modified: branches/3.2.x/Providers/SDF/Src/Provider/SdfFilterCapabilities.cpp
===================================================================
--- branches/3.2.x/Providers/SDF/Src/Provider/SdfFilterCapabilities.cpp 2007-01-29 17:47:32 UTC (rev 197)
+++ branches/3.2.x/Providers/SDF/Src/Provider/SdfFilterCapabilities.cpp 2007-01-31 21:45:22 UTC (rev 198)
@@ -87,7 +87,7 @@
// FdoSpatialOperations_Touches,
FdoSpatialOperations_Within,
// FdoSpatialOperations_CoveredBy
-// FdoSpatialOperations_Inside
+ FdoSpatialOperations_Inside,
FdoSpatialOperations_EnvelopeIntersects
};
Modified: branches/3.2.x/Providers/SDF/Src/Provider/SdfQueryOptimizer.cpp
===================================================================
--- branches/3.2.x/Providers/SDF/Src/Provider/SdfQueryOptimizer.cpp 2007-01-29 17:47:32 UTC (rev 197)
+++ branches/3.2.x/Providers/SDF/Src/Provider/SdfQueryOptimizer.cpp 2007-01-31 21:45:22 UTC (rev 198)
@@ -485,11 +485,6 @@
break;
}
}
- else if ( filter.GetOperation() == FdoSpatialOperations_Inside )
- {
- // The capability says so and can't change the capability yet! It's actually supported by the common code
- throw FdoCommandException::Create(NlsMsgGetMain(FDO_NLSID(SDFPROVIDER_98_SPATIAL_OP_NOTSUPPORTED)));
- }
else
{
//pushing NULL on return stack means no features are spatially excluded for this
Modified: branches/3.2.x/Providers/SDF/Src/UnitTest/MasterTest.cpp
===================================================================
--- branches/3.2.x/Providers/SDF/Src/UnitTest/MasterTest.cpp 2007-01-29 17:47:32 UTC (rev 197)
+++ branches/3.2.x/Providers/SDF/Src/UnitTest/MasterTest.cpp 2007-01-31 21:45:22 UTC (rev 198)
@@ -585,7 +585,44 @@
conn->Close();
}
+void MasterTest::spatialInsideFilter()
+{
+ FdoPtr<FdoIConnection> conn = CreateConnection();
+ openConnection(conn, SHP_PATH);
+
+ FdoPtr<FdoISelect> select = (FdoISelect*)conn->CreateCommand(FdoCommandType_Select);
+
+ select->SetFeatureClassName(L"World_Countries");
+
+
+ FdoPtr<FdoFgfGeometryFactory> gf = FdoFgfGeometryFactory::GetInstance();
+ //
+ double coords[] = { -18.6448,49.1377,
+ 35.8678, 49.1377,
+ 35.8678,11.7581,
+ -18.6448, 11.7581,
+ -18.6448,49.1377 }; //last pt equals first for rings
+
+ FdoPtr<FdoILinearRing> outer = gf->CreateLinearRing(0, 10, coords);
+ FdoPtr<FdoIPolygon> poly = gf->CreatePolygon(outer, NULL);
+
+
+ FdoPtr<FdoByteArray> polyfgf = gf->GetFgf(poly);
+ FdoPtr<FdoGeometryValue> gv = FdoGeometryValue::Create(polyfgf);
+ FdoPtr<FdoSpatialCondition> filter = FdoSpatialCondition::Create(L"SHPGEOM", FdoSpatialOperations_Inside, gv);
+ select->SetFilter(filter);
+ FdoPtr<FdoIFeatureReader> rdr = select->Execute();
+ int count2 = 0;
+ while (rdr->ReadNext())
+ count2++;
+
+ rdr->Close();
+ conn->Close();
+
+ CPPUNIT_ASSERT(count2 == 53);
+}
+
void MasterTest::coordSysTest()
{
FdoPtr<FdoIConnection> conn = CreateConnection();
Modified: branches/3.2.x/Providers/SDF/Src/UnitTest/MasterTest.h
===================================================================
--- branches/3.2.x/Providers/SDF/Src/UnitTest/MasterTest.h 2007-01-29 17:47:32 UTC (rev 197)
+++ branches/3.2.x/Providers/SDF/Src/UnitTest/MasterTest.h 2007-01-31 21:45:22 UTC (rev 198)
@@ -80,6 +80,7 @@
CPPUNIT_TEST_SUITE(MasterTest);
CPPUNIT_TEST(rtreeFilter);
CPPUNIT_TEST(spatialFilter);
+ CPPUNIT_TEST(spatialInsideFilter);
CPPUNIT_TEST(stringFilter);
CPPUNIT_TEST(computedPropTest);
CPPUNIT_TEST(keyFilterBeforeDelete);
@@ -118,6 +119,7 @@
void stringFilter();
void rtreeFilter();
void spatialFilter();
+ void spatialInsideFilter();
void coordSysTest();
void computedPropTest();
void selectDistinctTests();
More information about the fdo-commits
mailing list