[mapguide-commits] r6325 - in trunk/MgDev/Doc/devguide/source: . images

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Fri Dec 9 07:30:16 EST 2011


Author: jng
Date: 2011-12-09 04:30:16 -0800 (Fri, 09 Dec 2011)
New Revision: 6325

Added:
   trunk/MgDev/Doc/devguide/source/images/platformapi.png
Modified:
   trunk/MgDev/Doc/devguide/source/conf.py
   trunk/MgDev/Doc/devguide/source/digitizing_and_redlining.rst
   trunk/MgDev/Doc/devguide/source/mapguide_advanced.rst
Log:
#1614: More devguide content updates. Also change the sphinx document theme to a more cleaner looking theme (nature)

Modified: trunk/MgDev/Doc/devguide/source/conf.py
===================================================================
--- trunk/MgDev/Doc/devguide/source/conf.py	2011-12-09 10:27:04 UTC (rev 6324)
+++ trunk/MgDev/Doc/devguide/source/conf.py	2011-12-09 12:30:16 UTC (rev 6325)
@@ -95,7 +95,7 @@
 
 # The theme to use for HTML and HTML Help pages.  See the documentation for
 # a list of builtin themes.
-html_theme = 'sphinxdoc'
+html_theme = 'nature'
 
 # Theme options are theme-specific and customize the look and feel of a theme
 # further.  For a list of options available for each theme, see the
@@ -151,7 +151,7 @@
 #html_split_index = False
 
 # If true, links to the reST sources are added to the pages.
-#html_show_sourcelink = True
+html_show_sourcelink = True
 
 # If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
 #html_show_sphinx = True

Modified: trunk/MgDev/Doc/devguide/source/digitizing_and_redlining.rst
===================================================================
--- trunk/MgDev/Doc/devguide/source/digitizing_and_redlining.rst	2011-12-09 10:27:04 UTC (rev 6324)
+++ trunk/MgDev/Doc/devguide/source/digitizing_and_redlining.rst	2011-12-09 12:30:16 UTC (rev 6325)
@@ -107,6 +107,8 @@
     single: Redlining; Creating a Feature Source
     single: Feature Source; Creating
 
+.. _create-feature-source:
+
 Creating a Feature Source
 ^^^^^^^^^^^^^^^^^^^^^^^^^
 

Added: trunk/MgDev/Doc/devguide/source/images/platformapi.png
===================================================================
(Binary files differ)


Property changes on: trunk/MgDev/Doc/devguide/source/images/platformapi.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Modified: trunk/MgDev/Doc/devguide/source/mapguide_advanced.rst
===================================================================
--- trunk/MgDev/Doc/devguide/source/mapguide_advanced.rst	2011-12-09 10:27:04 UTC (rev 6324)
+++ trunk/MgDev/Doc/devguide/source/mapguide_advanced.rst	2011-12-09 12:30:16 UTC (rev 6325)
@@ -6,18 +6,169 @@
 Using Transactions
 ------------------
 
