[mapguide-commits] r4231 - in trunk/MgDev: Common/PlatformBase/Services Server/src/Services/Feature

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Wed Sep 16 22:05:31 EDT 2009


Author: leaf
Date: 2009-09-16 22:05:30 -0400 (Wed, 16 Sep 2009)
New Revision: 4231

Modified:
   trunk/MgDev/Common/PlatformBase/Services/FeatureService.h
   trunk/MgDev/Server/src/Services/Feature/OpCreateFeatureSource.cpp
   trunk/MgDev/Server/src/Services/Feature/ServerCreateFeatureSource.cpp
   trunk/MgDev/Server/src/Services/Feature/ServerCreateFeatureSource.h
   trunk/MgDev/Server/src/Services/Feature/ServerFeatureService.h
Log:
Ticket #1055: Implement some new changes to MapGuide RFC 77 - Create Feature Source.
http://trac.osgeo.org/mapguide/wiki/MapGuideRfc77

Previously, MgFeatureService::CreateFeatureSource(...) will throw an MgInvalidArgumentException no feature classes or spatial context are specified in the MgFileFeatureSourceParams instance. If the spatial context and feature class are not known at the time of creation then a "dummy" feature class and spatial context would need to be specified; and then deleted later. 

This change will allow MgFeatureService::CreateFeatureSource(...) to execute without the spatial context and feature class specified. 


Modified: trunk/MgDev/Common/PlatformBase/Services/FeatureService.h
===================================================================
--- trunk/MgDev/Common/PlatformBase/Services/FeatureService.h	2009-09-16 21:54:34 UTC (rev 4230)
+++ trunk/MgDev/Common/PlatformBase/Services/FeatureService.h	2009-09-17 02:05:30 UTC (rev 4231)
@@ -1422,12 +1422,14 @@
     /// \note1
     ///
     /// \remarks
-    /// MgFeatureSourceParams is an abstract class. Currently the
-    /// only concrete class is MgCreateSdfParams, and the only
-    /// feature source that can be created this way is an SDF file.
-    /// You can use this method to create an SDF file with the same
-    /// schema and spatial context definition as the provider that
-    /// you are connected to.
+    /// MgFeatureSourceParams is an abstract class. Currently there
+    /// are two concrete classes MgFileFeatureSourceParams and 
+    /// MgCreateSdfParams and SDF, SHP and SQLite feature source can 
+    /// be created only. If no well-know text format coordinate 
+    /// system is specified in argument sourceParams, this method 
+    /// will not create spatial context for the feature source. For
+    /// SHP feature source, a feature class must be specified.
+    /// Otherwise, an MgInvalidArgumentException will be thrown.
     ///
     /// <!-- Syntax in .Net, Java, and PHP -->
     /// \htmlinclude DotNetSyntaxTop.html

Modified: trunk/MgDev/Server/src/Services/Feature/OpCreateFeatureSource.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Feature/OpCreateFeatureSource.cpp	2009-09-16 21:54:34 UTC (rev 4230)
+++ trunk/MgDev/Server/src/Services/Feature/OpCreateFeatureSource.cpp	2009-09-17 02:05:30 UTC (rev 4231)
@@ -75,7 +75,7 @@
         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"MgCreateSdfParams");
+        MG_LOG_OPERATION_MESSAGE_ADD_STRING(L"MgFileFeatureSourceParams");
         MG_LOG_OPERATION_MESSAGE_PARAMETERS_END();
 
         Validate();

Modified: trunk/MgDev/Server/src/Services/Feature/ServerCreateFeatureSource.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Feature/ServerCreateFeatureSource.cpp	2009-09-16 21:54:34 UTC (rev 4230)
+++ trunk/MgDev/Server/src/Services/Feature/ServerCreateFeatureSource.cpp	2009-09-17 02:05:30 UTC (rev 4231)
@@ -41,14 +41,22 @@
         Ptr<MgServerCreateFileFeatureSource> creator = NULL;
         STRING providerName = params->GetProviderName();
         if (providerName == L"OSGeo.SDF") // NOXLATE
