[mapguide-commits] r6089 - in sandbox/adsk/2.3r: . Common/MapGuideCommon/Services Common/Renderers Server/src/Services/Kml Server/src/UnitTesting Web/src/HttpHandler

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Tue Aug 23 03:41:19 EDT 2011


Author: liuar
Date: 2011-08-23 00:41:18 -0700 (Tue, 23 Aug 2011)
New Revision: 6089

Added:
   sandbox/adsk/2.3r/Common/Renderers/KmlIconStyle.cpp
Modified:
   sandbox/adsk/2.3r/
   sandbox/adsk/2.3r/Common/MapGuideCommon/Services/KmlService.h
   sandbox/adsk/2.3r/Common/MapGuideCommon/Services/ProxyKmlService.cpp
   sandbox/adsk/2.3r/Common/MapGuideCommon/Services/ProxyKmlService.h
   sandbox/adsk/2.3r/Common/Renderers/KmlContent.h
   sandbox/adsk/2.3r/Common/Renderers/KmlRenderer.cpp
   sandbox/adsk/2.3r/Common/Renderers/KmlRenderer.h
   sandbox/adsk/2.3r/Common/Renderers/Makefile.am
   sandbox/adsk/2.3r/Common/Renderers/Renderers.vcproj
   sandbox/adsk/2.3r/Server/src/Services/Kml/OpGetFeaturesKml.cpp
   sandbox/adsk/2.3r/Server/src/Services/Kml/ServerKmlService.cpp
   sandbox/adsk/2.3r/Server/src/Services/Kml/ServerKmlService.h
   sandbox/adsk/2.3r/Server/src/UnitTesting/TestKmlService.cpp
   sandbox/adsk/2.3r/Web/src/HttpHandler/HttpKmlGetFeatures.cpp
   sandbox/adsk/2.3r/Web/src/HttpHandler/HttpKmlGetFeatures.h
Log:
Port the fix of ticket #1619 Lack of point style in KML service to adsk2.3r branch


Property changes on: sandbox/adsk/2.3r
___________________________________________________________________
Modified: svn:mergeinfo
   - /:5504
/trunk/MgDev:5504,5539,5561-5562,5595,6074
   + /:5504
/trunk/MgDev:5501,5504,5539,5561-5562,5595,6074

Modified: sandbox/adsk/2.3r/Common/MapGuideCommon/Services/KmlService.h
===================================================================
--- sandbox/adsk/2.3r/Common/MapGuideCommon/Services/KmlService.h	2011-08-23 02:07:34 UTC (rev 6088)
+++ sandbox/adsk/2.3r/Common/MapGuideCommon/Services/KmlService.h	2011-08-23 07:41:18 UTC (rev 6089)
@@ -153,6 +153,55 @@
         INT32 drawOrder,
         CREFSTRING format) = 0;
 
+    /////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns a layer definition in KML format
+    ///
+    /// \param layer
+    /// Input
+    /// layer object for which to generate KML.
+    ///
+    /// \param extents
+    /// Input
+    /// required spatial data extents
+    ///
+    /// \param width
+    /// Input
+    /// map width in pixels
+    ///
+    /// \param height
+    /// Input
+    /// map height in pixels
+    ///
+    /// \param dpi
+    /// Input
+    /// resolution in dots per inch
+    ///
+    /// \param drawOrder
+    /// Input
+    /// the draw order for the layer containing these features
+    ///
+    /// \param agentUri
+    /// Input
+    /// URI of map agent that issued request
+    ///
+    /// \param format
+    /// Input
+    /// requested response format
+    ///
+    /// \return
+    /// A byte reader containing the generated KML.
+    ///
+    virtual MgByteReader* GetFeaturesKml(
+        MgLayer* layer,
+        MgEnvelope* extents,
+        INT32 width,
+        INT32 height,
+        double dpi,
+        INT32 drawOrder,
+        CREFSTRING agentUri,
+        CREFSTRING format) = 0;
+
 INTERNAL_API:
 
     //////////////////////////////////////////////////////////////////

Modified: sandbox/adsk/2.3r/Common/MapGuideCommon/Services/ProxyKmlService.cpp
===================================================================
--- sandbox/adsk/2.3r/Common/MapGuideCommon/Services/ProxyKmlService.cpp	2011-08-23 02:07:34 UTC (rev 6088)
+++ sandbox/adsk/2.3r/Common/MapGuideCommon/Services/ProxyKmlService.cpp	2011-08-23 07:41:18 UTC (rev 6089)
@@ -149,6 +149,39 @@
     return (MgByteReader*)cmd.GetReturnValue().val.m_obj;
 }
 
