public XmlTestFactory(PrecisionModel pm, IGeometryOperation geometryOperation, IResultMatcher resultMatcher) { ObjGeometryFactory = new GeometryFactory(pm); _geometryOperation = geometryOperation; _resultMatcher = resultMatcher; _objReader = new WKTOrWKBReader(ObjGeometryFactory); }
public XmlTestFactory(PrecisionModel pm, IGeometryOperation geometryOperation, IResultMatcher resultMatcher) { var gs = new NtsGeometryServices(pm, 0); //ObjGeometryFactory = gs.CreateGeometryFactory(); _geometryOperation = geometryOperation; _resultMatcher = resultMatcher; _objReader = new MultiFormatReader(gs); }
public LoggingGeometryOperation(IGeometryOperation geomOp) { _geomOp = geomOp; }
public XmlTest(string description, bool bIsDefaultTarget, double tolerance, IGeometryOperation geometryOperation, IResultMatcher resultMatcher) { if (!string.IsNullOrEmpty(description)) { _strDescription = description; } else { _strDescription = "Untitled" + _nCount.ToString(); ++_nCount; } _bIsDefaultTarget = bIsDefaultTarget; _dTolerance = tolerance; _geometryOperation = geometryOperation; _resultMatcher = resultMatcher; }
public bool LoadFile(string fileName) { if (!File.Exists(fileName)) { throw new ArgumentException(fileName, "The file does not exits or the 'fileName' is not valid."); } try { var xmldoc = new XmlDocument(); xmldoc.Load(fileName); var root = xmldoc.DocumentElement; // Retrieve the "desc" tag, if any. XmlNode desc = root["desc"]; string strTestDescription = string.Empty; if (desc != null && desc.InnerText.Length > 0) { strTestDescription = desc.InnerText; } else { strTestDescription = Path.GetFileNameWithoutExtension(fileName); } // Retrieve the "workspace", if any. XmlNode workspace = root["workspace"]; if (workspace != null) { var workspaceAttributes = workspace.Attributes; if (workspaceAttributes != null && workspaceAttributes.Count > 0) { m_strTestWorkspace = workspaceAttributes["dir"].InnerText; } } // Retrieve the "tolerance" attribute, if any. XmlNode tolerance = root["tolerance"]; double dTolerance = 0.0; if (tolerance != null) { string strTolerance = tolerance.InnerText; try { dTolerance = double.Parse(strTolerance, GetNumberFormatInfo()); } catch (Exception ex) { XmlTestExceptionManager.Publish(ex); } } // Retrieve the precisionName" tag, if any. PrecisionModel pm = null; XmlNode precision = root["precisionModel"]; if (precision != null) { var precisionAttributes = precision.Attributes; if (precisionAttributes != null && precisionAttributes.Count > 0) { var attribute = precisionAttributes["type"]; if (attribute != null) { string strPrecision = attribute.InnerText; if (strPrecision == "FIXED" && precisionAttributes.Count == 4) { try { double scale = double.Parse(precisionAttributes["scale"].InnerText, GetNumberFormatInfo()); double offsetx = double.Parse(precisionAttributes["offsetx"].InnerText, GetNumberFormatInfo()); double offsety = double.Parse(precisionAttributes["offsety"].InnerText, GetNumberFormatInfo()); pm = new PrecisionModel(scale); } catch (Exception ex) { XmlTestExceptionManager.Publish(ex); } } else { pm = new PrecisionModel(); } } else { if (precisionAttributes.Count == 3) { double scale = double.Parse(precisionAttributes["scale"].InnerText, GetNumberFormatInfo()); double offsetx = double.Parse(precisionAttributes["offsetx"].InnerText, GetNumberFormatInfo()); double offsety = double.Parse(precisionAttributes["offsety"].InnerText, GetNumberFormatInfo()); pm = new PrecisionModel(scale); } } } } if (pm == null) { pm = new PrecisionModel(); } IGeometryOperation geometryOperation = null; XmlNode go = root["geometryOperation"]; if (go != null) { go = go.FirstChild; switch (go.Value) { case "com.vividsolutions.jtstest.geomop.PreparedGeometryOperation": geometryOperation = new PreparedGeometryOperation(); break; case "com.vividsolutions.jtstest.geomop.BufferValidatedGeometryOperation": geometryOperation = new BufferValidatedGeometryOperation(); break; case "com.vividsolutions.jtstest.geomop.OverlayValidatedGeometryOperation": geometryOperation = new OverlayValidatedGeometryOperation(); break; default: Console.WriteLine(string.Format("\n *** {0} *** \n", go.Value)); Console.ReadKey(true); geometryOperation = new GeometryMethodOperation(); break; } } IResultMatcher resultMatcher = null; XmlNode rm = root["resultMatcher"]; if (rm != null) { rm = rm.FirstChild; if (rm.Value.EndsWith("BufferResultMatcher", StringComparison.InvariantCultureIgnoreCase)) { resultMatcher = new BufferResultMatcher(); } else { throw new NotSupportedException(); } } m_objFactory = new XmlTestFactory(pm, geometryOperation, resultMatcher); m_listCurTests = new XmlTestCollection(); m_listCurTests.Name = strTestDescription; // Now, handle the "case" nodes var elemList = xmldoc.GetElementsByTagName("case"); for (int i = 0; i < elemList.Count; i++) { ParseCaseNode(elemList[i], dTolerance); } m_listarrTests.Add(m_listCurTests); return(true); } catch (Exception ex) { XmlTestExceptionManager.Publish(ex); return(false); } }