+        {
             creator = new MgServerCreateSdfFeatureSource(resource, params);
+            creator->CreateFeatureSource(false, false);
+        }
         else if (providerName == L"OSGeo.SHP") // NOXLATE
+        {
             creator = new MgServerCreateShpFeatureSource(resource, params);
+            creator->CreateFeatureSource(true, false);
+        }
         else if (providerName == L"OSGeo.SQLite") // NOXLATE
+        {
             creator = new MgServerCreateSqliteFeatureSource(resource, params);
+            creator->CreateFeatureSource(false, false);
+        }
         else
             throw new MgInvalidArgumentException(L"MgServerCreateFeatureSource.CreateFeatureSource", __LINE__, __WFILE__, NULL, L"", NULL);
-        creator->CreateFeatureSource();
     }
 
     MG_FEATURE_SERVICE_CHECK_CONNECTION_CATCH_AND_THROW(resource, L"MgServerCreateFeatureSource.CreateFeatureSource")
@@ -71,7 +79,7 @@
     SAFE_RELEASE(m_params);
 }
 
-void MgServerCreateFileFeatureSource::CreateFeatureSource()
+void MgServerCreateFileFeatureSource::CreateFeatureSource(bool bCheckFeatureClass, bool bCheckSpatialContext)
 {
     //Some basic schema validation:
     //  A schema must be supplied
@@ -83,22 +91,28 @@
     if(schema == NULL)
         throw new MgInvalidArgumentException(L"MgServerCreateFileFeatureSource.CreateFeatureSource", __LINE__, __WFILE__, NULL, L"MgMissingSchema", NULL);
 
-    Ptr<MgClassDefinitionCollection> classes = schema->GetClasses();
-    if(classes == NULL || classes->GetCount() == 0)
-        throw new MgInvalidArgumentException(L"MgServerCreateFileFeatureSource.CreateFeatureSource", __LINE__, __WFILE__, NULL, L"MgMissingClassDef", NULL);
+    if (bCheckFeatureClass)
+    {
+        Ptr<MgClassDefinitionCollection> classes = schema->GetClasses();
+        if(classes == NULL || classes->GetCount() == 0)
+            throw new MgInvalidArgumentException(L"MgServerCreateFileFeatureSource.CreateFeatureSource", __LINE__, __WFILE__, NULL, L"MgMissingClassDef", NULL);
 
-    for(INT32 ci = 0; ci < classes->GetCount(); ci++)
+        for(INT32 ci = 0; ci < classes->GetCount(); ci++)
+        {
+            Ptr<MgClassDefinition> classDef = classes->GetItem(ci);
+            Ptr<MgPropertyDefinitionCollection> idProps = classDef->GetIdentityProperties();
+            if(idProps == NULL || idProps->GetCount() == 0)
+                throw new MgInvalidArgumentException(L"MgServerCreateFileFeatureSource.CreateFeatureSource", __LINE__, __WFILE__, NULL, L"MgClassWOIdentity", NULL);
+        }
+    }
+
+    if (bCheckSpatialContext)
     {
-        Ptr<MgClassDefinition> classDef = classes->GetItem(ci);
-        Ptr<MgPropertyDefinitionCollection> idProps = classDef->GetIdentityProperties();
-        if(idProps == NULL || idProps->GetCount() == 0)
-            throw new MgInvalidArgumentException(L"MgServerCreateFileFeatureSource.CreateFeatureSource", __LINE__, __WFILE__, NULL, L"MgClassWOIdentity", NULL);
+        // A coordinate system must be defined
+        if(m_params->GetCoordinateSystemWkt().empty())
+            throw new MgInvalidArgumentException(L"MgServerCreateFileFeatureSource.CreateFeatureSource", __LINE__, __WFILE__, NULL, L"MgMissingSrs", NULL);
     }
 
-    // A coordinate system must be defined
-    if(m_params->GetCoordinateSystemWkt().empty())
-        throw new MgInvalidArgumentException(L"MgServerCreateFileFeatureSource.CreateFeatureSource", __LINE__, __WFILE__, NULL, L"MgMissingSrs", NULL);
-
     // Connect to provider
     STRING connString = GetFirstConnectionString();
     STRING providerName = m_params->GetProviderName();
@@ -152,13 +166,16 @@
     FdoIConnection* conn)
 {
     // Create the spatialcontext
-    FdoPtr<FdoICreateSpatialContext> spatialContext = (FdoICreateSpatialContext*)conn->CreateCommand(FdoCommandType_CreateSpatialContext);
-    spatialContext->SetCoordinateSystemWkt(m_params->GetCoordinateSystemWkt().c_str());
-    spatialContext->SetDescription(m_params->GetSpatialContextDescription().c_str());
-    spatialContext->SetName(m_params->GetSpatialContextName().c_str());
-    spatialContext->SetXYTolerance(m_params->GetXYTolerance());
-    spatialContext->SetZTolerance(m_params->GetZTolerance());
-    spatialContext->Execute();
+    if (!m_params->GetCoordinateSystemWkt().empty())
+    {
+        FdoPtr<FdoICreateSpatialContext> spatialContext = (FdoICreateSpatialContext*)conn->CreateCommand(FdoCommandType_CreateSpatialContext);
+        spatialContext->SetCoordinateSystemWkt(m_params->GetCoordinateSystemWkt().c_str());
+        spatialContext->SetDescription(m_params->GetSpatialContextDescription().c_str());
+        spatialContext->SetName(m_params->GetSpatialContextName().c_str());
+        spatialContext->SetXYTolerance(m_params->GetXYTolerance());
+        spatialContext->SetZTolerance(m_params->GetZTolerance());
+        spatialContext->Execute();
+    }
 
     // Create and set the schema
     Ptr<MgFeatureSchema> featureSchema = m_params->GetFeatureSchema();

Modified: trunk/MgDev/Server/src/Services/Feature/ServerCreateFeatureSource.h
===================================================================
--- trunk/MgDev/Server/src/Services/Feature/ServerCreateFeatureSource.h	2009-09-16 21:54:34 UTC (rev 4230)
+++ trunk/MgDev/Server/src/Services/Feature/ServerCreateFeatureSource.h	2009-09-17 02:05:30 UTC (rev 4231)
@@ -34,7 +34,7 @@
 public:
     MgServerCreateFileFeatureSource(MgResourceIdentifier* resource, MgFileFeatureSourceParams* params);
     virtual ~MgServerCreateFileFeatureSource();
-    void CreateFeatureSource();
+    void CreateFeatureSource(bool bCheckFeatureClass = false, bool bCheckSpatialContext = false);
     virtual void Dispose();
 
 protected:

Modified: trunk/MgDev/Server/src/Services/Feature/ServerFeatureService.h
===================================================================
--- trunk/MgDev/Server/src/Services/Feature/ServerFeatureService.h	2009-09-16 21:54:34 UTC (rev 4230)
+++ trunk/MgDev/Server/src/Services/Feature/ServerFeatureService.h	2009-09-17 02:05:30 UTC (rev 4231)
@@ -733,124 +733,134 @@
                                                   bool bActiveOnly);
 
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-    /// \brief
+    /// <summary>
     /// Set the active long transaction name for a feature source.