+// Retrieve feature geometries in KML format
+MgByteReader* MgProxyKmlService::GetFeaturesKml(
+    MgLayer* layer,
+    MgEnvelope* extents,
+    INT32 width,
+    INT32 height,
+    double dpi,
+    INT32 drawOrder,
+    CREFSTRING agentUri,
+    CREFSTRING format)
+{
+    MgCommand cmd;
+    cmd.ExecuteCommand(m_connProp,                                      // Connection
+                        MgCommand::knObject,                            // Return type expected
+                        MgKmlServiceOpId::GetFeaturesKml,               // Command Code
+                        8,                                              // No of arguments
+                        Kml_Service,                                    // Service Id
+                        BUILD_VERSION(1,0,0),                           // Operation version
+                        MgCommand::knObject, layer,                     // Argument#1
+                        MgCommand::knObject, extents,                   // Argument#2
+                        MgCommand::knInt32, width,                      // Argument#3
+                        MgCommand::knInt32, height,                     // Argument#4
+                        MgCommand::knDouble, dpi,                       // Argument#5
+                        MgCommand::knInt32, drawOrder,                  // Argument#6
+                        MgCommand::knString, &agentUri,                 // Argument#7
+                        MgCommand::knString, &format,                   // Argument#8
+                        MgCommand::knNone);                             // End of arguments
+
+    SetWarning(cmd.GetWarningObject());
+
+    return (MgByteReader*)cmd.GetReturnValue().val.m_obj;
+}
+
 //////////////////////////////////////////////////////////////////
 /// \brief
 /// Sets the connection properties for the Proxy Service.  This

Modified: sandbox/adsk/2.3r/Common/MapGuideCommon/Services/ProxyKmlService.h
===================================================================
--- sandbox/adsk/2.3r/Common/MapGuideCommon/Services/ProxyKmlService.h	2011-08-23 02:07:34 UTC (rev 6088)
+++ sandbox/adsk/2.3r/Common/MapGuideCommon/Services/ProxyKmlService.h	2011-08-23 07:41:18 UTC (rev 6089)
@@ -146,7 +146,56 @@
         INT32 drawOrder,
         CREFSTRING format);
 
+    /////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns a layer definition in KML format
+    ///
+    /// \param layer
+    /// Input
+    /// layer object for which to generate KML.
+    ///
+    /// \param extents
+    /// Input
+    /// required spatial data extents
+    ///
+    /// \param width
+    /// Input
+    /// map width in pixels
+    ///
+    /// \param height
+    /// Input
+    /// map height in pixels
+    ///
+    /// \param dpi
+    /// Input
+    /// resolution in dots per inch
+    ///
+    /// \param drawOrder
+    /// Input
+    /// the draw order for the layer containing these features
+    ///
+    /// \param agentUri
+    /// Input
+    /// URI of map agent that issued request
+    ///
+    /// \param format
+    /// Input
+    /// requested response format
+    ///
+    /// \return
+    /// A byte reader containing the generated KML.
+    ///
+    virtual MgByteReader* GetFeaturesKml(
+        MgLayer* layer,
+        MgEnvelope* extents,
+        INT32 width,
+        INT32 height,
+        double dpi,
+        INT32 drawOrder,
+        CREFSTRING agentUri,
+        CREFSTRING format);
 
+
 INTERNAL_API:
 
     //////////////////////////////////////////////////////////////////

Modified: sandbox/adsk/2.3r/Common/Renderers/KmlContent.h
===================================================================
--- sandbox/adsk/2.3r/Common/Renderers/KmlContent.h	2011-08-23 02:07:34 UTC (rev 6088)
+++ sandbox/adsk/2.3r/Common/Renderers/KmlContent.h	2011-08-23 07:41:18 UTC (rev 6089)
@@ -22,6 +22,7 @@
 #include "RendererStyles.h"
 #include "KmlLineStyle.h"
 #include "KmlPolyStyle.h"
+#include "KmlIconStyle.h"
 #include <sstream>
 
 class KmlContent

