diff --git a/SConstruct b/SConstruct index 70822cc44..5e4bf4417 100644 --- a/SConstruct +++ b/SConstruct @@ -11,7 +11,7 @@ opts.Add(PathOption('AGG_ROOT','agg source root directory','/opt/agg23')) opts.Add(PathOption('FREETYPE2_ROOT','freetype2 root directory','/opt/freetype2')) opts.Add(PathOption('PYTHON_ROOT','python root directory','/opt/python')) opts.Add('PYTHON_VERSION','python version','2.4') -opts.Add(ListOption('DATASOURCES','list of available datasources','postgis',['postgis'])) +opts.Add(ListOption('DATASOURCES','list of available datasources','postgis',['postgis','shape'])) opts.Add('POSTGRESQL_ROOT','path to postgresql prefix','/usr/local') platform = ARGUMENTS.get("OS",Platform()) diff --git a/datasources/postgis/postgis.cpp b/datasources/postgis/postgis.cpp index b782aaf26..2aab6a6e0 100644 --- a/datasources/postgis/postgis.cpp +++ b/datasources/postgis/postgis.cpp @@ -19,7 +19,6 @@ //$Id: postgis.cc 44 2005-04-22 18:53:54Z pavlenko $ #include "postgis.hpp" -#include #include #include #include diff --git a/datasources/shape/SConscript b/datasources/shape/SConscript index d423b77df..6d99108a7 100644 --- a/datasources/shape/SConscript +++ b/datasources/shape/SConscript @@ -9,18 +9,18 @@ agg_headers = agg_root + '/include' shape_src = Split( """ - dbffile.cc - shape.cc - shape_featureset.cc - shapefile.cc - shape_index_featureset.cc - shape_io.cc - shp_index.cc + dbffile.cpp + shape.cpp + shape_featureset.cpp + shapefile.cpp + shape_index_featureset.cpp + shape_io.cpp + shp_index.cpp """ ) headers = ['#include',boost_root,agg_headers] shape_datasource = env.SharedLibrary('shape',source=shape_src,SHLIBPREFIX='',CPPPATH=headers) -env.Install('#stage/datasources',shape_datasource) -#env.Default(shape_datasource) +env.Install(prefix+"/datasources",shape_datasource) + diff --git a/datasources/shape/dbf_test.cpp b/datasources/shape/dbf_test.cpp index 96d78f9d0..418d3eae5 100644 --- a/datasources/shape/dbf_test.cpp +++ b/datasources/shape/dbf_test.cpp @@ -18,7 +18,7 @@ #include #include -#include "dbffile.hh" +#include "dbffile.hpp" using namespace std; diff --git a/datasources/shape/dbffile.cpp b/datasources/shape/dbffile.cpp index 0a59d55ad..35693a817 100644 --- a/datasources/shape/dbffile.cpp +++ b/datasources/shape/dbffile.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "dbffile.hh" +#include "dbffile.hpp" #include @@ -113,7 +113,7 @@ void dbf_file::add_attribute(int col,Feature* f) const throw() { if (col>=0 && coladd_property(name,str); - break; - } + f->add_property(str); + break; case 'N': case 'F': { if (str[0]=='*') { + f->add_property("null"); break; } if (fields_[col].dec_>0) { double d; fromString(str,d); - - f->add_property(name,d); + f->add_property(d); } else { int i; fromString(str,i); - f->add_property(name,i); + f->add_property(i); } break; } diff --git a/datasources/shape/dbffile.hpp b/datasources/shape/dbffile.hpp index 370b5f5c3..3e439f682 100644 --- a/datasources/shape/dbffile.hpp +++ b/datasources/shape/dbffile.hpp @@ -24,7 +24,7 @@ #include #include -#include "mapnik.hh" +#include "mapnik.hpp" using namespace mapnik; @@ -58,7 +58,7 @@ class dbf_file void close(); int num_records() const; int num_fields() const; - const field_descriptor& descriptor(int col) const; + field_descriptor const& descriptor(int col) const; void move_to(int index); std::string string_value(int col) const; void add_attribute(int col,Feature* f) const throw(); diff --git a/datasources/shape/shape.cpp b/datasources/shape/shape.cpp index 4cf6c5145..8417e1ee2 100644 --- a/datasources/shape/shape.cpp +++ b/datasources/shape/shape.cpp @@ -16,9 +16,9 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "shape.hh" -#include "shape_featureset.hh" -#include "shape_index_featureset.hh" +#include "shape.hpp" +#include "shape_featureset.hpp" +#include "shape_index_featureset.hpp" #include #include @@ -29,12 +29,46 @@ shape_datasource::shape_datasource(const Parameters ¶ms) : shape_name_(params.get("file")), type_(datasource::Vector), file_length_(0), - indexed_(false) + indexed_(false), + desc_(params.get("name")) { try { shape_io shape(shape_name_); init(shape); + for (int i=0;i0) + { + desc_.add_descriptor(attribute_descriptor(fld_name,Double,false,8)); + } + else + { + desc_.add_descriptor(attribute_descriptor(fld_name,Integer,false,4)); + } + break; + } + default: + // + std::cout << "uknown type "< extent_; - bool indexed_; - static std::string name_; + public: int type() const; static std::string name(); featureset_ptr features(const query& q) const; const Envelope& envelope() const; shape_datasource(const Parameters ¶ms); + layer_descriptor const& get_descriptor() const; virtual ~shape_datasource(); private: shape_datasource(const shape_datasource&); shape_datasource& operator=(const shape_datasource&); void init(shape_io& shape); +private: + std::string shape_name_; + int type_; + long file_length_; + mapnik::Envelope extent_; + bool indexed_; + layer_descriptor desc_; + static std::string name_; + }; #endif //SHAPE_HH diff --git a/datasources/shape/shape_featureset.cpp b/datasources/shape/shape_featureset.cpp index 0be40169b..f33409298 100644 --- a/datasources/shape/shape_featureset.cpp +++ b/datasources/shape/shape_featureset.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "shape_featureset.hh" +#include "shape_featureset.hpp" #include template diff --git a/datasources/shape/shape_featureset.hpp b/datasources/shape/shape_featureset.hpp index 1219080c7..d724acaad 100644 --- a/datasources/shape/shape_featureset.hpp +++ b/datasources/shape/shape_featureset.hpp @@ -19,7 +19,7 @@ #ifndef SHAPE_FS_HH #define SHAPE_FS_HH -#include "shape.hh" +#include "shape.hpp" using namespace mapnik; diff --git a/datasources/shape/shape_index_featureset.cpp b/datasources/shape/shape_index_featureset.cpp index d2263b7b2..e7abab37a 100644 --- a/datasources/shape/shape_index_featureset.cpp +++ b/datasources/shape/shape_index_featureset.cpp @@ -18,7 +18,7 @@ //$Id: shape_index_featureset.cc 36 2005-04-05 14:32:18Z pavlenko $ -#include "shape_index_featureset.hh" +#include "shape_index_featureset.hpp" template shape_index_featureset::shape_index_featureset(const filterT& filter, diff --git a/datasources/shape/shape_index_featureset.hpp b/datasources/shape/shape_index_featureset.hpp index 4d2790007..436a081b2 100644 --- a/datasources/shape/shape_index_featureset.hpp +++ b/datasources/shape/shape_index_featureset.hpp @@ -19,7 +19,7 @@ #ifndef SHAPE_SQT_FS_HH #define SHAPE_SQT_FS_HH -#include "shape_featureset.hh" +#include "shape_featureset.hpp" #include #include diff --git a/datasources/shape/shape_io.cpp b/datasources/shape/shape_io.cpp index 343e66a72..55961c42d 100644 --- a/datasources/shape/shape_io.cpp +++ b/datasources/shape/shape_io.cpp @@ -18,8 +18,8 @@ //$Id: shape_io.cc 26 2005-03-29 19:18:59Z pavlenko $ -#include "shape_io.hh" -#include "shape.hh" +#include "shape_io.hpp" +#include "shape.hpp" const std::string shape_io::SHP = ".shp"; diff --git a/datasources/shape/shape_io.hpp b/datasources/shape/shape_io.hpp index 07dcaaaea..1cdf1b0d8 100644 --- a/datasources/shape/shape_io.hpp +++ b/datasources/shape/shape_io.hpp @@ -19,9 +19,9 @@ #ifndef SHAPE_IO_HH #define SHAPE_IO_HH -#include "dbffile.hh" -#include "shapefile.hh" -#include "shp_index.hh" +#include "dbffile.hpp" +#include "shapefile.hpp" +#include "shp_index.hpp" using mapnik::geometry_ptr; diff --git a/datasources/shape/shapefile.cpp b/datasources/shape/shapefile.cpp index 43d73820b..ae191ed74 100644 --- a/datasources/shape/shapefile.cpp +++ b/datasources/shape/shapefile.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "shapefile.hh" +#include "shapefile.hpp" shape_file::shape_file() {} diff --git a/datasources/shape/shapefile.hpp b/datasources/shape/shapefile.hpp index bc8f1c642..8a61251d2 100644 --- a/datasources/shape/shapefile.hpp +++ b/datasources/shape/shapefile.hpp @@ -21,7 +21,7 @@ #ifndef SHAPEFILE_HH #define SHAPEFILE_HH -#include "mapnik.hh" +#include "mapnik.hpp" #include using namespace mapnik; diff --git a/datasources/shape/shp_index.cpp b/datasources/shape/shp_index.cpp index 9b89c111c..892a93cf7 100644 --- a/datasources/shape/shp_index.cpp +++ b/datasources/shape/shp_index.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "shp_index.hh" +#include "shp_index.hpp" template void shp_index::query(const filterT& filter,std::ifstream& file,std::set& pos) diff --git a/datasources/shape/shp_index.hpp b/datasources/shape/shp_index.hpp index 675284d06..ad109130f 100644 --- a/datasources/shape/shp_index.hpp +++ b/datasources/shape/shp_index.hpp @@ -19,7 +19,7 @@ #ifndef SHP_INDEX_HH #define SHP_INDEX_HH -#include "mapnik.hh" +#include "mapnik.hpp" #include #include diff --git a/include/expression.hpp b/include/expression.hpp index 54403298d..db4715927 100644 --- a/include/expression.hpp +++ b/include/expression.hpp @@ -95,14 +95,7 @@ namespace mapnik value get_value(FeatureT const& feature) const { - if (valid_) - { - return feature.get_property(index_); - } - else - { - return value(""); - } + return feature.get_property(index_); } void accept(filter_visitor& v) { diff --git a/include/feature.hpp b/include/feature.hpp index b134876fd..6d49f3f4f 100644 --- a/include/feature.hpp +++ b/include/feature.hpp @@ -104,8 +104,10 @@ namespace mapnik value get_property(size_t index) const { - assert(index < props_.size()); - return props_[index]; + if (index < props_.size()) + return props_[index]; + else + return value(""); } const properties& get_properties() const