+ backports cosmetics

+ backports avoid static string as datasource name
This commit is contained in:
Lucio Asnaghi 2010-11-16 21:20:40 +00:00
parent 980098e2d5
commit b4421bc39c
3 changed files with 201 additions and 200 deletions

View file

@ -76,7 +76,12 @@ void shape_datasource::bind() const
if (!boost::filesystem::exists(shape_name_ + ".shp")) if (!boost::filesystem::exists(shape_name_ + ".shp"))
{ {
throw datasource_exception(shape_name_ + " does not exist"); throw datasource_exception("shapefile '" + shape_name_ + ".shp' does not exist");
}
if (boost::filesystem::is_directory(shape_name_ + ".shp"))
{
throw datasource_exception("shapefile '" + shape_name_ + ".shp' appears to be a directory not a file");
} }
try try
@ -133,8 +138,6 @@ void shape_datasource::bind() const
shape_datasource::~shape_datasource() {} shape_datasource::~shape_datasource() {}
const std::string shape_datasource::name_="shape";
void shape_datasource::init(shape_io& shape) void shape_datasource::init(shape_io& shape)
{ {
//first read header from *.shp //first read header from *.shp
@ -160,7 +163,6 @@ void shape_datasource::init(shape_io& shape)
#else #else
shape.shp().skip(4); shape.shp().skip(4);
#endif #endif
shape.shp().read_envelope(extent_); shape.shp().read_envelope(extent_);
#ifdef MAPNIK_DEBUG #ifdef MAPNIK_DEBUG
@ -189,7 +191,11 @@ void shape_datasource::init(shape_io& shape)
std::clog << "file_length=" << file_length_ << std::endl; std::clog << "file_length=" << file_length_ << std::endl;
std::clog << "shape_type=" << shape_type << std::endl; std::clog << "shape_type=" << shape_type << std::endl;
#endif #endif
}
std::string shape_datasource::name()
{
return "shape";
} }
int shape_datasource::type() const int shape_datasource::type() const
@ -203,16 +209,12 @@ layer_descriptor shape_datasource::get_descriptor() const
return desc_; return desc_;
} }
std::string shape_datasource::name()
{
return name_;
}
featureset_ptr shape_datasource::features(const query& q) const featureset_ptr shape_datasource::features(const query& q) const
{ {
if (!is_bound_) bind(); if (!is_bound_) bind();
filter_in_box filter(q.get_bbox()); filter_in_box filter(q.get_bbox());
if (indexed_) if (indexed_)
{ {
return featureset_ptr return featureset_ptr
@ -237,6 +239,7 @@ featureset_ptr shape_datasource::features_at_point(coord2d const& pt) const
if (!is_bound_) bind(); if (!is_bound_) bind();
filter_at_point filter(pt); filter_at_point filter(pt);
// collect all attribute names // collect all attribute names
std::vector<attribute_descriptor> const& desc_vector = desc_.get_descriptors(); std::vector<attribute_descriptor> const& desc_vector = desc_.get_descriptors();
std::vector<attribute_descriptor>::const_iterator itr = desc_vector.begin(); std::vector<attribute_descriptor>::const_iterator itr = desc_vector.begin();

View file

@ -61,7 +61,6 @@ class shape_datasource : public datasource
mutable Envelope<double> extent_; mutable Envelope<double> extent_;
mutable bool indexed_; mutable bool indexed_;
mutable layer_descriptor desc_; mutable layer_descriptor desc_;
static const std::string name_;
}; };
#endif //SHAPE_HPP #endif //SHAPE_HPP

View file

@ -115,6 +115,7 @@ struct shape_record
pos+=8; pos+=8;
return val; return val;
} }
long remains() long remains()
{ {
return (size-pos); return (size-pos);
@ -124,7 +125,6 @@ struct shape_record
{ {
Tag::dealloc(data); Tag::dealloc(data);
} }
}; };
using namespace boost::iostreams; using namespace boost::iostreams;
@ -162,7 +162,6 @@ public:
return file_.is_open(); return file_.is_open();
} }
inline void close() inline void close()
{ {
if (file_ && file_.is_open()) if (file_ && file_.is_open())