rename empty_featureset
=> invalid_featureset
to avoid ambiguity + add helper is_valid
method
This commit is contained in:
parent
843f96083d
commit
31814b32d0
10 changed files with 24 additions and 20 deletions
|
@ -41,21 +41,25 @@ struct MAPNIK_DECL Featureset : private util::noncopyable
|
||||||
virtual ~Featureset() {}
|
virtual ~Featureset() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct MAPNIK_DECL invalid_featureset final : Featureset
|
||||||
struct MAPNIK_DECL empty_featureset final : Featureset
|
|
||||||
{
|
{
|
||||||
feature_ptr next()
|
feature_ptr next()
|
||||||
{
|
{
|
||||||
return feature_ptr();
|
return feature_ptr();
|
||||||
}
|
}
|
||||||
~empty_featureset() {}
|
~invalid_featureset() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
using featureset_ptr = std::shared_ptr<Featureset>;
|
using featureset_ptr = std::shared_ptr<Featureset>;
|
||||||
|
|
||||||
inline featureset_ptr make_empty_featureset()
|
inline featureset_ptr make_invalid_featureset()
|
||||||
{
|
{
|
||||||
return std::make_shared<empty_featureset>();
|
return std::make_shared<invalid_featureset>();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool is_valid(featureset_ptr const& ptr)
|
||||||
|
{
|
||||||
|
return (dynamic_cast<invalid_featureset*>(ptr.get()) == nullptr) ? false : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -431,7 +431,7 @@ mapnik::featureset_ptr csv_datasource::features(mapnik::query const& q) const
|
||||||
return std::make_shared<csv_index_featureset>(filename_, filter, locator_, separator_, quote_, headers_, ctx_);
|
return std::make_shared<csv_index_featureset>(filename_, filter, locator_, separator_, quote_, headers_, ctx_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return mapnik::make_empty_featureset();
|
return mapnik::make_invalid_featureset();
|
||||||
}
|
}
|
||||||
|
|
||||||
mapnik::featureset_ptr csv_datasource::features_at_point(mapnik::coord2d const& pt, double tol) const
|
mapnik::featureset_ptr csv_datasource::features_at_point(mapnik::coord2d const& pt, double tol) const
|
||||||
|
|
|
@ -588,7 +588,7 @@ mapnik::featureset_ptr geojson_datasource::features(mapnik::query const& q) cons
|
||||||
|
|
||||||
}
|
}
|
||||||
// otherwise return an empty featureset
|
// otherwise return an empty featureset
|
||||||
return mapnik::make_empty_featureset();
|
return mapnik::make_invalid_featureset();
|
||||||
}
|
}
|
||||||
|
|
||||||
mapnik::featureset_ptr geojson_datasource::features_at_point(mapnik::coord2d const& pt, double tol) const
|
mapnik::featureset_ptr geojson_datasource::features_at_point(mapnik::coord2d const& pt, double tol) const
|
||||||
|
|
|
@ -560,7 +560,7 @@ featureset_ptr ogr_datasource::features(query const& q) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return mapnik::make_empty_featureset();
|
return mapnik::make_invalid_featureset();
|
||||||
}
|
}
|
||||||
|
|
||||||
featureset_ptr ogr_datasource::features_at_point(coord2d const& pt, double tol) const
|
featureset_ptr ogr_datasource::features_at_point(coord2d const& pt, double tol) const
|
||||||
|
@ -603,5 +603,5 @@ featureset_ptr ogr_datasource::features_at_point(coord2d const& pt, double tol)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return mapnik::make_empty_featureset();
|
return mapnik::make_invalid_featureset();
|
||||||
}
|
}
|
||||||
|
|
|
@ -998,7 +998,7 @@ featureset_ptr pgraster_datasource::features_with_context(query const& q,process
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return mapnik::make_empty_featureset();
|
return mapnik::make_invalid_featureset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1011,7 +1011,7 @@ featureset_ptr pgraster_datasource::features_at_point(coord2d const& pt, double
|
||||||
if (pool)
|
if (pool)
|
||||||
{
|
{
|
||||||
shared_ptr<Connection> conn = pool->borrowObject();
|
shared_ptr<Connection> conn = pool->borrowObject();
|
||||||
if (!conn) return mapnik::make_empty_featureset();
|
if (!conn) return mapnik::make_invalid_featureset();
|
||||||
|
|
||||||
if (conn->isOK())
|
if (conn->isOK())
|
||||||
{
|
{
|
||||||
|
@ -1082,7 +1082,7 @@ featureset_ptr pgraster_datasource::features_at_point(coord2d const& pt, double
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return mapnik::make_empty_featureset();
|
return mapnik::make_invalid_featureset();
|
||||||
}
|
}
|
||||||
|
|
||||||
box2d<double> pgraster_datasource::envelope() const
|
box2d<double> pgraster_datasource::envelope() const
|
||||||
|
|
|
@ -942,7 +942,7 @@ featureset_ptr postgis_datasource::features_with_context(query const& q,processo
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return mapnik::make_empty_featureset();
|
return mapnik::make_invalid_featureset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -955,7 +955,7 @@ featureset_ptr postgis_datasource::features_at_point(coord2d const& pt, double t
|
||||||
if (pool)
|
if (pool)
|
||||||
{
|
{
|
||||||
shared_ptr<Connection> conn = pool->borrowObject();
|
shared_ptr<Connection> conn = pool->borrowObject();
|
||||||
if (!conn) return mapnik::make_empty_featureset();
|
if (!conn) return mapnik::make_invalid_featureset();
|
||||||
|
|
||||||
if (conn->isOK())
|
if (conn->isOK())
|
||||||
{
|
{
|
||||||
|
@ -1030,7 +1030,7 @@ featureset_ptr postgis_datasource::features_at_point(coord2d const& pt, double t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return mapnik::make_empty_featureset();
|
return mapnik::make_invalid_featureset();
|
||||||
}
|
}
|
||||||
|
|
||||||
box2d<double> postgis_datasource::envelope() const
|
box2d<double> postgis_datasource::envelope() const
|
||||||
|
|
|
@ -224,5 +224,5 @@ featureset_ptr raster_datasource::features_at_point(coord2d const&, double tol)
|
||||||
{
|
{
|
||||||
MAPNIK_LOG_WARN(raster) << "raster_datasource: feature_at_point not supported";
|
MAPNIK_LOG_WARN(raster) << "raster_datasource: feature_at_point not supported";
|
||||||
|
|
||||||
return mapnik::make_empty_featureset();
|
return mapnik::make_invalid_featureset();
|
||||||
}
|
}
|
||||||
|
|
|
@ -551,7 +551,7 @@ featureset_ptr sqlite_datasource::features(query const& q) const
|
||||||
using_subquery_);
|
using_subquery_);
|
||||||
}
|
}
|
||||||
|
|
||||||
return mapnik::make_empty_featureset();
|
return mapnik::make_invalid_featureset();
|
||||||
}
|
}
|
||||||
|
|
||||||
featureset_ptr sqlite_datasource::features_at_point(coord2d const& pt, double tol) const
|
featureset_ptr sqlite_datasource::features_at_point(coord2d const& pt, double tol) const
|
||||||
|
@ -631,5 +631,5 @@ featureset_ptr sqlite_datasource::features_at_point(coord2d const& pt, double to
|
||||||
using_subquery_);
|
using_subquery_);
|
||||||
}
|
}
|
||||||
|
|
||||||
return mapnik::make_empty_featureset();
|
return mapnik::make_invalid_featureset();
|
||||||
}
|
}
|
||||||
|
|
|
@ -284,7 +284,7 @@ mapnik::featureset_ptr topojson_datasource::features(mapnik::query const& q) con
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// otherwise return an empty featureset pointer
|
// otherwise return an empty featureset pointer
|
||||||
return mapnik::make_empty_featureset();
|
return mapnik::make_invalid_featureset();
|
||||||
}
|
}
|
||||||
|
|
||||||
mapnik::featureset_ptr topojson_datasource::features_at_point(mapnik::coord2d const& pt, double tol) const
|
mapnik::featureset_ptr topojson_datasource::features_at_point(mapnik::coord2d const& pt, double tol) const
|
||||||
|
|
|
@ -746,7 +746,7 @@ featureset_ptr Map::query_point(unsigned index, double x, double y) const
|
||||||
else s << " (map has no layers)";
|
else s << " (map has no layers)";
|
||||||
throw std::out_of_range(s.str());
|
throw std::out_of_range(s.str());
|
||||||
}
|
}
|
||||||
return mapnik::make_empty_featureset();
|
return mapnik::make_invalid_featureset();
|
||||||
}
|
}
|
||||||
|
|
||||||
featureset_ptr Map::query_map_point(unsigned index, double x, double y) const
|
featureset_ptr Map::query_map_point(unsigned index, double x, double y) const
|
||||||
|
|
Loading…
Reference in a new issue