[mapguide-commits] r4254 -
sandbox/rfc60/MgDev/Server/src/Services/Mapping
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Tue Sep 22 19:17:10 EDT 2009
Author: uvlite
Date: 2009-09-22 19:17:10 -0400 (Tue, 22 Sep 2009)
New Revision: 4254
Modified:
sandbox/rfc60/MgDev/Server/src/Services/Mapping/MappingUtil.cpp
Log:
rfc60 add code to StylizeLayers to parse color defs from VectorScaleRange and store in runtime map
Modified: sandbox/rfc60/MgDev/Server/src/Services/Mapping/MappingUtil.cpp
===================================================================
--- sandbox/rfc60/MgDev/Server/src/Services/Mapping/MappingUtil.cpp 2009-09-22 23:16:38 UTC (rev 4253)
+++ sandbox/rfc60/MgDev/Server/src/Services/Mapping/MappingUtil.cpp 2009-09-22 23:17:10 UTC (rev 4254)
@@ -30,11 +30,18 @@
#include "StylizationUtil.h"
#include "Fdo.h"
+#include <algorithm>
+
//For logging
#include "ServerManager.h"
#include "LogManager.h"
#include "LogDetail.h"
+typedef std::list<const MdfString> STRCOLORLIST;
+typedef STRCOLORLIST* PSTRCOLORLIST;
+
+#define myassert(COND,L,F) if (!(COND)){ printf ("(%d) failed assertion in %d %s", GetCurrentThreadId(), L,F); throw new exception();}
+
#ifndef _WIN32
#define _wcsnicmp wcsncasecmp
@@ -48,7 +55,7 @@
}
#endif
-
+///----------------------------------------------------------------------------------------
MdfModel::MapDefinition* MgMappingUtil::GetMapDefinition(MgResourceService* svcResource, MgResourceIdentifier* resId)
{
//get and parse the mapdef
@@ -76,7 +83,7 @@
return mdef;
}
-
+///----------------------------------------------------------------------------------------
RSMgFeatureReader* MgMappingUtil::ExecuteFeatureQuery(MgFeatureService* svcFeature,
RS_Bounds& extent,
MdfModel::VectorLayerDefinition* vl,
@@ -235,7 +242,7 @@
return new RSMgFeatureReader(rdr.p, svcFeature, featResId.p, options, vl->GetGeometry());
}
-
+///----------------------------------------------------------------------------------------
RSMgFeatureReader* MgMappingUtil::ExecuteRasterQuery(MgFeatureService* svcFeature,
RS_Bounds& extent,
MdfModel::GridLayerDefinition* gl,
@@ -346,7 +353,8 @@
return new RSMgFeatureReader(rdr.p, svcFeature, featResId.p, options, L"clipped_raster");
}
-
+///----------------------------------------------------------------------------------------
+/// this is called by the MgServerRenderingService::RenderMapInternal to render the layers
void MgMappingUtil::StylizeLayers(MgResourceService* svcResource,
MgFeatureService* svcFeature,
MgDrawingService* svcDrawing,
@@ -563,9 +571,39 @@
dr->StartLayer(&layerInfo, &fcinfo);
ds->StylizeVectorLayer(vl, dr, rsReader, xformer, scale, NULL, NULL);
dr->EndLayer();
+ //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ // COLORPALETTE CODE from UV for Ticket #813
+ // add the colors from this scaleRange and vectorlayer to the map colors
+ // (overrideFilters == NULL could tells us
+ // that we have been called for rendering a map and not for selection)
+ try {
+ // the map object owns the color list so get a pointer from there
+ PSTRCOLORLIST pStringColorPalette = map->GetColorPalette();
+ PSTRCOLORLIST vLayerColors = scaleRange->GetUsedColorList();
+ if (!vLayerColors->empty())
+ {
+ assert (pStringColorPalette);
+ // add the vectorLayer's Colors to the map's color list
+ STRCOLORLIST::iterator it = vLayerColors->begin();
+ for(; it != vLayerColors->end(); it++)
+ { // uppercase the colorcodes (FFABDEFF) and filter empty strings
+ if (*it == L"") continue;
+ STRING upc = *it;
+ std::transform( upc.begin(), upc.end(), upc.begin(), towupper);
+ pStringColorPalette->push_back(upc);
+ }
+ assert (pStringColorPalette == map->GetColorPalette());
+ // the property setter canonicalizes the palette
+ map->SetColorPalette(pStringColorPalette);
+ }
+ } catch (exception e) {
+ ACE_DEBUG((LM_DEBUG, L"(%t) %w caught in MappingUtil.ColorPaletteGeneration\n", e.what()));
+ throw e;
+ }
+ //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
}
}
- else
+ else // not scaleRange
{
#ifdef _DEBUG
printf(" StylizeLayers() **NOT Stylizing - NO SCALE RANGE** Name:%S\n", (mapLayer->GetName()).c_str());
@@ -807,7 +845,8 @@
STRING stackTrace = exception->GetStackTrace(locale);
MG_LOG_EXCEPTION_ENTRY(message.c_str(), stackTrace.c_str());
-#ifdef _DEBUG
+
+#if defined(_DEBUG) || defined(_DEBUG_PNG8)
STRING details = mgException->GetDetails(locale);
wstring err = L"\n %t Error during stylization of layer ";
@@ -818,8 +857,10 @@
err += L"\n";
ACE_DEBUG( (LM_DEBUG, err.c_str()) );
#endif
- }
- }
+ /// this exception can be thrown or not depending on a serverconfig setting
+ // throw exception;
+ } // if exception
+ } // for all layers
#ifdef _DEBUG
printf("StylizeLayers() **MAPDONE** Layers:%d Total Time:%6.4f (s)\n\n", layers->GetCount(), (GetTickCount()-dwStart)/1000.0);
@@ -828,7 +869,7 @@
TransformCache::Clear(transformCache);
}
-
+///----------------------------------------------------------------------------------------
// When rendering a tile, we need to compute the extent used to determine
// which features to render into it. Features in adjacent tiles, but not
// in the current tile, will potentially draw in this tile due to their
@@ -1082,7 +1123,7 @@
return maxOffsetMCS;
}
-
+///----------------------------------------------------------------------------------------
// draws a given feature type style into an image
MgByteReader* MgMappingUtil::DrawFTS(MgResourceService* svcResource,
MdfModel::FeatureTypeStyle* fts,
@@ -1134,7 +1175,7 @@
return ccPoly->Envelope();
}
-
+///----------------------------------------------------------------------------------------
// returns an MgPolygon from a given envelope
MgPolygon* MgMappingUtil::GetPolygonFromEnvelope(MgEnvelope* env)
{
@@ -1154,7 +1195,7 @@
return new MgPolygon(outer, NULL);
}
-
+///----------------------------------------------------------------------------------------
void MgMappingUtilExceptionTrap(FdoException* except, int line, wchar_t* file)
{
MG_TRY()
@@ -1184,7 +1225,7 @@
MG_LOG_WARNING_ENTRY(MgServiceType::MappingService, message.c_str(), stackTrace.c_str());
}
-
+///----------------------------------------------------------------------------------------
void MgMappingUtil::InitializeStylizerCallback()
{
SetStylizerExceptionCallback(&MgMappingUtilExceptionTrap);
More information about the mapguide-commits
mailing list