Exemplo n.º 1
0
        protected bool ParseGeometry(Target targetType, string targetText, XmlTest xmlTestItem)
        {
            IGeometry geom = null;

            try
            {
                geom = m_objReader.Read(targetText);
            }
            catch (Exception ex)
            {
                xmlTestItem.Thrown = ex;
                XmlTestExceptionManager.Publish(ex);
                return(false);
            }

            if (geom == null)
            {
                return(false);
            }

            switch (targetType)
            {
            case Target.A:
                xmlTestItem.A = geom;
                break;

            case Target.B:
                xmlTestItem.B = geom;
                break;
            }

            return(true);
        }
Exemplo n.º 2
0
        public bool RunTests()
        {
            if (List.Count > 0)
            {
                for (int i = 0; i < List.Count; i++)
                {
                    XmlTest testItem = (XmlTest)List[i];

                    if (testItem != null)
                    {
                        XmlTestEventArgs args =
                            new XmlTestEventArgs(i, testItem.Run(), testItem);

                        if (TestEvent != null)
                        {
                            TestEvent(this, args);
                        }
                    }
                }

                return(true);
            }

            return(false);
        }
Exemplo n.º 3
0
        public XmlTest Create(XmlTestInfo testInfo, double tolerance)
        {
            XmlTest xmlTest = new XmlTest(testInfo.GetValue("desc"), 
                testInfo.IsDefaultTarget(), tolerance, _geometryOperation, _resultMatcher);

            // Handle test type or name.
            string strTestType = testInfo.GetValue("name");
            if (string.IsNullOrEmpty(strTestType))
                return null;
            
            ParseType(strTestType, xmlTest);

            // Handle the Geometry A:
            string wkt = testInfo.GetValue("a");
            if (!string.IsNullOrEmpty(wkt))
                ParseGeometry(Target.A, wkt, xmlTest);
            
            // Handle the Geometry B:
            wkt = testInfo.GetValue("b");
            if (!string.IsNullOrEmpty(wkt))           
                ParseGeometry(Target.B, wkt, xmlTest);

            string arg2 = testInfo.GetValue("arg2");
            if (!string.IsNullOrEmpty(arg2))
            {
                if (arg2 == "a" || arg2 == "A")
                    xmlTest.Argument1 = xmlTest.A;
                else if (arg2 == "b" || arg2 == "B")
                    xmlTest.Argument1 = xmlTest.B;
                else
                    xmlTest.Argument1 = arg2;
            }

            string arg3 = testInfo.GetValue("arg3");
            if (!string.IsNullOrEmpty(arg3))
                xmlTest.Argument2 = arg3;



            string strResult = testInfo.GetValue("result");
            if (string.IsNullOrEmpty(strResult))
                return null;

            ParseResult(strResult, xmlTest);

            return xmlTest;
        }
Exemplo n.º 4
0
        public XmlTest Create(XmlTestInfo testInfo, double tolerance)
        {
            XmlTest xmlTest = new XmlTest(testInfo.GetValue("desc"), 
                testInfo.IsDefaultTarget(), tolerance);

            // Handle test type or name.
            string strTestType = testInfo.GetValue("name");
            if (strTestType == null || strTestType.Length == 0)
                return null;
            
            ParseType(strTestType, xmlTest);

            // Handle the Geometry A:
            string wktA = testInfo.GetValue("a");
            if (wktA != null && wktA.Length > 0)
                ParseGeometry(Target.A, wktA, xmlTest);
            
            // Handle the Geometry B:
            string wktB = testInfo.GetValue("b");
            if (wktB != null && wktB.Length > 0)           
                ParseGeometry(Target.B, wktB, xmlTest);            

            // Handle the arguments
            string arg2 = testInfo.GetValue("arg2");
            if (arg2 != null && arg2.Length > 0)
            {
                if (arg2 == "a")
                    xmlTest.Argument1 = xmlTest.A;
                else if (arg2 == "b")
                    xmlTest.Argument1 = xmlTest.B;
            }

            string arg3 = testInfo.GetValue("arg3");
            if (arg3 != null && arg3.Length > 0)            
                xmlTest.Argument2 = arg3;

            string strResult = testInfo.GetValue("result");
            if (strResult == null || strResult.Length == 0)
                return null;

            ParseResult(strResult, xmlTest);

            return xmlTest;
        }
