Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

is_empty

Checks if a geometry is the empty set.

Synopsis

template<typename Geometry>
bool is_empty(Geometry const & geometry)

Parameters

Type

Concept

Name

Description

Geometry const &

Any type fulfilling a Geometry Concept

geometry

A model of the specified concept

Returns

Returns true if the geometry is the empty set

Header

Either

#include <boost/geometry.hpp>

Or

#include <boost/geometry/algorithms/is_empty.hpp>

Conformance

The function is_empty is not defined by OGC.

Supported geometries

Geometry

Status

Point

ok

Segment

ok

Box

ok

Linestring

ok

Ring

ok

Polygon

ok

MultiPoint

ok

MultiLinestring

ok

MultiPolygon

ok

Variant

ok

Complexity

Constant-time

Example

Check if a geometry is the empty set

#include <iostream>

#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point_xy.hpp>


int main()
{
    boost::geometry::model::multi_linestring
        <
            boost::geometry::model::linestring
                <
                    boost::geometry::model::d2::point_xy<double>
                >
        > mls;
    boost::geometry::read_wkt("MULTILINESTRING((0 0,0 10,10 0),(1 1,8 1,1 8))", mls);
    std::cout << "Is empty? " << (boost::geometry::is_empty(mls) ? "yes" : "no") << std::endl;
    boost::geometry::clear(mls);
    std::cout << "Is empty (after clearing)? " << (boost::geometry::is_empty(mls) ? "yes" : "no") << std::endl;
    return 0;
}

Output:

Is empty? no
Is empty (after clearing)? yes
See also

PrevUpHomeNext