Hi Giorgino,this is not a complete answer (I may look at question ii) later), but I think I may have the answer for question i):Note, how the postgis-doc you linked specifies "By that we mean they intersect, but one does not completely contain another." I think, line_test_1 completely contains line_test_2 so "false" should be the expected result of the overlaps-check. If you want "true" you may want to look for another geometric relation.Kind regardsTinko_______________________________________________Am Mo., 15. Juni 2020 um 09:23 Uhr schrieb Giorgino R via Geometry <geometry@lists.boost.org>:Hi there,_______________________________________________I have two questions for boost::geometry, any help will be much appreciated:i) I am trying to use overlap function for two linestrings (https://postgis.net/docs/ST_Overlaps.html); however, it looks like I am doing something wrong (?) .using point_2d = bg::model::point<double, 2, bg::cs::cartesian>;using linestring_2d = bg::model::linestring<point_2d>;// overlaps
linestring_2d line_test_1({ point_2d(0.0, 0.0), point_2d(2.0, 0.0) });
linestring_2d line_test_2({ point_2d(0.0, 0.0), point_2d(1.0, 0.0) });
bool res = bg::overlaps(line_test1, line_test2);This results to false. Should I use a specific strategy? I checked also tests and I saw that you do test overlap for linestrings.ii) I have a structure that contains a linestring. I want to use an unordered set for storing unique objects with respect to their geometry (linestring). Therefore, I will need to write hash functions as below:struct Object_hash
{
std::size_t operator()(const Object& obj) const
{
Linestring<Point> linestring = obj.get_linestring();
std::size_t hash = 0;
for (auto iter=linestring.cbegin(); iter!=linestring.cend(); ++iter)
{
boost::hash_combine(hash, iter->x1());
boost::hash_combine(hash, iter->x2());
}
return hash;
}
};struct Object_compare
{
bool operator()(const Object& obj1, const Object & obj2) const
{
return boost::geometry::equals(obj1.get_linestring(), obj2.get_linestring());
}
};As expected, the above is valid for linestrings with the same direction of their points. If one linestring is reversed this off course will not be valid. Is there any way that I can find a better hashing function? Is there any invariant field (for two spatial equaly linestrings) that I could use to create hash key?Many thanks in adavnce,BWG
Geometry mailing list
Geometry@lists.boost.org
https://lists.boost.org/mailman/listinfo.cgi/geometry
Geometry mailing list
Geometry@lists.boost.org
https://lists.boost.org/mailman/listinfo.cgi/geometry