-    ///
-    /// \remarks
-    /// The long transaction name is associated with the caller's session.  If
+    /// The long transaction name is associated with the caller's session. If
     /// no session is set then the method throws an MgSessionNotFoundException.
-    ///
-    /// \param featureSourceId (MgResourceIdentifier)
+    /// </summary>
+    /// <param name="featureSourceId">Input
     /// A resource identifier identifying a feature source in the repository.
-    /// \param longTransactionName (String/string)
+    /// </param>
+    /// <param name="longTransactionName">Input
     /// The long transaction name to set.
-    ///
-    /// \return
+    /// </param>
+    /// <returns>
     /// Returns true if the name was successfully set; otherwise
     /// returns false.
+    /// </returns>
     ///
-    /// \exception MgNullArgumentException
-    /// \exception MgInvalidResourceTypeException
-    /// \exception MgSessionNotFoundException
+    /// EXCEPTIONS:
+    /// MgNullArgumentException
+    /// MgInvalidResourceTypeException
+    /// MgSessionNotFoundException
     ///
     bool SetLongTransaction( MgResourceIdentifier* featureSourceId,
                              CREFSTRING longTransactionName);
 
     //////////////////////////////////////////////////////////////////
-    /// \brief
+    /// <summary>
     /// Retrieves schema information about a set of feature classes for a given feature source.
