当前位置: 首页>>代码示例>>C++>>正文


C++ io::WKTReader类代码示例

本文整理汇总了C++中geos::io::WKTReader的典型用法代码示例。如果您正苦于以下问题:C++ WKTReader类的具体用法?C++ WKTReader怎么用?C++ WKTReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了WKTReader类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: test_pointlocator_group

namespace tut {
//
// Test Group
//

// dummy data, not used
struct test_pointlocator_data {};

typedef test_group<test_pointlocator_data> group;
typedef group::object object;

group test_pointlocator_group("geos::algorithm::PointLocator");

// These are static to avoid namespace pollution
// The struct test_*_data above is probably there
// for the same reason...
//
static PrecisionModel pm;
static GeometryFactory::Ptr gf = GeometryFactory::create(&pm);
static geos::io::WKTReader reader(gf.get());

typedef std::unique_ptr<Geometry> GeomPtr;

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);
}


//
// Test Cases
//

// 1 - Test box
template<>
template<>
void object::test<1>
()
{
    runPtLocator(Location::INTERIOR, Coordinate(10, 10),
                 "POLYGON ((0 0, 0 20, 20 20, 20 0, 0 0))");
}

// 2 - Test complex ring
template<>
template<>
void object::test<2>
()
{
    runPtLocator(Location::INTERIOR, Coordinate(0, 0),
                 "POLYGON ((-40 80, -40 -80, 20 0, 20 -100, 40 40, 80 -80, 100 80, 140 -20, 120 140, 40 180,     60 40, 0 120, -20 -20, -40 80))");
}

// 3 - Test PointLocator LinearRing LineString
template<>
template<>
void object::test<3>
()
{
    runPtLocator(Location::BOUNDARY, Coordinate(0, 0),
                 "GEOMETRYCOLLECTION( LINESTRING(0 0, 10 10), LINEARRING(10 10, 10 20, 20 10, 10 10))");
}

// 4 - Test PointLocator Point inside LinearRing
template<>
template<>
void object::test<4>
()
{
    runPtLocator(Location::EXTERIOR, Coordinate(11, 11),
                 "LINEARRING(10 10, 10 20, 20 10, 10 10)");
}

// 5 - TestPointLocator Point inside MultiPoint
template<>
template<>
void object::test<5>
()
{
    runPtLocator(Location::INTERIOR, Coordinate(0, 0),
                 "MULTIPOINT ((1 1), (0 0))");
}

} // namespace tut
开发者ID:libgeos,项目名称:libgeos,代码行数:89,代码来源:PointLocatorTest.cpp

示例2: runIndicesOfThenExtract

 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());
 }
开发者ID:ryandavid,项目名称:rotobox,代码行数:8,代码来源:LengthIndexedLineTest.cpp

示例3: runIndexOfAfterTest

 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);
 }
开发者ID:ryandavid,项目名称:rotobox,代码行数:8,代码来源:LengthIndexedLineTest.cpp

示例4: runOffsetTest

    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);
    }
开发者ID:ryandavid,项目名称:rotobox,代码行数:15,代码来源:LengthIndexedLineTest.cpp

示例5: testInputOutput

		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());

		}
开发者ID:MarkusMattinen,项目名称:libspatialite,代码行数:34,代码来源:WKBReaderTest.cpp

示例6: checkExtractLine

 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);
 }
开发者ID:ryandavid,项目名称:rotobox,代码行数:8,代码来源:LengthIndexedLineTest.cpp

示例7:

		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);
		}
开发者ID:asapnet,项目名称:geos,代码行数:9,代码来源:PolygonTest.cpp

示例8: geom

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);
}
开发者ID:libgeos,项目名称:libgeos,代码行数:9,代码来源:PointLocatorTest.cpp

示例9: checkLengthOfLine

 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);
 }
开发者ID:libgeos,项目名称:libgeos,代码行数:10,代码来源:LengthTest.cpp

示例10:

		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);
		}
开发者ID:mwtoews,项目名称:libgeos,代码行数:11,代码来源:PolygonTest.cpp

示例11: fromWKT

	GeomPtr fromWKT(const std::string& wkt)
	{
		GeomPtr geom;
		try {
			geom.reset( rdr.read(wkt) );
		}
		catch (const GEOSException& ex) {
			cerr << ex.what() << endl;
		}
		return geom;
	}
开发者ID:mwtoews,项目名称:libgeos,代码行数:11,代码来源:ValidClosedRingTest.cpp

示例12:

        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()) )

	{
	}
开发者ID:asapnet,项目名称:geos,代码行数:11,代码来源:GeometrySnapperTest.cpp

示例13: readWKT

 GeomPtr readWKT(const std::string& inputWKT)
 {
     return GeomPtr(wktreader.read(inputWKT));
 }
开发者ID:ryandavid,项目名称:rotobox,代码行数:4,代码来源:PolygonizeTest.cpp

示例14: checkExpected

 void checkExpected(Geometry* result, string const& expected)
 {
     GeomPtr subLine(reader.read(expected));
     checkExpected(result, subLine.get());
 }
开发者ID:ryandavid,项目名称:rotobox,代码行数:5,代码来源:LengthIndexedLineTest.cpp


注:本文中的geos::io::WKTReader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。