is_empty

| Home | Libraries | People | FAQ | More

#### 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 implements function IsEmpty from the OGC Simple Feature Specification.

###### Supported geometries

Geometry | Status
--- | ---
Point |
Segment |
Box |
Linestring |
Ring |
Polygon |
MultiPoint |
MultiLinestring |
MultiPolygon |
Variant |

###### 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

- num_points