+A transaction encapsulates a unit of work performed on a Feature Source that will either wholly succeed or wholly fail. Transactions ensure the Feature Source is kept in a consistent state whether the operation succeeded or the operation failed.
+
+In the MapGuide API, the **MgTransaction** class represents the transaction to be performed in a Feature Source. The following example shows how to use a transaction over a series of feature operations:
+
+**.net (C#)**
+
+.. highlight:: csharp
+.. code-block:: csharp
+
+    //This code fragment assumes you have imported the OSGeo.MapGuide namespace
+    MgTransaction trans = null;
+    MgFeatureService featSvc = (MgFeatureService)siteConnection.CreateService(MgServiceType.FeatureService);
+    MgResourceIdentifier featureSourceId = new MgResourceIdentifier("Library://Data/Test.FeatureSource");
+    try
+    {
+        //Start the transaction, all changes below will not take effect until the transaction is committed
+        trans = featSvc.StartTransaction(featureSourceId);
+        //This does a SQL insert on the feature source
+        featSvc.ExecuteSql(featureSourceId, "INSERT INTO TABLE1(ID, NAME) VALUES(123, 'Test'), trans);
+        //This does a SQL update on the feature source
+        featSvc.ExecuteSql(featureSourceId, "UPDATE TABLE1 SET NAME = 'Joe Bloggs' WHERE ID = 32", trans);
+        //This does a SQL delete on the feature source
+        featSvc.ExecuteSql(featureSourceId, "DELETE FROM TABLE1 WHERE ID = 456, trans);
+        //Committing the transaction. The above changes will take effect
+        trans.Commit();
+    }
+    catch (MgException ex)
+    {
+        //Rollback the transaction. Any changes that the above SQL commands would've
+        //made are discarded
+        if (trans != null)
+            trans.Rollback();
+    }
+
+.. note::
+
+    Transactions are only supported by certain FDO providers. Check the provider capabilities of the Feature Source to determine if Transactions are available.
+
 Describing a Feature Source
 ---------------------------
 
-Creating a File-based Feature Source
-------------------------------------
+A Feature Source represents a connection to a FDO data store. FDO data stores are modeled in the following fashion:
 
-Feature Source CRUD
--------------------
+ * A data store contains 1 or more Feature Schemas
+ * A Feature Schema contains 1 or more Class Definitions
+ * A Class Definition contains 1 or more Property Definitions
 
+The **MgFeatureService** class provides various methods for describing such aspects of a Feature Source
+
+The following example lists the schema names of a Feature Source
+
+**.net (C#)**
+
+.. highlight:: csharp
+.. code-block:: csharp
+
+    //This code fragment assumes you have imported the OSGeo.MapGuide namespace
+    MgFeatureService featSvc = (MgFeatureService)siteConnection.CreateService(MgServiceType.FeatureService);
+    MgResourceIdentifier featureSourceId = new MgResourceIdentifier("Library://Data/Test.FeatureSource");
+    MgStringCollection schemaNames = featSvc.GetSchemas(featureSourceId);
+    Response.Write("<p>Schema Names:</p><ul>");
+    for (int i = 0; i < schemaNames.GetCount(); i++)
+    {
+        Response.Write("<li>" + schemaNames.GetItem(i) + "</li>");
+    }
+    Response.Write("</ul>");
+    
+The following example lists the class names for a given schema
+
+**.net (C#)**
+
+.. highlight:: csharp
+.. code-block:: csharp
+
+    //This code fragment assumes you have imported the OSGeo.MapGuide namespace
+    MgFeatureService featSvc = (MgFeatureService)siteConnection.CreateService(MgServiceType.FeatureService);
+    MgResourceIdentifier featureSourceId = new MgResourceIdentifier("Library://Data/Test.FeatureSource");
+    MgStringCollection classNames = featSvc.GetClasses(featureSourceId, schemaName);
+    Response.Write("<p>Class Names for " + schemaName + ":</p><ul>");
+    for (int i = 0; i < classNames.GetCount(); i++)
+    {
+        Response.Write("<li>" + classNames.GetItem(i) + "</li>");
+    }
+    Response.Write("</ul>");
+    
+Given a schema name and class name, the following example gets the matching class definition and writes out information about the class definition
+
+**.net (C#)**
+
+.. highlight:: csharp
+.. code-block:: csharp
+
+    //This code fragment assumes you have imported the OSGeo.MapGuide namespace
+    MgFeatureService featSvc = (MgFeatureService)siteConnection.CreateService(MgServiceType.FeatureService);
+    MgResourceIdentifier featureSourceId = new MgResourceIdentifier("Library://Data/Test.FeatureSource");
+    MgClassDefinition classDef = featSvc.GetClassDefinition(featureSourceId, schemaName, className);
+    Response.Write("<p>Name: " + classDef.GetName() + "</p>");
+    Response.Write("<p>Description: " + classDef.GetDescription() + "</p>");
+    Response.Write("<p>Default Geometry Property: " + classDef.GetDefaultGeometryPropertyName() + "</p>");
+    MgPropertyDefinitionCollection identityProps = classDef.GetIdentityProperties();
+    MgPropertyDefinitionCollection clsProps = classDef.GetProperties();
+    Response.Write("<p>Class Properties (* are identity):</p>");
+    Response.Write("<ul>");
+    for (int i = 0; i < clsProps.GetCount(); i++)
+    {
+        MgPropertyDefinition propDef = clsProps.GetItem(i);
+        Response.Write("<li>" + propDef.GetName());
+        if (propDef.GetPropertyType() == MgFeaturePropertyType.AssociationProperty)
+            Response.Write(" (Association)");
+        else if (propDef.GetPropertyType() == MgFeaturePropertyType.DataProperty)
+            Response.Write(" (Data)");
+        else if (propDef.GetPropertyType() == MgFeaturePropertyType.GeometricProperty)
+            Response.Write(" (Geometry)");
+        else if (propDef.GetPropertyType() == MgFeaturePropertyType.ObjectProperty)
+            Response.Write(" (Object)");
+        else if (propDef.GetPropertyType() == MgFeaturePropertyType.RasterProperty)
+            Response.Write(" (Raster)");
+        Response.Write(")");
+        if (identityProps.Contains(propDef))
+            Response.Write(" *");
+        Response.Write("</li>");
+    }
+    Response.Write("</li>");
+    
 Creating and Modifying Schemas
 ------------------------------
 
+The MapGuide API, not only allows you to manipulate data in a data store, it also allows you to create and modify the structure of a data store. :ref:`create-feature-source` showed how to create a data store with a defined schema, the `ApplySchema` API allows you to modify such schemas.
+
+The following example, modifies the `Default` schema by deleting the `Test` class definition inside
+
+**.net (C#)**
+
+.. highlight:: csharp
+.. code-block:: csharp
+
+    //This code fragment assumes you have imported the OSGeo.MapGuide namespace
+    MgFeatureService featSvc = (MgFeatureService)siteConnection.CreateService(MgServiceType.FeatureService);
+    MgResourceIdentifier featureSourceId = new MgResourceIdentifier("Library://Data/Test.FeatureSource");
+    
+    //Get the original "Test" schema
+    MgFeatureSchemaCollection schemas = featSvc.DescribeSchema(featureSourceId, "Default");
+    MgFeatureSchema schema = schemas.GetItem(0);
+    
+    //Find the "Test" class definition and set the deletion flag
+    MgClassDefinitionCollection classes = schema.GetClasses();
+    for (int i = 0; i < classes.GetCount(); i++)
+    {
+        MgClassDefinition cls = classes.GetItem(i);
+        if (cls.GetName() == "Test")
+        {
+            cls.Delete(); //Mark this class definition for deletion
+            break;
+        }
+    }
+    
+    //Apply the schema. This will delete the "Test" class definition
+    featSvc.ApplySchema(featureSourceId, schema);
+    
+.. note::
+
+    Not all data stores support the `ApplySchema` API. Check the FDO provider capabilities of the feature source to determine if such an operation is possible.
+
 Quering Data with Expressions and Filters
 -----------------------------------------
 
@@ -25,4 +176,12 @@
 -------------------
 
 The Geospatial Platform and MapGuide's role in it
--------------------------------------------------
\ No newline at end of file
+-------------------------------------------------
+
+The MapGuide API shares common code with products like AutoCAD Map3D. The common code that is shared between MapGuide and AutoCAD Map3D is known as the Geospatial Platform API
+
+.. image:: images/platformapi.png
+
+The classes for the Geospatial Platform API resides in the MgPlatformBase.dll library and is accessible in .net via the OSGeo.MapGuide.PlatformBase.dll assembly.
+
+By writing code that targets against the Geospatial Platform API (for example, using the `MgMapBase` class instead of `MgMap`) your code is easily portable between other products that are also built on top of it (like AutoCAD Map3D)
\ No newline at end of file



More information about the mapguide-commits mailing list