Regnerate geos wrapper with correct version for this branch
[geos.git] / src / noding / FastNodingValidator.cpp
blobaae89c6fcbd37ddb5d49a63fa5b8b2ef614b7335
1 /**********************************************************************
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
6 * Copyright (C) 2006 Refractions Research Inc.
8 * This is free software; you can redistribute and/or modify it under
9 * the terms of the GNU Lesser General Licence as published
10 * by the Free Software Foundation.
11 * See the COPYING file for more information.
13 **********************************************************************
15 * Last port: noding/FastNodingValidator.java rev. ??? (JTS-1.8)
17 **********************************************************************/
19 #include <geos/noding/FastNodingValidator.h>
20 #include <geos/noding/MCIndexNoder.h> // for checkInteriorIntersections()
21 #include <geos/noding/SingleInteriorIntersectionFinder.h>
22 #include <geos/util/TopologyException.h> // for checkValid()
23 #include <geos/geom/Coordinate.h>
24 #include <geos/io/WKTWriter.h> // for getErrorMessage()
26 #include <string>
27 #include <iostream>
29 namespace geos {
30 namespace noding { // geos.noding
32 /*private*/
33 void
34 FastNodingValidator::checkInteriorIntersections()
36 isValidVar = true;
37 segInt.reset(new SingleInteriorIntersectionFinder(li));
38 MCIndexNoder noder;
39 noder.setSegmentIntersector(segInt.get());
40 noder.computeNodes(&segStrings);
41 if (segInt->hasIntersection()) {
42 isValidVar = false;
43 return;
47 /*public*/
48 std::string
49 FastNodingValidator::getErrorMessage() const
51 using geos::io::WKTWriter;
52 using geos::geom::Coordinate;
54 if (isValidVar) return std::string("no intersections found");
56 //return std::string("found non-noded intersection etc etc");
58 const std::vector<Coordinate>& intSegs = segInt->getIntersectionSegments();
59 assert(intSegs.size() == 4);
60 return "found non-noded intersection between "
61 + WKTWriter::toLineString(intSegs[0], intSegs[1])
62 + " and "
63 + WKTWriter::toLineString(intSegs[2], intSegs[3]);
66 void
67 FastNodingValidator::checkValid()
69 execute();
70 if (! isValidVar)
72 //std::cerr << "Not valid: " << getErrorMessage() << " interior intersection: " << segInt->getInteriorIntersection() << std::endl;
73 throw util::TopologyException(getErrorMessage(), segInt->getInteriorIntersection());
77 } // namespace geos.noding
78 } // namespace geos
80 /**********************************************************************
81 * $Log$
82 **********************************************************************/