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

PrevUpHomeNext
wkt

Main WKT-streaming function.

Synopsis

template<typename Geometry>
wkt_manipulator<Geometry> wkt(Geometry const & geometry)

Parameters

Type

Concept

Name

Description

Geometry const &

Any type fulfilling a Geometry Concept

geometry

A model of the specified concept

Header

Either

#include <boost/geometry.hpp>

Or

#include <boost/geometry/io/wkt/write.hpp>

Conformance

The function wkt implements function AsText from the OGC Simple Feature Specification.

[Note] Note

wkt is not named "AsText" or "as_text" because Boost.Geometry also supports other textformats (svg, dsv)

Example

Shows the usage of wkt

#include <iostream>

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

int main()
{
    namespace geom = boost::geometry;
    typedef geom::model::d2::point_xy<double> point_type;

    point_type point = geom::make<point_type>(3, 6);
    geom::model::polygon<point_type> polygon;
    geom::append(geom::exterior_ring(polygon), geom::make<point_type>(0, 0));
    geom::append(geom::exterior_ring(polygon), geom::make<point_type>(0, 4));
    geom::append(geom::exterior_ring(polygon), geom::make<point_type>(4, 4));
    geom::append(geom::exterior_ring(polygon), geom::make<point_type>(4, 0));
    geom::append(geom::exterior_ring(polygon), geom::make<point_type>(0, 0));

    std::cout << boost::geometry::wkt(point) << std::endl;
    std::cout << boost::geometry::wkt(polygon) << std::endl;

    return 0;
}

Output:

POINT(3 6)
POLYGON((0 0,0 4,4 4,4 0,0 0))
See also

PrevUpHomeNext