[mapguide-commits] r4838 - in trunk/Tools/Maestro: . Maestro Maestro/ResourceEditors Maestro/ResourceEditors/FeatureSourceEditors/ODBC MaestroAPI

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Wed May 5 09:58:23 EDT 2010


Author: jng
Date: 2010-05-05 09:58:21 -0400 (Wed, 05 May 2010)
New Revision: 4838

Added:
   trunk/Tools/Maestro/MaestroAPI/CoordinateSystem.cs
   trunk/Tools/Maestro/MaestroAPI/CoordinateSystemCatalog.cs
   trunk/Tools/Maestro/MaestroAPI/CoordinateSystemCategory.cs
   trunk/Tools/Maestro/MaestroAPI/HttpCoordinateSystemCatalog.cs
   trunk/Tools/Maestro/MaestroAPI/HttpCoordinateSystemCategory.cs
   trunk/Tools/Maestro/MaestroAPI/ICoordinateSystemCatalog.cs
   trunk/Tools/Maestro/MaestroAPI/LocalNativeCoordinateSystemCatalog.cs
   trunk/Tools/Maestro/MaestroAPI/LocalNativeCoordinateSystemCategory.cs
Removed:
   trunk/Tools/Maestro/MaestroAPI/ICoordinateSystem.cs
Modified:
   trunk/Tools/Maestro/Maestro/ResourceEditors/FeatureSourceEditors/ODBC/FeatureSourceEditorODBC.cs
   trunk/Tools/Maestro/Maestro/ResourceEditors/MapEditor.cs
   trunk/Tools/Maestro/Maestro/ResourceEditors/SelectCoordinateSystem.cs
   trunk/Tools/Maestro/Maestro/ResourceProperties.cs
   trunk/Tools/Maestro/MaestroAPI/HttpCoordinateSystem.cs
   trunk/Tools/Maestro/MaestroAPI/HttpServerConnection.cs
   trunk/Tools/Maestro/MaestroAPI/LocalNativeConnection.cs
   trunk/Tools/Maestro/MaestroAPI/LocalNativeCoordinateSystem.cs
   trunk/Tools/Maestro/MaestroAPI/OSGeo.MapGuide.MaestroAPI.csproj
   trunk/Tools/Maestro/MaestroAPI/ServerConnectionI.cs
   trunk/Tools/Maestro/MapGuide Maestro.sln
Log:
#1350: Refactor Coordinate System API so that http/native implementations reside in separate classes. Also rename some types and properties to avoid confusion.

Modified: trunk/Tools/Maestro/Maestro/ResourceEditors/FeatureSourceEditors/ODBC/FeatureSourceEditorODBC.cs
===================================================================
--- trunk/Tools/Maestro/Maestro/ResourceEditors/FeatureSourceEditors/ODBC/FeatureSourceEditorODBC.cs	2010-05-05 13:03:36 UTC (rev 4837)
+++ trunk/Tools/Maestro/Maestro/ResourceEditors/FeatureSourceEditors/ODBC/FeatureSourceEditorODBC.cs	2010-05-05 13:58:21 UTC (rev 4838)
@@ -405,7 +405,7 @@
                 string wkt = m_feature.SupplementalSpatialContextInfo[0].CoordinateSystem;
                 //m_feature.SupplementalSpatialContextInfo = null;
 
-                string name = m_editor.CurrentConnection.CoordinateSystem.ConvertWktToCoordinateSystemCode(wkt);
+                string name = m_editor.CurrentConnection.CoordinateSystemCatalog.ConvertWktToCoordinateSystemCode(wkt);
 
                 if (wkt != m_wkt)
                     //TODO: Figure out how to get the coordsys extent

Modified: trunk/Tools/Maestro/Maestro/ResourceEditors/MapEditor.cs
===================================================================
--- trunk/Tools/Maestro/Maestro/ResourceEditors/MapEditor.cs	2010-05-05 13:03:36 UTC (rev 4837)
+++ trunk/Tools/Maestro/Maestro/ResourceEditors/MapEditor.cs	2010-05-05 13:58:21 UTC (rev 4838)
@@ -195,14 +195,14 @@
                     txtDescription.Text = m_map.Metadata.Replace("<MapDescription>", "").Replace("</MapDescription>", "");
                 }
 
