[mapguide-commits] r7377 - in sandbox/adsk/2.3r.sce/Server/src/Services: Mapping Rendering

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Wed Feb 20 18:54:02 PST 2013


Author: hubu
Date: 2013-02-20 18:54:02 -0800 (Wed, 20 Feb 2013)
New Revision: 7377

Modified:
   sandbox/adsk/2.3r.sce/Server/src/Services/Mapping/MappingUtil.cpp
   sandbox/adsk/2.3r.sce/Server/src/Services/Mapping/MappingUtil.h
   sandbox/adsk/2.3r.sce/Server/src/Services/Rendering/ServerRenderingService.cpp
Log:
Submit on behalf of Andy Zhang
This submission is for SCE project.
SCE uses Teradata database. I found the execution time of Teradata SQL statement changes significantly with different selection columns. For example, a SQL like ?\226?\128?\152SELECT col1 FROM ?\226?\128?\166?\226?\128?\153 is much faster than ?\226?\128?\152SELECT col1, col2, col3, ?\226?\128?\166 col15 FROM ?\226?\128?\166?\226?\128?\153 in Teradata. 

By default, AIMS Server selects all columns of a layer when rendering images and getting selection feature IDs. But of course, not all columns are used. Rending images needs the ?\226?\128?\152Geometry?\226?\128?\153 property. And ?\226?\128?\152Getting selection feature IDs?\226?\128?\153 needs the primary keys of the layer. So I changed the logic not to select all columns, but only select necessary columns. 

This change only works when the layer has NO theme rule (the rule can be defined in Studio ?\226?\128?\147 Layer Definition ?\226?\128?\147 Style). If a layer has defined rules, the rule condition also needs to be added to selection columns. But I didn?\226?\128?\153t find a solution for it. 

So, what I did for the performance improvement are:
1.	Check if the layer has rule definition
2.	If no, only add necessary columns to selection set



Modified: sandbox/adsk/2.3r.sce/Server/src/Services/Mapping/MappingUtil.cpp
===================================================================
--- sandbox/adsk/2.3r.sce/Server/src/Services/Mapping/MappingUtil.cpp	2013-02-20 10:58:32 UTC (rev 7376)
+++ sandbox/adsk/2.3r.sce/Server/src/Services/Mapping/MappingUtil.cpp	2013-02-21 02:54:02 UTC (rev 7377)
@@ -83,7 +83,8 @@
                                                       MgCoordinateSystem* mapCs,
                                                       MgCoordinateSystem* layerCs,
                                                       TransformCache* cache,
-                                                      bool spatialSelection)
+                                                      bool spatialSelection,
+                                                      bool hasRuleFilter)
 {
 #ifdef _DEBUG
     long dwStart = GetTickCount();
@@ -219,6 +220,12 @@
 
     Ptr<MgFeatureReader> rdr;
 
+    //Only add Geometry property if no theme rule filter
+    if (!hasRuleFilter && !geom.empty())
+    {
+        options->AddFeatureProperty(geom);
+    }
+
     //poor man's substitute for checking capabilities
     //try catch until we succeed...
     try
@@ -573,8 +580,29 @@
                     ACE_DEBUG((LM_INFO, L"(%t)  StylizeLayers(%d) **Stylizing** Name:%W  Override Filter(size=%d):\n%W\n", i, (mapLayer->GetName()).c_str(), overrideFilter.length(), overrideFilter.empty() ? L"(Empty)" : overrideFilter.c_str()));
                     #endif
 
+                    bool hasRuleFilter = false;
+                    FeatureTypeStyleCollection* pftsColl = scaleRange->GetFeatureTypeStyles();
+                    int ftsccount = pftsColl->GetCount();
+                    for (int j=0; j<ftsccount && !hasRuleFilter; ++j)
+                    {
+                        FeatureTypeStyle* pfts = pftsColl->GetAt(j);
+
+                        // iterate through the rulecollection
+                        RuleCollection* ruleColl = pfts->GetRules();
+                        int rccount = ruleColl->GetCount();
+                        for (int k=0; k<rccount; ++k)
+                        {
+                            Rule* rule = ruleColl->GetAt(k);
+                            if (!rule->GetFilter().empty())
+                            {
+                                hasRuleFilter = true;
+                                break;
+                            }
+                        }
+                    }
+
                     // create the reader we'll use
-                    rsReader = ExecuteFeatureQuery(svcFeature, extent, vl, overrideFilter.c_str(), dstCs, layerCs, item, spatialSelection);
+                    rsReader = ExecuteFeatureQuery(svcFeature, extent, vl, overrideFilter.c_str(), dstCs, layerCs, item, spatialSelection, hasRuleFilter);
                     // create an automatic FdoPtr around the reader
                     FdoPtr<FdoIFeatureReader> fdoReader = (NULL == rsReader) ? NULL : rsReader->GetInternalReader();
 

Modified: sandbox/adsk/2.3r.sce/Server/src/Services/Mapping/MappingUtil.h
===================================================================
--- sandbox/adsk/2.3r.sce/Server/src/Services/Mapping/MappingUtil.h	2013-02-20 10:58:32 UTC (rev 7376)
+++ sandbox/adsk/2.3r.sce/Server/src/Services/Mapping/MappingUtil.h	2013-02-21 02:54:02 UTC (rev 7377)
@@ -70,7 +70,8 @@
                                                  MgCoordinateSystem* mapCs,
                                                  MgCoordinateSystem* layerCs,
                                                  TransformCache* cache,
-                                                 bool spatialSelection = false);
+                                                 bool spatialSelection = false,
+                                                 bool hasRuleFilter = true);
 
     static RSMgFeatureReader* ExecuteRasterQuery(MgFeatureService* svcFeature,
                                                 RS_Bounds& extent,

Modified: sandbox/adsk/2.3r.sce/Server/src/Services/Rendering/ServerRenderingService.cpp
===================================================================
--- sandbox/adsk/2.3r.sce/Server/src/Services/Rendering/ServerRenderingService.cpp	2013-02-20 10:58:32 UTC (rev 7376)
+++ sandbox/adsk/2.3r.sce/Server/src/Services/Rendering/ServerRenderingService.cpp	2013-02-21 02:54:02 UTC (rev 7377)
@@ -1554,6 +1554,44 @@
                     options->SetFilter(vl->GetFilter());
                 }
 
+                // Only add identity properties if not request tooltip
+                if (!bOnlyTooltipLayers)
+                {
+                    MdfModel::VectorScaleRange* scaleRange = Stylizer::FindScaleRange(*vl->GetScaleRanges(), scale);
+                    bool hasRuleFilter = false;
+                    FeatureTypeStyleCollection* pftsColl = scaleRange->GetFeatureTypeStyles();
+                    int ftsccount = pftsColl->GetCount();
+                    for (int j=0; j<ftsccount && !hasRuleFilter; ++j)
+                    {
+                        FeatureTypeStyle* pfts = pftsColl->GetAt(j);
+
+                        // iterate through the rulecollection
+                        RuleCollection* ruleColl = pfts->GetRules();
+                        int rccount = ruleColl->GetCount();
+                        for (int k=0; k<rccount; ++k)
+                        {
+                            Rule* rule = ruleColl->GetAt(k);
+                            if (!rule->GetFilter().empty())
+                            {
+                                hasRuleFilter = true;
+                                break;
+                            }
+                        }
+                    }
+                    if (!hasRuleFilter)
+                    {
+                        STRING schemaName, className;
+                        MgUtil::ParseQualifiedClassName(vl->GetFeatureName(), schemaName, className);
+                        Ptr<MgClassDefinition> classDef = m_svcFeature->GetClassDefinition(featResId, schemaName, className);
+                        Ptr<MgPropertyDefinitionCollection> props = classDef->GetIdentityProperties();
+                        for (int i = 0; i < props->GetCount(); i++)
+                        {
+                            Ptr<MgPropertyDefinition> prop = props->GetItem(i);
+                            options->AddFeatureProperty(prop->GetName());
+                        }
+                    }
+                }
+
                 // TODO: can FeatureName be an extension name rather than a FeatureClass?
                 // The reader below needs to be closed and released before the intersectPolygon SelectFeatures below happens
                 // or we end up with a reference count issue that causes a new FDO connection to be cached instead of



More information about the mapguide-commits mailing list