Added: sandbox/adsk/2.3r/Common/Renderers/KmlIconStyle.cpp
===================================================================
--- sandbox/adsk/2.3r/Common/Renderers/KmlIconStyle.cpp	                        (rev 0)
+++ sandbox/adsk/2.3r/Common/Renderers/KmlIconStyle.cpp	2011-08-23 07:41:18 UTC (rev 6089)
@@ -0,0 +1,32 @@
+//
+//  Copyright (C) 2011 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 "stdafx.h"
+
+#include "KmlIconStyle.h"
+
+KmlIconStyle::KmlIconStyle(double scale, std::wstring href):
+    m_scale(scale),
+    m_href(href)
+{
+}
+
+
+bool KmlIconStyle::operator<(const KmlIconStyle& other) const
+{
+    return (other.m_scale < m_scale);
+}

Modified: sandbox/adsk/2.3r/Common/Renderers/KmlRenderer.cpp
===================================================================
--- sandbox/adsk/2.3r/Common/Renderers/KmlRenderer.cpp	2011-08-23 02:07:34 UTC (rev 6088)
+++ sandbox/adsk/2.3r/Common/Renderers/KmlRenderer.cpp	2011-08-23 07:41:18 UTC (rev 6089)
@@ -368,6 +368,16 @@
 
 void KmlRenderer::ProcessOneMarker(double x, double y, RS_MarkerDef& mdef, bool /*allowOverpost*/)
 {
+    //write style
+    RS_UIGraphic& uig = m_layerInfo->graphic();
+    unsigned char* data = uig.data();
+    if(NULL != data)
+    {
+        wchar_t * legendImage = new wchar_t[4096];
+        mbstowcs(legendImage,(const char*)data,4096);
+        WriteStyle(0.5,legendImage);
+    }
+
     char buffer[256];
     m_kmlContent->WriteString("<name><![CDATA[", false);
     m_kmlContent->WriteString(mdef.name(), false);
@@ -617,7 +627,50 @@
     m_kmlContent->WriteString(buffer);
 }
 
