[mapguide-commits] r4307 - in trunk/MgDev: Common/PlatformBase/Services Server/src/UnitTesting

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Mon Oct 19 13:40:27 EDT 2009


Author: brucedechant
Date: 2009-10-19 13:40:26 -0400 (Mon, 19 Oct 2009)
New Revision: 4307

Modified:
   trunk/MgDev/Common/PlatformBase/Services/SpatialContextReader.cpp
   trunk/MgDev/Server/src/UnitTesting/TestFeatureService.cpp
Log:
Fix for trac ticket 1107 - Spatial context reader not being closed
http://trac.osgeo.org/mapguide/ticket/1107

Notes:
- Change Close() method to not clear the internal collection
- Update existing TestCase_GetSpatialContexts unit test


Modified: trunk/MgDev/Common/PlatformBase/Services/SpatialContextReader.cpp
===================================================================
--- trunk/MgDev/Common/PlatformBase/Services/SpatialContextReader.cpp	2009-10-17 08:48:57 UTC (rev 4306)
+++ trunk/MgDev/Common/PlatformBase/Services/SpatialContextReader.cpp	2009-10-19 17:40:26 UTC (rev 4307)
@@ -171,7 +171,6 @@
 /// </summary>
 void MgSpatialContextReader::Close()
 {
-    m_spatialContextCol.Clear();
 }
 
 //////////////////////////////////////////////////////////////
@@ -189,7 +188,7 @@
 //////////////////////////////////////////////////////////////
 MgSpatialContextReader::~MgSpatialContextReader()
 {
-    this->Close();
+    m_spatialContextCol.Clear();
 }
 
 //////////////////////////////////////////////////////////////

Modified: trunk/MgDev/Server/src/UnitTesting/TestFeatureService.cpp
===================================================================
--- trunk/MgDev/Server/src/UnitTesting/TestFeatureService.cpp	2009-10-17 08:48:57 UTC (rev 4306)
+++ trunk/MgDev/Server/src/UnitTesting/TestFeatureService.cpp	2009-10-19 17:40:26 UTC (rev 4307)
@@ -1288,9 +1288,43 @@
         CPPUNIT_ASSERT_THROW_MG(pService->GetSpatialContexts(resource, activeOnly), MgInvalidResourceTypeException*);
 
         resource = new MgResourceIdentifier(L"Library://UnitTests/Data/Sheboygan_Parcels.FeatureSource");
+
+        // Get a valid spatial context reader
         Ptr<MgSpatialContextReader> reader = pService->GetSpatialContexts(resource, activeOnly);
+
+        // Advance to the 1st spatial context
         bool bResult = reader->ReadNext();
         CPPUNIT_ASSERT(bResult);
+
+        // Get the CS name and CS WKT
+        STRING csName = reader->GetName();
+        STRING csWkt = reader->GetCoordinateSystemWkt();
+        ACE_DEBUG((LM_DEBUG, ACE_TEXT("TestFeatureService::TestCase_GetSpatialContexts()\nName: %W\nWKT: %W\n"), csName.c_str(), csWkt.c_str()));
+
+        CPPUNIT_ASSERT(wcscmp(csName.c_str(), L"WGS84 Lat/Long's, Degre") == 0);
+        CPPUNIT_ASSERT(wcscmp(csWkt.c_str(), L"GEOGCS[\"WGS84 Lat/Long's, Degrees, -180 ==> +180\",DATUM[\"D_WGS_1984\",SPHEROID[\"World_Geodetic_System_of_1984\",6378137,298.257222932867]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.017453292519943295]]") == 0);
+
+        // Close the reader
+        reader->Close();
+
+        // Force the reader to be cleaned up for the next operation
+        reader = NULL;
+
+        // Get a valid spatial context reader, this reader will be coming from the cache
+        reader = pService->GetSpatialContexts(resource, activeOnly);
+
+        // Advance to the 1st spatial context
+        bResult = reader->ReadNext();
+        CPPUNIT_ASSERT(bResult);
+
+        // Get the CS name and CS WKT
+        csName = reader->GetName();
+        csWkt = reader->GetCoordinateSystemWkt();
+        CPPUNIT_ASSERT(wcscmp(csName.c_str(), L"WGS84 Lat/Long's, Degre") == 0);
+        CPPUNIT_ASSERT(wcscmp(csWkt.c_str(), L"GEOGCS[\"WGS84 Lat/Long's, Degrees, -180 ==> +180\",DATUM[\"D_WGS_1984\",SPHEROID[\"World_Geodetic_System_of_1984\",6378137,298.257222932867]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.017453292519943295]]") == 0);
+
+        // Close the reader
+        reader->Close();
     }
     catch(MgException* e)
     {



More information about the mapguide-commits mailing list