Exemplo n.º 5
0
 public XmlTestEventArgs(int index, bool success, XmlTest testItem) : base()
 {
     m_nIndex   = index;
     m_bSuccess = success;
     m_objTest  = testItem;
 }
 public void Remove(XmlTest value)  
 {
     List.Remove(value);
 }
Exemplo n.º 7
0
        protected bool ParseType(string testType, XmlTest xmlTestItem)
        {
            testType = testType.ToLower();

            if (testType == "getarea")
            {
                xmlTestItem.TestType = XmlTestType.Area;
            }

            else if (testType == "getboundary")
            {
                xmlTestItem.TestType = XmlTestType.Boundary;
            }

            else if (testType == "getboundarydimension")
            {
                xmlTestItem.TestType = XmlTestType.BoundaryDimension;
            }

            else if (testType == "buffer")
            {
                xmlTestItem.TestType = XmlTestType.Buffer;
            }

            else if (testType == "getcentroid")
            {
                xmlTestItem.TestType = XmlTestType.Centroid;
            }

            else if (testType == "contains")
            {
                xmlTestItem.TestType = XmlTestType.Contains;
            }

            else if (testType == "convexhull")
            {
                xmlTestItem.TestType = XmlTestType.ConvexHull;
            }

            else if (testType == "crosses")
            {
                xmlTestItem.TestType = XmlTestType.Crosses;
            }

            else if (testType == "difference")
            {
                xmlTestItem.TestType = XmlTestType.Difference;
            }

            else if (testType == "getdimension")
            {
                xmlTestItem.TestType = XmlTestType.Dimension;
            }

            else if (testType == "disjoint")
            {
                xmlTestItem.TestType = XmlTestType.Disjoint;
            }

            else if (testType == "distance")
            {
                xmlTestItem.TestType = XmlTestType.Distance;
            }

            else if (testType == "getenvelope")
            {
                xmlTestItem.TestType = XmlTestType.Envelope;
            }

            else if (testType == "equals")
            {
                xmlTestItem.TestType = XmlTestType.Equals;
            }

            else if (testType == "getinteriorpoint")
            {
                xmlTestItem.TestType = XmlTestType.InteriorPoint;
            }

            else if (testType == "intersection")
            {
                xmlTestItem.TestType = XmlTestType.Intersection;
            }

            else if (testType == "intersects")
            {
                xmlTestItem.TestType = XmlTestType.Intersects;
            }

            else if (testType == "isempty")
            {
                xmlTestItem.TestType = XmlTestType.IsEmpty;
            }

            else if (testType == "issimple")
            {
                xmlTestItem.TestType = XmlTestType.IsSimple;
            }

            else if (testType == "isvalid")
            {
                xmlTestItem.TestType = XmlTestType.IsValid;
            }

            else if (testType == "iswithindistance")
            {
                xmlTestItem.TestType = XmlTestType.IsWithinDistance;
            }

            else if (testType == "getlength")
            {
                xmlTestItem.TestType = XmlTestType.Length;
            }

            else if (testType == "getnumpoints")
            {
                xmlTestItem.TestType = XmlTestType.NumPoints;
            }

            else if (testType == "overlaps")
            {
                xmlTestItem.TestType = XmlTestType.Overlaps;
            }

            else if (testType == "relate")
            {
                xmlTestItem.TestType = XmlTestType.Relate;
            }

            else if (testType == "getsrid")
            {
                xmlTestItem.TestType = XmlTestType.SRID;
            }

            else if (testType == "symmetricdifference")
            {
                xmlTestItem.TestType = XmlTestType.SymmetricDifference;
            }

            else if (testType == "symdifference")
            {
                xmlTestItem.TestType = XmlTestType.SymmetricDifference;
            }

            else if (testType == "touches")
            {
                xmlTestItem.TestType = XmlTestType.Touches;
            }

            else if (testType == "union")
            {
                xmlTestItem.TestType = XmlTestType.Union;
            }

            else if (testType == "within")
            {
                xmlTestItem.TestType = XmlTestType.Within;
            }

            else if (testType == "covers")
            {
                xmlTestItem.TestType = XmlTestType.Covers;
            }

            else if (testType == "coveredby")
            {
                xmlTestItem.TestType = XmlTestType.CoveredBy;
            }

            else
            {
                throw new ArgumentException(String.Format("The operation type \"{0}\" is not valid: ", testType));
            }

            return(true);
        }
