[mapguide-commits] r7497 - in sandbox/jng/createruntimemap: Common/MapGuideCommon/Resources Common/MapGuideCommon/Services Common/Schema Server/src/Services/Mapping Server/src/UnitTesting Web/src/HttpHandler
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Fri May 17 06:48:43 PDT 2013
Author: jng
Date: 2013-05-17 06:48:43 -0700 (Fri, 17 May 2013)
New Revision: 7497
Added:
sandbox/jng/createruntimemap/Server/src/Services/Mapping/OpCreateRuntimeMap.cpp
sandbox/jng/createruntimemap/Server/src/Services/Mapping/OpCreateRuntimeMap.h
Modified:
sandbox/jng/createruntimemap/Common/MapGuideCommon/Resources/mapguide_en.res
sandbox/jng/createruntimemap/Common/MapGuideCommon/Services/MappingService.h
sandbox/jng/createruntimemap/Common/MapGuideCommon/Services/ProxyMappingService.cpp
sandbox/jng/createruntimemap/Common/MapGuideCommon/Services/ProxyMappingService.h
sandbox/jng/createruntimemap/Common/Schema/RuntimeMap-2.6.0.xsd
sandbox/jng/createruntimemap/Server/src/Services/Mapping/MappingUtil.cpp
sandbox/jng/createruntimemap/Server/src/Services/Mapping/MappingUtil.h
sandbox/jng/createruntimemap/Server/src/Services/Mapping/ServerMappingService.cpp
sandbox/jng/createruntimemap/Server/src/Services/Mapping/ServerMappingService.h
sandbox/jng/createruntimemap/Server/src/UnitTesting/TestMappingService.cpp
sandbox/jng/createruntimemap/Web/src/HttpHandler/HttpCreateRuntimeMap.cpp
sandbox/jng/createruntimemap/Web/src/HttpHandler/HttpCreateRuntimeMap.h
sandbox/jng/createruntimemap/Web/src/HttpHandler/HttpResourceStrings.cpp
sandbox/jng/createruntimemap/Web/src/HttpHandler/HttpResourceStrings.h
Log:
This submission includes the following changes:
- Derp! Left out OpCreateRuntimeMap.h and OpCreateRuntimeMap.cpp
- Allow the icon image format to be specified. Default is PNG. PNG, PNG8, JPG and GIF are the allowed formats. This exposed a defect in MgMappingService::GetLegendImage where image format was ignored because MgMappingUtil::DrawFTS was hard-coded for PNG output. This submission fixes that.
- One last change (hopefully) to the CREATERUNTIMEMAP response format in an effort to eliminate redundancy in the XML content.
- Promote icon format to the top-level. Since the format is the same for all inline icons, there's no point specifying the same mime type for each inline icon.
- On the same vein, group all rule elements by into a parent FeatureStyle element (with type specified in inside). This eliminates redundant <GeometryType> elements for multiple rules of a style as we can get that information from its parent
- Also on the same vein, remove the <ThemeCategory> element. This can be inferred from the rule's position in the parent FeatureStyle element
- Update unit test to exercise all supported icon image formats.
Modified: sandbox/jng/createruntimemap/Common/MapGuideCommon/Resources/mapguide_en.res
===================================================================
--- sandbox/jng/createruntimemap/Common/MapGuideCommon/Resources/mapguide_en.res 2013-05-15 17:57:17 UTC (rev 7496)
+++ sandbox/jng/createruntimemap/Common/MapGuideCommon/Resources/mapguide_en.res 2013-05-17 13:48:43 UTC (rev 7497)
@@ -259,6 +259,7 @@
MgInvalidGeometryTooFewCoordinates = The geometry is invalid because it has too few coordinates.
MgInvalidGeometryType = The geometry type is invalid because it is not recognized.
MgInvalidHour = The hour is invalid because it must be between 0 and 23.
+MgInvalidImageFormat = Invalid Image Format: %1
MgInvalidImageSizeTooBig = The requested image size exceeds the maximum.
MgInvalidIpConfigurationForSiteServer = The site server (%1) must have the same IP address as this local server (%2).
MgInvalidIpConfigurationForSupportServer = The site server (%1) must have a different IP address than this support server (%2).
Modified: sandbox/jng/createruntimemap/Common/MapGuideCommon/Services/MappingService.h
===================================================================
--- sandbox/jng/createruntimemap/Common/MapGuideCommon/Services/MappingService.h 2013-05-15 17:57:17 UTC (rev 7496)
+++ sandbox/jng/createruntimemap/Common/MapGuideCommon/Services/MappingService.h 2013-05-17 13:48:43 UTC (rev 7497)
@@ -433,6 +433,8 @@
/// The desired name of the runtime map
/// \param sessionId (String/string)
/// The session ID
+ /// \param iconFormat (String/string)
+ /// The desired image format for icons (from MgImageFormats)
/// \param iconWidth (int)
/// The width of each individual inline legend icons. Has no effect if icons was not requested in the response.
/// \param iconHeight (int)
@@ -452,9 +454,13 @@
/// \return
/// Returns an XML-based description of the runtime map
///
+ /// \exception MgInvalidArgumentException
+ /// \exception MgNullArgumentException
+ ///
virtual MgByteReader* CreateRuntimeMap(MgResourceIdentifier* mapDefinition,
CREFSTRING targetMapName,
CREFSTRING sessionId,
+ CREFSTRING iconFormat,
INT32 iconWidth,
INT32 iconHeight,
INT32 requestedFeatures,
Modified: sandbox/jng/createruntimemap/Common/MapGuideCommon/Services/ProxyMappingService.cpp
===================================================================
--- sandbox/jng/createruntimemap/Common/MapGuideCommon/Services/ProxyMappingService.cpp 2013-05-15 17:57:17 UTC (rev 7496)
+++ sandbox/jng/createruntimemap/Common/MapGuideCommon/Services/ProxyMappingService.cpp 2013-05-17 13:48:43 UTC (rev 7497)
@@ -478,6 +478,7 @@
MgByteReader* MgProxyMappingService::CreateRuntimeMap(MgResourceIdentifier* mapDefinition,
CREFSTRING targetMapName,
CREFSTRING sessionId,
+ CREFSTRING iconFormat,
INT32 iconWidth,
INT32 iconHeight,
INT32 requestedFeatures,
@@ -488,12 +489,13 @@
cmd.ExecuteCommand(m_connProp,
MgCommand::knObject,
MgMappingServiceOpId::CreateRuntimeMap2,
- 7,
+ 8,
Mapping_Service,
BUILD_VERSION(2,6,0),
MgCommand::knObject, mapDefinition,
MgCommand::knString, targetMapName,
MgCommand::knString, sessionId,
+ MgCommand::knString, iconFormat,
MgCommand::knInt32, iconWidth,
MgCommand::knInt32, iconHeight,
MgCommand::knInt32, requestedFeatures,
Modified: sandbox/jng/createruntimemap/Common/MapGuideCommon/Services/ProxyMappingService.h
===================================================================
--- sandbox/jng/createruntimemap/Common/MapGuideCommon/Services/ProxyMappingService.h 2013-05-15 17:57:17 UTC (rev 7496)
+++ sandbox/jng/createruntimemap/Common/MapGuideCommon/Services/ProxyMappingService.h 2013-05-17 13:48:43 UTC (rev 7497)
@@ -396,6 +396,8 @@
/// The desired name of the runtime map
/// \param sessionId (String/string)
/// The session ID
+ /// \param iconFormat (String/string)
+ /// The desired image format for icons (from MgImageFormats)
/// \param iconWidth (int)
/// The width of each individual inline legend icons. Has no effect if icons was not requested in the response.
/// \param iconHeight (int)
@@ -418,6 +420,7 @@
virtual MgByteReader* CreateRuntimeMap(MgResourceIdentifier* mapDefinition,
CREFSTRING targetMapName,
CREFSTRING sessionId,
+ CREFSTRING iconFormat,
INT32 iconWidth,
INT32 iconHeight,
INT32 requestedFeatures,
Modified: sandbox/jng/createruntimemap/Common/Schema/RuntimeMap-2.6.0.xsd
===================================================================
--- sandbox/jng/createruntimemap/Common/Schema/RuntimeMap-2.6.0.xsd 2013-05-15 17:57:17 UTC (rev 7496)
+++ sandbox/jng/createruntimemap/Common/Schema/RuntimeMap-2.6.0.xsd 2013-05-17 13:48:43 UTC (rev 7497)
@@ -26,6 +26,11 @@
<xs:documentation>The map's background color in ARGB hex string format</xs:documentation>
</xs:annotation>
</xs:element>
+ <xs:element name="IconMimeType" type="xs:string" minOccurs="0">
+ <xs:annotation>
+ <xs:documentation>The mime type of all inline icons</xs:documentation>
+ </xs:annotation>
+ </xs:element>
<xs:element name="CoordinateSystem" type="CoordinateSystemType" />
<xs:element name="Extents" type="Envelope" />
<xs:element name="Group" type="RuntimeMapGroup" minOccurs="0" maxOccurs="unbounded" />
@@ -208,24 +213,31 @@
<xs:documentation>The maximum scale of this scale range</xs:documentation>
</xs:annotation>
</xs:element>
- <xs:element name="Rule" type="RuleInfo" minOccurs="0" maxOccurs="unbounded" />
+ <xs:element name="FeatureStyle" type="FeatureStyleInfo" minOccurs="0" maxOccurs="unbounded">
+ <xs:annotation>
+ <xs:documentation>The feature style for a given geometry type.</xs:documentation>
+ </xs:annotation>
+ </xs:element>
</xs:sequence>
</xs:complexType>
- <xs:complexType name="RuleInfo">
+ <xs:complexType name="FeatureStyleInfo">
<xs:annotation>
- <xs:documentation>Describes a stylization rule in a layer's scale range</xs:documentation>
+ <xs:documentation>Defines the style rules for a given geometry type</xs:documentation>
</xs:annotation>
<xs:sequence>
- <xs:element name="GeometryType" type="xs:integer">
+ <xs:element name="Type" type="xs:integer">
<xs:annotation>
<xs:documentation>The geometry type that this rule is applicable to (1=point, 2=line, 3=area, 4=composite)</xs:documentation>
</xs:annotation>
</xs:element>
- <xs:element name="ThemeCategory" type="xs:integer">
- <xs:annotation>
- <xs:documentation>The theme category index</xs:documentation>
- </xs:annotation>
- </xs:element>
+ <xs:element name="Rule" type="RuleInfo" minOccurs="0" maxOccurs="unbounded" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="RuleInfo">
+ <xs:annotation>
+ <xs:documentation>Describes a stylization rule in a layer's scale range</xs:documentation>
+ </xs:annotation>
+ <xs:sequence>
<xs:element name="LegendLabel" type="xs:string">
<xs:annotation>
<xs:documentation>The legend label for this rule</xs:documentation>
@@ -236,30 +248,13 @@
<xs:documentation>The FDO filter that features must match in order for them to be stylized using this particular rule</xs:documentation>
</xs:annotation>
</xs:element>
- <xs:element name="Icon" type="IconInfo" minOccurs="0">
+ <xs:element name="Icon" type="xs:string" minOccurs="0">
<xs:annotation>
- <xs:documentation>Defines the icon for this rule</xs:documentation>
+ <xs:documentation>Defines the icon for this rule. The icon's image content is in base64 format</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
- <xs:complexType name="IconInfo">
- <xs:annotation>
- <xs:documentation>Describes a layer legend icon</xs:documentation>
- </xs:annotation>
- <xs:sequence>
- <xs:element name="MimeType" type="xs:string">
- <xs:annotation>
- <xs:documentation>The icon's mime type</xs:documentation>
- </xs:annotation>
- </xs:element>
- <xs:element name="Content" type="xs:string">
- <xs:annotation>
- <xs:documentation>The icon's image content (in base64 format)</xs:documentation>
- </xs:annotation>
- </xs:element>
- </xs:sequence>
- </xs:complexType>
<xs:complexType name="Envelope">
<xs:annotation>
<xs:documentation>Specifies an envelope (a rectangle) using two corner points.</xs:documentation>
Modified: sandbox/jng/createruntimemap/Server/src/Services/Mapping/MappingUtil.cpp
===================================================================
--- sandbox/jng/createruntimemap/Server/src/Services/Mapping/MappingUtil.cpp 2013-05-15 17:57:17 UTC (rev 7496)
+++ sandbox/jng/createruntimemap/Server/src/Services/Mapping/MappingUtil.cpp 2013-05-17 13:48:43 UTC (rev 7497)
@@ -1201,7 +1201,8 @@
MdfModel::FeatureTypeStyle* fts,
INT32 imgWidth,
INT32 imgHeight,
- INT32 themeCategory)
+ INT32 themeCategory,
+ CREFSTRING format)
{
if (!fts)
return NULL;
@@ -1219,9 +1220,6 @@
// draw the preview
StylizationUtil::DrawStylePreview(imgWidth, imgHeight, themeCategory, fts, &er, &se_sman);
- // TODO: use user-specified format
- RS_String format = L"PNG";
-
auto_ptr<RS_ByteData> data;
data.reset(er.Save(format, imgWidth, imgHeight));
@@ -1229,8 +1227,14 @@
{
// put this into a byte source
Ptr<MgByteSource> bs = new MgByteSource(data->GetBytes(), data->GetNumBytes());
- bs->SetMimeType(MgMimeType::Png);
+ if (format == MgImageFormats::Gif)
+ bs->SetMimeType(MgMimeType::Gif);
+ else if (format == MgImageFormats::Jpeg)
+ bs->SetMimeType(MgMimeType::Jpeg);
+ else if (format == MgImageFormats::Png || format == MgImageFormats::Png8)
+ bs->SetMimeType(MgMimeType::Png);
+
return bs->GetReader();
}
Modified: sandbox/jng/createruntimemap/Server/src/Services/Mapping/MappingUtil.h
===================================================================
--- sandbox/jng/createruntimemap/Server/src/Services/Mapping/MappingUtil.h 2013-05-15 17:57:17 UTC (rev 7496)
+++ sandbox/jng/createruntimemap/Server/src/Services/Mapping/MappingUtil.h 2013-05-17 13:48:43 UTC (rev 7497)
@@ -86,7 +86,7 @@
static MdfModel::MapDefinition* GetMapDefinition(MgResourceService* svcResource, MgResourceIdentifier* resId);
- static MgByteReader* DrawFTS(MgResourceService* svcResource, MdfModel::FeatureTypeStyle* fts, INT32 imgWidth, INT32 imgHeight, INT32 themeCategory);
+ static MgByteReader* DrawFTS(MgResourceService* svcResource, MdfModel::FeatureTypeStyle* fts, INT32 imgWidth, INT32 imgHeight, INT32 themeCategory, CREFSTRING format = L"PNG");
static double ComputeStylizationOffset(MgMap* map, MdfModel::VectorScaleRange* scaleRange, double scale);
static MgEnvelope* TransformExtent(MgEnvelope* extent, MgCoordinateSystemTransform* xform);
Added: sandbox/jng/createruntimemap/Server/src/Services/Mapping/OpCreateRuntimeMap.cpp
===================================================================
--- sandbox/jng/createruntimemap/Server/src/Services/Mapping/OpCreateRuntimeMap.cpp (rev 0)
+++ sandbox/jng/createruntimemap/Server/src/Services/Mapping/OpCreateRuntimeMap.cpp 2013-05-17 13:48:43 UTC (rev 7497)
@@ -0,0 +1,162 @@
+//
+// Copyright (C) 2004-2013 by Autodesk, Inc.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of version 2.1 of the GNU Lesser
+// General Public License as published by the Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+//
+
+#include "ServerMappingServiceDefs.h"
+#include "OpCreateRuntimeMap.h"
+
+
+///----------------------------------------------------------------------------
+/// <summary>
+/// Constructs the object.
+/// </summary>
+///----------------------------------------------------------------------------
+MgOpCreateRuntimeMap::MgOpCreateRuntimeMap()
+{
+}
+
+
+///----------------------------------------------------------------------------
+/// <summary>
+/// Destructs the object.
+/// </summary>
+///----------------------------------------------------------------------------
+MgOpCreateRuntimeMap::~MgOpCreateRuntimeMap()
+{
+}
+
+
+///----------------------------------------------------------------------------
+/// <summary>
+/// Executes the operation.
+/// </summary>
+///
+/// <exceptions>
+/// MgException
+/// </exceptions>
+///----------------------------------------------------------------------------
+void MgOpCreateRuntimeMap::Execute()
+{
+ ACE_DEBUG((LM_DEBUG, ACE_TEXT(" (%t) MgOpCreateRuntimeMap::Execute()\n")));
+
+ MG_LOG_OPERATION_MESSAGE(L"CreateRuntimeMap");
+
+ MG_TRY()
+
+ MG_LOG_OPERATION_MESSAGE_INIT(m_packet.m_OperationVersion, m_packet.m_NumArguments);
+
+ ACE_ASSERT(m_stream != NULL);
+
+ if (8 == m_packet.m_NumArguments)
+ {
+ STRING targetMapName;
+ STRING sessionId;
+ STRING iconFormat;
+ INT32 iconWidth, iconHeight, requestedFeatures, iconsPerScaleRange;
+
+ Ptr<MgResourceIdentifier> mapDefinition = (MgResourceIdentifier*)m_stream->GetObject();
+ m_stream->GetString(targetMapName);
+ m_stream->GetString(sessionId);
+ m_stream->GetString(iconFormat);
+ m_stream->GetInt32(iconWidth);
+ m_stream->GetInt32(iconHeight);
+ m_stream->GetInt32(requestedFeatures);
+ m_stream->GetInt32(iconsPerScaleRange);
+
+ BeginExecution();
+
+ MG_LOG_OPERATION_MESSAGE_PARAMETERS_START();
+ MG_LOG_OPERATION_MESSAGE_ADD_STRING((NULL == mapDefinition) ? L"MgResourceIdentifier" : mapDefinition->ToString().c_str());
+ MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
+ MG_LOG_OPERATION_MESSAGE_ADD_STRING(targetMapName);
+ MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
+ MG_LOG_OPERATION_MESSAGE_ADD_STRING(sessionId);
+ MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
+ MG_LOG_OPERATION_MESSAGE_ADD_STRING(iconFormat);
+ MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
+ MG_LOG_OPERATION_MESSAGE_ADD_INT32(iconWidth);
+ MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
+ MG_LOG_OPERATION_MESSAGE_ADD_INT32(iconHeight);
+ MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
+ MG_LOG_OPERATION_MESSAGE_ADD_INT32(requestedFeatures);
+ MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
+ MG_LOG_OPERATION_MESSAGE_ADD_INT32(iconsPerScaleRange);
+ MG_LOG_OPERATION_MESSAGE_PARAMETERS_END();
+
+ Validate();
+
+ Ptr<MgByteReader> byteReader =
+ m_service->CreateRuntimeMap(mapDefinition, targetMapName, sessionId, iconFormat, iconWidth, iconHeight, requestedFeatures, iconsPerScaleRange);
+
+ EndExecution(byteReader);
+ }
+ else if (4 == m_packet.m_NumArguments)
+ {
+ STRING sessionId;
+ INT32 requestedFeatures, iconsPerScaleRange;
+
+ Ptr<MgResourceIdentifier> mapDefinition = (MgResourceIdentifier*)m_stream->GetObject();
+ m_stream->GetString(sessionId);
+ m_stream->GetInt32(requestedFeatures);
+ m_stream->GetInt32(iconsPerScaleRange);
+
+ BeginExecution();
+
+ MG_LOG_OPERATION_MESSAGE_PARAMETERS_START();
+ MG_LOG_OPERATION_MESSAGE_ADD_STRING((NULL == mapDefinition) ? L"MgResourceIdentifier" : mapDefinition->ToString().c_str());
+ MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
+ MG_LOG_OPERATION_MESSAGE_ADD_STRING(sessionId);
+ MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
+ MG_LOG_OPERATION_MESSAGE_ADD_INT32(requestedFeatures);
+ MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
+ MG_LOG_OPERATION_MESSAGE_ADD_INT32(iconsPerScaleRange);
+ MG_LOG_OPERATION_MESSAGE_PARAMETERS_END();
+
+ Validate();
+
+ Ptr<MgByteReader> byteReader =
+ m_service->CreateRuntimeMap(mapDefinition, sessionId, requestedFeatures, iconsPerScaleRange);
+
+ EndExecution(byteReader);
+ }
+ else
+ {
+ MG_LOG_OPERATION_MESSAGE_PARAMETERS_START();
+ MG_LOG_OPERATION_MESSAGE_PARAMETERS_END();
+ }
+
+ if (!m_argsRead)
+ {
+ throw new MgOperationProcessingException(L"MgOpCreateRuntimeMap.Execute",
+ __LINE__, __WFILE__, NULL, L"", NULL);
+ }
+
+ // Successful operation
+ MG_LOG_OPERATION_MESSAGE_ADD_STRING(MgResources::Success.c_str());
+
+ MG_CATCH(L"MgOpCreateRuntimeMap.Execute")
+
+ if (mgException != NULL)
+ {
+ // Failed operation
+ MG_LOG_OPERATION_MESSAGE_ADD_STRING(MgResources::Failure.c_str());
+ }
+
+ // Add access log entry for operation
+ MG_LOG_OPERATION_MESSAGE_ACCESS_ENTRY();
+
+ MG_THROW()
+}
Added: sandbox/jng/createruntimemap/Server/src/Services/Mapping/OpCreateRuntimeMap.h
===================================================================
--- sandbox/jng/createruntimemap/Server/src/Services/Mapping/OpCreateRuntimeMap.h (rev 0)
+++ sandbox/jng/createruntimemap/Server/src/Services/Mapping/OpCreateRuntimeMap.h 2013-05-17 13:48:43 UTC (rev 7497)
@@ -0,0 +1,31 @@
+//
+// Copyright (C) 2004-2013 by Autodesk, Inc.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of version 2.1 of the GNU Lesser
+// General Public License as published by the Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+//
+
+#ifndef MG_OP_CREATE_RUNTIME_MAP_H
+#define MG_OP_CREATE_RUNTIME_MAP_H
+
+class MgOpCreateRuntimeMap : public MgMappingOperation
+{
+ public:
+ MgOpCreateRuntimeMap();
+ virtual ~MgOpCreateRuntimeMap();
+
+ public:
+ virtual void Execute();
+};
+
+#endif
\ No newline at end of file
Modified: sandbox/jng/createruntimemap/Server/src/Services/Mapping/ServerMappingService.cpp
===================================================================
--- sandbox/jng/createruntimemap/Server/src/Services/Mapping/ServerMappingService.cpp 2013-05-15 17:57:17 UTC (rev 7496)
+++ sandbox/jng/createruntimemap/Server/src/Services/Mapping/ServerMappingService.cpp 2013-05-17 13:48:43 UTC (rev 7497)
@@ -1690,7 +1690,7 @@
}
if (fts)
- byteReader = MgMappingUtil::DrawFTS(m_svcResource, fts, imgWidth, imgHeight, themeCategory);
+ byteReader = MgMappingUtil::DrawFTS(m_svcResource, fts, imgWidth, imgHeight, themeCategory, format);
else
{
//return the fixed array
@@ -1869,20 +1869,30 @@
{
CHECKNULL(mapDefinition, L"MgServerMappingService.CreateRuntimeMap");
STRING mapName = mapDefinition->GetName();
- return CreateRuntimeMap(mapDefinition, mapName, sessionId, LEGEND_BITMAP_SIZE, LEGEND_BITMAP_SIZE, requestedFeatures, iconsPerScaleRange);
+ return CreateRuntimeMap(mapDefinition, mapName, sessionId, MgImageFormats::Png, LEGEND_BITMAP_SIZE, LEGEND_BITMAP_SIZE, requestedFeatures, iconsPerScaleRange);
}
MgByteReader* MgServerMappingService::CreateRuntimeMap(MgResourceIdentifier* mapDefinition,
CREFSTRING targetMapName,
CREFSTRING sessionId,
+ CREFSTRING iconFormat,
INT32 iconWidth,
INT32 iconHeight,
INT32 requestedFeatures,
INT32 iconsPerScaleRange)
{
- CHECKNULL(mapDefinition, L"MgServerMappingService.CreateRuntimeMap");
+ CHECKARGUMENTNULL(mapDefinition, L"MgServerMappingService.CreateRuntimeMap");
+ LayerDefinitionMap layerDefinitionMap;
+ if (MgImageFormats::Png != iconFormat &&
+ MgImageFormats::Gif != iconFormat &&
+ MgImageFormats::Png8 != iconFormat &&
+ MgImageFormats::Jpeg != iconFormat)
+ {
+ MgStringCollection args;
+ args.Add(iconFormat);
+ throw new MgInvalidArgumentException(L"MgServerMappingService.CreateRuntimeMap", __LINE__, __WFILE__, NULL, L"MgInvalidImageFormat", &args);
+ }
Ptr<MgByteReader> byteReader;
- LayerDefinitionMap layerDefinitionMap;
MG_SERVER_MAPPING_SERVICE_TRY()
@@ -1933,6 +1943,18 @@
xml.append("<BackgroundColor>");
xml.append(MgUtil::WideCharToMultiByte(map->GetBackgroundColor()));
xml.append("</BackgroundColor>");
+ // ------------------------------ Icon Image Format --------------------------------- //
+ if ((requestedFeatures & REQUEST_LAYER_ICONS) == REQUEST_LAYER_ICONS)
+ {
+ xml.append("<IconMimeType>");
+ if (iconFormat == MgImageFormats::Gif)
+ xml.append(MgUtil::WideCharToMultiByte(MgMimeType::Gif));
+ else if (iconFormat == MgImageFormats::Jpeg)
+ xml.append(MgUtil::WideCharToMultiByte(MgMimeType::Jpeg));
+ else if (iconFormat == MgImageFormats::Png || iconFormat == MgImageFormats::Png8)
+ xml.append(MgUtil::WideCharToMultiByte(MgMimeType::Png));
+ xml.append("</IconMimeType>");
+ }
// ------------------------------ Coordinate System --------------------------------- //
xml.append("<CoordinateSystem>\n");
xml.append("<Wkt>");
@@ -2020,7 +2042,7 @@
if (it != layerDefinitionMap.end())
layerDef = it->second;
- CreateLayerItem(requestedFeatures, iconsPerScaleRange, iconWidth, iconHeight, layer, parent, layerDef, xml);
+ CreateLayerItem(requestedFeatures, iconsPerScaleRange, iconFormat, iconWidth, iconHeight, layer, parent, layerDef, xml);
}
}
// ------------------------ Finite Display Scales (if any) ------------------------- //
@@ -2102,7 +2124,7 @@
MG_SERVER_MAPPING_SERVICE_CATCH_AND_THROW(L"MgServerMappingService.CreateGroupItem")
}
-void MgServerMappingService::CreateLayerItem(INT32 requestedFeatures, INT32 iconsPerScaleRange, INT32 iconWidth, INT32 iconHeight, MgLayerBase* layer, MgLayerGroup* parent, MdfModel::LayerDefinition* ldf, std::string& xml)
+void MgServerMappingService::CreateLayerItem(INT32 requestedFeatures, INT32 iconsPerScaleRange, CREFSTRING iconFormat, INT32 iconWidth, INT32 iconHeight, MgLayerBase* layer, MgLayerGroup* parent, MdfModel::LayerDefinition* ldf, std::string& xml)
{
MG_SERVER_MAPPING_SERVICE_TRY()
@@ -2221,8 +2243,16 @@
geomType = 3;
else if (cts)
geomType = 4;
- INT32 catIndex = 0;
+ //Geometry type and Theme Category are required so that deferred icon requests can be made
+ //back to the GetLegendImage(), especially if we exceed the icons-per-scale-range limit
+ //Geometry type is specified here, theme category is inferred from rule item positioning.
+ xml.append("<FeatureStyle>\n");
+ xml.append("<Type>");
+ std::string sGeomType;
+ MgUtil::Int32ToString(geomType, sGeomType);
+ xml.append(sGeomType);
+ xml.append("</Type>\n");
MdfModel::RuleCollection* rules = fts->GetRules();
for (INT32 r = 0; r < rules->GetCount(); r++)
{
@@ -2238,18 +2268,6 @@
}
xml.append("<Rule>\n");
- //GeometryType and ThemeCategory are required so that deferred icon requests can be made
- //back to the GetLegendImage(), especially if we exceed the icons-per-scale-range limit
- xml.append("<GeometryType>");
- std::string sGeomType;
- MgUtil::Int32ToString(geomType, sGeomType);
- xml.append(sGeomType);
- xml.append("</GeometryType>\n");
- xml.append("<ThemeCategory>");
- std::string sThemeCat;
- MgUtil::Int32ToString(catIndex, sThemeCat);
- xml.append(sThemeCat);
- xml.append("</ThemeCategory>\n");
xml.append("<LegendLabel>");
xml.append(MgUtil::WideCharToMultiByte(MgUtil::ReplaceEscapeCharInXml(rule->GetLegendLabel())));
xml.append("</LegendLabel>\n");
@@ -2259,23 +2277,17 @@
if (bRequestIcon)
{
xml.append("<Icon>");
- Ptr<MgByteReader> iconReader = MgMappingUtil::DrawFTS(m_svcResource, fts, iconWidth, iconHeight, catIndex);
- xml.append("<MimeType>");
- xml.append(MgUtil::WideCharToMultiByte(iconReader->GetMimeType()));
- xml.append("</MimeType>\n");
- xml.append("<Content>");
+ Ptr<MgByteReader> iconReader = MgMappingUtil::DrawFTS(m_svcResource, fts, iconWidth, iconHeight, r, iconFormat);
Ptr<MgByteSink> sink = new MgByteSink(iconReader);
Ptr<MgByte> bytes = sink->ToBuffer();
Ptr<MgMemoryStreamHelper> streamHelper = new MgMemoryStreamHelper((INT8*) bytes->Bytes(), bytes->GetLength(), false);
std::string b64 = streamHelper->ToBase64();
xml.append(b64);
- xml.append("</Content>\n");
xml.append("</Icon>");
}
xml.append("</Rule>\n");
-
- catIndex++;
}
+ xml.append("</FeatureStyle>\n");
}
xml.append("</ScaleRange>\n");
Modified: sandbox/jng/createruntimemap/Server/src/Services/Mapping/ServerMappingService.h
===================================================================
--- sandbox/jng/createruntimemap/Server/src/Services/Mapping/ServerMappingService.h 2013-05-15 17:57:17 UTC (rev 7496)
+++ sandbox/jng/createruntimemap/Server/src/Services/Mapping/ServerMappingService.h 2013-05-17 13:48:43 UTC (rev 7497)
@@ -124,6 +124,7 @@
virtual MgByteReader* CreateRuntimeMap(MgResourceIdentifier* mapDefinition,
CREFSTRING targetMapName,
CREFSTRING sessionId,
+ CREFSTRING iconFormat,
INT32 iconWidth,
INT32 iconHeight,
INT32 requestedFeatures,
@@ -135,7 +136,7 @@
private:
void CreateGroupItem(MgLayerGroup* group, MgLayerGroup* parent, std::string& xml);
- void CreateLayerItem(INT32 requestedFeatures, INT32 iconsPerScaleRange, INT32 iconWidth, INT32 iconHeight, MgLayerBase* layer, MgLayerGroup* parent, MdfModel::LayerDefinition* ldf, std::string& xml);
+ void CreateLayerItem(INT32 requestedFeatures, INT32 iconsPerScaleRange, CREFSTRING iconFormat, INT32 iconWidth, INT32 iconHeight, MgLayerBase* layer, MgLayerGroup* parent, MdfModel::LayerDefinition* ldf, std::string& xml);
bool FeatureTypeStyleSupportsGeomType(MdfModel::FeatureTypeStyle* fts, INT32 geomType);
void MakeUIGraphicsForScaleRange(std::list<RS_UIGraphic>& uiGraphics, std::vector<MgByte*>& uiGraphicSources, MdfModel::VectorScaleRange* sr);
Modified: sandbox/jng/createruntimemap/Server/src/UnitTesting/TestMappingService.cpp
===================================================================
--- sandbox/jng/createruntimemap/Server/src/UnitTesting/TestMappingService.cpp 2013-05-15 17:57:17 UTC (rev 7496)
+++ sandbox/jng/createruntimemap/Server/src/UnitTesting/TestMappingService.cpp 2013-05-17 13:48:43 UTC (rev 7497)
@@ -257,30 +257,85 @@
{
//make a runtime map
Ptr<MgResourceIdentifier> mdfres = new MgResourceIdentifier(L"Library://UnitTests/Maps/Sheboygan.MapDefinition");
+ STRING format = MgImageFormats::Png;
//call the API
- Ptr<MgByteReader> rtMap = m_svcMapping->CreateRuntimeMap(mdfres, L"UnitTestSheboygan1", m_session, 16, 16, 0, 25);
+ Ptr<MgByteReader> rtMap = m_svcMapping->CreateRuntimeMap(mdfres, L"UnitTestSheboygan1", m_session, format, 16, 16, 0, 25);
Ptr<MgByteSink> sink = new MgByteSink(rtMap);
sink->ToFile(L"../UnitTestFiles/RuntimeMapBarebones.xml");
- rtMap = m_svcMapping->CreateRuntimeMap(mdfres, L"UnitTestSheboygan2", m_session, 16, 16, 1, 25);
+ rtMap = m_svcMapping->CreateRuntimeMap(mdfres, L"UnitTestSheboygan2", m_session, format, 16, 16, 1, 25);
sink = new MgByteSink(rtMap);
sink->ToFile(L"../UnitTestFiles/RuntimeMapLayersAndGroups.xml");
- rtMap = m_svcMapping->CreateRuntimeMap(mdfres, L"UnitTestSheboygan3", m_session, 16, 16, (1 | 2), 25);
+ rtMap = m_svcMapping->CreateRuntimeMap(mdfres, L"UnitTestSheboygan3", m_session, format, 16, 16, (1 | 2), 25);
sink = new MgByteSink(rtMap);
- sink->ToFile(L"../UnitTestFiles/RuntimeMapLayersAndGroupsWithIcons16x16.xml");
+ sink->ToFile(L"../UnitTestFiles/RuntimeMapLayersAndGroupsWithIconsPNG16x16.xml");
- rtMap = m_svcMapping->CreateRuntimeMap(mdfres, L"UnitTestSheboygan4", m_session, 16, 16, (1 | 2 | 4), 25);
+ rtMap = m_svcMapping->CreateRuntimeMap(mdfres, L"UnitTestSheboygan4", m_session, format, 16, 16, (1 | 2 | 4), 25);
sink = new MgByteSink(rtMap);
- sink->ToFile(L"../UnitTestFiles/RuntimeMapLayersAndGroupsWithIconsAndFeatureSource16x16.xml");
+ sink->ToFile(L"../UnitTestFiles/RuntimeMapLayersAndGroupsWithIconsAndFeatureSourcePNG16x16.xml");
- rtMap = m_svcMapping->CreateRuntimeMap(mdfres, L"UnitTestSheboygan5", m_session, 32, 32, (1 | 2), 25);
+ rtMap = m_svcMapping->CreateRuntimeMap(mdfres, L"UnitTestSheboygan5", m_session, format, 32, 32, (1 | 2), 25);
sink = new MgByteSink(rtMap);
- sink->ToFile(L"../UnitTestFiles/RuntimeMapLayersAndGroupsWithIcons32x32.xml");
+ sink->ToFile(L"../UnitTestFiles/RuntimeMapLayersAndGroupsWithIconsPNG32x32.xml");
- rtMap = m_svcMapping->CreateRuntimeMap(mdfres, L"UnitTestSheboygan6", m_session, 32, 32, (1 | 2 | 4), 25);
+ rtMap = m_svcMapping->CreateRuntimeMap(mdfres, L"UnitTestSheboygan6", m_session, format, 32, 32, (1 | 2 | 4), 25);
sink = new MgByteSink(rtMap);
- sink->ToFile(L"../UnitTestFiles/RuntimeMapLayersAndGroupsWithIconsAndFeatureSource32x32.xml");
+ sink->ToFile(L"../UnitTestFiles/RuntimeMapLayersAndGroupsWithIconsAndFeatureSourcePNG32x32.xml");
+
+ format = MgImageFormats::Gif;
+
+ rtMap = m_svcMapping->CreateRuntimeMap(mdfres, L"UnitTestSheboygan3", m_session, format, 16, 16, (1 | 2), 25);
+ sink = new MgByteSink(rtMap);
+ sink->ToFile(L"../UnitTestFiles/RuntimeMapLayersAndGroupsWithIconsGIF16x16.xml");
+
+ rtMap = m_svcMapping->CreateRuntimeMap(mdfres, L"UnitTestSheboygan4", m_session, format, 16, 16, (1 | 2 | 4), 25);
+ sink = new MgByteSink(rtMap);
+ sink->ToFile(L"../UnitTestFiles/RuntimeMapLayersAndGroupsWithIconsAndFeatureSourceGIF16x16.xml");
+
+ rtMap = m_svcMapping->CreateRuntimeMap(mdfres, L"UnitTestSheboygan5", m_session, format, 32, 32, (1 | 2), 25);
+ sink = new MgByteSink(rtMap);
+ sink->ToFile(L"../UnitTestFiles/RuntimeMapLayersAndGroupsWithIconsGIF32x32.xml");
+
+ rtMap = m_svcMapping->CreateRuntimeMap(mdfres, L"UnitTestSheboygan6", m_session, format, 32, 32, (1 | 2 | 4), 25);
+ sink = new MgByteSink(rtMap);
+ sink->ToFile(L"../UnitTestFiles/RuntimeMapLayersAndGroupsWithIconsAndFeatureSourceGIF32x32.xml");
+
+ format = MgImageFormats::Jpeg;
+
+ rtMap = m_svcMapping->CreateRuntimeMap(mdfres, L"UnitTestSheboygan3", m_session, format, 16, 16, (1 | 2), 25);
+ sink = new MgByteSink(rtMap);
+ sink->ToFile(L"../UnitTestFiles/RuntimeMapLayersAndGroupsWithIconsJPEG16x16.xml");
+
+ rtMap = m_svcMapping->CreateRuntimeMap(mdfres, L"UnitTestSheboygan4", m_session, format, 16, 16, (1 | 2 | 4), 25);
+ sink = new MgByteSink(rtMap);
+ sink->ToFile(L"../UnitTestFiles/RuntimeMapLayersAndGroupsWithIconsAndFeatureSourceJPEG16x16.xml");
+
+ rtMap = m_svcMapping->CreateRuntimeMap(mdfres, L"UnitTestSheboygan5", m_session, format, 32, 32, (1 | 2), 25);
+ sink = new MgByteSink(rtMap);
+ sink->ToFile(L"../UnitTestFiles/RuntimeMapLayersAndGroupsWithIconsJPEG32x32.xml");
+
+ rtMap = m_svcMapping->CreateRuntimeMap(mdfres, L"UnitTestSheboygan6", m_session, format, 32, 32, (1 | 2 | 4), 25);
+ sink = new MgByteSink(rtMap);
+ sink->ToFile(L"../UnitTestFiles/RuntimeMapLayersAndGroupsWithIconsAndFeatureSourceJPEG32x32.xml");
+
+ format = MgImageFormats::Png8;
+
+ rtMap = m_svcMapping->CreateRuntimeMap(mdfres, L"UnitTestSheboygan3", m_session, format, 16, 16, (1 | 2), 25);
+ sink = new MgByteSink(rtMap);
+ sink->ToFile(L"../UnitTestFiles/RuntimeMapLayersAndGroupsWithIconsPNG816x16.xml");
+
+ rtMap = m_svcMapping->CreateRuntimeMap(mdfres, L"UnitTestSheboygan4", m_session, format, 16, 16, (1 | 2 | 4), 25);
+ sink = new MgByteSink(rtMap);
+ sink->ToFile(L"../UnitTestFiles/RuntimeMapLayersAndGroupsWithIconsAndFeatureSourcePNG816x16.xml");
+
+ rtMap = m_svcMapping->CreateRuntimeMap(mdfres, L"UnitTestSheboygan5", m_session, format, 32, 32, (1 | 2), 25);
+ sink = new MgByteSink(rtMap);
+ sink->ToFile(L"../UnitTestFiles/RuntimeMapLayersAndGroupsWithIconsPNG832x32.xml");
+
+ rtMap = m_svcMapping->CreateRuntimeMap(mdfres, L"UnitTestSheboygan6", m_session, format, 32, 32, (1 | 2 | 4), 25);
+ sink = new MgByteSink(rtMap);
+ sink->ToFile(L"../UnitTestFiles/RuntimeMapLayersAndGroupsWithIconsAndFeatureSourcePNG832x32.xml");
}
catch(MgException* e)
{
Modified: sandbox/jng/createruntimemap/Web/src/HttpHandler/HttpCreateRuntimeMap.cpp
===================================================================
--- sandbox/jng/createruntimemap/Web/src/HttpHandler/HttpCreateRuntimeMap.cpp 2013-05-15 17:57:17 UTC (rev 7496)
+++ sandbox/jng/createruntimemap/Web/src/HttpHandler/HttpCreateRuntimeMap.cpp 2013-05-17 13:48:43 UTC (rev 7497)
@@ -61,8 +61,14 @@
{
m_targetMapName = sTargetMapName;
}
+ m_iconFormat = MgImageFormats::Png;
m_iconWidth = 16;
m_iconHeight = 16;
+ STRING sIconFormat = params->GetParameterValue(MgHttpResourceStrings::reqMappingIconFormat);
+ if (!sIconFormat.empty())
+ {
+ m_iconFormat = sIconFormat;
+ }
STRING sIconWidth = params->GetParameterValue(MgHttpResourceStrings::reqMappingIconWidth);
if (!sIconWidth.empty())
{
@@ -112,7 +118,7 @@
}
Ptr<MgMappingService> mappingService = (MgMappingService*)CreateService(MgServiceType::MappingService);
- byteReader = mappingService->CreateRuntimeMap(mdfId, mapName, sessionId, m_iconWidth, m_iconHeight, m_requestDataMask, m_iconLimitPerScaleRange);
+ byteReader = mappingService->CreateRuntimeMap(mdfId, mapName, sessionId, m_iconFormat, m_iconWidth, m_iconHeight, m_requestDataMask, m_iconLimitPerScaleRange);
// Convert to requested response format, if necessary
ProcessFormatConversion(byteReader);
Modified: sandbox/jng/createruntimemap/Web/src/HttpHandler/HttpCreateRuntimeMap.h
===================================================================
--- sandbox/jng/createruntimemap/Web/src/HttpHandler/HttpCreateRuntimeMap.h 2013-05-15 17:57:17 UTC (rev 7496)
+++ sandbox/jng/createruntimemap/Web/src/HttpHandler/HttpCreateRuntimeMap.h 2013-05-17 13:48:43 UTC (rev 7497)
@@ -63,6 +63,7 @@
private:
STRING m_targetMapName;
STRING m_mapDefinition;
+ STRING m_iconFormat;
INT32 m_iconWidth;
INT32 m_iconHeight;
INT32 m_requestDataMask;
Modified: sandbox/jng/createruntimemap/Web/src/HttpHandler/HttpResourceStrings.cpp
===================================================================
--- sandbox/jng/createruntimemap/Web/src/HttpHandler/HttpResourceStrings.cpp 2013-05-15 17:57:17 UTC (rev 7496)
+++ sandbox/jng/createruntimemap/Web/src/HttpHandler/HttpResourceStrings.cpp 2013-05-17 13:48:43 UTC (rev 7497)
@@ -222,6 +222,7 @@
const STRING MgHttpResourceStrings::reqMappingTargetMapName = L"TARGETMAPNAME";
const STRING MgHttpResourceStrings::reqMappingIconWidth = L"ICONWIDTH";
const STRING MgHttpResourceStrings::reqMappingIconHeight = L"ICONHEIGHT";
+const STRING MgHttpResourceStrings::reqMappingIconFormat = L"ICONFORMAT";
// Predefined Rendering Service Request Parameters
const STRING MgHttpResourceStrings::reqRenderingMapDefinition = L"MAPDEFINITION";
Modified: sandbox/jng/createruntimemap/Web/src/HttpHandler/HttpResourceStrings.h
===================================================================
--- sandbox/jng/createruntimemap/Web/src/HttpHandler/HttpResourceStrings.h 2013-05-15 17:57:17 UTC (rev 7496)
+++ sandbox/jng/createruntimemap/Web/src/HttpHandler/HttpResourceStrings.h 2013-05-17 13:48:43 UTC (rev 7497)
@@ -158,6 +158,7 @@
static const STRING reqMappingTargetMapName;
static const STRING reqMappingIconWidth;
static const STRING reqMappingIconHeight;
+ static const STRING reqMappingIconFormat;
// PREDEFINED RENDERING REQUEST PARAMETERS
static const STRING reqRenderingMapDefinition;
More information about the mapguide-commits
mailing list