Search in sources :

Example 1 with WKTOrWKBReader

use of com.revolsys.geometry.test.util.WKTOrWKBReader in project com.revolsys.open by revolsys.

the class TestReader method toGeometryResult.

/*
   * private GeometryOperation getGeometryOperationInstance(String classname) { GeometryOperation op
   * = null; try { Class goClass = Class.forName(classname); if
   * (!(GeometryOperation.class.isAssignableFrom(goClass))) return null; op = (GeometryOperation)
   * goClass.newInstance(); } catch (Exception ex) { return null; } return op; }
   */
private GeometryResult toGeometryResult(final String value, final TestFile testRun) throws com.revolsys.geometry.wkb.ParseException {
    final GeometryFactory geometryFactory = GeometryFactory.floating2d(0);
    final WKTOrWKBReader wktorbReader = new WKTOrWKBReader(geometryFactory);
    return new GeometryResult(wktorbReader.read(value));
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) WKTOrWKBReader(com.revolsys.geometry.test.util.WKTOrWKBReader)

Example 2 with WKTOrWKBReader

use of com.revolsys.geometry.test.util.WKTOrWKBReader in project com.revolsys.open by revolsys.

the class TestReader method parseTestCases.

/**
 *  Creates a List of TestCase's from the given <case> Element's.
 */
private List<TestCase> parseTestCases(final List caseElements, final File testFile, final TestFile testRun, final double tolerance) throws Throwable {
    this.wktorbReader = new WKTOrWKBReader(this.geometryFactory);
    final Vector<TestCase> testCases = new Vector<>();
    int caseIndex = 0;
    for (final Iterator i = caseElements.iterator(); i.hasNext(); ) {
        final Element caseElement = (Element) i.next();
        // System.out.println("Line: " +
        // ((LineNumberElement)caseElement).getStartLine());
        caseIndex++;
        try {
            final Element descElement = caseElement.getChild("desc");
            final Element aElement = caseElement.getChild("a");
            final Element bElement = caseElement.getChild("b");
            final File aWktFile = wktFile(aElement, testRun);
            final File bWktFile = wktFile(bElement, testRun);
            final String description = descElement != null ? descElement.getTextTrim() : "";
            final Geometry a = readGeometry(aElement, absoluteWktFile(aWktFile, testRun));
            final Geometry b = readGeometry(bElement, absoluteWktFile(bWktFile, testRun));
            final TestCase testCase = new TestCase(description, a, b, aWktFile, bWktFile, testRun, caseIndex, ((LineNumberElement) caseElement).getStartLine());
            final List testElements = caseElement.getChildren("test");
            // if (testElements.size() == 0) {
            // throw new TestParseException("Missing <test> in <case>");
            // }
            final List<GeometryOperationTest> tests = parseTests(testElements, caseIndex, testFile, testCase, tolerance);
            for (final GeometryOperationTest test : tests) {
                testCase.add(test);
            }
            testCases.add(testCase);
        } catch (final Exception e) {
            throw new IllegalArgumentException("An exception occurred while parsing <case> " + caseIndex + " in " + testFile, e);
        }
    }
    return testCases;
}
Also used : LineNumberElement(com.revolsys.geometry.test.util.LineNumberElement) Element(org.jdom.Element) DataConversionException(org.jdom.DataConversionException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) Geometry(com.revolsys.geometry.model.Geometry) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) WKTOrWKBReader(com.revolsys.geometry.test.util.WKTOrWKBReader) Vector(java.util.Vector) File(java.io.File)

Aggregations

WKTOrWKBReader (com.revolsys.geometry.test.util.WKTOrWKBReader)2 Geometry (com.revolsys.geometry.model.Geometry)1 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)1 LineNumberElement (com.revolsys.geometry.test.util.LineNumberElement)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Vector (java.util.Vector)1 DataConversionException (org.jdom.DataConversionException)1 Element (org.jdom.Element)1