[mapguide-commits] r6451 - in trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI: . Exceptions Properties Resource/Validation Services

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Tue Jan 24 02:59:49 EST 2012


Author: jng
Date: 2012-01-23 23:59:49 -0800 (Mon, 23 Jan 2012)
New Revision: 6451

Added:
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Exceptions/NullExtentException.cs
Modified:
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/OSGeo.MapGuide.MaestroAPI.csproj
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/PlatformConnectionBase.cs
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Properties/Resources.Designer.cs
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Properties/Resources.resx
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Resource/Validation/BaseMapDefinitionValidator.cs
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Resource/Validation/ValidationStatusCode.cs
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Services/IFeatureService.cs
Log:
#1929: Fix incorrect validation flag when saving a Map Definition that references an empty Feature Source.

Added: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Exceptions/NullExtentException.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Exceptions/NullExtentException.cs	                        (rev 0)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Exceptions/NullExtentException.cs	2012-01-24 07:59:49 UTC (rev 6451)
@@ -0,0 +1,44 @@
+#region Disclaimer / License
+// Copyright (C) 2012, Jackie Ng
+// http://trac.osgeo.org/mapguide/wiki/maestro, jumpinjackie at gmail.com
+// 
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// 
+// 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 Street, Fifth Floor, Boston, MA  02110-1301  USA
+// 
+#endregion
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace OSGeo.MapGuide.MaestroAPI.Exceptions
+{
+    [global::System.Serializable]
+    public class NullExtentException : Exception
+    {
+        //
+        // For guidelines regarding the creation of new exception types, see
+        //    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconerrorraisinghandlingguidelines.asp
+        // and
+        //    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp07192001.asp
+        //
+
+        public NullExtentException() { }
+        public NullExtentException(string message) : base(message) { }
+        public NullExtentException(string message, Exception inner) : base(message, inner) { }
+        protected NullExtentException(
+          System.Runtime.Serialization.SerializationInfo info,
+          System.Runtime.Serialization.StreamingContext context)
+            : base(info, context) { }
+    }
+}

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/OSGeo.MapGuide.MaestroAPI.csproj
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/OSGeo.MapGuide.MaestroAPI.csproj	2012-01-21 15:42:44 UTC (rev 6450)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/OSGeo.MapGuide.MaestroAPI.csproj	2012-01-24 07:59:49 UTC (rev 6451)
@@ -200,6 +200,7 @@
     <Compile Include="Exceptions\MaestroException.cs" />
     <Compile Include="Exceptions\NestedExceptionMessageProcessor.cs" />
     <Compile Include="Exceptions\NsDoc.cs" />
+    <Compile Include="Exceptions\NullExtentException.cs" />
     <Compile Include="Exceptions\ResourceConversionException.cs" />
     <Compile Include="Exceptions\SerializationException.cs" />
     <Compile Include="Exceptions\UnsupportedResourceTypeException.cs" />

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/PlatformConnectionBase.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/PlatformConnectionBase.cs	2012-01-21 15:42:44 UTC (rev 6450)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/PlatformConnectionBase.cs	2012-01-24 07:59:49 UTC (rev 6451)
@@ -39,6 +39,7 @@
 using GeoAPI.Geometries;
 using OSGeo.MapGuide.ObjectModels.LoadProcedure;
 using OSGeo.MapGuide.ObjectModels.LayerDefinition;