Exemplo n.º 8
0
        protected bool ParseType(string testType, XmlTest xmlTestItem)
        {
            testType = testType.ToLower();

            if (testType == "getarea")
                xmlTestItem.TestType = XmlTestType.Area;
            
            else if (testType == "getboundary")
                xmlTestItem.TestType = XmlTestType.Boundary;
            
            else if (testType == "getboundarydimension")
                xmlTestItem.TestType = XmlTestType.BoundaryDimension;
            
            else if (testType == "buffer")
                xmlTestItem.TestType = XmlTestType.Buffer;
            
            else if (testType == "getcentroid")
                xmlTestItem.TestType = XmlTestType.Centroid;
            
            else if (testType == "contains")
                xmlTestItem.TestType = XmlTestType.Contains;
            
            else if (testType == "convexhull")
                xmlTestItem.TestType = XmlTestType.ConvexHull;
            
            else if (testType == "crosses")
                xmlTestItem.TestType = XmlTestType.Crosses;
            
            else if (testType == "difference")
                xmlTestItem.TestType = XmlTestType.Difference;
            
            else if (testType == "getdimension")
                xmlTestItem.TestType = XmlTestType.Dimension;
            
            else if (testType == "disjoint")
                xmlTestItem.TestType = XmlTestType.Disjoint;
            
            else if (testType == "distance")
                xmlTestItem.TestType = XmlTestType.Distance;
            
            else if (testType == "getenvelope")
                xmlTestItem.TestType = XmlTestType.Envelope;
            
            else if (testType == "equals")
                xmlTestItem.TestType = XmlTestType.Equals;
            
            else if (testType == "getinteriorpoint")
                xmlTestItem.TestType = XmlTestType.InteriorPoint;
            
            else if (testType == "intersection")
                xmlTestItem.TestType = XmlTestType.Intersection;
            
            else if (testType == "intersects")
                xmlTestItem.TestType = XmlTestType.Intersects;
            
            else if (testType == "isempty")
                xmlTestItem.TestType = XmlTestType.IsEmpty;
            
            else if (testType == "issimple")
                xmlTestItem.TestType = XmlTestType.IsSimple;
            
            else if (testType == "isvalid")
                xmlTestItem.TestType = XmlTestType.IsValid;
            
            else if (testType == "iswithindistance")
                xmlTestItem.TestType = XmlTestType.IsWithinDistance;
            
            else if (testType == "getlength")
                xmlTestItem.TestType = XmlTestType.Length;
            
            else if (testType == "getnumpoints")
                xmlTestItem.TestType = XmlTestType.NumPoints;
            
            else if (testType == "overlaps")
                xmlTestItem.TestType = XmlTestType.Overlaps;
            
            else if (testType == "relate")
                xmlTestItem.TestType = XmlTestType.Relate;
            
            else if (testType == "getsrid")
                xmlTestItem.TestType = XmlTestType.SRID;
            
            else if (testType == "symmetricdifference")
                xmlTestItem.TestType = XmlTestType.SymmetricDifference;
            
            else if (testType == "symdifference")
                xmlTestItem.TestType = XmlTestType.SymmetricDifference;
            
            else if (testType == "touches")
                xmlTestItem.TestType = XmlTestType.Touches;
            
            else if (testType == "union")
                xmlTestItem.TestType = XmlTestType.Union;
            
            else if (testType == "within")
                xmlTestItem.TestType = XmlTestType.Within;

            else if (testType == "covers")
                xmlTestItem.TestType = XmlTestType.Covers;

            else if (testType == "coveredby")
                xmlTestItem.TestType = XmlTestType.CoveredBy;
            
            else throw new ArgumentException(String.Format("The operation type \"{0}\" is not valid: ", testType));
            
            return true;
        }
