[mapguide-commits] r6113 - in trunk/MgDev:
Common/MapGuideCommon/Services Common/MdfParser
Server/src/Services/Profiling Server/src/Services/Rendering
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Mon Sep 5 03:37:53 EDT 2011
Author: liuar
Date: 2011-09-05 00:37:53 -0700 (Mon, 05 Sep 2011)
New Revision: 6113
Modified:
trunk/MgDev/Common/MapGuideCommon/Services/ProxyRenderingService.cpp
trunk/MgDev/Common/MapGuideCommon/Services/ProxyRenderingService.h
trunk/MgDev/Common/MapGuideCommon/Services/RenderingDefs.h
trunk/MgDev/Common/MapGuideCommon/Services/RenderingService.h
trunk/MgDev/Common/MdfParser/IOProfileRenderMapResult.cpp
trunk/MgDev/Server/src/Services/Profiling/ServerProfilingService.cpp
trunk/MgDev/Server/src/Services/Rendering/OpRenderDynamicOverlay.cpp
trunk/MgDev/Server/src/Services/Rendering/OpRenderMap.cpp
trunk/MgDev/Server/src/Services/Rendering/RenderingOperationFactory.cpp
trunk/MgDev/Server/src/Services/Rendering/ServerRenderingService.cpp
trunk/MgDev/Server/src/Services/Rendering/ServerRenderingService.h
Log:
The RFC 110 Profiling Service (VII).
Implement the ProfileRenderMap API in Server.
1. Add a new internal used API for RenderingService to accept the profile result parameter
2. Inject profile code into ServerRenderingService.
Modified: trunk/MgDev/Common/MapGuideCommon/Services/ProxyRenderingService.cpp
===================================================================
--- trunk/MgDev/Common/MapGuideCommon/Services/ProxyRenderingService.cpp 2011-09-02 06:32:13 UTC (rev 6112)
+++ trunk/MgDev/Common/MapGuideCommon/Services/ProxyRenderingService.cpp 2011-09-05 07:37:53 UTC (rev 6113)
@@ -849,10 +849,10 @@
MgCommand cmd;
cmd.ExecuteCommand(m_connProp, // Connection
MgCommand::knObject, // Return type expected
- MgRenderingServiceOpId::RenderDynamicOverlay, // Command Code
+ MgRenderingServiceOpId::RenderDynamicOverlay2, // Command Code
4, // No of arguments
Rendering_Service, // Service Id
- BUILD_VERSION(2,1,0), // Operation version
+ BUILD_VERSION(2,4,0), // Operation version
MgCommand::knObject, map, // Argument#1
MgCommand::knObject, selection, // Argument#2
MgCommand::knObject, options, // Argument#3
@@ -863,3 +863,78 @@
return (MgByteReader*)cmd.GetReturnValue().val.m_obj;
}
+
+/////////////////////////////////////////////////////////////////
+/// \brief
+/// Renders the specified MgMap with specified parameters.
+/// Profile result will be recorded.
+///
+/// \param map
+/// Input
+/// map object containing current state of map.
+/// \param selection
+/// Input
+/// map feature selection. Specifies the selected features on the map
+/// \param center
+/// Input
+/// map center point. Specifies the center point for the map
+/// \param scale
+/// Input
+/// map scale. Specifies the scale for the map
+/// \param width
+/// Input
+/// image width. Specifies the image width in pixels
+/// \param height
+/// Input
+/// image height. Specifies the image height in pixels
+/// \param backgroundColor
+/// Input
+/// background color. Specifies the map background color
+/// \param format
+/// Input
+/// image format. Defines the format of the resulting image
+/// \param bKeepSelection
+/// Input
+/// true if you want to keep the selection
+/// \param profileRenderMapResult
+/// Input&Output
+/// profile result of rendering map
+///
+/// \return
+/// A byte reader containing the rendered image
+///
+MgByteReader* MgProxyRenderingService::RenderMap(
+ MgMap* map,
+ MgSelection* selection,
+ MgCoordinate* center,
+ double scale,
+ INT32 width,
+ INT32 height,
+ MgColor* backgroundColor,
+ CREFSTRING format,
+ bool bKeepSelection,
+ ProfileRenderMapResult* profileRenderMapResult)
+{
+ MgCommand cmd;
+ cmd.ExecuteCommand(m_connProp, // Connection
+ MgCommand::knObject, // Return type expected
+ MgRenderingServiceOpId::RenderMap5, // Command Code
+ 10, // No of arguments
+ Rendering_Service, // Service Id
+ BUILD_VERSION(2,4,0), // Operation version
+ MgCommand::knObject, map, // Argument#1
+ MgCommand::knObject, selection, // Argument#2
+ MgCommand::knObject, center, // Argument#3
+ MgCommand::knDouble, scale, // Argument#4
+ MgCommand::knInt32, width, // Argument#5
+ MgCommand::knInt32, height, // Argument#6
+ MgCommand::knObject, backgroundColor, // Argument#7
+ MgCommand::knString, &format, // Argument#8
+ MgCommand::knInt8, (INT8)bKeepSelection, // Argument#9
+ MgCommand::knObject, profileRenderMapResult, // Argument#10
+ MgCommand::knNone); // End of arguments
+
+ SetWarning(cmd.GetWarningObject());
+
+ return (MgByteReader*)cmd.GetReturnValue().val.m_obj;
+}
Modified: trunk/MgDev/Common/MapGuideCommon/Services/ProxyRenderingService.h
===================================================================
--- trunk/MgDev/Common/MapGuideCommon/Services/ProxyRenderingService.h 2011-09-02 06:32:13 UTC (rev 6112)
+++ trunk/MgDev/Common/MapGuideCommon/Services/ProxyRenderingService.h 2011-09-05 07:37:53 UTC (rev 6113)
@@ -618,6 +618,57 @@
MgRenderingOptions* options,
ProfileRenderMapResult* profileRenderMapResult);
+ /////////////////////////////////////////////////////////////////
+ /// \brief
+ /// Renders the specified MgMap with specified parameters.
+ /// Profile result will be recorded.
+ ///
+ /// \param map
+ /// Input
+ /// map object containing current state of map.
+ /// \param selection
+ /// Input
+ /// map feature selection. Specifies the selected features on the map
+ /// \param center
+ /// Input
+ /// map center point. Specifies the center point for the map
+ /// \param scale
+ /// Input
+ /// map scale. Specifies the scale for the map
+ /// \param width
+ /// Input
+ /// image width. Specifies the image width in pixels
+ /// \param height
+ /// Input
+ /// image height. Specifies the image height in pixels
+ /// \param backgroundColor
+ /// Input
+ /// background color. Specifies the map background color
+ /// \param format
+ /// Input
+ /// image format. Defines the format of the resulting image
+ /// \param bKeepSelection
+ /// Input
+ /// true if you want to keep the selection
+ /// \param profileRenderMapResult
+ /// Input&Output
+ /// profile result of rendering map
+ ///
+ /// \return
+ /// A byte reader containing the rendered image
+ ///
+ virtual MgByteReader* RenderMap(
+ MgMap* map,
+ MgSelection* selection,
+ MgCoordinate* center,
+ double scale,
+ INT32 width,
+ INT32 height,
+ MgColor* backgroundColor,
+ CREFSTRING format,
+ bool bKeepSelection,
+ ProfileRenderMapResult* profileRenderMapResult);
+
protected:
//////////////////////////////////////////////////////////////////
Modified: trunk/MgDev/Common/MapGuideCommon/Services/RenderingDefs.h
===================================================================
--- trunk/MgDev/Common/MapGuideCommon/Services/RenderingDefs.h 2011-09-02 06:32:13 UTC (rev 6112)
+++ trunk/MgDev/Common/MapGuideCommon/Services/RenderingDefs.h 2011-09-05 07:37:53 UTC (rev 6113)
@@ -37,6 +37,8 @@
static const int RenderDynamicOverlay = 0x1111E909;
static const int QueryFeatureProperties = 0x1111E90A;
static const int RenderMap4 = 0x1111E90B;
+ static const int RenderDynamicOverlay2 = 0x1111E90C;
+ static const int RenderMap5 = 0x1111E90D;
};
/// \endcond
Modified: trunk/MgDev/Common/MapGuideCommon/Services/RenderingService.h
===================================================================
--- trunk/MgDev/Common/MapGuideCommon/Services/RenderingService.h 2011-09-02 06:32:13 UTC (rev 6112)
+++ trunk/MgDev/Common/MapGuideCommon/Services/RenderingService.h 2011-09-05 07:37:53 UTC (rev 6113)
@@ -617,6 +617,57 @@
MgRenderingOptions* options,
ProfileRenderMapResult* profileRenderMapResult) = 0;
+ /////////////////////////////////////////////////////////////////
+ /// \brief
+ /// Renders the specified MgMap with specified parameters.
+ /// Profile result will be recorded.
+ ///
+ /// \param map
+ /// Input
+ /// map object containing current state of map.
+ /// \param selection
+ /// Input
+ /// map feature selection. Specifies the selected features on the map
+ /// \param center
+ /// Input
+ /// map center point. Specifies the center point for the map
+ /// \param scale
+ /// Input
+ /// map scale. Specifies the scale for the map
+ /// \param width
+ /// Input
+ /// image width. Specifies the image width in pixels
+ /// \param height
+ /// Input
+ /// image height. Specifies the image height in pixels
+ /// \param backgroundColor
+ /// Input
+ /// background color. Specifies the map background color
+ /// \param format
+ /// Input
+ /// image format. Defines the format of the resulting image
+ /// \param bKeepSelection
+ /// Input
+ /// true if you want to keep the selection
+ /// \param profileRenderMapResult
+ /// Input&Output
+ /// profile result of rendering map
+ ///
+ /// \return
+ /// A byte reader containing the rendered image
+ ///
+ virtual MgByteReader* RenderMap(
+ MgMap* map,
+ MgSelection* selection,
+ MgCoordinate* center,
+ double scale,
+ INT32 width,
+ INT32 height,
+ MgColor* backgroundColor,
+ CREFSTRING format,
+ bool bKeepSelection,
+ ProfileRenderMapResult* profileRenderMapResult) = 0;
+
protected:
/////////////////////////////////////////////////////////////////
Modified: trunk/MgDev/Common/MdfParser/IOProfileRenderMapResult.cpp
===================================================================
--- trunk/MgDev/Common/MdfParser/IOProfileRenderMapResult.cpp 2011-09-02 06:32:13 UTC (rev 6112)
+++ trunk/MgDev/Common/MdfParser/IOProfileRenderMapResult.cpp 2011-09-05 07:37:53 UTC (rev 6113)
@@ -85,7 +85,7 @@
void IOProfileRenderMapResult::Write(MdfStream& fd, ProfileRenderMapResult* profileRenderMapResult, Version* version, MgTab& tab)
{
ProfileResult::ProfileResultType type = profileRenderMapResult->GetProfileResultType();
- if (ProfileResult::ProfileRenderMap)
+ if (ProfileResult::ProfileRenderMap == type)
fd << tab.tab() << startStr(sProfileRenderMapResult) << std::endl;
else //ProfileResult::ProfileRenderDynamicOverlay
fd << tab.tab() << startStr(sProfileRenderDynamicOverlayResult) << std::endl;
Modified: trunk/MgDev/Server/src/Services/Profiling/ServerProfilingService.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Profiling/ServerProfilingService.cpp 2011-09-02 06:32:13 UTC (rev 6112)
+++ trunk/MgDev/Server/src/Services/Profiling/ServerProfilingService.cpp 2011-09-05 07:37:53 UTC (rev 6113)
@@ -58,14 +58,13 @@
MG_TRY()
- // selection is an optional and nullable parameter
- if (NULL == map || NULL == options)
+ if (NULL == map)
throw new MgNullArgumentException(L"MgServerProfilingService.ProfileRenderDynamicOverlay", __LINE__, __WFILE__, NULL, L"", NULL);
auto_ptr<ProfileRenderMapResult> pPRMResult; // a pointer points to Profile Render Map Result
pPRMResult.reset(new ProfileRenderMapResult());
- // Start to profile the RenderDynamicOverlay process
+ // Start to profile the ProfileRenderDynamicOverlay process
double renderMapStart = MgTimerUtil::GetTime();
m_svcRendering->RenderDynamicOverlay(map, selection, options, pPRMResult.get());
double renderMapEnd = MgTimerUtil::GetTime();
@@ -97,17 +96,32 @@
bool bKeepSelection)
{
Ptr<MgByteReader> ret;
+
+ MG_TRY()
- //MG_TRY()
- //MapProfileResult* mapProfileResult = new MapProfileResult();
- //m_svcRendering->SetProfileResult(mapProfileResult);
- //ret = m_svcRendering->RenderMap(map,selection,center,scale,width,height,backgroundColor,format,bKeepSelection);
- //
- //Version mapProfileResultVersion23(2, 3, 0); // MapGuide 2012
- //MdfParser::SAX2Parser parser;
- //parser.WriteToFile("c:\\map.xml",mapProfileResult,&mapProfileResultVersion23);
- //MG_CATCH_AND_THROW(L"MgServerProfilingService.ProfileRenderMap")
+ if (NULL == map)
+ throw new MgNullArgumentException(L"MgServerProfilingService.ProfileRenderMap", __LINE__, __WFILE__, NULL, L"", NULL);
+ auto_ptr<ProfileRenderMapResult> pPRMResult; // a pointer points to Profile Render Map Result
+ pPRMResult.reset(new ProfileRenderMapResult());
+
+ // Start to profile the ProfileRenderMap process
+ double renderMapStart = MgTimerUtil::GetTime();
+ m_svcRendering->RenderMap(map, selection, center, scale, width, height, backgroundColor, format, bKeepSelection, pPRMResult.get());
+ double renderMapEnd = MgTimerUtil::GetTime();
+
+ pPRMResult->SetRenderTime(renderMapEnd - renderMapStart);
+ pPRMResult->SetProfileResultType(ProfileResult::ProfileRenderMap);
+
+ // Serialize the ProfileRenderMapResult to xml
+ MdfParser::SAX2Parser parser;
+ auto_ptr<Version> version;
+ version.reset(new Version(2,4,0));
+ string content = parser.SerializeToXML(pPRMResult.get(),version.get());
+ ret = new MgByteReader(MgUtil::MultiByteToWideChar(content), MgMimeType::Xml);
+
+ MG_CATCH_AND_THROW(L"MgServerProfilingService.ProfileRenderMap")
+
return ret.Detach();
}
Modified: trunk/MgDev/Server/src/Services/Rendering/OpRenderDynamicOverlay.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Rendering/OpRenderDynamicOverlay.cpp 2011-09-02 06:32:13 UTC (rev 6112)
+++ trunk/MgDev/Server/src/Services/Rendering/OpRenderDynamicOverlay.cpp 2011-09-05 07:37:53 UTC (rev 6113)
@@ -105,6 +105,7 @@
auto_ptr<ProfileRenderMapResult> pProfileRenderMapResult;
pProfileRenderMapResult.reset((ProfileRenderMapResult*)m_stream->GetObject());
+
BeginExecution();
MG_LOG_OPERATION_MESSAGE_PARAMETERS_START();
Modified: trunk/MgDev/Server/src/Services/Rendering/OpRenderMap.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Rendering/OpRenderMap.cpp 2011-09-02 06:32:13 UTC (rev 6112)
+++ trunk/MgDev/Server/src/Services/Rendering/OpRenderMap.cpp 2011-09-05 07:37:53 UTC (rev 6113)
@@ -245,6 +245,69 @@
EndExecution(byteReader);
}
+ else if (10 == m_packet.m_NumArguments)
+ {
+ Ptr<MgMap> map = (MgMap*)m_stream->GetObject();
+ Ptr<MgResourceIdentifier> resource = map->GetResourceId();
+ map->SetDelayedLoadResourceService(m_resourceService);
+
+ Ptr<MgSelection> selection = (MgSelection*)m_stream->GetObject();
+ if(selection)
+ selection->SetMap(map);
+
+ Ptr<MgCoordinate> center = (MgCoordinate*)m_stream->GetObject();
+
+ double scale = 0.0;
+ m_stream->GetDouble(scale);
+
+ INT32 width = 0;
+ m_stream->GetInt32(width);
+
+ INT32 height = 0;
+ m_stream->GetInt32(height);
+
+ Ptr<MgColor> color = (MgColor*)m_stream->GetObject();
+
+ STRING format;
+ m_stream->GetString(format);
+
+ bool bKeepSelection = false;
+ m_stream->GetBoolean(bKeepSelection);
+
+ auto_ptr<ProfileRenderMapResult> pProfileRenderMapResult;
+ pProfileRenderMapResult.reset((ProfileRenderMapResult*)m_stream->GetObject());
+
+ BeginExecution();
+
+ MG_LOG_OPERATION_MESSAGE_PARAMETERS_START();
+ MG_LOG_OPERATION_MESSAGE_ADD_STRING((NULL == resource) ? L"MgResourceIdentifier" : resource->ToString().c_str());
+ MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
+ MG_LOG_OPERATION_MESSAGE_ADD_STRING(L"MgSelection");
+ MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
+ MG_LOG_OPERATION_MESSAGE_ADD_STRING(L"MgCoordinate");
+ MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
+ MG_LOG_OPERATION_MESSAGE_ADD_DOUBLE(scale);
+ MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
+ MG_LOG_OPERATION_MESSAGE_ADD_INT32(width);
+ MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
+ MG_LOG_OPERATION_MESSAGE_ADD_INT32(height);
+ MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
+ MG_LOG_OPERATION_MESSAGE_ADD_STRING(L"MgColor");
+ MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
+ MG_LOG_OPERATION_MESSAGE_ADD_STRING(format.c_str());
+ MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
+ MG_LOG_OPERATION_MESSAGE_ADD_BOOL(bKeepSelection);
+ MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
+ MG_LOG_OPERATION_MESSAGE_ADD_STRING(L"ProfileRenderMapResult");
+ MG_LOG_OPERATION_MESSAGE_PARAMETERS_END();
+
+ Validate();
+
+ Ptr<MgByteReader> byteReader =
+ m_service->RenderMap(map, selection, center, scale, width, height, color, format, bKeepSelection, pProfileRenderMapResult.get());
+
+ EndExecution(byteReader);
+ }
else
{
MG_LOG_OPERATION_MESSAGE_PARAMETERS_START();
Modified: trunk/MgDev/Server/src/Services/Rendering/RenderingOperationFactory.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Rendering/RenderingOperationFactory.cpp 2011-09-02 06:32:13 UTC (rev 6112)
+++ trunk/MgDev/Server/src/Services/Rendering/RenderingOperationFactory.cpp 2011-09-05 07:37:53 UTC (rev 6113)
@@ -85,6 +85,17 @@
L"MgRenderingOperationFactory.GetOperation", __LINE__, __WFILE__, NULL, L"", NULL);
}
break;
+ case MgRenderingServiceOpId::RenderDynamicOverlay2:
+ switch (VERSION_NO_PHASE(operationVersion))
+ {
+ case VERSION_SUPPORTED(2,4):
+ handler.reset(new MgOpRenderDynamicOverlay());
+ break;
+ default:
+ throw new MgInvalidOperationVersionException(
+ L"MgRenderingOperationFactory.GetOperation", __LINE__, __WFILE__, NULL, L"", NULL);
+ }
+ break;
case MgRenderingServiceOpId::RenderMap1:
switch (VERSION_NO_PHASE(operationVersion))
@@ -135,6 +146,18 @@
}
break;
+ case MgRenderingServiceOpId::RenderMap5:
+ switch (VERSION_NO_PHASE(operationVersion))
+ {
+ case VERSION_SUPPORTED(2,4):
+ handler.reset(new MgOpRenderMap());
+ break;
+ default:
+ throw new MgInvalidOperationVersionException(
+ L"MgRenderingOperationFactory.GetOperation", __LINE__, __WFILE__, NULL, L"", NULL);
+ }
+ break;
+
case MgRenderingServiceOpId::QueryFeatures:
switch (VERSION_NO_PHASE(operationVersion))
{
Modified: trunk/MgDev/Server/src/Services/Rendering/ServerRenderingService.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Rendering/ServerRenderingService.cpp 2011-09-02 06:32:13 UTC (rev 6112)
+++ trunk/MgDev/Server/src/Services/Rendering/ServerRenderingService.cpp 2011-09-05 07:37:53 UTC (rev 6113)
@@ -606,7 +606,7 @@
///////////////////////////////////////////////////////////////////////////////
-// default arguments bClip = false
+// default arguments bClip = false pProfileRenderMapResult = NULL
MgByteReader* MgServerRenderingService::RenderMap(MgMap* map,
MgSelection* selection,
MgCoordinate* center,
@@ -620,6 +620,21 @@
return RenderMap(map, selection, center, scale, width, height, backgroundColor, format, bKeepSelection, false);
}
+///////////////////////////////////////////////////////////////////////////////
+// default arguments bClip = false
+MgByteReader* MgServerRenderingService::RenderMap(MgMap* map,
+ MgSelection* selection,
+ MgCoordinate* center,
+ double scale,
+ INT32 width,
+ INT32 height,
+ MgColor* backgroundColor,
+ CREFSTRING format,
+ bool bKeepSelection,
+ ProfileRenderMapResult* pPRMResult)
+{
+ return RenderMap(map, selection, center, scale, width, height, backgroundColor, format, bKeepSelection, false, pPRMResult);
+}
///////////////////////////////////////////////////////////////////////////////
// render map around center point in given scale
@@ -634,7 +649,8 @@
MgColor* backgroundColor,
CREFSTRING format,
bool bKeepSelection,
- bool bClip)
+ bool bClip,
+ ProfileRenderMapResult* pPRMResult)
{
Ptr<MgByteReader> ret;
@@ -685,8 +701,19 @@
// initialize the appropriate map renderer
auto_ptr<SE_Renderer> dr(CreateRenderer(width, height, bgcolor, bClip));
+ if(NULL != pPRMResult)
+ {
+ Ptr<MgResourceIdentifier> mapResId = map->GetResourceId();
+ pPRMResult->SetResourceId(mapResId ? mapResId->ToString() : L"");
+ pPRMResult->SetScale(scale);
+ pPRMResult->SetExtents(Box2D(b.minx, b.miny, b.maxx, b.maxy));
+ Ptr<MgLayerCollection> layers = map->GetLayers();
+ pPRMResult->SetLayerCount(layers->GetCount());
+ pPRMResult->SetCoordinateSystem(map->GetMapSRS());
+ }
+
// call the internal helper API to do all the stylization overhead work
- ret = RenderMapInternal(map, selection, NULL, dr.get(), width, height, width, height, format, scale, b, false, bKeepSelection, true);
+ ret = RenderMapInternal(map, selection, NULL, dr.get(), width, height, width, height, format, scale, b, false, bKeepSelection, true, pPRMResult);
MG_CATCH_AND_THROW(L"MgServerRenderingService.RenderMap")
@@ -859,7 +886,7 @@
{
MgRenderingOptions options(format, MgRenderingOptions::RenderSelection |
MgRenderingOptions::RenderLayers | (bKeepSelection? MgRenderingOptions::KeepSelection : 0), NULL);
- return RenderMapInternal(map, selection, roLayers, dr, drawWidth, drawHeight, saveWidth, saveHeight, scale, b, expandExtents, &options, renderWatermark);
+ return RenderMapInternal(map, selection, roLayers, dr, drawWidth, drawHeight, saveWidth, saveHeight, scale, b, expandExtents, &options, renderWatermark, pPRMResult);
}
///////////////////////////////////////////////////////////////////////////////
@@ -1051,17 +1078,6 @@
if (renderWatermark && (behavior & MgRenderingOptions::RenderLayers) && map->GetWatermarkUsage() != 0)
{
- ProfileRenderWatermarksResult* pPRWsResult = NULL; // pointer points to Profile Render Watermarks Result
-
- if(NULL != pPRMResult)
- {
- pPRWsResult = new ProfileRenderWatermarksResult();
- pPRMResult->AdoptProfileRenderWatermarksResult(pPRWsResult);
-
- // Set the start time of stylizing watermarks
- pPRWsResult->SetRenderTime(MgTimerUtil::GetTime());
- }
-
// Rendering watermark only when:
// 1. rendering layers
// 2. not set renderWatermark to false (not render tile)
@@ -1154,122 +1170,136 @@
MgStringCollection watermarkDefinitions; // Loaded watermark definition
MgStringCollection failLoadedIds; // ID list of failed in loading resource
- for (int i=watermarkInstances.GetCount()-1; i>=0; i--)
+ if(0 != watermarkInstances.GetCount())
{
- WatermarkInstance* instance = watermarkInstances.GetAt(i);
- STRING resourceId = instance->GetResourceId();
- WatermarkDefinition* wdef = NULL;
- MG_TRY()
- for(int j = 0; j < watermarkIds.GetCount(); j++)
- {
- if(resourceId == watermarkIds.GetItem(j))
+ ProfileRenderWatermarksResult* pPRWsResult = NULL; // pointer points to Profile Render Watermarks Result
+
+ if(NULL != pPRMResult)
+ {
+ pPRWsResult = new ProfileRenderWatermarksResult();
+ pPRMResult->AdoptProfileRenderWatermarksResult(pPRWsResult);
+
+ // Set the start time of stylizing watermarks
+ pPRWsResult->SetRenderTime(MgTimerUtil::GetTime());
+ }
+
+ for (int i=watermarkInstances.GetCount()-1; i>=0; i--)
+ {
+ WatermarkInstance* instance = watermarkInstances.GetAt(i);
+ STRING resourceId = instance->GetResourceId();
+ WatermarkDefinition* wdef = NULL;
+ MG_TRY()
+ for(int j = 0; j < watermarkIds.GetCount(); j++)
{
- wdef = MgWatermark::GetWatermarkDefinition(watermarkDefinitions.GetItem(j));
- break;
+ if(resourceId == watermarkIds.GetItem(j))
+ {
+ wdef = MgWatermark::GetWatermarkDefinition(watermarkDefinitions.GetItem(j));
+ break;
+ }
}
- }
- if(NULL != pPRWsResult)
- {
- ProfileRenderWatermarkResult* pPRWResult = new ProfileRenderWatermarkResult(); // pointer points to Render Watermark Result
+ if(NULL != pPRWsResult)
+ {
+ ProfileRenderWatermarkResult* pPRWResult = new ProfileRenderWatermarkResult(); // pointer points to Render Watermark Result
- // Set the start time of stylizing watermark
- pPRWResult->SetRenderTime(MgTimerUtil::GetTime());
+ // Set the start time of stylizing watermark
+ pPRWResult->SetRenderTime(MgTimerUtil::GetTime());
- ProfileRenderWatermarkResultCollection* pPRWResultColl = pPRWsResult->GetProfileRenderWatermarkResults();
- pPRWResultColl->Adopt(pPRWResult);
- }
+ ProfileRenderWatermarkResultCollection* pPRWResultColl = pPRWsResult->GetProfileRenderWatermarkResults();
+ pPRWResultColl->Adopt(pPRWResult);
+ }
- if(wdef == NULL)
- {
- Ptr<MgResourceIdentifier> resId = new MgResourceIdentifier(resourceId);
- Ptr<MgByteReader> reader = m_svcResource->GetResourceContent(resId);
- STRING content = reader->ToString();
- watermarkIds.Add(resourceId);
- watermarkDefinitions.Add(content);
- wdef = MgWatermark::GetWatermarkDefinition(content);
- }
- assert(wdef != NULL);
- if (instance->GetPositionOverride())
- {
- wdef->AdoptPosition(instance->OrphanPositionOverride());
- }
- if (instance->GetAppearanceOverride())
- {
- wdef->AdoptAppearance(instance->OrphanAppearanceOverride());
- }
- ds.StylizeWatermark(dr, wdef, drawWidth, drawHeight, saveWidth, saveHeight);
+ if(wdef == NULL)
+ {
+ Ptr<MgResourceIdentifier> resId = new MgResourceIdentifier(resourceId);
+ Ptr<MgByteReader> reader = m_svcResource->GetResourceContent(resId);
+ STRING content = reader->ToString();
+ watermarkIds.Add(resourceId);
+ watermarkDefinitions.Add(content);
+ wdef = MgWatermark::GetWatermarkDefinition(content);
+ }
+ assert(wdef != NULL);
+ if (instance->GetPositionOverride())
+ {
+ wdef->AdoptPosition(instance->OrphanPositionOverride());
+ }
+ if (instance->GetAppearanceOverride())
+ {
+ wdef->AdoptAppearance(instance->OrphanAppearanceOverride());
+ }
+ ds.StylizeWatermark(dr, wdef, drawWidth, drawHeight, saveWidth, saveHeight);
- if(NULL != pPRWsResult)
- {
- ProfileRenderWatermarkResultCollection* pPRWResultColl = pPRWsResult->GetProfileRenderWatermarkResults();
- ProfileRenderWatermarkResult* pPRWResult = pPRWResultColl->GetAt(pPRWResultColl->GetCount()-1); // TODO: check index
+ if(NULL != pPRWsResult)
+ {
+ ProfileRenderWatermarkResultCollection* pPRWResultColl = pPRWsResult->GetProfileRenderWatermarkResults();
+ ProfileRenderWatermarkResult* pPRWResult = pPRWResultColl->GetAt(pPRWResultColl->GetCount()-1); // TODO: check index
- // Calculate the time spent on stylizing watermark
- double stylizeWatermarkTime = MgTimerUtil::GetTime() - pPRWResult->GetRenderTime();
- pPRWResult->SetRenderTime(stylizeWatermarkTime);
+ // Calculate the time spent on stylizing watermark
+ double stylizeWatermarkTime = MgTimerUtil::GetTime() - pPRWResult->GetRenderTime();
+ pPRWResult->SetRenderTime(stylizeWatermarkTime);
- pPRWResult->SetResourceId(resourceId);
+ pPRWResult->SetResourceId(resourceId);
- WatermarkPosition* position = wdef->GetPosition();
- if(NULL != dynamic_cast<XYWatermarkPosition*>(position))
- {
- pPRWResult->SetPositionType(L"XY");
+ WatermarkPosition* position = wdef->GetPosition();
+ if(NULL != dynamic_cast<XYWatermarkPosition*>(position))
+ {
+ pPRWResult->SetPositionType(L"XY");
+ }
+ else // No other position types
+ {
+ pPRWResult->SetPositionType(L"Tile");
+ }
}
- else // No other position types
- {
- pPRWResult->SetPositionType(L"Tile");
- }
- }
- MG_CATCH(L"MgServerRenderingService.RenderMapInternal")
- if(mgException.p)
- {
- // Do not do anything if fail in resource loading and has logged error.
- bool isExceptionLogged = false;
- if(wdef == NULL) // Fail in resource loading
- {
- for(int i = 0; i < failLoadedIds.GetCount(); i++)
- {
- if(resourceId == failLoadedIds.GetItem(i))
+ MG_CATCH(L"MgServerRenderingService.RenderMapInternal")
+ if(mgException.p)
+ {
+ // Do not do anything if fail in resource loading and has logged error.
+ bool isExceptionLogged = false;
+ if(wdef == NULL) // Fail in resource loading
+ {
+ for(int i = 0; i < failLoadedIds.GetCount(); i++)
{
- isExceptionLogged = true;
- break;
+ if(resourceId == failLoadedIds.GetItem(i))
+ {
+ isExceptionLogged = true;
+ break;
+ }
}
}
- }
- if(!isExceptionLogged)
- {
- // TODO: Eventually this should be used to indicate visually to the client what
- // layer failed in addition to logging the error.
- MgServerManager* serverManager = MgServerManager::GetInstance();
- STRING locale = (NULL == serverManager)? MgResources::DefaultMessageLocale : serverManager->GetDefaultMessageLocale();
- MG_LOG_EXCEPTION_ENTRY(mgException->GetExceptionMessage(locale).c_str(), mgException->GetStackTrace(locale).c_str());
+ if(!isExceptionLogged)
+ {
+ // TODO: Eventually this should be used to indicate visually to the client what
+ // layer failed in addition to logging the error.
+ MgServerManager* serverManager = MgServerManager::GetInstance();
+ STRING locale = (NULL == serverManager)? MgResources::DefaultMessageLocale : serverManager->GetDefaultMessageLocale();
+ MG_LOG_EXCEPTION_ENTRY(mgException->GetExceptionMessage(locale).c_str(), mgException->GetStackTrace(locale).c_str());
-#if defined(_DEBUG) || defined(_DEBUG_PNG8)
- STRING details = mgException->GetDetails(locale);
+ #if defined(_DEBUG) || defined(_DEBUG_PNG8)
+ STRING details = mgException->GetDetails(locale);
- wstring err = L"\n %t Error during stylization of watermark:";
- err += instance->GetName();
- err += L"\n";
- err += L"Details: ";
- err += details;
- err += L"\n";
- ACE_DEBUG( (LM_DEBUG, err.c_str()) );
-#endif
- if(wdef == NULL) // Failed in resource loading
- {
- failLoadedIds.Add(resourceId);
+ wstring err = L"\n %t Error during stylization of watermark:";
+ err += instance->GetName();
+ err += L"\n";
+ err += L"Details: ";
+ err += details;
+ err += L"\n";
+ ACE_DEBUG( (LM_DEBUG, err.c_str()) );
+ #endif
+ if(wdef == NULL) // Failed in resource loading
+ {
+ failLoadedIds.Add(resourceId);
+ }
}
}
}
- }
- if(NULL != pPRWsResult)
- {
- // Calculate the time spent on stylizing watermarks
- double stylizeRenderWatermarksTime = MgTimerUtil::GetTime() - pPRWsResult->GetRenderTime();
- pPRWsResult->SetRenderTime(stylizeRenderWatermarksTime);
+ if(NULL != pPRWsResult)
+ {
+ // Calculate the time spent on stylizing watermarks
+ double stylizeRenderWatermarksTime = MgTimerUtil::GetTime() - pPRWsResult->GetRenderTime();
+ pPRWsResult->SetRenderTime(stylizeRenderWatermarksTime);
+ }
}
}
Modified: trunk/MgDev/Server/src/Services/Rendering/ServerRenderingService.h
===================================================================
--- trunk/MgDev/Server/src/Services/Rendering/ServerRenderingService.h 2011-09-02 06:32:13 UTC (rev 6112)
+++ trunk/MgDev/Server/src/Services/Rendering/ServerRenderingService.h 2011-09-05 07:37:53 UTC (rev 6113)
@@ -124,8 +124,20 @@
MgColor* backgroundColor,
CREFSTRING format,
bool bKeepSelection,
- bool bClip);
+ ProfileRenderMapResult* pPRMResult);
+ virtual MgByteReader* RenderMap(MgMap* map,
+ MgSelection* selection,
+ MgCoordinate* center,
+ double scale,
+ INT32 width,
+ INT32 height,
+ MgColor* backgroundColor,
+ CREFSTRING format,
+ bool bKeepSelection,
+ bool bClip,
+ ProfileRenderMapResult* pPRMResult = NULL);
+
virtual MgByteReader* RenderMapLegend(MgMap* map,
INT32 width,
INT32 height,
More information about the mapguide-commits
mailing list