Permalink
Browse files

cpp coding style cleanups

  • Loading branch information...
1 parent 0f1386a commit 3a029356a5619b55f8f48df5877ecd92a5db49f9 Dane Springmeyer committed Apr 12, 2012
Showing with 944 additions and 1,072 deletions.
  1. +1 −0 .gitignore
  2. +4 −0 Makefile
  3. +50 −175 src/ds_emitter.hpp
  4. +9 −9 src/js_grid_utils.hpp
  5. +2 −2 src/mapnik_.cpp
  6. +2 −2 src/mapnik_.hpp
  7. +18 −18 src/mapnik_color.cpp
  8. +3 −3 src/mapnik_color.hpp
  9. +24 −24 src/mapnik_datasource.cpp
  10. +2 −2 src/mapnik_datasource.hpp
  11. +9 −9 src/mapnik_expression.cpp
  12. +2 −2 src/mapnik_expression.hpp
  13. +20 −20 src/mapnik_feature.cpp
  14. +2 −2 src/mapnik_feature.hpp
  15. +7 −7 src/mapnik_featureset.cpp
  16. +3 −3 src/mapnik_featureset.hpp
  17. +17 −17 src/mapnik_fonts.hpp
  18. +10 −10 src/mapnik_geometry.cpp
  19. +2 −2 src/mapnik_geometry.hpp
  20. +66 −67 src/mapnik_grid.cpp
  21. +3 −3 src/mapnik_grid.hpp
  22. +54 −55 src/mapnik_grid_view.cpp
  23. +3 −3 src/mapnik_grid_view.hpp
  24. +78 −87 src/mapnik_image.cpp
  25. +3 −3 src/mapnik_image.hpp
  26. +52 −61 src/mapnik_image_view.cpp
  27. +3 −3 src/mapnik_image_view.hpp
  28. +12 −12 src/mapnik_js_datasource.cpp
  29. +2 −2 src/mapnik_js_datasource.hpp
  30. +15 −15 src/mapnik_layer.cpp
  31. +4 −4 src/mapnik_layer.hpp
  32. +180 −187 src/mapnik_map.cpp
  33. +4 −4 src/mapnik_map.hpp
  34. +16 −16 src/mapnik_memory_datasource.cpp
  35. +2 −2 src/mapnik_memory_datasource.hpp
  36. +3 −3 src/mapnik_palette.cpp
  37. +2 −2 src/mapnik_palette.hpp
  38. +2 −2 src/mapnik_plugins.hpp
  39. +106 −106 src/mapnik_projection.cpp
  40. +2 −2 src/mapnik_projection.hpp
  41. +2 −2 src/mapnik_query.cpp
  42. +2 −2 src/mapnik_query.hpp
  43. +16 −16 src/mem_datasource.hpp
  44. +94 −94 src/node_mapnik.cpp
  45. +12 −12 src/utils.hpp
  46. +12 −0 tools/cpp.el
  47. +7 −0 tools/fix_cpp_style.sh
View
@@ -9,3 +9,4 @@ test/tmp
lib/_mapnik.node
lib/mapnik_settings.js
node_modules/
+src/*.*~
View
@@ -44,6 +44,10 @@ endif
fix:
@fixjsstyle lib/*js bin/*js test/*js examples/*/*.js examples/*/*/*.js
+fixc:
+ @tools/fix_cpp_style.sh
+ @rm src/*.*~
+
lint:
@./node_modules/.bin/jshint lib/*js bin/*js test/*js examples/*/*.js examples/*/*/*.js
View
@@ -23,15 +23,15 @@ static void describe_datasource(Local<Object> description, mapnik::datasource_pt
{
// todo collect active attributes in styles
/*
- std::vector<std::string> const& style_names = layer.styles();
- Local<Array> s = Array::New(style_names.size());
- for (unsigned i = 0; i < style_names.size(); ++i)
- {
- s->Set(i, String::New(style_names[i].c_str()) );
- }
- meta->Set(String::NewSymbol("styles"), s );
+ std::vector<std::string> const& style_names = layer.styles();
+ Local<Array> s = Array::New(style_names.size());
+ for (unsigned i = 0; i < style_names.size(); ++i)
+ {
+ s->Set(i, String::New(style_names[i].c_str()) );
+ }
+ meta->Set(String::NewSymbol("styles"), s );
*/
-
+
// type
if (ds->type() == mapnik::datasource::Raster)
{
@@ -41,7 +41,7 @@ static void describe_datasource(Local<Object> description, mapnik::datasource_pt
{
description->Set(String::NewSymbol("type"), String::New("vector"));
}
-
+
// extent
Local<Array> a = Array::New(4);
mapnik::box2d<double> e = ds->envelope();
@@ -50,12 +50,12 @@ static void describe_datasource(Local<Object> description, mapnik::datasource_pt
a->Set(2, Number::New(e.maxx()));
a->Set(3, Number::New(e.maxy()));
description->Set(String::NewSymbol("extent"), a);
-
+
mapnik::layer_descriptor ld = ds->get_descriptor();
-
+
// encoding
description->Set(String::NewSymbol("encoding"), String::New(ld.get_encoding().c_str()));
-
+
// field names and types
Local<Object> fields = Object::New();
std::vector<mapnik::attribute_descriptor> const& desc = ld.get_descriptors();
@@ -77,20 +77,20 @@ static void describe_datasource(Local<Object> description, mapnik::datasource_pt
++itr;
}
description->Set(String::NewSymbol("fields"), fields);
-
+
mapnik::query q(ds->envelope());
mapnik::featureset_ptr fs = ds->features(q);
description->Set(String::NewSymbol("geometry_type"), Undefined());
description->Set(String::NewSymbol("has_features"), False());
-
+
// TODO - need to remove this after this lands:
// https://github.com/mapnik/mapnik/issues/701
if (fs)
{
mapnik::feature_ptr fp = fs->next();
if (fp) {
-
+
description->Set(String::NewSymbol("has_features"), True());
if (fp->num_geometries() > 0)
{
@@ -99,37 +99,37 @@ static void describe_datasource(Local<Object> description, mapnik::datasource_pt
Local<String> js_type = String::New("unknown");
switch (g_type)
{
- case mapnik::Point:
- {
- if (fp->num_geometries() > 1) {
- js_type = String::New("multipoint");
- } else {
- js_type = String::New("point");
- }
- break;
- }
- case mapnik::Polygon:
- {
- if (fp->num_geometries() > 1) {
- js_type = String::New("multipolygon");
- } else {
- js_type = String::New("polygon");
- }
- break;
+ case mapnik::Point:
+ {
+ if (fp->num_geometries() > 1) {
+ js_type = String::New("multipoint");
+ } else {
+ js_type = String::New("point");
}
- case mapnik::LineString:
- {
- if (fp->num_geometries() > 1) {
- js_type = String::New("multilinestring");
- } else {
- js_type = String::New("linestring");
- }
- break;
+ break;
+ }
+ case mapnik::Polygon:
+ {
+ if (fp->num_geometries() > 1) {
+ js_type = String::New("multipolygon");
+ } else {
+ js_type = String::New("polygon");
}
- default:
- {
- break;
+ break;
+ }
+ case mapnik::LineString:
+ {
+ if (fp->num_geometries() > 1) {
+ js_type = String::New("multilinestring");
+ } else {
+ js_type = String::New("linestring");
}
+ break;
+ }
+ default:
+ {
+ break;
+ }
}
description->Set(String::NewSymbol("geometry_type"), js_type);
}
@@ -139,12 +139,12 @@ static void describe_datasource(Local<Object> description, mapnik::datasource_pt
catch (const std::exception & ex)
{
ThrowException(Exception::Error(
- String::New(ex.what())));
+ String::New(ex.what())));
}
catch (...)
{
ThrowException(Exception::Error(
- String::New("unknown exception happened when calling describe_datasource, please file bug")));
+ String::New("unknown exception happened when calling describe_datasource, please file bug")));
}
}
@@ -154,12 +154,7 @@ static void datasource_features(Local<Array> a, mapnik::datasource_ptr ds, unsig
try
{
- #if MAPNIK_VERSION >= 800
mapnik::query q(ds->envelope());
- #else
- mapnik::query q(ds->envelope(),1.0,1.0);
- #endif
-
mapnik::layer_descriptor ld = ds->get_descriptor();
std::vector<mapnik::attribute_descriptor> const& desc = ld.get_descriptors();
std::vector<mapnik::attribute_descriptor>::const_iterator itr = desc.begin();
@@ -169,7 +164,7 @@ static void datasource_features(Local<Array> a, mapnik::datasource_ptr ds, unsig
q.add_property_name(itr->get_name());
++itr;
}
-
+
mapnik::featureset_ptr fs = ds->features(q);
if (fs)
{
@@ -188,10 +183,10 @@ static void datasource_features(Local<Array> a, mapnik::datasource_ptr ds, unsig
// not a mapnik::value_holder
boost::apply_visitor( serializer, boost::get<1>(*itr).base() );
}
-
+
// add feature id
feat->Set(String::NewSymbol("__id__"), Integer::New(fp->id()));
-
+
a->Set(idx, feat);
}
++idx;
@@ -201,136 +196,16 @@ static void datasource_features(Local<Array> a, mapnik::datasource_ptr ds, unsig
catch (const std::exception & ex)
{
ThrowException(Exception::Error(
- String::New(ex.what())));
+ String::New(ex.what())));
}
catch (...)
{
ThrowException(Exception::Error(
- String::New("unknown exception happened when calling datasource_features, please file bug")));
+ String::New("unknown exception happened when calling datasource_features, please file bug")));
}
}
-/*
-// start, limit
-static void datasource_stats(Local<Object> stats, mapnik::datasource_ptr ds, unsigned first, unsigned last)
-{
- // TODO
- // for strings, collect first 15 unique
- // allow options to specific which fields
-
-#if MAPNIK_VERSION >= 800
- mapnik::query q(ds->envelope());
-#else
- mapnik::query q(ds->envelope(),1.0,1.0);
-#endif
-
- mapnik::layer_descriptor ld = ds->get_descriptor();
- std::vector<mapnik::attribute_descriptor> const& desc = ld.get_descriptors();
- Local<Object> fields = Object::New();
- std::vector<mapnik::attribute_descriptor>::const_iterator itr = desc.begin();
- std::vector<mapnik::attribute_descriptor>::const_iterator end = desc.end();
- unsigned int size = 0;
- typedef std::vector<mapnik::value> vals;
- std::map<std::string, vals > values;
- //Local<Object> values = Object::New();
- while (itr != end)
- {
- q.add_property_name(itr->get_name());
- Local<Object> field_hash = Object::New();
- int field_type = itr->get_type();
- std::string type("");
- if (field_type == 1) type = "Number";
- else if (field_type == 2) type = "Number";
- else if (field_type == 3) type = "Number";
- else if (field_type == 4) type = "String";
- else if (field_type == 5) type = "Geometry";
- else if (field_type == 6) type = "Mapnik Object";
- field_hash->Set(String::NewSymbol("type"),String::New(type.c_str()));
- fields->Set(String::NewSymbol(itr->get_name().c_str()),field_hash);
- //values->Set(String::NewSymbol(itr->get_name().c_str()),Local<Array>::New());
- ++itr;
- ++size;
- }
- stats->Set(String::NewSymbol("fields"), fields);
-
- // todo - ability to get mapnik features without also parseing geometries
- mapnik::featureset_ptr fs = ds->features(q);
- unsigned idx = 0;
- if (fs)
- {
- mapnik::feature_ptr fp;
- typedef std::map<std::string,mapnik::value> properties;
- properties min_prop;
- properties max_prop;
- first = true;
- while ((fp = fs->next()))
- {
- ++idx;
- properties const& fprops = fp->props();
- properties::const_iterator it;
- properties::const_iterator end;
- if (first){
- first = false;
- it = fprops.begin();
- end = fprops.end();
- for (; it != end; ++it)
- {
- min_prop[it->first] = it->second;
- max_prop[it->first] = it->second;
- vals& v = values[it->first];
- if(std::find(v.begin(), v.end(), it->second) == v.end()) {
- v.push_back(it->second);
- }
- }
- }
- else
- {
- it = fprops.begin();
- end = fprops.end();
- for (; it != end; ++it)
- {
- vals& v = values[it->first];
- if(std::find(v.begin(), v.end(), it->second) == v.end()) {
- v.push_back(it->second);
- if (it->second > max_prop[it->first])
- max_prop[it->first] = it->second;
-
- if (it->second < min_prop[it->first])
- min_prop[it->first] = it->second;
- }
- }
- }
- }
-
- Local<Array> names = fields->GetPropertyNames();
- uint32_t i = 0;
- uint32_t a_length = names->Length();
- while (i < a_length) {
- Local<Value> name = names->Get(i)->ToString();
- Local<Object> hash = fields->Get(name)->ToObject();
- std::string key = TOSTR(name);
- node_mapnik::params_to_object serializer_min(hash, "min");
- boost::apply_visitor( serializer_min, min_prop[key].base() );
- node_mapnik::params_to_object serializer_max(hash, "max");
- boost::apply_visitor( serializer_max, max_prop[key].base() );
- vals& v = values[key];
- unsigned int num_vals = v.size();
- Local<Array> a = Array::New(num_vals);
- for (unsigned j = 0; j < num_vals; ++j)
- {
- a->Set(j, boost::apply_visitor(value_converter(),v[j].base()) );
- }
- hash->Set(String::NewSymbol("values"),a);
- i++;
- }
-
- }
-
- stats->Set(String::NewSymbol("count"), Number::New(idx));
-}
-*/
-
}
#endif
View
@@ -15,9 +15,9 @@ using namespace node;
namespace node_mapnik {
template <typename T, typename ArrayType>
-static void grid2utf(T const& grid_type,
- ArrayType const& l,
- std::vector<typename T::lookup_type>& key_order)
+static void grid2utf(T const& grid_type,
+ ArrayType const& l,
+ std::vector<typename T::lookup_type>& key_order)
{
typename T::data_type const& data = grid_type.data();
typename T::feature_key_type const& feature_keys = grid_type.get_feature_keys();
@@ -67,10 +67,10 @@ static void grid2utf(T const& grid_type,
// requires mapnik >= r2957
template <typename T, typename ArrayType>
-static void grid2utf(T const& grid_type,
- ArrayType const& l,
- std::vector<typename T::lookup_type>& key_order,
- unsigned int resolution)
+static void grid2utf(T const& grid_type,
+ ArrayType const& l,
+ std::vector<typename T::lookup_type>& key_order,
+ unsigned int resolution)
{
typename T::feature_key_type const& feature_keys = grid_type.get_feature_keys();
typename T::key_type keys;
@@ -120,8 +120,8 @@ static void grid2utf(T const& grid_type,
template <typename T>
static void write_features(T const& grid_type,
- Local<Object>& feature_data,
- std::vector<typename T::lookup_type> const& key_order)
+ Local<Object>& feature_data,
+ std::vector<typename T::lookup_type> const& key_order)
{
std::string const& key = grid_type.get_key();
std::set<std::string> const& attributes = grid_type.property_names();
View
@@ -17,8 +17,8 @@ void •::Initialize(Handle<Object> target) {
}
•::•(std::string const& name) :
- ObjectWrap(),
- this_(boost::make_shared<mapnik::•>(name)) {}
+ObjectWrap(),
+ this_(boost::make_shared<mapnik::•>(name)) {}
•::~•()
{
Oops, something went wrong. Retry.

0 comments on commit 3a02935

Please sign in to comment.