Osmium  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Classes | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
Osmium::Export::Shapefile Class Reference

#include <shapefile.hpp>

Inheritance diagram for Osmium::Export::Shapefile:
Inheritance graph
[legend]
Collaboration diagram for Osmium::Export::Shapefile:
Collaboration graph
[legend]

List of all members.

Classes

class  Field
struct  JavascriptTemplate

Public Member Functions

virtual ~Shapefile ()
void close ()
void add_field (Field &field)
void add_field (const std::string &name, DBFFieldType type, int width=1, int decimals=0)
void add_field (const std::string &name, const std::string &type, int width=1, int decimals=0)
void add_geometry (SHPObject *shp_object)
void add_attribute (const int field, const bool value) const
void add_attribute (const int field, const int value) const
void add_attribute (const int field, const std::string &value) const
void add_attribute (const int field, const char *value) const
void add_attribute (const int field) const
void add_attribute_with_truncate (const int field, const char *value)
void add_attribute_with_truncate (const int field, const std::string &value)
int add_string_attribute (int n, v8::Local< v8::Value > value) const
int add_logical_attribute (int n, v8::Local< v8::Value > value) const
bool add (Osmium::Geometry::Geometry *geometry, v8::Local< v8::Object > attributes)
v8::Local< v8::Object > js_instance () const
v8::Handle< v8::Value > js_add_field (const v8::Arguments &args)
v8::Handle< v8::Value > js_add (const v8::Arguments &args)
v8::Handle< v8::Value > js_close (const v8::Arguments &)

Protected Member Functions

 Shapefile (const std::string &filename, int type)

Private Member Functions

void open ()

Private Attributes

const std::string m_filename_base
 base filename
std::vector< Fieldm_fields
 fields in DBF
SHPHandle m_shp_handle
DBFHandle m_dbf_handle
int m_current_shape
 entity number of the shape we are currently writing
int m_type
 shapefile type
int m_sequence_number
 shapefile sequence number for auto-overflow (0=first)

Static Private Attributes

static const unsigned int max_dbf_fields = 16
static const unsigned int max_dbf_field_name_length = 11
static const int max_dbf_field_length = 255

Constructor & Destructor Documentation

virtual Osmium::Export::Shapefile::~Shapefile ( ) [inline, virtual]
Osmium::Export::Shapefile::Shapefile ( const std::string &  filename,
int  type 
) [inline, protected]

The constructor for Shapefile is protected. Use one of PointShapefile, LineShapefile, or PolygonShapefile.


Member Function Documentation

bool Osmium::Export::Shapefile::add ( Osmium::Geometry::Geometry geometry,
v8::Local< v8::Object >  attributes 
) [inline]

Add a geometry to the shapefile.

< a Javascript object (hash) with the attributes

Parameters:
geometrythe geometry
void Osmium::Export::Shapefile::add_attribute ( const int  field,
const bool  value 
) const [inline]
void Osmium::Export::Shapefile::add_attribute ( const int  field,
const int  value 
) const [inline]
void Osmium::Export::Shapefile::add_attribute ( const int  field,
const std::string &  value 
) const [inline]
void Osmium::Export::Shapefile::add_attribute ( const int  field,
const char *  value 
) const [inline]
void Osmium::Export::Shapefile::add_attribute ( const int  field) const [inline]
void Osmium::Export::Shapefile::add_attribute_with_truncate ( const int  field,
const char *  value 
) [inline]
void Osmium::Export::Shapefile::add_attribute_with_truncate ( const int  field,
const std::string &  value 
) [inline]
void Osmium::Export::Shapefile::add_field ( Field field) [inline]

Add a field to a shapefile.

void Osmium::Export::Shapefile::add_field ( const std::string &  name,
DBFFieldType  type,
int  width = 1,
int  decimals = 0 
) [inline]

Add a field to a shapefile.

Parameters:
nameThe name of the field (1 to 11 characters long)
typeThe type of the field (FT_STRING, FT_INTEGER, FT_DOUBLE, or FT_BOOL)
widthThe width of the field (number of digits for ints and doubles)
decimalsThe precision of double fields (otherwise ignored)
void Osmium::Export::Shapefile::add_field ( const std::string &  name,
const std::string &  type,
int  width = 1,
int  decimals = 0 
) [inline]

Add a field to a shapefile.

Parameters:
nameThe name of the field (1 to 11 characters long)
typeThe type of the field ("string", "integer", "double", or "bool")
widthThe width of the field (number of digits for ints and doubles)
decimalsThe precision of double fields (otherwise ignored)
void Osmium::Export::Shapefile::add_geometry ( SHPObject *  shp_object) [inline]

Add a new geometry (shape object) to the Shapefile. You have to call this first for every new shape. After that you call add_attribute() for all the attributes.

Parameters:
shp_objectA pointer to the shape object to be added. The object will be freed for you by calling SHPDestroyObject()!
Exceptions:
Osmium::Exception::IllegalGeometryIf shp_object is NULL or the type of geometry does not fit the type of the shapefile.
int Osmium::Export::Shapefile::add_logical_attribute ( int  n,
v8::Local< v8::Value >  value 
) const [inline]
int Osmium::Export::Shapefile::add_string_attribute ( int  n,
v8::Local< v8::Value >  value 
) const [inline]
v8::Handle<v8::Value> Osmium::Export::Shapefile::js_add ( const v8::Arguments &  args) [inline]
v8::Handle<v8::Value> Osmium::Export::Shapefile::js_add_field ( const v8::Arguments &  args) [inline]
v8::Handle<v8::Value> Osmium::Export::Shapefile::js_close ( const v8::Arguments &  ) [inline]
v8::Local<v8::Object> Osmium::Export::Shapefile::js_instance ( ) const [inline]
void Osmium::Export::Shapefile::open ( ) [inline, private]

Open and initialize all files belonging to shapefile (.shp/shx/dbf/prj/cpg). Uses m_filename_base and m_sequence_number plus suffix to build filename.


Member Data Documentation

entity number of the shape we are currently writing

fields in DBF

const std::string Osmium::Export::Shapefile::m_filename_base [private]

base filename

shapefile sequence number for auto-overflow (0=first)

shapefile type

const int Osmium::Export::Shapefile::max_dbf_field_length = 255 [static, private]
const unsigned int Osmium::Export::Shapefile::max_dbf_field_name_length = 11 [static, private]
const unsigned int Osmium::Export::Shapefile::max_dbf_fields = 16 [static, private]

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines