Skip to content

Commit

Permalink
Various small changes to the library, fixes to the geometry visual tests
Browse files Browse the repository at this point in the history
  • Loading branch information
flippmoke committed Dec 30, 2015
1 parent ebd6469 commit e6e85ce
Show file tree
Hide file tree
Showing 10 changed files with 466 additions and 91 deletions.
28 changes: 14 additions & 14 deletions src/vector_tile_geometry_decoder.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void decode_point(mapnik::geometry::geometry<typename T::value_type> & geom,
cmd = paths.point_next(x1, y1);
if (cmd == T::end)
{
geom = mapnik::geometry::geometry_empty();
geom = std::move(mapnik::geometry::geometry_empty());
return;
}
else if (bbox.intersects(x1,y1))
Expand Down Expand Up @@ -104,7 +104,7 @@ void decode_point(mapnik::geometry::geometry<typename T::value_type> & geom,
std::size_t num_points = mp.size();
if (num_points == 0)
{
geom = mapnik::geometry::geometry_empty();
geom = std::move(mapnik::geometry::geometry_empty());
}
else if (num_points == 1)
{
Expand Down Expand Up @@ -135,7 +135,7 @@ void decode_linestring(mapnik::geometry::geometry<typename T::value_type> & geom
cmd = paths.line_next(x0, y0, false);
if (cmd == T::end)
{
geom = mapnik::geometry::geometry_empty();
geom = std::move(mapnik::geometry::geometry_empty());
return;
}
else if (cmd != T::move_to)
Expand Down Expand Up @@ -223,7 +223,7 @@ void decode_linestring(mapnik::geometry::geometry<typename T::value_type> & geom
std::size_t num_lines = multi_line.size();
if (num_lines == 0)
{
geom = mapnik::geometry::geometry_empty();
geom = std::move(mapnik::geometry::geometry_empty());
}
else if (num_lines == 1)
{
Expand Down Expand Up @@ -413,15 +413,15 @@ void decode_polygons(mapnik::geometry::geometry<T1> & geom,
std::size_t num_rings = rings.size();
if (num_rings == 0)
{
geom = mapnik::geometry::geometry_empty();
geom = std::move(mapnik::geometry::geometry_empty());
}
else if (num_rings == 1)
{
if (rings_itr->size() < 4)
{
if (version == 1)
{
geom = mapnik::geometry::geometry_empty();
geom = std::move(mapnik::geometry::geometry_empty());
return;
}
else
Expand Down Expand Up @@ -531,7 +531,7 @@ void decode_polygons(mapnik::geometry::geometry<T1> & geom,
if (num_poly == 1)
{
auto itr = std::make_move_iterator(multi_poly.begin());
geom = mapnik::geometry::polygon<value_type>(std::move(*itr));
geom = std::move(*itr);
}
else
{
Expand Down Expand Up @@ -608,7 +608,7 @@ void decode_polygons(mapnik::geometry::geometry<T1> & geom,
if (num_poly == 1)
{
auto itr = std::make_move_iterator(multi_poly.begin());
geom = mapnik::geometry::polygon<value_type>(std::move(*itr));
geom = std::move(*itr);
}
else
{
Expand Down Expand Up @@ -819,7 +819,7 @@ typename Geometry<T>::command Geometry<T>::ring_next(value_type & rx,
if (skip_lineto_zero && dx == 0 && dy == 0)
{
// We are going to skip this vertex as the point doesn't move call ring_next again
return ring_next(rx,ry,true);
return ring_next(rx, ry, true);
}
detail::move_cursor(x, y, dx, dy, scale_x_, scale_y_);
rx = x;
Expand Down Expand Up @@ -968,7 +968,7 @@ typename GeometryPBF<T>::command GeometryPBF<T>::line_next(value_type & rx,
if (skip_lineto_zero && dx == 0 && dy == 0)
{
// We are going to skip this vertex as the point doesn't move call line_next again
return line_next(rx,ry,true);
return line_next(rx, ry, true);
}
detail::move_cursor(x, y, dx, dy, scale_x_, scale_y_);
rx = x;
Expand Down Expand Up @@ -1048,7 +1048,7 @@ typename GeometryPBF<T>::command GeometryPBF<T>::ring_next(value_type & rx,
if (skip_lineto_zero && dx == 0 && dy == 0)
{
// We are going to skip this vertex as the point doesn't move call ring_next again
return ring_next(rx,ry,true);
return ring_next(rx, ry, true);
}
detail::move_cursor(x, y, dx, dy, scale_x_, scale_y_);
rx = x;
Expand Down Expand Up @@ -1082,7 +1082,7 @@ MAPNIK_VECTOR_INLINE mapnik::geometry::geometry<typename T::value_type> decode_g
detail::read_rings<T>(rings, paths, bbox, version);
if (rings.empty())
{
geom = mapnik::geometry::geometry_empty();
geom = std::move(mapnik::geometry::geometry_empty());
}
else
{
Expand All @@ -1095,11 +1095,11 @@ MAPNIK_VECTOR_INLINE mapnik::geometry::geometry<typename T::value_type> decode_g
{
// This was changed to not throw as unknown according to v2 of spec can simply be ignored and doesn't require
// it failing the processing
geom = mapnik::geometry::geometry_empty();
geom = std::move(mapnik::geometry::geometry_empty());
break;
}
}
return geom;
return std::move(geom);
}

template <typename T>
Expand Down
4 changes: 2 additions & 2 deletions src/vector_tile_geometry_feature.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ MAPNIK_VECTOR_INLINE void geometry_to_feature(T const& geom,
if (encode_geometry(geom, *vt_feature, x, y))
{
// Releasing the pointer is important here because the layer will take over ownership!
layer.add_feature(vt_feature.release(), mapnik_feature, solid);
layer.add_feature(vt_feature, mapnik_feature, solid);
}
}

Expand All @@ -92,7 +92,7 @@ MAPNIK_VECTOR_INLINE void raster_to_feature(std::string const& buffer,
std::unique_ptr<vector_tile::Tile_Feature> vt_feature(new vector_tile::Tile_Feature());
vt_feature->set_raster(buffer);
// Releasing the pointer is important here because the layer will take over ownership!
layer.add_feature(vt_feature.release(), mapnik_feature, false);
layer.add_feature(vt_feature, mapnik_feature, false);
}

} // end ns vector_tile_impl
Expand Down
46 changes: 36 additions & 10 deletions src/vector_tile_layer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,43 @@ struct tile_layer

tile_layer(std::string const & name, std::uint32_t extent);

tile_layer(tile_layer && l)
: layer_(std::move(l.layer_)),
keys_(std::move(l.keys_)),
values_(std::move(l.values_)),
solid_(l.solid_),
empty_(l.empty_),
painted_(l.painted_)
tile_layer(tile_layer && rhs)
: layer_(std::move(rhs.layer_)),
keys_(std::move(rhs.keys_)),
values_(std::move(rhs.values_)),
solid_(std::move(rhs.solid_)),
empty_(std::move(rhs.empty_)),
painted_(std::move(rhs.painted_))
{
}

MAPNIK_VECTOR_INLINE void add_feature(vector_tile::Tile_Feature * vt_feature,
tile_layer(tile_layer const& rhs)
: layer_(new vector_tile::Tile_Layer(*rhs.layer_)),
keys_(rhs.keys_),
values_(rhs.values_),
solid_(rhs.solid_),
empty_(rhs.empty_),
painted_(rhs.painted_)
{
}

tile_layer& operator=(tile_layer rhs)
{
swap(rhs);
return *this;
}

void swap(tile_layer & rhs)
{
std::swap(layer_, rhs.layer_);
std::swap(keys_, rhs.keys_);
std::swap(values_, rhs.values_);
std::swap(solid_, rhs.solid_);
std::swap(empty_, rhs.empty_);
std::swap(painted_, rhs.painted_);
}

MAPNIK_VECTOR_INLINE void add_feature(std::unique_ptr<vector_tile::Tile_Feature> & vt_feature,
mapnik::feature_impl const& mapnik_feature,
bool feature_solid);

Expand All @@ -66,9 +92,9 @@ struct tile_layer
painted_ = true;
}

std::unique_ptr<vector_tile::Tile_Layer> release()
std::unique_ptr<vector_tile::Tile_Layer> & get_layer()
{
return std::move(layer_);
return layer_;
}

private:
Expand Down
6 changes: 4 additions & 2 deletions src/vector_tile_layer.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ tile_layer::tile_layer(std::string const & name, std::uint32_t extent)
layer_->set_version(2);
}

MAPNIK_VECTOR_INLINE void tile_layer::add_feature(vector_tile::Tile_Feature * vt_feature,
MAPNIK_VECTOR_INLINE void tile_layer::add_feature(std::unique_ptr<vector_tile::Tile_Feature> & vt_feature,
mapnik::feature_impl const& mapnik_feature,
bool feature_solid)

Expand Down Expand Up @@ -130,7 +130,9 @@ MAPNIK_VECTOR_INLINE void tile_layer::add_feature(vector_tile::Tile_Feature * vt
}
}
}
layer_->mutable_features()->AddAllocated(vt_feature);
vector_tile::Tile_Feature * feat = layer_->add_features();
feat->Swap(vt_feature.get());
//layer_->mutable_features()->AddAllocated(vt_feature.release());
if (!feature_solid)
{
solid_ = false;
Expand Down
67 changes: 55 additions & 12 deletions src/vector_tile_processor.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ tile_layer create_geom_layer(mapnik::datasource_ptr ds,
mapnik::query const& q,
std::string const& layer_name,
std::uint32_t layer_extent,
mapnik::projection const& target_proj,
mapnik::projection const& source_proj,
std::string const& target_proj_srs,
std::string const& source_proj_srs,
mapnik::view_transform const& view_trans,
std::uint32_t path_multiplier,
mapnik::box2d<double> const& buffered_extent,
Expand All @@ -209,6 +209,9 @@ tile_layer create_geom_layer(mapnik::datasource_ptr ds,
bool multi_polygon_union,
bool process_all_rings)
{
// Setup projection
mapnik::projection target_proj(target_proj_srs, true);
mapnik::projection source_proj(source_proj_srs, true);
// set up a transform from target to source
// target == final map (aka tile) projection, usually epsg:3857
// source == projection of the data being queried
Expand Down Expand Up @@ -307,12 +310,15 @@ tile_layer create_raster_layer(mapnik::datasource_ptr ds,
std::uint32_t tile_size,
std::string const& layer_name,
std::uint32_t layer_extent,
mapnik::projection const& target_proj,
mapnik::projection const& source_proj,
std::string const& target_proj_srs,
std::string const& source_proj_srs,
mapnik::view_transform const& view_trans,
std::string const& image_format,
scaling_method_e scaling_method)
{
// Setup projection
mapnik::projection target_proj(target_proj_srs, true);
mapnik::projection source_proj(source_proj_srs, true);
// set up a transform from target to source
// target == final map (aka tile) projection, usually epsg:3857
// source == projection of the data being queried
Expand Down Expand Up @@ -419,6 +425,7 @@ void processor::update_tile(tile & t,

// Futures
std::vector<std::future<tile_layer> > lay_vec;
//std::vector<tile_layer> lay_vec;
lay_vec.reserve(m_.layers().size());

for (mapnik::layer const& lay : m_.layers())
Expand All @@ -434,8 +441,10 @@ void processor::update_tile(tile & t,
continue;
}

mapnik::projection target_proj(m_.srs(),true);
mapnik::projection source_proj(lay.srs(),true);
std::string const& target_proj_srs = m_.srs();
std::string const& source_proj_srs = lay.srs();
mapnik::projection target_proj(target_proj_srs, true);
mapnik::projection source_proj(source_proj_srs, true);

mapnik::box2d<double> buffered_extent = detail::get_buffered_extent(req, lay, m_);
mapnik::box2d<double> query_ext(lay.envelope());
Expand All @@ -449,15 +458,14 @@ void processor::update_tile(tile & t,

if (ds->type() == datasource::Vector)
{

lay_vec.emplace_back(std::async(
detail::create_geom_layer,
ds,
q,
lay.name(),
req.width() * path_multiplier,
target_proj,
source_proj,
target_proj_srs,
source_proj_srs,
view_trans,
path_multiplier,
buffered_extent,
Expand All @@ -468,6 +476,25 @@ void processor::update_tile(tile & t,
multi_polygon_union_,
process_all_rings_
));
/*
lay_vec.emplace_back(
detail::create_geom_layer(
ds,
q,
lay.name(),
req.width() * path_multiplier,
target_proj_srs,
source_proj_srs,
view_trans,
path_multiplier,
buffered_extent,
simplify_distance_,
area_threshold_,
fill_type_,
strictly_simple_,
multi_polygon_union_,
process_all_rings_
));*/
}
else // Raster
{
Expand All @@ -478,19 +505,35 @@ void processor::update_tile(tile & t,
req.width(),
lay.name(),
req.width() * path_multiplier,
target_proj,
source_proj,
target_proj_srs,
source_proj_srs,
view_trans,
image_format_,
scaling_method_
));
/*
lay_vec.emplace_back(
detail::create_raster_layer(
ds,
q,
req.width(),
lay.name(),
req.width() * path_multiplier,
target_proj_srs,
source_proj_srs,
view_trans,
image_format_,
scaling_method_
));
*/
}
}

for (auto & lay_future : lay_vec)
//for (auto & l : lay_vec)
{
tile_layer l = lay_future.get();
t.add_layer(l.release(),
t.add_layer(l.get_layer(),
l.is_painted(),
l.is_solid(),
l.is_empty());
Expand Down
Loading

0 comments on commit e6e85ce

Please sign in to comment.