Merge branch 'mapnik-geometry' into mapnik-geometry-template

This commit is contained in:
Blake Thompson 2015-04-15 15:16:47 -05:00
commit 7a50bb5214
7 changed files with 106 additions and 26 deletions

View File

@ -1,8 +1,8 @@
/*******************************************************************************
* *
* Author : Angus Johnson *
* Version : 6.2.8 *
* Date : 10 February 2015 *
* Version : 6.2.9 *
* Date : 16 February 2015 *
* Website : http://www.angusj.com *
* Copyright : Angus Johnson 2010-2015 *
* *
@ -170,18 +170,18 @@ private:
friend class MAPNIK_DECL Clipper; //to access AllNodes
};
bool Orientation(const Path &poly);
double Area(const Path &poly);
int PointInPolygon(const IntPoint &pt, const Path &path);
MAPNIK_DECL bool Orientation(const Path &poly);
MAPNIK_DECL double Area(const Path &poly);
MAPNIK_DECL int PointInPolygon(const IntPoint &pt, const Path &path);
void SimplifyPolygon(const Path &in_poly, Paths &out_polys, PolyFillType fillType = pftEvenOdd);
void SimplifyPolygons(const Paths &in_polys, Paths &out_polys, PolyFillType fillType = pftEvenOdd);
void SimplifyPolygons(Paths &polys, PolyFillType fillType = pftEvenOdd);
MAPNIK_DECL void SimplifyPolygon(const Path &in_poly, Paths &out_polys, PolyFillType fillType = pftEvenOdd);
MAPNIK_DECL void SimplifyPolygons(const Paths &in_polys, Paths &out_polys, PolyFillType fillType = pftEvenOdd);
MAPNIK_DECL void SimplifyPolygons(Paths &polys, PolyFillType fillType = pftEvenOdd);
void CleanPolygon(const Path& in_poly, Path& out_poly, double distance = 1.415);
void CleanPolygon(Path& poly, double distance = 1.415);
void CleanPolygons(const Paths& in_polys, Paths& out_polys, double distance = 1.415);
void CleanPolygons(Paths& polys, double distance = 1.415);
MAPNIK_DECL void CleanPolygon(const Path& in_poly, Path& out_poly, double distance = 1.415);
MAPNIK_DECL void CleanPolygon(Path& poly, double distance = 1.415);
MAPNIK_DECL void CleanPolygons(const Paths& in_polys, Paths& out_polys, double distance = 1.415);
MAPNIK_DECL void CleanPolygons(Paths& polys, double distance = 1.415);
void MinkowskiSum(const Path& pattern, const Path& path, Paths& solution, bool pathIsClosed);
void MinkowskiSum(const Path& pattern, const Paths& paths, Paths& solution, bool pathIsClosed);

View File

@ -1,8 +1,8 @@
/*******************************************************************************
* *
* Author : Angus Johnson *
* Version : 6.2.8 *
* Date : 10 February 2015 *
* Version : 6.2.9 *
* Date : 16 February 2015 *
* Website : http://www.angusj.com *
* Copyright : Angus Johnson 2010-2015 *
* *
@ -969,16 +969,13 @@ TEdge* ClipperBase::ProcessBound(TEdge* E, bool NextIsForward)
EStart = E->Prev;
else
EStart = E->Next;
if (EStart->OutIdx != Skip)
{
if (IsHorizontal(*EStart)) //ie an adjoining horizontal skip edge
if (IsHorizontal(*EStart)) //ie an adjoining horizontal skip edge
{
if (EStart->Bot.X != E->Bot.X && EStart->Top.X != E->Bot.X)
ReverseHorizontal(*E);
}
else if (EStart->Bot.X != E->Bot.X)
ReverseHorizontal(*E);
}
}
EStart = E;

View File

@ -57,8 +57,7 @@ struct unicode_string : qi::grammar<Iterator, std::string()>
struct push_utf8
{
template <typename S, typename C>
struct result { typedef void type; };
using result_type = void;
void operator()(std::string& utf8, uchar code_point) const
{
@ -71,8 +70,7 @@ struct push_utf8
struct push_esc
{
template <typename S, typename C>
struct result { typedef void type; };
using result_type = void;
void operator()(std::string& utf8, uchar c) const
{

View File

@ -171,9 +171,9 @@ struct render_marker_symbolizer_visitor
if (clip) // optional clip (default: true)
{
geometry::geometry_types type = geometry::geometry_type(feature_.get_geometry());
if (type == geometry::geometry_types::Polygon)
if (type == geometry::geometry_types::Polygon || type == geometry::geometry_types::MultiPolygon)
converter.template set<clip_poly_tag>();
else if (type == geometry::geometry_types::LineString)
else if (type == geometry::geometry_types::LineString || type == geometry::geometry_types::MultiLineString)
converter.template set<clip_line_tag>();
}

View File

@ -244,7 +244,8 @@ private:
// We eliminated the previous point because it was too close, but
// we have to output it now anyway, since this is the end of the
// vertex stream. Make sure that we output SEG_CLOSE in the next call.
vtx = last;
vtx.x = start_vertex_.x;
vtx.y = start_vertex_.y;
status_ = closing;
}
break;

View File

@ -181,6 +181,57 @@ private:
mutable bool start_loop_;
};
struct ring_vertex_adapter
{
using value_type = typename point::value_type;
ring_vertex_adapter(linear_ring const& ring)
: ring_(ring),
current_index_(0),
end_index_(ring_.size()),
start_loop_(true) {}
void rewind(unsigned) const
{
current_index_ = 0;
end_index_ = ring_.size();
start_loop_ = true;
}
unsigned vertex(value_type * x, value_type * y) const
{
if (current_index_ < end_index_)
{
auto const& coord = ring_[current_index_++];
*x = coord.x;
*y = coord.y;
if (start_loop_)
{
start_loop_= false;
return mapnik::SEG_MOVETO;
}
if (current_index_ == end_index_)
{
*x = 0;
*y = 0;
return mapnik::SEG_CLOSE;
}
return mapnik::SEG_LINETO;
}
return mapnik::SEG_END;
}
inline geometry_types type () const
{
return geometry_types::Polygon;
}
private:
linear_ring const& ring_;
mutable std::size_t current_index_;
mutable std::size_t end_index_;
mutable bool start_loop_;
};
template <typename T>
struct vertex_adapter_traits {};

View File

@ -98,7 +98,40 @@ SECTION("polygon with hole") {
REQUIRE( x == 0 );
REQUIRE( y == 0 );
// first hole
// exterior ring via ring_vertex_adapter
mapnik::geometry::ring_vertex_adapter va2(g.exterior_ring);
cmd = va2.vertex(&x,&y);
REQUIRE( cmd == mapnik::SEG_MOVETO );
REQUIRE( x == 0 );
REQUIRE( y == 0 );
cmd = va2.vertex(&x,&y);
REQUIRE( cmd == mapnik::SEG_LINETO );
REQUIRE( x == -10 );
REQUIRE( y == 0 );
cmd = va2.vertex(&x,&y);
REQUIRE( cmd == mapnik::SEG_LINETO );
REQUIRE( x == -10 );
REQUIRE( y == 10 );
cmd = va2.vertex(&x,&y);
REQUIRE( cmd == mapnik::SEG_LINETO );
REQUIRE( x == 0 );
REQUIRE( y == 10 );
cmd = va2.vertex(&x,&y);
REQUIRE( cmd == mapnik::SEG_CLOSE );
REQUIRE( x == 0 );
REQUIRE( y == 0 );
// since ring adapter is only for exterior, next should be END
cmd = va2.vertex(&x,&y);
REQUIRE( cmd == mapnik::SEG_END );
REQUIRE( x == 0 );
REQUIRE( y == 0 );
// first hole for polygon_adapter
cmd = va.vertex(&x,&y);
REQUIRE( cmd == mapnik::SEG_MOVETO );
REQUIRE( x == -7 );