remove shp_index.hpp and update shape.input
This commit is contained in:
parent
8c16f267bb
commit
2e0486440c
2 changed files with 9 additions and 116 deletions
|
@ -36,10 +36,9 @@
|
|||
#include <boost/interprocess/streams/bufferstream.hpp>
|
||||
#endif
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
#include "shape_index_featureset.hpp"
|
||||
#include "shape_utils.hpp"
|
||||
#include "shp_index.hpp"
|
||||
#include <mapnik/util/spatial_index.hpp>
|
||||
|
||||
using mapnik::feature_factory;
|
||||
|
||||
|
@ -52,11 +51,11 @@ shape_index_featureset<filterT>::shape_index_featureset(filterT const& filter,
|
|||
int row_limit)
|
||||
: filter_(filter),
|
||||
ctx_(std::make_shared<mapnik::context_type>()),
|
||||
shape_ptr_(std::move(shape_ptr)),
|
||||
tr_(new mapnik::transcoder(encoding)),
|
||||
row_limit_(row_limit),
|
||||
count_(0),
|
||||
feature_bbox_()
|
||||
shape_ptr_(std::move(shape_ptr)),
|
||||
tr_(new mapnik::transcoder(encoding)),
|
||||
row_limit_(row_limit),
|
||||
count_(0),
|
||||
feature_bbox_()
|
||||
{
|
||||
shape_ptr_->shp().skip(100);
|
||||
setup_attributes(ctx_, attribute_names, shape_name, *shape_ptr_,attr_ids_);
|
||||
|
@ -65,17 +64,14 @@ shape_index_featureset<filterT>::shape_index_featureset(filterT const& filter,
|
|||
if (index)
|
||||
{
|
||||
#ifdef SHAPE_MEMORY_MAPPED_FILE
|
||||
//shp_index<filterT,stream<mapped_file_source> >::query(filter, index->file(), offsets_);
|
||||
shp_index<filterT,boost::interprocess::ibufferstream>::query(filter, index->file(), offsets_);
|
||||
//spatial_index<unsigned, filterT,stream<mapped_file_source> >::query(filter, index->file(), offsets_);
|
||||
mapnik::util::spatial_index<std::streampos, filterT,boost::interprocess::ibufferstream>::query(filter, index->file(), offsets_);
|
||||
#else
|
||||
shp_index<filterT,std::ifstream>::query(filter, index->file(), offsets_);
|
||||
mapnik::util::spatial_index<std::streampos, std::ifstream>::query(filter, index->file(), offsets_);
|
||||
#endif
|
||||
}
|
||||
|
||||
std::sort(offsets_.begin(), offsets_.end());
|
||||
|
||||
MAPNIK_LOG_DEBUG(shape) << "shape_index_featureset: Query size=" << offsets_.size();
|
||||
|
||||
itr_ = offsets_.begin();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,103 +0,0 @@
|
|||
/*****************************************************************************
|
||||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2015 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
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef SHP_INDEX_HPP
|
||||
#define SHP_INDEX_HPP
|
||||
|
||||
// stl
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
|
||||
// mapnik
|
||||
#include <mapnik/box2d.hpp>
|
||||
#include <mapnik/query.hpp>
|
||||
|
||||
using mapnik::box2d;
|
||||
using mapnik::query;
|
||||
|
||||
template <typename filterT, typename IStream = std::ifstream>
|
||||
class shp_index
|
||||
{
|
||||
public:
|
||||
static void query(filterT const& filter, IStream& file,std::vector<std::streampos>& pos);
|
||||
private:
|
||||
shp_index();
|
||||
~shp_index();
|
||||
shp_index(const shp_index&);
|
||||
shp_index& operator=(const shp_index&);
|
||||
static int read_ndr_integer(IStream& in);
|
||||
static void read_envelope(IStream& in, box2d<double>& envelope);
|
||||
static void query_node(const filterT& filter, IStream& in, std::vector<std::streampos>& pos);
|
||||
};
|
||||
|
||||
template <typename filterT, typename IStream>
|
||||
void shp_index<filterT, IStream>::query(const filterT& filter, IStream& file, std::vector<std::streampos>& pos)
|
||||
{
|
||||
file.seekg(16, std::ios::beg);
|
||||
query_node(filter, file, pos);
|
||||
}
|
||||
|
||||
template <typename filterT, typename IStream>
|
||||
void shp_index<filterT, IStream>::query_node(const filterT& filter, IStream& file, std::vector<std::streampos>& ids)
|
||||
{
|
||||
int offset = read_ndr_integer(file);
|
||||
|
||||
box2d<double> node_ext;
|
||||
read_envelope(file, node_ext);
|
||||
|
||||
int num_shapes = read_ndr_integer(file);
|
||||
|
||||
if (! filter.pass(node_ext))
|
||||
{
|
||||
file.seekg(offset + num_shapes * 4 + 4, std::ios::cur);
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < num_shapes; ++i)
|
||||
{
|
||||
int id = read_ndr_integer(file);
|
||||
ids.push_back(id);
|
||||
}
|
||||
|
||||
int children = read_ndr_integer(file);
|
||||
|
||||
for (int j = 0; j < children; ++j)
|
||||
{
|
||||
query_node(filter, file, ids);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename filterT, typename IStream>
|
||||
int shp_index<filterT, IStream>::read_ndr_integer(IStream& file)
|
||||
{
|
||||
char b[4];
|
||||
file.read(b, 4);
|
||||
return (b[0] & 0xff) | (b[1] & 0xff) << 8 | (b[2] & 0xff) << 16 | (b[3] & 0xff) << 24;
|
||||
}
|
||||
|
||||
template <typename filterT, typename IStream>
|
||||
void shp_index<filterT, IStream>::read_envelope(IStream& file, box2d<double>& envelope)
|
||||
{
|
||||
file.read(reinterpret_cast<char*>(&envelope), sizeof(envelope));
|
||||
}
|
||||
|
||||
#endif // SHP_INDEX_HPP
|
Loading…
Reference in a new issue