[mapguide-commits] r6832 - in trunk/MgDev: . Common/MapGuideCommon/Resources Common/Stylization Desktop Server/src/Common/Manager Server/src/Services/Feature Server/src/Services/Mapping Web/src/mapadmin/HelpDocs Web/src/mapviewerphp Web/src/schemareport Web/src/viewerfiles

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Mon Jul 2 07:54:35 PDT 2012


Author: jng
Date: 2012-07-02 07:54:35 -0700 (Mon, 02 Jul 2012)
New Revision: 6832

Modified:
   trunk/MgDev/
   trunk/MgDev/Common/MapGuideCommon/Resources/mapguide_en.res
   trunk/MgDev/Common/Stylization/SE_Renderer.cpp
   trunk/MgDev/Desktop/
   trunk/MgDev/Server/src/Common/Manager/FdoConnectionManager.cpp
   trunk/MgDev/Server/src/Services/Feature/FeatureGeometricFunctions.cpp
   trunk/MgDev/Server/src/Services/Feature/ServerFeatureServiceExceptionDef.h
   trunk/MgDev/Server/src/Services/Feature/ServerFeatureUtil.cpp
   trunk/MgDev/Server/src/Services/Feature/ServerSelectFeatures.cpp
   trunk/MgDev/Server/src/Services/Mapping/MappingUtil.cpp
   trunk/MgDev/Web/src/mapadmin/HelpDocs/
   trunk/MgDev/Web/src/mapadmin/HelpDocs/configuring_servers.htm
   trunk/MgDev/Web/src/mapviewerphp/quickplotgeneratepicture.php
   trunk/MgDev/Web/src/schemareport/displayschemafunctions.php
   trunk/MgDev/Web/src/schemareport/showclass.php
   trunk/MgDev/Web/src/schemareport/showgeom.php
   trunk/MgDev/Web/src/viewerfiles/
   trunk/MgDev/Web/src/viewerfiles/quickplot.js
   trunk/MgDev/setenvironment.bat
Log:
Merge in r6796, r6797, r6798, r6799 and r6801 from 2.4 branch


Property changes on: trunk/MgDev
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/2.4/MgDev:6749-6756,6777-6783,6785-6787,6789,6791-6794
/sandbox/rfc94:5099-5163
   + /branches/2.4/MgDev:6749-6756,6777-6783,6785-6787,6789,6791-6794,6796-6801
/sandbox/rfc94:5099-5163

Modified: trunk/MgDev/Common/MapGuideCommon/Resources/mapguide_en.res
===================================================================
--- trunk/MgDev/Common/MapGuideCommon/Resources/mapguide_en.res	2012-07-02 13:20:49 UTC (rev 6831)
+++ trunk/MgDev/Common/MapGuideCommon/Resources/mapguide_en.res	2012-07-02 14:54:35 UTC (rev 6832)
@@ -230,11 +230,12 @@
 MgFailedToLoadFdoLibrary                              = Failed to load FDO library.
 MgFailedToRetrieveSystemExceptionMesage               = Failed to retrieve the system exception mesage. This message may not be unicode compliant.
 MgFailedToRetrieveThirdPartyExceptionMesage           = Failed to retrieve the third party exception mesage. This message may not be unicode compliant.
-MgFeatureSourceFormatInnerExceptionMessage            = Error occurred in Feature Source (%1): %2
+MgFeatureSourceFormatInnerExceptionMessage            = Error occurred in Feature Source (%1): %2 (Cause: %3, Root Cause: %4)
 MgFeatureReaderIdNotFound                             = The feature reader ID was not found.
 MgFilenamesIdentical                                  = The filenames cannot be the same.
 MgFormatAllExceptionDetail                            = - %1(%2)
 MgFormatAllExceptionStackTrace                        = - %1(%2) line %3 file %4
+MgFormatFdoExceptionMessage                           = %1 (Cause: %2, Root Cause: %3)
 MgFormatInnerExceptionMessage                         = %1
 MgGeometryEmpty                                       = The geometry cannot be empty.
 MgGeometryPropertyEmpty                               = The geometry property cannot be empty.


Property changes on: trunk/MgDev/Common/Stylization/SE_Renderer.cpp
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/2.4/MgDev/Common/Stylization/SE_Renderer.cpp:6749-6756,6777-6783,6785-6787,6789,6791-6794
/sandbox/adsk/2.4j/Common/Stylization/SE_Renderer.cpp:6327-6445
/sandbox/rfc94/Common/Stylization/SE_Renderer.cpp:5099-5163
/trunk/MgDev/Common/Stylization/SE_Renderer.cpp:6250-6326
   + /branches/2.4/MgDev/Common/Stylization/SE_Renderer.cpp:6749-6756,6777-6783,6785-6787,6789,6791-6794,6796-6801
/sandbox/adsk/2.4j/Common/Stylization/SE_Renderer.cpp:6327-6445
/sandbox/rfc94/Common/Stylization/SE_Renderer.cpp:5099-5163
/trunk/MgDev/Common/Stylization/SE_Renderer.cpp:6250-6326


