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); }
int main() { PrecisionModel pm; GeometryFactory::Ptr gf = GeometryFactory::create(&pm); WKTReader rdr(gf.get()); string inputWKT = "POLYGON ((110 320, 190 220, 60 200, 180 120, 120 40, 290 150, 410 40, 410 230, 500 340, 320 310, 260 370, 220 310, 110 320), (220 260, 250 180, 290 220, 360 150, 350 250, 260 280, 220 260))"; GeomPtr base ( rdr.read(inputWKT) ); run(base.get()); }
void object::test<13>() { Coordinate p1(-123456789, -40); Coordinate p2(381039468754763.0, 123456789); Coordinate q(0, 0); using geos::geom::CoordinateSequence; using geos::geom::GeometryFactory; using geos::geom::LineString; GeometryFactory::Ptr factory = GeometryFactory::create(); CoordinateSequence* cs = new CoordinateArraySequence(); cs->add(p1); cs->add(p2); GeomPtr l ( factory->createLineString(cs) ); GeomPtr p ( factory->createPoint(q) ); ensure(!l->intersects(p.get())); ensure(!CGAlgorithms::isOnLine(q, cs)); ensure_equals(CGAlgorithms::computeOrientation(p1, p2, q), -1); }
~test_polygon_data() { // FREE MEMORY factory_->destroyGeometry(poly_); }
test_validclosedring_data() : pm_(1) , factory_(GeometryFactory::create(&pm_, 0)) , rdr(factory_.get()) {}
test_geometry_clone_data() : factory(GeometryFactory::create()) , reader(factory.get()) {}
test_unaryuniontest_data() : gf(GeometryFactory::create()), wktreader(gf.get()) { wktwriter.setTrim(true); }
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