[mapguide-commits] r9592 - in trunk/MgDev: . Common/MapGuideCommon/Controller Web/src/HttpHandler
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Wed Aug 7 05:10:44 PDT 2019
Author: jng
Date: 2019-08-07 05:10:44 -0700 (Wed, 07 Aug 2019)
New Revision: 9592
Modified:
trunk/MgDev/
trunk/MgDev/Common/MapGuideCommon/Controller/HtmlController.cpp
trunk/MgDev/Common/MapGuideCommon/Controller/HtmlController.h
trunk/MgDev/Web/src/HttpHandler/HttpQueryMapFeatures.cpp
Log:
Merged revision(s) 9590-9591 from sandbox/jng/querymapfeatures_selectionkey:
Implement MapGuide RFC 176
Index: trunk/MgDev
===================================================================
--- trunk/MgDev 2019-08-05 16:32:31 UTC (rev 9591)
+++ trunk/MgDev 2019-08-07 12:10:44 UTC (rev 9592)
Property changes on: trunk/MgDev
___________________________________________________________________
Modified: svn:mergeinfo
## -21,6 +21,7 ##
/sandbox/jng/geos34x:8256-8259
/sandbox/jng/ogc:9240-9255
/sandbox/jng/php56x:8975-8985
+/sandbox/jng/querymapfeatures_selectionkey:9590-9591
/sandbox/jng/remove_gd:9548-9558
/sandbox/jng/rfc155:8872-8884
/sandbox/jng/simplify:8814-9141
Modified: trunk/MgDev/Common/MapGuideCommon/Controller/HtmlController.cpp
===================================================================
--- trunk/MgDev/Common/MapGuideCommon/Controller/HtmlController.cpp 2019-08-05 16:32:31 UTC (rev 9591)
+++ trunk/MgDev/Common/MapGuideCommon/Controller/HtmlController.cpp 2019-08-07 12:10:44 UTC (rev 9592)
@@ -248,7 +248,8 @@
INT32 layerAttributeFilter,
INT32 requestData,
CREFSTRING selectionColor,
- CREFSTRING selectionFormat)
+ CREFSTRING selectionFormat,
+ bool bIncludeSelectionKey)
{
Ptr<MgByteReader> result;
Ptr<MgFeatureInformation> featureInfo;
@@ -310,7 +311,7 @@
inlineSelectionImg = service->RenderDynamicOverlay(map, newSelection, renderOpts);
}
- result = CollectQueryMapFeaturesResult(resourceService, featureService, map, requestData, featureInfo, newSelection, inlineSelectionImg);
+ result = CollectQueryMapFeaturesResult(resourceService, featureService, map, requestData, featureInfo, newSelection, inlineSelectionImg, bIncludeSelectionKey);
// Return XML
return result.Detach();
@@ -322,7 +323,8 @@
INT32 requestData,
MgFeatureInformation* featInfo,
MgSelection* selectionSet,
- MgByteReader* inlineSelection)
+ MgByteReader* inlineSelection,
+ bool bIncludeSelectionKey)
{
STRING xml;
STRING tooltip;
@@ -390,7 +392,7 @@
if ((requestData & REQUEST_ATTRIBUTES) == REQUEST_ATTRIBUTES)
{
xml.append(L"<SelectedFeatures>\n");
- WriteSelectedFeatureAttributes(resourceService, featureService, map, selectionSet, xml);
+ WriteSelectedFeatureAttributes(resourceService, featureService, map, selectionSet, bIncludeSelectionKey, xml);
xml.append(L"</SelectedFeatures>\n");
}
else
@@ -443,12 +445,13 @@
MgFeatureService* featureService,
MgMapBase* map,
MgSelection* selectionSet,
+ bool bIncludeSelectionKey,
REFSTRING xmlOut)
{
MgAgfReaderWriter agfRw;
MgWktReaderWriter wktRw;
MgCoordinateSystemFactory csFactory;
-
+ MgMemoryStreamHelper streamHelper;
Ptr<MgReadOnlyLayerCollection> selLayers = selectionSet->GetLayers();
if (NULL != selLayers.p)
{
@@ -462,6 +465,7 @@
// are used for property names for each feature. This element provides a reverse lookup table to ascertain the FDO system
// property name for each attribute for client applications that require such information
// [0...n] <Feature> - Each selected feature in the layer
+ // [0...1] <SelectionKey> - Selection key for this feature [only if requested]
// [1] <Bounds> - The feature's bounding box [minx miny maxx maxy]
// [0...n] <Property> - Property value for current feature
@@ -537,9 +541,17 @@
propNames->Add(selLayer->GetFeatureGeometryName()); //Don't forget geometry
xmlOut.append(L"</LayerMetadata>\n");
Ptr<MgReader> reader = selectionSet->GetSelectedFeatures(selLayer, selLayer->GetFeatureClassName(), propNames);
- while(reader->ReadNext())
+ while (reader->ReadNext())
{
xmlOut.append(L"<Feature>\n");
+ if (bIncludeSelectionKey)
+ {
+ STRING selKey = EncodeKey(&streamHelper, reader, selLayer);
+ xmlOut.append(L"<SelectionKey>\n");
+ xmlOut.append(selKey);
+ xmlOut.append(L"</SelectionKey>\n");
+ }
+
STRING geomPropName = selLayer->GetFeatureGeometryName();
if (!reader->IsNull(geomPropName))
{
@@ -730,6 +742,67 @@
}
}
+STRING MgHtmlController::EncodeKey(MgMemoryStreamHelper* stream, MgReader* feature, MgLayerBase* layer)
+{
+ //This is effectively a carbon-copy impl of MgSelectionBase::AddFeatureIds()
+
+ stream->Clear();
+
+ Ptr<MgClassDefinition> classDef = layer->GetClassDefinition();
+ Ptr<MgPropertyDefinitionCollection> props = classDef->GetProperties();
+ MgLayerBase::IdPropertyList propList = layer->GetIdPropertyList();
+ MgLayerBase::IdPropertyList::iterator idIter;
+ for (idIter = propList.begin(); idIter != propList.end(); ++idIter)
+ {
+ switch (idIter->type)
+ {
+ case MgPropertyType::Int16:
+ {
+ stream->WriteUINT16((UINT16)feature->GetInt16(idIter->name));
+ }
+ break;
+ case MgPropertyType::Int32:
+ {
+ stream->WriteUINT32((UINT32)feature->GetInt32(idIter->name));
+ }
+ break;
+ case MgPropertyType::Int64:
+ {
+ stream->WriteINT64(feature->GetInt64(idIter->name));
+ }
+ break;
+ case MgPropertyType::String:
+ {
+ stream->WriteNullTermString(feature->GetString(idIter->name));
+ }
+ break;
+ case MgPropertyType::Double:
+ {
+ stream->WriteDouble(feature->GetDouble(idIter->name));
+ }
+ break;
+ case MgPropertyType::Single:
+ {
+ stream->WriteSingle(feature->GetSingle(idIter->name));
+ }
+ break;
+ case MgPropertyType::DateTime:
+ {
+ Ptr<MgDateTime> dateTime = feature->GetDateTime(idIter->name);
+ Ptr<MgStream> tempStream = new MgStream(stream);
+ dateTime->Serialize(tempStream);
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+ STRING b64;
+ UnicodeString::MultiByteToWideChar(stream->ToBase64().c_str(), b64);
+ return b64;
+}
+
//////////////////////////////////////////////////////////////////
// Generates JavaScript code that can be embedded in an HTML response
// to a non-viewer initiated web application request. The returned code
Modified: trunk/MgDev/Common/MapGuideCommon/Controller/HtmlController.h
===================================================================
--- trunk/MgDev/Common/MapGuideCommon/Controller/HtmlController.h 2019-08-05 16:32:31 UTC (rev 9591)
+++ trunk/MgDev/Common/MapGuideCommon/Controller/HtmlController.h 2019-08-07 12:10:44 UTC (rev 9592)
@@ -205,7 +205,8 @@
INT32 layerAttributeFilter,
INT32 requestData,
CREFSTRING selectionColor,
- CREFSTRING selectionFormat);
+ CREFSTRING selectionFormat,
+ bool bIncludeSelectionKey);
//////////////////////////////////////////////////////////////////
/// \brief
@@ -311,7 +312,8 @@
INT32 requestData,
MgFeatureInformation* featInfo,
MgSelection* selectionSet,
- MgByteReader* inlineSelection);
+ MgByteReader* inlineSelection,
+ bool bIncludeSelectionKey);
//////////////////////////////////////////////////////////////////
/// \brief
@@ -326,10 +328,13 @@
}
private:
+ static STRING EncodeKey(MgMemoryStreamHelper* stream, MgReader* feature, MgLayerBase* layer);
+
static void WriteSelectedFeatureAttributes(MgResourceService* resourceService,
MgFeatureService* featureService,
MgMapBase* map,
MgSelection* selectionSet,
+ bool bIncludeSelectionKey,
REFSTRING xmlOut);
static MgCoordinateSystemTransform* GetLayerToMapTransform(MgLayerBase* layer,
Modified: trunk/MgDev/Web/src/HttpHandler/HttpQueryMapFeatures.cpp
===================================================================
--- trunk/MgDev/Web/src/HttpHandler/HttpQueryMapFeatures.cpp 2019-08-05 16:32:31 UTC (rev 9591)
+++ trunk/MgDev/Web/src/HttpHandler/HttpQueryMapFeatures.cpp 2019-08-07 12:10:44 UTC (rev 9592)
@@ -153,7 +153,9 @@
}
else if (version >= MG_API_VERSION(2, 6, 0))
{
- featureDescriptionInfo = controller.QueryMapFeatures(m_mapName, layerNames, filterGeometry, selectionVariant, m_featureFilter, m_maxFeatures, m_persist, m_layerAttributeFilter, m_requestData, m_selectionColor, m_selectionFormat);
+ //We only render selection keys alongside attributes for v4.0.0 and higher requests
+ bool bIncludeSelectionKey = version >= MG_API_VERSION(4, 0, 0);
+ featureDescriptionInfo = controller.QueryMapFeatures(m_mapName, layerNames, filterGeometry, selectionVariant, m_featureFilter, m_maxFeatures, m_persist, m_layerAttributeFilter, m_requestData, m_selectionColor, m_selectionFormat, bIncludeSelectionKey);
}
//Convert to alternate response format, if necessary
ProcessFormatConversion(featureDescriptionInfo);
More information about the mapguide-commits
mailing list