Skip to content

Commit

Permalink
Change API on RelateNG::relate() to always return IM matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
pramsey committed Aug 12, 2024
1 parent fe530fa commit ce25994
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion capi/geos_ts_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3755,7 +3755,7 @@ extern "C" {
const geos::geom::prep::PreparedGeometry* pg, const Geometry* g)
{
return execute(extHandle, [&]() -> char * {
return gstrdup(pg->relate(g));
return gstrdup(pg->relate(g)->toString());
});
}

Expand Down
2 changes: 1 addition & 1 deletion include/geos/geom/prep/BasicPreparedGeometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ class BasicPreparedGeometry: public PreparedGeometry {
/**
* Default implementation.
*/
std::string relate(const geom::Geometry* g) const override;
std::unique_ptr<IntersectionMatrix> relate(const geom::Geometry* g) const override;

/**
* Default implementation.
Expand Down
3 changes: 2 additions & 1 deletion include/geos/geom/prep/PreparedGeometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ namespace geos {
class Geometry;
class Coordinate;
class CoordinateSequence;
class IntersectionMatrix;
}
}

Expand Down Expand Up @@ -235,7 +236,7 @@ class GEOS_DLL PreparedGeometry {
* @param geom the Geometry to test the
* @return the DE9IM matrix
*/
virtual std::string relate(const geom::Geometry* g) const = 0;
virtual std::unique_ptr<IntersectionMatrix> relate(const geom::Geometry* g) const = 0;

/** \brief
* Compares the prepared geometry to the given geometry
Expand Down
2 changes: 1 addition & 1 deletion include/geos/operation/relateng/RelateNG.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ class GEOS_DLL RelateNG {
bool coveredBy(const Geometry* a);
bool equalsTopo(const Geometry* a);
bool relate(const Geometry* a, const std::string& pat);
std::string relate(const Geometry* a);
std::unique_ptr<IntersectionMatrix> relate(const Geometry* a);

};

Expand Down
3 changes: 2 additions & 1 deletion src/geom/prep/BasicPreparedGeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include <geos/geom/prep/BasicPreparedGeometry.h>
#include <geos/geom/Coordinate.h>
#include <geos/geom/IntersectionMatrix.h>
#include <geos/algorithm/PointLocator.h>
#include <geos/geom/util/ComponentCoordinateExtracter.h>
#include <geos/operation/distance/DistanceOp.h>
Expand Down Expand Up @@ -155,7 +156,7 @@ BasicPreparedGeometry::relate(const geom::Geometry* g, const std::string& pat) c
return getRelateNG()->relate(g, pat);
}

std::string
std::unique_ptr<IntersectionMatrix>
BasicPreparedGeometry::relate(const geom::Geometry* g) const
{
return getRelateNG()->relate(g);
Expand Down
4 changes: 2 additions & 2 deletions src/operation/relateng/RelateNG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,10 @@ RelateNG::relate(const Geometry* b, const std::string& imPattern)
}

/* public */
std::string
std::unique_ptr<IntersectionMatrix>
RelateNG::relate(const Geometry* b)
{
return evaluate(b)->toString();
return evaluate(b);
}

/************************************************************************/
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/operation/relateng/RelateNGTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct test_relateng_support {
ensure_equals("preparedContains", prep_a->contains(b), a->contains(b));
ensure_equals("preparedCrosses", prep_a->crosses(b), a->crosses(b));
ensure_equals("preparedTouches", prep_a->touches(b), a->touches(b));
ensure_equals("preparedRelate", prep_a->relate(b), a->relate(b)->toString());
ensure_equals("preparedRelate", prep_a->relate(b)->toString(), a->relate(b)->toString());
}

void checkIntersectsDisjoint(const std::string& wkta, const std::string& wktb, bool expectedValue)
Expand Down

0 comments on commit ce25994

Please sign in to comment.