[fdo-commits] r2688 - trunk/Providers/SDF/Src/Utils

svn_fdo at osgeo.org svn_fdo at osgeo.org
Fri Mar 16 16:30:29 EDT 2007


Author: danstoica
Date: 2007-03-16 16:30:29 -0400 (Fri, 16 Mar 2007)
New Revision: 2688

Modified:
   trunk/Providers/SDF/Src/Utils/FilterExecutor.cpp
   trunk/Providers/SDF/Src/Utils/FilterExecutor.h
Log:
Ticket #43: SHP, SDF: wrong results when quering multi polygons

Modified: trunk/Providers/SDF/Src/Utils/FilterExecutor.cpp
===================================================================
--- trunk/Providers/SDF/Src/Utils/FilterExecutor.cpp	2007-03-14 16:24:38 UTC (rev 2687)
+++ trunk/Providers/SDF/Src/Utils/FilterExecutor.cpp	2007-03-16 20:30:29 UTC (rev 2688)
@@ -333,8 +333,11 @@
     FdoPtr<FdoIGeometry> geomRight = gf->CreateGeometryFromFgf(baRight);
     FdoPtr<FdoIGeometry> geomLeft = gf->CreateGeometryFromFgf(fgf, fgfLen);
 
+	// A polygon might be actually a multi polygon. 
+	FdoPtr<FdoIGeometry> geometry = ReconstructPolygon( geomLeft );
+
     //call on the geometry utility to evaluate the spatial operation
-    bool ret = FdoSpatialUtility::Evaluate(geomLeft, filter.GetOperation(), geomRight);
+    bool ret = FdoSpatialUtility::Evaluate( geometry? geometry : geomLeft, filter.GetOperation(), geomRight);
     
     m_retvals.push(m_pPool->ObtainBooleanValue(ret));            
 }
@@ -997,5 +1000,26 @@
     m_retvals.push(m_pPool->ObtainInt64Value(color));
 }
 
+// Returns NULL in case geometry was not reconstructed
+FdoIGeometry *FilterExecutor::ReconstructPolygon( FdoIGeometry *geometry )
+{
+	FdoPtr<FdoIGeometry> newGeometry;
 
+	if ( geometry->GetDerivedType() == FdoGeometryType_Polygon )
+	{
+		FdoIPolygon * poly = (FdoIPolygon *)geometry;
+		if ( poly->GetInteriorRingCount() != 0 )
+		{
+			FdoPtr<FdoLinearRingCollection> rings = FdoLinearRingCollection::Create ();
+			for (int i = 0; i < poly->GetInteriorRingCount(); i++)
+			{
+				FdoPtr<FdoILinearRing>	ring = poly->GetInteriorRing(i);
+				rings->Add(ring);
+			}
+			newGeometry = FdoSpatialUtility::CreateGeometryFromRings (rings, true);
+		}
+	}
+	return FDO_SAFE_ADDREF(newGeometry.p);
+}
 
+

Modified: trunk/Providers/SDF/Src/Utils/FilterExecutor.h
===================================================================
--- trunk/Providers/SDF/Src/Utils/FilterExecutor.h	2007-03-14 16:24:38 UTC (rev 2687)
+++ trunk/Providers/SDF/Src/Utils/FilterExecutor.h	2007-03-16 20:30:29 UTC (rev 2688)
@@ -154,6 +154,9 @@
 	void ProcessFunctionCeilFloor( FdoString *name, DataValue* argLeft );
 
     void ExecuteARGB(FdoFunction& function);
+
+	FdoIGeometry* ReconstructPolygon( FdoIGeometry *geometry );
+
     
     //pattern matching
     bool MatchesHere(wchar_t* pattern, wchar_t* src);



More information about the fdo-commits mailing list