[prev in list] [next in list] [prev in thread] [next in thread]
List: mapguide-commits
Subject: [mapguide-commits] r6590 - trunk/MgDev/Common/Stylization
From: svn_mapguide () osgeo ! org
Date: 2012-04-25 21:20:13
Message-ID: 20120425212013.EE0343902F2 () trac ! osgeo ! org
[Download RAW message or body]
Author: waltweltonlair
Date: 2012-04-25 14:20:13 -0700 (Wed, 25 Apr 2012)
New Revision: 6590
Modified:
trunk/MgDev/Common/Stylization/DefaultStylizer.cpp
trunk/MgDev/Common/Stylization/DefaultStylizer.h
Log:
Fix #1986 (Stylization: allow retrieving visibility information)
Submit code fix from Dan S. (reviewed by me).
Modified: trunk/MgDev/Common/Stylization/DefaultStylizer.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/DefaultStylizer.cpp 2012-04-25 11:23:59 UTC (rev \
6589)
+++ trunk/MgDev/Common/Stylization/DefaultStylizer.cpp 2012-04-25 21:20:13 UTC (rev \
6590) @@ -539,3 +539,91 @@
delete m_pRasterAdapter;
m_pRasterAdapter = NULL;
}
+
+
+//////////////////////////////////////////////////////////////////////////////
+bool DefaultStylizer::HasValidScaleRange(MdfModel::VectorLayerDefinition* layer,
+ double mapScale)
+{
+ // look through the scale ranges to find a valid one
+ MdfModel::VectorScaleRangeCollection* scaleRanges = layer->GetScaleRanges();
+ MdfModel::VectorScaleRange* scaleRange = Stylizer::FindScaleRange(*scaleRanges, \
mapScale); +
+ return (NULL != scaleRange);
+}
+
+
+//////////////////////////////////////////////////////////////////////////////
+FdoFilter* DefaultStylizer::GetRulesFilter(MdfModel::VectorLayerDefinition* layer,
+ double \
mapScale) +{
+ // look through the scale ranges to find a valid one
+ MdfModel::VectorScaleRangeCollection* scaleRanges = layer->GetScaleRanges();
+ MdfModel::VectorScaleRange* scaleRange = Stylizer::FindScaleRange(*scaleRanges, \
mapScale); +
+ // no range -- fast return, the layer is invisible at this scale
+ if (NULL == scaleRange)
+ return NULL;
+
+ // extract all the composite styles once
+ MdfModel::FeatureTypeStyleCollection* ftsc = scaleRange->GetFeatureTypeStyles();
+ std::vector<CompositeTypeStyle*> compTypeStyles;
+ for (int i=0; i<ftsc->GetCount(); ++i)
+ {
+ MdfModel::FeatureTypeStyle* fts = ftsc->GetAt(i);
+ if (FeatureTypeStyleVisitor::DetermineFeatureTypeStyle(fts) == \
FeatureTypeStyleVisitor::ftsComposite) + \
compTypeStyles.push_back((CompositeTypeStyle*)fts); + }
+
+ size_t numTypeStyles = compTypeStyles.size();
+ _ASSERT(numTypeStyles > 0);
+ if (numTypeStyles == 0)
+ return NULL;
+
+ // Build a filter by combining the filters for each rule
+ MdfString filterstr;
+
+ for (size_t i=0; i<numTypeStyles; ++i)
+ {
+ CompositeTypeStyle* style = compTypeStyles.at(i);
+ RuleCollection* rulecoll = style->GetRules();
+ int nRules = rulecoll->GetCount();
+
+ for (int j=0; j<nRules; ++j)
+ {
+ CompositeRule* r = static_cast<CompositeRule*>(rulecoll->GetAt(j));
+ const MdfString& temp = r->GetFilter();
+
+ if (!temp.empty())
+ {
+ if (filterstr.empty())
+ filterstr.append(L"("); // start filter
+ else
+ filterstr.append(L" OR ");
+
+ filterstr.append(L"(");
+ filterstr.append(temp.c_str());
+ filterstr.append(L")");
+ }
+ }
+ }
+
+ // Output filter
+ FdoFilter* filter = NULL;
+
+ if (!filterstr.empty())
+ {
+ filterstr.append(L")"); // close filter
+
+ try
+ {
+ filter = FdoFilter::Parse(filterstr.c_str());
+ }
+ catch (FdoException* e)
+ {
+ e->Release();
+ }
+ }
+
+ return filter;
+}
Modified: trunk/MgDev/Common/Stylization/DefaultStylizer.h
===================================================================
--- trunk/MgDev/Common/Stylization/DefaultStylizer.h 2012-04-25 11:23:59 UTC (rev \
6589)
+++ trunk/MgDev/Common/Stylization/DefaultStylizer.h 2012-04-25 21:20:13 UTC (rev \
6590) @@ -68,6 +68,11 @@
STYLIZATION_API virtual void SetGeometryAdapter(FdoGeometryType type, \
GeometryAdapter* stylizer);
+ STYLIZATION_API virtual bool HasValidScaleRange(MdfModel::VectorLayerDefinition* \
layer, + double mapScale);
+
+ STYLIZATION_API virtual FdoFilter* \
GetRulesFilter(MdfModel::VectorLayerDefinition* layer, + \
double mapScale); private:
int StylizeVLHelper(MdfModel::VectorLayerDefinition* layer,
MdfModel::VectorScaleRange* scaleRange,
_______________________________________________
mapguide-commits mailing list
mapguide-commits@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapguide-commits
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic