Permalink
Browse files

Added transcoder based on iconv. Internally we use UCS-2 at the moment.

 * Postgis plug-in determines encoding by querying 'client_encoding' parameter (libpq). 
 * Shapfiles (dbf!) don't store character encoding information. Users can apply 'encoding' parameter at datasource creation stage (defaults to Latin1 (ISO-8859-1))
 * Raster plug-in utf-8
  • Loading branch information...
artemp committed Feb 6, 2007
1 parent fe313cd commit e016bd61f8a3564c560282049e2cd12559552860
View
@@ -43,7 +43,7 @@ int main ( int argc , char** argv)
std::cout << " running demo ... \n";
datasource_cache::instance()->register_datasources(argv[1]);
- freetype_engine::instance()->register_font("/usr/share/fonts/bitstream-vera/Vera.ttf");
+ freetype_engine::instance()->register_font("/opt/mapnik/lib64/mapnik/fonts//Vera.ttf");
Map m(800,600);
m.setBackground(color_factory::from_string("white"));
View
@@ -271,7 +271,7 @@
# Populated Places
popplaces_lyr = Layer('Populated Places')
-popplaces_lyr.datasource = Shapefile(file='../data/popplaces')
+popplaces_lyr.datasource = Shapefile(file='../data/popplaces',encoding='latin1')
popplaces_style = Style()
popplaces_rule = Rule()
@@ -27,13 +27,15 @@
// boost
#include <boost/utility.hpp>
+#include <boost/shared_ptr.hpp>
// mapnik
+#include <mapnik/config.hpp>
#include <mapnik/feature_style_processor.hpp>
#include <mapnik/font_engine_freetype.hpp>
#include <mapnik/label_collision_detector.hpp>
#include <mapnik/placement_finder.hpp>
#include <mapnik/map.hpp>
-#include <mapnik/config.hpp>
+#include <mapnik/unicode.hpp>
namespace mapnik {
template <typename T>
@@ -71,12 +73,12 @@ namespace mapnik {
Feature const& feature,
proj_transform const& prj_trans);
private:
- T & pixmap_;
- CoordTransform t_;
- face_manager<freetype_engine> font_manager_;
-// label_collision_detector2 label_detector_;
- placement_finder finder_;
- label_collision_detector2 point_detector_; //Note: May want to merge this with placement_finder
+ T & pixmap_;
+ CoordTransform t_;
+ face_manager<freetype_engine> font_manager_;
+ placement_finder finder_;
+ label_collision_detector2 point_detector_; //Note: May want to merge this with placement_finder
+ boost::shared_ptr<transcoder> tr_;
};
}
@@ -32,157 +32,157 @@
namespace mapnik
{
- using std::string;
- using std::vector;
- using std::clog;
- using std::endl;
+ using std::string;
+ using std::vector;
+ using std::clog;
- enum {
- Integer=1,
- Float =2,
- Double =3,
- String =4,
- Geometry=5,
- Object=6
- };
+ enum {
+ Integer=1,
+ Float =2,
+ Double =3,
+ String =4,
+ Geometry=5,
+ Object=6
+ };
- class attribute_descriptor
- {
- public:
- attribute_descriptor(string const& name,unsigned type,
- bool primary_key=false,
- int size=-1,
- int precision=-1)
+ class attribute_descriptor
+ {
+ public:
+ attribute_descriptor(string const& name,unsigned type,
+ bool primary_key=false,
+ int size=-1,
+ int precision=-1)
: name_(name),
type_(type),
primary_key_(primary_key),
size_(size),
precision_(precision) {}
- attribute_descriptor(attribute_descriptor const& other)
+ attribute_descriptor(attribute_descriptor const& other)
: name_(other.name_),
type_(other.type_),
primary_key_(other.primary_key_),
size_(other.size_),
precision_(other.precision_) {}
- attribute_descriptor& operator=(attribute_descriptor const& other)
- {
+ attribute_descriptor& operator=(attribute_descriptor const& other)
+ {
if (this == &other)
- return *this;
+ return *this;
name_=other.name_;
type_=other.type_;
primary_key_=other.primary_key_;
size_=other.size_;
precision_=other.precision_;
return *this;
- }
- string const& get_name() const
- {
+ }
+ string const& get_name() const
+ {
return name_;
- }
- unsigned get_type() const
- {
+ }
+ unsigned get_type() const
+ {
return type_;
- }
- bool is_primary_key() const
- {
+ }
+ bool is_primary_key() const
+ {
return primary_key_;
- }
- int get_size() const
- {
+ }
+ int get_size() const
+ {
return size_;
- }
+ }
- int get_precision() const
- {
+ int get_precision() const
+ {
return precision_;
- }
- private:
- string name_;
- int type_;
- bool primary_key_;
- int size_;
- int precision_;
- };
+ }
+ private:
+ string name_;
+ int type_;
+ bool primary_key_;
+ int size_;
+ int precision_;
+ };
- template <typename charT,typename traits>
- inline std::basic_ostream<charT,traits>&
- operator << (std::basic_ostream<charT,traits>& out,
- attribute_descriptor const& ad)
- {
- out << "name=" << ad.get_name() << endl;
- out << "type=" << ad.get_type() << endl;
- out << "size=" << ad.get_size() << endl;
- return out;
- }
+ template <typename charT,typename traits>
+ inline std::basic_ostream<charT,traits>&
+ operator << (std::basic_ostream<charT,traits>& out,
+ attribute_descriptor const& ad)
+ {
+ out << "name=" << ad.get_name() << "\n";
+ out << "type=" << ad.get_type() << "\n";
+ out << "size=" << ad.get_size() << "\n";
+ return out;
+ }
- class layer_descriptor
- {
- public:
- layer_descriptor(string const& name,int srid=-1)
+ class layer_descriptor
+ {
+ public:
+ layer_descriptor(string const& name,string const& encoding)
: name_(name),
- srid_(srid) {}
+ encoding_(encoding) {}
- layer_descriptor(layer_descriptor const& other)
+ layer_descriptor(layer_descriptor const& other)
: name_(other.name_),
- srid_(other.srid_),
+ encoding_(other.encoding_),
desc_ar_(other.desc_ar_) {}
- void set_name(string const& name)
- {
+ void set_name(string const& name)
+ {
name_=name;
- }
- string const& get_name() const
- {
+ }
+
+ string const& get_name() const
+ {
return name_;
- }
+ }
- void set_srid(int srid)
- {
- srid_=srid;
- }
+ void set_encoding(std::string const& encoding)
+ {
+ encoding_=encoding;
+ }
- int get_srid() const
- {
- return srid_;
- }
+ std::string const& get_encoding() const
+ {
+ return encoding_;
+ }
- void add_descriptor(attribute_descriptor const& desc)
- {
+ void add_descriptor(attribute_descriptor const& desc)
+ {
desc_ar_.push_back(desc);
- }
+ }
- vector<attribute_descriptor> const& get_descriptors() const
- {
+ vector<attribute_descriptor> const& get_descriptors() const
+ {
return desc_ar_;
- }
- vector<attribute_descriptor>& get_descriptors()
- {
+ }
+ vector<attribute_descriptor>& get_descriptors()
+ {
return desc_ar_;
- }
- private:
- string name_;
- int srid_;
- vector<attribute_descriptor> desc_ar_;
- };
+ }
+ private:
+ string name_;
+ string encoding_;
+ vector<attribute_descriptor> desc_ar_;
+ };
- template <typename charT,typename traits>
- inline std::basic_ostream<charT,traits>&
- operator << (std::basic_ostream<charT,traits>& out,
- layer_descriptor const& ld)
- {
- out << "name=" << ld.get_name() << endl;
- out << "srid=" << ld.get_srid() << endl;
- vector<attribute_descriptor> const& desc_ar=ld.get_descriptors();
- vector<attribute_descriptor>::const_iterator pos=desc_ar.begin();
- while (pos != desc_ar.end())
- {
- out << *pos++ << endl;
+ template <typename charT,typename traits>
+ inline std::basic_ostream<charT,traits>&
+ operator << (std::basic_ostream<charT,traits>& out,
+ layer_descriptor const& ld)
+ {
+ out << "name=" << ld.get_name() << "\n";
+ out << "encoding=" << ld.get_encoding() << "\n";
+ vector<attribute_descriptor> const& desc_ar=ld.get_descriptors();
+ vector<attribute_descriptor>::const_iterator pos=desc_ar.begin();
+ while (pos != desc_ar.end())
+ {
+ out << *pos++ << "\n";
- }
- return out;
- }
+ }
+ return out;
+ }
}
#endif //FEATURE_LAYER_DESC_HPP
@@ -53,7 +53,7 @@ namespace mapnik
} else if (q<0.0) result=false;
return result;
}
-
+
template <typename T,typename Image>
bool clip_line(T& x0,T& y0,T& x1,T& y1,Envelope<T> const& box)
{
@@ -37,8 +37,15 @@ namespace mapnik {
void save_to_file(std::string const& filename,
std::string const& type,
T const& image);
-
-
+ template <typename T>
+ void save_as_png(std::string const& filename,
+ T const& image);
+
+ template <typename T>
+ void save_as_jpeg(std::string const& filename,
+ int quality,
+ T const& image);
+
template <typename T>
double distance(T x0,T y0,T x1,T y1)
{
@@ -210,15 +217,16 @@ namespace mapnik {
}
}
}
+
#ifdef _MSC_VER
- template MAPNIK_DECL void save_to_file<ImageData32>(std::string const&,
- std::string const& ,
- ImageData32 const&);
-
- template MAPNIK_DECL void save_to_file<image_view<ImageData32> > (std::string const&,
- std::string const& ,
- image_view<ImageData32> const&);
-#endif
+ template MAPNIK_DECL void save_to_file<ImageData32>(std::string const&,
+ std::string const& ,
+ ImageData32 const&);
+ template MAPNIK_DECL void save_to_file<image_view<ImageData32> > (std::string const&,
+ std::string const& ,
+ image_view<ImageData32> const&);
+#endif
+
}
#endif //IMAGE_UTIL_HPP
Oops, something went wrong.

0 comments on commit e016bd6

Please sign in to comment.