-    ///
-    /// <!-- Syntax in .Net, Java, and PHP -->
-    /// \htmlinclude DotNetSyntaxTop.html
-    /// virtual MgByteReader CreateFeatureSource(MgResourceIdentifier featureSourceId, MgStringCollection featureClasses);
-    /// \htmlinclude SyntaxBottom.html
-    /// \htmlinclude JavaSyntaxTop.html
-    /// virtual MgByteReader CreateFeatureSource(MgResourceIdentifier featureSourceId, MgStringCollection featureClasses);
-    /// \htmlinclude SyntaxBottom.html
-    /// \htmlinclude PHPSyntaxTop.html
-    /// virtual MgByteReader CreateFeatureSource(MgResourceIdentifier featureSourceId, MgStringCollection featureClasses);
-    /// \htmlinclude SyntaxBottom.html
-    ///
-    /// \param featureSourceId (MgResourceIdentifier)
+    /// </summary>
+    /// <param name="featureSourceId">Input
     /// The resource identifier defining the
     /// location of the feature source in
     /// the repository.
-    /// \param featureClasses (MgStringCollection)
+    /// </param>
+    /// <param name="featureClasses">Input
     /// A collection of strings identifying the feature classes for which to
     /// retrieve schema information. If this collection is null or empty, information
     /// is returned for all feature classes.
-    ///
-    /// \return
+    /// </param>
+    /// <returns>
     /// Returns an MgByteReader containing the XML schema.
+    /// </returns>
     ///
     MgByteReader* DescribeWfsFeatureType(MgResourceIdentifier* featureSourceId, MgStringCollection* featureClasses);
 
     //////////////////////////////////////////////////////////////////
-    /// \brief
+    /// <summary>
     /// Retrieves feature information based on the supplied criteria.
-    ///
-    /// <!-- Syntax in .Net, Java, and PHP -->
-    /// \htmlinclude DotNetSyntaxTop.html
-    /// virtual MgByteReader GetWfsFeature(MgResourceIdentifier featureSourceId, string featureClass, MgStringCollection requiredProperties, string srs, string filter, int maxFeatures);
-    /// \htmlinclude SyntaxBottom.html
-    /// \htmlinclude JavaSyntaxTop.html
-    /// virtual MgByteReader GetWfsFeature(MgResourceIdentifier featureSourceId, String featureClass, MgStringCollection requiredProperties, String srs, String filter, int maxFeatures);
-    /// \htmlinclude SyntaxBottom.html
-    /// \htmlinclude PHPSyntaxTop.html
-    /// virtual MgByteReader GetWfsFeature(MgResourceIdentifier featureSourceId, string featureClass, MgStringCollection requiredProperties, string srs, string filter, int maxFeatures);
-    /// \htmlinclude SyntaxBottom.html
-    ///
-    /// \param featureSourceId (MgResourceIdentifier)
+    /// </summary>
+    /// <param name="featureSourceId">Input
     /// The resource identifier defining the
     /// location of the feature source in
     /// the repository.
-    /// \param featureClass (String/string)
+    /// </param>
+    /// <param name="featureClass">Input
     /// The feature class containing the features to retrieve.
-    /// \param requiredProperties (MgStringCollection)
+    /// </param>
+    /// <param name="requiredProperties">Input
     /// The collection of properties to retrieve for each feature. If the
     /// collection is null or empty, all properties will be retrieved.