+void KmlRenderer::WriteStyle(double scale, const std::wstring& href)
+{
+    if (m_styleContent == NULL)
+    {
+        m_styleContent = new KmlContent();
+    }
 
+    char buffer[256];
+    int thisStyleId = 0;
+    KmlIconStyle key(1, href);
+    KmlIconStyleIdMap::iterator iter = m_iconStyleMap.find(key);
+    if (iter != m_iconStyleMap.end())
+    {
+        thisStyleId = (*iter).second;
+    }
+    else
+    {
+        thisStyleId = m_iconStyleMap[key] = m_styleId;
+
+        //write the style definitions into the style storage
+        sprintf(buffer, "<Style id=\"%d\">", m_styleId++);
+        m_styleContent->WriteString(buffer);
+
+        //line style
+        m_styleContent->WriteString("<IconStyle>",false);
+        m_styleContent->WriteString("<scale>",false);
+        sprintf(buffer, "%f", scale);
+        m_styleContent->WriteString(buffer,false);
+        m_styleContent->WriteString("</scale>",false);
+        m_styleContent->WriteString("<Icon>",false);
+        m_styleContent->WriteString("<href>",false);
+        m_styleContent->WriteString(href,false);
+        m_styleContent->WriteString("</href>",false);
+        m_styleContent->WriteString("</Icon>",false);
+        m_styleContent->WriteString("</IconStyle>");
+
+        m_styleContent->WriteString("</Style>");
+    }
+
+    //write a style reference into the main document
+    sprintf(buffer, "<styleUrl>#%d</styleUrl>", thisStyleId);
+    m_kmlContent->WriteString(buffer);
+}
+
 double KmlRenderer::_MeterToPixels(RS_Units unit, double number)
 {
     double scale_factor;

Modified: sandbox/adsk/2.3r/Common/Renderers/KmlRenderer.h
===================================================================
--- sandbox/adsk/2.3r/Common/Renderers/KmlRenderer.h	2011-08-23 02:07:34 UTC (rev 6088)
+++ sandbox/adsk/2.3r/Common/Renderers/KmlRenderer.h	2011-08-23 07:41:18 UTC (rev 6089)
@@ -29,6 +29,7 @@
 typedef std::map<RS_String, KmlContent*> ThemeMap;
 typedef std::map<KmlLineStyle, int> KmlLineStyleIdMap;
 typedef std::map<KmlPolyStyle, int> KmlPolyStyleIdMap;
+typedef std::map<KmlIconStyle, int> KmlIconStyleIdMap;
 
 class TransformMesh;
 
@@ -167,6 +168,7 @@
     void ProcessOneMarker(double x, double y, RS_MarkerDef& mdef, bool allowOverpost);
     void WriteStyle(RS_FillStyle& fill);
     void WriteStyle(RS_LineStroke& lsym);
+    void WriteStyle(double scale, const std::wstring& href);
     void WriteLinearRing(LineBuffer* plb, int contour);
     void WriteLinearRing(LineBuffer* plb);
     void WriteCoordinates(LineBuffer* plb);
@@ -189,6 +191,7 @@
     int m_styleId;
     KmlLineStyleIdMap m_lineStyleMap;
     KmlPolyStyleIdMap m_polyStyleMap;
+    KmlIconStyleIdMap m_iconStyleMap;
     double m_pixelSize;
     int m_drawOrder;
     double m_elevation;

Modified: sandbox/adsk/2.3r/Common/Renderers/Makefile.am
===================================================================
--- sandbox/adsk/2.3r/Common/Renderers/Makefile.am	2011-08-23 02:07:34 UTC (rev 6088)
+++ sandbox/adsk/2.3r/Common/Renderers/Makefile.am	2011-08-23 07:41:18 UTC (rev 6089)
@@ -36,6 +36,7 @@
   KmlContent.cpp \
   KmlLineStyle.cpp \
   KmlPolyStyle.cpp \
+  KmlIconStyle.cpp \
   KmlRenderer.cpp \
   ObservationMesh.cpp \
   RenderUtil.cpp \
@@ -65,6 +66,7 @@
   KmlContent.h \
   KmlLineStyle.h \
   KmlPolyStyle.h \
+  KmlIconStyle.h \
   KmlRenderer.h \
   ObservationMesh.h \
   Renderers.h \

Modified: sandbox/adsk/2.3r/Common/Renderers/Renderers.vcproj
===================================================================
--- sandbox/adsk/2.3r/Common/Renderers/Renderers.vcproj	2011-08-23 02:07:34 UTC (rev 6088)
+++ sandbox/adsk/2.3r/Common/Renderers/Renderers.vcproj	2011-08-23 07:41:18 UTC (rev 6089)
@@ -501,6 +501,14 @@
 				>
 			</File>
 			<File
+				RelativePath=".\KmlIconStyle.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\KmlIconStyle.h"
+				>
+			</File>
+			<File
 				RelativePath=".\KmlLineStyle.cpp"
 				>
 			</File>

Modified: sandbox/adsk/2.3r/Server/src/Services/Kml/OpGetFeaturesKml.cpp
===================================================================
--- sandbox/adsk/2.3r/Server/src/Services/Kml/OpGetFeaturesKml.cpp	2011-08-23 02:07:34 UTC (rev 6088)
+++ sandbox/adsk/2.3r/Server/src/Services/Kml/OpGetFeaturesKml.cpp	2011-08-23 07:41:18 UTC (rev 6089)
@@ -94,6 +94,43 @@
 
         EndExecution(kml);
     }
