move segment y_order sort to header that can be used by each renderer
This commit is contained in:
parent
b3c01a5b59
commit
14068cad23
3 changed files with 47 additions and 19 deletions
44
include/mapnik/segment.hpp
Normal file
44
include/mapnik/segment.hpp
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*****************************************************************************
|
||||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2011 Artem Pavlenko
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
//$Id$
|
||||
|
||||
#ifndef MAPNIK_SEGMENT_HPP
|
||||
#define MAPNIK_SEGMENT_HPP
|
||||
|
||||
#include <boost/tuple/tuple.hpp>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
|
||||
typedef boost::tuple<double,double,double,double> segment_t;
|
||||
|
||||
static bool y_order(segment_t const& first,segment_t const& second)
|
||||
{
|
||||
double miny0 = std::min(first.get<1>(),first.get<3>());
|
||||
double miny1 = std::min(second.get<1>(),second.get<3>());
|
||||
return miny0 > miny1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //MAPNIK_SEGMENT_HPP
|
|
@ -24,9 +24,9 @@
|
|||
// mapnik
|
||||
#include <mapnik/agg_renderer.hpp>
|
||||
#include <mapnik/agg_rasterizer.hpp>
|
||||
#include <mapnik/segment.hpp>
|
||||
|
||||
// boost
|
||||
#include <boost/tuple/tuple.hpp>
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
||||
// agg
|
||||
|
@ -41,14 +41,6 @@
|
|||
namespace mapnik
|
||||
{
|
||||
|
||||
typedef boost::tuple<double,double,double,double> segment_t;
|
||||
bool y_order(segment_t const& first,segment_t const& second)
|
||||
{
|
||||
double miny0 = std::min(first.get<1>(),first.get<3>());
|
||||
double miny1 = std::min(second.get<1>(),second.get<3>());
|
||||
return miny0 > miny1;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void agg_renderer<T>::process(building_symbolizer const& sym,
|
||||
Feature const& feature,
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include <mapnik/marker_cache.hpp>
|
||||
#include <mapnik/svg/svg_path_adapter.hpp>
|
||||
#include <mapnik/svg/svg_path_attributes.hpp>
|
||||
#include <mapnik/segment.hpp>
|
||||
|
||||
// cairo
|
||||
#include <cairomm/context.h>
|
||||
|
@ -43,7 +44,6 @@
|
|||
|
||||
// boost
|
||||
#include <boost/utility.hpp>
|
||||
#include <boost/tuple/tuple.hpp>
|
||||
|
||||
// stl
|
||||
#ifdef MAPNIK_DEBUG
|
||||
|
@ -762,14 +762,6 @@ void cairo_renderer_base::process(polygon_symbolizer const& sym,
|
|||
}
|
||||
}
|
||||
|
||||
typedef boost::tuple<double,double,double,double> segment_t;
|
||||
bool cairo_y_order(segment_t const& first,segment_t const& second)
|
||||
{
|
||||
double miny0 = std::min(first.get<1>(), first.get<3>());
|
||||
double miny1 = std::min(second.get<1>(), second.get<3>());
|
||||
return miny0 > miny1;
|
||||
}
|
||||
|
||||
void cairo_renderer_base::process(building_symbolizer const& sym,
|
||||
Feature const& feature,
|
||||
proj_transform const& prj_trans)
|
||||
|
@ -820,7 +812,7 @@ void cairo_renderer_base::process(building_symbolizer const& sym,
|
|||
y0 = y;
|
||||
}
|
||||
|
||||
std::sort(face_segments.begin(), face_segments.end(), cairo_y_order);
|
||||
std::sort(face_segments.begin(), face_segments.end(), y_order);
|
||||
std::deque<segment_t>::const_iterator itr = face_segments.begin();
|
||||
for (; itr != face_segments.end(); ++itr)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue