In most cases the documentation gives small examples of how to use the algorithms or classes. The point example is a slightly larger example giving an idea of how to use different algorithms from the library, related to points. It shows
- the usage of include files
- how to declare points, using different coordinate types
- how to construct points, specifying coordinates, initializing to zero or to infinite
- how to compare points to each other
- how points can be streamed as OGC text
- calculating the distance from point to point
#include <iostream>
#include <boost/geometry/geometry.hpp>
#include <boost/geometry/geometries/adapted/boost_polygon/point.hpp>
int main()
{
using namespace boost::geometry;
boost::tuple<double, double> pt3;
double pt4[2];
boost::array<double, 2> pt5;
boost::polygon::point_data<double> pt6;
point_2d pt7;
std::cout << "Distances: "
<< d1 << " and " << d2 << " and " << d3 << std::endl;
set<0>(p3, 1);
set<1>(p3, 1);
std::cout << get<0>(p2) << "," << get<1>(p2) << std::endl;
std::cout << p2.x() << "," << p2.y() << std::endl;
std::cout << pt3.get<0>() << "," << pt3.get<1>() << std::endl;
std::cout << dsv(pt3) << std::endl;
std::cout <<
wkt(p4) << (
equals(p4, p5) ?
" equals " :
" don't equals ") <<
wkt(p5) << std::endl;
return 0;
}