adding more sld things

This commit is contained in:
Artem Pavlenko 2005-04-05 14:32:18 +00:00
parent 0135ce9351
commit 74e2e5a47c
23 changed files with 286 additions and 159 deletions

View file

@ -12,8 +12,8 @@ extension mapnik
mapnik_python.cc
# requirements and dependencies for Boost.Python extensions
<template>@boost/libs/python/build/extension
: # path to mapnik include dir e.g.
: # path to mapnik include dir
<include>$(MAPNIK_DIR)/include
# path to libmapnik.so e.g.
# path to libmapnik.so
<library-file>$(MAPNIK_DIR)/lib/libmapnik.so
;

View file

@ -1,9 +1,9 @@
#Copyright (C) 2005 by Artem Pavlenko
lib_LTLIBRARIES = libmapnik.la
nobase_include_HEADERS = attribute.hh color.hh config.hh coord.hh coord_array.hh vertex_vector.hh ctrans.hh datasource.hh datasource_cache.hh factory.hh feature.hh query.hh filter.hh filter_visitor.hh envelope.hh gamma.hh geometry.hh geom_util.hh graphics.hh image_data.hh image_reader.hh image_util.hh layer.hh line_aa.hh map.hh mapnik.hh memory.hh params.hh plugin.hh line_symbolizer.hh polygon_symbolizer.hh image_symbolizer.hh pool.hh ptr.hh raster.hh render.hh scanline_aa.hh scanline.hh style.hh style_cache.hh style_factory.hh symbolizer.hh text.hh utils.hh vertex.hh vertex_transform.hh wkb.hh logical.hh rule.hh comparison.hh fill.hh spatial.hh expression.hh stroke.hh attribute_collector.hh colorcube.hh
nobase_include_HEADERS = attribute.hh color.hh config.hh coord.hh coord_array.hh vertex_vector.hh ctrans.hh datasource.hh datasource_cache.hh factory.hh feature.hh query.hh filter.hh filter_visitor.hh envelope.hh gamma.hh geometry.hh geom_util.hh graphics.hh image_data.hh image_reader.hh image_util.hh layer.hh line_aa.hh map.hh mapnik.hh memory.hh params.hh plugin.hh line_symbolizer.hh polygon_symbolizer.hh image_symbolizer.hh pool.hh ptr.hh raster.hh render.hh scanline_aa.hh scanline.hh style.hh style_cache.hh style_factory.hh symbolizer.hh text.hh utils.hh vertex.hh vertex_transform.hh wkb.hh logical.hh rule.hh comparison.hh fill.hh spatial.hh expression.hh stroke.hh attribute_collector.hh colorcube.hh feature_type_style.hh
libmapnik_la_SOURCES = attribute.hh color.cc color.hh coord.hh coord_array.hh vertex_vector.hh ctrans.hh datasource.hh datasource_cache.cc datasource_cache.hh envelope.cc envelope.hh query.hh factory.hh feature.hh filter.hh filter_visitor.hh geometry.hh gamma.hh geom_util.hh graphics.cc graphics.hh image_data.hh image_reader.cc image_reader.hh image_util.cc image_util.hh layer.cc layer.hh line_aa.cc line_aa.hh map.cc map.hh mapnik.hh memory.cc memory.hh params.cc params.hh plugin.cc plugin.hh png_reader.cc line_symbolizer.hh polygon_symbolizer.hh image_symbolizer.hh pool.hh ptr.hh raster.hh render.cc render.hh scanline_aa.cc scanline_aa.hh scanline.cc scanline.hh style.cc style.hh style_cache.cc style_cache.hh style_factory.hh symbolizer.hh text.cc text.hh utils.hh vertex.hh vertex_transform.hh wkb.cc wkb.hh logical.hh rule.hh comparison.hh fill.hh spatial.hh expression.hh stroke.hh attribute_collector.hh colorcube.hh
libmapnik_la_SOURCES = attribute.hh color.cc color.hh coord.hh coord_array.hh vertex_vector.hh ctrans.hh datasource.hh datasource_cache.cc datasource_cache.hh envelope.cc envelope.hh query.hh factory.hh feature.hh filter.hh filter_visitor.hh geometry.hh gamma.hh geom_util.hh graphics.cc graphics.hh image_data.hh image_reader.cc image_reader.hh image_util.cc image_util.hh layer.cc layer.hh line_aa.cc line_aa.hh map.cc map.hh mapnik.hh memory.cc memory.hh params.cc params.hh plugin.cc plugin.hh png_reader.cc line_symbolizer.hh polygon_symbolizer.hh image_symbolizer.hh pool.hh ptr.hh raster.hh render.cc render.hh scanline_aa.cc scanline_aa.hh scanline.cc scanline.hh style.cc style.hh style_cache.cc style_cache.hh style_factory.hh symbolizer.hh text.cc text.hh utils.hh vertex.hh vertex_transform.hh wkb.cc wkb.hh logical.hh rule.hh comparison.hh fill.hh spatial.hh expression.hh stroke.hh attribute_collector.hh colorcube.hh feature_type_style.hh
if BUILD_TIFF_READER
libmapnik_la_SOURCES += tiff_reader.cc

