[mapguide-commits] r7290 - in trunk/MgDev: Common/PlatformBase/MapLayer Web/src/mapviewernet
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Fri Jan 4 23:30:35 PST 2013
Author: hubu
Date: 2013-01-04 23:30:33 -0800 (Fri, 04 Jan 2013)
New Revision: 7290
Modified:
trunk/MgDev/Common/PlatformBase/MapLayer/SelectionBase.cpp
trunk/MgDev/Common/PlatformBase/MapLayer/SelectionBase.h
trunk/MgDev/Web/src/mapviewernet/getselectedfeatures.aspx
Log:
Submit on behalf of Andy Zhang
Integrate revision 7259 to trunk.
Implement ticket http://trac.osgeo.org/mapguide/ticket/2193
There is a publish Api MgSelectionBase::GenerateFilter(MgLayerBase* layer, CREFSTRING className) in class MgSelectBase, which generates a Fdo filter text for the selections of the specified layer and class. If the key of the layer has more than one column e.g. K1 and K2, the generated filter text is like '(K1=xxx AND K2=xxx) OR (K1=xxx AND K2=xxx) OR ...'. This kind of fitler text cannot be broken into small pieces by MgSelectCommand. If the selection set is very big, it is possible that the generated filter text exceed the max length of Sql statement.
So now we make the method MgSelectionBase::GenerateFilters(MgLayerBase* layer, CREFSTRING className, INT32 selectionSize) to be a published Api. The caller (php, asp from web-tier side) can use this method to get several smaller filter text of a selection to avoid the filter text exceed the length limit.
This submission also updated Web/src/mapviewernet/getselectedfeatures.aspx to use the new API to get selection properties.
Modified: trunk/MgDev/Common/PlatformBase/MapLayer/SelectionBase.cpp
===================================================================
--- trunk/MgDev/Common/PlatformBase/MapLayer/SelectionBase.cpp 2013-01-05 07:13:04 UTC (rev 7289)
+++ trunk/MgDev/Common/PlatformBase/MapLayer/SelectionBase.cpp 2013-01-05 07:30:33 UTC (rev 7290)
@@ -823,17 +823,22 @@
STRING clsName = layer->GetFeatureClassName();
STRING geomName = layer->GetFeatureGeometryName();
- STRING filterText = this->GenerateFilter(layer, clsName);
+ Ptr<MgStringCollection> filters = GenerateFilters(layer, clsName, 30000 /* magic number */);
+ INT32 numFilter = (NULL == filters)? 0 : filters->GetCount();
- Ptr<MgEnvelope> clsEnv = GetFeatureExtents(featureService, featureResId, clsName, filterText, geomName);
- if (env != NULL)
+ for (INT32 j = 0; j < numFilter; ++j)
{
- env->ExpandToInclude(clsEnv);
+ STRING filterText = filters->GetItem(j);
+ Ptr<MgEnvelope> clsEnv = GetFeatureExtents(featureService, featureResId, clsName, filterText, geomName);
+ if (env != NULL)
+ {
+ env->ExpandToInclude(clsEnv);
+ }
+ else
+ {
+ env = clsEnv.Detach();
+ }
}
- else
- {
- env = clsEnv.Detach();
- }
}
}
return env.Detach();
Modified: trunk/MgDev/Common/PlatformBase/MapLayer/SelectionBase.h
===================================================================
--- trunk/MgDev/Common/PlatformBase/MapLayer/SelectionBase.h 2013-01-05 07:13:04 UTC (rev 7289)
+++ trunk/MgDev/Common/PlatformBase/MapLayer/SelectionBase.h 2013-01-05 07:30:33 UTC (rev 7290)
@@ -396,6 +396,27 @@
///
STRING GenerateFilter(MgLayerBase* layer, CREFSTRING className);
+ //////////////////////////////////////////////////////////////////
+ /// \brief
+ /// Generates a collection of FDO filter strings for the selections
+ /// of the specified layer and class
+ ///
+ /// <!-- Syntax in .Net, Java, and PHP -->
+ /// \htmlinclude DotNetSyntaxTop.html
+ /// string GenerateFilters(MgLayerBase layer, string className, int selectionSize);
+ /// \htmlinclude SyntaxBottom.html
+ /// \htmlinclude JavaSyntaxTop.html
+ /// String GenerateFilters(MgLayerBase layer, String className, int selectionSize);
+ /// \htmlinclude SyntaxBottom.html
+ /// \htmlinclude PHPSyntaxTop.html
+ /// string GenerateFilters(MgLayerBase layer, string className, int selectionSize);
+ /// \htmlinclude SyntaxBottom.html
+ ///
+ /// \return
+ /// Returns the collection of FDO filter strings
+ ///
+ MgStringCollection* GenerateFilters(MgLayerBase* layer, CREFSTRING className, INT32 selectionSize);
+
///////////////////////////////////////////////////////////////////////////
/// \brief
/// Gets the extents of the selection set.
@@ -519,15 +540,6 @@
INTERNAL_API:
- //////////////////////////////////////////////////////////////////
- /// \brief
- /// Generate a collection of FDO filter strings for the selections
- /// of the specified layer and class.
- ///
- /// \return
- /// Collection of FDO filter strings.
- ///
- MgStringCollection* GenerateFilters(MgLayerBase* layer, CREFSTRING className, INT32 selectionSize);
//////////////////////////////////////////////////////////////////
/// \brief
Modified: trunk/MgDev/Web/src/mapviewernet/getselectedfeatures.aspx
===================================================================
--- trunk/MgDev/Web/src/mapviewernet/getselectedfeatures.aspx 2013-01-05 07:13:04 UTC (rev 7289)
+++ trunk/MgDev/Web/src/mapviewernet/getselectedfeatures.aspx 2013-01-05 07:30:33 UTC (rev 7290)
@@ -84,6 +84,7 @@
String locale;
CultureInfo culture;
System.Text.RegularExpressions.Regex regex;
+ const int RenderSelectionBatchSize = 30000; /* default filter size */
static NameValueCollection GetLayerPropertyMappings(MgResourceService resSvc, MgLayerBase layer)
{
@@ -312,66 +313,70 @@
}
query.AddFeatureProperty(geomName);
- String filter = selection.GenerateFilter(layer, className);
- query.SetFilter(filter);
+ MgStringCollection filters = selection.GenerateFilters(layer, className, RenderSelectionBatchSize);
+ for (int j = 0; j < filters.GetCount(); j++)
+ {
+ String filter = filters.GetItem(j);
+ query.SetFilter(filter);
- MgFeatureReader reader = layer.SelectFeatures(query);
+ MgFeatureReader reader = layer.SelectFeatures(query);
- MgClassDefinition clsDef = reader.GetClassDefinition();
- MgPropertyDefinitionCollection props = clsDef.GetProperties();
+ MgClassDefinition clsDef = reader.GetClassDefinition();
+ MgPropertyDefinitionCollection props = clsDef.GetProperties();
- while (reader.ReadNext())
- {
- Feature feat = new Feature(layerName);
- ZoomBox zoom = null;
-
- for (int k = 0; k < props.Count; k++)
+ while (reader.ReadNext())
{
- MgPropertyDefinition propDef = props[k];
- String propName = propDef.Name;
- int propType = reader.GetPropertyType(propName);
+ Feature feat = new Feature(layerName);
+ ZoomBox zoom = null;
- if (mappings[propName] != null || propType == MgPropertyType.Geometry)
+ for (int k = 0; k < props.Count; k++)
{
- String value = "";
- if (!reader.IsNull(propName))
+ MgPropertyDefinition propDef = props[k];
+ String propName = propDef.Name;
+ int propType = reader.GetPropertyType(propName);
+
+ if (mappings[propName] != null || propType == MgPropertyType.Geometry)
{
- if (propName == geomName)
+ String value = "";
+ if (!reader.IsNull(propName))
{
- MgByteReader agf = reader.GetGeometry(propName);
- MgGeometry geom = agfRW.Read(agf);
+ if (propName == geomName)
+ {
+ MgByteReader agf = reader.GetGeometry(propName);
+ MgGeometry geom = agfRW.Read(agf);
- MgEnvelope env = geom.Envelope();
- MgCoordinate ll = env.GetLowerLeftCoordinate();
- MgCoordinate ur = env.GetUpperRightCoordinate();
+ MgEnvelope env = geom.Envelope();
+ MgCoordinate ll = env.GetLowerLeftCoordinate();
+ MgCoordinate ur = env.GetUpperRightCoordinate();
- zoom = new ZoomBox();
- zoom.MinX = ll.X;
- zoom.MinY = ll.Y;
- zoom.MaxX = ur.X;
- zoom.MaxY = ur.Y;
+ zoom = new ZoomBox();
+ zoom.MinX = ll.X;
+ zoom.MinY = ll.Y;
+ zoom.MaxX = ur.X;
+ zoom.MaxY = ur.Y;
- feat.Zoom = zoom;
- }
- else
- {
- value = GetPropertyValueFromFeatureReader(reader, agfRW, propType, propName);
- }
+ feat.Zoom = zoom;
+ }
+ else
+ {
+ value = GetPropertyValueFromFeatureReader(reader, agfRW, propType, propName);
+ }
- if (mappings[propName] != null)
- {
- FeatureProperty fp = new FeatureProperty();
- fp.Name = mappings[propName];
- fp.Value = value;
+ if (mappings[propName] != null)
+ {
+ FeatureProperty fp = new FeatureProperty();
+ fp.Name = mappings[propName];
+ fp.Value = value;
- feat.AddProperty(fp);
+ feat.AddProperty(fp);
+ }
}
}
}
+ selectionSet.AddFeature(feat);
}
- selectionSet.AddFeature(feat);
+ reader.Close();
}
- reader.Close();
}
//Now output the selection set
More information about the mapguide-commits
mailing list