本文整理汇总了C++中PathType::type方法的典型用法代码示例。如果您正苦于以下问题:C++ PathType::type方法的具体用法?C++ PathType::type怎么用?C++ PathType::type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PathType
的用法示例。
在下文中一共展示了PathType::type方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: hit_test
bool hit_test(PathType & path, double x, double y, double tol)
{
bool inside=false;
double x0 = 0;
double y0 = 0;
double x1 = 0;
double y1 = 0;
double start_x = 0;
double start_y = 0;
path.rewind(0);
unsigned command = path.vertex(&x0, &y0);
if (command == SEG_END)
{
return false;
}
unsigned count = 0;
mapnik::geometry::geometry_types geom_type = static_cast<mapnik::geometry::geometry_types>(path.type());
while (SEG_END != (command = path.vertex(&x1, &y1)))
{
++count;
if (command == SEG_MOVETO)
{
x0 = x1;
y0 = y1;
start_x = x0;
start_y = y0;
continue;
}
else if (command == SEG_CLOSE)
{
x1 = start_x;
y1 = start_y;
}
switch(geom_type)
{
case mapnik::geometry::geometry_types::Polygon:
{
if ((((y1 <= y) && (y < y0)) ||
((y0 <= y) && (y < y1))) &&
(x < (x0 - x1) * (y - y1)/ (y0 - y1) + x1))
inside=!inside;
break;
}
case mapnik::geometry::geometry_types::LineString:
{
double distance = point_to_segment_distance(x,y,x0,y0,x1,y1);
if (distance < tol)
return true;
break;
}
default:
break;
}
x0 = x1;
y0 = y1;
}
// TODO - handle multi-point?
if (count == 0) // one vertex
{
return distance(x, y, x0, y0) <= tol;
}
return inside;
}