[fdo-commits] r2689 - trunk/Providers/SHP/Src/Provider

svn_fdo at osgeo.org svn_fdo at osgeo.org
Fri Mar 16 16:33:09 EDT 2007


Author: danstoica
Date: 2007-03-16 16:33:09 -0400 (Fri, 16 Mar 2007)
New Revision: 2689

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

Modified: trunk/Providers/SHP/Src/Provider/ShpFeatIdQueryEvaluator.cpp
===================================================================
--- trunk/Providers/SHP/Src/Provider/ShpFeatIdQueryEvaluator.cpp	2007-03-16 20:30:29 UTC (rev 2688)
+++ trunk/Providers/SHP/Src/Provider/ShpFeatIdQueryEvaluator.cpp	2007-03-16 20:33:09 UTC (rev 2689)
@@ -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 );
     }
@@ -360,10 +364,11 @@
         results->searchArea.yMax = searchArea.yMax + xyRes;
 
         bool            done = false;
+        BoundingBoxEx   extents;
+
         do
         {
             unsigned long   offset;
-            BoundingBoxEx     extents;
 
             int nStatus = m_RTree->GetNextObject (offset, extents);
             switch (nStatus)
@@ -424,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 );
             }
@@ -471,9 +479,12 @@
     if (right == NULL)
         return right;
 
-    std::sort(left->begin(), left->end(), std::less<FdoInt32>());
-    std::sort(right->begin(), right->end(), std::less<FdoInt32>());
+	if ( left->size() > 0 )
+		std::sort(left->begin(), left->end(), std::less<FdoInt32>());
 
+	if ( right->size() > 0 )
+		std::sort(right->begin(), right->end(), std::less<FdoInt32>());
+
     recno_list::iterator iter1 = left->begin();
     recno_list::iterator iter2 = right->begin();
 
@@ -893,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: trunk/Providers/SHP/Src/Provider/ShpFeatIdQueryEvaluator.h
===================================================================
--- trunk/Providers/SHP/Src/Provider/ShpFeatIdQueryEvaluator.h	2007-03-16 20:30:29 UTC (rev 2688)
+++ trunk/Providers/SHP/Src/Provider/ShpFeatIdQueryEvaluator.h	2007-03-16 20:33:09 UTC (rev 2689)
@@ -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