void object::test<8>()
    {
        geom1_ = GEOSGeomFromWKT("MULTILINESTRING((0 0, 10 0),(10 0, 10 10))");
        geom2_ = GEOSGeomFromWKT("LINESTRING(10 0, 10 -10)");
        pat_ = GEOSRelateBoundaryNodeRule(geom1_, geom2_, 5);
	ensure(0 == pat_);
    }
    void object::test<2>()
    {
        geom1_ = GEOSGeomFromWKT("LINESTRING(0 0, 10 0, 10 10, 0 0)");
        geom2_ = GEOSGeomFromWKT("LINESTRING(0 0, 0 -10)");
        pat_ = GEOSRelateBoundaryNodeRule(geom1_, geom2_, GEOSRELATE_BNR_MOD2);
	ensure_equals(std::string(pat_), std::string("F01FFF102"));
    }
Ejemplo n.º 3
0
void object::test<2>
()
{
    numcalls = 0;

    initGEOS(notice, notice);

    GEOS_interruptRegisterCallback(countCalls);

    ensure_equals(numcalls, 0);

    GEOSGeometry* geom1 = GEOSGeomFromWKT("LINESTRING(0 0, 1 1, 2 2, 4 4)");
    GEOSGeometry* geom2 = GEOSGeomFromWKT("LINESTRING(0 0, 1 1.01, 4 4.001)");

    ensure("GEOSGeomFromWKT failed", nullptr != geom1);

    GEOSGeometry* geom3 = GEOSSnap(geom1, geom2, 0.1);

    ensure("GEOSSnap failed", nullptr != geom3);

    ensure("interrupt callback never called", numcalls > 0);

    GEOSGeom_destroy(geom1);
    GEOSGeom_destroy(geom2);
    GEOSGeom_destroy(geom3);

    GEOS_interruptRegisterCallback(nullptr); /* unregister */

    finishGEOS();
}
    void object::test<7>()
    {
        geom1_ = GEOSGeomFromWKT("MULTILINESTRING((0 0, 10 0),(10 0, 10 10))");
        geom2_ = GEOSGeomFromWKT("LINESTRING(10 0, 10 -10)");
        pat_ = GEOSRelateBoundaryNodeRule(geom1_, geom2_,
		GEOSRELATE_BNR_MONOVALENT_ENDPOINT);
	ensure_equals(std::string(pat_), std::string("F01FF0102"));
    }
Ejemplo n.º 5
0
    void object::test<1>()
    {
        geom1_ = GEOSGeomFromWKT("POINT(10 10)");
        geom2_ = GEOSGeomFromWKT("POINT(3 6)");

        double dist;
        int ret = GEOSDistance(geom1_, geom2_, &dist);

        ensure_equals(ret, 1);
        ensure_distance(dist, 8.06225774829855, 1e-12);
    }
Ejemplo n.º 6
0
    void object::test<1>()
    {
        geom1_ = GEOSGeomFromWKT("POLYGON EMPTY");
        geom2_ = GEOSGeomFromWKT("POLYGON EMPTY");

        ensure( 0 != geom1_ );
        ensure( 0 != geom2_ );

        GEOSCoordSequence *coords_;
        coords_ = GEOSNearestPoints(geom1_, geom2_);

        ensure( 0 == coords_ );
    }