+    else if (8 == m_packet.m_NumArguments)
+    {
+        Ptr<MgLayer> layer = (MgLayer*)m_stream->GetObject();
+        Ptr<MgResourceIdentifier> resource = layer->GetLayerDefinition();
+        Ptr<MgEnvelope> extents = (MgEnvelope*)m_stream->GetObject();
+        INT32 width;
+        m_stream->GetInt32(width);
+        INT32 height;
+        m_stream->GetInt32(height);
+        double dpi;
+        m_stream->GetDouble(dpi);
+        INT32 drawOrder;
+        m_stream->GetInt32(drawOrder);
+        STRING agentUri;
+        m_stream->GetString(agentUri);
+        STRING format;
+        m_stream->GetString(format);
+        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_STRING(L"MgEnvelope");
+        MG_LOG_OPERATION_MESSAGE_ADD_INT32(width);
+        MG_LOG_OPERATION_MESSAGE_ADD_INT32(height);
+        MG_LOG_OPERATION_MESSAGE_ADD_DOUBLE(dpi);
+        MG_LOG_OPERATION_MESSAGE_ADD_INT32(drawOrder);
+        MG_LOG_OPERATION_MESSAGE_ADD_STRING(agentUri.c_str());
+        MG_LOG_OPERATION_MESSAGE_ADD_STRING(format.c_str());
+        MG_LOG_OPERATION_MESSAGE_PARAMETERS_END();
+
+        Validate();
+
+        Ptr<MgByteReader> kml =
+            m_service->GetFeaturesKml(layer, extents, width, height, dpi, drawOrder, agentUri, format);
+
+        EndExecution(kml);
+    }
     else
     {
         MG_LOG_OPERATION_MESSAGE_PARAMETERS_START();

Modified: sandbox/adsk/2.3r/Server/src/Services/Kml/ServerKmlService.cpp
===================================================================
--- sandbox/adsk/2.3r/Server/src/Services/Kml/ServerKmlService.cpp	2011-08-23 02:07:34 UTC (rev 6088)
+++ sandbox/adsk/2.3r/Server/src/Services/Kml/ServerKmlService.cpp	2011-08-23 07:41:18 UTC (rev 6089)
@@ -233,6 +233,12 @@
 MgByteReader* MgServerKmlService::GetFeaturesKml(MgLayer* layer, MgEnvelope* extents,
     INT32 width, INT32 height, double dpi, INT32 drawOrder, CREFSTRING format)
 {
+    return GetFeaturesKml(layer, extents, width, height, dpi, drawOrder, L"", format);
+}
+
+MgByteReader* MgServerKmlService::GetFeaturesKml(MgLayer* layer, MgEnvelope* extents, 
+    INT32 width, INT32 height, double dpi, INT32 drawOrder, CREFSTRING agentUri, CREFSTRING format)
+{
     Ptr<MgByteReader> byteReader;
 
     MG_TRY()
@@ -280,7 +286,8 @@
         KmlContent kmlContent;
         kmlContent.StartDocument();
         kmlContent.WriteString("<visibility>1</visibility>");
-        AppendFeatures(layer, ldf.get(), extents, scale, dpi, drawOrder, kmlContent);
+        STRING sessionId = GetSessionId();
+        AppendFeatures(layer, ldf.get(), extents, agentUri, scale, dpi, drawOrder, sessionId, kmlContent);
         kmlContent.EndDocument();
         Ptr<MgByteSource> byteSource = GetByteSource(kmlContent, format);
         if(byteSource != NULL)
@@ -424,17 +431,27 @@
 void MgServerKmlService::AppendFeatures(MgLayer* layer,
                                         MdfModel::LayerDefinition* layerDef,
                                         MgEnvelope* extents,
+                                        CREFSTRING agentUri,
                                         double scale,
                                         double dpi,
                                         INT32 drawOrder,
+                                        CREFSTRING sessionId,
                                         KmlContent& kmlContent)
 {
     MgCSTrans* csTrans = NULL;
     RSMgFeatureReader* rsReader = NULL;
+    char* legendImage = NULL;
 
     MG_TRY()
-
-    RS_UIGraphic uig(NULL, 0, layer->GetLegendLabel());
+    
+    if(!agentUri.empty())
+    {
+        STRING strLegendImage = GetPointStyleImageUrl(agentUri,layer,scale,sessionId);
+        legendImage = new char[4096];
+        wcstombs(legendImage, strLegendImage.c_str(), 4096 );
+    }
+    
+    RS_UIGraphic uig((unsigned char*)legendImage, 0, layer->GetLegendLabel());
     RS_LayerUIInfo layerInfo(layer->GetName(),
                              layer->GetObjectId(),
                              layer->GetSelectable(),
@@ -523,7 +540,7 @@
     }*/
 
     MG_CATCH(L"MgServerKmlService.AppendFeatures")
-
+    delete[] legendImage;
     delete rsReader;
     delete csTrans;
 
@@ -871,3 +888,84 @@
     }
     return sessionId;
 }
+
+STRING MgServerKmlService::GetPointStyleImageUrl(STRING agentUri, MgLayer* layer, double scale, CREFSTRING sessionId)
+{
+    STRING strLegendImage = agentUri + L"?OPERATION=GetLegendImage&amp;LAYERDEFINITION="; 
+    strLegendImage += layer->GetLayerDefinition()->ToString();
+    strLegendImage += L"&amp;SCALE=" ;
+    
+    STRING strScale;
+    MgUtil::DoubleToString(scale,strScale);
+    strLegendImage += strScale;
+
+    STRING strGeomType;
+    STRING strCategoryIndex = L"-1";
+    //get layer definition
+    Ptr<MgResourceIdentifier> resId = layer->GetLayerDefinition();
+    auto_ptr<MdfModel::LayerDefinition> ldf(MgLayerBase::GetLayerDefinition(m_svcResource, resId));
+
+    MdfModel::VectorLayerDefinition* vl = dynamic_cast<MdfModel::VectorLayerDefinition*>(ldf.get());
+    if(vl != NULL)
+    {
+        //get the scale ranges
+        MdfModel::VectorScaleRangeCollection* scaleRanges = vl->GetScaleRanges();
+        MdfModel::VectorScaleRange* range = NULL;
+
+        for (int i = 0; i < scaleRanges->GetCount(); i++)
+        {
+            range = scaleRanges->GetAt(i);
+            double minScale = range->GetMinScale();
+            double maxScale = range->GetMaxScale();
+            if(scale > minScale && scale <= maxScale)
+            {
+                int categoryIndex = -1;
+                MdfModel::FeatureTypeStyleCollection* styleCollection = range->GetFeatureTypeStyles();
+                MdfModel::FeatureTypeStyle* style = NULL;
+                for (int j = 0; j < styleCollection->GetCount(); j++)
+                {
+                    style = styleCollection->GetAt(j);
+                    MdfModel::RuleCollection* ruleCollection = style->GetRules();
+                    for(int k = 0; k < ruleCollection->GetCount(); k++)
+                    {
+                        MdfModel::PointRule* pointRule = dynamic_cast<MdfModel::PointRule*>(ruleCollection->GetAt(k));
+                        MdfModel::CompositeRule* compositeRule = dynamic_cast<MdfModel::CompositeRule*>(ruleCollection->GetAt(k));
+                        
+                        if(NULL != pointRule)
+                        {
+                            strGeomType = L"1"; // FeatureTypeStyleVisitor::ftsPoint
+                        }
+                        else if(NULL != compositeRule)
+                        {
+                            strGeomType = L"4"; //FeatureTypeStyleVisitor::ftsComposite
+
+                            MdfModel::CompositeSymbolization* symbolization = compositeRule->GetSymbolization();
+                            MdfModel::SymbolInstanceCollection* symbolInstanceCollection = symbolization->GetSymbolCollection();
+                            for(int l = 0; l < symbolInstanceCollection->GetCount(); l++)
+                            {
+                                MdfModel::SymbolInstance* symbolInstance = symbolInstanceCollection->GetAt(l);
+                                if(symbolInstance->GetGeometryContext() == MdfModel::SymbolInstance::GeometryContext::gcPoint)
+                                {
+                                    MgUtil::Int32ToString(++categoryIndex,strCategoryIndex);
+                                }
+                                else
+                                {
+                                    ++categoryIndex;
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+    strLegendImage += L"&amp;THEMECATEGORY=";
+    strLegendImage += strCategoryIndex;
+    strLegendImage += L"&amp;TYPE=";
+    strLegendImage += strGeomType;
+    strLegendImage += L"&amp;SESSION=";
+    strLegendImage += sessionId;
+    strLegendImage += L"&amp;VERSION=1";
+
+    return strLegendImage;
+}

Modified: sandbox/adsk/2.3r/Server/src/Services/Kml/ServerKmlService.h
===================================================================
--- sandbox/adsk/2.3r/Server/src/Services/Kml/ServerKmlService.h	2011-08-23 02:07:34 UTC (rev 6088)
+++ sandbox/adsk/2.3r/Server/src/Services/Kml/ServerKmlService.h	2011-08-23 07:41:18 UTC (rev 6089)
@@ -70,6 +70,8 @@
 
     virtual MgByteReader* GetFeaturesKml(MgLayer* layer, MgEnvelope* extents, INT32 width, INT32 height, double dpi, INT32 drawOrder, CREFSTRING format);
 
+    virtual MgByteReader* GetFeaturesKml(MgLayer* layer, MgEnvelope* extents, INT32 width, INT32 height, double dpi, INT32 drawOrder, CREFSTRING agentUri, CREFSTRING format);
+
 private:
 
     void AppendLayer(MgLayer* layer,
@@ -112,6 +114,16 @@
         INT32 drawOrder,
         KmlContent& kmlContent);
 
+    void AppendFeatures(MgLayer* layer,
+        MdfModel::LayerDefinition* layerDef,
+        MgEnvelope* extents,
+        CREFSTRING agentUri,
+        double scale,
+        double dpi,
+        INT32 drawOrder,
+        CREFSTRING sessionId,
+        KmlContent& kmlContent);
+
     MgByteSource* GetByteSource(KmlContent& kmlContent, CREFSTRING format);
 
     void InitializeResourceService();
@@ -128,6 +140,8 @@
     double GetScale(MgEnvelope* llExtents, int width, int height, double dpi);
     STRING GetSessionId();
 
+    STRING GetPointStyleImageUrl(STRING agentUri, MgLayer* layer, double scale, CREFSTRING sessionId);
+
     Ptr<MgResourceService> m_svcResource;
     Ptr<MgFeatureService> m_svcFeature;
     Ptr<MgDrawingService> m_svcDrawing;

Modified: sandbox/adsk/2.3r/Server/src/UnitTesting/TestKmlService.cpp
===================================================================
--- sandbox/adsk/2.3r/Server/src/UnitTesting/TestKmlService.cpp	2011-08-23 02:07:34 UTC (rev 6088)
+++ sandbox/adsk/2.3r/Server/src/UnitTesting/TestKmlService.cpp	2011-08-23 07:41:18 UTC (rev 6089)
@@ -385,10 +385,11 @@
         INT32 height = 717;
         double dpi = 96;
         INT32 drawOrder = 0;
+        STRING agentUri = L"http://myserver/mapguide/mapagent/mapagent.fcgi";
         STRING format = L"KML";
 
         //call GetLayerKml
-        Ptr<MgByteReader> reader = m_svcKml->GetFeaturesKml(layer, extents, width, height, dpi, drawOrder, format);
+        Ptr<MgByteReader> reader = m_svcKml->GetFeaturesKml(layer, extents, width, height, dpi, drawOrder, agentUri, format);
 
         STRING mimeType = reader->GetMimeType();
         CPPUNIT_ASSERT(mimeType.compare(MgMimeType::Kml) == 0);

Modified: sandbox/adsk/2.3r/Web/src/HttpHandler/HttpKmlGetFeatures.cpp
===================================================================
--- sandbox/adsk/2.3r/Web/src/HttpHandler/HttpKmlGetFeatures.cpp	2011-08-23 02:07:34 UTC (rev 6088)
+++ sandbox/adsk/2.3r/Web/src/HttpHandler/HttpKmlGetFeatures.cpp	2011-08-23 07:41:18 UTC (rev 6089)
@@ -42,6 +42,9 @@
     // Get the bounding box
     m_boundingBox = params->GetParameterValue(MgHttpResourceStrings::reqKmlBoundingBox);
 
+    // Get the map agent Uri
+    m_agentUri = hRequest->GetAgentUri();
+
     // Get the requested format
     m_format = params->GetParameterValue(MgHttpResourceStrings::reqKmlFormat);
 
@@ -117,7 +120,7 @@
     Ptr<MgKmlService> kmlService = dynamic_cast<MgKmlService*>(CreateService(MgServiceType::KmlService));
 
     // Get the KML geometries
-    Ptr<MgByteReader> reader = kmlService->GetFeaturesKml(layer, extents, m_width, m_height, m_dpi, m_drawOrder, m_format);
+    Ptr<MgByteReader> reader = kmlService->GetFeaturesKml(layer, extents, m_width, m_height, m_dpi, m_drawOrder, m_agentUri, m_format);
 
     // Set the result
     hResult->SetResultObject(reader, reader->GetMimeType());

Modified: sandbox/adsk/2.3r/Web/src/HttpHandler/HttpKmlGetFeatures.h
===================================================================
--- sandbox/adsk/2.3r/Web/src/HttpHandler/HttpKmlGetFeatures.h	2011-08-23 02:07:34 UTC (rev 6088)
+++ sandbox/adsk/2.3r/Web/src/HttpHandler/HttpKmlGetFeatures.h	2011-08-23 07:41:18 UTC (rev 6089)
@@ -61,6 +61,7 @@
     double m_dpi;
     INT32 m_width;
     INT32 m_height;
+    STRING m_agentUri;
     INT32 m_drawOrder;
 };
 



More information about the mapguide-commits mailing list