[fdo-commits] r2570 - in trunk/Providers/SDF/Src: Provider UnitTest
Utils
svn_fdo at osgeo.org
svn_fdo at osgeo.org
Tue Feb 20 17:12:32 EST 2007
Author: badreddinekaroui
Date: 2007-02-20 17:12:31 -0500 (Tue, 20 Feb 2007)
New Revision: 2570
Modified:
trunk/Providers/SDF/Src/Provider/RTree.cpp
trunk/Providers/SDF/Src/Provider/SdfDelete.cpp
trunk/Providers/SDF/Src/Provider/SdfFilterCapabilities.cpp
trunk/Providers/SDF/Src/Provider/SdfQueryOptimizer.cpp
trunk/Providers/SDF/Src/Provider/SdfQueryOptimizer.h
trunk/Providers/SDF/Src/Provider/SdfSelect.cpp
trunk/Providers/SDF/Src/Provider/SdfUpdate.cpp
trunk/Providers/SDF/Src/UnitTest/MasterTest.cpp
trunk/Providers/SDF/Src/UnitTest/MasterTest.h
trunk/Providers/SDF/Src/Utils/FilterExecutor.h
Log:
Trac #13: Merging defect fixes from branch 3.2.x to the trunk
merging the fix for the filter properties and spatial operators validations and
the Rtree rebalancing issue where the root node get deleted and the new root node is not persisted.
Modified: trunk/Providers/SDF/Src/Provider/RTree.cpp
===================================================================
--- trunk/Providers/SDF/Src/Provider/RTree.cpp 2007-02-20 22:08:51 UTC (rev 2569)
+++ trunk/Providers/SDF/Src/Provider/RTree.cpp 2007-02-20 22:12:31 UTC (rev 2570)
@@ -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: trunk/Providers/SDF/Src/Provider/SdfDelete.cpp
===================================================================
--- trunk/Providers/SDF/Src/Provider/SdfDelete.cpp 2007-02-20 22:08:51 UTC (rev 2569)
+++ trunk/Providers/SDF/Src/Provider/SdfDelete.cpp 2007-02-20 22:12:31 UTC (rev 2570)
@@ -23,8 +23,8 @@
#include "SdfDeletingFeatureReader.h"
#include "DataDb.h"
#include "PropertyIndex.h"
+#include "FdoCommonFilterExecutor.h"
-
//-------------------------------------------------------
// Constructor / destructor
//-------------------------------------------------------
@@ -73,8 +73,12 @@
m_connection->GetSchema()->GetClasses())->FindItem(m_className->GetName());
if( clas == NULL )
throw FdoException::Create(NlsMsgGetMain(FDO_NLSID(SDFPROVIDER_75_CLASS_NOTFOUND), m_className->GetName()));
+
if( m_filter != NULL )
- SdfQueryOptimizer::ValidateFilter( clas, m_filter );
+ {
+ FdoPtr<FdoIFilterCapabilities> filterCaps = m_connection->GetFilterCapabilities();
+ FdoCommonFilterExecutor::ValidateFilter( clas, m_filter, NULL, filterCaps );
+ }
m_connection->FlushAll( clas, true );
Modified: trunk/Providers/SDF/Src/Provider/SdfFilterCapabilities.cpp
===================================================================
--- trunk/Providers/SDF/Src/Provider/SdfFilterCapabilities.cpp 2007-02-20 22:08:51 UTC (rev 2569)
+++ trunk/Providers/SDF/Src/Provider/SdfFilterCapabilities.cpp 2007-02-20 22:12:31 UTC (rev 2570)
@@ -87,7 +87,7 @@
// FdoSpatialOperations_Touches,
FdoSpatialOperations_Within,
// FdoSpatialOperations_CoveredBy
-// FdoSpatialOperations_Inside
+ FdoSpatialOperations_Inside,
FdoSpatialOperations_EnvelopeIntersects
};
Modified: trunk/Providers/SDF/Src/Provider/SdfQueryOptimizer.cpp
===================================================================
--- trunk/Providers/SDF/Src/Provider/SdfQueryOptimizer.cpp 2007-02-20 22:08:51 UTC (rev 2569)
+++ trunk/Providers/SDF/Src/Provider/SdfQueryOptimizer.cpp 2007-02-20 22:12:31 UTC (rev 2570)
@@ -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
@@ -839,145 +834,3 @@
return false;
}
-
-
-void SdfQueryOptimizer::ValidateFilter( FdoClassDefinition *cls, FdoFilter *filter )
-{
- class SdfFilterValidator : public virtual FdoIExpressionProcessor, public virtual FdoIFilterProcessor
- {
- private:
- FdoClassDefinition* m_class;
-
- protected:
-
- void HandleExpr( FdoExpression *exp )
- {
- exp->Process( this );
- }
- void HandleFilter( FdoFilter *filter )
- {
- filter->Process( this );
- }
- public:
-
- SdfFilterValidator( FdoClassDefinition *cls )
- {
- m_class = cls;
- }
-
- virtual void Dispose() { delete this; }
-
- /// <summary>Increase the reference count.</summary>
- /// <returns>Returns the new reference count (value for debugging use only).</returns>
- FdoInt32 AddRef()
- {
- // NOTE: due to multiple inheritance, there is an ambiguity in which AddRef() method to call.
- // Calling BOTH AddRef() methods leads to instances of this class being prematurely released.
- return FdoIFilterProcessor::AddRef();
- }
-
- /// <summary>Decrease the reference count.</summary>
- /// <returns>Returns the new reference count (value for debugging use only).</returns>
- FdoInt32 Release ()
- {
- // NOTE: due to multiple inheritance, there is an ambiguity in which Release() method to call.
- // Calling BOTH Release() methods leads to instances of this class being prematurely released.
- return FdoIFilterProcessor::Release();
- }
-
- virtual void ProcessBinaryExpression(FdoBinaryExpression& expr)
- {
- HandleExpr( FdoPtr<FdoExpression>(expr.GetLeftExpression()) );
- HandleExpr( FdoPtr<FdoExpression>(expr.GetRightExpression()) );
- }
- virtual void ProcessBooleanValue(FdoBooleanValue& expr) { }
- virtual void ProcessByteValue(FdoByteValue& expr){ }
- virtual void ProcessDateTimeValue(FdoDateTimeValue& expr){ }
- virtual void ProcessDoubleValue(FdoDoubleValue& expr){ }
- virtual void ProcessDecimalValue(FdoDecimalValue& expr){ }
- virtual void ProcessInt16Value(FdoInt16Value& expr){ }
- virtual void ProcessInt32Value(FdoInt32Value& expr){ }
- virtual void ProcessInt64Value(FdoInt64Value& expr){ }
- virtual void ProcessSingleValue(FdoSingleValue& expr){ }
- virtual void ProcessStringValue(FdoStringValue& expr){ }
- virtual void ProcessBLOBValue(FdoBLOBValue& expr){ }
- virtual void ProcessCLOBValue(FdoCLOBValue& expr){ }
- virtual void ProcessFunction(FdoFunction& expr)
- {
- FdoPtr<FdoExpressionCollection>col = expr.GetArguments();
- for(int i=0; i<col->GetCount(); i++)
- HandleExpr( FdoPtr<FdoExpression>(col->GetItem( i ) ) );
- }
- virtual void ProcessGeometryValue(FdoGeometryValue& expr){ }
- virtual void ProcessParameter(FdoParameter& expr){ }
- virtual void ProcessUnaryExpression(FdoUnaryExpression& expr)
- {
- HandleExpr( FdoPtr<FdoExpression>(expr.GetExpression()) );
- }
- virtual void ProcessBinaryLogicalOperator(FdoBinaryLogicalOperator& filter)
- {
- HandleFilter( FdoPtr<FdoFilter>(filter.GetLeftOperand()) );
- HandleFilter( FdoPtr<FdoFilter>(filter.GetRightOperand()) );
- }
- virtual void ProcessComparisonCondition(FdoComparisonCondition& filter)
- {
- HandleExpr( FdoPtr<FdoExpression>(filter.GetLeftExpression()) );
- HandleExpr( FdoPtr<FdoExpression>(filter.GetRightExpression()) );
- }
- virtual void ProcessDistanceCondition(FdoDistanceCondition& filter){ }
-
- virtual void ProcessInCondition(FdoInCondition& filter)
- {
- ProcessIdentifier( *(FdoPtr<FdoIdentifier>(filter.GetPropertyName())) );
- }
- virtual void ProcessNullCondition(FdoNullCondition& filter)
- {
- ProcessIdentifier( *(FdoPtr<FdoIdentifier>(filter.GetPropertyName())) );
- }
- virtual void ProcessSpatialCondition(FdoSpatialCondition& filter){ }
-
- virtual void ProcessUnaryLogicalOperator(FdoUnaryLogicalOperator& filter)
- {
- HandleFilter( FdoPtr<FdoFilter>(filter.GetOperand()) );
- }
-
- virtual void ProcessIdentifier(FdoIdentifier& expr)
- {
- // This is used to validate the property names referenced in the filter.
- FdoPtr<FdoPropertyDefinitionCollection>props = m_class->GetProperties();
- FdoPtr<FdoReadOnlyPropertyDefinitionCollection>basePops = m_class->GetBaseProperties();
- FdoPtr<FdoPropertyDefinition> prop;
-
- int length;
- // If any of the identifiers is a decorated name of the form <obj proper>.<property>, then this is
- // an association or object proeperty; assume it exist for now.
- if( expr.GetScope( length ) && length > 0 )
- return;
-
- prop = props->FindItem( expr.GetName() );
- if( prop != NULL )
- return;
-
- try
- {
- prop = basePops->GetItem( expr.GetName() );
- if( prop != NULL )
- return;
- }
- catch(FdoException *exp )
- {
- exp->Release();
- }
-
- throw FdoException::Create(NlsMsgGetMain(FDO_NLSID(SDFPROVIDER_97_PROPERTY_NOTFOUND), expr.GetName(), m_class->GetName() ));
- }
-
- virtual void ProcessComputedIdentifier(FdoComputedIdentifier& expr)
- {
- HandleExpr( FdoPtr<FdoExpression>(expr.GetExpression()) );
- }
- };
-
- SdfFilterValidator validator(cls);
- filter->Process( &validator );
-}
Modified: trunk/Providers/SDF/Src/Provider/SdfQueryOptimizer.h
===================================================================
--- trunk/Providers/SDF/Src/Provider/SdfQueryOptimizer.h 2007-02-20 22:08:51 UTC (rev 2569)
+++ trunk/Providers/SDF/Src/Provider/SdfQueryOptimizer.h 2007-02-20 22:12:31 UTC (rev 2570)
@@ -117,8 +117,6 @@
SDF_API virtual void ProcessGeometryValue(FdoGeometryValue& expr);
- static void ValidateFilter( FdoClassDefinition *cls, FdoFilter *filter );
-
public:
//-----------------------------------------------------------------
Modified: trunk/Providers/SDF/Src/Provider/SdfSelect.cpp
===================================================================
--- trunk/Providers/SDF/Src/Provider/SdfSelect.cpp 2007-02-20 22:08:51 UTC (rev 2569)
+++ trunk/Providers/SDF/Src/Provider/SdfSelect.cpp 2007-02-20 22:12:31 UTC (rev 2570)
@@ -21,7 +21,7 @@
#include "SdfQueryOptimizer.h"
#include "SdfSimpleFeatureReader.h"
#include "FilterExecutor.h"
-
+#include "FdoCommonFilterExecutor.h"
//-------------------------------------------------------
// Constructor / destructor
//-------------------------------------------------------
@@ -117,8 +117,12 @@
throw FdoException::Create(NlsMsgGetMain(FDO_NLSID(SDFPROVIDER_75_CLASS_NOTFOUND), m_className->GetName()));
if( m_filter != NULL )
- SdfQueryOptimizer::ValidateFilter( clas, m_filter );
+ {
+ FdoPtr<FdoIFilterCapabilities> filterCaps = m_connection->GetFilterCapabilities();
+ FdoCommonFilterExecutor::ValidateFilter( clas, m_filter, m_properties, filterCaps );
+ }
+
//get the R-Tree for this feature class...
SdfRTree* rt = m_connection->GetRTree(clas);
recno_list* features = NULL;
Modified: trunk/Providers/SDF/Src/Provider/SdfUpdate.cpp
===================================================================
--- trunk/Providers/SDF/Src/Provider/SdfUpdate.cpp 2007-02-20 22:08:51 UTC (rev 2569)
+++ trunk/Providers/SDF/Src/Provider/SdfUpdate.cpp 2007-02-20 22:12:31 UTC (rev 2570)
@@ -21,8 +21,8 @@
#include "SdfUpdatingFeatureReader.h"
#include "SdfQueryOptimizer.h"
#include "DataDb.h"
+#include "FdoCommonFilterExecutor.h"
-
//-------------------------------------------------------
// Constructor / destructor
//-------------------------------------------------------
@@ -85,8 +85,10 @@
throw FdoException::Create(NlsMsgGetMain(FDO_NLSID(SDFPROVIDER_75_CLASS_NOTFOUND), m_className->GetName()));
if( m_filter != NULL )
- SdfQueryOptimizer::ValidateFilter( clas, m_filter );
-
+ {
+ FdoPtr<FdoIFilterCapabilities> filterCaps = m_connection->GetFilterCapabilities();
+ FdoCommonFilterExecutor::ValidateFilter( clas, m_filter, NULL, filterCaps );
+ }
m_connection->FlushAll( clas, true );
Modified: trunk/Providers/SDF/Src/UnitTest/MasterTest.cpp
===================================================================
--- trunk/Providers/SDF/Src/UnitTest/MasterTest.cpp 2007-02-20 22:08:51 UTC (rev 2569)
+++ trunk/Providers/SDF/Src/UnitTest/MasterTest.cpp 2007-02-20 22:12:31 UTC (rev 2570)
@@ -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: trunk/Providers/SDF/Src/UnitTest/MasterTest.h
===================================================================
--- trunk/Providers/SDF/Src/UnitTest/MasterTest.h 2007-02-20 22:08:51 UTC (rev 2569)
+++ trunk/Providers/SDF/Src/UnitTest/MasterTest.h 2007-02-20 22:12:31 UTC (rev 2570)
@@ -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();
Modified: trunk/Providers/SDF/Src/Utils/FilterExecutor.h
===================================================================
--- trunk/Providers/SDF/Src/Utils/FilterExecutor.h 2007-02-20 22:08:51 UTC (rev 2569)
+++ trunk/Providers/SDF/Src/Utils/FilterExecutor.h 2007-02-20 22:12:31 UTC (rev 2570)
@@ -20,7 +20,7 @@
#include "DataValue.h"
#include "DataValueStack.h"
-typedef DataValueStack<DataValue> retval_stack;
+typedef DataValueStack<DataValue> sdf_retval_stack;
//forward declare
class DataValuePool;
@@ -130,7 +130,7 @@
protected:
//execution stack
- retval_stack m_retvals;
+ sdf_retval_stack m_retvals;
//feature reader
FdoIFeatureReader* m_reader;
More information about the fdo-commits
mailing list