View file

@ -79,7 +79,8 @@ am__libmapnik_la_SOURCES_DIST = attribute.hh color.cc color.hh \
style_factory.hh symbolizer.hh text.cc text.hh utils.hh \
vertex.hh vertex_transform.hh wkb.cc wkb.hh logical.hh rule.hh \
comparison.hh fill.hh spatial.hh expression.hh stroke.hh \
attribute_collector.hh colorcube.hh tiff_reader.cc
attribute_collector.hh colorcube.hh feature_type_style.hh \
tiff_reader.cc
@BUILD_TIFF_READER_TRUE@am__objects_1 = libmapnik_la-tiff_reader.lo
am_libmapnik_la_OBJECTS = libmapnik_la-color.lo \
libmapnik_la-datasource_cache.lo libmapnik_la-envelope.lo \
@ -239,7 +240,7 @@ subdirs = @subdirs@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
lib_LTLIBRARIES = libmapnik.la
nobase_include_HEADERS = attribute.hh color.hh config.hh coord.hh coord_array.hh vertex_vector.hh ctrans.hh datasource.hh datasource_cache.hh factory.hh feature.hh query.hh filter.hh filter_visitor.hh envelope.hh gamma.hh geometry.hh geom_util.hh graphics.hh image_data.hh image_reader.hh image_util.hh layer.hh line_aa.hh map.hh mapnik.hh memory.hh params.hh plugin.hh line_symbolizer.hh polygon_symbolizer.hh image_symbolizer.hh pool.hh ptr.hh raster.hh render.hh scanline_aa.hh scanline.hh style.hh style_cache.hh style_factory.hh symbolizer.hh text.hh utils.hh vertex.hh vertex_transform.hh wkb.hh logical.hh rule.hh comparison.hh fill.hh spatial.hh expression.hh stroke.hh attribute_collector.hh colorcube.hh
nobase_include_HEADERS = attribute.hh color.hh config.hh coord.hh coord_array.hh vertex_vector.hh ctrans.hh datasource.hh datasource_cache.hh factory.hh feature.hh query.hh filter.hh filter_visitor.hh envelope.hh gamma.hh geometry.hh geom_util.hh graphics.hh image_data.hh image_reader.hh image_util.hh layer.hh line_aa.hh map.hh mapnik.hh memory.hh params.hh plugin.hh line_symbolizer.hh polygon_symbolizer.hh image_symbolizer.hh pool.hh ptr.hh raster.hh render.hh scanline_aa.hh scanline.hh style.hh style_cache.hh style_factory.hh symbolizer.hh text.hh utils.hh vertex.hh vertex_transform.hh wkb.hh logical.hh rule.hh comparison.hh fill.hh spatial.hh expression.hh stroke.hh attribute_collector.hh colorcube.hh feature_type_style.hh
libmapnik_la_SOURCES = attribute.hh color.cc color.hh coord.hh \
coord_array.hh vertex_vector.hh ctrans.hh datasource.hh \
datasource_cache.cc datasource_cache.hh envelope.cc \
@ -256,7 +257,8 @@ libmapnik_la_SOURCES = attribute.hh color.cc color.hh coord.hh \
style_factory.hh symbolizer.hh text.cc text.hh utils.hh \
vertex.hh vertex_transform.hh wkb.cc wkb.hh logical.hh rule.hh \
comparison.hh fill.hh spatial.hh expression.hh stroke.hh \
attribute_collector.hh colorcube.hh $(am__append_1)
attribute_collector.hh colorcube.hh feature_type_style.hh \
$(am__append_1)
libmapnik_la_CPPFLAGS = $(FREETYPE2_CFLAGS) @INCLTDL@
libmapnik_la_LIBADD = @LIBLTDL@ -lpthread -lpng -ljpeg $(FREETYPE2_LIBS) -lz -lm
libmapnik_la_LDFLAGS = -version-info 0:0:0 $(TIFF_LDFLAGS)