Ejemplo n.º 7
0
void object::test<4>
()
{
    geom1_ = GEOSGeomFromWKT("LINESTRING(0 0, 10 10)");
    geom2_ = GEOSGeomFromWKT("LINESTRING(0 10, 10 0)");
    prepGeom1_ = GEOSPrepare(geom1_);

    ensure(nullptr != prepGeom1_);

    int ret = GEOSPreparedIntersects(prepGeom1_, geom2_);
    ensure_equals(ret, 1);

}
Ejemplo n.º 8
0
void object::test<2>
()
{
    geom1_ = GEOSGeomFromWKT("POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))");
    geom2_ = GEOSGeomFromWKT("POLYGON((2 2, 2 3, 3 3, 3 2, 2 2))");
    prepGeom1_ = GEOSPrepare(geom1_);

    ensure(nullptr != prepGeom1_);

    int ret = GEOSPreparedContainsProperly(prepGeom1_, geom2_);
    ensure_equals(ret, 1);

}
Ejemplo n.º 9
0
void object::test<6>
()
{
    geom1_ = GEOSGeomFromWKT("POLYGON((0 0, 0 10, 10 11, 10 0, 0 0))");
    geom2_ = GEOSGeomFromWKT("POLYGON((0 0, 2 0, 2 2, 0 2, 0 0))");
    prepGeom1_ = GEOSPrepare(geom1_);

    ensure(nullptr != prepGeom1_);

    int ret = GEOSPreparedContains(prepGeom1_, geom2_);
    ensure_equals(ret, 1);

}
    void object::test<1>()
    {
        input_ = GEOSGeomFromWKT("MULTIPOINT (130 240, 130 240, 130 240, 570 240, 570 240, 570 240, 650 240)");
        ensure( 0 != input_ );

        expected_ = GEOSGeomFromWKT("LINESTRING (130 240, 650 240, 130 240)");   
        ensure( 0 != expected_ );

        GEOSGeometry* output = GEOSConvexHull(input_);
        ensure( 0 != output );
        ensure( 0 == GEOSisEmpty(output) );
        // TODO
        //ensure( 0 != GEOSEquals(output, expected_));
    }
Ejemplo n.º 11
0
void object::test<1>
()
{
    numcalls = 0;

    initGEOS(notice, notice);

    GEOS_interruptRegisterCallback(countCalls);

    ensure_equals(numcalls, 0);

    GEOSGeometry* geom1 = GEOSGeomFromWKT("LINESTRING(0 0, 1 0)");

    ensure("GEOSGeomFromWKT failed", nullptr != geom1);

    GEOSGeometry* geom2 = GEOSBuffer(geom1, 1, 8);

    ensure("GEOSBufferWithStyle failed", nullptr != geom2);

    ensure("interrupt callback never called", numcalls > 0);

    GEOSGeom_destroy(geom1);
    GEOSGeom_destroy(geom2);

    GEOS_interruptRegisterCallback(nullptr); /* unregister */


    finishGEOS();
}
Ejemplo n.º 12
0
    void object::test<7>()
    {
        std::string wkt0("LINESTRING ("
            "665.7317504882812500 133.0762634277343700,"
            "1774.4752197265625000 19.9391822814941410,"
            "756.2413940429687500 466.8306579589843700,"
            "626.1337890625000000 1898.0147705078125000,"
            "433.8007202148437500 404.6052856445312500)");
        
        geom1_ = GEOSGeomFromWKT(wkt0.c_str());
        ensure( 0 != geom1_ );

        double width = 57.164000837203;

        // left-sided
        {
            geom2_ = GEOSOffsetCurve(geom1_, width, 8, GEOSBUF_JOIN_MITRE, 5.57);
            ensure( 0 != geom2_ );
            // likely, 5 >= 5
            ensure(GEOSGeomGetNumPoints(geom2_) >= GEOSGeomGetNumPoints(geom1_));
            wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
            //ensure_equals(std::string(wkt_), ...);
        }

        // right-sided
        {
            width = -width;
            geom2_ = GEOSOffsetCurve(geom1_, width, 8, GEOSBUF_JOIN_MITRE, 5.57);
            ensure( 0 != geom2_ );
            // likely, 5 >= 7
            ensure(GEOSGeomGetNumPoints(geom2_) >= GEOSGeomGetNumPoints(geom1_));
            wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
            //ensure_equals(std::string(wkt_), ...);
        }
    }
 /// Polygon fully within rectangle
 template<> template<> void object::test<12>()
 {
   const char *wkt = "POLYGON((1 1, 1 30, 30 30, 30 1, 1 1),(10 10, 20 10, 20 20, 10 20, 10 10))";
   geom1_ = GEOSGeomFromWKT(wkt);
   geom2_ = GEOSClipByRect(geom1_, 0, 0, 40, 40);
   isEqual(geom2_, wkt);
 }
Ejemplo n.º 14
0
    void object::test<3>()
    {
        geom1_ = GEOSGeomFromWKT("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))");
        geom2_ = GEOSGeomFromWKT("POLYGON((1 1,1 2,2 2,2 1,1 1))");

        ensure( nullptr != geom1_ );
        ensure( nullptr != geom2_ );

        char const r1 = GEOSWithin(geom1_, geom2_);

        ensure_equals(int(r1), 0);

        char const r2 = GEOSWithin(geom2_, geom1_);

        ensure_equals(int(r2), 1);
    }
