revived shape support + removed unsed header from postgis.cpp

This commit is contained in:
Artem Pavlenko 2005-06-16 20:56:31 +00:00
parent 41d8341547
commit 84bd684f87
20 changed files with 93 additions and 58 deletions

View file

@ -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())

View file

@ -19,7 +19,6 @@
//$Id: postgis.cc 44 2005-04-22 18:53:54Z pavlenko $
#include "postgis.hpp"
#include <netinet/in.h>
#include <string>
#include <algorithm>
#include <set>

View file

@ -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)

View file

@ -18,7 +18,7 @@
#include <iostream>
#include <iomanip>
#include "dbffile.hh"
#include "dbffile.hpp"
using namespace std;

View file

@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "dbffile.hh"
#include "dbffile.hpp"
#include <string>
@ -113,7 +113,7 @@ void dbf_file::add_attribute(int col,Feature* f) const throw()
{
if (col>=0 && col<num_fields_)
{
std::string name=fields_[col].name_;
std::string str=trim(std::string(record_+fields_[col].offset_,fields_[col].length_));
switch (fields_[col].type_)
@ -122,29 +122,27 @@ void dbf_file::add_attribute(int col,Feature* f) const throw()
case 'D'://todo handle date?
case 'M':
case 'L':
{
f->add_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;
}

View file

@ -24,7 +24,7 @@
#include <fstream>
#include <cassert>
#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();

View file

@ -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 <iostream>
#include <stdexcept>
@ -29,12 +29,46 @@ shape_datasource::shape_datasource(const Parameters &params)
: 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;i<shape.dbf().num_fields();++i)
{
field_descriptor const& fd=shape.dbf().descriptor(i);
std::string fld_name=fd.name_;
switch (fd.type_)
{
case 'C':
case 'D':
case 'M':
case 'L':
desc_.add_descriptor(attribute_descriptor(fld_name,String));
break;
case 'N':
case 'F':
{
if (fd.dec_>0)
{
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 "<<fd.type_<<"\n";
break;
}
}
}
catch (datasource_exception& ex)
{
@ -91,6 +125,10 @@ int shape_datasource::type() const
return type_;
}
layer_descriptor const& shape_datasource::get_descriptor() const
{
return desc_;
}
std::string shape_datasource::name()
{

View file

@ -19,30 +19,35 @@
#ifndef SHAPE_HH
#define SHAPE_HH
#include "mapnik.hh"
#include "shape_io.hh"
#include "mapnik.hpp"
#include "shape_io.hpp"
using namespace mapnik;
class shape_datasource : public datasource
{
std::string shape_name_;
int type_;
long file_length_;
mapnik::Envelope<double> extent_;
bool indexed_;
static std::string name_;
public:
int type() const;
static std::string name();
featureset_ptr features(const query& q) const;
const Envelope<double>& envelope() const;
shape_datasource(const Parameters &params);
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<double> extent_;
bool indexed_;
layer_descriptor desc_;
static std::string name_;
};
#endif //SHAPE_HH

View file

@ -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 <iostream>
template <typename filterT>

View file

@ -19,7 +19,7 @@
#ifndef SHAPE_FS_HH
#define SHAPE_FS_HH
#include "shape.hh"
#include "shape.hpp"
using namespace mapnik;

View file

@ -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 <typename filterT>
shape_index_featureset<filterT>::shape_index_featureset(const filterT& filter,

View file

@ -19,7 +19,7 @@
#ifndef SHAPE_SQT_FS_HH
#define SHAPE_SQT_FS_HH
#include "shape_featureset.hh"
#include "shape_featureset.hpp"
#include <set>
#include <vector>

View file

@ -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";

View file

@ -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;

View file

@ -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() {}

View file

@ -21,7 +21,7 @@
#ifndef SHAPEFILE_HH
#define SHAPEFILE_HH
#include "mapnik.hh"
#include "mapnik.hpp"
#include <fstream>
using namespace mapnik;

View file

@ -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 <typename filterT>
void shp_index<filterT>::query(const filterT& filter,std::ifstream& file,std::set<int>& pos)

View file

@ -19,7 +19,7 @@
#ifndef SHP_INDEX_HH
#define SHP_INDEX_HH
#include "mapnik.hh"
#include "mapnik.hpp"
#include <fstream>
#include <set>

View file

@ -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<FeatureT>& v)
{

View file

@ -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