本文整理汇总了C++中GeometryType::vertex方法的典型用法代码示例。如果您正苦于以下问题:C++ GeometryType::vertex方法的具体用法?C++ GeometryType::vertex怎么用?C++ GeometryType::vertex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GeometryType
的用法示例。
在下文中一共展示了GeometryType::vertex方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: to_polygon_wkb
wkb_buffer_ptr to_polygon_wkb( GeometryType const& g, wkbByteOrder byte_order)
{
unsigned num_points = g.size();
assert(num_points > 1);
using point_type = std::pair<double,double>;
using linear_ring = std::vector<point_type>;
boost::ptr_vector<linear_ring> rings;
double x = 0;
double y = 0;
std::size_t size = 1 + 4 + 4 ; // byteOrder + wkbType + numRings
for (unsigned i=0; i< num_points; ++i)
{
unsigned command = g.vertex(i,&x,&y);
if (command == SEG_MOVETO)
{
rings.push_back(new linear_ring); // start new loop
rings.back().push_back(std::make_pair(x,y));
size += 4; // num_points
size += 2 * 8; // point
}
else if (command == SEG_LINETO)
{
rings.back().push_back(std::make_pair(x,y));
size += 2 * 8; // point
}
}
unsigned num_rings = rings.size();
wkb_buffer_ptr wkb = std::make_unique<wkb_buffer>(size);
wkb_stream ss(wkb->buffer(), wkb->size());
ss.write(reinterpret_cast<char*>(&byte_order),1);
int type = static_cast<int>(mapnik::geometry_type::types::Polygon);
write(ss,type,4,byte_order);
write(ss,num_rings,4,byte_order);
for ( linear_ring const& ring : rings)
{
unsigned num_ring_points = ring.size();
write(ss,num_ring_points,4,byte_order);
for ( point_type const& pt : ring)
{
write(ss,pt.first,8,byte_order);
write(ss,pt.second,8,byte_order);
}
}
assert(ss.good());
return std::move(wkb);
}
示例2: to_polygon_wkb
wkb_buffer_ptr to_polygon_wkb( GeometryType const& g, wkbByteOrder byte_order)
{
unsigned num_points = g.size();
assert(num_points > 1);
typedef std::pair<double,double> point_type;
typedef std::vector<point_type> linear_ring;
boost::ptr_vector<linear_ring> rings;
double x = 0;
double y = 0;
std::size_t size = 1 + 4 + 4 ; // byteOrder + wkbType + numRings
for (unsigned i=0; i< num_points; ++i)
{
unsigned command = g.vertex(i,&x,&y);
if (command == SEG_MOVETO)
{
rings.push_back(new linear_ring); // start new loop
rings.back().push_back(std::make_pair(x,y));
size += 4; // num_points
size += 2 * 8; // point
}
else if (command == SEG_LINETO)
{
rings.back().push_back(std::make_pair(x,y));
size += 2 * 8; // point
}
}
unsigned num_rings = rings.size();
wkb_buffer_ptr wkb = boost::make_shared<wkb_buffer>(size);
boost::interprocess::bufferstream ss(wkb->buffer(), wkb->size(), std::ios::out | std::ios::binary);
ss.write(reinterpret_cast<char*>(&byte_order),1);
int type = static_cast<int>(mapnik::Polygon);
write(ss,type,4,byte_order);
write(ss,num_rings,4,byte_order);
BOOST_FOREACH ( linear_ring const& ring, rings)
{
unsigned num_ring_points = ring.size();
write(ss,num_ring_points,4,byte_order);
BOOST_FOREACH ( point_type const& pt, ring)
{
write(ss,pt.first,8,byte_order);
write(ss,pt.second,8,byte_order);
}
示例3: to_point_wkb
wkb_buffer_ptr to_point_wkb( GeometryType const& g, wkbByteOrder byte_order)
{
assert(g.size() == 1);
std::size_t size = 1 + 4 + 8*2 ; // byteOrder + wkbType + Point
wkb_buffer_ptr wkb = std::make_unique<wkb_buffer>(size);
wkb_stream ss(wkb->buffer(), wkb->size());
ss.write(reinterpret_cast<char*>(&byte_order),1);
int type = static_cast<int>(mapnik::geometry_type::types::Point);
write(ss,type,4,byte_order);
double x = 0;
double y = 0;
g.vertex(0,&x,&y);
write(ss,x,8,byte_order);
write(ss,y,8,byte_order);
assert(ss.good());
return std::move(wkb);
}
示例4: to_point_wkb
wkb_buffer_ptr to_point_wkb( GeometryType const& g, wkbByteOrder byte_order)
{
assert(g.size() == 1);
std::size_t size = 1 + 4 + 8*2 ; // byteOrder + wkbType + Point
wkb_buffer_ptr wkb = boost::make_shared<wkb_buffer>(size);
boost::interprocess::bufferstream ss(wkb->buffer(), wkb->size(), std::ios::out | std::ios::binary);
ss.write(reinterpret_cast<char*>(&byte_order),1);
int type = static_cast<int>(mapnik::Point);
write(ss,type,4,byte_order);
double x = 0;
double y = 0;
g.vertex(0,&x,&y);
write(ss,x,8,byte_order);
write(ss,y,8,byte_order);
assert(ss.good());
return wkb;
}
示例5: to_line_string_wkb
wkb_buffer_ptr to_line_string_wkb( GeometryType const& g, wkbByteOrder byte_order)
{
unsigned num_points = g.size();
assert(num_points > 1);
std::size_t size = 1 + 4 + 4 + 8*2*num_points ; // byteOrder + wkbType + numPoints + Point*numPoints
wkb_buffer_ptr wkb = std::make_unique<wkb_buffer>(size);
wkb_stream ss(wkb->buffer(), wkb->size());
ss.write(reinterpret_cast<char*>(&byte_order),1);
int type = static_cast<int>(mapnik::geometry_type::types::LineString);
write(ss,type,4,byte_order);
write(ss,num_points,4,byte_order);
double x = 0;
double y = 0;
for (unsigned i=0; i< num_points; ++i)
{
g.vertex(i,&x,&y);
write(ss,x,8,byte_order);
write(ss,y,8,byte_order);
}
assert(ss.good());
return std::move(wkb);
}