Property changes on: trunk/MgDev/Desktop
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/2.4/MgDev/Desktop:6612-6613,6615-6616,6749-6756,6777-6783,6785-6787,6789,6791-6794
/sandbox/rfc94/Desktop:5099-5163
   + /branches/2.4/MgDev/Desktop:6612-6613,6615-6616,6749-6756,6777-6783,6785-6787,6789,6791-6794,6796-6801
/sandbox/rfc94/Desktop:5099-5163

Modified: trunk/MgDev/Server/src/Common/Manager/FdoConnectionManager.cpp
===================================================================
--- trunk/MgDev/Server/src/Common/Manager/FdoConnectionManager.cpp	2012-07-02 13:20:49 UTC (rev 6831)
+++ trunk/MgDev/Server/src/Common/Manager/FdoConnectionManager.cpp	2012-07-02 14:54:35 UTC (rev 6832)
@@ -361,6 +361,8 @@
             MgStringCollection args;
             args.Add(resourceIdentifier->ToString());
             args.Add(message);
+            args.Add(L"");
+            args.Add(L"");
 
             //Replace the exception to be thrown with our one
             mgException = new MgFdoException(L"MgFdoConnectionManager.Open", __LINE__, __WFILE__, NULL, L"MgFeatureSourceFormatInnerExceptionMessage", &args);

