Exemplo n.º 1
0
Polyline::Polyline(const Polyline& ply) : GeoObject(), _ply_pnts(ply._ply_pnts)
{
	for (size_t k(0); k < ply.getNumberOfPoints(); ++k)
		_ply_pnt_ids.push_back(ply.getPointID(k));

	if (ply.getNumberOfPoints() > 0)
		for (size_t k(0); k < ply.getNumberOfPoints(); ++k)
			_length.push_back(ply.getLength(k));
}
Exemplo n.º 2
0
bool operator==(Polyline const& lhs, Polyline const& rhs)
{
	if (lhs.getNumberOfPoints() != rhs.getNumberOfPoints())
		return false;

	const size_t n(lhs.getNumberOfPoints());
	for (size_t k(0); k < n; k++)
	{
		if (lhs.getPointID(k) != rhs.getPointID(k))
			return false;
	}

	return true;
}
Exemplo n.º 3
0
bool isLineSegmentIntersecting(const Polyline& ply, GEOLIB::Point const& s0, GEOLIB::Point const& s1)
{
	const size_t n(ply.getNumberOfPoints() - 1);
	bool intersect(false);
	GEOLIB::Point intersection_pnt;
	for (size_t k(0); k < n && !intersect; k++)
	{
		intersect = MathLib::lineSegmentIntersect(*(ply.getPoint(k)), *(ply.getPoint(k + 1)), s0, s1, intersection_pnt);
	}
	return intersect;
}
Exemplo n.º 4
0
bool Polygon::isPartOfPolylineInPolygon(const Polyline& ply) const
{
    const std::size_t ply_size (ply.getNumberOfPoints());
    // check points
    for (std::size_t k(0); k < ply_size; k++) {
        if (isPntInPolygon (*(ply.getPoint(k)))) {
            return true;
        }
    }

    GeoLib::Point s;
    for (auto polygon_seg : *this) {
        for (auto polyline_seg : ply) {
            if (GeoLib::lineSegmentIntersect(polyline_seg, polygon_seg, s)) {
                return true;
            }
        }
    }

    return false;
}
Exemplo n.º 5
0
bool containsEdge(const Polyline& ply, size_t id0, size_t id1)
{
	if (id0 == id1)
	{
		std::cerr << "no valid edge id0 == id1 == " << id0 << "\n";
		return false;
	}
	if (id0 > id1)
		BASELIB::swap(id0, id1);
	const size_t n(ply.getNumberOfPoints() - 1);
	for (size_t k(0); k < n; k++)
	{
		size_t ply_pnt0(ply.getPointID(k));
		size_t ply_pnt1(ply.getPointID(k + 1));
		if (ply_pnt0 > ply_pnt1)
			BASELIB::swap(ply_pnt0, ply_pnt1);
		if (ply_pnt0 == id0 && ply_pnt1 == id1)
			return true;
	}
	return false;
}