[mapguide-commits] r9571 - in sandbox/jng/wfs_hits: Common/MapGuideCommon/Services Common/PlatformBase/Services Server/src/Services/Feature
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Fri Jul 12 06:47:29 PDT 2019
Author: jng
Date: 2019-07-12 06:47:29 -0700 (Fri, 12 Jul 2019)
New Revision: 9571
Modified:
sandbox/jng/wfs_hits/Common/MapGuideCommon/Services/ProxyFeatureService.cpp
sandbox/jng/wfs_hits/Common/MapGuideCommon/Services/ProxyFeatureService.h
sandbox/jng/wfs_hits/Common/PlatformBase/Services/FeatureDefs.h
sandbox/jng/wfs_hits/Common/PlatformBase/Services/FeatureService.h
sandbox/jng/wfs_hits/Server/src/Services/Feature/FeatureOperationFactory.cpp
sandbox/jng/wfs_hits/Server/src/Services/Feature/ServerFeatureService.cpp
sandbox/jng/wfs_hits/Server/src/Services/Feature/ServerFeatureService.h
sandbox/jng/wfs_hits/Server/src/Services/Feature/ServerFeatureService.vcxproj
sandbox/jng/wfs_hits/Server/src/Services/Feature/ServerFeatureService.vcxproj.filters
sandbox/jng/wfs_hits/Server/src/Services/Feature/ServerFeatureServiceBuild.cpp
sandbox/jng/wfs_hits/Server/src/Services/Feature/WfsQueryAdapter.cpp
sandbox/jng/wfs_hits/Server/src/Services/Feature/WfsQueryAdapter.h
Log:
Add new internal API GetWfsFeatureTotal which will service WFS GetFeatures in resultType=hits mode
Modified: sandbox/jng/wfs_hits/Common/MapGuideCommon/Services/ProxyFeatureService.cpp
===================================================================
--- sandbox/jng/wfs_hits/Common/MapGuideCommon/Services/ProxyFeatureService.cpp 2019-07-12 12:42:38 UTC (rev 9570)
+++ sandbox/jng/wfs_hits/Common/MapGuideCommon/Services/ProxyFeatureService.cpp 2019-07-12 13:47:29 UTC (rev 9571)
@@ -1505,6 +1505,28 @@
return SAFE_ADDREF((MgProxyFeatureReader*)featReader);
}
+INT32 MgProxyFeatureService::GetWfsFeatureTotal(MgResourceIdentifier* featureSourceId,
+ CREFSTRING featureClass,
+ CREFSTRING filter,
+ INT32 maxFeatures)
+{
+ MgCommand cmd;
+ cmd.ExecuteCommand(m_connProp, // Connection
+ MgCommand::knInt32, // Return type expected
+ MgFeatureServiceOpId::GetWfsFeatureTotal_Id, // Command Code
+ 4, // No of arguments
+ Feature_Service, // Service Id
+ BUILD_VERSION(4, 0, 0), // Operation version
+ MgCommand::knObject, featureSourceId, // Argument#1
+ MgCommand::knString, &featureClass, // Argument#2
+ MgCommand::knString, &filter, // Argument#3
+ MgCommand::knInt32, maxFeatures, // Argument#4
+ MgCommand::knNone); // End of argument
+
+ SetWarning(cmd.GetWarningObject());
+ return cmd.GetReturnValue().val.m_i32;
+}
+
//////////////////////////////////////////////////////////////////
MgBatchPropertyCollection* MgProxyFeatureService::GetFeatures(CREFSTRING featureReader)
{
Modified: sandbox/jng/wfs_hits/Common/MapGuideCommon/Services/ProxyFeatureService.h
===================================================================
--- sandbox/jng/wfs_hits/Common/MapGuideCommon/Services/ProxyFeatureService.h 2019-07-12 12:42:38 UTC (rev 9570)
+++ sandbox/jng/wfs_hits/Common/MapGuideCommon/Services/ProxyFeatureService.h 2019-07-12 13:47:29 UTC (rev 9571)
@@ -1563,6 +1563,49 @@
CREFSTRING filter,
CREFSTRING sortCriteria);
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \brief
+ /// Retrieves the total feature count for the given WFS query
+ ///
+ /// \note1
+ ///
+ /// <!-- Syntax in .Net, Java, and PHP -->
+ /// \htmlinclude DotNetSyntaxTop.html
+ /// virtual int GetWfsFeatureTotal(MgResourceIdentifier featureSourceId, string featureClass, string filter, int maxFeatures);
+ /// \htmlinclude SyntaxBottom.html
+ /// \htmlinclude JavaSyntaxTop.html
+ /// virtual int GetWfsFeatureTotal(MgResourceIdentifier featureSourceId, string featureClass, string filter, int maxFeatures);
+ /// \htmlinclude SyntaxBottom.html
+ /// \htmlinclude PHPSyntaxTop.html
+ /// virtual int GetWfsFeatureTotal(MgResourceIdentifier featureSourceId, string featureClass, string filter, int maxFeatures);
+ /// \htmlinclude SyntaxBottom.html
+ ///
+ /// \param featureSourceId (MgResourceIdentifier)
+ /// The resource identifier defining the
+ /// location of the feature source in
+ /// the repository.
+ /// \param featureClass (String/string)
+ /// The feature class containing the features to retrieve.
+ /// \param filter (String/string)
+ /// An XML string containing the definition for an OGC filter
+ /// \param maxFeatures (int)
+ /// If greater than 0 and less than the real computed total, this will be the value returned
+ ///
+ /// \remarks
+ /// This method is primarily used to service the WFS GetFeatures operation in resultType=hits mode
+ /// where a total is desired over requesting the whole set of feature data
+ ///
+ /// \return
+ /// Returns an MgByteReader containing the requested feature information.
+ ///
+ /// \exception MgInvalidArgumentException
+ ///
+ /// \since 4.0
+ INT32 GetWfsFeatureTotal(MgResourceIdentifier* featureSourceId,
+ CREFSTRING featureClass,
+ CREFSTRING filter,
+ INT32 maxFeatures);
+
////////////////////////////////////////////////////////////////////////////////
/// \brief
/// This method enumerates all the providers and if they are FDO enabled for
Modified: sandbox/jng/wfs_hits/Common/PlatformBase/Services/FeatureDefs.h
===================================================================
--- sandbox/jng/wfs_hits/Common/PlatformBase/Services/FeatureDefs.h 2019-07-12 12:42:38 UTC (rev 9570)
+++ sandbox/jng/wfs_hits/Common/PlatformBase/Services/FeatureDefs.h 2019-07-12 13:47:29 UTC (rev 9571)
@@ -85,6 +85,7 @@
static const int SelectFeaturesWithTransform = 0x1111ED35;
static const int GetWfsReader_Id = 0x1111ED36;
+ static const int GetWfsFeatureTotal_Id = 0x1111ED37;
};
/// \endcond
Modified: sandbox/jng/wfs_hits/Common/PlatformBase/Services/FeatureService.h
===================================================================
--- sandbox/jng/wfs_hits/Common/PlatformBase/Services/FeatureService.h 2019-07-12 12:42:38 UTC (rev 9570)
+++ sandbox/jng/wfs_hits/Common/PlatformBase/Services/FeatureService.h 2019-07-12 13:47:29 UTC (rev 9571)
@@ -2046,13 +2046,13 @@
///
/// <!-- Syntax in .Net, Java, and PHP -->
/// \htmlinclude DotNetSyntaxTop.html
- /// virtual MgFeatureReader GetWfsReader(MgResourceIdentifier featureSourceId, string featureClass, MgStringCollection requiredProperties, string srs, string filter, int maxFeatures, string outputFormat, string sortCriteria);
+ /// virtual MgFeatureReader GetWfsReader(MgResourceIdentifier featureSourceId, string featureClass, MgStringCollection requiredProperties, string srs, string filter, string sortCriteria);
/// \htmlinclude SyntaxBottom.html
/// \htmlinclude JavaSyntaxTop.html
- /// virtual MgFeatureReader GetWfsReader(MgResourceIdentifier featureSourceId, string featureClass, MgStringCollection requiredProperties, string srs, string filter, int maxFeatures, string outputFormat, string sortCriteria);
+ /// virtual MgFeatureReader GetWfsReader(MgResourceIdentifier featureSourceId, string featureClass, MgStringCollection requiredProperties, string srs, string filter, string sortCriteria);
/// \htmlinclude SyntaxBottom.html
/// \htmlinclude PHPSyntaxTop.html
- /// virtual MgFeatureReader GetWfsReader(MgResourceIdentifier featureSourceId, string featureClass, MgStringCollection requiredProperties, string srs, string filter, int maxFeatures, string outputFormat, string sortCriteria);
+ /// virtual MgFeatureReader GetWfsReader(MgResourceIdentifier featureSourceId, string featureClass, MgStringCollection requiredProperties, string srs, string filter, string sortCriteria);
/// \htmlinclude SyntaxBottom.html
///
/// \param featureSourceId (MgResourceIdentifier)
@@ -2122,6 +2122,49 @@
INTERNAL_API:
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \brief
+ /// Retrieves the total feature count for the given WFS query
+ ///
+ /// \note1
+ ///
+ /// <!-- Syntax in .Net, Java, and PHP -->
+ /// \htmlinclude DotNetSyntaxTop.html
+ /// virtual int GetWfsFeatureTotal(MgResourceIdentifier featureSourceId, string featureClass, string filter, int maxFeatures);
+ /// \htmlinclude SyntaxBottom.html
+ /// \htmlinclude JavaSyntaxTop.html
+ /// virtual int GetWfsFeatureTotal(MgResourceIdentifier featureSourceId, string featureClass, string filter, int maxFeatures);
+ /// \htmlinclude SyntaxBottom.html
+ /// \htmlinclude PHPSyntaxTop.html
+ /// virtual int GetWfsFeatureTotal(MgResourceIdentifier featureSourceId, string featureClass, string filter, int maxFeatures);
+ /// \htmlinclude SyntaxBottom.html
+ ///
+ /// \param featureSourceId (MgResourceIdentifier)
+ /// The resource identifier defining the
+ /// location of the feature source in
+ /// the repository.
+ /// \param featureClass (String/string)
+ /// The feature class containing the features to retrieve.
+ /// \param filter (String/string)
+ /// An XML string containing the definition for an OGC filter
+ /// \param maxFeatures (int)
+ /// If greater than 0 and less than the real computed total, this will be the value returned
+ ///
+ /// \remarks
+ /// This method is primarily used to service the WFS GetFeatures operation in resultType=hits mode
+ /// where a total is desired over requesting the whole set of feature data
+ ///
+ /// \return
+ /// Returns an MgByteReader containing the requested feature information.
+ ///
+ /// \exception MgInvalidArgumentException
+ ///
+ /// \since 4.0
+ virtual INT32 GetWfsFeatureTotal(MgResourceIdentifier* featureSourceId,
+ CREFSTRING featureClass,
+ CREFSTRING filter,
+ INT32 maxFeatures) = 0;
+
//////////////////////////////////////////////////////////////////
/// \brief
/// Construct an MgFeatureService object.
Modified: sandbox/jng/wfs_hits/Server/src/Services/Feature/FeatureOperationFactory.cpp
===================================================================
--- sandbox/jng/wfs_hits/Server/src/Services/Feature/FeatureOperationFactory.cpp 2019-07-12 12:42:38 UTC (rev 9570)
+++ sandbox/jng/wfs_hits/Server/src/Services/Feature/FeatureOperationFactory.cpp 2019-07-12 13:47:29 UTC (rev 9571)
@@ -59,6 +59,7 @@
#include "OpDescribeWfsFeatureType.h"
#include "OpGetWfsFeature.h"
#include "OpGetWfsReader.h"
+#include "OpGetWfsFeatureTotal.h"
#include "OpEnumerateDataStores.h"
#include "OpGetSchemaMapping.h"
#include "OpGetFdoCacheInfo.h"
@@ -592,6 +593,18 @@
}
break;
+ case MgFeatureServiceOpId::GetWfsFeatureTotal_Id:
+ switch (VERSION_NO_PHASE(operationVersion))
+ {
+ case VERSION_SUPPORTED(4, 0):
+ handler.reset(new MgOpGetWfsFeatureTotal());
+ break;
+ default:
+ throw new MgInvalidOperationVersionException(
+ L"MgFeatureOperationFactory.GetOperation", __LINE__, __WFILE__, NULL, L"", NULL);
+ }
+ break;
+
case MgFeatureServiceOpId::EnumerateDataStores_Id:
switch (VERSION_NO_PHASE(operationVersion))
{
Modified: sandbox/jng/wfs_hits/Server/src/Services/Feature/ServerFeatureService.cpp
===================================================================
--- sandbox/jng/wfs_hits/Server/src/Services/Feature/ServerFeatureService.cpp 2019-07-12 12:42:38 UTC (rev 9570)
+++ sandbox/jng/wfs_hits/Server/src/Services/Feature/ServerFeatureService.cpp 2019-07-12 13:47:29 UTC (rev 9571)
@@ -2067,6 +2067,28 @@
}
+INT32 MgServerFeatureService::GetWfsFeatureTotal(MgResourceIdentifier* fs,
+ CREFSTRING featureClass,
+ CREFSTRING wfsFilter,
+ INT32 maxFeatures)
+{
+ INT32 total = -1;
+
+ MG_LOG_TRACE_ENTRY(L"MgServerFeatureService::GetWfsFeatureTotal()");
+
+ Ptr<MgFeatureReader> mgfReader;
+
+ MG_FEATURE_SERVICE_TRY()
+
+ MgWfsQueryAdapter wfsQuery(this);
+ wfsQuery.SetOptions(fs, featureClass, NULL, L"", wfsFilter, L"");
+ total = wfsQuery.GetTotal(maxFeatures);
+
+ MG_FEATURE_SERVICE_CHECK_CONNECTION_CATCH_AND_THROW(fs, L"MgServerFeatureService.GetWfsFeatureTotal")
+
+ return total;
+}
+
////////////////////////////////////////////////////////////////////////////////////////////////////////
/// \brief
/// Retrieves feature information based on the supplied criteria with specified format.
Modified: sandbox/jng/wfs_hits/Server/src/Services/Feature/ServerFeatureService.h
===================================================================
--- sandbox/jng/wfs_hits/Server/src/Services/Feature/ServerFeatureService.h 2019-07-12 12:42:38 UTC (rev 9570)
+++ sandbox/jng/wfs_hits/Server/src/Services/Feature/ServerFeatureService.h 2019-07-12 13:47:29 UTC (rev 9571)
@@ -952,6 +952,11 @@
CREFSTRING filter,
CREFSTRING sortCriteria);
+ INT32 GetWfsFeatureTotal(MgResourceIdentifier* featureSourceId,
+ CREFSTRING featureClass,
+ CREFSTRING filter,
+ INT32 maxFeatures);
+
////////////////////////////////////////////////////////////////////////////////
/// <summary>
/// This method enumerates all the providers and if they are FDO enabled for
Modified: sandbox/jng/wfs_hits/Server/src/Services/Feature/ServerFeatureService.vcxproj
===================================================================
--- sandbox/jng/wfs_hits/Server/src/Services/Feature/ServerFeatureService.vcxproj 2019-07-12 12:42:38 UTC (rev 9570)
+++ sandbox/jng/wfs_hits/Server/src/Services/Feature/ServerFeatureService.vcxproj 2019-07-12 13:47:29 UTC (rev 9571)
@@ -513,6 +513,12 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
+ <ClCompile Include="OpGetWfsFeatureTotal.cpp">
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
+ </ClCompile>
<ClCompile Include="OpXmlToSchema.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
@@ -864,6 +870,7 @@
<ClInclude Include="OpGetSpatialContexts.h" />
<ClInclude Include="OpGetSqlRows.h" />
<ClInclude Include="OpGetWfsFeature.h" />
+ <ClInclude Include="OpGetWfsFeatureTotal.h" />
<ClInclude Include="OpGetWfsReader.h" />
<ClInclude Include="OpInsertFeatures.h" />
<ClInclude Include="OpInsertFeaturesBatched.h" />
Modified: sandbox/jng/wfs_hits/Server/src/Services/Feature/ServerFeatureService.vcxproj.filters
===================================================================
--- sandbox/jng/wfs_hits/Server/src/Services/Feature/ServerFeatureService.vcxproj.filters 2019-07-12 12:42:38 UTC (rev 9570)
+++ sandbox/jng/wfs_hits/Server/src/Services/Feature/ServerFeatureService.vcxproj.filters 2019-07-12 13:47:29 UTC (rev 9571)
@@ -205,6 +205,9 @@
<Filter>Ops</Filter>
</ClCompile>
<ClCompile Include="WfsQueryAdapter.cpp" />
+ <ClCompile Include="OpGetWfsFeatureTotal.cpp">
+ <Filter>Ops</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="FeatureOperation.h">
@@ -419,6 +422,9 @@
<Filter>Ops</Filter>
</ClInclude>
<ClInclude Include="WfsQueryAdapter.h" />
+ <ClInclude Include="OpGetWfsFeatureTotal.h">
+ <Filter>Ops</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="ServerFeatureService.rc" />
Modified: sandbox/jng/wfs_hits/Server/src/Services/Feature/ServerFeatureServiceBuild.cpp
===================================================================
--- sandbox/jng/wfs_hits/Server/src/Services/Feature/ServerFeatureServiceBuild.cpp 2019-07-12 12:42:38 UTC (rev 9570)
+++ sandbox/jng/wfs_hits/Server/src/Services/Feature/ServerFeatureServiceBuild.cpp 2019-07-12 13:47:29 UTC (rev 9571)
@@ -86,6 +86,7 @@
#include "OpGetIdentityProperties.cpp"
#include "OpDescribeWfsFeatureType.cpp"
#include "OpGetWfsFeature.cpp"
+#include "OpGetWfsFeatureTotal.cpp"
#include "OpGetWfsReader.cpp"
#include "FilterUtil.cpp"
#include "WfsQueryAdapter.cpp"
Modified: sandbox/jng/wfs_hits/Server/src/Services/Feature/WfsQueryAdapter.cpp
===================================================================
--- sandbox/jng/wfs_hits/Server/src/Services/Feature/WfsQueryAdapter.cpp 2019-07-12 12:42:38 UTC (rev 9570)
+++ sandbox/jng/wfs_hits/Server/src/Services/Feature/WfsQueryAdapter.cpp 2019-07-12 13:47:29 UTC (rev 9571)
@@ -213,4 +213,29 @@
fr = m_featSvc->SelectFeatures(m_fs, m_className, m_options);
MG_FEATURE_SERVICE_CHECK_CONNECTION_CATCH_AND_THROW(m_fs, L"MgWfsQueryAdapter.GetWfsReader")
return fr.Detach();
+}
+
+INT32 MgWfsQueryAdapter::GetTotal(INT32 maxFeatures)
+{
+ INT32 total = 0;
+
+ MG_FEATURE_SERVICE_TRY()
+ // TODO: can FeatureName be an extension name rather than a FeatureClass?
+ Ptr<MgFeatureReader> fr = m_featSvc->SelectFeatures(m_fs, m_className, m_options);
+
+ // You may think: Why are we raw spinning this reader? We have select aggregates (with COUNT())
+ // and other performant shortcuts available, but the real stickler is the maxFeatures parameter
+ // passed in. WFS queries allow for this to be passed in and if we get one, we must respect
+ // the value. None of our performant shortcuts allow us to apply an upper limit on it. So given
+ // these constraints, raw spinning the feature reader is the only viable option.
+ while (fr->ReadNext())
+ {
+ total++;
+ //Break loop if we hit max features
+ if (maxFeatures > 0 && total >= maxFeatures)
+ break;
+ }
+
+ MG_FEATURE_SERVICE_CHECK_CONNECTION_CATCH_AND_THROW(m_fs, L"MgWfsQueryAdapter.GetWfsReader")
+ return total;
}
\ No newline at end of file
Modified: sandbox/jng/wfs_hits/Server/src/Services/Feature/WfsQueryAdapter.h
===================================================================
--- sandbox/jng/wfs_hits/Server/src/Services/Feature/WfsQueryAdapter.h 2019-07-12 12:42:38 UTC (rev 9570)
+++ sandbox/jng/wfs_hits/Server/src/Services/Feature/WfsQueryAdapter.h 2019-07-12 13:47:29 UTC (rev 9571)
@@ -37,6 +37,7 @@
MgCoordinateSystem* GetMapCs();
MgCoordinateSystemTransform* GetTransform();
MgClassDefinition* GetClassDefinition();
+ INT32 GetTotal(INT32 maxFeatures);
private:
Ptr<MgClassDefinition> m_classDef;
More information about the mapguide-commits
mailing list