Exemplo n.º 9
0
        protected bool ParseGeometry(Target targetType, string targetText, XmlTest xmlTestItem)
        {   
            IGeometry geom = null;
            try
            {
                geom = m_objReader.Read(targetText);
            }
            catch (Exception ex)
            {
                xmlTestItem.Thrown = ex;
                XmlTestExceptionManager.Publish(ex);
                return false;
            }

            if (geom == null)
                return false;

            switch (targetType) 
            {
                case Target.A:
                    xmlTestItem.A = geom;
                    break;

                case Target.B:
                    xmlTestItem.B = geom;
                    break;
            }

            return true;
        }
Exemplo n.º 10
0
 public void Insert(int index, XmlTest value)
 {
     List.Insert(index, value);
 }
Exemplo n.º 11
0
 public int IndexOf(XmlTest value)
 {
     return(List.IndexOf(value));
 }
Exemplo n.º 12
0
 public int Add(XmlTest value)
 {
     return(List.Add(value));
 }
        protected bool ParseResult(string result, XmlTest xmlTestItem)
        {
            switch (xmlTestItem.TestType)
            {
            // Here we expect double
            case XmlTestType.Area:
            case XmlTestType.Distance:
            case XmlTestType.Length:
            case XmlTestType.MinClearance:
            {
                try
                {
                    xmlTestItem.Result = double.Parse(result, GetNumberFormatInfo());
                    return(true);
                }
                catch (Exception ex)
                {
                    XmlTestExceptionManager.Publish(ex);
                    return(false);
                }
            }

            // Here we expect integer
            case XmlTestType.BoundaryDimension:
            case XmlTestType.Dimension:
            case XmlTestType.NumPoints:
            case XmlTestType.SRID:
            {
                try
                {
                    xmlTestItem.Result = int.Parse(result);
                    return(true);
                }
                catch (Exception ex)
                {
                    XmlTestExceptionManager.Publish(ex);
                    return(false);
                }
            }

            // Here we expect a point
            case XmlTestType.Boundary:
            case XmlTestType.Buffer:
            case XmlTestType.BufferMitredJoin:
            case XmlTestType.Centroid:
            case XmlTestType.ConvexHull:
            case XmlTestType.Densify:
            case XmlTestType.Difference:
            case XmlTestType.Envelope:
            case XmlTestType.InteriorPoint:
            case XmlTestType.Intersection:
            case XmlTestType.SymmetricDifference:
            case XmlTestType.Union:
            case XmlTestType.MinClearanceLine:
            {
                try
                {
                    xmlTestItem.Result = _objReader.Read(result);
                    return(true);
                }
                catch (Exception ex)
                {
                    XmlTestExceptionManager.Publish(ex);
                    return(false);
                }
            }

            // Here we expect boolean
            case XmlTestType.Contains:
            case XmlTestType.Crosses:
            case XmlTestType.Disjoint:
            case XmlTestType.Equals:
            case XmlTestType.Intersects:
            case XmlTestType.IsEmpty:
            case XmlTestType.IsSimple:
            case XmlTestType.IsValid:
            case XmlTestType.IsWithinDistance:
            case XmlTestType.Overlaps:
            case XmlTestType.Relate:
            case XmlTestType.Touches:
            case XmlTestType.Within:
            case XmlTestType.Covers:
            case XmlTestType.CoveredBy:
            case XmlTestType.EqualsExact:
            case XmlTestType.EqualsNorm:
            case XmlTestType.EqualsTopo:
            {
                try
                {
                    xmlTestItem.Result = bool.Parse(result);
                    return(true);
                }
                catch (Exception ex)
                {
                    XmlTestExceptionManager.Publish(ex);
                    return(false);
                }
            }

            default:
                string format = string.Format("Test not implemented: {0}", xmlTestItem.TestType);
                throw new NotImplementedException(format);
            }
        }
