[fdo-commits] r217 - branches/3.2.x/Providers/SHP/Src/Provider

svn_fdo at osgeo.org svn_fdo at osgeo.org
Fri Mar 16 15:15:11 EDT 2007


Author: danstoica
Date: 2007-03-16 15:15:11 -0400 (Fri, 16 Mar 2007)
New Revision: 217

Modified:
   branches/3.2.x/Providers/SHP/Src/Provider/ShpFeatIdQueryEvaluator.cpp
   branches/3.2.x/Providers/SHP/Src/Provider/ShpFeatIdQueryEvaluator.h
Log:
Fixed secondary filtering in the presence of Multipolygons 

Modified: branches/3.2.x/Providers/SHP/Src/Provider/ShpFeatIdQueryEvaluator.cpp
===================================================================
--- branches/3.2.x/Providers/SHP/Src/Provider/ShpFeatIdQueryEvaluator.cpp	2007-03-15 13:18:45 UTC (rev 216)
+++ branches/3.2.x/Providers/SHP/Src/Provider/ShpFeatIdQueryEvaluator.cpp	2007-03-16 19:15:11 UTC (rev 217)
@@ -275,7 +275,11 @@
         FdoPtr<FdoIGeometry>  geomLeft = gf->CreateGeometryFromFgf( geomLeftFgf );
         delete shape;
 
-        bool  ret = FdoSpatialUtility::Evaluate( geomLeft, spatialOp, filterGeom);
+		// The Polygon might be a multi polygon. 
+		FdoPtr<FdoIGeometry> geometry = ReconstructPolygon( geomLeft );
+
+		bool  ret = FdoSpatialUtility::Evaluate( geometry? geometry : geomLeft, spatialOp, filterGeom);
+
         if ( ret )
             secFilterList->push_back( featNum );
     }
@@ -425,7 +429,10 @@
                 FdoPtr<FdoIGeometry>  geomLeft = gf->CreateGeometryFromFgf( geomLeftFgf );
                 delete shape;
 
-                bool  ret = FdoSpatialUtility::Evaluate( geomLeft, spatialOp, geomRight);
+				// The Polygon might be actually a multi polygon. 
+				FdoPtr<FdoIGeometry> geometry = ReconstructPolygon( geomLeft );
+
+				bool  ret = FdoSpatialUtility::Evaluate( geometry? geometry : geomLeft, spatialOp, geomRight);
                 if ( ret )
                     secFilterList->push_back( featNum );
             }
@@ -897,7 +904,28 @@
     return aproxListSize;
 }
 
+// Returns NULL in case geometry was not reconstructed
+FdoIGeometry *ShpFeatIdQueryEvaluator::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);
+}
+
 void ShpFeatIdQueryEvaluator::PrintFlattenParseTree()
 {
     for (retno_lists::iterator iter_comp_op = m_FeatidLists.begin(); iter_comp_op != m_FeatidLists.end(); iter_comp_op++ )

Modified: branches/3.2.x/Providers/SHP/Src/Provider/ShpFeatIdQueryEvaluator.h
===================================================================
--- branches/3.2.x/Providers/SHP/Src/Provider/ShpFeatIdQueryEvaluator.h	2007-03-15 13:18:45 UTC (rev 216)
+++ branches/3.2.x/Providers/SHP/Src/Provider/ShpFeatIdQueryEvaluator.h	2007-03-16 19:15:11 UTC (rev 217)
@@ -92,6 +92,7 @@
 	void					ProcessLeafExpession( interval_res* curr_filter, int curr_logical_op, int maxRecords );
 	void					PrintFlattenParseTree();
 	void					DoSecondaryFilter(FdoIGeometry *filterGeom, FdoSpatialOperations spatialOp );
+	FdoIGeometry*			ReconstructPolygon( FdoIGeometry *geometry );
 
     FdoGeometricPropertyDefinition* FindGeomProp(FdoClassDefinition* classDef);
 



More information about the fdo-commits mailing list