void runIndexOfAfterTest(string const& inputStr, string const& testPtWKT)
 {
     GeomPtr input(reader.read(inputStr));
     GeomPtr testPoint(reader.read(testPtWKT));
     const Coordinate* testPt = testPoint->getCoordinate();
     bool resultOK = indexOfAfterCheck(input.get(), *testPt);
     ensure(resultOK);
 }
 void runIndicesOfThenExtract(string const& inputStr, string const& subLineStr)
 {
     GeomPtr input(reader.read(inputStr));
     GeomPtr subLine(reader.read(subLineStr));
     GeomPtr result(indicesOfThenExtract(input.get(), subLine.get()));
     
     checkExpected(result.get(), subLine.get());
 }
    void runOffsetTest(string const& inputWKT, string const& testPtWKT,
                       double offsetDistance, string const& expectedPtWKT)
    {
        GeomPtr input(reader.read(inputWKT));
        GeomPtr testPoint(reader.read(testPtWKT));
        GeomPtr expectedPoint(reader.read(expectedPtWKT));
        const Coordinate* testPt = testPoint->getCoordinate();
        const Coordinate* expectedPt = expectedPoint->getCoordinate();
        Coordinate offsetPt = extractOffsetAt(input.get(), *testPt, offsetDistance);

        bool isOk = offsetPt.distance(*expectedPt) < TOLERANCE_DIST;
        if (! isOk)
            cout << "Expected = " << *expectedPoint << "  Actual = " << offsetPt << endl;
        ensure(isOk);
    }
		void testInputOutput(const std::string& WKT,
				const std::string& ndrWKB,
				const std::string& xdrWKB)
		{
			GeomPtr gWKT(wktreader.read(WKT));

			// NDR input
			std::stringstream ndr_in(ndrWKB);
			GeomPtr gWKB_ndr(wkbreader.readHEX(ndr_in));
			ensure("NDR input",
				gWKB_ndr->equalsExact(gWKT.get()) );

			// XDR input
			std::stringstream xdr_in(xdrWKB);
			GeomPtr gWKB_xdr(wkbreader.readHEX(xdr_in));
			ensure("XDR input",
				gWKB_xdr->equalsExact(gWKT.get()) );

			// Compare geoms read from NDR and XDR
			ensure( gWKB_xdr->equalsExact(gWKB_ndr.get()) );

			// NDR output
			std::stringstream ndr_out;
			ndrwkbwriter.writeHEX(*gWKT, ndr_out);
			ensure_equals("NDR output",
				ndr_out.str(), ndr_in.str());

			// XDR output
			std::stringstream xdr_out;
			xdrwkbwriter.writeHEX(*gWKT, xdr_out);
			ensure_equals("XDR output",
				xdr_out.str(), xdr_in.str());

		}
 void checkExtractLine(const char* wkt, double start, double end, const char* expected)
 {
     string wktstr(wkt);
     GeomPtr linearGeom(reader.read(wktstr));
     LengthIndexedLine indexedLine(linearGeom.get());
     GeomPtr result(indexedLine.extractLine(start, end));
     checkExpected(result.get(), expected);
 }
Esempio n. 6
0
		test_polygon_data() 
			: pm_(1), factory_(&pm_, 0), reader_(&factory_),
			empty_poly_(factory_.createPolygon()), poly_size_(7)
		{
			// Create non-empty LinearRing
			GeometryPtr geo = 0;
			geo = reader_.read("POLYGON((0 10, 5 5, 10 5, 15 10, 10 15, 5 15, 0 10))");
			poly_ = static_cast<PolygonPtr>(geo);
		}
Esempio n. 7
0
void
runPtLocator(int expected, const Coordinate& pt,
             const std::string& wkt)
{
    GeomPtr geom(reader.read(wkt));
    geos::algorithm::PointLocator pointLocator;
    int loc = pointLocator.locate(pt, geom.get());
    ensure_equals(loc, expected);
}
Esempio n. 8
0
 void
 checkLengthOfLine(std::string wkt, double expectedLength)
 {
     std::unique_ptr<Geometry> lineGeom(reader_.read(wkt));
     std::unique_ptr<LineString> line(dynamic_cast<LineString*>(lineGeom.release()));
     ensure(nullptr != line.get());
     const CoordinateSequence* lineSeq = line->getCoordinatesRO();
     double actual = algorithm::Length::ofLine(lineSeq);
     ensure_equals(actual, expectedLength);
 }
Esempio n. 9
0
		test_polygon_data()
			: pm_(1)
      , factory_(GeometryFactory::create(&pm_, 0))
      , reader_(factory_.get())
      , empty_poly_(factory_->createPolygon()), poly_size_(7)
		{
			// Create non-empty LinearRing
			GeometryPtr geo = nullptr;
			geo = reader_.read("POLYGON((0 10, 5 5, 10 5, 15 10, 10 15, 5 15, 0 10))");
			poly_ = dynamic_cast<PolygonPtr>(geo);
		}
Esempio n. 10
0
	GeomPtr fromWKT(const std::string& wkt)
	{
		GeomPtr geom;
		try {
			geom.reset( rdr.read(wkt) );
		}
		catch (const GEOSException& ex) {
			cerr << ex.what() << endl;
		}
		return geom;
	}
Esempio n. 11
0
        test_geometrysnapper_data()
		:
		factory(), // initialize before use!
		reader(&factory),
		src(reader.read(
			"POLYGON ((0 0, 0 100, 100 100, 100 0, 0 0))"
		)),
		snapper( *(src.get()) )

	{
	}
Esempio n. 12
0
 GeomPtr readWKT(const std::string& inputWKT)
 {
     return GeomPtr(wktreader.read(inputWKT));
 }
Esempio n. 13
0
 void checkExpected(Geometry* result, string const& expected)
 {
     GeomPtr subLine(reader.read(expected));
     checkExpected(result, subLine.get());
 }