Exemplo n.º 14
0
        private void ParseCaseNode(XmlNode caseNode, double tolerance)
        {
            if (caseNode != null && m_objFactory != null)
            {
                XmlTestInfo testInfo = new XmlTestInfo(true);

                XmlNode desc = caseNode["desc"];
                if (desc != null)
                {
                    testInfo.SetValue("desc", desc.InnerText);
                }

                XmlElement a = (XmlElement)caseNode["a"];
                if (a != null)
                {
                    if (a.HasAttribute("file"))
                    {
                    }
                    else
                    {
                        testInfo.SetValue("a", a.InnerText);
                    }
                }

                XmlElement b = (XmlElement)caseNode["b"];
                if (b != null)
                {
                    if (b.HasAttribute("file"))
                    {
                    }
                    else
                    {
                        testInfo.SetValue("b", b.InnerText);
                    }
                }

                // Now, handle the "test" nodes
                XmlNodeList elemList = caseNode.SelectNodes("test");
                if (elemList == null)
                {
                    return;
                }
                if (elemList.Count <= 0)
                {
                    return;
                }
                else if (elemList.Count == 1)
                {
                    XmlElement testElement = ((XmlElement)elemList[0])["op"];
                    testInfo.SetValue("result", testElement.InnerText);

                    if (testElement.HasAttribute("name"))
                    {
                        testInfo.SetValue("name", testElement.GetAttribute("name"));
                    }

                    if (testElement.HasAttribute("arg1"))
                    {
                        testInfo.SetValue("arg1", testElement.GetAttribute("arg1").ToLower());
                    }

                    if (testElement.HasAttribute("arg2"))
                    {
                        testInfo.SetValue("arg2", testElement.GetAttribute("arg2").ToLower());
                    }

                    if (testElement.HasAttribute("arg3"))
                    {
                        testInfo.SetValue("arg3", testElement.GetAttribute("arg3"));
                    }

                    XmlTest xmlTest = m_objFactory.Create(testInfo, tolerance);
                    if (xmlTest != null && m_listCurTests != null)
                    {
                        m_listCurTests.Add(xmlTest);
                    }
                }
                else
                {
                    string baseDesc = testInfo.GetValue("desc");

                    for (int i = 0; i < elemList.Count; i++)
                    {
                        string strDescNew = baseDesc + " - " + (i + 1).ToString();

                        testInfo.SetValue("desc", strDescNew);

                        XmlElement testElement = ((XmlElement)elemList[i])["op"];
                        testInfo.SetValue("result", testElement.InnerText);

                        if (testElement.HasAttribute("name"))
                        {
                            testInfo.SetValue("name", testElement.GetAttribute("name"));
                        }

                        if (testElement.HasAttribute("arg1"))
                        {
                            testInfo.SetValue("arg1", testElement.GetAttribute("arg1"));
                        }

                        if (testElement.HasAttribute("arg2"))
                        {
                            testInfo.SetValue("arg2", testElement.GetAttribute("arg2"));
                        }

                        if (testElement.HasAttribute("arg3"))
                        {
                            testInfo.SetValue("arg3", testElement.GetAttribute("arg3"));
                        }

                        XmlTest xmlTest = m_objFactory.Create(testInfo, tolerance);
                        if (xmlTest != null && m_listCurTests != null)
                        {
                            m_listCurTests.Add(xmlTest);
                        }
                    }
                }

                testInfo.Clear();
            }
        }
Exemplo n.º 15
0
 public XmlTestEventArgs(int index, bool success, XmlTest testItem) : base()
 {
     m_nIndex   = index;
     m_bSuccess = success;
     m_objTest  = testItem;
 }