Ejemplo n.º 15
0
    void object::test<1>()
    {
        geom1_ = GEOSGeomFromWKT("POLYGON EMPTY");
        geom2_ = GEOSGeomFromWKT("POLYGON EMPTY");

        ensure( nullptr != geom1_ );
        ensure( nullptr != geom2_ );

        char const r1 = GEOSWithin(geom1_, geom2_);

        ensure_equals(r1, 0);

        char const r2 = GEOSWithin(geom2_, geom1_);

        ensure_equals(r2, 0);
    }
Ejemplo n.º 16
0
    void object::test<2>()
    {
        geom1_ = GEOSGeomFromWKT("POLYGON((1 1,1 5,5 5,5 1,1 1))");
        geom2_ = GEOSGeomFromWKT("POINT(2 2)");

        ensure( nullptr != geom1_ );
        ensure( nullptr != geom2_ );

        char const r1 = GEOSWithin(geom1_, geom2_);

        ensure_equals(int(r1), 0);

        char const r2 = GEOSWithin(geom2_, geom1_);

        ensure_equals(int(r2), 1);
    }
 /// Polygon overlapping rectangle
 template<> template<> void object::test<13>()
 {
   const char *wkt = "POLYGON((0 0, 0 30, 30 30, 30 0, 0 0),(10 10, 20 10, 20 20, 10 20, 10 10))";
   geom1_ = GEOSGeomFromWKT(wkt);
   geom2_ = GEOSClipByRect(geom1_, 5, 5, 15, 15);
   isEqual(geom2_, "POLYGON ((5 5, 5 15, 10 15, 10 10, 15 10, 15 5, 5 5))");
 }
Ejemplo n.º 18
0
    void object::test<1>()
    {
        geom1_ = GEOSGeomFromWKT("POLYGON EMPTY");
        geom2_ = GEOSGeomFromWKT("POLYGON EMPTY");

        ensure( 0 != geom1_ );
        ensure( 0 != geom2_ );

        char const r1 = GEOSIntersects(geom1_, geom2_);

        ensure_equals(r1, 0);

        char const r2 = GEOSIntersects(geom2_, geom1_);

        ensure_equals(r2, 0);
    }
    void object::test<1>()
    {
        const int size = 2;
        GEOSGeometry* geoms[size] = { 0 };

        geoms[0] = GEOSGeomFromWKT("LINESTRING(1 3, 3 3, 3 1, 1 1, 1 3)");
        geoms[1] = GEOSGeomFromWKT("LINESTRING(1 3, 3 3, 3 1, 1 1, 1 3)");

        GEOSGeometry* g = GEOSPolygonizer_getCutEdges(geoms, size);

        ensure(0 != g);
        ensure_equals(GEOSGetNumGeometries(g), size);

        GEOSGeom_destroy(g);
        GEOSGeom_destroy(geoms[0]);
        GEOSGeom_destroy(geoms[1]);
    }
Ejemplo n.º 20
0
void object::test<1>
()
{
    geom1_ = GEOSGeomFromWKT("POLYGON EMPTY");
    prepGeom1_ = GEOSPrepare(geom1_);

    ensure(nullptr != prepGeom1_);

}
Ejemplo n.º 21
0
void object::test<1>()
{
    geom1_ = GEOSGeomFromWKT("POLYGON EMPTY");

    ensure ( 0 != GEOSisEmpty(geom1_) );

    geom2_ = GEOSSimplify(geom1_, 43.2);

    ensure ( 0 != GEOSisEmpty(geom2_) );
}
Ejemplo n.º 22
0
    void object::test<2>()
    {
        geom1_ = GEOSGeomFromWKT("POINT (6 3)");
        ensure( 0 != geom1_ );

        geom2_ = GEOSUnaryUnion(geom1_);
        ensure( 0 != geom2_ );

        ensure_equals(toWKT(geom2_), std::string("POINT (6 3)"));
    }