Modified: trunk/MgDev/Server/src/Services/Feature/FeatureGeometricFunctions.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Feature/FeatureGeometricFunctions.cpp	2012-07-02 13:20:49 UTC (rev 6831)
+++ trunk/MgDev/Server/src/Services/Feature/FeatureGeometricFunctions.cpp	2012-07-02 14:54:35 UTC (rev 6832)
@@ -108,7 +108,16 @@
     while(m_reader->ReadNext())
     {
         // Get the geometry
-        Ptr<MgGeometry> val = GetValue();
+        Ptr<MgGeometry> val;
+        try 
+        {
+            val = GetValue();
+        }
+        catch(MgException* ex) //Don't let a bad geometry derail us, just discard and continue
+        {
+            ex->Release();
+            continue;
+        }
 
         // Get the envelope
         Ptr<MgEnvelope> envl = val->Envelope();

Modified: trunk/MgDev/Server/src/Services/Feature/ServerFeatureServiceExceptionDef.h
===================================================================
--- trunk/MgDev/Server/src/Services/Feature/ServerFeatureServiceExceptionDef.h	2012-07-02 13:20:49 UTC (rev 6831)
+++ trunk/MgDev/Server/src/Services/Feature/ServerFeatureServiceExceptionDef.h	2012-07-02 14:54:35 UTC (rev 6832)
@@ -34,11 +34,22 @@
         MgStringCollection arguments;                                         \
         wchar_t* buf = (wchar_t*)e->GetExceptionMessage();                    \
         INT64 nativeErrorCode = e->GetNativeErrorCode();                      \
+        FdoPtr<FdoException> cause = e->GetCause();                           \
+        FdoPtr<FdoException> root = e->GetRootCause();                        \
                                                                               \
+        wchar_t* causeStr = NULL;                                             \
+        wchar_t* rootCauseStr = NULL;                                         \
+        if (NULL != cause.p)                                                  \
+            causeStr = (wchar_t*)cause->GetExceptionMessage();                \
+        if (NULL != root.p)                                                   \
+            rootCauseStr = (wchar_t*)root->GetExceptionMessage();             \
+                                                                              \
         if (NULL != buf)                                                      \
         {                                                                     \
-            messageId = L"MgFormatInnerExceptionMessage";                     \
+            messageId = L"MgFormatFdoExceptionMessage";                       \
             arguments.Add(buf);                                               \
+            arguments.Add((causeStr == NULL) ? L"" : causeStr);               \
+            arguments.Add((rootCauseStr == NULL) ? L"" : rootCauseStr);       \
         }                                                                     \
                                                                               \
         FDO_SAFE_RELEASE(e);                                                  \
@@ -54,12 +65,23 @@
         MgStringCollection arguments;                                         \
         wchar_t* buf = (wchar_t*)e->GetExceptionMessage();                    \
         INT64 nativeErrorCode = e->GetNativeErrorCode();                      \
+        FdoPtr<FdoException> cause = e->GetCause();                           \
+        FdoPtr<FdoException> root = e->GetRootCause();                        \
                                                                               \
+        wchar_t* causeStr = NULL;                                             \
+        wchar_t* rootCauseStr = NULL;                                         \
+        if (NULL != cause.p)                                                  \
+            causeStr = (wchar_t*)cause->GetExceptionMessage();                \
+        if (NULL != root.p)                                                   \
+            rootCauseStr = (wchar_t*)root->GetExceptionMessage();             \
+                                                                              \
         if (NULL != buf)                                                      \
         {                                                                     \
             messageId = L"MgFeatureSourceFormatInnerExceptionMessage";        \
             arguments.Add(fsId->ToString());                                  \
             arguments.Add(buf);                                               \
+            arguments.Add((causeStr == NULL) ? L"" : causeStr);               \
+            arguments.Add((rootCauseStr == NULL) ? L"" : rootCauseStr);       \
         }                                                                     \
                                                                               \
         FDO_SAFE_RELEASE(e);                                                  \
@@ -108,7 +130,16 @@
         MgStringCollection arguments;                                         \
         wchar_t* buf = (wchar_t*)e->GetExceptionMessage();                    \
         INT64 nativeErrorCode = e->GetNativeErrorCode();                      \
+        FdoPtr<FdoException> cause = e->GetCause();                           \
+        FdoPtr<FdoException> root = e->GetRootCause();                        \
                                                                               \
+        wchar_t* causeStr = NULL;                                             \
+        wchar_t* rootCauseStr = NULL;                                         \
+        if (NULL != cause.p)                                                  \
+            causeStr = (wchar_t*)cause->GetExceptionMessage();                \
+        if (NULL != root.p)                                                   \
+            rootCauseStr = (wchar_t*)root->GetExceptionMessage();             \
+                                                                              \
         if (NULL != buf)                                                      \
         {                                                                     \
             if((NULL != wcsstr(buf, L"Lost connection to MySQL server during query")) || \
@@ -125,6 +156,8 @@
             messageId = L"MgFeatureSourceFormatInnerExceptionMessage";        \
             arguments.Add(resource->ToString());                              \
             arguments.Add(buf);                                               \
+            arguments.Add((causeStr == NULL) ? L"" : causeStr);               \
+            arguments.Add((rootCauseStr == NULL) ? L"" : rootCauseStr);       \
         }                                                                     \
                                                                               \
         FDO_SAFE_RELEASE(e);                                                  \


Property changes on: trunk/MgDev/Server/src/Services/Feature/ServerFeatureUtil.cpp
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/2.4/MgDev/Server/src/Services/Feature/ServerFeatureUtil.cpp:6738-6741,6749-6756,6777-6783,6785-6787,6789,6791-6794
/sandbox/adsk/2.4j/Server/src/Services/Feature/ServerFeatureUtil.cpp:6327-6481
/sandbox/rfc94/Server/src/Services/Feature/ServerFeatureUtil.cpp:5099-5163
/trunk/MgDev/Server/src/Services/Feature/ServerFeatureUtil.cpp:6250-6326
   + /branches/2.4/MgDev/Server/src/Services/Feature/ServerFeatureUtil.cpp:6738-6741,6749-6756,6777-6783,6785-6787,6789,6791-6794,6796-6801
/sandbox/adsk/2.4j/Server/src/Services/Feature/ServerFeatureUtil.cpp:6327-6481
/sandbox/rfc94/Server/src/Services/Feature/ServerFeatureUtil.cpp:5099-5163
/trunk/MgDev/Server/src/Services/Feature/ServerFeatureUtil.cpp:6250-6326

Modified: trunk/MgDev/Server/src/Services/Feature/ServerSelectFeatures.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Feature/ServerSelectFeatures.cpp	2012-07-02 13:20:49 UTC (rev 6831)
+++ trunk/MgDev/Server/src/Services/Feature/ServerSelectFeatures.cpp	2012-07-02 14:54:35 UTC (rev 6832)
@@ -99,6 +99,22 @@
     bool bFeatureCalculation = FindFeatureCalculation(resource, className);
     //Test for the FDO join optimization, because performance is **substantially** better
     bool bSupportsFdoJoin = SupportsFdoJoin(resource, className, isSelectAggregate);
+
+    // HACK: Sorry, we have to do this for now. Only SQLite provider satisifes the original
+    // FDO join optimization in both regular select and select aggregate modes
+    //
+    // SQL Server has problems in aggregate mode. So we'll say the FDO join optimization is 
+    // not supported when this is in aggregate mode. This means the join is handled by the
+    // GWS query engine. SQL Server on SQL Server join will use the best algorithm (sort merge)
+    // as both sides are sortable so we won't suffer too much of a performance penalty.
+    if (isSelectAggregate)
+    {
+        MdfModel::FeatureSource* featureSource = m_featureSourceCacheItem->Get();
+        const MdfModel::MdfString& providerName = featureSource->GetProvider();
+        if (providerName.find(L"OSGeo.SQLite") == MdfString::npos) //NOXLATE
+            bSupportsFdoJoin = false;
+    }
+
 #ifdef DEBUG_FDO_JOIN
     STRING fsIdStr = resource->ToString();
     ACE_DEBUG((LM_INFO, ACE_TEXT("\n(%t) Testing Feature Source (%W, %W) for FDO join optimization"), fsIdStr.c_str(), className.c_str()));
@@ -1769,7 +1785,7 @@
     if (NULL == (FdoClassDefinition*)classDef)
     {
         //TODO: Refine message if available
-        throw new MgClassNotFoundException(L"MgServerSelectFeatures.SelectFdoJoin", __LINE__, __WFILE__, NULL, L"", NULL);
+        throw new MgClassNotFoundException(L"MgServerSelectFeatures.IsFunctionOnPrimaryProperty", __LINE__, __WFILE__, NULL, L"", NULL);
     }
 
     FdoPtr<FdoPropertyDefinitionCollection> properties = classDef->GetProperties();
@@ -1843,7 +1859,7 @@
         if (NULL == (FdoClassDefinition*)classDef)
         {
             //TODO: Refine message if available
-            throw new MgClassNotFoundException(L"MgServerSelectFeatures.SelectFdoJoin", __LINE__, __WFILE__, NULL, L"", NULL);
+            throw new MgClassNotFoundException(L"MgServerSelectFeatures.FilterContainsSecondaryProperties", __LINE__, __WFILE__, NULL, L"", NULL);
         }
 
         FdoPtr<FdoPropertyDefinitionCollection> propDefs = classDef->GetProperties();
@@ -2162,7 +2178,7 @@
     if (NULL == (FdoClassDefinition*)classDef)
     {
         //TODO: Refine message if available
-        throw new MgClassNotFoundException(L"MgServerSelectFeatures.SelectFdoJoin", __LINE__, __WFILE__, NULL, L"", NULL);
+        throw new MgClassNotFoundException(L"MgServerSelectFeatures.ApplyClassProperties", __LINE__, __WFILE__, NULL, L"", NULL);
     }
 
     FdoPtr<FdoIdentifierCollection> propNames = m_command->GetPropertyNames();


Property changes on: trunk/MgDev/Server/src/Services/Mapping/MappingUtil.cpp
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/2.4/MgDev/Server/src/Services/Mapping/MappingUtil.cpp:6738-6741,6749-6756,6777-6783,6785-6787,6789,6791-6794
/sandbox/adsk/2.4j/Server/src/Services/Mapping/MappingUtil.cpp:6327-6535
/sandbox/rfc94/Server/src/Services/Mapping/MappingUtil.cpp:5099-5163
/trunk/MgDev/Server/src/Services/Mapping/MappingUtil.cpp:6250-6326
   + /branches/2.4/MgDev/Server/src/Services/Mapping/MappingUtil.cpp:6738-6741,6749-6756,6777-6783,6785-6787,6789,6791-6794,6796-6801
/sandbox/adsk/2.4j/Server/src/Services/Mapping/MappingUtil.cpp:6327-6535
/sandbox/rfc94/Server/src/Services/Mapping/MappingUtil.cpp:5099-5163
/trunk/MgDev/Server/src/Services/Mapping/MappingUtil.cpp:6250-6326


Property changes on: trunk/MgDev/Web/src/mapadmin/HelpDocs
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/2.4/MgDev/Web/src/mapadmin/HelpDocs:6738-6741,6749-6756,6777-6783,6785-6787,6789,6791-6794
/sandbox/adsk/2.4j/Web/src/mapadmin/HelpDocs:6413
/sandbox/rfc94/Web/src/mapadmin/HelpDocs:5099-5163
   + /branches/2.4/MgDev/Web/src/mapadmin/HelpDocs:6738-6741,6749-6756,6777-6783,6785-6787,6789,6791-6794,6796-6801
/sandbox/adsk/2.4j/Web/src/mapadmin/HelpDocs:6413
/sandbox/rfc94/Web/src/mapadmin/HelpDocs:5099-5163


Property changes on: trunk/MgDev/Web/src/mapadmin/HelpDocs/configuring_servers.htm
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/2.4/MgDev/Web/src/mapadmin/HelpDocs/configuring_servers.htm:6738-6741,6749-6756,6777-6783,6785-6787,6789,6791-6794
/sandbox/adsk/2.4j/Web/src/mapadmin/HelpDocs/configuring_servers.htm:6327-6435
/sandbox/rfc94/Web/src/mapadmin/HelpDocs/configuring_servers.htm:5099-5163
/trunk/MgDev/Web/src/mapadmin/HelpDocs/configuring_servers.htm:6250-6326
   + /branches/2.4/MgDev/Web/src/mapadmin/HelpDocs/configuring_servers.htm:6738-6741,6749-6756,6777-6783,6785-6787,6789,6791-6794,6796-6801
/sandbox/adsk/2.4j/Web/src/mapadmin/HelpDocs/configuring_servers.htm:6327-6435
/sandbox/rfc94/Web/src/mapadmin/HelpDocs/configuring_servers.htm:5099-5163
/trunk/MgDev/Web/src/mapadmin/HelpDocs/configuring_servers.htm:6250-6326


Property changes on: trunk/MgDev/Web/src/mapviewerphp/quickplotgeneratepicture.php
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/2.4/MgDev/Web/src/mapviewerphp/quickplotgeneratepicture.php:6738-6741,6749-6756,6777-6783,6785-6787,6789,6791-6794
/sandbox/adsk/2.4jbeta2/Web/src/mapviewerphp/quickplotgeneratepicture.php:6334-6374
/sandbox/rfc94/Web/src/mapviewerphp/quickplotgeneratepicture.php:5099-5163
   + /branches/2.4/MgDev/Web/src/mapviewerphp/quickplotgeneratepicture.php:6738-6741,6749-6756,6777-6783,6785-6787,6789,6791-6794,6796-6801
/sandbox/adsk/2.4jbeta2/Web/src/mapviewerphp/quickplotgeneratepicture.php:6334-6374
/sandbox/rfc94/Web/src/mapviewerphp/quickplotgeneratepicture.php:5099-5163

Modified: trunk/MgDev/Web/src/schemareport/displayschemafunctions.php
===================================================================
--- trunk/MgDev/Web/src/schemareport/displayschemafunctions.php	2012-07-02 13:20:49 UTC (rev 6831)
+++ trunk/MgDev/Web/src/schemareport/displayschemafunctions.php	2012-07-02 14:54:35 UTC (rev 6832)
@@ -21,6 +21,186 @@
 
 <?php
 
+class MBR 
+{
+    public $coordinateSystem;
+    public $extentGeometry;
+}
+
+function GetFeatureClassMBR($featuresId, $className, $geomProp, $featureSrvc)
+{
+    $extentGeometryAgg = null;
+    $extentGeometrySc = null;
+    $extentByteReader = null;
+    
+    $mbr = new MBR();
+    $geomName = $geomProp->GetName();
+    $spatialContext = $geomProp->GetSpatialContextAssociation();
+
+    // Finds the coordinate system
+    $agfReaderWriter = new MgAgfReaderWriter();
+    $spatialcontextReader = $featureSrvc->GetSpatialContexts($featuresId, false);
+    while ($spatialcontextReader->ReadNext())
+    {
+        if ($spatialcontextReader->GetName() == $spatialContext)
+        {
+            $mbr->coordinateSystem = $spatialcontextReader->GetCoordinateSystemWkt();
+
+            // Finds the extent
+            $extentByteReader = $spatialcontextReader->GetExtent();
+            break;
+        }
+    }
+    $spatialcontextReader->Close();
+    if ($extentByteReader != null)
+    {
+        // Get the extent geometry from the spatial context
+        $extentGeometrySc = $agfReaderWriter->Read($extentByteReader);
+    }
+
+    // Try to get the extents using the selectaggregate as sometimes the spatial context
+    // information is not set
+    $aggregateOptions = new MgFeatureAggregateOptions();
+    $featureProp = 'SPATIALEXTENTS("' . $geomName . '")';
+    $aggregateOptions->AddComputedProperty('EXTENTS', $featureProp);
+
+    try
+    {
+        $dataReader = $featureSrvc->SelectAggregate($featuresId, $className, $aggregateOptions);
+        if($dataReader->ReadNext())
+        {
+            // Get the extents information
+            $byteReader = $dataReader->GetGeometry('EXTENTS');
+            $extentGeometryAgg = $agfReaderWriter->Read($byteReader);
+        }
+        $dataReader->Close();
+    }
+    catch (MgException $e)
+    {
+        if ($extentGeometryAgg == null) 
+        {
+            //We do have one last hope. EXTENT() is an internal MapGuide custom function that's universally supported
+            //as it operates against an underlying select query result. This raw-spins the reader server-side so there
+            //is no server -> web tier transmission overhead involved.
+            try
+            {
+                $aggregateOptions = new MgFeatureAggregateOptions();
+                $aggregateOptions->AddComputedProperty("COMP_EXTENT", "EXTENT(".$geomName.")");
+                
+                $dataReader = $featureSrvc->SelectAggregate($featuresId, $className, $aggregateOptions);
+                if($dataReader->ReadNext())
+                {
+                    // Get the extents information
+                    $byteReader = $dataReader->GetGeometry('COMP_EXTENT');
+                    $extentGeometryAgg = $agfReaderWriter->Read($byteReader);
+                }
+                $dataReader->Close();
+            }
+            catch (MgException $e2) 
+            {
+                
+            }
+        }
+    }
+    
+    $mbr->extentGeometry = null;
+    // Prefer SpatialExtents() of EXTENT() result over spatial context extent
+    if ($extentGeometryAgg != null)
+        $mbr->extentGeometry = $extentGeometryAgg;
+    if ($mbr->extentGeometry == null) { //Stil null? Now try spatial context
+        if ($extentGeometrySc != null)
+            $mbr->extentGeometry = $extentGeometrySc;
+    }
+    return $mbr;
+}
+
+function GetFeatureCount($featuresId, $schemaName, $className, $resourceSrvc, $featureSrvc)
+{
+    //Try the SelectAggregate shortcut. This is faster than raw spinning a feature reader
+    //
+    //NOTE: If MapGuide supported scrollable readers like FDO, we'd have also tried 
+    //that as well.
+    $featureName = $schemaName . ":" . $className;
+    $canCount = false;
+    $gotCount = false;
+    $fsBr = $resourceSrvc->GetResourceContent($featuresId);
+    $fsXml = $fsBr->ToString();
+    $fsDoc = DOMDocument::loadXML($fsXml);
+    $providerNodeList = $fsDoc->getElementsByTagName("Provider");
+    $providerName = $providerNodeList->item(0)->nodeValue;
+    $capsBr = $featureSrvc->GetCapabilities($providerName);
+    $capsXml = $capsBr->ToString();
+    //This should be good enough to find out if Count() is supported
+    $canCount = !(strstr($capsXml, "<Name>Count</Name>") === false);
+    
+    if ($canCount) {
+        $clsDef = $featureSrvc->GetClassDefinition($featuresId, $schemaName, $className);
+        $idProps = $clsDef->GetIdentityProperties();
+        if ($idProps->GetCount() > 0)
+        {
+            $pd = $idProps->GetItem(0);
+            $expr = "COUNT(" .$pd->GetName(). ")";
+            $query = new MgFeatureAggregateOptions();
+            $query->AddComputedProperty("TotalCount", $expr);
+            try 
+            {
+                $dataReader = $featureSrvc->SelectAggregate($featuresId, $featureName, $query);
+                if ($dataReader->ReadNext())
+                {
+                    // When there is no data, the property will be null.
+                    if($dataReader->IsNull("TotalCount"))
+                    {
+                        $totalEntries = 0;
+                        $gotCount = true;
+                    }
+                    else
+                    {
+                        $ptype = $dataReader->GetPropertyType("TotalCount");
+                        switch ($ptype)
+                        {
+                            case MgPropertyType::Int32:
+                                $totalEntries = $dataReader->GetInt32("TotalCount");
+                                $gotCount = true;
+                                break;
+                            case MgPropertyType::Int64:
+                                $totalEntries = $dataReader->GetInt64("TotalCount");
+                                $gotCount = true;
+                                break;
+                        }
+                        $dataReader->Close();
+                    }
+                }
+            }
+            catch (MgException $ex) //Some providers like OGR can lie
+            {
+                $gotCount = false;
+            }
+        }
+    }
+    
+    if ($gotCount == false)
+    {
+        $featureReader = null;
+        try 
+        {
+            $featureReader = $featureSrvc->SelectFeatures($featuresId, $featureName, null);
+        }
+        catch (MgException $ex)
+        {
+            $totalEntries = -1; //Can't Count() or raw spin? Oh dear!
+        }
+        
+        if ($featureReader != null)
+        {
+            while($featureReader->ReadNext())
+                $totalEntries++;
+            $featureReader->Close();
+        }
+    }
+    
+    return $totalEntries;
+}
+
 function GetPropertyName($featureReader, $property, $propertyType)
 {
     if($featureReader->IsNull($property))

Modified: trunk/MgDev/Web/src/schemareport/showclass.php
===================================================================
--- trunk/MgDev/Web/src/schemareport/showclass.php	2012-07-02 13:20:49 UTC (rev 6831)
+++ trunk/MgDev/Web/src/schemareport/showclass.php	2012-07-02 14:54:35 UTC (rev 6832)
@@ -60,6 +60,7 @@
                 $site->Open($userInfo);
 
                 $featureSrvc = $site->CreateService(MgServiceType::FeatureService);
+                $resourceSrvc = $site->CreateService(MgServiceType::ResourceService);
                 $resId = new MgResourceIdentifier($resName);
 
                 $schemaName = substr(strrchr($schemaName, "/"), 1);
@@ -67,12 +68,8 @@
                 $geomName = $classDef->GetDefaultGeometryPropertyName();
 
                 $qualifiedClassName = $schemaName . ":" . $className;
-                $featureReader = $featureSrvc->SelectFeatures($resId, $qualifiedClassName, null);
-
                 // Calculate total number of entries.
-                while($featureReader->ReadNext())
-                  $totalEntries++;
-                $featureReader->Close();
+                $totalEntries = GetFeatureCount($resId, $schemaName, $className, $resourceSrvc, $featureSrvc);
 
                 $currentPage = ceil(($index+$maxEntries)/$maxEntries);
                 $maxPage = ceil($totalEntries/$maxEntries);

Modified: trunk/MgDev/Web/src/schemareport/showgeom.php
===================================================================
--- trunk/MgDev/Web/src/schemareport/showgeom.php	2012-07-02 13:20:49 UTC (rev 6831)
+++ trunk/MgDev/Web/src/schemareport/showgeom.php	2012-07-02 14:54:35 UTC (rev 6832)
@@ -70,93 +70,21 @@
                 $featuresId = new MgResourceIdentifier($resName);
 
                 $schemaName = substr(strrchr($schemaName, "/"), 1);
-                $featureName = $schemaName . ':' . $className;
-
+                
                 $classDef = $featureSrvc->GetClassDefinition($featuresId, $schemaName, $className);
-                $geomProp = $classDef->GetProperties()->GetItem($geomName);
-                $spatialContext = $geomProp->GetSpatialContextAssociation();
+                $clsProps = $classDef->GetProperties();
+                $geomProp = $clsProps->GetItem($geomName);
 
-                //Try the SelectAggregate shortcut. This is faster than raw spinning a feature reader
+                //TODO: Worse case scenario is no provider support for Count() or SpatialExtents()
+                //In such cases, we should piggy-back off of the same raw-spun feature reader to compile the count and MBR
+                //instead of having to raw-spin twice (once to get the count, another to get the MBR via EXTENT())
                 //
-                //NOTE: If MapGuide supported scrollable readers like FDO, we'd have also tried 
-                //that as well.
-                $canCount = false;
-                $gotCount = false;
-                $fsBr = $resourceSrvc->GetResourceContent($featuresId);
-                $fsXml = $fsBr->ToString();
-                $fsDoc = DOMDocument::loadXML($fsXml);
-                $providerNodeList = $fsDoc->getElementsByTagName("Provider");
-                $providerName = $providerNodeList->item(0)->nodeValue;
-                $capsBr = $featureSrvc->GetCapabilities($providerName);
-                $capsXml = $capsBr->ToString();
-                //This should be good enough to find out if Count() is supported
-                $canCount = !(strstr($capsXml, "<Name>Count</Name>") === false);
+                //TODO: Have a way to do this purely mgserver-side so we don't have row transmission overhead by doing the counting
+                //on the web tier
+
+                $totalEntries = GetFeatureCount($featuresId, $schemaName, $className, $resourceSrvc, $featureSrvc);
+                $featureName = $schemaName . ':' . $className;
                 
-                if ($canCount) {
-                    $clsDef = $featureSrvc->GetClassDefinition($featuresId, $schemaName, $className);
-                    $idProps = $clsDef->GetIdentityProperties();
-                    if ($idProps->GetCount() > 0)
-                    {
-                        $pd = $idProps->GetItem(0);
-                        $expr = "COUNT(" .$pd->GetName(). ")";
-                        $query = new MgFeatureAggregateOptions();
-                        $query->AddComputedProperty("TotalCount", $expr);
-                        try 
-                        {
-                            $dataReader = $featureSrvc->SelectAggregate($featuresId, $featureName, $query);
-                            if ($dataReader->ReadNext())
-                            {
-                                // When there is no data, the property will be null.
-                                if($dataReader->IsNull("TotalCount"))
-                                {
-                                    $totalEntries = 0;
-                                    $gotCount = true;
-                                }
-                                else
-                                {
-                                    $ptype = $dataReader->GetPropertyType("TotalCount");
-                                    switch ($ptype)
-                                    {
-                                        case MgPropertyType::Int32:
-                                            $totalEntries = $dataReader->GetInt32("TotalCount");
-                                            $gotCount = true;
-                                            break;
-                                        case MgPropertyType::Int64:
-                                            $totalEntries = $dataReader->GetInt64("TotalCount");
-                                            $gotCount = true;
-                                            break;
-                                    }
-                                    $dataReader->Close();
-                                }
-                            }
-                        }
-                        catch (MgException $ex) //Some providers like OGR can lie
-                        {
-                            $gotCount = false;
-                        }
-                    }
-                }
-                
-                if ($gotCount == false)
-                {
-                    $featureReader = null;
-                    try 
-                    {
-                        $featureReader = $featureSrvc->SelectFeatures($featuresId, $featureName, null);
-                    }
-                    catch (MgException $ex)
-                    {
-                        $totalEntries = -1; //Can't Count() or raw spin? Oh dear!
-                    }
-                    
-                    if ($featureReader != null)
-                    {
-                        while($featureReader->ReadNext())
-                            $totalEntries++;
-                        $featureReader->Close();
-                    }
-                }
-                
                 // Create a layer definition
                 $layerfactory = new LayerDefinitionFactory();
                 $layerDefinition = CreateLayerDef($layerfactory, $resName, $featureName, $geomName, $geomType);
@@ -168,65 +96,12 @@
                 $resId = new MgResourceIdentifier($resName);
                 $resourceSrvc->SetResource($resId, $byteSource->GetReader(), null);
 
-                $extentGeometryAgg = null;
-                $extentGeometrySc = null;
-                $extentByteReader = null;
-
-                // Finds the coordinate system
-                $agfReaderWriter = new MgAgfReaderWriter();
-                $spatialcontextReader = $featureSrvc->GetSpatialContexts($featuresId, false);
-                while ($spatialcontextReader->ReadNext())
-                {
-                    if ($spatialcontextReader->GetName() == $spatialContext)
-                    {
-                        $coordinate = $spatialcontextReader->GetCoordinateSystemWkt();
-
-                        // Finds the extent
-                        $extentByteReader = $spatialcontextReader->GetExtent();
-                        break;
-                    }
-                }
-                $spatialcontextReader->Close();
-                if ($extentByteReader == null)
-                {
-                    // Get the extent geometry from the spatial context
-                    $extentGeometrySc = $agfReaderWriter->Read($extentByteReader);
-                }
-
-                // Try to get the extents using the selectaggregate as sometimes the spatial context
-                // information is not set
-                $aggregateOptions = new MgFeatureAggregateOptions();
-                $featureProp = 'SPATIALEXTENTS("' . $geomName . '")';
-                $aggregateOptions->AddComputedProperty('EXTENTS', $featureProp);
-
-                try
-                {
-                    $dataReader = $featureSrvc->SelectAggregate($featuresId, $className, $aggregateOptions);
-                    if($dataReader->ReadNext())
-                    {
-                        // Get the extents information
-                        $byteReader = $dataReader->GetGeometry('EXTENTS');
-                        $extentGeometryAgg = $agfReaderWriter->Read($byteReader);
-                    }
-                    $dataReader->Close();
-                }
-                catch (MgException $e)
-                {
+                $mbr = GetFeatureClassMBR($featuresId, $className, $geomProp, $featureSrvc);
+                if ($mbr->extentGeometry == null)
+                    throw new Exception(ErrorMessages::NullExtent);
                 
-                }
-                
-                $extentGeometry = null;
-                // Prefer SpatialExtents() extent over spatial context extent
-                if ($extentGeometryAgg != null)
-                    $extentGeometry = $extentGeometryAgg;
-                if ($extentGeometry == null) { //Stil null? Now try spatial context
-                    if ($extentGeometrySc != null)
-                        $extentGeometry = $extentGeometrySc;
-                    else
-                        throw new Exception(ErrorMessages::NullExtent);
-                }
                 // Get the coordinates
-                $iterator = $extentGeometry->GetCoordinates();
+                $iterator = $mbr->extentGeometry->GetCoordinates();
                 while($iterator->MoveNext())
                 {
                     $x = $iterator->GetCurrent()->GetX();
@@ -251,7 +126,7 @@
 
                 // Create a map definition
                 $mapfactory = new MapDefinitionFactory();
-                $mapDefinition = CreateMapDef($mapfactory, $className, $resName, $coordinate, $minX, $maxX, $minY, $maxY);
+                $mapDefinition = CreateMapDef($mapfactory, $className, $resName, $mbr->coordinateSystem, $minX, $maxX, $minY, $maxY);
 
                 // Save the map definition to a resource stored in the session repository
                 $byteSource = new MgByteSource($mapDefinition, strlen($mapDefinition));


Property changes on: trunk/MgDev/Web/src/viewerfiles
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/2.4/MgDev/Web/src/viewerfiles:6738-6741,6749-6756,6777-6783,6785-6787,6789,6791-6794
/sandbox/adsk/2.2gp/Web/src/viewerfiles:5392
   + /branches/2.4/MgDev/Web/src/viewerfiles:6738-6741,6749-6756,6777-6783,6785-6787,6789,6791-6794,6796-6801
/sandbox/adsk/2.2gp/Web/src/viewerfiles:5392


Property changes on: trunk/MgDev/Web/src/viewerfiles/quickplot.js
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/2.4/MgDev/Web/src/viewerfiles/quickplot.js:6738-6741,6749-6756,6777-6783,6785-6787,6789,6791-6794
/sandbox/adsk/2.2gp/Web/src/viewerfiles/quickplot.js:5392
/sandbox/adsk/2.4j/Web/src/viewerfiles/quickplot.js:6327-6474
/trunk/MgDev/Web/src/viewerfiles/quickplot.js:6250-6326
   + /branches/2.4/MgDev/Web/src/viewerfiles/quickplot.js:6738-6741,6749-6756,6777-6783,6785-6787,6789,6791-6794,6796-6801
/sandbox/adsk/2.2gp/Web/src/viewerfiles/quickplot.js:5392
/sandbox/adsk/2.4j/Web/src/viewerfiles/quickplot.js:6327-6474
/trunk/MgDev/Web/src/viewerfiles/quickplot.js:6250-6326

Modified: trunk/MgDev/setenvironment.bat
===================================================================
--- trunk/MgDev/setenvironment.bat	2012-07-02 13:20:49 UTC (rev 6831)
+++ trunk/MgDev/setenvironment.bat	2012-07-02 14:54:35 UTC (rev 6832)
@@ -55,11 +55,11 @@
 rem running
 rem ==================================================
 
-IF "%JAVA_HOME%" == "" SET JAVA_HOME=C:\Program Files\Java\jdk1.6.0_21
+IF "%JAVA_HOME%" == "" SET JAVA_HOME=C:\Program Files\Java\jdk1.6.0_31
 IF "%DOXYGEN%" == "" SET DOXYGEN=%MG_DEV%\BuildTools\doxygen
-IF "%GNUWIN32%" == "" SET GNUWIN32=C:\Program Files\GnuWin32\bin
+IF "%GNUWIN32%" == "" SET GNUWIN32=C:\Program Files (x86)\GnuWin32\bin
 IF "%SEVENZ%" == "" SET SEVENZ=%MG_DEV%\BuildTools\WebTools\7-Zip
-IF "%ANT_HOME%" == "" SET ANT_HOME=%MG_DEV%\BuildTools\apache-ant-1.7.1
+IF "%ANT_HOME%" == "" SET ANT_HOME=C:\apache-ant-1.8.3
 
 SET PATH=%PATH%;%DOXYGEN%;%GNUWIN32%;%SEVENZ%;%ANT_HOME%\bin
 rem ==================================================



More information about the mapguide-commits mailing list