Exemplo n.º 16
0
        protected bool ParseResult(string result, XmlTest xmlTestItem)
        {
            switch (xmlTestItem.TestType) 
            {
                // Here we expect double
                case XmlTestType.Area:
                case XmlTestType.Distance:
                case XmlTestType.Length:
                {
                    try
                    {
                        xmlTestItem.Result = Double.Parse(result, GetNumberFormatInfo());
                        return true;
                    }
                    catch (Exception ex)
                    {
                        XmlTestExceptionManager.Publish(ex);
                        return false;
                    }
                }

                // Here we expect integer
                case XmlTestType.BoundaryDimension:
                case XmlTestType.Dimension:
                case XmlTestType.NumPoints:
                case XmlTestType.SRID:
                {
                    try
                    {
                        xmlTestItem.Result = Int32.Parse(result);
                        return true;
                    }
                    catch (Exception ex)
                    {
                        XmlTestExceptionManager.Publish(ex);
                        return false;
                    }
                }

                // Here we expect a point
                case XmlTestType.Boundary:
                case XmlTestType.Buffer:
                case XmlTestType.Centroid:
                case XmlTestType.ConvexHull:
                case XmlTestType.Difference:
                case XmlTestType.Envelope:
                case XmlTestType.InteriorPoint:
                case XmlTestType.Intersection:
                case XmlTestType.SymmetricDifference:
                case XmlTestType.Union:
                {
                    try
                    {
                        xmlTestItem.Result = m_objReader.Read(result);                        
                        return true;
                    }
                    catch (Exception ex)
                    {
                        XmlTestExceptionManager.Publish(ex);
                        return false;
                    }
                }

                // Here we expect boolean
                case XmlTestType.Contains:
                case XmlTestType.Crosses:
                case XmlTestType.Disjoint:
                case XmlTestType.Equals:
                case XmlTestType.Intersects:
                case XmlTestType.IsEmpty:
                case XmlTestType.IsSimple:
                case XmlTestType.IsValid:
                case XmlTestType.IsWithinDistance:
                case XmlTestType.Overlaps:
                case XmlTestType.Relate:
                case XmlTestType.Touches:
                case XmlTestType.Within:
                case XmlTestType.Covers:
                case XmlTestType.CoveredBy:
                {
                    try
                    {
                        xmlTestItem.Result = Boolean.Parse(result);
                        return true;
                    }
                    catch (Exception ex)
                    {
                        XmlTestExceptionManager.Publish(ex);
                        return false;
                    }
                }

                default:
                    break;
            }
            return false;
        }
Exemplo n.º 17
0
 public void Remove(XmlTest value)
 {
     List.Remove(value);
 }
        public XmlTest Create(XmlTestInfo testInfo, double tolerance)
        {
            XmlTest xmlTest = new XmlTest(testInfo.GetValue("desc"),
                                          testInfo.IsDefaultTarget(), tolerance, _geometryOperation, _resultMatcher);

            // Handle test type or name.
            string strTestType = testInfo.GetValue("name");

            if (string.IsNullOrEmpty(strTestType))
            {
                return(null);
            }

            ParseType(strTestType, xmlTest);

            // Handle the Geometry A:
            string wkt = testInfo.GetValue("a");

            if (!string.IsNullOrEmpty(wkt))
            {
                ParseGeometry(Target.A, wkt, xmlTest);
            }

            // Handle the Geometry B:
            wkt = testInfo.GetValue("b");
            if (!string.IsNullOrEmpty(wkt))
            {
                ParseGeometry(Target.B, wkt, xmlTest);
            }

            string arg2 = testInfo.GetValue("arg2");

            if (!string.IsNullOrEmpty(arg2))
            {
                if (arg2 == "a" || arg2 == "A")
                {
                    xmlTest.Argument1 = xmlTest.A;
                }
                else if (arg2 == "b" || arg2 == "B")
                {
                    xmlTest.Argument1 = xmlTest.B;
                }
                else
                {
                    xmlTest.Argument1 = arg2;
                }
            }

            string arg3 = testInfo.GetValue("arg3");

            if (!string.IsNullOrEmpty(arg3))
            {
                xmlTest.Argument2 = arg3;
            }

            string strResult = testInfo.GetValue("result");

            if (string.IsNullOrEmpty(strResult))
            {
                return(null);
            }

            ParseResult(strResult, xmlTest);

            return(xmlTest);
        }