-				if (m_editor.CurrentConnection.CoordinateSystem == null || m_map.CoordinateSystem == null || m_map.CoordinateSystem.Length == 0 || !m_editor.CurrentConnection.CoordinateSystem.IsLoaded)
+				if (m_editor.CurrentConnection.CoordinateSystemCatalog == null || m_map.CoordinateSystem == null || m_map.CoordinateSystem.Length == 0 || !m_editor.CurrentConnection.CoordinateSystemCatalog.IsLoaded)
 					txtCoordsys.Text = m_map.CoordinateSystem;
 				else
 				{
 					try
 					{
-						string coordcode = m_editor.CurrentConnection.CoordinateSystem.ConvertWktToCoordinateSystemCode(m_map.CoordinateSystem);
-						txtCoordsys.Text = m_editor.CurrentConnection.CoordinateSystem.FindCoordSys(coordcode).ToString();
+						string coordcode = m_editor.CurrentConnection.CoordinateSystemCatalog.ConvertWktToCoordinateSystemCode(m_map.CoordinateSystem);
+						txtCoordsys.Text = m_editor.CurrentConnection.CoordinateSystemCatalog.FindCoordSys(coordcode).ToString();
 					}
 					catch
 					{

Modified: trunk/Tools/Maestro/Maestro/ResourceEditors/SelectCoordinateSystem.cs
===================================================================
--- trunk/Tools/Maestro/Maestro/ResourceEditors/SelectCoordinateSystem.cs	2010-05-05 13:03:36 UTC (rev 4837)
+++ trunk/Tools/Maestro/Maestro/ResourceEditors/SelectCoordinateSystem.cs	2010-05-05 13:58:21 UTC (rev 4838)
@@ -58,10 +58,10 @@
 
 		private OSGeo.MapGuide.MaestroAPI.ServerConnectionI m_connection;
 
-		private OSGeo.MapGuide.MaestroAPI.HttpCoordinateSystem.CoordSys m_wktCoordSys = null;
-		private OSGeo.MapGuide.MaestroAPI.HttpCoordinateSystem.CoordSys m_epsgCoordSys = null;
-		private OSGeo.MapGuide.MaestroAPI.HttpCoordinateSystem.CoordSys m_coordsysCodeCoordSys = null;
-		private OSGeo.MapGuide.MaestroAPI.HttpCoordinateSystem.CoordSys m_selectedCoordsys = null;
+		private OSGeo.MapGuide.MaestroAPI.CoordinateSystem m_wktCoordSys = null;
+		private OSGeo.MapGuide.MaestroAPI.CoordinateSystem m_epsgCoordSys = null;
+		private OSGeo.MapGuide.MaestroAPI.CoordinateSystem m_coordsysCodeCoordSys = null;
+		private OSGeo.MapGuide.MaestroAPI.CoordinateSystem m_selectedCoordsys = null;
 
 		private System.Windows.Forms.Label CoordinateWait;
 		private System.Windows.Forms.ComboBox EPSGCodeText;
@@ -78,7 +78,7 @@
 			: this()
 		{
 			m_connection = connection;
-			if (m_connection.CoordinateSystem == null)
+			if (m_connection.CoordinateSystemCatalog == null)
 			{
 				SelectByList.Enabled = 
 					SelectByCoordSysCode.Enabled =
@@ -92,7 +92,7 @@
 			else
 			{
 				CoordinateCategory.Items.Clear();
-				CoordinateCategory.Items.AddRange(m_connection.CoordinateSystem.Categories);
+				CoordinateCategory.Items.AddRange(m_connection.CoordinateSystemCatalog.Categories);
 			}
 		}
 
@@ -359,12 +359,12 @@
 			CoordinateWait.Visible = true;
 			CoordinateWait.BringToFront();
 			this.Refresh();
-			m_connection.CoordinateSystem.FindCoordSys("");
+			m_connection.CoordinateSystemCatalog.FindCoordSys("");
 
-			OSGeo.MapGuide.MaestroAPI.HttpCoordinateSystem.CoordSys[] items = null;
+			OSGeo.MapGuide.MaestroAPI.CoordinateSystem[] items = null;
 			try
 			{
-				items = m_connection.CoordinateSystem.Coordsys;
+				items = m_connection.CoordinateSystemCatalog.Coordsys;
 			}
 			catch
 			{
@@ -375,7 +375,7 @@
 			{
 				EPSGCodeText.Items.Clear();
 				if (items != null)
-					foreach(OSGeo.MapGuide.MaestroAPI.HttpCoordinateSystem.CoordSys c in items)
+					foreach(OSGeo.MapGuide.MaestroAPI.CoordinateSystem c in items)
 						if (c.Code.StartsWith("EPSG:"))
 							EPSGCodeText.Items.Add(c.EPSG);
 			}
@@ -389,7 +389,7 @@
 			{
 				CoordSysCodeText.Items.Clear();
 				if (items != null)
-					foreach(OSGeo.MapGuide.MaestroAPI.HttpCoordinateSystem.CoordSys c in items)
+					foreach(OSGeo.MapGuide.MaestroAPI.CoordinateSystem c in items)
 						CoordSysCodeText.Items.Add(c.Code);
 			}
 			finally
@@ -425,7 +425,7 @@
 				if (CoordinateCategory.SelectedIndex >= 0 && CoordinateSystem.SelectedIndex >= 0)
 					OKBtn.Enabled = true;
 			}
-			else if (m_connection.CoordinateSystem == null)
+			else if (m_connection.CoordinateSystemCatalog == null)
 				OKBtn.Enabled = true;
 			else if (SelectByWKT.Checked)
 				OKBtn.Enabled = m_wktCoordSys != null;
@@ -460,7 +460,7 @@
 			CoordinateSystem.Enabled = CoordinateSystemLabel.Enabled = CoordinateCategory.SelectedIndex >= 0;
 			if (CoordinateCategory.SelectedIndex >= 0)
 			{
-				OSGeo.MapGuide.MaestroAPI.HttpCoordinateSystem.Category cat = CoordinateCategory.SelectedItem as OSGeo.MapGuide.MaestroAPI.HttpCoordinateSystem.Category;
+				OSGeo.MapGuide.MaestroAPI.CoordinateSystemCategory cat = CoordinateCategory.SelectedItem as OSGeo.MapGuide.MaestroAPI.CoordinateSystemCategory;
 				if (cat == null)
 				{
 					OKBtn.Enabled = false;
@@ -474,9 +474,9 @@
 
 		private void UpdateOthers()
 		{
-			OSGeo.MapGuide.MaestroAPI.HttpCoordinateSystem.CoordSys selectedCoordsys;
+			OSGeo.MapGuide.MaestroAPI.CoordinateSystem selectedCoordsys;
 			if (SelectByList.Checked)
-				selectedCoordsys = CoordinateSystem.SelectedItem as OSGeo.MapGuide.MaestroAPI.HttpCoordinateSystem.CoordSys;
+				selectedCoordsys = CoordinateSystem.SelectedItem as OSGeo.MapGuide.MaestroAPI.CoordinateSystem;
 			else if (SelectByCoordSysCode.Checked)
 				selectedCoordsys = m_coordsysCodeCoordSys;
 			else if (SelectByWKT.Checked)
@@ -558,12 +558,12 @@
 			try
 			{
 				m_wktCoordSys = null;
-				if (m_connection.CoordinateSystem.IsValid(WKTText.Text))
+				if (m_connection.CoordinateSystemCatalog.IsValid(WKTText.Text))
 				{
 					try
 					{
-						string coordcode = m_connection.CoordinateSystem.ConvertWktToCoordinateSystemCode(WKTText.Text);
-						m_wktCoordSys = m_connection.CoordinateSystem.FindCoordSys(coordcode);
+						string coordcode = m_connection.CoordinateSystemCatalog.ConvertWktToCoordinateSystemCode(WKTText.Text);
+						m_wktCoordSys = m_connection.CoordinateSystemCatalog.FindCoordSys(coordcode);
 					}
 					catch
 					{
@@ -571,7 +571,7 @@
 
 					if (m_wktCoordSys == null)
 					{
-						m_wktCoordSys = new OSGeo.MapGuide.MaestroAPI.HttpCoordinateSystem.CoordSys();
+                        m_wktCoordSys = m_connection.CoordinateSystemCatalog.CreateEmptyCoordinateSystem();
 						m_wktCoordSys.Code = null;
 						m_wktCoordSys.Description = null;
 						m_wktCoordSys.WKT = WKTText.Text;
@@ -589,8 +589,8 @@
 			try
 			{
 				m_coordsysCodeCoordSys = null;
-				string s = m_connection.CoordinateSystem.ConvertCoordinateSystemCodeToWkt(CoordSysCodeText.Text);
-				m_coordsysCodeCoordSys = m_connection.CoordinateSystem.FindCoordSys(CoordSysCodeText.Text);
+				string s = m_connection.CoordinateSystemCatalog.ConvertCoordinateSystemCodeToWkt(CoordSysCodeText.Text);
+				m_coordsysCodeCoordSys = m_connection.CoordinateSystemCatalog.FindCoordSys(CoordSysCodeText.Text);
 			}
 			catch
 			{
@@ -603,12 +603,12 @@
 			try
 			{
 				m_epsgCoordSys = null;
-				m_epsgCoordSys = m_connection.CoordinateSystem.FindCoordSys("EPSG:" + EPSGCodeText.Text);
+				m_epsgCoordSys = m_connection.CoordinateSystemCatalog.FindCoordSys("EPSG:" + EPSGCodeText.Text);
 				if (m_epsgCoordSys == null)
 				{
-					string s = m_connection.CoordinateSystem.ConvertEpsgCodeToWkt(EPSGCodeText.Text);
-					s = m_connection.CoordinateSystem.ConvertWktToCoordinateSystemCode(s);
-					m_epsgCoordSys = m_connection.CoordinateSystem.FindCoordSys(s);
+					string s = m_connection.CoordinateSystemCatalog.ConvertEpsgCodeToWkt(EPSGCodeText.Text);
+					s = m_connection.CoordinateSystemCatalog.ConvertWktToCoordinateSystemCode(s);
+					m_epsgCoordSys = m_connection.CoordinateSystemCatalog.FindCoordSys(s);
 				}
 			}
 			catch
@@ -620,12 +620,12 @@
 		private void OKBtn_Click(object sender, System.EventArgs e)
 		{
 			if (SelectByList.Checked)
-				m_selectedCoordsys = CoordinateSystem.SelectedItem as OSGeo.MapGuide.MaestroAPI.HttpCoordinateSystem.CoordSys;
+				m_selectedCoordsys = CoordinateSystem.SelectedItem as OSGeo.MapGuide.MaestroAPI.CoordinateSystem;
 			else if (SelectByCoordSysCode.Checked)
 				m_selectedCoordsys = m_coordsysCodeCoordSys;
-			else if (SelectByWKT.Checked && m_connection.CoordinateSystem == null)
+			else if (SelectByWKT.Checked && m_connection.CoordinateSystemCatalog == null)
 			{
-				m_selectedCoordsys = new OSGeo.MapGuide.MaestroAPI.HttpCoordinateSystem.CoordSys();
+                m_selectedCoordsys = m_connection.CoordinateSystemCatalog.CreateEmptyCoordinateSystem();
 				m_selectedCoordsys.Code = null;
 				m_selectedCoordsys.Description = null;
 				m_selectedCoordsys.WKT = WKTText.Text;
@@ -638,7 +638,7 @@
 				m_selectedCoordsys = null;
 		}
 
-		public OSGeo.MapGuide.MaestroAPI.HttpCoordinateSystem.CoordSys SelectedCoordSys
+		public OSGeo.MapGuide.MaestroAPI.CoordinateSystem SelectedCoordSys
 		{
 			get { return m_selectedCoordsys; }
 		}

Modified: trunk/Tools/Maestro/Maestro/ResourceProperties.cs
===================================================================
--- trunk/Tools/Maestro/Maestro/ResourceProperties.cs	2010-05-05 13:03:36 UTC (rev 4837)
+++ trunk/Tools/Maestro/Maestro/ResourceProperties.cs	2010-05-05 13:58:21 UTC (rev 4838)
@@ -436,7 +436,7 @@
                 try
                 {
                     List<string> items = new List<string>();
-                    foreach (OSGeo.MapGuide.MaestroAPI.HttpCoordinateSystem.CoordSys c in m_connection.CoordinateSystem.Coordsys)
+                    foreach (OSGeo.MapGuide.MaestroAPI.CoordinateSystem c in m_connection.CoordinateSystemCatalog.Coordsys)
                         if (c.Code.StartsWith("EPSG:"))
                             items.Add(c.Code);
 
@@ -723,7 +723,7 @@
                 if (m_srslist == null)
                 {
                     List<string> items = new List<string>();
-                    foreach (OSGeo.MapGuide.MaestroAPI.HttpCoordinateSystem.CoordSys c in m_connection.CoordinateSystem.Coordsys)
+                    foreach (OSGeo.MapGuide.MaestroAPI.CoordinateSystem c in m_connection.CoordinateSystemCatalog.Coordsys)
                         if (c.Code.StartsWith("EPSG:"))
                             items.Add(c.Code);
 

Added: trunk/Tools/Maestro/MaestroAPI/CoordinateSystem.cs
===================================================================
--- trunk/Tools/Maestro/MaestroAPI/CoordinateSystem.cs	                        (rev 0)
+++ trunk/Tools/Maestro/MaestroAPI/CoordinateSystem.cs	2010-05-05 13:58:21 UTC (rev 4838)
@@ -0,0 +1,106 @@
+#region Disclaimer / License
+// Copyright (C) 2010, 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;
+using System.Xml;
+
+namespace OSGeo.MapGuide.MaestroAPI
+{
+    public abstract class CoordinateSystem
+    {
+        protected CoordinateSystemCategory m_parent;
+        protected string m_code;
+        protected string m_description;
+        protected string m_projection;
+        protected string m_projectionDescription;
+        protected string m_datum;
+        protected string m_datumDescription;
+        protected string m_ellipsoid;
+        protected string m_ellipsoidDescription;
+
+        protected string m_wkt = null;
+        protected string m_epsg = null;
+
+        protected CoordinateSystem() { } 
+
+        protected CoordinateSystem(CoordinateSystemCategory parent)
+        {
+            m_parent = parent;
+        }
+
+		public string Code 
+		{ 
+			get { return m_code; } 
+			set { m_code = value; }
+		}
+		public string Description 
+		{ 
+			get { return m_description; } 
+			set { m_description = value; }
+		}
+		public string Projection { get { return m_projection; } }
+		public string ProjectionDescription { get { return m_projectionDescription; } }
+		public string Datum { get { return m_datum; } }
+		public string DatumDescription { get { return m_datumDescription; } }
+		public string Ellipsoid { get { return m_ellipsoid; } }
+		public string EllipsoidDescription { get { return m_ellipsoidDescription; } }
+
+		public string WKT 
+		{
+			get 
+			{
+				if (m_wkt == null)
+					m_wkt = m_parent.Parent.ConvertCoordinateSystemCodeToWkt(m_code);
+				return m_wkt;
+			}
+			set
+			{
+				m_wkt = value;
+			}
+		}
+
+		public string EPSG 
+		{
+			get 
+			{
+				if (m_epsg == null)
+					if (m_code.StartsWith("EPSG:"))
+						m_epsg = m_code.Substring(5);
+					else
+						m_epsg = m_parent.Parent.ConvertWktToEpsgCode(m_parent.Parent.ConvertCoordinateSystemCodeToWkt(m_code));
+
+				return m_epsg;
+			}
+		}
+
+		public override string ToString()
+		{
+			if (m_description == null && m_code == null)
+				return m_wkt == null ? "<null>" : m_wkt;
+			else if (m_description == null)
+				return m_code;
+			else if (m_code == null)
+				return m_description;
+			else
+				return m_description + " (" + m_code + ")";
+		}
+    }
+}

Added: trunk/Tools/Maestro/MaestroAPI/CoordinateSystemCatalog.cs
===================================================================
--- trunk/Tools/Maestro/MaestroAPI/CoordinateSystemCatalog.cs	                        (rev 0)
+++ trunk/Tools/Maestro/MaestroAPI/CoordinateSystemCatalog.cs	2010-05-05 13:58:21 UTC (rev 4838)
@@ -0,0 +1,84 @@
+#region Disclaimer / License
+// Copyright (C) 2010, 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
+{
+    public abstract class CoordinateSystemCatalog : ICoordinateSystemCatalog
+    {
+        public virtual CoordinateSystem[] Coordsys
+        {
+            get
+            {
+                List<CoordinateSystem> items = new List<CoordinateSystem>();
+                foreach (CoordinateSystemCategory cat in this.Categories)
+                {
+                    foreach (CoordinateSystem coord in cat.Items)
+                    {
+                        items.Add(coord);
+                    }
+                }
+                return items.ToArray();
+            }
+        }
+
+        public virtual CoordinateSystem FindCoordSys(string coordcode)
+        {
+            try
+            {
+                foreach (CoordinateSystemCategory cat in this.Categories)
+                {
+                    foreach (CoordinateSystem coord in cat.Items)
+                    {
+                        if (coord.Code == coordcode)
+                            return coord;
+                    }
+                }
+            }
+            catch
+            {
+            }
+
+            return null;
+        }
+
+        public abstract CoordinateSystem CreateEmptyCoordinateSystem();
+
+        public abstract CoordinateSystemCategory[] Categories { get; }
+
+        public abstract string LibraryName { get; }
+
+        public abstract string ConvertCoordinateSystemCodeToWkt(string coordcode);
+
+        public abstract string ConvertEpsgCodeToWkt(string epsg);
+
+        public abstract string ConvertWktToCoordinateSystemCode(string wkt);
+
+        public abstract string ConvertWktToEpsgCode(string wkt);
+
+        public abstract CoordinateSystem[] EnumerateCoordinateSystems(string category);
+
+        public abstract bool IsValid(string wkt);
+
+        public abstract bool IsLoaded { get; }
+    }
+}

Added: trunk/Tools/Maestro/MaestroAPI/CoordinateSystemCategory.cs
===================================================================
--- trunk/Tools/Maestro/MaestroAPI/CoordinateSystemCategory.cs	                        (rev 0)
+++ trunk/Tools/Maestro/MaestroAPI/CoordinateSystemCategory.cs	2010-05-05 13:58:21 UTC (rev 4838)
@@ -0,0 +1,82 @@
+#region Disclaimer / License
+// Copyright (C) 2010, 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
+{
+    public abstract class CoordinateSystemCategory
+    {
+        private ICoordinateSystemCatalog _parent;
+		private string m_name;
+        private CoordinateSystem[] m_items;
+
+        internal CoordinateSystemCategory(ICoordinateSystemCatalog parent, string name)
+		{
+			m_name = name;
+			_parent = parent;
+		}
+
+		public string Name { get { return m_name; } }
+
+        internal ICoordinateSystemCatalog Parent { get { return _parent; } }
+
+		public CoordinateSystem[] Items
+		{
+			get
+			{
+				if (m_items == null)
+				{
+                    if (_parent != null)
+                    {
+                        return _parent.EnumerateCoordinateSystems(m_name);
+                    }
+                    /*
+                    if (_parent != null)
+                    {
+                        string req = m_httpParent.RequestBuilder.EnumerateCoordinateSystems(m_name);
+                        XmlDocument doc = new XmlDocument();
+                        doc.Load(m_httpParent.Connection.WebClient.OpenRead(req));
+                        XmlNodeList lst = doc.SelectNodes("BatchPropertyCollection/PropertyCollection");
+                        CoordSys[] data = new CoordSys[lst.Count];
+                        for (int i = 0; i < lst.Count; i++)
+                            data[i] = new CoordSys(this, lst[i]);
+                        m_items = data;
+                    }
+                    else
+                    {
+                        MgBatchPropertyCollection bp = m_localParent.m_cf.EnumerateCoordinateSystems(m_name);
+                        List<CoordSys> lst = new List<CoordSys>();
+                        for(int i = 0; i < bp.Count; i++)
+                            lst.Add(new CoordSys(this, bp[i]));
+
+                    }*/
+				}
+				return m_items;
+			}
+		}
+
+		public override string ToString()
+		{
+			return m_name;
+		}
+    }
+}

Modified: trunk/Tools/Maestro/MaestroAPI/HttpCoordinateSystem.cs
===================================================================
--- trunk/Tools/Maestro/MaestroAPI/HttpCoordinateSystem.cs	2010-05-05 13:03:36 UTC (rev 4837)
+++ trunk/Tools/Maestro/MaestroAPI/HttpCoordinateSystem.cs	2010-05-05 13:58:21 UTC (rev 4838)
@@ -1,4 +1,23 @@
 #region Disclaimer / License
+// Copyright (C) 2010, 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
+#region Disclaimer / License
 // Copyright (C) 2009, Kenneth Skovhede
 // http://www.hexad.dk, opensource at hexad.dk
 // 
@@ -28,323 +47,42 @@
 	/// Interface to MapGuide coordinate system functions.
 	/// Only works with server > 1.2, since the coordinate mapping is not avalible through Http on older versions
 	/// </summary>
-	public class HttpCoordinateSystem : OSGeo.MapGuide.MaestroAPI.ICoordinateSystem
+	public class HttpCoordinateSystem : CoordinateSystem
 	{
-		private HttpServerConnection m_con;
-		private RequestBuilder m_req;
-		private Category[] m_categories;
-		private string m_coordLib = null;
+        internal HttpCoordinateSystem() : base() { }
 
-		internal HttpCoordinateSystem(HttpServerConnection con, RequestBuilder req)
+        internal HttpCoordinateSystem(CoordinateSystemCategory parent, XmlNode topnode) : base(parent)
 		{
-			m_con = con;
-			m_req = req;
-		}
-
-		internal HttpServerConnection Connection { get { return m_con; } }
-		internal RequestBuilder RequestBuilder { get { return m_req; } }
-
-		public Category[] Categories
-		{
-			get
-			{
-				if (m_categories == null)
-				{
-					string req = m_req.EnumerateCategories();
-					XmlDocument doc = new XmlDocument();
-					doc.Load(m_con.WebClient.OpenRead(req));
-					XmlNodeList lst = doc.SelectNodes("StringCollection/Item");
-					Category[] data = new Category[lst.Count];
-					for(int i = 0; i < lst.Count; i++)
-						data[i] = new Category(this, lst[i].InnerText);
-					m_categories = data;
-				}
-
-				return m_categories;
-			}
-		}
-
-		public string LibraryName
-		{
-			get 
-			{
-				if (m_coordLib == null)
-				{
-					string req = m_req.GetBaseLibrary();
-					m_coordLib = System.Text.Encoding.UTF8.GetString(m_con.WebClient.DownloadData(req));
-				}
-				return m_coordLib;
-			}
-		}
-
-		public bool IsValid(string wkt)
-		{
-			string req = m_req.IsValidCoordSys(wkt);
-			return System.Text.Encoding.UTF8.GetString(m_con.WebClient.DownloadData(req)).ToLower().Trim().Equals("true");
-		}
-
-		public string ConvertWktToCoordinateSystemCode(string wkt)
-		{
-			string req = m_req.ConvertWktToCoordinateSystemCode(wkt);
-			return System.Text.Encoding.UTF8.GetString(m_con.WebClient.DownloadData(req));
-		}
-
-		public string ConvertCoordinateSystemCodeToWkt(string coordcode)
-		{
-			string req = m_req.ConvertCoordinateSystemCodeToWkt(coordcode);
-			return System.Text.Encoding.UTF8.GetString(m_con.WebClient.DownloadData(req));
-		}
-
-		public string ConvertWktToEpsgCode(string wkt)
-		{
-			string req = m_req.ConvertWktToEpsgCode(wkt);
-			return System.Text.Encoding.UTF8.GetString(m_con.WebClient.DownloadData(req));
-		}
-
-		public string ConvertEpsgCodeToWkt(string epsg)
-		{
-			string req = m_req.ConvertEpsgCodeToWkt(epsg);
-			return System.Text.Encoding.UTF8.GetString(m_con.WebClient.DownloadData(req));
-		}
-
-		public class Category
-		{
-			private HttpCoordinateSystem m_httpParent;
-            private LocalNativeCoordinateSystem m_localParent;
-			private string m_name;
-			private CoordSys[] m_items;
-
-			internal Category(HttpCoordinateSystem parent, string name)
-			{
-				m_name = name;
-				m_httpParent = parent;
-			}
-
-            internal Category(LocalNativeCoordinateSystem parent, string name)
+            foreach (XmlNode node in topnode.ChildNodes)
             {
-                m_name = name;
-                m_localParent = parent;
+                switch (node["Name"].InnerText.ToLower())
+                {
+                    case "code":
+                        m_code = node["Value"].InnerText;
+                        break;
+                    case "description":
+                        m_description = node["Value"].InnerText;
+                        break;
+                    case "projection":
+                        m_projection = node["Value"].InnerText;
+                        break;
+                    case "projection description":
+                        m_projectionDescription = node["Value"].InnerText;
+                        break;
+                    case "Datum":
+                        m_datum = node["Value"].InnerText;
+                        break;
+                    case "datum description":
+                        m_datumDescription = node["Value"].InnerText;
+                        break;
+                    case "ellipsoid":
+                        m_ellipsoid = node["Value"].InnerText;
+                        break;
+                    case "ellipsoid description":
+                        m_ellipsoidDescription = node["Value"].InnerText;
+                        break;
+                }
             }
-
-			public string Name { get { return m_name; } }
-			internal HttpCoordinateSystem HttpParent { get { return m_httpParent; } }
-            internal LocalNativeCoordinateSystem LocalParent { get { return m_localParent; } }
-            internal ICoordinateSystem Parent { get { return m_httpParent == null ? (ICoordinateSystem)m_localParent : (ICoordinateSystem)m_httpParent; } }
-
-			public CoordSys[] Items
-			{
-				get
-				{
-					if (m_items == null)
-					{
-                        if (m_httpParent != null)
-                        {
-                            string req = m_httpParent.RequestBuilder.EnumerateCoordinateSystems(m_name);
-                            XmlDocument doc = new XmlDocument();
-                            doc.Load(m_httpParent.Connection.WebClient.OpenRead(req));
-                            XmlNodeList lst = doc.SelectNodes("BatchPropertyCollection/PropertyCollection");
-                            CoordSys[] data = new CoordSys[lst.Count];
-                            for (int i = 0; i < lst.Count; i++)
-                                data[i] = new CoordSys(this, lst[i]);
-                            m_items = data;
-                        }
-                        else
-                        {
-                            MgBatchPropertyCollection bp = m_localParent.m_cf.EnumerateCoordinateSystems(m_name);
-                            List<CoordSys> lst = new List<CoordSys>();
-                            for(int i = 0; i < bp.Count; i++)
-                                lst.Add(new CoordSys(this, bp[i]));
-
-                        }
-					}
-					return m_items;
-				}
-			}
-
-			public override string ToString()
-			{
-				return m_name;
-			}
-
 		}
-
-		public class CoordSys
-		{
-			private Category m_parent;
-			private string m_code;
-			private string m_description;
-			private string m_projection;
-			private string m_projectionDescription;
-			private string m_datum;
-			private string m_datumDescription;
-			private string m_ellipsoid;
-			private string m_ellipsoidDescription;
-
-			private string m_wkt = null;
-			private string m_epsg = null;
-
-			public CoordSys()
-			{
-			}
-
-            internal CoordSys(Category parent, MgPropertyCollection props)
-            {
-                m_parent = parent;
-
-                for (int i = 0; i < props.Count; i++)
-                    switch (props[i].Name.ToLower())
-                    {
-                        case "code":
-                            m_code = (props[i] as MgStringProperty).Value;
-                            break;
-                        case "description":
-                            m_description = (props[i] as MgStringProperty).Value;
-                            break;
-                        case "projection":
-                            m_projection = (props[i] as MgStringProperty).Value;
-                            break;
-                        case "projection description":
-                            m_projectionDescription = (props[i] as MgStringProperty).Value;
-                            break;
-                        case "Datum":
-                            m_datum = (props[i] as MgStringProperty).Value;
-                            break;
-                        case "datum description":
-                            m_datumDescription = (props[i] as MgStringProperty).Value;
-                            break;
-                        case "ellipsoid":
-                            m_ellipsoid = (props[i] as MgStringProperty).Value;
-                            break;
-                        case "ellipsoid description":
-                            m_ellipsoidDescription = (props[i] as MgStringProperty).Value;
-                            break;
-                    }
-            }
-
-			internal CoordSys(Category parent, XmlNode topnode)
-			{
-				m_parent = parent;
-
-				foreach(XmlNode node in topnode.ChildNodes)
-					switch(node["Name"].InnerText.ToLower())
-					{
-						case "code":
-							m_code = node["Value"].InnerText;
-							break;
-						case "description":
-							m_description = node["Value"].InnerText;
-							break;
-						case "projection":
-							m_projection = node["Value"].InnerText;
-							break;
-						case "projection description":
-							m_projectionDescription = node["Value"].InnerText;
-							break;
-						case "Datum":
-							m_datum = node["Value"].InnerText;
-							break;
-						case "datum description":
-							m_datumDescription = node["Value"].InnerText;
-							break;
-						case "ellipsoid":
-							m_ellipsoid = node["Value"].InnerText;
-							break;
-						case "ellipsoid description":
-							m_ellipsoidDescription = node["Value"].InnerText;
-							break;
-					}
-			}
-
-			public string Code 
-			{ 
-				get { return m_code; } 
-				set { m_code = value; }
-			}
-			public string Description 
-			{ 
-				get { return m_description; } 
-				set { m_description = value; }
-			}
-			public string Projection { get { return m_projection; } }
-			public string ProjectionDescription { get { return m_projectionDescription; } }
-			public string Datum { get { return m_datum; } }
-			public string DatumDescription { get { return m_datumDescription; } }
-			public string Ellipsoid { get { return m_ellipsoid; } }
-			public string EllipsoidDescription { get { return m_ellipsoidDescription; } }
-
-			public string WKT 
-			{
-				get 
-				{
-					if (m_wkt == null)
-						m_wkt = m_parent.Parent.ConvertCoordinateSystemCodeToWkt(m_code);
-					return m_wkt;
-				}
-				set
-				{
-					m_wkt = value;
-				}
-			}
-
-			public string EPSG 
-			{
-				get 
-				{
-					if (m_epsg == null)
-						if (m_code.StartsWith("EPSG:"))
-							m_epsg = m_code.Substring(5);
-						else
-							m_epsg = m_parent.Parent.ConvertWktToEpsgCode(m_parent.Parent.ConvertCoordinateSystemCodeToWkt(m_code));
-
-					return m_epsg;
-				}
-			}
-
-			public override string ToString()
-			{
-				if (m_description == null && m_code == null)
-					return m_wkt == null ? "<null>" : m_wkt;
-				else if (m_description == null)
-					return m_code;
-				else if (m_code == null)
-					return m_description;
-				else
-					return m_description + " (" + m_code + ")";
-			}
-
-
-		}
-
-		public CoordSys[] Coordsys
-		{
-			get 
-			{
-				ArrayList items = new ArrayList();
-				foreach(OSGeo.MapGuide.MaestroAPI.HttpCoordinateSystem.Category cat in this.Categories)
-						foreach(OSGeo.MapGuide.MaestroAPI.HttpCoordinateSystem.CoordSys coord in cat.Items)
-							items.Add(coord);
-
-				return (CoordSys[])items.ToArray(typeof(CoordSys));
-			}
-		}
-
-		public CoordSys FindCoordSys(string coordcode)
-		{
-			try
-			{
-				foreach(OSGeo.MapGuide.MaestroAPI.HttpCoordinateSystem.Category cat in this.Categories)
-						foreach(OSGeo.MapGuide.MaestroAPI.HttpCoordinateSystem.CoordSys coord in cat.Items)
-							if (coord.Code == coordcode)
-								return coord;
-			}
-			catch
-			{
-			}
-
-			return null;
-		}
-
-        public bool IsLoaded { get { return m_categories != null; } }
-
 	}
 }

Added: trunk/Tools/Maestro/MaestroAPI/HttpCoordinateSystemCatalog.cs
===================================================================
--- trunk/Tools/Maestro/MaestroAPI/HttpCoordinateSystemCatalog.cs	                        (rev 0)
+++ trunk/Tools/Maestro/MaestroAPI/HttpCoordinateSystemCatalog.cs	2010-05-05 13:58:21 UTC (rev 4838)
@@ -0,0 +1,139 @@
+#region Disclaimer / License
+// Copyright (C) 2010, 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;
+using System.Xml;
+
+namespace OSGeo.MapGuide.MaestroAPI
+{
+    public class HttpCoordinateSystemCatalog : CoordinateSystemCatalog
+    {
+        private HttpServerConnection m_con;
+		private RequestBuilder m_req;
+		private CoordinateSystemCategory[] m_categories;
+		private string m_coordLib = null;
+
+        internal HttpCoordinateSystemCatalog(HttpServerConnection con, RequestBuilder req)
+		{
+			m_con = con;
+			m_req = req;
+		}
+
+		internal HttpServerConnection Connection { get { return m_con; } }
+		internal RequestBuilder RequestBuilder { get { return m_req; } }
+
+        public override CoordinateSystemCategory[] Categories
+		{
+			get
+			{
+				if (m_categories == null)
+				{
+					string req = m_req.EnumerateCategories();
+					XmlDocument doc = new XmlDocument();
+					doc.Load(m_con.WebClient.OpenRead(req));
+					XmlNodeList lst = doc.SelectNodes("StringCollection/Item");
+                    CoordinateSystemCategory[] data = new CoordinateSystemCategory[lst.Count];
+					for(int i = 0; i < lst.Count; i++)
+						data[i] = new HttpCoordinateSystemCategory(this, lst[i].InnerText);
+					m_categories = data;
+				}
+
+				return m_categories;
+			}
+		}
+
+        public override string LibraryName
+		{
+			get 
+			{
+				if (m_coordLib == null)
+				{
+					string req = m_req.GetBaseLibrary();
+					m_coordLib = System.Text.Encoding.UTF8.GetString(m_con.WebClient.DownloadData(req));
+				}
+				return m_coordLib;
+			}
+		}
+
+        public override bool IsValid(string wkt)
+		{
+			string req = m_req.IsValidCoordSys(wkt);
+			return System.Text.Encoding.UTF8.GetString(m_con.WebClient.DownloadData(req)).ToLower().Trim().Equals("true");
+		}
+
+        public override string ConvertWktToCoordinateSystemCode(string wkt)
+		{
+			string req = m_req.ConvertWktToCoordinateSystemCode(wkt);
+			return System.Text.Encoding.UTF8.GetString(m_con.WebClient.DownloadData(req));
+		}
+
+        public override string ConvertCoordinateSystemCodeToWkt(string coordcode)
+		{
+			string req = m_req.ConvertCoordinateSystemCodeToWkt(coordcode);
+			return System.Text.Encoding.UTF8.GetString(m_con.WebClient.DownloadData(req));
+		}
+
+        public override string ConvertWktToEpsgCode(string wkt)
+		{
+			string req = m_req.ConvertWktToEpsgCode(wkt);
+			return System.Text.Encoding.UTF8.GetString(m_con.WebClient.DownloadData(req));
+		}
+
+        public override string ConvertEpsgCodeToWkt(string epsg)
+		{
+			string req = m_req.ConvertEpsgCodeToWkt(epsg);
+			return System.Text.Encoding.UTF8.GetString(m_con.WebClient.DownloadData(req));
+		}
+
+        public override bool IsLoaded { get { return m_categories != null; } }
+
+        public override CoordinateSystem[] EnumerateCoordinateSystems(string category)
+        {
+            CoordinateSystemCategory cat = null;
+            foreach (CoordinateSystemCategory csc in this.Categories)
+            {
+                if (csc.Name == category)
+                {
+                    cat = csc;
+                    break;
+                }
+            }
+
+            if (cat == null)
+                return new CoordinateSystem[0];
+
+            string req = this.RequestBuilder.EnumerateCoordinateSystems(category);
+            XmlDocument doc = new XmlDocument();
+            doc.Load(m_con.WebClient.OpenRead(req));
+            XmlNodeList lst = doc.SelectNodes("BatchPropertyCollection/PropertyCollection");
+            CoordinateSystem[] data = new CoordinateSystem[lst.Count];
+            for (int i = 0; i < lst.Count; i++)
+                data[i] = new HttpCoordinateSystem(cat, lst[i]);
+
+            return data;
+        }
+
+        public override CoordinateSystem CreateEmptyCoordinateSystem()
+        {
+            return new HttpCoordinateSystem();
+        }
+    }
+}

Added: trunk/Tools/Maestro/MaestroAPI/HttpCoordinateSystemCategory.cs
===================================================================
--- trunk/Tools/Maestro/MaestroAPI/HttpCoordinateSystemCategory.cs	                        (rev 0)
+++ trunk/Tools/Maestro/MaestroAPI/HttpCoordinateSystemCategory.cs	2010-05-05 13:58:21 UTC (rev 4838)
@@ -0,0 +1,30 @@
+#region Disclaimer / License
+// Copyright (C) 2010, 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
+{
+    public class HttpCoordinateSystemCategory : CoordinateSystemCategory
+    {
+        public HttpCoordinateSystemCategory(ICoordinateSystemCatalog parent, string name) : base(parent, name) { }
+    }
+}

Modified: trunk/Tools/Maestro/MaestroAPI/HttpServerConnection.cs
===================================================================
--- trunk/Tools/Maestro/MaestroAPI/HttpServerConnection.cs	2010-05-05 13:03:36 UTC (rev 4837)
+++ trunk/Tools/Maestro/MaestroAPI/HttpServerConnection.cs	2010-05-05 13:58:21 UTC (rev 4838)
@@ -753,10 +753,10 @@
 
 		public override Version SiteVersion { get { return m_siteVersion; } }
 
-		private HttpCoordinateSystem m_coordsys = null;
+        private ICoordinateSystemCatalog m_coordsys = null;
 		//TODO: Figure out a strategy for cache invalidation 
 		//TODO: Figure out if this can work with MapGuide EP 1.0 (just exclude it?)
-		public ICoordinateSystem CoordinateSystem 
+		public ICoordinateSystemCatalog CoordinateSystemCatalog 
 		{ 
 			get 
 			{ 
@@ -765,7 +765,7 @@
 				else
 				{	
 					if (m_coordsys == null)
-						m_coordsys = new HttpCoordinateSystem(this, m_reqBuilder);
+						m_coordsys = new HttpCoordinateSystemCatalog(this, m_reqBuilder);
 					return m_coordsys;
 				}
 			} 

Deleted: trunk/Tools/Maestro/MaestroAPI/ICoordinateSystem.cs
===================================================================
--- trunk/Tools/Maestro/MaestroAPI/ICoordinateSystem.cs	2010-05-05 13:03:36 UTC (rev 4837)
+++ trunk/Tools/Maestro/MaestroAPI/ICoordinateSystem.cs	2010-05-05 13:58:21 UTC (rev 4838)
@@ -1,36 +0,0 @@
-#region Disclaimer / License
-// Copyright (C) 2009, Kenneth Skovhede
-// http://www.hexad.dk, opensource at hexad.dk
-// 
-// 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;
-namespace OSGeo.MapGuide.MaestroAPI
-{
-    public interface ICoordinateSystem
-    {
-        HttpCoordinateSystem.Category[] Categories { get; }
-        string ConvertCoordinateSystemCodeToWkt(string coordcode);
-        string ConvertEpsgCodeToWkt(string epsg);
-        string ConvertWktToCoordinateSystemCode(string wkt);
-        string ConvertWktToEpsgCode(string wkt);
-        HttpCoordinateSystem.CoordSys[] Coordsys { get; }
-        HttpCoordinateSystem.CoordSys FindCoordSys(string coordcode);
-        bool IsValid(string wkt);
-        string LibraryName { get; }
-        bool IsLoaded { get; }
-    }
-}

Added: trunk/Tools/Maestro/MaestroAPI/ICoordinateSystemCatalog.cs
===================================================================
--- trunk/Tools/Maestro/MaestroAPI/ICoordinateSystemCatalog.cs	                        (rev 0)
+++ trunk/Tools/Maestro/MaestroAPI/ICoordinateSystemCatalog.cs	2010-05-05 13:58:21 UTC (rev 4838)
@@ -0,0 +1,38 @@
+#region Disclaimer / License
+// Copyright (C) 2009, Kenneth Skovhede
+// http://www.hexad.dk, opensource at hexad.dk
+// 
+// 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;
+namespace OSGeo.MapGuide.MaestroAPI
+{
+    public interface ICoordinateSystemCatalog
+    {
+        CoordinateSystemCategory[] Categories { get; }
+        string ConvertCoordinateSystemCodeToWkt(string coordcode);
+        string ConvertEpsgCodeToWkt(string epsg);
+        string ConvertWktToCoordinateSystemCode(string wkt);
+        string ConvertWktToEpsgCode(string wkt);
+        CoordinateSystem[] Coordsys { get; }
+        CoordinateSystem[] EnumerateCoordinateSystems(string category);
+        CoordinateSystem FindCoordSys(string coordcode);
+        CoordinateSystem CreateEmptyCoordinateSystem();
+        bool IsValid(string wkt);
+        string LibraryName { get; }
+        bool IsLoaded { get; }
+    }
+}

Modified: trunk/Tools/Maestro/MaestroAPI/LocalNativeConnection.cs
===================================================================
--- trunk/Tools/Maestro/MaestroAPI/LocalNativeConnection.cs	2010-05-05 13:03:36 UTC (rev 4837)
+++ trunk/Tools/Maestro/MaestroAPI/LocalNativeConnection.cs	2010-05-05 13:58:21 UTC (rev 4838)
@@ -491,10 +491,10 @@
 		}
 
 
-        private LocalNativeCoordinateSystem m_coordsys = null;
+        private ICoordinateSystemCatalog m_coordsys = null;
         //TODO: Figure out a strategy for cache invalidation 
         
-        public ICoordinateSystem CoordinateSystem
+        public ICoordinateSystemCatalog CoordinateSystemCatalog
 		{
             get
             {
@@ -503,7 +503,7 @@
                 else
                 {
                     if (m_coordsys == null)
-                        m_coordsys = new LocalNativeCoordinateSystem(this);
+                        m_coordsys = new LocalNativeCoordinateSystemCatalog(this);
                     return m_coordsys;
                 }
             }

Modified: trunk/Tools/Maestro/MaestroAPI/LocalNativeCoordinateSystem.cs
===================================================================
--- trunk/Tools/Maestro/MaestroAPI/LocalNativeCoordinateSystem.cs	2010-05-05 13:03:36 UTC (rev 4837)
+++ trunk/Tools/Maestro/MaestroAPI/LocalNativeCoordinateSystem.cs	2010-05-05 13:58:21 UTC (rev 4838)
@@ -24,105 +24,42 @@
 
 namespace OSGeo.MapGuide.MaestroAPI
 {
-    public class LocalNativeCoordinateSystem : ICoordinateSystem
+    public class LocalNativeCoordinateSystem : CoordinateSystem
     {
-        private LocalNativeConnection m_con;
-        private HttpCoordinateSystem.Category[] m_categories;
-        private string m_coordLib = null;
-        internal OSGeo.MapGuide.MgCoordinateSystemFactory m_cf;
+        internal LocalNativeCoordinateSystem() : base() { }
 
-        internal LocalNativeCoordinateSystem(LocalNativeConnection con)
+        internal LocalNativeCoordinateSystem(CoordinateSystemCategory parent, MgPropertyCollection props) : base(parent)
         {
-            m_con = con;
-            m_cf = new MgCoordinateSystemFactory();
-        }
-
-        #region ICoordinateSystem Members
-
-        public HttpCoordinateSystem.Category[] Categories
-        {
-            get
+            for (int i = 0; i < props.Count; i++)
             {
-                if (m_categories == null)
+                switch (props[i].Name.ToLower())
                 {
-                    MgStringCollection c = m_cf.EnumerateCategories();
-                    HttpCoordinateSystem.Category[] data = new HttpCoordinateSystem.Category[c.GetCount()];
-
-                    for (int i = 0; i < c.GetCount(); i++)
-                        data[i] = new HttpCoordinateSystem.Category(this, c.GetItem(i));
-                    m_categories = data;
+                    case "code":
+                        m_code = (props[i] as MgStringProperty).Value;
+                        break;
+                    case "description":
+                        m_description = (props[i] as MgStringProperty).Value;
+                        break;
+                    case "projection":
+                        m_projection = (props[i] as MgStringProperty).Value;
+                        break;
+                    case "projection description":
+                        m_projectionDescription = (props[i] as MgStringProperty).Value;
+                        break;
+                    case "Datum":
+                        m_datum = (props[i] as MgStringProperty).Value;
+                        break;
+                    case "datum description":
+                        m_datumDescription = (props[i] as MgStringProperty).Value;
+                        break;
+                    case "ellipsoid":
+                        m_ellipsoid = (props[i] as MgStringProperty).Value;
+                        break;
+                    case "ellipsoid description":
+                        m_ellipsoidDescription = (props[i] as MgStringProperty).Value;
+                        break;
                 }
-
-                return m_categories;
             }
         }
-
-        public string ConvertCoordinateSystemCodeToWkt(string coordcode)
-        {
-            return m_cf.ConvertCoordinateSystemCodeToWkt(coordcode);
-        }
-
-        public string ConvertEpsgCodeToWkt(string epsg)
-        {
-            return m_cf.ConvertEpsgCodeToWkt(int.Parse(epsg));
-        }
-
-        public string ConvertWktToCoordinateSystemCode(string wkt)
-        {
-            return m_cf.ConvertWktToCoordinateSystemCode(wkt);
-        }
-
-        public string ConvertWktToEpsgCode(string wkt)
-        {
-            return m_cf.ConvertWktToEpsgCode(wkt).ToString();
-        }
-
-        public HttpCoordinateSystem.CoordSys[] Coordsys
-        {
-            get
-            {
-                ArrayList items = new ArrayList();
-                foreach (OSGeo.MapGuide.MaestroAPI.HttpCoordinateSystem.Category cat in this.Categories)
-                    foreach (OSGeo.MapGuide.MaestroAPI.HttpCoordinateSystem.CoordSys coord in cat.Items)
-                        items.Add(coord);
-
-                return (HttpCoordinateSystem.CoordSys[])items.ToArray(typeof(HttpCoordinateSystem.CoordSys));
-            }
-        }
-
-        public HttpCoordinateSystem.CoordSys FindCoordSys(string coordcode)
-        {
-            try
-            {
-                foreach (OSGeo.MapGuide.MaestroAPI.HttpCoordinateSystem.Category cat in this.Categories)
-                    foreach (OSGeo.MapGuide.MaestroAPI.HttpCoordinateSystem.CoordSys coord in cat.Items)
-                        if (coord.Code == coordcode)
-                            return coord;
-            }
-            catch
-            {
-            }
-
-            return null;
-        }
-
-        public bool IsValid(string wkt)
-        {
-            return m_cf.IsValid(wkt);
-        }
-
-        public string LibraryName
-        {
-            get
-            {
-                if (m_coordLib == null)
-                    m_coordLib = m_cf.GetBaseLibrary();
-                return m_coordLib;
-            }
-        }
-
-        public bool IsLoaded { get { return m_categories != null; } } 
-
-        #endregion
     }
 }

Added: trunk/Tools/Maestro/MaestroAPI/LocalNativeCoordinateSystemCatalog.cs
===================================================================
--- trunk/Tools/Maestro/MaestroAPI/LocalNativeCoordinateSystemCatalog.cs	                        (rev 0)
+++ trunk/Tools/Maestro/MaestroAPI/LocalNativeCoordinateSystemCatalog.cs	2010-05-05 13:58:21 UTC (rev 4838)
@@ -0,0 +1,122 @@
+#region Disclaimer / License
+// Copyright (C) 2010, 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
+{
+    public class LocalNativeCoordinateSystemCatalog : CoordinateSystemCatalog
+    {
+        private LocalNativeConnection m_con;
+        private CoordinateSystemCategory[] m_categories;
+        private string m_coordLib = null;
+        internal OSGeo.MapGuide.MgCoordinateSystemFactory m_cf;
+
+        internal LocalNativeCoordinateSystemCatalog(LocalNativeConnection con)
+        {
+            m_con = con;
+            m_cf = new MgCoordinateSystemFactory();
+        }
+
+        public override CoordinateSystemCategory[] Categories
+        {
+            get
+            {
+                if (m_categories == null)
+                {
+                    MgStringCollection c = m_cf.EnumerateCategories();
+                    CoordinateSystemCategory[] data = new CoordinateSystemCategory[c.GetCount()];
+
+                    for (int i = 0; i < c.GetCount(); i++)
+                        data[i] = new LocalNativeCoordinateSystemCategory(this, c.GetItem(i));
+                    m_categories = data;
+                }
+
+                return m_categories;
+            }
+        }
+
+        public override string ConvertCoordinateSystemCodeToWkt(string coordcode)
+        {
+            return m_cf.ConvertCoordinateSystemCodeToWkt(coordcode);
+        }
+
+        public override string ConvertEpsgCodeToWkt(string epsg)
+        {
+            return m_cf.ConvertEpsgCodeToWkt(int.Parse(epsg));
+        }
+
+        public override string ConvertWktToCoordinateSystemCode(string wkt)
+        {
+            return m_cf.ConvertWktToCoordinateSystemCode(wkt);
+        }
+
+        public override string ConvertWktToEpsgCode(string wkt)
+        {
+            return m_cf.ConvertWktToEpsgCode(wkt).ToString();
+        }
+
+        public override bool IsValid(string wkt)
+        {
+            return m_cf.IsValid(wkt);
+        }
+
+        public override string LibraryName
+        {
+            get
+            {
+                if (m_coordLib == null)
+                    m_coordLib = m_cf.GetBaseLibrary();
+                return m_coordLib;
+            }
+        }
+
+        public override bool IsLoaded { get { return m_categories != null; } }
+
+        public override CoordinateSystem[] EnumerateCoordinateSystems(string category)
+        {
+            CoordinateSystemCategory cat = null;
+            foreach (CoordinateSystemCategory csc in this.Categories)
+            {
+                if (csc.Name == category)
+                {
+                    cat = csc;
+                    break;
+                }
+            }
+
+            if (cat == null)
+                return new CoordinateSystem[0];
+
+            MgBatchPropertyCollection bp = m_cf.EnumerateCoordinateSystems(category);
+            List<CoordinateSystem> lst = new List<CoordinateSystem>();
+            for (int i = 0; i < bp.Count; i++)
+                lst.Add(new LocalNativeCoordinateSystem(cat, bp[i]));
+
+            return lst.ToArray();
+        }
+
+        public override CoordinateSystem CreateEmptyCoordinateSystem()
+        {
+            return new LocalNativeCoordinateSystem();
+        }
+    }
+}

Added: trunk/Tools/Maestro/MaestroAPI/LocalNativeCoordinateSystemCategory.cs
===================================================================
--- trunk/Tools/Maestro/MaestroAPI/LocalNativeCoordinateSystemCategory.cs	                        (rev 0)
+++ trunk/Tools/Maestro/MaestroAPI/LocalNativeCoordinateSystemCategory.cs	2010-05-05 13:58:21 UTC (rev 4838)
@@ -0,0 +1,30 @@
+#region Disclaimer / License
+// Copyright (C) 2010, 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
+{
+    public class LocalNativeCoordinateSystemCategory : CoordinateSystemCategory
+    {
+        public LocalNativeCoordinateSystemCategory(ICoordinateSystemCatalog parent, string name) : base(parent, name) { }
+    }
+}

Modified: trunk/Tools/Maestro/MaestroAPI/OSGeo.MapGuide.MaestroAPI.csproj
===================================================================
--- trunk/Tools/Maestro/MaestroAPI/OSGeo.MapGuide.MaestroAPI.csproj	2010-05-05 13:03:36 UTC (rev 4837)
+++ trunk/Tools/Maestro/MaestroAPI/OSGeo.MapGuide.MaestroAPI.csproj	2010-05-05 13:58:21 UTC (rev 4838)
@@ -1,7 +1,7 @@
 <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
   <PropertyGroup>
     <ProjectType>Local</ProjectType>
-    <ProductVersion>9.0.30729</ProductVersion>
+    <ProductVersion>9.0.21022</ProductVersion>
     <SchemaVersion>2.0</SchemaVersion>
     <ProjectGuid>{290B027E-3649-4A60-A9BF-0544831435E2}</ProjectGuid>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -134,6 +134,9 @@
     </Compile>
     <Compile Include="ConnectionFactory.cs" />
     <Compile Include="ConnectionProviderRegistry.cs" />
+    <Compile Include="CoordinateSystem.cs" />
+    <Compile Include="CoordinateSystemCatalog.cs" />
+    <Compile Include="CoordinateSystemCategory.cs" />
     <Compile Include="Generated\StringCollection-1.0.0.cs" />
     <Compile Include="HttpCoordinateSystem.cs">
       <SubType>Code</SubType>
@@ -276,10 +279,12 @@
     <Compile Include="Generated\WebLayout-1.0.0.cs">
       <SubType>Code</SubType>
     </Compile>
+    <Compile Include="HttpCoordinateSystemCatalog.cs" />
+    <Compile Include="HttpCoordinateSystemCategory.cs" />
     <Compile Include="HttpServerConnection.cs">
       <SubType>Code</SubType>
     </Compile>
-    <Compile Include="ICoordinateSystem.cs" />
+    <Compile Include="ICoordinateSystemCatalog.cs" />
     <Compile Include="LenghtyOperationCallbackArgs.cs">
       <SubType>Code</SubType>
     </Compile>
@@ -287,6 +292,8 @@
       <SubType>Code</SubType>
     </Compile>
     <Compile Include="LocalNativeCoordinateSystem.cs" />
+    <Compile Include="LocalNativeCoordinateSystemCatalog.cs" />
+    <Compile Include="LocalNativeCoordinateSystemCategory.cs" />
     <Compile Include="MgFeatureSetReader.cs" />
     <Compile Include="RequestBuilder.cs">
       <SubType>Code</SubType>

Modified: trunk/Tools/Maestro/MaestroAPI/ServerConnectionI.cs
===================================================================
--- trunk/Tools/Maestro/MaestroAPI/ServerConnectionI.cs	2010-05-05 13:03:36 UTC (rev 4837)
+++ trunk/Tools/Maestro/MaestroAPI/ServerConnectionI.cs	2010-05-05 13:58:21 UTC (rev 4838)
@@ -175,7 +175,7 @@
 		RuntimeClasses.RuntimeMap GetRuntimeMap(string resourceID);
 		Version SiteVersion { get; }
 		bool DisableValidation { get; set; }
-		ICoordinateSystem CoordinateSystem { get; }
+		ICoordinateSystemCatalog CoordinateSystemCatalog { get; }
 		bool HasFolder(string folderpath);
 		void CreateFolder(string folderpath);
 

Modified: trunk/Tools/Maestro/MapGuide Maestro.sln
===================================================================
--- trunk/Tools/Maestro/MapGuide Maestro.sln	2010-05-05 13:03:36 UTC (rev 4837)
+++ trunk/Tools/Maestro/MapGuide Maestro.sln	2010-05-05 13:58:21 UTC (rev 4838)
@@ -23,10 +23,6 @@
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OSGeo.MapGuide.Maestro.LoginForm", "Maestro\LoginForm\OSGeo.MapGuide.Maestro.LoginForm.csproj", "{4B79021A-5117-4894-BBC0-39452E4F40E3}"
 EndProject
 Global
-	GlobalSection(SubversionScc) = preSolution
-		Svn-Managed = True
-		Manager = AnkhSVN - Subversion Support for Visual Studio
-	EndGlobalSection
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
 		Release|Any CPU = Release|Any CPU
@@ -80,4 +76,8 @@
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
 	EndGlobalSection
+	GlobalSection(SubversionScc) = preSolution
+		Svn-Managed = True
+		Manager = AnkhSVN - Subversion Support for Visual Studio
+	EndGlobalSection
 EndGlobal



More information about the mapguide-commits mailing list