Ejemplo n.º 23
0
    void object::test<1>()
    {
        geom1_ = GEOSGeomFromWKT("POINT EMPTY");
        ensure( 0 != geom1_ );

        geom2_ = GEOSUnaryUnion(geom1_);
        ensure( 0 != geom2_ );

        ensure_equals(toWKT(geom2_), std::string("GEOMETRYCOLLECTION EMPTY"));
    }
Ejemplo n.º 24
0
    void object::test<5>()
    {
        geom1_ = GEOSGeomFromWKT("GEOMETRYCOLLECTION (POINT(4 5), MULTIPOINT(6 7, 6 5, 6 7), LINESTRING(0 5, 10 5), LINESTRING(4 -10, 4 10))");
        ensure( 0 != geom1_ );

        geom2_ = GEOSUnaryUnion(geom1_);
        ensure( 0 != geom2_ );

        ensure_equals(toWKT(geom2_), std::string("GEOMETRYCOLLECTION (POINT (6 7), LINESTRING (4 -10, 4 5), LINESTRING (4 5, 4 10), LINESTRING (0 5, 4 5), LINESTRING (4 5, 10 5))"));
    }
Ejemplo n.º 25
0
    void object::test<1>()
    {
	    GEOSGeometry* geom1 = GEOSGeomFromWKT("POLYGON EMPTY");

		ensure ( 0 != GEOSisEmpty(geom1) );

		GEOSGeometry* geom2 = GEOSSimplify(geom1, 43.2);

		ensure ( 0 != GEOSisEmpty(geom2) );
    }
Ejemplo n.º 26
0
    void object::test<4>()
    {
        geom1_ = GEOSGeomFromWKT("MULTIPOINT (4 5, 6 7, 4 5, 6 5, 6 7)");
        ensure( 0 != geom1_ );

        geom2_ = GEOSUnaryUnion(geom1_);
        ensure( 0 != geom2_ );

        ensure_equals(toWKT(geom2_), std::string("MULTIPOINT (4 5, 6 5, 6 7)"));
    }
Ejemplo n.º 27
0
        void test_wkt(std::string const& wkt)
        {
            geom1_ = GEOSGeomFromWKT(wkt.c_str());
            ensure ( 0 != geom1_ );

            char* wkt_c = GEOSGeomToWKT(geom1_);
            std::string out(wkt_c); 
        free(wkt_c);

            ensure_equals(out, wkt);
        }
Ejemplo n.º 28
0
        void test_writer_wkt(GEOSWKTWriter *writer, std::string const& wkt)
        {
            geom1_ = GEOSGeomFromWKT(wkt.c_str());
            ensure ( 0 != geom1_ );

            char* wkt_c = GEOSWKTWriter_write(writer,geom1_);
            std::string out(wkt_c); 
            free(wkt_c);

            ensure_equals(out, wkt);
        }
Ejemplo n.º 29
0
        void test_wkt(std::string const& wkt, std::string::size_type n)
        {
            geom1_ = GEOSGeomFromWKT(wkt.c_str());
            ensure ( 0 != geom1_ );

            char* wkt_c = GEOSGeomToWKT(geom1_);
            std::string out(wkt_c); 
        free(wkt_c);

            ensure_equals(out.substr(0, n), wkt.substr(0, n));
        }
Ejemplo n.º 30
0
    void object::test<8>()
    {
        geom1_ = GEOSGeomFromWKT("GEOMETRYCOLLECTION (MULTILINESTRING((5 7, 12 7), (4 5, 6 5), (5.5 7.5, 6.5 7.5)), POLYGON((0 0, 10 0, 10 10, 0 10, 0 0),(5 6, 7 6, 7 8, 5 8, 5 6)), MULTIPOINT(6 6.5, 6 1, 12 2, 6 1))");
        ensure( 0 != geom1_ );

        geom2_ = GEOSUnaryUnion(geom1_);
        ensure( 0 != geom2_ );

        ensure_equals(toWKT(geom2_), std::string(
"GEOMETRYCOLLECTION (POINT (6 6.5), POINT (12 2), LINESTRING (5 7, 7 7), LINESTRING (10 7, 12 7), LINESTRING (5.5 7.5, 6.5 7.5), POLYGON ((10 7, 10 0, 0 0, 0 10, 10 10, 10 7), (5 6, 7 6, 7 7, 7 8, 5 8, 5 7, 5 6)))"
));
    }