Exemplo n.º 19
0
 public int Add(XmlTest value)  
 {
     return List.Add(value);
 }
Exemplo n.º 20
0
 public XmlTestEventArgs(int index, bool success, XmlTest testItem)
 {
     _nIndex   = index;
     _bSuccess = success;
     _objTest  = testItem;
 }
Exemplo n.º 21
0
 public int IndexOf(XmlTest value)  
 {
     return List.IndexOf(value);
 }
Exemplo n.º 22
0
        protected bool ParseResult(string result, XmlTest xmlTestItem)
        {
            switch (xmlTestItem.TestType)
            {
            // Here we expect double
            case XmlTestType.Area:
            case XmlTestType.Distance:
            case XmlTestType.Length:
            {
                try
                {
                    xmlTestItem.Result = Double.Parse(result, GetNumberFormatInfo());
                    return(true);
                }
                catch (Exception ex)
                {
                    XmlTestExceptionManager.Publish(ex);
                    return(false);
                }
            }

            // Here we expect integer
            case XmlTestType.BoundaryDimension:
            case XmlTestType.Dimension:
            case XmlTestType.NumPoints:
            case XmlTestType.SRID:
            {
                try
                {
                    xmlTestItem.Result = Int32.Parse(result);
                    return(true);
                }
                catch (Exception ex)
                {
                    XmlTestExceptionManager.Publish(ex);
                    return(false);
                }
            }

            // Here we expect a point
            case XmlTestType.Boundary:
            case XmlTestType.Buffer:
            case XmlTestType.Centroid:
            case XmlTestType.ConvexHull:
            case XmlTestType.Difference:
            case XmlTestType.Envelope:
            case XmlTestType.InteriorPoint:
            case XmlTestType.Intersection:
            case XmlTestType.SymmetricDifference:
            case XmlTestType.Union:
            {
                try
                {
                    xmlTestItem.Result = m_objReader.Read(result);
                    return(true);
                }
                catch (Exception ex)
                {
                    XmlTestExceptionManager.Publish(ex);
                    return(false);
                }
            }

            // Here we expect boolean
            case XmlTestType.Contains:
            case XmlTestType.Crosses:
            case XmlTestType.Disjoint:
            case XmlTestType.Equals:
            case XmlTestType.Intersects:
            case XmlTestType.IsEmpty:
            case XmlTestType.IsSimple:
            case XmlTestType.IsValid:
            case XmlTestType.IsWithinDistance:
            case XmlTestType.Overlaps:
            case XmlTestType.Relate:
            case XmlTestType.Touches:
            case XmlTestType.Within:
            case XmlTestType.Covers:
            case XmlTestType.CoveredBy:
            {
                try
                {
                    xmlTestItem.Result = Boolean.Parse(result);
                    return(true);
                }
                catch (Exception ex)
                {
                    XmlTestExceptionManager.Publish(ex);
                    return(false);
                }
            }

            default:
                break;
            }
            return(false);
        }
Exemplo n.º 23
0
 public void Insert(int index, XmlTest value)  
 {
     List.Insert(index, value);
 }