View file

@ -0,0 +1,35 @@
/* This file is part of Mapnik (c++ mapping toolkit)
* Copyright (C) 2005 Artem Pavlenko
*
* Mapnik is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
//$Id$
#ifndef ATTRIBUTE_DESCRIPTOR
#define ATTRIBUTE_DESCRIPTOR
#include <string>
namespace mapnik
{
struct attribute_desc
{
std::string name;
eType type;
};
}
#endif

View file

@ -53,7 +53,7 @@ namespace mapnik
return message_.c_str();
}
};
class datasource
{
public:
@ -64,15 +64,11 @@ namespace mapnik
Raster
};
virtual int type() const=0;
virtual FeaturesetPtr featuresAll(const CoordTransform& t) const=0;
virtual FeaturesetPtr featuresInBox(const CoordTransform& t,const Envelope<double>& box) const=0;
virtual FeaturesetPtr featuresAtPoint(const CoordTransform& t,const coord2d& pt) const=0;
virtual FeaturesetPtr features(const query& q) const=0;
virtual const Envelope<double>& envelope() const=0;
virtual ~datasource() {};
};
typedef std::string datasource_name();
typedef datasource* create_ds(const Parameters& params);
typedef void destroy_ds(datasource *ds);

62
src/feature_type_style.hh Normal file
View file

@ -0,0 +1,62 @@
/* This file is part of Mapnik (c++ mapping toolkit)
* Copyright (C) 2005 Artem Pavlenko
*
* Mapnik is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
//$Id$
#ifndef FEATURE_TYPE_STYLE
#define FEATURE_TYPE_STYLE
#include "rule.hh"
#include "feature.hh"
#include "ptr.hh"
#include <vector>
namespace mapnik
{
//typedef feature<geometry_ptr,raster_ptr> Feature;
typedef ref_ptr<rule<Feature,filter> > rule_ptr;
class feature_type_style
{
private:
std::vector<rule_ptr> rules_;
public:
feature_type_style() {}
feature_type_style(const feature_type_style& rhs)
: rules_(rhs.rules_) {}
feature_type_style& operator=(const feature_type_style& rhs)
{
if (this == &rhs) return *this;
rules_=rhs.rules_;
return *this;
}
void add_rule(const rule_ptr& rule)
{
rules_.push_back(rule);
}
const std::vector<rule_ptr>& rules() const
{
return rules_;
}
~feature_type_style() {}
};
}
#endif //FEATURE_TYPE_STYLE

View file

@ -96,7 +96,7 @@ namespace mapnik
if (pos_ < cont_->size())
{
value_type x,y;
vertex_.cmd=cont_->get_at(pos_,x,y);
vertex_.cmd=cont_->get_vertex(pos_,&x,&y);
vertex_.x=Transform::apply(x);
vertex_.y=Transform::apply(y);
}

View file

@ -87,8 +87,8 @@ namespace mapnik
}
png_init_io(png_ptr, fp);
png_set_compression_level(png_ptr, Z_BEST_COMPRESSION);
png_set_compression_strategy(png_ptr, Z_FILTERED);
//png_set_compression_level(png_ptr, Z_BEST_COMPRESSION);
//png_set_compression_strategy(png_ptr, Z_FILTERED);
png_set_IHDR(png_ptr, info_ptr,image.width(),image.height(),8,
PNG_COLOR_TYPE_RGB_ALPHA,PNG_INTERLACE_NONE,
PNG_COMPRESSION_TYPE_DEFAULT,PNG_FILTER_TYPE_DEFAULT);

View file

@ -54,6 +54,8 @@
#include "wkb.hh"
#include "map.hh"
#include "colorcube.hh"
#include "feature_type_style.hh"
namespace mapnik
{

View file

@ -108,7 +108,6 @@ int PostgisDatasource::type() const
return type_;
}
std::string PostgisDatasource::table_from_sql(const std::string& sql)
{
std::string table_name(sql);
@ -124,37 +123,6 @@ std::string PostgisDatasource::table_from_sql(const std::string& sql)
return table_name;
}
FeaturesetPtr PostgisDatasource::featuresAll(const CoordTransform& t) const
{
return FeaturesetPtr(0);
}
FeaturesetPtr PostgisDatasource::featuresInBox(const CoordTransform& t,
const mapnik::Envelope<double>& box) const
{
Featureset *fs=0;
ConnectionManager *mgr=ConnectionManager::instance();
ref_ptr<Pool<Connection,ConnectionCreator> > pool=mgr->getPool(creator_.id());
if (pool)
{
const ref_ptr<Connection>& conn = pool->borrowObject();
if (conn && conn->isOK())
{
PoolGuard<ref_ptr<Connection>,ref_ptr<Pool<Connection,ConnectionCreator> > > guard(conn,pool);
std::ostringstream s;
s << "select gid,asbinary("<<geometryColumn_<<") as geom from ";
s << table_<<" where "<<geometryColumn_<<"&& setSRID('BOX3D(";
s << box.minx() << " " << box.miny() << ",";
s << box.maxx() << " " << box.maxy() << ")'::box3d,"<<srid_<<")";
std::cout << s.str()<<std::endl;
ref_ptr<ResultSet> rs=conn->executeQuery(s.str(),1);
fs=new PostgisFeatureset(rs);
}
}
return FeaturesetPtr(fs);
}
FeaturesetPtr PostgisDatasource::features(const query& q) const
{
Featureset *fs=0;
@ -180,33 +148,6 @@ FeaturesetPtr PostgisDatasource::features(const query& q) const
return FeaturesetPtr(fs);
}
FeaturesetPtr PostgisDatasource::featuresAtPoint(const CoordTransform& t,
const mapnik::coord2d& pt) const
{
Featureset *fs=0;
ConnectionManager *mgr=ConnectionManager::instance();
ref_ptr<Pool<Connection,ConnectionCreator> > pool=mgr->getPool(creator_.id());
if (pool)
{
const ref_ptr<Connection>& conn = pool->borrowObject();
if (conn && conn->isOK())
{
PoolGuard<ref_ptr<Connection>,ref_ptr<Pool<Connection,ConnectionCreator> > > guard(conn,pool);
std::ostringstream s;
s << "select gid,asbinary("<<geometryColumn_<<") as geom from ";
s << table_<<" where setSRID('BOX3D(";
s << pt.x << " " << pt.y << ",";
s << pt.x << " " << pt.y << ")'::box3d,"<<srid_<<") && "<<geometryColumn_;
std::cout << s.str()<<std::endl;
ref_ptr<ResultSet> rs=conn->executeQuery(s.str(),1);
fs=new PostgisFeatureset(rs);
}
}
return FeaturesetPtr(fs);
}
const Envelope<double>& PostgisDatasource::envelope() const
{
return extent_;

View file

@ -43,11 +43,7 @@ class PostgisDatasource : public datasource
public:
static std::string name();
int type() const;
FeaturesetPtr featuresAll(const CoordTransform& t) const;
FeaturesetPtr featuresInBox(const CoordTransform& t,const mapnik::Envelope<double>& box) const;
FeaturesetPtr featuresAtPoint(const CoordTransform& t,const mapnik::coord2d& pt) const;
FeaturesetPtr features(const query& q) const;
const mapnik::Envelope<double>& envelope() const;
PostgisDatasource(const Parameters &params);
~PostgisDatasource();

107
src/query.hh Normal file
View file

@ -0,0 +1,107 @@
/* This file is part of Mapnik (c++ mapping toolkit)
* Copyright (C) 2005 Artem Pavlenko
*
* Mapnik is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
//$Id$
#ifndef QUERY_HH
#define QUERY_HH
#include <set>
#include <limits>
#include "filter.hh"
#include "envelope.hh"
#include "feature.hh"
namespace mapnik
{
class query
{
private:
Envelope<double> bbox_;
filter<Feature>* filter_;
std::set<std::string> names_;
public:
query()
: bbox_(std::numeric_limits<double>::min(),
std::numeric_limits<double>::min(),
std::numeric_limits<double>::max(),
std::numeric_limits<double>::max()),
filter_(new null_filter<Feature>)
{}
query(const Envelope<double>& bbox)
: bbox_(bbox),
filter_(new null_filter<Feature>)
{}
query(const Envelope<double>& bbox,const filter<Feature>& f)
: bbox_(bbox),
filter_(f.clone())
{}
query(const query& other)
: bbox_(other.bbox_),
filter_(other.filter_->clone())
{}
query& operator=(const query& other)
{
filter<Feature>* tmp=other.filter_->clone();
delete filter_;
filter_=tmp;
bbox_=other.bbox_;
names_=other.names_;
return *this;
}
const filter<Feature>* get_filter() const
{
return filter_;
}
const Envelope<double>& get_bbox() const
{
return bbox_;
}
void set_filter(const filter<Feature>& f)
{
filter<Feature>* tmp=f.clone();
delete filter_;
filter_=tmp;
}
void add_property_name(const std::string& name)
{
names_.insert(name);
}
const std::set<std::string>& property_names() const
{
return names_;
}
~query()
{
delete filter_;
}
};
}
#endif //QUERY_HH

View file

@ -119,6 +119,7 @@ namespace mapnik
const Color& background=map.getBackground();
image.setBackground(background);
query q(extent);
for (size_t n=0;n<map.layerCount();++n)
{
const Layer& l=map.getLayer(n);

View file

@ -29,11 +29,12 @@ namespace mapnik
{
typedef ref_ptr<Symbolizer> symbolizer_ptr;
typedef std::vector<symbolizer_ptr> symbolizers;
template <typename FeatureT> class null_filter;
template <typename Feature,template <typename> class Filter>
template <typename FeatureT,template <typename> class Filter>
class rule
{
typedef Filter<Feature> filter_type;
typedef Filter<FeatureT> filter_type;
typedef ref_ptr<filter_type> filter_ptr;
private:
@ -53,7 +54,7 @@ namespace mapnik
min_scale_(0),
max_scale_(std::numeric_limits<double>::infinity()),
syms_(),
filter_(new null_filter<Feature>),
filter_(new null_filter<FeatureT>),
else_filter_(false) {}
rule(const std::string& name,const std::string& title)
@ -63,7 +64,7 @@ namespace mapnik
min_scale_(0),
max_scale_(std::numeric_limits<double>::infinity()),
syms_(),
filter_(new null_filter<Feature>),
filter_(new null_filter<FeatureT>),
else_filter_(false) {}
rule(const std::string& name,const std::string& title,
@ -73,7 +74,7 @@ namespace mapnik
min_scale_(min_scale_denominator),
max_scale_(max_scale_denominator),
syms_(),
filter_(new null_filter<Feature>),
filter_(new null_filter<FeatureT>),
else_filter_(false) {}
rule(const rule& rhs)

View file

@ -3,6 +3,6 @@ plugins_LTLIBRARIES = shape.la
shape_la_SOURCES = dbffile.cc shape.cc shape_io.cc shape_featureset.cc shape_index_featureset.hh dbffile.hh shapefile.cc shape_featureset.hh shape_io.hh shp_index.cc dbf_test.cc shapefile.hh shape.hh shape_index_featureset.cc shp_index.hh
shape_la_LIBDADD =
shape_la_LDFLAGS = -module -version-info 0:0:0 -lpthread
shape_la_LDFLAGS = -module -version-info 0:0:0 -lpthread
shape_la_CXXFLAGS = -I$(top_srcdir)/src

View file

@ -202,7 +202,7 @@ target_alias = @target_alias@
plugins_LTLIBRARIES = shape.la
shape_la_SOURCES = dbffile.cc shape.cc shape_io.cc shape_featureset.cc shape_index_featureset.hh dbffile.hh shapefile.cc shape_featureset.hh shape_io.hh shp_index.cc dbf_test.cc shapefile.hh shape.hh shape_index_featureset.cc shp_index.hh
shape_la_LIBDADD =
shape_la_LDFLAGS = -module -version-info 0:0:0 -lpthread
shape_la_LDFLAGS = -module -version-info 0:0:0 -lpthread
shape_la_CXXFLAGS = -I$(top_srcdir)/src
all: all-am

View file

@ -102,44 +102,14 @@ std::string shape_datasource::name()
return "shape";
}
FeaturesetPtr shape_datasource::featuresAll(const CoordTransform& t) const
{
return FeaturesetPtr(0);
}
FeaturesetPtr shape_datasource::featuresInBox(const CoordTransform& t,const mapnik::Envelope<double>& box) const
{
std::cout << "query box="<<box<<std::endl;
filter_in_box filter(box);
if (indexed_)
{
return FeaturesetPtr(new ShapeIndexFeatureset<filter_in_box>(filter,shape_name_,-1));
}
return FeaturesetPtr(new ShapeFeatureset<filter_in_box>(filter,shape_name_,file_length_,-1));
}
FeaturesetPtr shape_datasource::featuresAtPoint(const CoordTransform& t,const mapnik::coord2d& pt) const
{
std::cout << "query point="<<"..todo: pt .." <<std::endl;
filter_at_point filter(pt);
if (indexed_)
{
return FeaturesetPtr(new ShapeIndexFeatureset<filter_at_point>(filter,shape_name_,-1));
}
return FeaturesetPtr(new ShapeFeatureset<filter_at_point>(filter,shape_name_,file_length_,-1));
}
FeaturesetPtr shape_datasource::features(const query& q) const
{
filter_in_box filter(q.get_bbox());
if (indexed_)
{
return FeaturesetPtr(new ShapeIndexFeatureset<filter_in_box>(filter,shape_name_,-1));
return FeaturesetPtr(new shape_index_featureset<filter_in_box>(filter,shape_name_,q.property_names()));
}
return FeaturesetPtr(new ShapeFeatureset<filter_in_box>(filter,shape_name_,file_length_,-1));
return FeaturesetPtr(new shape_featureset<filter_in_box>(filter,shape_name_,file_length_));
}
const Envelope<double>& shape_datasource::envelope() const

View file

@ -20,11 +20,10 @@
#include <iostream>
template <typename filterT>
ShapeFeatureset<filterT>::ShapeFeatureset(const filterT& filter,
const std::string& shape_file,
long file_length, int srid)
: srid_(srid),
filter_(filter),
shape_featureset<filterT>::shape_featureset(const filterT& filter,
const std::string& shape_file,
long file_length )
: filter_(filter),
shape_type_(shape_io::shape_null),
shape_(shape_file),
query_ext_(),
@ -36,7 +35,7 @@ ShapeFeatureset<filterT>::ShapeFeatureset(const filterT& filter,
template <typename filterT>
Feature* ShapeFeatureset<filterT>::next()
Feature* shape_featureset<filterT>::next()
{
Feature* feature=0;
std::streampos pos=shape_.shp().pos();
@ -111,7 +110,6 @@ Feature* ShapeFeatureset<filterT>::next()
template <typename filterT>
ShapeFeatureset<filterT>::~ShapeFeatureset() {}
shape_featureset<filterT>::~shape_featureset() {}
template class ShapeFeatureset<filter_in_box>;
template class ShapeFeatureset<filter_at_point>;
template class shape_featureset<filter_in_box>;

View file

@ -24,9 +24,8 @@
using namespace mapnik;
template <typename filterT>
class ShapeFeatureset : public Featureset
class shape_featureset : public Featureset
{
int srid_;
filterT filter_;
int shape_type_;
shape_io shape_;
@ -36,12 +35,12 @@ class ShapeFeatureset : public Featureset
mutable int total_geom_size;
mutable int count_;
public:
ShapeFeatureset(const filterT& filter, const std::string& shape_file,long file_length,int srid);
virtual ~ShapeFeatureset();
shape_featureset(const filterT& filter, const std::string& shape_file,long file_length);
virtual ~shape_featureset();
Feature* next();
private:
ShapeFeatureset(const ShapeFeatureset&);
const ShapeFeatureset& operator=(const ShapeFeatureset&);
shape_featureset(const shape_featureset&);
const shape_featureset& operator=(const shape_featureset&);
};
#endif //SHAPE_FS_HH

View file

@ -21,11 +21,10 @@
#include "shape_index_featureset.hh"
template <typename filterT>
ShapeIndexFeatureset<filterT>::ShapeIndexFeatureset(const filterT& filter,
const std::string& shape_file,
int srid)
: srid_(srid),
filter_(filter),
shape_index_featureset<filterT>::shape_index_featureset(const filterT& filter,
const std::string& shape_file,
const std::set<std::string>& attribute_names)
: filter_(filter),
shape_type_(0),
shape_(shape_file),
count_(0)
@ -41,10 +40,25 @@ ShapeIndexFeatureset<filterT>::ShapeIndexFeatureset(const filterT& filter,
}
std::cout<< "query size=" << ids_.size() << "\n";
itr_ = ids_.begin();
// deal with attributes
typename std::set<std::string>::const_iterator pos=attribute_names.begin();
while (pos!=attribute_names.end())
{
for (int i=0;i<shape_.dbf().num_fields();++i)
{
if (shape_.dbf().descriptor(i).name_ == *pos)
{
attr_ids_.push_back(i);
break;
}
}
++pos;
}
}
template <typename filterT>
Feature* ShapeIndexFeatureset<filterT>::next()
Feature* shape_index_featureset<filterT>::next()
{
Feature *f=0;
if (itr_!=ids_.end())
@ -98,19 +112,21 @@ Feature* ShapeIndexFeatureset<filterT>::next()
break;
}
}
if (0)
if (attr_ids_.size())
{
shape_.dbf().move_to(shape_.id_);
for (int j=0;j<shape_.dbf().num_fields();++j)
typename std::vector<int>::const_iterator pos=attr_ids_.begin();
while (pos!=attr_ids_.end())
{
try
{
shape_.dbf().add_attribute(j,f);//TODO optimize!!!
shape_.dbf().add_attribute(*pos,f);//TODO optimize!!!
}
catch (...)
{
//TODO
}
++pos;
}
}
}
@ -121,8 +137,7 @@ Feature* ShapeIndexFeatureset<filterT>::next()
template <typename filterT>
ShapeIndexFeatureset<filterT>::~ShapeIndexFeatureset() {}
shape_index_featureset<filterT>::~shape_index_featureset() {}
template class ShapeIndexFeatureset<filter_at_point>;
template class ShapeIndexFeatureset<filter_in_box>;
template class shape_index_featureset<filter_in_box>;

View file

@ -21,29 +21,29 @@
#include "shape_featureset.hh"
#include <set>
#include <vector>
template <typename filterT>
class ShapeIndexFeatureset : public Featureset
class shape_index_featureset : public Featureset
{
int srid_;
filterT filter_;
int shape_type_;
shape_io shape_;
Envelope<double> query_ext_;
std::set<int> ids_;
std::set<int>::iterator itr_;
std::vector<int> attr_ids_;
mutable Envelope<double> feature_ext_;
mutable int total_geom_size;
mutable int count_;
public:
ShapeIndexFeatureset(const filterT& filter,const std::string& shape_file,int srid);
virtual ~ShapeIndexFeatureset();
shape_index_featureset(const filterT& filter,const std::string& shape_file,
const std::set<std::string>& attribute_names);
virtual ~shape_index_featureset();
Feature* next();
private:
//no copying
ShapeIndexFeatureset(const ShapeIndexFeatureset&);
ShapeIndexFeatureset& operator=(const ShapeIndexFeatureset&);
shape_index_featureset(const shape_index_featureset&);
shape_index_featureset& operator=(const shape_index_featureset&);
};
#endif //SHAPE_SQT_FS_HH

View file

@ -21,9 +21,11 @@
#ifndef STYLE_HH
#define STYLE_HH
//#include "feature.hh"
#include "color.hh"
#include "ptr.hh"
#include "symbolizer.hh"
//#include "rule.hh"
#include <vector>
#include <algorithm>
@ -86,7 +88,7 @@ namespace mapnik
{
return symbols_.end();
}
};
};
}
#endif //STYLE_HH
#endif //STYLE_HH

View file

@ -31,9 +31,9 @@ namespace mapnik
{
typedef T0 value_type;
typedef T1 return_type;
static return_type apply(const value_type val)
static return_type apply(value_type val)
{
return return_type(val*(1<<shift));
return static_cast<return_type>(val*(1<<shift));
}
};
@ -42,9 +42,9 @@ namespace mapnik
{
typedef T0 value_type;
typedef T1 return_type;
static return_type apply(const value_type val)
static return_type apply(value_type val)
{
return return_type(val);
return static_cast<return_type>(val);
}
};