Merge branch 'master' of https://github.com/mapnik/mapnik
This commit is contained in:
commit
fd895f9533
55 changed files with 567 additions and 1016 deletions
|
@ -14,6 +14,8 @@ For a complete change history, see the SVN log.
|
||||||
Mapnik 2.1.0
|
Mapnik 2.1.0
|
||||||
------------
|
------------
|
||||||
|
|
||||||
|
- SQLite - Added support for !intersects! token in sql subselects (#809) allow custom positioning of rtree spatial filter.
|
||||||
|
|
||||||
- New CSV plugin - reads tabular files - autodetecting geo columns, newlines, and delimiters. Uses in-memory featureset for fast rendering and is not designed for large files (#902)
|
- New CSV plugin - reads tabular files - autodetecting geo columns, newlines, and delimiters. Uses in-memory featureset for fast rendering and is not designed for large files (#902)
|
||||||
|
|
||||||
- Fixed bug in shield line placement when dx/dy are used to shift the label relative to the placement point (Matt Amos) (#908)
|
- Fixed bug in shield line placement when dx/dy are used to shift the label relative to the placement point (Matt Amos) (#908)
|
||||||
|
|
|
@ -142,7 +142,11 @@ paths += "__all__ = [mapniklibpath,inputpluginspath,fontscollectionpath]\n"
|
||||||
|
|
||||||
if not os.path.exists('mapnik'):
|
if not os.path.exists('mapnik'):
|
||||||
os.mkdir('mapnik')
|
os.mkdir('mapnik')
|
||||||
file('mapnik/paths.py','w').write(paths % (os.path.relpath(env['MAPNIK_LIB_DIR'],target_path)))
|
|
||||||
|
if hasattr(os.path,'relpath'): # python 2.6 and above
|
||||||
|
file('mapnik/paths.py','w').write(paths % (os.path.relpath(env['MAPNIK_LIB_DIR'],target_path)))
|
||||||
|
else:
|
||||||
|
file('mapnik/paths.py','w').write(paths % (env['MAPNIK_LIB_DIR']))
|
||||||
|
|
||||||
# force open perms temporarily so that `sudo scons install`
|
# force open perms temporarily so that `sudo scons install`
|
||||||
# does not later break simple non-install non-sudo rebuild
|
# does not later break simple non-install non-sudo rebuild
|
||||||
|
|
|
@ -593,7 +593,7 @@ class PDFPrinter:
|
||||||
|
|
||||||
for l in m.layers:
|
for l in m.layers:
|
||||||
# extract the layer names for naming layers if we use OCG
|
# extract the layer names for naming layers if we use OCG
|
||||||
self._layer_names.append(l.title or l.name)
|
self._layer_names.append(l.name)
|
||||||
|
|
||||||
layer_map = Map(m.width,m.height,m.srs)
|
layer_map = Map(m.width,m.height,m.srs)
|
||||||
layer_map.layers.append(l)
|
layer_map.layers.append(l)
|
||||||
|
@ -884,7 +884,7 @@ class PDFPrinter:
|
||||||
for l in reversed(m.layers):
|
for l in reversed(m.layers):
|
||||||
have_layer_header = False
|
have_layer_header = False
|
||||||
added_styles={}
|
added_styles={}
|
||||||
layer_title = l.title or l.name
|
layer_title = l.name
|
||||||
if layer_title in processed_layers:
|
if layer_title in processed_layers:
|
||||||
continue
|
continue
|
||||||
processed_layers.append(layer_title)
|
processed_layers.append(layer_title)
|
||||||
|
@ -906,8 +906,8 @@ class PDFPrinter:
|
||||||
if r.filter and str(r.filter) != "true":
|
if r.filter and str(r.filter) != "true":
|
||||||
if len(rule_text) > 0:
|
if len(rule_text) > 0:
|
||||||
rule_text += " AND "
|
rule_text += " AND "
|
||||||
if r.title:
|
if r.name:
|
||||||
rule_text += r.title
|
rule_text += r.name
|
||||||
else:
|
else:
|
||||||
rule_text += str(r.filter)
|
rule_text += str(r.filter)
|
||||||
active_rules = tuple(active_rules)
|
active_rules = tuple(active_rules)
|
||||||
|
|
|
@ -45,7 +45,7 @@ using mapnik::from_wkt;
|
||||||
|
|
||||||
void feature_add_geometries_from_wkb(Feature &feature, std::string wkb)
|
void feature_add_geometries_from_wkb(Feature &feature, std::string wkb)
|
||||||
{
|
{
|
||||||
geometry_utils::from_wkb(feature.paths(), wkb.c_str(), wkb.size(), true);
|
geometry_utils::from_wkb(feature.paths(), wkb.c_str(), wkb.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
void feature_add_geometries_from_wkt(Feature &feature, std::string wkt)
|
void feature_add_geometries_from_wkt(Feature &feature, std::string wkt)
|
||||||
|
|
|
@ -62,7 +62,7 @@ void add_wkt_impl(path_type& p, std::string const& wkt)
|
||||||
|
|
||||||
void add_wkb_impl(path_type& p, std::string const& wkb)
|
void add_wkb_impl(path_type& p, std::string const& wkb)
|
||||||
{
|
{
|
||||||
mapnik::geometry_utils::from_wkb(p, wkb.c_str(), wkb.size(), true);
|
mapnik::geometry_utils::from_wkb(p, wkb.c_str(), wkb.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::shared_ptr<path_type> from_wkt_impl(std::string const& wkt)
|
boost::shared_ptr<path_type> from_wkt_impl(std::string const& wkt)
|
||||||
|
@ -76,7 +76,7 @@ boost::shared_ptr<path_type> from_wkt_impl(std::string const& wkt)
|
||||||
boost::shared_ptr<path_type> from_wkb_impl(std::string const& wkb)
|
boost::shared_ptr<path_type> from_wkb_impl(std::string const& wkb)
|
||||||
{
|
{
|
||||||
boost::shared_ptr<path_type> paths = boost::make_shared<path_type>();
|
boost::shared_ptr<path_type> paths = boost::make_shared<path_type>();
|
||||||
mapnik::geometry_utils::from_wkb(*paths, wkb.c_str(), wkb.size(), true);
|
mapnik::geometry_utils::from_wkb(*paths, wkb.c_str(), wkb.size());
|
||||||
return paths;
|
return paths;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,6 +117,24 @@ std::string to_wkt( geometry_type const& geom)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string to_wkt2( path_type const& geom)
|
||||||
|
{
|
||||||
|
#if BOOST_VERSION >= 104700
|
||||||
|
std::string wkt; // Use Python String directly ?
|
||||||
|
bool result = mapnik::util::to_wkt(wkt,geom);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
throw std::runtime_error("Generate WKT failed");
|
||||||
|
}
|
||||||
|
return wkt;
|
||||||
|
#else
|
||||||
|
std::ostringstream s;
|
||||||
|
s << BOOST_VERSION/100000 << "." << BOOST_VERSION/100 % 1000 << "." << BOOST_VERSION % 100;
|
||||||
|
throw std::runtime_error("mapnik::to_wkt() requires at least boost 1.47 while your build was compiled against boost " + s.str());
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void export_geometry()
|
void export_geometry()
|
||||||
{
|
{
|
||||||
using namespace boost::python;
|
using namespace boost::python;
|
||||||
|
@ -125,9 +143,6 @@ void export_geometry()
|
||||||
.value("Point",mapnik::Point)
|
.value("Point",mapnik::Point)
|
||||||
.value("LineString",mapnik::LineString)
|
.value("LineString",mapnik::LineString)
|
||||||
.value("Polygon",mapnik::Polygon)
|
.value("Polygon",mapnik::Polygon)
|
||||||
.value("MultiPoint",mapnik::MultiPoint)
|
|
||||||
.value("MultiLineString",mapnik::MultiLineString)
|
|
||||||
.value("MultiPolygon",mapnik::MultiPolygon)
|
|
||||||
;
|
;
|
||||||
|
|
||||||
using mapnik::geometry_type;
|
using mapnik::geometry_type;
|
||||||
|
@ -145,6 +160,7 @@ void export_geometry()
|
||||||
.def("__len__", &path_type::size)
|
.def("__len__", &path_type::size)
|
||||||
.def("add_wkt",add_wkt_impl)
|
.def("add_wkt",add_wkt_impl)
|
||||||
.def("add_wkb",add_wkb_impl)
|
.def("add_wkb",add_wkb_impl)
|
||||||
|
.def("to_wkt",&to_wkt2)
|
||||||
.def("from_wkt",from_wkt_impl)
|
.def("from_wkt",from_wkt_impl)
|
||||||
.def("from_wkb",from_wkb_impl)
|
.def("from_wkb",from_wkb_impl)
|
||||||
.staticmethod("from_wkt")
|
.staticmethod("from_wkt")
|
||||||
|
|
|
@ -54,7 +54,7 @@ struct layer_pickle_suite : boost::python::pickle_suite
|
||||||
{
|
{
|
||||||
s.append(style_names[i]);
|
s.append(style_names[i]);
|
||||||
}
|
}
|
||||||
return boost::python::make_tuple(l.abstract(),l.title(),l.clear_label_cache(),l.getMinZoom(),l.getMaxZoom(),l.isQueryable(),l.datasource()->params(),l.cache_features(),s);
|
return boost::python::make_tuple(l.clear_label_cache(),l.getMinZoom(),l.getMaxZoom(),l.isQueryable(),l.datasource()->params(),l.cache_features(),s);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -70,28 +70,24 @@ struct layer_pickle_suite : boost::python::pickle_suite
|
||||||
throw_error_already_set();
|
throw_error_already_set();
|
||||||
}
|
}
|
||||||
|
|
||||||
l.set_abstract(extract<std::string>(state[0]));
|
l.set_clear_label_cache(extract<bool>(state[0]));
|
||||||
|
|
||||||
l.set_title(extract<std::string>(state[1]));
|
l.setMinZoom(extract<double>(state[1]));
|
||||||
|
|
||||||
l.set_clear_label_cache(extract<bool>(state[2]));
|
l.setMaxZoom(extract<double>(state[2]));
|
||||||
|
|
||||||
l.setMinZoom(extract<double>(state[3]));
|
l.setQueryable(extract<bool>(state[3]));
|
||||||
|
|
||||||
l.setMaxZoom(extract<double>(state[4]));
|
mapnik::parameters params = extract<parameters>(state[4]);
|
||||||
|
|
||||||
l.setQueryable(extract<bool>(state[5]));
|
|
||||||
|
|
||||||
mapnik::parameters params = extract<parameters>(state[6]);
|
|
||||||
l.set_datasource(datasource_cache::instance()->create(params));
|
l.set_datasource(datasource_cache::instance()->create(params));
|
||||||
|
|
||||||
boost::python::list s = extract<boost::python::list>(state[7]);
|
boost::python::list s = extract<boost::python::list>(state[5]);
|
||||||
for (int i=0;i<len(s);++i)
|
for (int i=0;i<len(s);++i)
|
||||||
{
|
{
|
||||||
l.add_style(extract<std::string>(s[i]));
|
l.add_style(extract<std::string>(s[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
l.set_cache_features(extract<bool>(state[8]));
|
l.set_cache_features(extract<bool>(state[6]));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -152,21 +148,6 @@ void export_layer()
|
||||||
"False\n"
|
"False\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
.add_property("abstract",
|
|
||||||
make_function(&layer::abstract,return_value_policy<copy_const_reference>()),
|
|
||||||
&layer::set_abstract,
|
|
||||||
"Get/Set the abstract of the layer.\n"
|
|
||||||
"\n"
|
|
||||||
"Usage:\n"
|
|
||||||
">>> from mapnik import Layer\n"
|
|
||||||
">>> lyr = Layer('My Layer','+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')\n"
|
|
||||||
">>> lyr.abstract\n"
|
|
||||||
"'' # default is en empty string\n"
|
|
||||||
">>> lyr.abstract = 'My Shapefile rendered with Mapnik'\n"
|
|
||||||
">>> lyr.abstract\n"
|
|
||||||
"'My Shapefile rendered with Mapnik'\n"
|
|
||||||
)
|
|
||||||
|
|
||||||
.add_property("active",
|
.add_property("active",
|
||||||
&layer::isActive,
|
&layer::isActive,
|
||||||
&layer::setActive,
|
&layer::setActive,
|
||||||
|
@ -310,20 +291,5 @@ void export_layer()
|
||||||
"'My Style'\n"
|
"'My Style'\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
.add_property("title",
|
|
||||||
make_function(&layer::title, return_value_policy<copy_const_reference>()),
|
|
||||||
&layer::set_title,
|
|
||||||
"Get/Set the title of the layer.\n"
|
|
||||||
"\n"
|
|
||||||
"Usage:\n"
|
|
||||||
">>> from mapnik import layer\n"
|
|
||||||
">>> lyr = layer('My layer','+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')\n"
|
|
||||||
">>> lyr.title\n"
|
|
||||||
"''\n"
|
|
||||||
">>> lyr.title = 'My first layer'\n"
|
|
||||||
">>> lyr.title\n"
|
|
||||||
"'My first layer'\n"
|
|
||||||
)
|
|
||||||
|
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,7 +86,7 @@ struct rule_pickle_suite : boost::python::pickle_suite
|
||||||
static boost::python::tuple
|
static boost::python::tuple
|
||||||
getinitargs(const rule& r)
|
getinitargs(const rule& r)
|
||||||
{
|
{
|
||||||
return boost::python::make_tuple(r.get_name(),r.get_title(),r.get_min_scale(),r.get_max_scale());
|
return boost::python::make_tuple(r.get_name(),r.get_min_scale(),r.get_max_scale());
|
||||||
}
|
}
|
||||||
|
|
||||||
static boost::python::tuple
|
static boost::python::tuple
|
||||||
|
@ -102,7 +102,7 @@ struct rule_pickle_suite : boost::python::pickle_suite
|
||||||
// We serialize filter expressions AST as strings
|
// We serialize filter expressions AST as strings
|
||||||
std::string filter_expr = to_expression_string(*r.get_filter());
|
std::string filter_expr = to_expression_string(*r.get_filter());
|
||||||
|
|
||||||
return boost::python::make_tuple(r.get_abstract(),filter_expr,r.has_else_filter(),r.has_also_filter(),syms);
|
return boost::python::make_tuple(filter_expr,r.has_else_filter(),r.has_also_filter(),syms);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -119,11 +119,6 @@ struct rule_pickle_suite : boost::python::pickle_suite
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state[0])
|
if (state[0])
|
||||||
{
|
|
||||||
r.set_title(extract<std::string>(state[0]));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (state[1])
|
|
||||||
{
|
{
|
||||||
rule dfl;
|
rule dfl;
|
||||||
std::string filter = extract<std::string>(state[1]);
|
std::string filter = extract<std::string>(state[1]);
|
||||||
|
@ -134,12 +129,12 @@ struct rule_pickle_suite : boost::python::pickle_suite
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state[2])
|
if (state[1])
|
||||||
{
|
{
|
||||||
r.set_else(true);
|
r.set_else(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state[3])
|
if (state[2])
|
||||||
{
|
{
|
||||||
r.set_also(true);
|
r.set_also(true);
|
||||||
}
|
}
|
||||||
|
@ -176,18 +171,12 @@ void export_rule()
|
||||||
|
|
||||||
class_<rule>("Rule",init<>("default constructor"))
|
class_<rule>("Rule",init<>("default constructor"))
|
||||||
.def(init<std::string const&,
|
.def(init<std::string const&,
|
||||||
boost::python::optional<std::string const&,double,double> >())
|
boost::python::optional<double,double> >())
|
||||||
.def_pickle(rule_pickle_suite())
|
.def_pickle(rule_pickle_suite())
|
||||||
.add_property("name",make_function
|
.add_property("name",make_function
|
||||||
(&rule::get_name,
|
(&rule::get_name,
|
||||||
return_value_policy<copy_const_reference>()),
|
return_value_policy<copy_const_reference>()),
|
||||||
&rule::set_name)
|
&rule::set_name)
|
||||||
.add_property("title",make_function
|
|
||||||
(&rule::get_title,return_value_policy<copy_const_reference>()),
|
|
||||||
&rule::set_title)
|
|
||||||
.add_property("abstract",make_function
|
|
||||||
(&rule::get_abstract,return_value_policy<copy_const_reference>()),
|
|
||||||
&rule::set_abstract)
|
|
||||||
.add_property("filter",make_function
|
.add_property("filter",make_function
|
||||||
(&rule::get_filter,return_value_policy<copy_const_reference>()),
|
(&rule::get_filter,return_value_policy<copy_const_reference>()),
|
||||||
&rule::set_filter)
|
&rule::set_filter)
|
||||||
|
|
|
@ -36,29 +36,24 @@ namespace mapnik {
|
||||||
|
|
||||||
enum eGeomType {
|
enum eGeomType {
|
||||||
Point = 1,
|
Point = 1,
|
||||||
LineString,
|
LineString = 2,
|
||||||
Polygon,
|
Polygon = 3
|
||||||
MultiPoint,
|
|
||||||
MultiLineString,
|
|
||||||
MultiPolygon
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template <typename T, template <typename> class Container=vertex_vector>
|
template <typename T, template <typename> class Container=vertex_vector>
|
||||||
class geometry
|
class geometry : private::boost::noncopyable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef T coord_type;
|
typedef T coord_type;
|
||||||
typedef Container<coord_type> container_type;
|
typedef Container<coord_type> container_type;
|
||||||
typedef typename container_type::value_type value_type;
|
typedef typename container_type::value_type value_type;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
container_type cont_;
|
container_type cont_;
|
||||||
eGeomType type_;
|
eGeomType type_;
|
||||||
mutable unsigned itr_;
|
mutable unsigned itr_;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
geometry(eGeomType type)
|
explicit geometry(eGeomType type)
|
||||||
: type_(type),
|
: type_(type),
|
||||||
itr_(0)
|
itr_(0)
|
||||||
{}
|
{}
|
||||||
|
@ -168,7 +163,7 @@ public:
|
||||||
*/
|
*/
|
||||||
void label_position(double *x, double *y) const
|
void label_position(double *x, double *y) const
|
||||||
{
|
{
|
||||||
if (type_ == LineString || type_ == MultiLineString)
|
if (type_ == LineString)
|
||||||
{
|
{
|
||||||
middle_point(x,y);
|
middle_point(x,y);
|
||||||
return;
|
return;
|
||||||
|
@ -232,7 +227,7 @@ public:
|
||||||
/* summarized distance centroid */
|
/* summarized distance centroid */
|
||||||
void label_position3(double *x, double *y) const
|
void label_position3(double *x, double *y) const
|
||||||
{
|
{
|
||||||
if (type_ == LineString || type_ == MultiLineString)
|
if (type_ == LineString)
|
||||||
{
|
{
|
||||||
middle_point(x,y);
|
middle_point(x,y);
|
||||||
return;
|
return;
|
||||||
|
@ -392,7 +387,7 @@ public:
|
||||||
|
|
||||||
typedef geometry<double,vertex_vector> geometry_type;
|
typedef geometry<double,vertex_vector> geometry_type;
|
||||||
typedef boost::shared_ptr<geometry_type> geometry_ptr;
|
typedef boost::shared_ptr<geometry_type> geometry_ptr;
|
||||||
typedef boost::ptr_vector<geometry_type> geometry_containter;
|
typedef boost::ptr_vector<geometry_type> geometry_container;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,28 +56,9 @@ public:
|
||||||
/*!
|
/*!
|
||||||
* @return the name of the layer.
|
* @return the name of the layer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const std::string& name() const;
|
const std::string& name() const;
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Set the title of the layer.
|
|
||||||
*/
|
|
||||||
void set_title(std::string const& title);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @return the title of the layer.
|
|
||||||
*/
|
|
||||||
const std::string& title() const;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Set the abstract of the layer.
|
|
||||||
*/
|
|
||||||
void set_abstract(std::string const& abstract);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @return the abstract of the layer.
|
|
||||||
*/
|
|
||||||
const std::string& abstract() const;
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Set the SRS of the layer.
|
* @brief Set the SRS of the layer.
|
||||||
*/
|
*/
|
||||||
|
@ -212,8 +193,6 @@ private:
|
||||||
void swap(const layer& other);
|
void swap(const layer& other);
|
||||||
|
|
||||||
std::string name_;
|
std::string name_;
|
||||||
std::string title_;
|
|
||||||
std::string abstract_;
|
|
||||||
std::string srs_;
|
std::string srs_;
|
||||||
|
|
||||||
double minZoom_;
|
double minZoom_;
|
||||||
|
|
|
@ -132,8 +132,6 @@ public:
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::string name_;
|
std::string name_;
|
||||||
std::string title_;
|
|
||||||
std::string abstract_;
|
|
||||||
double min_scale_;
|
double min_scale_;
|
||||||
double max_scale_;
|
double max_scale_;
|
||||||
symbolizers syms_;
|
symbolizers syms_;
|
||||||
|
@ -143,8 +141,6 @@ private:
|
||||||
public:
|
public:
|
||||||
rule()
|
rule()
|
||||||
: name_(),
|
: name_(),
|
||||||
title_(),
|
|
||||||
abstract_(),
|
|
||||||
min_scale_(0),
|
min_scale_(0),
|
||||||
max_scale_(std::numeric_limits<double>::infinity()),
|
max_scale_(std::numeric_limits<double>::infinity()),
|
||||||
syms_(),
|
syms_(),
|
||||||
|
@ -153,11 +149,9 @@ public:
|
||||||
also_filter_(false) {}
|
also_filter_(false) {}
|
||||||
|
|
||||||
rule(const std::string& name,
|
rule(const std::string& name,
|
||||||
const std::string& title="",
|
|
||||||
double min_scale_denominator=0,
|
double min_scale_denominator=0,
|
||||||
double max_scale_denominator=std::numeric_limits<double>::infinity())
|
double max_scale_denominator=std::numeric_limits<double>::infinity())
|
||||||
: name_(name),
|
: name_(name),
|
||||||
title_(title),
|
|
||||||
min_scale_(min_scale_denominator),
|
min_scale_(min_scale_denominator),
|
||||||
max_scale_(max_scale_denominator),
|
max_scale_(max_scale_denominator),
|
||||||
syms_(),
|
syms_(),
|
||||||
|
@ -167,8 +161,6 @@ public:
|
||||||
|
|
||||||
rule(const rule& rhs, bool deep_copy = false)
|
rule(const rule& rhs, bool deep_copy = false)
|
||||||
: name_(rhs.name_),
|
: name_(rhs.name_),
|
||||||
title_(rhs.title_),
|
|
||||||
abstract_(rhs.abstract_),
|
|
||||||
min_scale_(rhs.min_scale_),
|
min_scale_(rhs.min_scale_),
|
||||||
max_scale_(rhs.max_scale_),
|
max_scale_(rhs.max_scale_),
|
||||||
syms_(rhs.syms_),
|
syms_(rhs.syms_),
|
||||||
|
@ -264,26 +256,6 @@ public:
|
||||||
return name_;
|
return name_;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string const& get_title() const
|
|
||||||
{
|
|
||||||
return title_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_title(std::string const& title)
|
|
||||||
{
|
|
||||||
title_=title;
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_abstract(std::string const& abstract)
|
|
||||||
{
|
|
||||||
abstract_=abstract;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string const& get_abstract() const
|
|
||||||
{
|
|
||||||
return abstract_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void append(const symbolizer& sym)
|
void append(const symbolizer& sym)
|
||||||
{
|
{
|
||||||
syms_.push_back(sym);
|
syms_.push_back(sym);
|
||||||
|
@ -362,8 +334,6 @@ private:
|
||||||
void swap(rule& rhs) throw()
|
void swap(rule& rhs) throw()
|
||||||
{
|
{
|
||||||
name_=rhs.name_;
|
name_=rhs.name_;
|
||||||
title_=rhs.title_;
|
|
||||||
abstract_=rhs.abstract_;
|
|
||||||
min_scale_=rhs.min_scale_;
|
min_scale_=rhs.min_scale_;
|
||||||
max_scale_=rhs.max_scale_;
|
max_scale_=rhs.max_scale_;
|
||||||
syms_=rhs.syms_;
|
syms_=rhs.syms_;
|
||||||
|
|
|
@ -219,10 +219,6 @@ wkb_buffer_ptr to_wkb(geometry_type const& g, wkbByteOrder byte_order )
|
||||||
case mapnik::Polygon:
|
case mapnik::Polygon:
|
||||||
wkb = to_polygon_wkb(g, byte_order);
|
wkb = to_polygon_wkb(g, byte_order);
|
||||||
break;
|
break;
|
||||||
case mapnik::MultiPoint:
|
|
||||||
case mapnik::MultiLineString:
|
|
||||||
case mapnik::MultiPolygon:
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,8 +42,19 @@ bool to_wkt(std::string & wkt, mapnik::geometry_type const& geom)
|
||||||
{
|
{
|
||||||
typedef std::back_insert_iterator<std::string> sink_type;
|
typedef std::back_insert_iterator<std::string> sink_type;
|
||||||
sink_type sink(wkt);
|
sink_type sink(wkt);
|
||||||
wkt_generator<sink_type> generator;
|
// disable temporarily until compile works with g++
|
||||||
bool result = karma::generate(sink, generator, geom);
|
//wkt_generator<sink_type> generator(true);
|
||||||
|
bool result = false;//karma::generate(sink, generator, geom);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool to_wkt(std::string & wkt, mapnik::geometry_container const& geom)
|
||||||
|
{
|
||||||
|
typedef std::back_insert_iterator<std::string> sink_type;
|
||||||
|
sink_type sink(wkt);
|
||||||
|
// disable temporarily until compile works with g++
|
||||||
|
//wkt_multi_generator<sink_type> generator;
|
||||||
|
bool result = false;//karma::generate(sink, generator, geom);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,6 @@
|
||||||
#include <mapnik/geometry.hpp>
|
#include <mapnik/geometry.hpp>
|
||||||
#include <mapnik/util/vertex_iterator.hpp>
|
#include <mapnik/util/vertex_iterator.hpp>
|
||||||
#include <mapnik/util/container_adapter.hpp>
|
#include <mapnik/util/container_adapter.hpp>
|
||||||
|
|
||||||
// boost
|
// boost
|
||||||
#include <boost/tuple/tuple.hpp>
|
#include <boost/tuple/tuple.hpp>
|
||||||
#include <boost/spirit/include/karma.hpp>
|
#include <boost/spirit/include/karma.hpp>
|
||||||
|
@ -49,6 +48,8 @@ namespace mapnik { namespace util {
|
||||||
namespace karma = boost::spirit::karma;
|
namespace karma = boost::spirit::karma;
|
||||||
namespace phoenix = boost::phoenix;
|
namespace phoenix = boost::phoenix;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
struct get_type
|
struct get_type
|
||||||
{
|
{
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
@ -56,7 +57,7 @@ struct get_type
|
||||||
|
|
||||||
int operator() (geometry_type const& geom) const
|
int operator() (geometry_type const& geom) const
|
||||||
{
|
{
|
||||||
return (int)geom.type();
|
return static_cast<int>(geom.type());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -73,21 +74,61 @@ struct get_first
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct multi_geometry_
|
||||||
|
{
|
||||||
|
template <typename T>
|
||||||
|
struct result { typedef bool type; };
|
||||||
|
|
||||||
|
bool operator() (geometry_container const& geom) const
|
||||||
|
{
|
||||||
|
return geom.size() > 1 ? true : false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct multi_geometry_type
|
||||||
|
{
|
||||||
|
template <typename T>
|
||||||
|
struct result { typedef boost::tuple<unsigned,bool> type; };
|
||||||
|
|
||||||
|
boost::tuple<unsigned,bool> operator() (geometry_container const& geom) const
|
||||||
|
{
|
||||||
|
unsigned type = 0u;
|
||||||
|
bool collection = false;
|
||||||
|
|
||||||
|
geometry_container::const_iterator itr = geom.begin();
|
||||||
|
geometry_container::const_iterator end = geom.end();
|
||||||
|
|
||||||
|
for ( ; itr != end; ++itr)
|
||||||
|
{
|
||||||
|
if (type != 0 && itr->type() != type)
|
||||||
|
{
|
||||||
|
collection = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
type = itr->type();
|
||||||
|
}
|
||||||
|
return boost::tuple<unsigned,bool>(type, collection);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct coordinate_policy : karma::real_policies<T>
|
struct wkt_coordinate_policy : karma::real_policies<T>
|
||||||
{
|
{
|
||||||
typedef boost::spirit::karma::real_policies<T> base_type;
|
typedef boost::spirit::karma::real_policies<T> base_type;
|
||||||
static int floatfield(T n) { return base_type::fmtflags::fixed; }
|
static int floatfield(T n) { return base_type::fmtflags::fixed; }
|
||||||
static unsigned precision(T n) { return 6u ;}
|
static unsigned precision(T n) { return 6 ;}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
template <typename OutputIterator>
|
template <typename OutputIterator>
|
||||||
struct wkt_generator :
|
struct wkt_generator :
|
||||||
karma::grammar<OutputIterator, geometry_type const& ()>
|
karma::grammar<OutputIterator, geometry_type const& ()>
|
||||||
{
|
{
|
||||||
|
|
||||||
wkt_generator()
|
wkt_generator(bool single = false)
|
||||||
: wkt_generator::base_type(wkt)
|
: wkt_generator::base_type(wkt)
|
||||||
{
|
{
|
||||||
using boost::spirit::karma::uint_;
|
using boost::spirit::karma::uint_;
|
||||||
|
@ -97,22 +138,27 @@ struct wkt_generator :
|
||||||
using boost::spirit::karma::_a;
|
using boost::spirit::karma::_a;
|
||||||
using boost::spirit::karma::_r1;
|
using boost::spirit::karma::_r1;
|
||||||
using boost::spirit::karma::eps;
|
using boost::spirit::karma::eps;
|
||||||
|
using boost::spirit::karma::string;
|
||||||
|
|
||||||
wkt = point | linestring | polygon
|
wkt = point | linestring | polygon
|
||||||
;
|
;
|
||||||
|
|
||||||
point = &uint_(mapnik::Point)[_1 = _type(_val)]
|
point = &uint_(mapnik::Point)[_1 = _type(_val)]
|
||||||
<< lit("Point(") << point_coord [_1 = _first(_val)] << lit(')')
|
<< string[ phoenix::if_ (single) [_1 = "Point("]
|
||||||
|
.else_[_1 = "("]]
|
||||||
|
<< point_coord [_1 = _first(_val)] << lit(')')
|
||||||
;
|
;
|
||||||
|
|
||||||
linestring = &uint_(mapnik::LineString)[_1 = _type(_val)]
|
linestring = &uint_(mapnik::LineString)[_1 = _type(_val)]
|
||||||
<< lit("LineString(")
|
<< string[ phoenix::if_ (single) [_1 = "LineString("]
|
||||||
|
.else_[_1 = "("]]
|
||||||
<< coords
|
<< coords
|
||||||
<< lit(')')
|
<< lit(')')
|
||||||
;
|
;
|
||||||
|
|
||||||
polygon = &uint_(mapnik::Polygon)[_1 = _type(_val)]
|
polygon = &uint_(mapnik::Polygon)[_1 = _type(_val)]
|
||||||
<< lit("Polygon(")
|
<< string[ phoenix::if_ (single) [_1 = "Polygon("]
|
||||||
|
.else_[_1 = "("]]
|
||||||
<< coords2
|
<< coords2
|
||||||
<< lit("))")
|
<< lit("))")
|
||||||
;
|
;
|
||||||
|
@ -121,7 +167,7 @@ struct wkt_generator :
|
||||||
;
|
;
|
||||||
|
|
||||||
polygon_coord %= ( &uint_(mapnik::SEG_MOVETO) << eps[_r1 += 1]
|
polygon_coord %= ( &uint_(mapnik::SEG_MOVETO) << eps[_r1 += 1]
|
||||||
<< karma::string[ if_ (_r1 > 1) [_1 = "),("]
|
<< string[ if_ (_r1 > 1) [_1 = "),("]
|
||||||
.else_[_1 = "("] ] | &uint_ << ",")
|
.else_[_1 = "("] ] | &uint_ << ",")
|
||||||
<< coord_type
|
<< coord_type
|
||||||
<< lit(' ')
|
<< lit(' ')
|
||||||
|
@ -144,16 +190,69 @@ struct wkt_generator :
|
||||||
karma::rule<OutputIterator, geometry_type const& ()> coords;
|
karma::rule<OutputIterator, geometry_type const& ()> coords;
|
||||||
karma::rule<OutputIterator, karma::locals<unsigned>, geometry_type const& ()> coords2;
|
karma::rule<OutputIterator, karma::locals<unsigned>, geometry_type const& ()> coords2;
|
||||||
karma::rule<OutputIterator, geometry_type::value_type ()> point_coord;
|
karma::rule<OutputIterator, geometry_type::value_type ()> point_coord;
|
||||||
karma::rule<OutputIterator, geometry_type::value_type const& (unsigned& )> polygon_coord;
|
karma::rule<OutputIterator, geometry_type::value_type (unsigned& )> polygon_coord;
|
||||||
|
|
||||||
// phoenix functions
|
// phoenix functions
|
||||||
phoenix::function<get_type > _type;
|
phoenix::function<get_type > _type;
|
||||||
phoenix::function<get_first> _first;
|
phoenix::function<get_first> _first;
|
||||||
//
|
//
|
||||||
karma::real_generator<double, coordinate_policy<double> > coord_type;
|
karma::real_generator<double, wkt_coordinate_policy<double> > coord_type;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
template <typename OutputIterator>
|
||||||
|
struct wkt_multi_generator :
|
||||||
|
karma::grammar<OutputIterator, karma::locals< boost::tuple<unsigned,bool> >, geometry_container const& ()>
|
||||||
|
{
|
||||||
|
|
||||||
|
wkt_multi_generator()
|
||||||
|
: wkt_multi_generator::base_type(wkt)
|
||||||
|
{
|
||||||
|
using boost::spirit::karma::lit;
|
||||||
|
using boost::spirit::karma::eps;
|
||||||
|
using boost::spirit::karma::_val;
|
||||||
|
using boost::spirit::karma::_1;
|
||||||
|
using boost::spirit::karma::_a;
|
||||||
|
|
||||||
|
geometry_types.add
|
||||||
|
(mapnik::Point,"Point")
|
||||||
|
(mapnik::LineString,"LineString")
|
||||||
|
(mapnik::Polygon,"Polygon")
|
||||||
|
;
|
||||||
|
|
||||||
|
wkt = eps(phoenix::at_c<1>(_a))[_a = _multi_type(_val)]
|
||||||
|
<< lit("GeometryCollection(") << geometry << lit(")")
|
||||||
|
| eps(is_multi(_val)) << lit("Multi") << geometry_types[_1 = phoenix::at_c<0>(_a)]
|
||||||
|
<< "(" << multi_geometry << ")"
|
||||||
|
| geometry
|
||||||
|
;
|
||||||
|
|
||||||
|
geometry = -(single_geometry % lit(','))
|
||||||
|
;
|
||||||
|
|
||||||
|
single_geometry = geometry_types[_1 = _type(_val)] << path
|
||||||
|
;
|
||||||
|
|
||||||
|
multi_geometry = -(path % lit(','))
|
||||||
|
;
|
||||||
|
|
||||||
|
}
|
||||||
|
// rules
|
||||||
|
karma::rule<OutputIterator, karma::locals<boost::tuple<unsigned,bool> >, geometry_container const& ()> wkt;
|
||||||
|
karma::rule<OutputIterator, geometry_container const& ()> geometry;
|
||||||
|
karma::rule<OutputIterator, geometry_type const& ()> single_geometry;
|
||||||
|
karma::rule<OutputIterator, geometry_container const& ()> multi_geometry;
|
||||||
|
wkt_generator<OutputIterator> path;
|
||||||
|
// phoenix
|
||||||
|
phoenix::function<multi_geometry_> is_multi;
|
||||||
|
phoenix::function<multi_geometry_type> _multi_type;
|
||||||
|
phoenix::function<get_type > _type;
|
||||||
|
//
|
||||||
|
karma::symbols<unsigned, char const*> geometry_types;
|
||||||
|
};
|
||||||
|
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,8 @@
|
||||||
#include <mapnik/geometry.hpp>
|
#include <mapnik/geometry.hpp>
|
||||||
#include <mapnik/ctrans.hpp>
|
#include <mapnik/ctrans.hpp>
|
||||||
#include <mapnik/feature.hpp>
|
#include <mapnik/feature.hpp>
|
||||||
|
// boost
|
||||||
|
#include <boost/utility.hpp>
|
||||||
|
|
||||||
namespace mapnik
|
namespace mapnik
|
||||||
{
|
{
|
||||||
|
@ -49,19 +51,14 @@ enum wkbFormat
|
||||||
wkbSpatiaLite=3
|
wkbSpatiaLite=3
|
||||||
};
|
};
|
||||||
|
|
||||||
class MAPNIK_DECL geometry_utils
|
class MAPNIK_DECL geometry_utils : private boost::noncopyable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static void from_wkb (boost::ptr_vector<geometry_type>& paths,
|
static void from_wkb (boost::ptr_vector<geometry_type>& paths,
|
||||||
const char* wkb,
|
const char* wkb,
|
||||||
unsigned size,
|
unsigned size,
|
||||||
bool multiple_geometries = false,
|
|
||||||
wkbFormat format = wkbGeneric);
|
wkbFormat format = wkbGeneric);
|
||||||
private:
|
|
||||||
geometry_utils();
|
|
||||||
geometry_utils(geometry_utils const&);
|
|
||||||
geometry_utils& operator=(const geometry_utils&);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -98,8 +98,6 @@ geos_datasource::geos_datasource(parameters const& params, bool bind)
|
||||||
if (! geometry) throw datasource_exception("missing <wkt> parameter");
|
if (! geometry) throw datasource_exception("missing <wkt> parameter");
|
||||||
geometry_string_ = *geometry;
|
geometry_string_ = *geometry;
|
||||||
|
|
||||||
multiple_geometries_ = *params_.get<mapnik::boolean>("multiple_geometries",false);
|
|
||||||
|
|
||||||
boost::optional<std::string> ext = params_.get<std::string>("extent");
|
boost::optional<std::string> ext = params_.get<std::string>("extent");
|
||||||
if (ext) extent_initialized_ = extent_.from_string(*ext);
|
if (ext) extent_initialized_ = extent_.from_string(*ext);
|
||||||
|
|
||||||
|
@ -270,8 +268,7 @@ featureset_ptr geos_datasource::features(query const& q) const
|
||||||
geometry_id_,
|
geometry_id_,
|
||||||
geometry_data_,
|
geometry_data_,
|
||||||
geometry_data_name_,
|
geometry_data_name_,
|
||||||
desc_.get_encoding(),
|
desc_.get_encoding());
|
||||||
multiple_geometries_);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
featureset_ptr geos_datasource::features_at_point(coord2d const& pt) const
|
featureset_ptr geos_datasource::features_at_point(coord2d const& pt) const
|
||||||
|
@ -290,6 +287,5 @@ featureset_ptr geos_datasource::features_at_point(coord2d const& pt) const
|
||||||
geometry_id_,
|
geometry_id_,
|
||||||
geometry_data_,
|
geometry_data_,
|
||||||
geometry_data_name_,
|
geometry_data_name_,
|
||||||
desc_.get_encoding(),
|
desc_.get_encoding());
|
||||||
multiple_geometries_);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,6 @@ private:
|
||||||
mutable std::string geometry_data_name_;
|
mutable std::string geometry_data_name_;
|
||||||
mutable int geometry_id_;
|
mutable int geometry_id_;
|
||||||
std::string geometry_string_;
|
std::string geometry_string_;
|
||||||
bool multiple_geometries_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GEOS_DATASOURCE_HPP
|
#endif // GEOS_DATASOURCE_HPP
|
||||||
|
|
|
@ -53,15 +53,13 @@ geos_featureset::geos_featureset(GEOSGeometry* geometry,
|
||||||
int identifier,
|
int identifier,
|
||||||
const std::string& field,
|
const std::string& field,
|
||||||
const std::string& field_name,
|
const std::string& field_name,
|
||||||
const std::string& encoding,
|
const std::string& encoding)
|
||||||
bool multiple_geometries)
|
|
||||||
: geometry_(geometry),
|
: geometry_(geometry),
|
||||||
tr_(new transcoder(encoding)),
|
tr_(new transcoder(encoding)),
|
||||||
extent_(extent),
|
extent_(extent),
|
||||||
identifier_(identifier),
|
identifier_(identifier),
|
||||||
field_(field),
|
field_(field),
|
||||||
field_name_(field_name),
|
field_name_(field_name),
|
||||||
multiple_geometries_(multiple_geometries),
|
|
||||||
already_rendered_(false)
|
already_rendered_(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -120,9 +118,7 @@ feature_ptr geos_featureset::next()
|
||||||
|
|
||||||
geometry_utils::from_wkb(feature->paths(),
|
geometry_utils::from_wkb(feature->paths(),
|
||||||
wkb.data(),
|
wkb.data(),
|
||||||
wkb.size(),
|
wkb.size());
|
||||||
multiple_geometries_);
|
|
||||||
|
|
||||||
if (field_ != "")
|
if (field_ != "")
|
||||||
{
|
{
|
||||||
boost::put(*feature, field_name_, tr_->transcode(field_.c_str()));
|
boost::put(*feature, field_name_, tr_->transcode(field_.c_str()));
|
||||||
|
|
|
@ -44,8 +44,7 @@ public:
|
||||||
int identifier,
|
int identifier,
|
||||||
const std::string& field,
|
const std::string& field,
|
||||||
const std::string& field_name,
|
const std::string& field_name,
|
||||||
const std::string& encoding,
|
const std::string& encoding);
|
||||||
bool multiple_geometries);
|
|
||||||
virtual ~geos_featureset();
|
virtual ~geos_featureset();
|
||||||
mapnik::feature_ptr next();
|
mapnik::feature_ptr next();
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,6 @@ private:
|
||||||
const std::list<kismet_network_data>& knd_list_;
|
const std::list<kismet_network_data>& knd_list_;
|
||||||
boost::scoped_ptr<mapnik::transcoder> tr_;
|
boost::scoped_ptr<mapnik::transcoder> tr_;
|
||||||
mapnik::wkbFormat format_;
|
mapnik::wkbFormat format_;
|
||||||
bool multiple_geometries_;
|
|
||||||
int feature_id_;
|
int feature_id_;
|
||||||
std::list<kismet_network_data>::const_iterator knd_list_it;
|
std::list<kismet_network_data>::const_iterator knd_list_it;
|
||||||
mapnik::projection source_;
|
mapnik::projection source_;
|
||||||
|
|
|
@ -94,7 +94,6 @@ occi_datasource::occi_datasource(parameters const& params, bool bind)
|
||||||
table_ = *table;
|
table_ = *table;
|
||||||
}
|
}
|
||||||
|
|
||||||
multiple_geometries_ = *params_.get<mapnik::boolean>("multiple_geometries",false);
|
|
||||||
use_spatial_index_ = *params_.get<mapnik::boolean>("use_spatial_index",true);
|
use_spatial_index_ = *params_.get<mapnik::boolean>("use_spatial_index",true);
|
||||||
use_connection_pool_ = *params_.get<mapnik::boolean>("use_connection_pool",true);
|
use_connection_pool_ = *params_.get<mapnik::boolean>("use_connection_pool",true);
|
||||||
|
|
||||||
|
@ -560,7 +559,6 @@ featureset_ptr occi_datasource::features(query const& q) const
|
||||||
conn_,
|
conn_,
|
||||||
s.str(),
|
s.str(),
|
||||||
desc_.get_encoding(),
|
desc_.get_encoding(),
|
||||||
multiple_geometries_,
|
|
||||||
use_connection_pool_,
|
use_connection_pool_,
|
||||||
row_prefetch_,
|
row_prefetch_,
|
||||||
props.size());
|
props.size());
|
||||||
|
@ -642,7 +640,6 @@ featureset_ptr occi_datasource::features_at_point(coord2d const& pt) const
|
||||||
conn_,
|
conn_,
|
||||||
s.str(),
|
s.str(),
|
||||||
desc_.get_encoding(),
|
desc_.get_encoding(),
|
||||||
multiple_geometries_,
|
|
||||||
use_connection_pool_,
|
use_connection_pool_,
|
||||||
row_prefetch_,
|
row_prefetch_,
|
||||||
size);
|
size);
|
||||||
|
|
|
@ -64,7 +64,6 @@ private:
|
||||||
mutable oracle::occi::StatelessConnectionPool* pool_;
|
mutable oracle::occi::StatelessConnectionPool* pool_;
|
||||||
mutable oracle::occi::Connection* conn_;
|
mutable oracle::occi::Connection* conn_;
|
||||||
bool use_connection_pool_;
|
bool use_connection_pool_;
|
||||||
bool multiple_geometries_;
|
|
||||||
bool use_spatial_index_;
|
bool use_spatial_index_;
|
||||||
static const std::string METADATA_TABLE;
|
static const std::string METADATA_TABLE;
|
||||||
};
|
};
|
||||||
|
|
|
@ -59,12 +59,10 @@ occi_featureset::occi_featureset(StatelessConnectionPool* pool,
|
||||||
Connection* conn,
|
Connection* conn,
|
||||||
std::string const& sqlstring,
|
std::string const& sqlstring,
|
||||||
std::string const& encoding,
|
std::string const& encoding,
|
||||||
bool multiple_geometries,
|
|
||||||
bool use_connection_pool,
|
bool use_connection_pool,
|
||||||
unsigned prefetch_rows,
|
unsigned prefetch_rows,
|
||||||
unsigned num_attrs)
|
unsigned num_attrs)
|
||||||
: tr_(new transcoder(encoding)),
|
: tr_(new transcoder(encoding)),
|
||||||
multiple_geometries_(multiple_geometries),
|
|
||||||
num_attrs_(num_attrs),
|
num_attrs_(num_attrs),
|
||||||
feature_id_(1)
|
feature_id_(1)
|
||||||
{
|
{
|
||||||
|
@ -101,7 +99,7 @@ feature_ptr occi_featureset::next()
|
||||||
boost::scoped_ptr<SDOGeometry> geom(dynamic_cast<SDOGeometry*>(rs_->getObject(1)));
|
boost::scoped_ptr<SDOGeometry> geom(dynamic_cast<SDOGeometry*>(rs_->getObject(1)));
|
||||||
if (geom.get())
|
if (geom.get())
|
||||||
{
|
{
|
||||||
convert_geometry(geom.get(), feature, multiple_geometries_);
|
convert_geometry(geom.get(), feature);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<MetaData> listOfColumns = rs_->getColumnListMetaData();
|
std::vector<MetaData> listOfColumns = rs_->getColumnListMetaData();
|
||||||
|
@ -204,7 +202,7 @@ feature_ptr occi_featureset::next()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void occi_featureset::convert_geometry(SDOGeometry* geom, feature_ptr feature, bool multiple_geometries)
|
void occi_featureset::convert_geometry(SDOGeometry* geom, feature_ptr feature)
|
||||||
{
|
{
|
||||||
int gtype = (int)geom->getSdo_gtype();
|
int gtype = (int)geom->getSdo_gtype();
|
||||||
int dimensions = gtype / 1000;
|
int dimensions = gtype / 1000;
|
||||||
|
@ -248,16 +246,13 @@ void occi_featureset::convert_geometry(SDOGeometry* geom, feature_ptr feature, b
|
||||||
{
|
{
|
||||||
const bool is_single_geom = true;
|
const bool is_single_geom = true;
|
||||||
const bool is_point_type = false;
|
const bool is_point_type = false;
|
||||||
const bool multiple_geoms = false;
|
|
||||||
|
|
||||||
convert_ordinates(feature,
|
convert_ordinates(feature,
|
||||||
mapnik::LineString,
|
mapnik::LineString,
|
||||||
elem_info,
|
elem_info,
|
||||||
ordinates,
|
ordinates,
|
||||||
dimensions,
|
dimensions,
|
||||||
is_single_geom,
|
is_single_geom,
|
||||||
is_point_type,
|
is_point_type);
|
||||||
multiple_geoms);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -267,16 +262,13 @@ void occi_featureset::convert_geometry(SDOGeometry* geom, feature_ptr feature, b
|
||||||
{
|
{
|
||||||
const bool is_single_geom = true;
|
const bool is_single_geom = true;
|
||||||
const bool is_point_type = false;
|
const bool is_point_type = false;
|
||||||
const bool multiple_geoms = false;
|
|
||||||
|
|
||||||
convert_ordinates(feature,
|
convert_ordinates(feature,
|
||||||
mapnik::Polygon,
|
mapnik::Polygon,
|
||||||
elem_info,
|
elem_info,
|
||||||
ordinates,
|
ordinates,
|
||||||
dimensions,
|
dimensions,
|
||||||
is_single_geom,
|
is_single_geom,
|
||||||
is_point_type,
|
is_point_type);
|
||||||
multiple_geoms);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -286,19 +278,15 @@ void occi_featureset::convert_geometry(SDOGeometry* geom, feature_ptr feature, b
|
||||||
{
|
{
|
||||||
const bool is_single_geom = false;
|
const bool is_single_geom = false;
|
||||||
const bool is_point_type = true;
|
const bool is_point_type = true;
|
||||||
const bool multiple_geoms = true;
|
|
||||||
|
|
||||||
// Todo - force using true as multiple_geometries until we have proper multipoint handling
|
|
||||||
// http://trac.mapnik.org/ticket/458
|
|
||||||
|
|
||||||
|
// FIXME :http://trac.mapnik.org/ticket/458
|
||||||
convert_ordinates(feature,
|
convert_ordinates(feature,
|
||||||
mapnik::Point,
|
mapnik::Point,
|
||||||
elem_info,
|
elem_info,
|
||||||
ordinates,
|
ordinates,
|
||||||
dimensions,
|
dimensions,
|
||||||
is_single_geom,
|
is_single_geom,
|
||||||
is_point_type,
|
is_point_type);
|
||||||
multiple_geoms);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -315,8 +303,7 @@ void occi_featureset::convert_geometry(SDOGeometry* geom, feature_ptr feature, b
|
||||||
ordinates,
|
ordinates,
|
||||||
dimensions,
|
dimensions,
|
||||||
is_single_geom,
|
is_single_geom,
|
||||||
is_point_type,
|
is_point_type);
|
||||||
multiple_geometries);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -333,8 +320,7 @@ void occi_featureset::convert_geometry(SDOGeometry* geom, feature_ptr feature, b
|
||||||
ordinates,
|
ordinates,
|
||||||
dimensions,
|
dimensions,
|
||||||
is_single_geom,
|
is_single_geom,
|
||||||
is_point_type,
|
is_point_type);
|
||||||
multiple_geometries);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -352,8 +338,7 @@ void occi_featureset::convert_geometry(SDOGeometry* geom, feature_ptr feature, b
|
||||||
ordinates,
|
ordinates,
|
||||||
dimensions,
|
dimensions,
|
||||||
is_single_geom,
|
is_single_geom,
|
||||||
is_point_type,
|
is_point_type);
|
||||||
multiple_geometries);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -374,8 +359,7 @@ void occi_featureset::convert_ordinates(mapnik::feature_ptr feature,
|
||||||
const std::vector<Number>& ordinates,
|
const std::vector<Number>& ordinates,
|
||||||
const int dimensions,
|
const int dimensions,
|
||||||
const bool is_single_geom,
|
const bool is_single_geom,
|
||||||
const bool is_point_geom,
|
const bool is_point_geom)
|
||||||
const bool multiple_geometries)
|
|
||||||
{
|
{
|
||||||
const int elem_size = elem_info.size();
|
const int elem_size = elem_info.size();
|
||||||
const int ord_size = ordinates.size();
|
const int ord_size = ordinates.size();
|
||||||
|
@ -388,7 +372,7 @@ void occi_featureset::convert_ordinates(mapnik::feature_ptr feature,
|
||||||
|
|
||||||
if (! is_single_geom && elem_size > SDO_ELEM_INFO_SIZE)
|
if (! is_single_geom && elem_size > SDO_ELEM_INFO_SIZE)
|
||||||
{
|
{
|
||||||
geometry_type* geom = multiple_geometries ? 0 : new geometry_type(geom_type);
|
geometry_type* geom = new geometry_type(geom_type);
|
||||||
if (geom) geom->set_capacity(ord_size);
|
if (geom) geom->set_capacity(ord_size);
|
||||||
|
|
||||||
for (int i = SDO_ELEM_INFO_SIZE; i < elem_size; i+=3)
|
for (int i = SDO_ELEM_INFO_SIZE; i < elem_size; i+=3)
|
||||||
|
@ -443,8 +427,6 @@ void occi_featureset::convert_ordinates(mapnik::feature_ptr feature,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_linear_element)
|
if (is_linear_element)
|
||||||
{
|
|
||||||
if (multiple_geometries)
|
|
||||||
{
|
{
|
||||||
if (geom)
|
if (geom)
|
||||||
{
|
{
|
||||||
|
@ -453,7 +435,6 @@ void occi_featureset::convert_ordinates(mapnik::feature_ptr feature,
|
||||||
|
|
||||||
geom = new geometry_type(gtype);
|
geom = new geometry_type(gtype);
|
||||||
geom->set_capacity((next_offset - 1) - (offset - 1 - dimensions));
|
geom->set_capacity((next_offset - 1) - (offset - 1 - dimensions));
|
||||||
}
|
|
||||||
|
|
||||||
fill_geometry_type(geom,
|
fill_geometry_type(geom,
|
||||||
offset - 1,
|
offset - 1,
|
||||||
|
|
|
@ -42,7 +42,6 @@ public:
|
||||||
oracle::occi::Connection* conn,
|
oracle::occi::Connection* conn,
|
||||||
std::string const& sqlstring,
|
std::string const& sqlstring,
|
||||||
std::string const& encoding,
|
std::string const& encoding,
|
||||||
bool multiple_geometries,
|
|
||||||
bool use_connection_pool,
|
bool use_connection_pool,
|
||||||
unsigned prefetch_rows,
|
unsigned prefetch_rows,
|
||||||
unsigned num_attrs);
|
unsigned num_attrs);
|
||||||
|
@ -50,15 +49,14 @@ public:
|
||||||
mapnik::feature_ptr next();
|
mapnik::feature_ptr next();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void convert_geometry (SDOGeometry* geom, mapnik::feature_ptr feature, bool multiple_geometries);
|
void convert_geometry (SDOGeometry* geom, mapnik::feature_ptr feature);
|
||||||
void convert_ordinates (mapnik::feature_ptr feature,
|
void convert_ordinates (mapnik::feature_ptr feature,
|
||||||
const mapnik::eGeomType& geom_type,
|
const mapnik::eGeomType& geom_type,
|
||||||
const std::vector<oracle::occi::Number>& elem_info,
|
const std::vector<oracle::occi::Number>& elem_info,
|
||||||
const std::vector<oracle::occi::Number>& ordinates,
|
const std::vector<oracle::occi::Number>& ordinates,
|
||||||
const int dimensions,
|
const int dimensions,
|
||||||
const bool is_single_geom,
|
const bool is_single_geom,
|
||||||
const bool is_point_geom,
|
const bool is_point_geom);
|
||||||
const bool multiple_geometries);
|
|
||||||
void fill_geometry_type (mapnik::geometry_type* geom,
|
void fill_geometry_type (mapnik::geometry_type* geom,
|
||||||
const int real_offset,
|
const int real_offset,
|
||||||
const int next_offset,
|
const int next_offset,
|
||||||
|
@ -70,7 +68,6 @@ private:
|
||||||
oracle::occi::ResultSet* rs_;
|
oracle::occi::ResultSet* rs_;
|
||||||
boost::scoped_ptr<mapnik::transcoder> tr_;
|
boost::scoped_ptr<mapnik::transcoder> tr_;
|
||||||
const char* fidcolumn_;
|
const char* fidcolumn_;
|
||||||
bool multiple_geometries_;
|
|
||||||
unsigned num_attrs_;
|
unsigned num_attrs_;
|
||||||
mutable int feature_id_;
|
mutable int feature_id_;
|
||||||
};
|
};
|
||||||
|
|
|
@ -87,8 +87,6 @@ postgis_datasource::postgis_datasource(parameters const& params, bool bind)
|
||||||
{
|
{
|
||||||
if (table_.empty()) throw mapnik::datasource_exception("Postgis Plugin: missing <table> parameter");
|
if (table_.empty()) throw mapnik::datasource_exception("Postgis Plugin: missing <table> parameter");
|
||||||
|
|
||||||
multiple_geometries_ = *params_.get<mapnik::boolean>("multiple_geometries",false);
|
|
||||||
|
|
||||||
boost::optional<std::string> ext = params_.get<std::string>("extent");
|
boost::optional<std::string> ext = params_.get<std::string>("extent");
|
||||||
if (ext) extent_initialized_ = extent_.from_string(*ext);
|
if (ext) extent_initialized_ = extent_.from_string(*ext);
|
||||||
|
|
||||||
|
@ -517,7 +515,7 @@ featureset_ptr postgis_datasource::features(const query& q) const
|
||||||
unsigned num_attr = props.size();
|
unsigned num_attr = props.size();
|
||||||
if (!key_field_.empty())
|
if (!key_field_.empty())
|
||||||
++num_attr;
|
++num_attr;
|
||||||
return boost::make_shared<postgis_featureset>(rs,desc_.get_encoding(),multiple_geometries_,!key_field_.empty(),num_attr);
|
return boost::make_shared<postgis_featureset>(rs,desc_.get_encoding(), !key_field_.empty(),num_attr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -585,7 +583,7 @@ featureset_ptr postgis_datasource::features_at_point(coord2d const& pt) const
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::shared_ptr<IResultSet> rs = get_resultset(conn, s.str());
|
boost::shared_ptr<IResultSet> rs = get_resultset(conn, s.str());
|
||||||
return boost::make_shared<postgis_featureset>(rs,desc_.get_encoding(),multiple_geometries_,!key_field_.empty(),size);
|
return boost::make_shared<postgis_featureset>(rs,desc_.get_encoding(), !key_field_.empty(),size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return featureset_ptr();
|
return featureset_ptr();
|
||||||
|
|
|
@ -69,7 +69,6 @@ class postgis_datasource : public datasource
|
||||||
mutable mapnik::box2d<double> extent_;
|
mutable mapnik::box2d<double> extent_;
|
||||||
mutable layer_descriptor desc_;
|
mutable layer_descriptor desc_;
|
||||||
ConnectionCreator<Connection> creator_;
|
ConnectionCreator<Connection> creator_;
|
||||||
bool multiple_geometries_;
|
|
||||||
const std::string bbox_token_;
|
const std::string bbox_token_;
|
||||||
const std::string scale_denom_token_;
|
const std::string scale_denom_token_;
|
||||||
bool persist_connection_;
|
bool persist_connection_;
|
||||||
|
|
|
@ -49,11 +49,9 @@ using mapnik::feature_factory;
|
||||||
|
|
||||||
postgis_featureset::postgis_featureset(boost::shared_ptr<IResultSet> const& rs,
|
postgis_featureset::postgis_featureset(boost::shared_ptr<IResultSet> const& rs,
|
||||||
std::string const& encoding,
|
std::string const& encoding,
|
||||||
bool multiple_geometries,
|
|
||||||
bool key_field=false,
|
bool key_field=false,
|
||||||
unsigned num_attrs=0)
|
unsigned num_attrs=0)
|
||||||
: rs_(rs),
|
: rs_(rs),
|
||||||
multiple_geometries_(multiple_geometries),
|
|
||||||
num_attrs_(num_attrs),
|
num_attrs_(num_attrs),
|
||||||
tr_(new transcoder(encoding)),
|
tr_(new transcoder(encoding)),
|
||||||
totalGeomSize_(0),
|
totalGeomSize_(0),
|
||||||
|
@ -103,7 +101,7 @@ feature_ptr postgis_featureset::next()
|
||||||
// parse geometry
|
// parse geometry
|
||||||
int size = rs_->getFieldLength(0);
|
int size = rs_->getFieldLength(0);
|
||||||
const char *data = rs_->getValue(0);
|
const char *data = rs_->getValue(0);
|
||||||
geometry_utils::from_wkb(feature->paths(),data,size,multiple_geometries_);
|
geometry_utils::from_wkb(feature->paths(), data, size);
|
||||||
totalGeomSize_+=size;
|
totalGeomSize_+=size;
|
||||||
|
|
||||||
for ( ;pos<num_attrs_+1;++pos)
|
for ( ;pos<num_attrs_+1;++pos)
|
||||||
|
|
|
@ -44,7 +44,6 @@ class postgis_featureset : public mapnik::Featureset
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
boost::shared_ptr<IResultSet> rs_;
|
boost::shared_ptr<IResultSet> rs_;
|
||||||
bool multiple_geometries_;
|
|
||||||
unsigned num_attrs_;
|
unsigned num_attrs_;
|
||||||
boost::scoped_ptr<mapnik::transcoder> tr_;
|
boost::scoped_ptr<mapnik::transcoder> tr_;
|
||||||
int totalGeomSize_;
|
int totalGeomSize_;
|
||||||
|
@ -53,7 +52,6 @@ private:
|
||||||
public:
|
public:
|
||||||
postgis_featureset(boost::shared_ptr<IResultSet> const& rs,
|
postgis_featureset(boost::shared_ptr<IResultSet> const& rs,
|
||||||
std::string const& encoding,
|
std::string const& encoding,
|
||||||
bool multiple_geometries,
|
|
||||||
bool key_field,
|
bool key_field,
|
||||||
unsigned num_attrs);
|
unsigned num_attrs);
|
||||||
mapnik::feature_ptr next();
|
mapnik::feature_ptr next();
|
||||||
|
|
|
@ -248,49 +248,19 @@ feature_ptr shape_featureset<filterT>::next()
|
||||||
}
|
}
|
||||||
|
|
||||||
case shape_io::shape_polyline:
|
case shape_io::shape_polyline:
|
||||||
{
|
|
||||||
geometry_type* line = shape_.read_polyline();
|
|
||||||
feature->add_geometry(line);
|
|
||||||
++count_;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case shape_io::shape_polylinem:
|
case shape_io::shape_polylinem:
|
||||||
{
|
|
||||||
geometry_type* line = shape_.read_polylinem();
|
|
||||||
feature->add_geometry(line);
|
|
||||||
++count_;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case shape_io::shape_polylinez:
|
case shape_io::shape_polylinez:
|
||||||
{
|
{
|
||||||
geometry_type* line = shape_.read_polylinez();
|
shape_.read_polyline(feature->paths());
|
||||||
feature->add_geometry(line);
|
|
||||||
++count_;
|
++count_;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case shape_io::shape_polygon:
|
case shape_io::shape_polygon:
|
||||||
{
|
|
||||||
geometry_type* poly = shape_.read_polygon();
|
|
||||||
feature->add_geometry(poly);
|
|
||||||
++count_;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case shape_io::shape_polygonm:
|
case shape_io::shape_polygonm:
|
||||||
{
|
|
||||||
geometry_type* poly = shape_.read_polygonm();
|
|
||||||
feature->add_geometry(poly);
|
|
||||||
++count_;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case shape_io::shape_polygonz:
|
case shape_io::shape_polygonz:
|
||||||
{
|
{
|
||||||
geometry_type* poly = shape_.read_polygonz();
|
shape_.read_polygon(feature->paths());
|
||||||
feature->add_geometry(poly);
|
|
||||||
++count_;
|
++count_;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -193,49 +193,18 @@ feature_ptr shape_index_featureset<filterT>::next()
|
||||||
}
|
}
|
||||||
|
|
||||||
case shape_io::shape_polyline:
|
case shape_io::shape_polyline:
|
||||||
{
|
|
||||||
geometry_type* line = shape_.read_polyline();
|
|
||||||
feature->add_geometry(line);
|
|
||||||
++count_;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case shape_io::shape_polylinem:
|
case shape_io::shape_polylinem:
|
||||||
{
|
|
||||||
geometry_type* line = shape_.read_polylinem();
|
|
||||||
feature->add_geometry(line);
|
|
||||||
++count_;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case shape_io::shape_polylinez:
|
case shape_io::shape_polylinez:
|
||||||
{
|
{
|
||||||
geometry_type* line = shape_.read_polylinez();
|
shape_.read_polyline(feature->paths());
|
||||||
feature->add_geometry(line);
|
|
||||||
++count_;
|
++count_;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case shape_io::shape_polygon:
|
case shape_io::shape_polygon:
|
||||||
{
|
|
||||||
geometry_type* poly = shape_.read_polygon();
|
|
||||||
feature->add_geometry(poly);
|
|
||||||
++count_;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case shape_io::shape_polygonm:
|
case shape_io::shape_polygonm:
|
||||||
{
|
|
||||||
geometry_type* poly = shape_.read_polygonm();
|
|
||||||
feature->add_geometry(poly);
|
|
||||||
++count_;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case shape_io::shape_polygonz:
|
case shape_io::shape_polygonz:
|
||||||
{
|
{
|
||||||
geometry_type* poly = shape_.read_polygonz();
|
shape_.read_polygon(feature->paths());
|
||||||
feature->add_geometry(poly);
|
|
||||||
++count_;
|
++count_;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,18 +106,16 @@ dbf_file& shape_io::dbf()
|
||||||
return dbf_;
|
return dbf_;
|
||||||
}
|
}
|
||||||
|
|
||||||
geometry_type* shape_io::read_polyline()
|
void shape_io::read_polyline(mapnik::geometry_container & geom)
|
||||||
{
|
{
|
||||||
shape_file::record_type record(reclength_ * 2 - 36);
|
shape_file::record_type record(reclength_ * 2 - 36);
|
||||||
shp_.read_record(record);
|
shp_.read_record(record);
|
||||||
|
|
||||||
int num_parts = record.read_ndr_integer();
|
int num_parts = record.read_ndr_integer();
|
||||||
int num_points = record.read_ndr_integer();
|
int num_points = record.read_ndr_integer();
|
||||||
geometry_type* line = new geometry_type(mapnik::LineString);
|
|
||||||
line->set_capacity(num_points + num_parts);
|
|
||||||
if (num_parts == 1)
|
if (num_parts == 1)
|
||||||
{
|
{
|
||||||
line->set_capacity(num_points + 1);
|
geometry_type* line = new geometry_type(mapnik::LineString);
|
||||||
record.skip(4);
|
record.skip(4);
|
||||||
double x = record.read_double();
|
double x = record.read_double();
|
||||||
double y = record.read_double();
|
double y = record.read_double();
|
||||||
|
@ -128,6 +126,7 @@ geometry_type* shape_io::read_polyline()
|
||||||
y = record.read_double();
|
y = record.read_double();
|
||||||
line->line_to(x, y);
|
line->line_to(x, y);
|
||||||
}
|
}
|
||||||
|
geom.push_back(line);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -140,6 +139,7 @@ geometry_type* shape_io::read_polyline()
|
||||||
int start, end;
|
int start, end;
|
||||||
for (int k = 0; k < num_parts; ++k)
|
for (int k = 0; k < num_parts; ++k)
|
||||||
{
|
{
|
||||||
|
geometry_type* line = new geometry_type(mapnik::LineString);
|
||||||
start = parts[k];
|
start = parts[k];
|
||||||
if (k == num_parts - 1)
|
if (k == num_parts - 1)
|
||||||
{
|
{
|
||||||
|
@ -160,135 +160,9 @@ geometry_type* shape_io::read_polyline()
|
||||||
y = record.read_double();
|
y = record.read_double();
|
||||||
line->line_to(x, y);
|
line->line_to(x, y);
|
||||||
}
|
}
|
||||||
|
geom.push_back(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return line;
|
|
||||||
}
|
|
||||||
|
|
||||||
geometry_type* shape_io::read_polylinem()
|
|
||||||
{
|
|
||||||
shape_file::record_type record(reclength_ * 2 - 36);
|
|
||||||
shp_.read_record(record);
|
|
||||||
|
|
||||||
int num_parts = record.read_ndr_integer();
|
|
||||||
int num_points = record.read_ndr_integer();
|
|
||||||
geometry_type* line = new geometry_type(mapnik::LineString);
|
|
||||||
line->set_capacity(num_points + num_parts);
|
|
||||||
if (num_parts == 1)
|
|
||||||
{
|
|
||||||
record.skip(4);
|
|
||||||
double x = record.read_double();
|
|
||||||
double y = record.read_double();
|
|
||||||
line->move_to(x, y);
|
|
||||||
for (int i = 1; i < num_points; ++i)
|
|
||||||
{
|
|
||||||
x = record.read_double();
|
|
||||||
y = record.read_double();
|
|
||||||
line->line_to(x, y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::vector<int> parts(num_parts);
|
|
||||||
for (int i = 0; i < num_parts; ++i)
|
|
||||||
{
|
|
||||||
parts[i] = record.read_ndr_integer();
|
|
||||||
}
|
|
||||||
|
|
||||||
int start, end;
|
|
||||||
for (int k = 0; k < num_parts; ++k)
|
|
||||||
{
|
|
||||||
start = parts[k];
|
|
||||||
if (k == num_parts - 1)
|
|
||||||
{
|
|
||||||
end = num_points;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
end = parts[k + 1];
|
|
||||||
}
|
|
||||||
|
|
||||||
double x = record.read_double();
|
|
||||||
double y = record.read_double();
|
|
||||||
line->move_to(x, y);
|
|
||||||
|
|
||||||
for (int j = start + 1; j < end; ++j)
|
|
||||||
{
|
|
||||||
x = record.read_double();
|
|
||||||
y = record.read_double();
|
|
||||||
line->line_to(x, y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// m-range
|
|
||||||
//double m0=record.read_double();
|
|
||||||
//double m1=record.read_double();
|
|
||||||
|
|
||||||
//for (int i=0;i<num_points;++i)
|
|
||||||
//{
|
|
||||||
// double m=record.read_double();
|
|
||||||
//}
|
|
||||||
|
|
||||||
return line;
|
|
||||||
}
|
|
||||||
|
|
||||||
geometry_type* shape_io::read_polylinez()
|
|
||||||
{
|
|
||||||
shape_file::record_type record(reclength_ * 2 - 36);
|
|
||||||
shp_.read_record(record);
|
|
||||||
|
|
||||||
int num_parts = record.read_ndr_integer();
|
|
||||||
int num_points = record.read_ndr_integer();
|
|
||||||
geometry_type* line = new geometry_type(mapnik::LineString);
|
|
||||||
line->set_capacity(num_points + num_parts);
|
|
||||||
if (num_parts == 1)
|
|
||||||
{
|
|
||||||
record.skip(4);
|
|
||||||
double x = record.read_double();
|
|
||||||
double y = record.read_double();
|
|
||||||
line->move_to(x, y);
|
|
||||||
for (int i = 1; i < num_points; ++i)
|
|
||||||
{
|
|
||||||
x = record.read_double();
|
|
||||||
y = record.read_double();
|
|
||||||
line->line_to(x, y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::vector<int> parts(num_parts);
|
|
||||||
for (int i = 0; i < num_parts; ++i)
|
|
||||||
{
|
|
||||||
parts[i] = record.read_ndr_integer();
|
|
||||||
}
|
|
||||||
|
|
||||||
int start, end;
|
|
||||||
for (int k = 0; k < num_parts; ++k)
|
|
||||||
{
|
|
||||||
start = parts[k];
|
|
||||||
if (k == num_parts - 1)
|
|
||||||
{
|
|
||||||
end = num_points;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
end = parts[k + 1];
|
|
||||||
}
|
|
||||||
|
|
||||||
double x = record.read_double();
|
|
||||||
double y = record.read_double();
|
|
||||||
line->move_to(x, y);
|
|
||||||
|
|
||||||
for (int j = start + 1; j < end; ++j)
|
|
||||||
{
|
|
||||||
x = record.read_double();
|
|
||||||
y = record.read_double();
|
|
||||||
line->line_to(x, y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// z-range
|
// z-range
|
||||||
//double z0=record.read_double();
|
//double z0=record.read_double();
|
||||||
//double z1=record.read_double();
|
//double z1=record.read_double();
|
||||||
|
@ -306,10 +180,9 @@ geometry_type* shape_io::read_polylinez()
|
||||||
// double m=record.read_double();
|
// double m=record.read_double();
|
||||||
//}
|
//}
|
||||||
|
|
||||||
return line;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
geometry_type* shape_io::read_polygon()
|
void shape_io::read_polygon(mapnik::geometry_container & geom)
|
||||||
{
|
{
|
||||||
shape_file::record_type record(reclength_ * 2 - 36);
|
shape_file::record_type record(reclength_ * 2 - 36);
|
||||||
shp_.read_record(record);
|
shp_.read_record(record);
|
||||||
|
@ -317,8 +190,7 @@ geometry_type* shape_io::read_polygon()
|
||||||
int num_parts = record.read_ndr_integer();
|
int num_parts = record.read_ndr_integer();
|
||||||
int num_points = record.read_ndr_integer();
|
int num_points = record.read_ndr_integer();
|
||||||
std::vector<int> parts(num_parts);
|
std::vector<int> parts(num_parts);
|
||||||
geometry_type* poly = new geometry_type(mapnik::Polygon);
|
|
||||||
poly->set_capacity(num_points + num_parts);
|
|
||||||
for (int i = 0; i < num_parts; ++i)
|
for (int i = 0; i < num_parts; ++i)
|
||||||
{
|
{
|
||||||
parts[i] = record.read_ndr_integer();
|
parts[i] = record.read_ndr_integer();
|
||||||
|
@ -326,6 +198,7 @@ geometry_type* shape_io::read_polygon()
|
||||||
|
|
||||||
for (int k = 0; k < num_parts; k++)
|
for (int k = 0; k < num_parts; k++)
|
||||||
{
|
{
|
||||||
|
geometry_type* poly = new geometry_type(mapnik::Polygon);
|
||||||
int start = parts[k];
|
int start = parts[k];
|
||||||
int end;
|
int end;
|
||||||
if (k == num_parts - 1)
|
if (k == num_parts - 1)
|
||||||
|
@ -347,101 +220,8 @@ geometry_type* shape_io::read_polygon()
|
||||||
y = record.read_double();
|
y = record.read_double();
|
||||||
poly->line_to(x, y);
|
poly->line_to(x, y);
|
||||||
}
|
}
|
||||||
|
geom.push_back(poly);
|
||||||
}
|
}
|
||||||
return poly;
|
|
||||||
}
|
|
||||||
|
|
||||||
geometry_type* shape_io::read_polygonm()
|
|
||||||
{
|
|
||||||
shape_file::record_type record(reclength_ * 2 - 36);
|
|
||||||
shp_.read_record(record);
|
|
||||||
|
|
||||||
int num_parts = record.read_ndr_integer();
|
|
||||||
int num_points = record.read_ndr_integer();
|
|
||||||
std::vector<int> parts(num_parts);
|
|
||||||
geometry_type* poly = new geometry_type(mapnik::Polygon);
|
|
||||||
poly->set_capacity(num_points + num_parts);
|
|
||||||
for (int i = 0; i < num_parts; ++i)
|
|
||||||
{
|
|
||||||
parts[i] = record.read_ndr_integer();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int k = 0; k < num_parts; k++)
|
|
||||||
{
|
|
||||||
int start = parts[k];
|
|
||||||
int end;
|
|
||||||
if (k == num_parts - 1)
|
|
||||||
{
|
|
||||||
end = num_points;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
end = parts[k + 1];
|
|
||||||
}
|
|
||||||
|
|
||||||
double x = record.read_double();
|
|
||||||
double y = record.read_double();
|
|
||||||
poly->move_to(x, y);
|
|
||||||
|
|
||||||
for (int j = start + 1; j < end; j++)
|
|
||||||
{
|
|
||||||
x = record.read_double();
|
|
||||||
y = record.read_double();
|
|
||||||
poly->line_to(x, y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// m-range
|
|
||||||
//double m0=record.read_double();
|
|
||||||
//double m1=record.read_double();
|
|
||||||
|
|
||||||
//for (int i=0;i<num_points;++i)
|
|
||||||
//{
|
|
||||||
// double m=record.read_double();
|
|
||||||
//}
|
|
||||||
return poly;
|
|
||||||
}
|
|
||||||
|
|
||||||
geometry_type* shape_io::read_polygonz()
|
|
||||||
{
|
|
||||||
shape_file::record_type record(reclength_ * 2 - 36);
|
|
||||||
shp_.read_record(record);
|
|
||||||
|
|
||||||
int num_parts = record.read_ndr_integer();
|
|
||||||
int num_points = record.read_ndr_integer();
|
|
||||||
std::vector<int> parts(num_parts);
|
|
||||||
geometry_type* poly = new geometry_type(mapnik::Polygon);
|
|
||||||
poly->set_capacity(num_points + num_parts);
|
|
||||||
for (int i = 0; i < num_parts; ++i)
|
|
||||||
{
|
|
||||||
parts[i] = record.read_ndr_integer();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int k = 0; k < num_parts; k++)
|
|
||||||
{
|
|
||||||
int start = parts[k];
|
|
||||||
int end;
|
|
||||||
if (k == num_parts - 1)
|
|
||||||
{
|
|
||||||
end = num_points;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
end = parts[k + 1];
|
|
||||||
}
|
|
||||||
|
|
||||||
double x = record.read_double();
|
|
||||||
double y = record.read_double();
|
|
||||||
poly->move_to(x, y);
|
|
||||||
|
|
||||||
for (int j = start + 1; j < end; j++)
|
|
||||||
{
|
|
||||||
x = record.read_double();
|
|
||||||
y = record.read_double();
|
|
||||||
poly->line_to(x, y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// z-range
|
// z-range
|
||||||
//double z0=record.read_double();
|
//double z0=record.read_double();
|
||||||
//double z1=record.read_double();
|
//double z1=record.read_double();
|
||||||
|
@ -458,6 +238,6 @@ geometry_type* shape_io::read_polygonz()
|
||||||
//{
|
//{
|
||||||
// double m=record.read_double();
|
// double m=record.read_double();
|
||||||
//}
|
//}
|
||||||
|
|
||||||
return poly;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
#ifndef SHAPE_IO_HPP
|
#ifndef SHAPE_IO_HPP
|
||||||
#define SHAPE_IO_HPP
|
#define SHAPE_IO_HPP
|
||||||
|
|
||||||
|
// mapnik
|
||||||
|
#include <mapnik/geometry.hpp>
|
||||||
// boost
|
// boost
|
||||||
#include <boost/utility.hpp>
|
#include <boost/utility.hpp>
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
|
@ -56,7 +58,6 @@ public:
|
||||||
~shape_io();
|
~shape_io();
|
||||||
|
|
||||||
shape_file& shp();
|
shape_file& shp();
|
||||||
//shape_file& shx();
|
|
||||||
dbf_file& dbf();
|
dbf_file& dbf();
|
||||||
|
|
||||||
inline boost::shared_ptr<shape_file>& index()
|
inline boost::shared_ptr<shape_file>& index()
|
||||||
|
@ -72,16 +73,10 @@ public:
|
||||||
void move_to(int id);
|
void move_to(int id);
|
||||||
int type() const;
|
int type() const;
|
||||||
const box2d<double>& current_extent() const;
|
const box2d<double>& current_extent() const;
|
||||||
mapnik::geometry_type* read_polyline();
|
void read_polyline(mapnik::geometry_container & geom);
|
||||||
mapnik::geometry_type* read_polylinem();
|
void read_polygon(mapnik::geometry_container & geom);
|
||||||
mapnik::geometry_type* read_polylinez();
|
|
||||||
mapnik::geometry_type* read_polygon();
|
|
||||||
mapnik::geometry_type* read_polygonm();
|
|
||||||
mapnik::geometry_type* read_polygonz();
|
|
||||||
|
|
||||||
unsigned type_;
|
unsigned type_;
|
||||||
shape_file shp_;
|
shape_file shp_;
|
||||||
//shape_file shx_;
|
|
||||||
dbf_file dbf_;
|
dbf_file dbf_;
|
||||||
boost::shared_ptr<shape_file> index_;
|
boost::shared_ptr<shape_file> index_;
|
||||||
unsigned reclength_;
|
unsigned reclength_;
|
||||||
|
@ -89,7 +84,6 @@ public:
|
||||||
box2d<double> cur_extent_;
|
box2d<double> cur_extent_;
|
||||||
|
|
||||||
static const std::string SHP;
|
static const std::string SHP;
|
||||||
//static const std::string SHX;
|
|
||||||
static const std::string DBF;
|
static const std::string DBF;
|
||||||
static const std::string INDEX;
|
static const std::string INDEX;
|
||||||
};
|
};
|
||||||
|
|
|
@ -62,6 +62,7 @@ sqlite_datasource::sqlite_datasource(parameters const& params, bool bind)
|
||||||
key_field_(*params_.get<std::string>("key_field", "")),
|
key_field_(*params_.get<std::string>("key_field", "")),
|
||||||
row_offset_(*params_.get<int>("row_offset", 0)),
|
row_offset_(*params_.get<int>("row_offset", 0)),
|
||||||
row_limit_(*params_.get<int>("row_limit", 0)),
|
row_limit_(*params_.get<int>("row_limit", 0)),
|
||||||
|
intersects_token_("!intersects!"),
|
||||||
desc_(*params_.get<std::string>("type"), *params_.get<std::string>("encoding", "utf-8")),
|
desc_(*params_.get<std::string>("type"), *params_.get<std::string>("encoding", "utf-8")),
|
||||||
format_(mapnik::wkbAuto)
|
format_(mapnik::wkbAuto)
|
||||||
{
|
{
|
||||||
|
@ -102,7 +103,6 @@ void sqlite_datasource::bind() const
|
||||||
throw datasource_exception("Sqlite Plugin: " + dataset_name_ + " does not exist");
|
throw datasource_exception("Sqlite Plugin: " + dataset_name_ + " does not exist");
|
||||||
}
|
}
|
||||||
|
|
||||||
multiple_geometries_ = *params_.get<mapnik::boolean>("multiple_geometries", false);
|
|
||||||
use_spatial_index_ = *params_.get<mapnik::boolean>("use_spatial_index", true);
|
use_spatial_index_ = *params_.get<mapnik::boolean>("use_spatial_index", true);
|
||||||
|
|
||||||
// TODO - remove this option once all datasources have an indexing api
|
// TODO - remove this option once all datasources have an indexing api
|
||||||
|
@ -186,7 +186,8 @@ void sqlite_datasource::bind() const
|
||||||
if (using_subquery_)
|
if (using_subquery_)
|
||||||
{
|
{
|
||||||
std::ostringstream s;
|
std::ostringstream s;
|
||||||
s << "SELECT " << fields_ << " FROM (" << table_ << ") LIMIT 1";
|
std::string query = populate_tokens(table_);
|
||||||
|
s << "SELECT " << fields_ << " FROM (" << query << ") LIMIT 1";
|
||||||
found_types_via_subquery = sqlite_utils::detect_types_from_subquery(s.str(),geometry_field_,desc_,dataset_);
|
found_types_via_subquery = sqlite_utils::detect_types_from_subquery(s.str(),geometry_field_,desc_,dataset_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,7 +226,12 @@ void sqlite_datasource::bind() const
|
||||||
|
|
||||||
if (geometry_field_.empty())
|
if (geometry_field_.empty())
|
||||||
{
|
{
|
||||||
throw datasource_exception("Sqlite Plugin: cannot detect geometry_field, please supply the name of the geometry_field to use.");
|
std::ostringstream s;
|
||||||
|
s << "Sqlite Plugin: unable to detect the column "
|
||||||
|
<< "containing a valid geometry on table '" << geometry_table_ << "'. "
|
||||||
|
<< "Please provide a column name by passing the 'geometry_field' option "
|
||||||
|
<< "or indicate a different spatial table to use by passing the 'geometry_table' option";
|
||||||
|
throw datasource_exception(s.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index_table_.empty())
|
if (index_table_.empty())
|
||||||
|
@ -302,6 +308,7 @@ void sqlite_datasource::bind() const
|
||||||
{
|
{
|
||||||
|
|
||||||
// TODO - clean this up - reducing arguments
|
// TODO - clean this up - reducing arguments
|
||||||
|
std::string query = populate_tokens(table_);
|
||||||
if (!sqlite_utils::detect_extent(dataset_,
|
if (!sqlite_utils::detect_extent(dataset_,
|
||||||
has_spatial_index_,
|
has_spatial_index_,
|
||||||
extent_,
|
extent_,
|
||||||
|
@ -310,7 +317,7 @@ void sqlite_datasource::bind() const
|
||||||
geometry_field_,
|
geometry_field_,
|
||||||
geometry_table_,
|
geometry_table_,
|
||||||
key_field_,
|
key_field_,
|
||||||
table_))
|
query))
|
||||||
{
|
{
|
||||||
std::ostringstream s;
|
std::ostringstream s;
|
||||||
s << "Sqlite Plugin: extent could not be determined for table '"
|
s << "Sqlite Plugin: extent could not be determined for table '"
|
||||||
|
@ -324,6 +331,17 @@ void sqlite_datasource::bind() const
|
||||||
is_bound_ = true;
|
is_bound_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string sqlite_datasource::populate_tokens(const std::string& sql) const
|
||||||
|
{
|
||||||
|
std::string populated_sql = sql;
|
||||||
|
if (boost::algorithm::ifind_first(populated_sql, intersects_token_))
|
||||||
|
{
|
||||||
|
// replace with dummy comparison that is true
|
||||||
|
boost::algorithm::ireplace_first(populated_sql, intersects_token_, "1=1");
|
||||||
|
}
|
||||||
|
return populated_sql;
|
||||||
|
}
|
||||||
|
|
||||||
sqlite_datasource::~sqlite_datasource()
|
sqlite_datasource::~sqlite_datasource()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -461,23 +479,21 @@ featureset_ptr sqlite_datasource::features(query const& q) const
|
||||||
|
|
||||||
s << " FROM ";
|
s << " FROM ";
|
||||||
|
|
||||||
std::string query (table_);
|
std::string query(table_);
|
||||||
|
|
||||||
if (! key_field_.empty() && has_spatial_index_)
|
if (! key_field_.empty() && has_spatial_index_)
|
||||||
{
|
{
|
||||||
std::ostringstream spatial_sql;
|
// TODO - debug warn if fails
|
||||||
spatial_sql << std::setprecision(16);
|
sqlite_utils::apply_spatial_filter(query,
|
||||||
spatial_sql << " WHERE " << key_field_ << " IN (SELECT pkid FROM " << index_table_;
|
e,
|
||||||
spatial_sql << " WHERE xmax>=" << e.minx() << " AND xmin<=" << e.maxx() ;
|
table_,
|
||||||
spatial_sql << " AND ymax>=" << e.miny() << " AND ymin<=" << e.maxy() << ")";
|
key_field_,
|
||||||
if (boost::algorithm::ifind_first(query, "WHERE"))
|
index_table_,
|
||||||
|
geometry_table_,
|
||||||
|
intersects_token_); }
|
||||||
|
else
|
||||||
{
|
{
|
||||||
boost::algorithm::ireplace_first(query, "WHERE", spatial_sql.str() + " AND ");
|
query = populate_tokens(table_);
|
||||||
}
|
|
||||||
else if (boost::algorithm::ifind_first(query, geometry_table_))
|
|
||||||
{
|
|
||||||
boost::algorithm::ireplace_first(query, table_, table_ + " " + spatial_sql.str());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
s << query ;
|
s << query ;
|
||||||
|
@ -502,7 +518,6 @@ featureset_ptr sqlite_datasource::features(query const& q) const
|
||||||
return boost::make_shared<sqlite_featureset>(rs,
|
return boost::make_shared<sqlite_featureset>(rs,
|
||||||
desc_.get_encoding(),
|
desc_.get_encoding(),
|
||||||
format_,
|
format_,
|
||||||
multiple_geometries_,
|
|
||||||
using_subquery_);
|
using_subquery_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -541,19 +556,18 @@ featureset_ptr sqlite_datasource::features_at_point(coord2d const& pt) const
|
||||||
|
|
||||||
if (! key_field_.empty() && has_spatial_index_)
|
if (! key_field_.empty() && has_spatial_index_)
|
||||||
{
|
{
|
||||||
std::ostringstream spatial_sql;
|
// TODO - debug warn if fails
|
||||||
spatial_sql << std::setprecision(16);
|
sqlite_utils::apply_spatial_filter(query,
|
||||||
spatial_sql << " WHERE " << key_field_ << " IN (SELECT pkid FROM " << index_table_;
|
e,
|
||||||
spatial_sql << " WHERE xmax>=" << e.minx() << " AND xmin<=" << e.maxx() ;
|
table_,
|
||||||
spatial_sql << " AND ymax>=" << e.miny() << " AND ymin<=" << e.maxy() << ")";
|
key_field_,
|
||||||
if (boost::algorithm::ifind_first(query, "WHERE"))
|
index_table_,
|
||||||
{
|
geometry_table_,
|
||||||
boost::algorithm::ireplace_first(query, "WHERE", spatial_sql.str() + " AND ");
|
intersects_token_);
|
||||||
}
|
}
|
||||||
else if (boost::algorithm::ifind_first(query, geometry_table_))
|
else
|
||||||
{
|
{
|
||||||
boost::algorithm::ireplace_first(query, table_, table_ + " " + spatial_sql.str());
|
query = populate_tokens(table_);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
s << query ;
|
s << query ;
|
||||||
|
@ -577,7 +591,6 @@ featureset_ptr sqlite_datasource::features_at_point(coord2d const& pt) const
|
||||||
return boost::make_shared<sqlite_featureset>(rs,
|
return boost::make_shared<sqlite_featureset>(rs,
|
||||||
desc_.get_encoding(),
|
desc_.get_encoding(),
|
||||||
format_,
|
format_,
|
||||||
multiple_geometries_,
|
|
||||||
using_subquery_);
|
using_subquery_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,11 @@ public:
|
||||||
void bind() const;
|
void bind() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
// FIXME: remove mutable qualifier from data members
|
||||||
|
// by factoring out bind() logic out from
|
||||||
|
// datasource impl !!!
|
||||||
|
|
||||||
mutable mapnik::box2d<double> extent_;
|
mutable mapnik::box2d<double> extent_;
|
||||||
mutable bool extent_initialized_;
|
mutable bool extent_initialized_;
|
||||||
int type_;
|
int type_;
|
||||||
|
@ -65,9 +70,10 @@ private:
|
||||||
mutable std::string key_field_;
|
mutable std::string key_field_;
|
||||||
mutable int row_offset_;
|
mutable int row_offset_;
|
||||||
mutable int row_limit_;
|
mutable int row_limit_;
|
||||||
|
// TODO - also add to postgis.input
|
||||||
|
const std::string intersects_token_;
|
||||||
mutable mapnik::layer_descriptor desc_;
|
mutable mapnik::layer_descriptor desc_;
|
||||||
mutable mapnik::wkbFormat format_;
|
mutable mapnik::wkbFormat format_;
|
||||||
mutable bool multiple_geometries_;
|
|
||||||
mutable bool use_spatial_index_;
|
mutable bool use_spatial_index_;
|
||||||
mutable bool has_spatial_index_;
|
mutable bool has_spatial_index_;
|
||||||
mutable bool using_subquery_;
|
mutable bool using_subquery_;
|
||||||
|
@ -76,6 +82,7 @@ private:
|
||||||
// Fill init_statements with any statements
|
// Fill init_statements with any statements
|
||||||
// needed to attach auxillary databases
|
// needed to attach auxillary databases
|
||||||
void parse_attachdb(std::string const& attachdb) const;
|
void parse_attachdb(std::string const& attachdb) const;
|
||||||
|
std::string populate_tokens(const std::string& sql) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAPNIK_SQLITE_DATASOURCE_HPP
|
#endif // MAPNIK_SQLITE_DATASOURCE_HPP
|
||||||
|
|
|
@ -47,12 +47,10 @@ using mapnik::feature_factory;
|
||||||
sqlite_featureset::sqlite_featureset(boost::shared_ptr<sqlite_resultset> rs,
|
sqlite_featureset::sqlite_featureset(boost::shared_ptr<sqlite_resultset> rs,
|
||||||
std::string const& encoding,
|
std::string const& encoding,
|
||||||
mapnik::wkbFormat format,
|
mapnik::wkbFormat format,
|
||||||
bool multiple_geometries,
|
|
||||||
bool using_subquery)
|
bool using_subquery)
|
||||||
: rs_(rs),
|
: rs_(rs),
|
||||||
tr_(new transcoder(encoding)),
|
tr_(new transcoder(encoding)),
|
||||||
format_(format),
|
format_(format),
|
||||||
multiple_geometries_(multiple_geometries),
|
|
||||||
using_subquery_(using_subquery)
|
using_subquery_(using_subquery)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -75,7 +73,7 @@ feature_ptr sqlite_featureset::next()
|
||||||
int feature_id = rs_->column_integer(1);
|
int feature_id = rs_->column_integer(1);
|
||||||
|
|
||||||
feature_ptr feature(feature_factory::create(feature_id));
|
feature_ptr feature(feature_factory::create(feature_id));
|
||||||
geometry_utils::from_wkb(feature->paths(), data, size, multiple_geometries_, format_);
|
geometry_utils::from_wkb(feature->paths(), data, size, format_);
|
||||||
|
|
||||||
for (int i = 2; i < rs_->column_count(); ++i)
|
for (int i = 2; i < rs_->column_count(); ++i)
|
||||||
{
|
{
|
||||||
|
|
|
@ -42,7 +42,6 @@ public:
|
||||||
sqlite_featureset(boost::shared_ptr<sqlite_resultset> rs,
|
sqlite_featureset(boost::shared_ptr<sqlite_resultset> rs,
|
||||||
std::string const& encoding,
|
std::string const& encoding,
|
||||||
mapnik::wkbFormat format,
|
mapnik::wkbFormat format,
|
||||||
bool multiple_geometries,
|
|
||||||
bool using_subquery);
|
bool using_subquery);
|
||||||
virtual ~sqlite_featureset();
|
virtual ~sqlite_featureset();
|
||||||
mapnik::feature_ptr next();
|
mapnik::feature_ptr next();
|
||||||
|
@ -51,7 +50,6 @@ private:
|
||||||
boost::shared_ptr<sqlite_resultset> rs_;
|
boost::shared_ptr<sqlite_resultset> rs_;
|
||||||
boost::scoped_ptr<mapnik::transcoder> tr_;
|
boost::scoped_ptr<mapnik::transcoder> tr_;
|
||||||
mapnik::wkbFormat format_;
|
mapnik::wkbFormat format_;
|
||||||
bool multiple_geometries_;
|
|
||||||
bool using_subquery_;
|
bool using_subquery_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -108,6 +108,42 @@ public:
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool apply_spatial_filter(std::string & query,
|
||||||
|
mapnik::box2d<double> const& e,
|
||||||
|
std::string const& table,
|
||||||
|
std::string const& key_field,
|
||||||
|
std::string const& index_table,
|
||||||
|
std::string const& geometry_table,
|
||||||
|
std::string const& intersects_token)
|
||||||
|
{
|
||||||
|
std::ostringstream spatial_sql;
|
||||||
|
spatial_sql << std::setprecision(16);
|
||||||
|
spatial_sql << key_field << " IN (SELECT pkid FROM " << index_table;
|
||||||
|
spatial_sql << " WHERE xmax>=" << e.minx() << " AND xmin<=" << e.maxx() ;
|
||||||
|
spatial_sql << " AND ymax>=" << e.miny() << " AND ymin<=" << e.maxy() << ")";
|
||||||
|
if (boost::algorithm::ifind_first(query, intersects_token))
|
||||||
|
{
|
||||||
|
boost::algorithm::ireplace_all(query, intersects_token, spatial_sql.str());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// substitute first WHERE found if not using JOIN
|
||||||
|
// (because we can't know the WHERE is on the right table)
|
||||||
|
else if (boost::algorithm::ifind_first(query, "WHERE")
|
||||||
|
&& !boost::algorithm::ifind_first(query, "JOIN"))
|
||||||
|
{
|
||||||
|
std::string replace(" WHERE " + spatial_sql.str() + " AND ");
|
||||||
|
boost::algorithm::ireplace_first(query, "WHERE", replace);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// fallback to appending spatial filter at end of query
|
||||||
|
else if (boost::algorithm::ifind_first(query, geometry_table))
|
||||||
|
{
|
||||||
|
query = table + " WHERE " + spatial_sql.str();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static void get_tables(boost::shared_ptr<sqlite_connection> ds,
|
static void get_tables(boost::shared_ptr<sqlite_connection> ds,
|
||||||
std::vector<std::string> & tables)
|
std::vector<std::string> & tables)
|
||||||
{
|
{
|
||||||
|
@ -151,11 +187,11 @@ public:
|
||||||
while (rs->is_valid() && rs->step_next())
|
while (rs->is_valid() && rs->step_next())
|
||||||
{
|
{
|
||||||
int size;
|
int size;
|
||||||
const char* data = (const char*) rs->column_blob(0, size);
|
const char* data = static_cast<const char*>(rs->column_blob(0, size));
|
||||||
if (data)
|
if (data)
|
||||||
{
|
{
|
||||||
boost::ptr_vector<mapnik::geometry_type> paths;
|
boost::ptr_vector<mapnik::geometry_type> paths;
|
||||||
mapnik::geometry_utils::from_wkb(paths, data, size, false, mapnik::wkbAuto);
|
mapnik::geometry_utils::from_wkb(paths, data, size, mapnik::wkbAuto);
|
||||||
for (unsigned i=0; i<paths.size(); ++i)
|
for (unsigned i=0; i<paths.size(); ++i)
|
||||||
{
|
{
|
||||||
mapnik::box2d<double> const& bbox = paths[i].envelope();
|
mapnik::box2d<double> const& bbox = paths[i].envelope();
|
||||||
|
@ -241,12 +277,19 @@ public:
|
||||||
if (data)
|
if (data)
|
||||||
{
|
{
|
||||||
boost::ptr_vector<mapnik::geometry_type> paths;
|
boost::ptr_vector<mapnik::geometry_type> paths;
|
||||||
// TODO - contraint fails if multiple_geometries = true
|
mapnik::geometry_utils::from_wkb(paths, data, size, mapnik::wkbAuto);
|
||||||
bool multiple_geometries = false;
|
mapnik::box2d<double> bbox;
|
||||||
mapnik::geometry_utils::from_wkb(paths, data, size, multiple_geometries, mapnik::wkbAuto);
|
|
||||||
for (unsigned i=0; i<paths.size(); ++i)
|
for (unsigned i=0; i<paths.size(); ++i)
|
||||||
{
|
{
|
||||||
mapnik::box2d<double> const& bbox = paths[i].envelope();
|
if (i==0)
|
||||||
|
{
|
||||||
|
bbox = paths[i].envelope();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bbox.expand_to_include(paths[i].envelope());
|
||||||
|
}
|
||||||
|
}
|
||||||
if (bbox.valid())
|
if (bbox.valid())
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -278,7 +321,6 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (mapnik::datasource_exception const& ex)
|
catch (mapnik::datasource_exception const& ex)
|
||||||
{
|
{
|
||||||
if (!existed)
|
if (!existed)
|
||||||
|
@ -320,13 +362,11 @@ public:
|
||||||
while (rs->is_valid() && rs->step_next())
|
while (rs->is_valid() && rs->step_next())
|
||||||
{
|
{
|
||||||
int size;
|
int size;
|
||||||
const char* data = (const char*) rs->column_blob(0, size);
|
const char* data = static_cast<const char*>(rs->column_blob(0, size));
|
||||||
if (data)
|
if (data)
|
||||||
{
|
{
|
||||||
boost::ptr_vector<mapnik::geometry_type> paths;
|
boost::ptr_vector<mapnik::geometry_type> paths;
|
||||||
// TODO - contraint fails if multiple_geometries = true
|
mapnik::geometry_utils::from_wkb(paths, data, size, mapnik::wkbAuto);
|
||||||
bool multiple_geometries = false;
|
|
||||||
mapnik::geometry_utils::from_wkb(paths, data, size, multiple_geometries, mapnik::wkbAuto);
|
|
||||||
for (unsigned i=0; i<paths.size(); ++i)
|
for (unsigned i=0; i<paths.size(); ++i)
|
||||||
{
|
{
|
||||||
mapnik::box2d<double> const& bbox = paths[i].envelope();
|
mapnik::box2d<double> const& bbox = paths[i].envelope();
|
||||||
|
@ -568,6 +608,7 @@ public:
|
||||||
// PRAGMA table_info is used so here we assume the column is a string
|
// PRAGMA table_info is used so here we assume the column is a string
|
||||||
// which is a lesser evil than altogether dropping the column
|
// which is a lesser evil than altogether dropping the column
|
||||||
desc.add_descriptor(mapnik::attribute_descriptor(fld_name, mapnik::String));
|
desc.add_descriptor(mapnik::attribute_descriptor(fld_name, mapnik::String));
|
||||||
|
break;
|
||||||
|
|
||||||
case SQLITE_BLOB:
|
case SQLITE_BLOB:
|
||||||
if (geometry_field.empty()
|
if (geometry_field.empty()
|
||||||
|
|
|
@ -44,7 +44,7 @@ void agg_renderer<T>::process(text_symbolizer const& sym,
|
||||||
|
|
||||||
if (geom.num_points() == 0) continue; // don't bother with empty geometries
|
if (geom.num_points() == 0) continue; // don't bother with empty geometries
|
||||||
|
|
||||||
if ((geom.type() == Polygon || geom.type() == MultiPolygon) && sym.get_minimum_path_length() > 0)
|
if ((geom.type() == Polygon) && sym.get_minimum_path_length() > 0)
|
||||||
{
|
{
|
||||||
// TODO - find less costly method than fetching full envelope
|
// TODO - find less costly method than fetching full envelope
|
||||||
box2d<double> gbox = t_.forward(geom.envelope(),prj_trans);
|
box2d<double> gbox = t_.forward(geom.envelope(),prj_trans);
|
||||||
|
|
|
@ -37,8 +37,6 @@ namespace mapnik
|
||||||
{
|
{
|
||||||
layer::layer(std::string const& name, std::string const& srs)
|
layer::layer(std::string const& name, std::string const& srs)
|
||||||
: name_(name),
|
: name_(name),
|
||||||
title_(""),
|
|
||||||
abstract_(""),
|
|
||||||
srs_(srs),
|
srs_(srs),
|
||||||
minZoom_(0),
|
minZoom_(0),
|
||||||
maxZoom_(std::numeric_limits<double>::max()),
|
maxZoom_(std::numeric_limits<double>::max()),
|
||||||
|
@ -51,8 +49,6 @@ layer::layer(std::string const& name, std::string const& srs)
|
||||||
|
|
||||||
layer::layer(const layer& rhs)
|
layer::layer(const layer& rhs)
|
||||||
: name_(rhs.name_),
|
: name_(rhs.name_),
|
||||||
title_(rhs.title_),
|
|
||||||
abstract_(rhs.abstract_),
|
|
||||||
srs_(rhs.srs_),
|
srs_(rhs.srs_),
|
||||||
minZoom_(rhs.minZoom_),
|
minZoom_(rhs.minZoom_),
|
||||||
maxZoom_(rhs.maxZoom_),
|
maxZoom_(rhs.maxZoom_),
|
||||||
|
@ -79,8 +75,6 @@ bool layer::operator==(layer const& other) const
|
||||||
void layer::swap(const layer& rhs)
|
void layer::swap(const layer& rhs)
|
||||||
{
|
{
|
||||||
name_=rhs.name_;
|
name_=rhs.name_;
|
||||||
title_=rhs.title_;
|
|
||||||
abstract_=rhs.abstract_;
|
|
||||||
srs_ = rhs.srs_;
|
srs_ = rhs.srs_;
|
||||||
minZoom_=rhs.minZoom_;
|
minZoom_=rhs.minZoom_;
|
||||||
maxZoom_=rhs.maxZoom_;
|
maxZoom_=rhs.maxZoom_;
|
||||||
|
@ -105,26 +99,6 @@ std::string const& layer::name() const
|
||||||
return name_;
|
return name_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void layer::set_title( std::string const& title)
|
|
||||||
{
|
|
||||||
title_ = title;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string const& layer::title() const
|
|
||||||
{
|
|
||||||
return title_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void layer::set_abstract( std::string const& abstract)
|
|
||||||
{
|
|
||||||
abstract_ = abstract;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string const& layer::abstract() const
|
|
||||||
{
|
|
||||||
return abstract_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void layer::set_srs(std::string const& srs)
|
void layer::set_srs(std::string const& srs)
|
||||||
{
|
{
|
||||||
srs_ = srs;
|
srs_ = srs;
|
||||||
|
|
|
@ -577,8 +577,6 @@ void map_parser::parse_layer( Map & map, ptree const & lay )
|
||||||
s << "name,"
|
s << "name,"
|
||||||
<< "srs,"
|
<< "srs,"
|
||||||
<< "status,"
|
<< "status,"
|
||||||
<< "title,"
|
|
||||||
<< "abstract,"
|
|
||||||
<< "minzoom,"
|
<< "minzoom,"
|
||||||
<< "maxzoom,"
|
<< "maxzoom,"
|
||||||
<< "queryable,"
|
<< "queryable,"
|
||||||
|
@ -601,18 +599,6 @@ void map_parser::parse_layer( Map & map, ptree const & lay )
|
||||||
lyr.setActive( * status );
|
lyr.setActive( * status );
|
||||||
}
|
}
|
||||||
|
|
||||||
optional<std::string> title = get_opt_attr<std::string>(lay, "title");
|
|
||||||
if (title)
|
|
||||||
{
|
|
||||||
lyr.set_title( * title );
|
|
||||||
}
|
|
||||||
|
|
||||||
optional<std::string> abstract = get_opt_attr<std::string>(lay, "abstract");
|
|
||||||
if (abstract)
|
|
||||||
{
|
|
||||||
lyr.set_abstract( * abstract );
|
|
||||||
}
|
|
||||||
|
|
||||||
optional<double> minZoom = get_opt_attr<double>(lay, "minzoom");
|
optional<double> minZoom = get_opt_attr<double>(lay, "minzoom");
|
||||||
if (minZoom)
|
if (minZoom)
|
||||||
{
|
{
|
||||||
|
@ -765,14 +751,12 @@ void map_parser::parse_layer( Map & map, ptree const & lay )
|
||||||
|
|
||||||
void map_parser::parse_rule( feature_type_style & style, ptree const & r )
|
void map_parser::parse_rule( feature_type_style & style, ptree const & r )
|
||||||
{
|
{
|
||||||
ensure_attrs(r, "Rule", "name,title");
|
ensure_attrs(r, "Rule", "name");
|
||||||
std::string name;
|
std::string name;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
name = get_attr( r, "name", std::string());
|
name = get_attr( r, "name", std::string());
|
||||||
std::string title = get_attr( r, "title", std::string());
|
rule rule(name);
|
||||||
|
|
||||||
rule rule(name,title);
|
|
||||||
|
|
||||||
optional<std::string> filter_expr =
|
optional<std::string> filter_expr =
|
||||||
get_opt_child<std::string>( r, "Filter");
|
get_opt_child<std::string>( r, "Filter");
|
||||||
|
|
|
@ -646,10 +646,6 @@ void serialize_rule( ptree & style_node, const rule & r, bool explicit_defaults)
|
||||||
{
|
{
|
||||||
set_attr(rule_node, "name", r.get_name());
|
set_attr(rule_node, "name", r.get_name());
|
||||||
}
|
}
|
||||||
if ( r.get_title() != dfl.get_title() )
|
|
||||||
{
|
|
||||||
set_attr(rule_node, "title", r.get_title());
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( r.has_else_filter() )
|
if ( r.has_else_filter() )
|
||||||
{
|
{
|
||||||
|
@ -814,21 +810,12 @@ void serialize_layer( ptree & map_node, const layer & layer, bool explicit_defau
|
||||||
{
|
{
|
||||||
ptree & layer_node = map_node.push_back(
|
ptree & layer_node = map_node.push_back(
|
||||||
ptree::value_type("Layer", ptree()))->second;
|
ptree::value_type("Layer", ptree()))->second;
|
||||||
|
|
||||||
if ( layer.name() != "" )
|
if ( layer.name() != "" )
|
||||||
{
|
{
|
||||||
set_attr( layer_node, "name", layer.name() );
|
set_attr( layer_node, "name", layer.name() );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( layer.abstract() != "" )
|
|
||||||
{
|
|
||||||
set_attr( layer_node, "abstract", layer.abstract() );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( layer.title() != "" )
|
|
||||||
{
|
|
||||||
set_attr( layer_node, "title", layer.title() );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( layer.srs() != "" )
|
if ( layer.srs() != "" )
|
||||||
{
|
{
|
||||||
set_attr( layer_node, "srs", layer.srs() );
|
set_attr( layer_node, "srs", layer.srs() );
|
||||||
|
|
212
src/wkb.cpp
212
src/wkb.cpp
|
@ -115,15 +115,12 @@ public:
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
~wkb_reader() {}
|
void read(boost::ptr_vector<geometry_type> & paths)
|
||||||
|
|
||||||
void read_multi(boost::ptr_vector<geometry_type> & paths)
|
|
||||||
{
|
{
|
||||||
int type = read_integer();
|
int type = read_integer();
|
||||||
|
|
||||||
#ifdef MAPNIK_DEBUG_WKB
|
#ifdef MAPNIK_DEBUG_WKB
|
||||||
std::clog << "wkb_reader: read_multi "
|
std::clog << "wkb_reader: read " << wkb_geometry_type_string(type) << " " << type << std::endl;
|
||||||
<< wkb_geometry_type_string(type) << " " << type << std::endl;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
|
@ -175,63 +172,6 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void read(boost::ptr_vector<geometry_type> & paths)
|
|
||||||
{
|
|
||||||
int type = read_integer();
|
|
||||||
|
|
||||||
#ifdef MAPNIK_DEBUG_WKB
|
|
||||||
std::clog << "wkb_reader: read " << wkb_geometry_type_string(type) << " " << type << std::endl;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case wkbPoint:
|
|
||||||
read_point(paths);
|
|
||||||
break;
|
|
||||||
case wkbLineString:
|
|
||||||
read_linestring(paths);
|
|
||||||
break;
|
|
||||||
case wkbPolygon:
|
|
||||||
read_polygon(paths);
|
|
||||||
break;
|
|
||||||
case wkbMultiPoint:
|
|
||||||
read_multipoint_2(paths);
|
|
||||||
break;
|
|
||||||
case wkbMultiLineString:
|
|
||||||
read_multilinestring_2(paths);
|
|
||||||
break;
|
|
||||||
case wkbMultiPolygon:
|
|
||||||
read_multipolygon_2(paths);
|
|
||||||
break;
|
|
||||||
case wkbGeometryCollection:
|
|
||||||
read_collection_2(paths);
|
|
||||||
break;
|
|
||||||
case wkbPointZ:
|
|
||||||
read_point_xyz(paths);
|
|
||||||
break;
|
|
||||||
case wkbLineStringZ:
|
|
||||||
read_linestring_xyz(paths);
|
|
||||||
break;
|
|
||||||
case wkbPolygonZ:
|
|
||||||
read_polygon_xyz(paths);
|
|
||||||
break;
|
|
||||||
case wkbMultiPointZ:
|
|
||||||
read_multipoint_xyz_2(paths);
|
|
||||||
break;
|
|
||||||
case wkbMultiLineStringZ:
|
|
||||||
read_multilinestring_xyz_2(paths);
|
|
||||||
break;
|
|
||||||
case wkbMultiPolygonZ:
|
|
||||||
read_multipolygon_xyz_2(paths);
|
|
||||||
break;
|
|
||||||
case wkbGeometryCollectionZ:
|
|
||||||
read_collection_2(paths);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
int read_integer()
|
int read_integer()
|
||||||
|
@ -330,20 +270,6 @@ private:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void read_multipoint_2(boost::ptr_vector<geometry_type> & paths)
|
|
||||||
{
|
|
||||||
geometry_type* pt = new geometry_type(MultiPoint);
|
|
||||||
int num_points = read_integer();
|
|
||||||
for (int i = 0; i < num_points; ++i)
|
|
||||||
{
|
|
||||||
pos_ += 5;
|
|
||||||
double x = read_double();
|
|
||||||
double y = read_double();
|
|
||||||
pt->move_to(x, y);
|
|
||||||
}
|
|
||||||
paths.push_back(pt);
|
|
||||||
}
|
|
||||||
|
|
||||||
void read_point_xyz(boost::ptr_vector<geometry_type> & paths)
|
void read_point_xyz(boost::ptr_vector<geometry_type> & paths)
|
||||||
{
|
{
|
||||||
geometry_type* pt = new geometry_type(Point);
|
geometry_type* pt = new geometry_type(Point);
|
||||||
|
@ -364,22 +290,6 @@ private:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void read_multipoint_xyz_2(boost::ptr_vector<geometry_type> & paths)
|
|
||||||
{
|
|
||||||
geometry_type* pt = new geometry_type(MultiPoint);
|
|
||||||
int num_points = read_integer();
|
|
||||||
for (int i = 0; i < num_points; ++i)
|
|
||||||
{
|
|
||||||
pos_ += 5;
|
|
||||||
double x = read_double();
|
|
||||||
double y = read_double();
|
|
||||||
pos_ += 8; // double z = read_double();
|
|
||||||
pt->move_to(x, y);
|
|
||||||
}
|
|
||||||
paths.push_back(pt);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void read_linestring(boost::ptr_vector<geometry_type> & paths)
|
void read_linestring(boost::ptr_vector<geometry_type> & paths)
|
||||||
{
|
{
|
||||||
geometry_type* line = new geometry_type(LineString);
|
geometry_type* line = new geometry_type(LineString);
|
||||||
|
@ -405,28 +315,6 @@ private:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void read_multilinestring_2(boost::ptr_vector<geometry_type> & paths)
|
|
||||||
{
|
|
||||||
geometry_type* line = new geometry_type(MultiLineString);
|
|
||||||
int num_lines = read_integer();
|
|
||||||
unsigned capacity = 0;
|
|
||||||
for (int i = 0; i < num_lines; ++i)
|
|
||||||
{
|
|
||||||
pos_ += 5;
|
|
||||||
int num_points = read_integer();
|
|
||||||
capacity += num_points;
|
|
||||||
CoordinateArray ar(num_points);
|
|
||||||
read_coords(ar);
|
|
||||||
line->set_capacity(capacity);
|
|
||||||
line->move_to(ar[0].x, ar[0].y);
|
|
||||||
for (int j = 1; j < num_points; ++j)
|
|
||||||
{
|
|
||||||
line->line_to(ar[j].x, ar[j].y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
paths.push_back(line);
|
|
||||||
}
|
|
||||||
|
|
||||||
void read_linestring_xyz(boost::ptr_vector<geometry_type> & paths)
|
void read_linestring_xyz(boost::ptr_vector<geometry_type> & paths)
|
||||||
{
|
{
|
||||||
geometry_type* line = new geometry_type(LineString);
|
geometry_type* line = new geometry_type(LineString);
|
||||||
|
@ -452,28 +340,6 @@ private:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void read_multilinestring_xyz_2(boost::ptr_vector<geometry_type> & paths)
|
|
||||||
{
|
|
||||||
geometry_type* line = new geometry_type(MultiLineString);
|
|
||||||
int num_lines = read_integer();
|
|
||||||
unsigned capacity = 0;
|
|
||||||
for (int i = 0; i < num_lines; ++i)
|
|
||||||
{
|
|
||||||
pos_ += 5;
|
|
||||||
int num_points = read_integer();
|
|
||||||
capacity += num_points;
|
|
||||||
CoordinateArray ar(num_points);
|
|
||||||
read_coords_xyz(ar);
|
|
||||||
line->set_capacity(capacity);
|
|
||||||
line->move_to(ar[0].x, ar[0].y);
|
|
||||||
for (int j = 1; j < num_points; ++j)
|
|
||||||
{
|
|
||||||
line->line_to(ar[j].x, ar[j].y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
paths.push_back(line);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void read_polygon(boost::ptr_vector<geometry_type> & paths)
|
void read_polygon(boost::ptr_vector<geometry_type> & paths)
|
||||||
{
|
{
|
||||||
|
@ -506,33 +372,6 @@ private:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void read_multipolygon_2(boost::ptr_vector<geometry_type> & paths)
|
|
||||||
{
|
|
||||||
geometry_type* poly = new geometry_type(MultiPolygon);
|
|
||||||
int num_polys = read_integer();
|
|
||||||
unsigned capacity = 0;
|
|
||||||
for (int i = 0; i < num_polys; ++i)
|
|
||||||
{
|
|
||||||
pos_ += 5;
|
|
||||||
int num_rings = read_integer();
|
|
||||||
for (int r = 0; r < num_rings; ++r)
|
|
||||||
{
|
|
||||||
int num_points = read_integer();
|
|
||||||
capacity += num_points;
|
|
||||||
CoordinateArray ar(num_points);
|
|
||||||
read_coords(ar);
|
|
||||||
poly->set_capacity(capacity);
|
|
||||||
poly->move_to(ar[0].x, ar[0].y);
|
|
||||||
for (int j = 1; j < num_points; ++j)
|
|
||||||
{
|
|
||||||
poly->line_to(ar[j].x, ar[j].y);
|
|
||||||
}
|
|
||||||
poly->line_to(ar[0].x, ar[0].y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
paths.push_back(poly);
|
|
||||||
}
|
|
||||||
|
|
||||||
void read_polygon_xyz(boost::ptr_vector<geometry_type> & paths)
|
void read_polygon_xyz(boost::ptr_vector<geometry_type> & paths)
|
||||||
{
|
{
|
||||||
geometry_type* poly = new geometry_type(Polygon);
|
geometry_type* poly = new geometry_type(Polygon);
|
||||||
|
@ -564,34 +403,6 @@ private:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void read_multipolygon_xyz_2(boost::ptr_vector<geometry_type> & paths)
|
|
||||||
{
|
|
||||||
geometry_type* poly = new geometry_type(MultiPolygon);
|
|
||||||
int num_polys = read_integer();
|
|
||||||
unsigned capacity = 0;
|
|
||||||
for (int i = 0; i < num_polys; ++i)
|
|
||||||
{
|
|
||||||
pos_ += 5;
|
|
||||||
int num_rings = read_integer();
|
|
||||||
for (int r = 0; r < num_rings; ++r)
|
|
||||||
{
|
|
||||||
int num_points = read_integer();
|
|
||||||
capacity += num_points;
|
|
||||||
CoordinateArray ar(num_points);
|
|
||||||
read_coords_xyz(ar);
|
|
||||||
poly->set_capacity(capacity);
|
|
||||||
poly->move_to(ar[0].x, ar[0].y);
|
|
||||||
for (int j = 1; j < num_points; ++j)
|
|
||||||
{
|
|
||||||
poly->line_to(ar[j].x, ar[j].y);
|
|
||||||
}
|
|
||||||
poly->line_to(ar[0].x, ar[0].y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
paths.push_back(poly);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void read_collection(boost::ptr_vector<geometry_type> & paths)
|
void read_collection(boost::ptr_vector<geometry_type> & paths)
|
||||||
{
|
{
|
||||||
int num_geometries = read_integer();
|
int num_geometries = read_integer();
|
||||||
|
@ -602,16 +413,6 @@ private:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void read_collection_2(boost::ptr_vector<geometry_type> & paths)
|
|
||||||
{
|
|
||||||
int num_geometries = read_integer();
|
|
||||||
for (int i = 0; i < num_geometries; ++i)
|
|
||||||
{
|
|
||||||
pos_ += 1; // skip byte order
|
|
||||||
read_multi(paths);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef MAPNIK_DEBUG_WKB
|
#ifdef MAPNIK_DEBUG_WKB
|
||||||
std::string wkb_geometry_type_string(int type)
|
std::string wkb_geometry_type_string(int type)
|
||||||
{
|
{
|
||||||
|
@ -645,17 +446,10 @@ private:
|
||||||
void geometry_utils::from_wkb (boost::ptr_vector<geometry_type>& paths,
|
void geometry_utils::from_wkb (boost::ptr_vector<geometry_type>& paths,
|
||||||
const char* wkb,
|
const char* wkb,
|
||||||
unsigned size,
|
unsigned size,
|
||||||
bool multiple_geometries,
|
|
||||||
wkbFormat format)
|
wkbFormat format)
|
||||||
{
|
{
|
||||||
wkb_reader reader(wkb, size, format);
|
wkb_reader reader(wkb, size, format);
|
||||||
if (multiple_geometries)
|
|
||||||
{
|
|
||||||
return reader.read_multi(paths);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return reader.read(paths);
|
return reader.read(paths);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<!DOCTYPE Map>
|
<!DOCTYPE Map>
|
||||||
<Map background-color="white" srs="+init=epsg:4326" minimum-version="0.7.2">
|
<Map background-color="white" srs="+init=epsg:4326" minimum-version="0.7.2">
|
||||||
<Style name="1">
|
<Style name="1">
|
||||||
<Rule title="foo">
|
<Rule>
|
||||||
<MarkersSymbolizer stroke="green" stroke-width="1.3" fill="yellow"/>
|
<MarkersSymbolizer stroke="green" stroke-width="1.3" fill="yellow"/>
|
||||||
<LineSymbolizer stroke-width=".2" stroke="grey"/>
|
<LineSymbolizer stroke-width=".2" stroke="grey"/>
|
||||||
</Rule>
|
</Rule>
|
||||||
|
|
|
@ -2,31 +2,31 @@
|
||||||
<Map background-color="white" srs="+init=epsg:4326" minimum-version="0.7.2">
|
<Map background-color="white" srs="+init=epsg:4326" minimum-version="0.7.2">
|
||||||
|
|
||||||
<Style name="1">
|
<Style name="1">
|
||||||
<Rule title="foo">
|
<Rule>
|
||||||
<Filter>([name]='CHILE')</Filter>
|
<Filter>([name]='CHILE')</Filter>
|
||||||
<MarkersSymbolizer fill="darkgreen" opacity=".7" width="15" height="10" stroke="green" stroke-width="7" stroke-opacity=".2" placement="point" marker-type="ellipse"/>
|
<MarkersSymbolizer fill="darkgreen" opacity=".7" width="15" height="10" stroke="green" stroke-width="7" stroke-opacity=".2" placement="point" marker-type="ellipse"/>
|
||||||
</Rule>
|
</Rule>
|
||||||
<Rule title="foo">
|
<Rule>
|
||||||
<Filter>([name]='Australia')</Filter>
|
<Filter>([name]='Australia')</Filter>
|
||||||
<MarkersSymbolizer fill="darkblue" opacity=".7" width="10" height="20" stroke="blue" stroke-width="7" stroke-opacity=".2" placement="point" marker-type="ellipse"/>
|
<MarkersSymbolizer fill="darkblue" opacity=".7" width="10" height="20" stroke="blue" stroke-width="7" stroke-opacity=".2" placement="point" marker-type="ellipse"/>
|
||||||
</Rule>
|
</Rule>
|
||||||
<Rule title="foo1">
|
<Rule>
|
||||||
<Filter>([name]='Brazil')</Filter>
|
<Filter>([name]='Brazil')</Filter>
|
||||||
<MarkersSymbolizer fill="darkorange" opacity=".7" width="20" height="10" stroke="orange" stroke-width="7" stroke-opacity=".2" placement="point" marker-type="ellipse"/>
|
<MarkersSymbolizer fill="darkorange" opacity=".7" width="20" height="10" stroke="orange" stroke-width="7" stroke-opacity=".2" placement="point" marker-type="ellipse"/>
|
||||||
</Rule>
|
</Rule>
|
||||||
<Rule title="foo">
|
<Rule>
|
||||||
<Filter>([name]='Mongolia')</Filter>
|
<Filter>([name]='Mongolia')</Filter>
|
||||||
<MarkersSymbolizer fill="darkgoldenrod" opacity=".7" width="25" height="10" stroke="yellow" stroke-width="7" stroke-opacity=".2" placement="point" marker-type="ellipse"/>
|
<MarkersSymbolizer fill="darkgoldenrod" opacity=".7" width="25" height="10" stroke="yellow" stroke-width="7" stroke-opacity=".2" placement="point" marker-type="ellipse"/>
|
||||||
</Rule>
|
</Rule>
|
||||||
<Rule title="foo">
|
<Rule>
|
||||||
<Filter>([name]='Sudan')</Filter>
|
<Filter>([name]='Sudan')</Filter>
|
||||||
<MarkersSymbolizer fill="darkcyan" opacity=".7" width="15" height="10" stroke="cadetblue" stroke-width="7" stroke-opacity=".2" placement="point" marker-type="ellipse"/>
|
<MarkersSymbolizer fill="darkcyan" opacity=".7" width="15" height="10" stroke="cadetblue" stroke-width="7" stroke-opacity=".2" placement="point" marker-type="ellipse"/>
|
||||||
</Rule>
|
</Rule>
|
||||||
<Rule title="foo">
|
<Rule>
|
||||||
<Filter>([name]='United States')</Filter>
|
<Filter>([name]='United States')</Filter>
|
||||||
<MarkersSymbolizer fill="#cc3344" opacity=".7" width="15" height="10" stroke="#cc3344" stroke-width="7" stroke-opacity=".2" placement="point" marker-type="ellipse"/>
|
<MarkersSymbolizer fill="#cc3344" opacity=".7" width="15" height="10" stroke="#cc3344" stroke-width="7" stroke-opacity=".2" placement="point" marker-type="ellipse"/>
|
||||||
</Rule>
|
</Rule>
|
||||||
<Rule title="foo">
|
<Rule>
|
||||||
<ElseFilter/>
|
<ElseFilter/>
|
||||||
<PointSymbolizer file="../svg/ellipses.svg"/>
|
<PointSymbolizer file="../svg/ellipses.svg"/>
|
||||||
</Rule>
|
</Rule>
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
<!DOCTYPE Map>
|
<!DOCTYPE Map>
|
||||||
<Map background-color="#b5d0d0" srs="+init=epsg:4326" minimum-version="0.7.2">
|
<Map background-color="#b5d0d0" srs="+init=epsg:4326" minimum-version="0.7.2">
|
||||||
<Style name="1">
|
<Style name="1">
|
||||||
<Rule title="foo">
|
<Rule>
|
||||||
<Filter>([x]=0)</Filter>
|
<Filter>([x]=0)</Filter>
|
||||||
<TextSymbolizer size="10" dy="-10" face-name="DejaVu Sans Book" halo-radius="1" allow-overlap="true">[label]</TextSymbolizer>
|
<TextSymbolizer size="10" dy="-10" face-name="DejaVu Sans Book" halo-radius="1" allow-overlap="true">[label]</TextSymbolizer>
|
||||||
<PointSymbolizer/>
|
<PointSymbolizer/>
|
||||||
</Rule>
|
</Rule>
|
||||||
<Rule title="foo">
|
<Rule>
|
||||||
<Filter>([y]=0)</Filter>
|
<Filter>([y]=0)</Filter>
|
||||||
<TextSymbolizer size="10" dy="5" face-name="DejaVu Sans Book" halo-radius="1">[label]</TextSymbolizer>
|
<TextSymbolizer size="10" dy="5" face-name="DejaVu Sans Book" halo-radius="1">[label]</TextSymbolizer>
|
||||||
<PointSymbolizer/>
|
<PointSymbolizer/>
|
||||||
</Rule>
|
</Rule>
|
||||||
<Rule title="foo">
|
<Rule>
|
||||||
<ElseFilter/>
|
<ElseFilter/>
|
||||||
<TextSymbolizer size="10" dy="-5" face-name="DejaVu Sans Book" halo-radius="1">[label]</TextSymbolizer>
|
<TextSymbolizer size="10" dy="-5" face-name="DejaVu Sans Book" halo-radius="1">[label]</TextSymbolizer>
|
||||||
<PointSymbolizer/>
|
<PointSymbolizer/>
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
<!DOCTYPE Map>
|
<!DOCTYPE Map>
|
||||||
<Map background-color="#b5d0d0" srs="+init=epsg:4326" minimum-version="0.7.2">
|
<Map background-color="#b5d0d0" srs="+init=epsg:4326" minimum-version="0.7.2">
|
||||||
<Style name="1">
|
<Style name="1">
|
||||||
<Rule title="foo">
|
<Rule>
|
||||||
<Filter>([x]=0)</Filter>
|
<Filter>([x]=0)</Filter>
|
||||||
<TextSymbolizer size="10" dy="-10" face-name="DejaVu Sans Book" halo-radius="1" allow-overlap="true">[label]</TextSymbolizer>
|
<TextSymbolizer size="10" dy="-10" face-name="DejaVu Sans Book" halo-radius="1" allow-overlap="true">[label]</TextSymbolizer>
|
||||||
<PointSymbolizer/>
|
<PointSymbolizer/>
|
||||||
</Rule>
|
</Rule>
|
||||||
<Rule title="foo">
|
<Rule>
|
||||||
<Filter>([y]=0)</Filter>
|
<Filter>([y]=0)</Filter>
|
||||||
<TextSymbolizer size="10" dy="5" face-name="DejaVu Sans Book" halo-radius="1">[label]</TextSymbolizer>
|
<TextSymbolizer size="10" dy="5" face-name="DejaVu Sans Book" halo-radius="1">[label]</TextSymbolizer>
|
||||||
<PointSymbolizer/>
|
<PointSymbolizer/>
|
||||||
</Rule>
|
</Rule>
|
||||||
<Rule title="foo">
|
<Rule>
|
||||||
<ElseFilter/>
|
<ElseFilter/>
|
||||||
<TextSymbolizer size="10" dy="-5" face-name="DejaVu Sans Book" halo-radius="1">[label]</TextSymbolizer>
|
<TextSymbolizer size="10" dy="-5" face-name="DejaVu Sans Book" halo-radius="1">[label]</TextSymbolizer>
|
||||||
<PointSymbolizer/>
|
<PointSymbolizer/>
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
<!DOCTYPE Map>
|
<!DOCTYPE Map>
|
||||||
<Map background-color="#b5d0d0" srs="+init=epsg:4326" minimum-version="0.7.2">
|
<Map background-color="#b5d0d0" srs="+init=epsg:4326" minimum-version="0.7.2">
|
||||||
<Style name="1">
|
<Style name="1">
|
||||||
<Rule title="foo">
|
<Rule>
|
||||||
<Filter>([x]=0)</Filter>
|
<Filter>([x]=0)</Filter>
|
||||||
<TextSymbolizer size="10" dy="-10" face-name="DejaVu Sans Book" halo-radius="1" allow-overlap="true">[label]</TextSymbolizer>
|
<TextSymbolizer size="10" dy="-10" face-name="DejaVu Sans Book" halo-radius="1" allow-overlap="true">[label]</TextSymbolizer>
|
||||||
<PointSymbolizer/>
|
<PointSymbolizer/>
|
||||||
</Rule>
|
</Rule>
|
||||||
<Rule title="foo">
|
<Rule>
|
||||||
<Filter>([y]=0)</Filter>
|
<Filter>([y]=0)</Filter>
|
||||||
<TextSymbolizer size="10" dy="5" face-name="DejaVu Sans Book" halo-radius="1">[label]</TextSymbolizer>
|
<TextSymbolizer size="10" dy="5" face-name="DejaVu Sans Book" halo-radius="1">[label]</TextSymbolizer>
|
||||||
<PointSymbolizer/>
|
<PointSymbolizer/>
|
||||||
</Rule>
|
</Rule>
|
||||||
<Rule title="foo">
|
<Rule>
|
||||||
<ElseFilter/>
|
<ElseFilter/>
|
||||||
<TextSymbolizer size="10" dy="-5" face-name="DejaVu Sans Book" halo-radius="1">[label]</TextSymbolizer>
|
<TextSymbolizer size="10" dy="-5" face-name="DejaVu Sans Book" halo-radius="1">[label]</TextSymbolizer>
|
||||||
<PointSymbolizer/>
|
<PointSymbolizer/>
|
||||||
|
|
|
@ -1,38 +1,38 @@
|
||||||
<!DOCTYPE Map>
|
<!DOCTYPE Map>
|
||||||
<Map background-color="#b5d0d0" srs="+init=epsg:4326" minimum-version="0.7.2">
|
<Map background-color="#b5d0d0" srs="+init=epsg:4326" minimum-version="0.7.2">
|
||||||
<Style name="1">
|
<Style name="1">
|
||||||
<Rule title="foo">
|
<Rule>
|
||||||
<Filter>([name]='CHILE')</Filter>
|
<Filter>([name]='CHILE')</Filter>
|
||||||
<TextSymbolizer size="10" dy="5" face-name="DejaVu Sans Book" text-transform="lowercase" wrap-width="10" wrap-character=" " halo-radius="1">[name] + ' (default OGC pixel)'</TextSymbolizer>
|
<TextSymbolizer size="10" dy="5" face-name="DejaVu Sans Book" text-transform="lowercase" wrap-width="10" wrap-character=" " halo-radius="1">[name] + ' (default OGC pixel)'</TextSymbolizer>
|
||||||
<PointSymbolizer/>
|
<PointSymbolizer/>
|
||||||
</Rule>
|
</Rule>
|
||||||
<Rule title="foo">
|
<Rule>
|
||||||
<Filter>([name]='Australia')</Filter>
|
<Filter>([name]='Australia')</Filter>
|
||||||
<TextSymbolizer size="10" dy="20" face-name="DejaVu Sans Book" halo-radius="1">[name] + ' (png)'</TextSymbolizer>
|
<TextSymbolizer size="10" dy="20" face-name="DejaVu Sans Book" halo-radius="1">[name] + ' (png)'</TextSymbolizer>
|
||||||
<PointSymbolizer file="../images/dummy.png" allow-overlap="true"/>
|
<PointSymbolizer file="../images/dummy.png" allow-overlap="true"/>
|
||||||
</Rule>
|
</Rule>
|
||||||
<Rule title="foo1">
|
<Rule>
|
||||||
<Filter>([name]='Brazil')</Filter>
|
<Filter>([name]='Brazil')</Filter>
|
||||||
<TextSymbolizer size="10" dy="20" face-name="DejaVu Sans Book" halo-radius="1">[name] + ' (svg & tif)'</TextSymbolizer>
|
<TextSymbolizer size="10" dy="20" face-name="DejaVu Sans Book" halo-radius="1">[name] + ' (svg & tif)'</TextSymbolizer>
|
||||||
<PointSymbolizer file="../images/dummy.tif" allow-overlap="true"/>
|
<PointSymbolizer file="../images/dummy.tif" allow-overlap="true"/>
|
||||||
<PointSymbolizer file="../svg/ellipses.svg" allow-overlap="true"/>
|
<PointSymbolizer file="../svg/ellipses.svg" allow-overlap="true"/>
|
||||||
</Rule>
|
</Rule>
|
||||||
<Rule title="foo">
|
<Rule>
|
||||||
<Filter>([name]='Mongolia')</Filter>
|
<Filter>([name]='Mongolia')</Filter>
|
||||||
<TextSymbolizer size="10" dy="20" face-name="DejaVu Sans Book" halo-radius="1">[name] + ' (tiff)'</TextSymbolizer>
|
<TextSymbolizer size="10" dy="20" face-name="DejaVu Sans Book" halo-radius="1">[name] + ' (tiff)'</TextSymbolizer>
|
||||||
<PointSymbolizer file="../images/dummy.tiff" allow-overlap="true"/>
|
<PointSymbolizer file="../images/dummy.tiff" allow-overlap="true"/>
|
||||||
</Rule>
|
</Rule>
|
||||||
<Rule title="foo">
|
<Rule>
|
||||||
<Filter>([name]='Sudan')</Filter>
|
<Filter>([name]='Sudan')</Filter>
|
||||||
<TextSymbolizer size="10" dy="20" face-name="DejaVu Sans Book" halo-radius="1">[name] + ' (jpeg)'</TextSymbolizer>
|
<TextSymbolizer size="10" dy="20" face-name="DejaVu Sans Book" halo-radius="1">[name] + ' (jpeg)'</TextSymbolizer>
|
||||||
<PointSymbolizer file="../images/dummy.jpeg"/>
|
<PointSymbolizer file="../images/dummy.jpeg"/>
|
||||||
</Rule>
|
</Rule>
|
||||||
<Rule title="foo">
|
<Rule>
|
||||||
<Filter>([name]='United States')</Filter>
|
<Filter>([name]='United States')</Filter>
|
||||||
<TextSymbolizer size="10" dy="20" face-name="DejaVu Sans Book" halo-radius="1">[name] + ' (jpg)'</TextSymbolizer>
|
<TextSymbolizer size="10" dy="20" face-name="DejaVu Sans Book" halo-radius="1">[name] + ' (jpg)'</TextSymbolizer>
|
||||||
<PointSymbolizer file="../images/dummy.jpg"/>
|
<PointSymbolizer file="../images/dummy.jpg"/>
|
||||||
</Rule>
|
</Rule>
|
||||||
<Rule title="foo">
|
<Rule>
|
||||||
<ElseFilter/>
|
<ElseFilter/>
|
||||||
<TextSymbolizer size="10" dy="20" face-name="DejaVu Sans Book" halo-radius="1">[name]</TextSymbolizer>
|
<TextSymbolizer size="10" dy="20" face-name="DejaVu Sans Book" halo-radius="1">[name]</TextSymbolizer>
|
||||||
<PointSymbolizer file="../images/bogus_will_fail.png"/>
|
<PointSymbolizer file="../images/bogus_will_fail.png"/>
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
<!DOCTYPE Map>
|
<!DOCTYPE Map>
|
||||||
<Map background-color="#b5d0d0" srs="+init=epsg:4326" minimum-version="0.7.2">
|
<Map background-color="#b5d0d0" srs="+init=epsg:4326" minimum-version="0.7.2">
|
||||||
<Style name="1">
|
<Style name="1">
|
||||||
<Rule title="foo1">
|
<Rule>
|
||||||
<Filter>([name]='Brazil' or [name]='Mongolia' or [name]='Sudan')</Filter>
|
<Filter>([name]='Brazil' or [name]='Mongolia' or [name]='Sudan')</Filter>
|
||||||
<PointSymbolizer file="../svg/point_sm.svg" allow-overlap="true"/>
|
<PointSymbolizer file="../svg/point_sm.svg" allow-overlap="true"/>
|
||||||
</Rule>
|
</Rule>
|
||||||
<Rule title="foo">
|
<Rule>
|
||||||
<ElseFilter/>
|
<ElseFilter/>
|
||||||
<PointSymbolizer file="../svg/point_sm.svg" ignore-placement="true"/>
|
<PointSymbolizer file="../svg/point_sm.svg" ignore-placement="true"/>
|
||||||
<PointSymbolizer/>
|
<PointSymbolizer/>
|
||||||
|
|
|
@ -1,26 +1,26 @@
|
||||||
<!DOCTYPE Map>
|
<!DOCTYPE Map>
|
||||||
<Map background-color="#b5d0d0" minimum-version="0.7.2">
|
<Map background-color="#b5d0d0" minimum-version="0.7.2">
|
||||||
<Style name="test">
|
<Style name="test">
|
||||||
<Rule title="asia">
|
<Rule name="asia">
|
||||||
<Filter>([REGION]=142)</Filter>
|
<Filter>([REGION]=142)</Filter>
|
||||||
<PointSymbolizer file="../images/dummy.png" allow-overlap="true"/>
|
<PointSymbolizer file="../images/dummy.png" allow-overlap="true"/>
|
||||||
</Rule>
|
</Rule>
|
||||||
<Rule title="europe">
|
<Rule name="europe">
|
||||||
<Filter>([REGION]=150)</Filter>
|
<Filter>([REGION]=150)</Filter>
|
||||||
<!-- requires at least Mapnik 0.7.1 to work due to http://trac.mapnik.org/ticket/508 -->
|
<!-- requires at least Mapnik 0.7.1 to work due to http://trac.mapnik.org/ticket/508 -->
|
||||||
<PolygonPatternSymbolizer file="../images/dummy.png"/>
|
<PolygonPatternSymbolizer file="../images/dummy.png"/>
|
||||||
</Rule>
|
</Rule>
|
||||||
<Rule title="americas">
|
<Rule name="americas">
|
||||||
<Filter>([REGION]=19)</Filter>
|
<Filter>([REGION]=19)</Filter>
|
||||||
<!-- requires at least Mapnik 0.7.1 to work due to http://trac.mapnik.org/ticket/508 -->
|
<!-- requires at least Mapnik 0.7.1 to work due to http://trac.mapnik.org/ticket/508 -->
|
||||||
<LinePatternSymbolizer file="../images/dummy.png"/>
|
<LinePatternSymbolizer file="../images/dummy.png"/>
|
||||||
</Rule>
|
</Rule>
|
||||||
<Rule title="Africa">
|
<Rule name="Africa">
|
||||||
<Filter>([REGION]=2)</Filter>
|
<Filter>([REGION]=2)</Filter>
|
||||||
<ShieldSymbolizer placement="vertex" size="10" fill="#000000" file="../images/dummy.png" face-name="DejaVu Sans Bold">[NAME]</ShieldSymbolizer>
|
<ShieldSymbolizer placement="vertex" size="10" fill="#000000" file="../images/dummy.png" face-name="DejaVu Sans Bold">[NAME]</ShieldSymbolizer>
|
||||||
</Rule>
|
</Rule>
|
||||||
|
|
||||||
<Rule title="rest">
|
<Rule name="rest">
|
||||||
<ElseFilter/>
|
<ElseFilter/>
|
||||||
<LineSymbolizer stroke-width="1"/>
|
<LineSymbolizer stroke-width="1"/>
|
||||||
</Rule>
|
</Rule>
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
<Map srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over" background-color="steelblue" minimum-version="0.7.2">
|
<Map srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over" background-color="steelblue" minimum-version="0.7.2">
|
||||||
|
|
||||||
<Style name="labels">
|
<Style name="labels">
|
||||||
<Rule title="foo">
|
<Rule>
|
||||||
<Filter>([name]='CHILE')</Filter>
|
<Filter>([name]='CHILE')</Filter>
|
||||||
<TextSymbolizer size="15" orientation="45" face-name="DejaVu Sans Book" halo-radius="1">'45˚ angle'</TextSymbolizer>
|
<TextSymbolizer size="15" orientation="45" face-name="DejaVu Sans Book" halo-radius="1">'45˚ angle'</TextSymbolizer>
|
||||||
</Rule>
|
</Rule>
|
||||||
<Rule title="foo">
|
<Rule>
|
||||||
<Filter>([name]='Australia')</Filter>
|
<Filter>([name]='Australia')</Filter>
|
||||||
<TextSymbolizer size="15" orientation="-45" face-name="DejaVu Sans Book" halo-radius="1">'- 45˚ angle'</TextSymbolizer>
|
<TextSymbolizer size="15" orientation="-45" face-name="DejaVu Sans Book" halo-radius="1">'- 45˚ angle'</TextSymbolizer>
|
||||||
</Rule>
|
</Rule>
|
||||||
<Rule title="foo1">
|
<Rule>
|
||||||
<Filter>([name]='Brazil')</Filter>
|
<Filter>([name]='Brazil')</Filter>
|
||||||
<TextSymbolizer size="15" orientation="90" face-name="DejaVu Sans Book" halo-radius="1">'90˚ angle'</TextSymbolizer>
|
<TextSymbolizer size="15" orientation="90" face-name="DejaVu Sans Book" halo-radius="1">'90˚ angle'</TextSymbolizer>
|
||||||
</Rule>
|
</Rule>
|
||||||
<Rule title="foo">
|
<Rule>
|
||||||
<Filter>([name]='Mongolia')</Filter>
|
<Filter>([name]='Mongolia')</Filter>
|
||||||
<TextSymbolizer size="15" orientation="-90" face-name="DejaVu Sans Book" halo-radius="1">'- 90˚ angle'</TextSymbolizer>
|
<TextSymbolizer size="15" orientation="-90" face-name="DejaVu Sans Book" halo-radius="1">'- 90˚ angle'</TextSymbolizer>
|
||||||
</Rule>
|
</Rule>
|
||||||
<Rule title="foo">
|
<Rule>
|
||||||
<Filter>([name]='South Sudan')</Filter>
|
<Filter>([name]='South Sudan')</Filter>
|
||||||
<TextSymbolizer size="15" orientation="180" face-name="DejaVu Sans Book" halo-radius="1">'180˚ angle'</TextSymbolizer>
|
<TextSymbolizer size="15" orientation="180" face-name="DejaVu Sans Book" halo-radius="1">'180˚ angle'</TextSymbolizer>
|
||||||
</Rule>
|
</Rule>
|
||||||
<Rule title="foo">
|
<Rule>
|
||||||
<Filter>([name]='United States')</Filter>
|
<Filter>([name]='United States')</Filter>
|
||||||
<TextSymbolizer size="15" face-name="DejaVu Sans Book" halo-radius="1">'no rotation of text'</TextSymbolizer>
|
<TextSymbolizer size="15" face-name="DejaVu Sans Book" halo-radius="1">'no rotation of text'</TextSymbolizer>
|
||||||
</Rule>
|
</Rule>
|
||||||
<Rule title="foo">
|
<Rule>
|
||||||
<ElseFilter/>
|
<ElseFilter/>
|
||||||
<TextSymbolizer size="15" face-name="DejaVu Sans Book" halo-radius="1">[name]</TextSymbolizer>
|
<TextSymbolizer size="15" face-name="DejaVu Sans Book" halo-radius="1">[name]</TextSymbolizer>
|
||||||
</Rule>
|
</Rule>
|
||||||
|
|
|
@ -213,12 +213,10 @@ def test_layer_init():
|
||||||
eq_(l.clear_label_cache,False)
|
eq_(l.clear_label_cache,False)
|
||||||
eq_(l.cache_features,False)
|
eq_(l.cache_features,False)
|
||||||
eq_(l.visible(1),True)
|
eq_(l.visible(1),True)
|
||||||
eq_(l.abstract,'')
|
|
||||||
eq_(l.active,True)
|
eq_(l.active,True)
|
||||||
eq_(l.datasource,None)
|
eq_(l.datasource,None)
|
||||||
eq_(l.queryable,False)
|
eq_(l.queryable,False)
|
||||||
eq_(l.srs,'+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')
|
eq_(l.srs,'+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')
|
||||||
eq_(l.title,'')
|
|
||||||
|
|
||||||
# Map initialization
|
# Map initialization
|
||||||
def test_map_init():
|
def test_map_init():
|
||||||
|
@ -399,7 +397,6 @@ def test_rule_init():
|
||||||
r = mapnik.Rule()
|
r = mapnik.Rule()
|
||||||
|
|
||||||
eq_(r.name, '')
|
eq_(r.name, '')
|
||||||
eq_(r.title, '')
|
|
||||||
eq_(r.min_scale, 0)
|
eq_(r.min_scale, 0)
|
||||||
eq_(r.max_scale, float('inf'))
|
eq_(r.max_scale, float('inf'))
|
||||||
eq_(r.has_else(), False)
|
eq_(r.has_else(), False)
|
||||||
|
@ -420,34 +417,30 @@ def test_rule_init():
|
||||||
r = mapnik.Rule("Name")
|
r = mapnik.Rule("Name")
|
||||||
|
|
||||||
eq_(r.name, 'Name')
|
eq_(r.name, 'Name')
|
||||||
eq_(r.title, '')
|
|
||||||
eq_(r.min_scale, 0)
|
eq_(r.min_scale, 0)
|
||||||
eq_(r.max_scale, float('inf'))
|
eq_(r.max_scale, float('inf'))
|
||||||
eq_(r.has_else(), False)
|
eq_(r.has_else(), False)
|
||||||
eq_(r.has_also(), False)
|
eq_(r.has_also(), False)
|
||||||
|
|
||||||
r = mapnik.Rule("Name", "Title")
|
r = mapnik.Rule("Name")
|
||||||
|
|
||||||
eq_(r.name, 'Name')
|
eq_(r.name, 'Name')
|
||||||
eq_(r.title, 'Title')
|
|
||||||
eq_(r.min_scale, 0)
|
eq_(r.min_scale, 0)
|
||||||
eq_(r.max_scale, float('inf'))
|
eq_(r.max_scale, float('inf'))
|
||||||
eq_(r.has_else(), False)
|
eq_(r.has_else(), False)
|
||||||
eq_(r.has_also(), False)
|
eq_(r.has_also(), False)
|
||||||
|
|
||||||
r = mapnik.Rule("Name", "Title", min_scale)
|
r = mapnik.Rule("Name", min_scale)
|
||||||
|
|
||||||
eq_(r.name, 'Name')
|
eq_(r.name, 'Name')
|
||||||
eq_(r.title, 'Title')
|
|
||||||
eq_(r.min_scale, min_scale)
|
eq_(r.min_scale, min_scale)
|
||||||
eq_(r.max_scale, float('inf'))
|
eq_(r.max_scale, float('inf'))
|
||||||
eq_(r.has_else(), False)
|
eq_(r.has_else(), False)
|
||||||
eq_(r.has_also(), False)
|
eq_(r.has_also(), False)
|
||||||
|
|
||||||
r = mapnik.Rule("Name", "Title", min_scale, max_scale)
|
r = mapnik.Rule("Name", min_scale, max_scale)
|
||||||
|
|
||||||
eq_(r.name, 'Name')
|
eq_(r.name, 'Name')
|
||||||
eq_(r.title, 'Title')
|
|
||||||
eq_(r.min_scale, min_scale)
|
eq_(r.min_scale, min_scale)
|
||||||
eq_(r.max_scale, max_scale)
|
eq_(r.max_scale, max_scale)
|
||||||
eq_(r.has_else(), False)
|
eq_(r.has_else(), False)
|
||||||
|
|
|
@ -83,6 +83,9 @@ if 'sqlite' in mapnik.DatasourceCache.instance().plugin_names():
|
||||||
table='(select * from world_merc INNER JOIN business on world_merc.iso3 = business.ISO3 limit 100)',
|
table='(select * from world_merc INNER JOIN business on world_merc.iso3 = business.ISO3 limit 100)',
|
||||||
attachdb='busines@business.sqlite'
|
attachdb='busines@business.sqlite'
|
||||||
)
|
)
|
||||||
|
eq_(len(ds.fields()),29)
|
||||||
|
eq_(ds.fields(),['OGC_FID', 'fips', 'iso2', 'iso3', 'un', 'name', 'area', 'pop2005', 'region', 'subregion', 'lon', 'lat', 'ISO3:1', '1995', '1996', '1997', '1998', '1999', '2000', '2001', '2002', '2003', '2004', '2005', '2006', '2007', '2008', '2009', '2010'])
|
||||||
|
eq_(ds.field_types(),['int', 'str', 'str', 'str', 'int', 'str', 'int', 'int', 'int', 'int', 'float', 'float', 'str', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int'])
|
||||||
fs = ds.featureset()
|
fs = ds.featureset()
|
||||||
feature = fs.next()
|
feature = fs.next()
|
||||||
eq_(feature.id(),1)
|
eq_(feature.id(),1)
|
||||||
|
@ -126,6 +129,71 @@ if 'sqlite' in mapnik.DatasourceCache.instance().plugin_names():
|
||||||
#import pdb;pdb.set_trace()
|
#import pdb;pdb.set_trace()
|
||||||
print 'invalid key/v %s/%s for: %s' % (k,v,feature)
|
print 'invalid key/v %s/%s for: %s' % (k,v,feature)
|
||||||
|
|
||||||
|
def test_attachdb_with_sql_join_count():
|
||||||
|
ds = mapnik.SQLite(file='../data/sqlite/world.sqlite',
|
||||||
|
table='(select * from world_merc INNER JOIN business on world_merc.iso3 = business.ISO3 limit 100)',
|
||||||
|
attachdb='busines@business.sqlite'
|
||||||
|
)
|
||||||
|
eq_(len(ds.fields()),29)
|
||||||
|
eq_(ds.fields(),['OGC_FID', 'fips', 'iso2', 'iso3', 'un', 'name', 'area', 'pop2005', 'region', 'subregion', 'lon', 'lat', 'ISO3:1', '1995', '1996', '1997', '1998', '1999', '2000', '2001', '2002', '2003', '2004', '2005', '2006', '2007', '2008', '2009', '2010'])
|
||||||
|
eq_(ds.field_types(),['int', 'str', 'str', 'str', 'int', 'str', 'int', 'int', 'int', 'int', 'float', 'float', 'str', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int'])
|
||||||
|
eq_(len(ds.all_features()),100)
|
||||||
|
|
||||||
|
def test_attachdb_with_sql_join_count2():
|
||||||
|
'''
|
||||||
|
sqlite3 world.sqlite
|
||||||
|
attach database 'business.sqlite' as business;
|
||||||
|
select count(*) from world_merc INNER JOIN business on world_merc.iso3 = business.ISO3;
|
||||||
|
'''
|
||||||
|
ds = mapnik.SQLite(file='../data/sqlite/world.sqlite',
|
||||||
|
table='(select * from world_merc INNER JOIN business on world_merc.iso3 = business.ISO3)',
|
||||||
|
attachdb='busines@business.sqlite'
|
||||||
|
)
|
||||||
|
eq_(len(ds.fields()),29)
|
||||||
|
eq_(ds.fields(),['OGC_FID', 'fips', 'iso2', 'iso3', 'un', 'name', 'area', 'pop2005', 'region', 'subregion', 'lon', 'lat', 'ISO3:1', '1995', '1996', '1997', '1998', '1999', '2000', '2001', '2002', '2003', '2004', '2005', '2006', '2007', '2008', '2009', '2010'])
|
||||||
|
eq_(ds.field_types(),['int', 'str', 'str', 'str', 'int', 'str', 'int', 'int', 'int', 'int', 'float', 'float', 'str', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int'])
|
||||||
|
eq_(len(ds.all_features()),192)
|
||||||
|
|
||||||
|
def test_attachdb_with_sql_join_count3():
|
||||||
|
'''
|
||||||
|
select count(*) from (select * from world_merc where 1=1) as world_merc INNER JOIN business on world_merc.iso3 = business.ISO3;
|
||||||
|
'''
|
||||||
|
ds = mapnik.SQLite(file='../data/sqlite/world.sqlite',
|
||||||
|
table='(select * from (select * from world_merc where !intersects!) as world_merc INNER JOIN business on world_merc.iso3 = business.ISO3)',
|
||||||
|
attachdb='busines@business.sqlite'
|
||||||
|
)
|
||||||
|
eq_(len(ds.fields()),29)
|
||||||
|
eq_(ds.fields(),['OGC_FID', 'fips', 'iso2', 'iso3', 'un', 'name', 'area', 'pop2005', 'region', 'subregion', 'lon', 'lat', 'ISO3:1', '1995', '1996', '1997', '1998', '1999', '2000', '2001', '2002', '2003', '2004', '2005', '2006', '2007', '2008', '2009', '2010'])
|
||||||
|
eq_(ds.field_types(),['int', 'str', 'str', 'str', 'int', 'str', 'int', 'int', 'int', 'int', 'float', 'float', 'str', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int'])
|
||||||
|
eq_(len(ds.all_features()),192)
|
||||||
|
|
||||||
|
def test_attachdb_with_sql_join_count4():
|
||||||
|
'''
|
||||||
|
select count(*) from (select * from world_merc where 1=1) as world_merc INNER JOIN business on world_merc.iso3 = business.ISO3;
|
||||||
|
'''
|
||||||
|
ds = mapnik.SQLite(file='../data/sqlite/world.sqlite',
|
||||||
|
table='(select * from (select * from world_merc where !intersects! limit 1) as world_merc INNER JOIN business on world_merc.iso3 = business.ISO3)',
|
||||||
|
attachdb='busines@business.sqlite'
|
||||||
|
)
|
||||||
|
eq_(len(ds.fields()),29)
|
||||||
|
eq_(ds.fields(),['OGC_FID', 'fips', 'iso2', 'iso3', 'un', 'name', 'area', 'pop2005', 'region', 'subregion', 'lon', 'lat', 'ISO3:1', '1995', '1996', '1997', '1998', '1999', '2000', '2001', '2002', '2003', '2004', '2005', '2006', '2007', '2008', '2009', '2010'])
|
||||||
|
eq_(ds.field_types(),['int', 'str', 'str', 'str', 'int', 'str', 'int', 'int', 'int', 'int', 'float', 'float', 'str', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int'])
|
||||||
|
eq_(len(ds.all_features()),1)
|
||||||
|
|
||||||
|
def test_attachdb_with_sql_join_count5():
|
||||||
|
'''
|
||||||
|
select count(*) from (select * from world_merc where 1=1) as world_merc INNER JOIN business on world_merc.iso3 = business.ISO3;
|
||||||
|
'''
|
||||||
|
ds = mapnik.SQLite(file='../data/sqlite/world.sqlite',
|
||||||
|
table='(select * from (select * from world_merc where !intersects! and 1=2) as world_merc INNER JOIN business on world_merc.iso3 = business.ISO3)',
|
||||||
|
attachdb='busines@business.sqlite'
|
||||||
|
)
|
||||||
|
# nothing is able to join to business so we don't pick up business schema
|
||||||
|
eq_(len(ds.fields()),12)
|
||||||
|
eq_(ds.fields(),['OGC_FID', 'fips', 'iso2', 'iso3', 'un', 'name', 'area', 'pop2005', 'region', 'subregion', 'lon', 'lat'])
|
||||||
|
eq_(ds.field_types(),['int', 'str', 'str', 'str', 'int', 'str', 'int', 'int', 'int', 'int', 'float', 'float'])
|
||||||
|
eq_(len(ds.all_features()),0)
|
||||||
|
|
||||||
def test_subqueries():
|
def test_subqueries():
|
||||||
ds = mapnik.SQLite(file='../data/sqlite/world.sqlite',
|
ds = mapnik.SQLite(file='../data/sqlite/world.sqlite',
|
||||||
table='world_merc',
|
table='world_merc',
|
||||||
|
@ -179,14 +247,16 @@ if 'sqlite' in mapnik.DatasourceCache.instance().plugin_names():
|
||||||
eq_(feature['OGC_FID'],1)
|
eq_(feature['OGC_FID'],1)
|
||||||
eq_(feature['fips'],u'AC')
|
eq_(feature['fips'],u'AC')
|
||||||
|
|
||||||
ds = mapnik.SQLite(file='../data/sqlite/world.sqlite',
|
# same as above, except with alias like postgres requires
|
||||||
table='(select GEOMETRY,rowid as aliased_id,fips from world_merc)',
|
# TODO - should we try to make this work?
|
||||||
key_field='aliased_id'
|
#ds = mapnik.SQLite(file='../data/sqlite/world.sqlite',
|
||||||
)
|
# table='(select GEOMETRY,rowid as aliased_id,fips from world_merc) as table',
|
||||||
fs = ds.featureset()
|
# key_field='aliased_id'
|
||||||
feature = fs.next()
|
# )
|
||||||
eq_(feature['aliased_id'],1)
|
#fs = ds.featureset()
|
||||||
eq_(feature['fips'],u'AC')
|
#feature = fs.next()
|
||||||
|
#eq_(feature['aliased_id'],1)
|
||||||
|
#eq_(feature['fips'],u'AC')
|
||||||
|
|
||||||
ds = mapnik.SQLite(file='../data/sqlite/world.sqlite',
|
ds = mapnik.SQLite(file='../data/sqlite/world.sqlite',
|
||||||
table='(select GEOMETRY,OGC_FID,OGC_FID as rowid,fips from world_merc)',
|
table='(select GEOMETRY,OGC_FID,OGC_FID as rowid,fips from world_merc)',
|
||||||
|
@ -220,6 +290,31 @@ if 'sqlite' in mapnik.DatasourceCache.instance().plugin_names():
|
||||||
query.add_property_name('bogus')
|
query.add_property_name('bogus')
|
||||||
fs = ds.features(query)
|
fs = ds.features(query)
|
||||||
|
|
||||||
|
def test_intersects_token1():
|
||||||
|
ds = mapnik.SQLite(file='../data/sqlite/empty.db',
|
||||||
|
table='(select * from empty where !intersects!)',
|
||||||
|
)
|
||||||
|
fs = ds.featureset()
|
||||||
|
feature = fs.next()
|
||||||
|
eq_(feature,None)
|
||||||
|
|
||||||
|
def test_intersects_token1():
|
||||||
|
ds = mapnik.SQLite(file='../data/sqlite/empty.db',
|
||||||
|
table='(select * from empty where "a"!="b" and !intersects!)',
|
||||||
|
)
|
||||||
|
fs = ds.featureset()
|
||||||
|
feature = fs.next()
|
||||||
|
eq_(feature,None)
|
||||||
|
|
||||||
|
def test_intersects_token1():
|
||||||
|
ds = mapnik.SQLite(file='../data/sqlite/empty.db',
|
||||||
|
table='(select * from empty where "a"!="b" and !intersects!)',
|
||||||
|
)
|
||||||
|
fs = ds.featureset()
|
||||||
|
feature = fs.next()
|
||||||
|
eq_(feature,None)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
setup()
|
setup()
|
||||||
[eval(run)() for run in dir() if 'test_' in run]
|
[eval(run)() for run in dir() if 'test_' in run]
|
||||||
|
|
|
@ -47,27 +47,6 @@
|
||||||
|
|
||||||
namespace mapnik {
|
namespace mapnik {
|
||||||
|
|
||||||
/*
|
|
||||||
struct blob_to_hex
|
|
||||||
{
|
|
||||||
std::string operator() (const char* blob, unsigned size)
|
|
||||||
{
|
|
||||||
std::string buf;
|
|
||||||
buf.reserve(size*2);
|
|
||||||
std::ostringstream s(buf);
|
|
||||||
s.seekp(0);
|
|
||||||
char hex[3];
|
|
||||||
std::memset(hex,0,3);
|
|
||||||
for ( unsigned pos=0; pos < size; ++pos)
|
|
||||||
{
|
|
||||||
std::sprintf (hex, "%02X", int(blob[pos]) & 0xff);
|
|
||||||
s << hex;
|
|
||||||
}
|
|
||||||
return s.str();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
*/
|
|
||||||
|
|
||||||
template <typename Connection>
|
template <typename Connection>
|
||||||
void pgsql2sqlite(Connection conn,
|
void pgsql2sqlite(Connection conn,
|
||||||
std::string const& query,
|
std::string const& query,
|
||||||
|
@ -297,7 +276,7 @@ void pgsql2sqlite(Connection conn,
|
||||||
if (oid == geometry_oid)
|
if (oid == geometry_oid)
|
||||||
{
|
{
|
||||||
mapnik::Feature feat(pkid);
|
mapnik::Feature feat(pkid);
|
||||||
geometry_utils::from_wkb(feat.paths(),buf,size,false,wkbGeneric);
|
geometry_utils::from_wkb(feat.paths(),buf,size,wkbGeneric);
|
||||||
if (feat.num_geometries() > 0)
|
if (feat.num_geometries() > 0)
|
||||||
{
|
{
|
||||||
geometry_type const& geom=feat.get_geometry(0);
|
geometry_type const& geom=feat.get_geometry(0);
|
||||||
|
@ -316,8 +295,6 @@ void pgsql2sqlite(Connection conn,
|
||||||
empty_geom = false;
|
empty_geom = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//output_rec.push_back(sqlite::value_type("X'" + hex(buf,size) + "'"));
|
|
||||||
output_rec.push_back(sqlite::blob(buf,size));
|
output_rec.push_back(sqlite::blob(buf,size));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -69,7 +69,6 @@
|
||||||
<!ELEMENT Layer (StyleName|Datasource)*>
|
<!ELEMENT Layer (StyleName|Datasource)*>
|
||||||
<!-- FIXME: queryable true/false ? -->
|
<!-- FIXME: queryable true/false ? -->
|
||||||
<!ATTLIST Layer
|
<!ATTLIST Layer
|
||||||
abstract CDATA #IMPLIED
|
|
||||||
clear_label_cache (yes|1|no|0) #IMPLIED
|
clear_label_cache (yes|1|no|0) #IMPLIED
|
||||||
minzoom CDATA "0"
|
minzoom CDATA "0"
|
||||||
maxzoom CDATA #IMPLIED
|
maxzoom CDATA #IMPLIED
|
||||||
|
@ -77,7 +76,6 @@
|
||||||
queryable (true|on|1|false|off|0) "0"
|
queryable (true|on|1|false|off|0) "0"
|
||||||
srs CDATA #IMPLIED
|
srs CDATA #IMPLIED
|
||||||
status (on|1|off|0) "1"
|
status (on|1|off|0) "1"
|
||||||
title CDATA ""
|
|
||||||
tolerance CDATA #IMPLIED
|
tolerance CDATA #IMPLIED
|
||||||
toleranceunits CDATA #IMPLIED
|
toleranceunits CDATA #IMPLIED
|
||||||
>
|
>
|
||||||
|
@ -90,7 +88,6 @@
|
||||||
<!-- FIXME: MapnikXMLDescription.pdf specified name is required? -->
|
<!-- FIXME: MapnikXMLDescription.pdf specified name is required? -->
|
||||||
<!ATTLIST Rule
|
<!ATTLIST Rule
|
||||||
name CDATA #IMPLIED
|
name CDATA #IMPLIED
|
||||||
title CDATA #IMPLIED
|
|
||||||
>
|
>
|
||||||
|
|
||||||
<!ELEMENT Filter (#PCDATA)>
|
<!ELEMENT Filter (#PCDATA)>
|
||||||
|
|
Loading…
Reference in a new issue