Exemplo n.º 24
0
        public XmlTest Create(XmlTestInfo testInfo, double tolerance)
        {
            XmlTest xmlTest = new XmlTest(testInfo.GetValue("desc"),
                                          testInfo.IsDefaultTarget(), tolerance);

            // Handle test type or name.
            string strTestType = testInfo.GetValue("name");

            if (strTestType == null || strTestType.Length == 0)
            {
                return(null);
            }

            ParseType(strTestType, xmlTest);

            // Handle the Geometry A:
            string wktA = testInfo.GetValue("a");

            if (wktA != null && wktA.Length > 0)
            {
                ParseGeometry(Target.A, wktA, xmlTest);
            }

            // Handle the Geometry B:
            string wktB = testInfo.GetValue("b");

            if (wktB != null && wktB.Length > 0)
            {
                ParseGeometry(Target.B, wktB, xmlTest);
            }

            // Handle the arguments
            string arg2 = testInfo.GetValue("arg2");

            if (arg2 != null && arg2.Length > 0)
            {
                if (arg2 == "a")
                {
                    xmlTest.Argument1 = xmlTest.A;
                }
                else if (arg2 == "b")
                {
                    xmlTest.Argument1 = xmlTest.B;
                }
            }

            string arg3 = testInfo.GetValue("arg3");

            if (arg3 != null && arg3.Length > 0)
            {
                xmlTest.Argument2 = arg3;
            }

            string strResult = testInfo.GetValue("result");

            if (strResult == null || strResult.Length == 0)
            {
                return(null);
            }

            ParseResult(strResult, xmlTest);

            return(xmlTest);
        }
Exemplo n.º 25
0
        protected bool ParseResult(string result, XmlTest xmlTestItem)
        {
            switch (xmlTestItem.TestType) 
            {
                // Here we expect double
                case XmlTestType.Area:
                case XmlTestType.Distance:
                case XmlTestType.Length:
                case XmlTestType.MinClearance:
                {
                    try
                    {
                        xmlTestItem.Result = Double.Parse(result, GetNumberFormatInfo());
                        return true;
                    }
                    catch (Exception ex)
                    {
                        XmlTestExceptionManager.Publish(ex);
                        return false;
                    }
                }

                // Here we expect integer
                case XmlTestType.BoundaryDimension:
                case XmlTestType.Dimension:
                case XmlTestType.NumPoints:
                case XmlTestType.SRID:
                {
                    try
                    {
                        xmlTestItem.Result = Int32.Parse(result);
                        return true;
                    }
                    catch (Exception ex)
                    {
                        XmlTestExceptionManager.Publish(ex);
                        return false;
                    }
                }

                // Here we expect a point
                case XmlTestType.Boundary:
                case XmlTestType.Buffer:
                case XmlTestType.BufferMitredJoin:
                case XmlTestType.Centroid:
                case XmlTestType.ConvexHull:
                case XmlTestType.Densify:
                case XmlTestType.Difference:
                case XmlTestType.Envelope:
                case XmlTestType.InteriorPoint:
                case XmlTestType.Intersection:
                case XmlTestType.SymmetricDifference:
                case XmlTestType.Union:
                case XmlTestType.MinClearanceLine:
                {
                    try
                    {
                        xmlTestItem.Result = _objReader.Read(result);                        
                        return true;
                    }
                    catch (Exception ex)
                    {
                        XmlTestExceptionManager.Publish(ex);
                        return false;
                    }
                }

                // Here we expect boolean
                case XmlTestType.Contains:
                case XmlTestType.Crosses:
                case XmlTestType.Disjoint:
                case XmlTestType.Equals:
                case XmlTestType.Intersects:
                case XmlTestType.IsEmpty:
                case XmlTestType.IsSimple:
                case XmlTestType.IsValid:
                case XmlTestType.IsWithinDistance:
                case XmlTestType.Overlaps:
                case XmlTestType.Relate:
                case XmlTestType.Touches:
                case XmlTestType.Within:
                case XmlTestType.Covers:
                case XmlTestType.CoveredBy:
                case XmlTestType.EqualsExact:
                case XmlTestType.EqualsNorm:
                case XmlTestType.EqualsTopo:
                {
                    try
                    {
                        xmlTestItem.Result = Boolean.Parse(result);
                        return true;
                    }
                    catch (Exception ex)
                    {
                        XmlTestExceptionManager.Publish(ex);
                        return false;
                    }
                }

                default:
                    string format = String.Format("Test not implemented: {0}",  xmlTestItem.TestType);
                    throw new NotImplementedException(format);
            }
        }