-    /// \param srs (String/string)
-    /// The spatial reference system in which to return feature geometries
-    /// \param filter (String/string)
-    /// An XML string containing the definition for an OGC filter
-    /// \param filter (int)
+    /// </param>
+    /// <param name="srs">Input
+    /// The spatial reference system in which to return feature geometries.
+    /// </param>
+    /// <param name="filter">Input
+    /// An XML string containing the definition for an OGC filter.
+    /// </param>
+    /// <param name="maxFeatures">Input
     /// The maximum number of features to retrieve. If the value is less
     /// than or equal to zero, all features will be retrieved.
-    ///
-    /// \return
+    /// </param>
+    /// <returns>
     /// Returns an MgByteReader containing the requested feature information.
+    /// </returns>
     ///
     MgByteReader* GetWfsFeature(MgResourceIdentifier* featureSourceId, CREFSTRING featureClass,
         MgStringCollection* requiredProperties, CREFSTRING srs, CREFSTRING filter, INT32 maxFeatures);
 
     ////////////////////////////////////////////////////////////////////////////////
-    /// \brief
+    /// <summary>
     /// This method enumerates all the providers and if they are FDO enabled for
     /// the specified provider and partial connection string.
-    ///
-    /// \param providerName (String/string)
+    /// </summary>
+    /// <param name="providerName">Input
     /// The name of the Fdo feature provider.
-    /// \param partialConnString (String/string)
+    /// </param>
+    /// <param name="partialConnString">Input
     /// The partial connection string to the Fdo provider.
+    /// </param>
+    /// <returns>
+    /// Returns the list of data stores.
+    /// </returns>
     ///
-    /// \returns
-    /// Returns the list of data stores.
     MgByteReader* EnumerateDataStores(CREFSTRING providerName, CREFSTRING partialConnString);
 
     ////////////////////////////////////////////////////////////////////////////////
-    /// \brief
+    /// <summary>
     /// This method returns all of the logical to physical schema mappings for
     /// the specified provider and partial connection string.
-    ///
-    /// \param providerName (String/string)
+    /// </summary>
+    /// <param name="providerName">Input
     /// The name of the Fdo feature provider.
-    /// \param partialConnString (String/string)
+    /// </param>
+    /// <param name="partialConnString">Input
     /// The partial connection string to the Fdo provider.
+    /// </param>
+    /// <returns>
+    /// Returns the schema mapping.
+    /// </returns>
     ///
-    /// \returns
-    /// Returns the schema mapping.
     MgByteReader* GetSchemaMapping(CREFSTRING providerName, CREFSTRING partialConnString);
 
+    ////////////////////////////////////////////////////////////////////////////////
+    /// <summary>
+    /// Create a feature source using the given feature source parameters and identified by the
+    /// specified resource identifier.
+    /// </summary>
+    /// <param name="featureSourceId">Input
+    /// The resource identifier defining the location of the new feature source in the repository.
+    /// </param>
+    /// <param name="sourceParams">Input
+    /// The feature source parameters (feature schema and spatial context definitions).
+    /// </param>
+    /// <returns>
+    /// Returns nothing.
+    /// </returns>
+    ///
+    void CreateFeatureSource(MgResourceIdentifier* resource, MgFeatureSourceParams* sourceParams);
+
     // Feature
     MgBatchPropertyCollection* GetFeatures(CREFSTRING featureReader);
     bool CloseFeatureReader(CREFSTRING featureReader);
@@ -870,8 +880,6 @@
     STRING SchemaToXml(MgFeatureSchemaCollection* schema);
     MgFeatureSchemaCollection* XmlToSchema(CREFSTRING xml);
 
-    void CreateFeatureSource(MgResourceIdentifier* resource, MgFeatureSourceParams* sourceParams);
-
     //////////////////////////////////////////////////////////////////
     /// \brief
     /// Returns a class definition collection containing identity properties for the specified classes.



More information about the mapguide-commits mailing list