+using OSGeo.MapGuide.MaestroAPI.Exceptions;
 
 namespace OSGeo.MapGuide.MaestroAPI
 {
@@ -1578,6 +1579,7 @@
         /// <param name="geometry">The geometry.</param>
         /// <param name="filter">The filter.</param>
         /// <param name="allowFallbackToContextInformation">if set to <c>true</c> [allow fallback to context information].</param>
+        /// <exception cref="T:OSGeo.MapGuide.MaestroAPI.Exceptions.NullExtentException">Thrown if the geometric extent is null</exception>
         /// <returns></returns>
         protected virtual OSGeo.MapGuide.ObjectModels.Common.IEnvelope GetSpatialExtent(string resourceID, string schema, string geometry, string filter, bool allowFallbackToContextInformation)
         {
@@ -1593,10 +1595,13 @@
                     {
                         if (fsr.ReadNext())
                         {
+                            if (fsr.IsNull("EXTENT"))
+                                throw new NullExtentException();
+
                             IGeometry geom = fsr["EXTENT"] as IGeometry;
                             if (geom == null)
                             {
-                                throw new Exception("No data found in resource: " + resourceID);
+                                throw new NullExtentException();
                             }
                             else
                             {

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Properties/Resources.Designer.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Properties/Resources.Designer.cs	2012-01-21 15:42:44 UTC (rev 6450)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Properties/Resources.Designer.cs	2012-01-24 07:59:49 UTC (rev 6451)
@@ -1,7 +1,7 @@
 //------------------------------------------------------------------------------
 // <auto-generated>
 //     This code was generated by a tool.
-//     Runtime Version:2.0.50727.5448
+//     Runtime Version:2.0.50727.4963
 //
 //     Changes to this file may cause incorrect behavior and will be lost if
 //     the code is regenerated.
@@ -918,6 +918,15 @@
         }
         
         /// <summary>
+        ///   Looks up a localized string similar to Map Definition references feature source {0} which has a null extent. Most likely caused by feature source having no actual data inside it.
+        /// </summary>
+        internal static string MDF_LayerWithNullExtent {
+            get {
+                return ResourceManager.GetString("MDF_LayerWithNullExtent", resourceCulture);
+            }
+        }
+        
+        /// <summary>
         ///   Looks up a localized string similar to Layer {0} has no geometry column.
         /// </summary>
         internal static string MDF_MissingLayerGeometryColumnError {

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Properties/Resources.resx
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Properties/Resources.resx	2012-01-21 15:42:44 UTC (rev 6450)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Properties/Resources.resx	2012-01-24 07:59:49 UTC (rev 6451)
@@ -560,4 +560,7 @@
   <data name="ERR_PROPERTY_VALUE_NOT_OF_TYPE" xml:space="preserve">
     <value>The specified property {0} is not of type: {1}</value>
   </data>
+  <data name="MDF_LayerWithNullExtent" xml:space="preserve">
+    <value>Map Definition references feature source {0} which has a null extent. Most likely caused by feature source having no actual data inside it</value>
+  </data>
 </root>
\ No newline at end of file

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Resource/Validation/BaseMapDefinitionValidator.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Resource/Validation/BaseMapDefinitionValidator.cs	2012-01-21 15:42:44 UTC (rev 6450)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Resource/Validation/BaseMapDefinitionValidator.cs	2012-01-24 07:59:49 UTC (rev 6451)
@@ -198,8 +198,16 @@
                             }
                             catch (Exception ex)
                             {
-                                string msg = NestedExceptionMessageProcessor.GetFullMessage(ex);
-                                issues.Add(new ValidationIssue(resource, ValidationStatus.Error, ValidationStatusCode.Error_MapDefinition_ResourceRead, string.Format(Properties.Resources.MDF_ResourceReadError, fs.ResourceID, msg)));
+                                var nex = ex as NullExtentException;
+                                if (nex != null)
+                                {
+                                    issues.Add(new ValidationIssue(resource, ValidationStatus.Warning, ValidationStatusCode.Warning_MapDefinition_FeatureSourceWithNullExtent, string.Format(Properties.Resources.MDF_LayerWithNullExtent, fs.ResourceID)));
+                                }
+                                else
+                                {
+                                    string msg = NestedExceptionMessageProcessor.GetFullMessage(ex);
+                                    issues.Add(new ValidationIssue(resource, ValidationStatus.Error, ValidationStatusCode.Error_MapDefinition_ResourceRead, string.Format(Properties.Resources.MDF_ResourceReadError, fs.ResourceID, msg)));
+                                }
                             }
                         }
                         catch (Exception ex)

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Resource/Validation/ValidationStatusCode.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Resource/Validation/ValidationStatusCode.cs	2012-01-21 15:42:44 UTC (rev 6450)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Resource/Validation/ValidationStatusCode.cs	2012-01-24 07:59:49 UTC (rev 6451)
@@ -161,6 +161,11 @@
         Warning_MapDefinition_MissingCoordinateSystem,
 
         /// <summary>
+        /// The Map Definition contains a referenced feature source that has a null extent (usually caused by having no data in the feature source)
+        /// </summary>
+        Warning_MapDefinition_FeatureSourceWithNullExtent,
+
+        /// <summary>
         /// The specified initial view parameters lie outside the referenced Map Definition's extents. Usually means you will see nothing when the Fusion viewer loads.
         /// </summary>
         Warning_Fusion_InitialViewOutsideMapExtents = 3401,

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Services/IFeatureService.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Services/IFeatureService.cs	2012-01-21 15:42:44 UTC (rev 6450)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Services/IFeatureService.cs	2012-01-24 07:59:49 UTC (rev 6451)
@@ -188,6 +188,7 @@
         /// <param name="schema"></param>
         /// <param name="geometry"></param>
         /// <param name="allowFallbackToContextInformation"></param>
+        /// <exception cref="T:OSGeo.MapGuide.MaestroAPI.Exceptions.NullExtentException">Thrown if the geometric extent is null</exception>
         /// <returns></returns>
         ObjCommon.IEnvelope GetSpatialExtent(string resourceID, string schema, string geometry, bool allowFallbackToContextInformation);
 



More information about the mapguide-commits mailing list