ruby_mapnik 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest.txt CHANGED
@@ -91,8 +91,6 @@ ext/ruby_mapnik/_mapnik_font_engine.rb.cpp
91
91
  ext/ruby_mapnik/_mapnik_font_engine.rb.h
92
92
  ext/ruby_mapnik/_mapnik_geometry.rb.cpp
93
93
  ext/ruby_mapnik/_mapnik_geometry.rb.h
94
- ext/ruby_mapnik/_mapnik_glyph_symbolizer.rb.cpp
95
- ext/ruby_mapnik/_mapnik_glyph_symbolizer.rb.h
96
94
  ext/ruby_mapnik/_mapnik_layer.rb.cpp
97
95
  ext/ruby_mapnik/_mapnik_layer.rb.h
98
96
  ext/ruby_mapnik/_mapnik_line_pattern_symbolizer.rb.cpp
@@ -155,7 +153,6 @@ test/test_mapnik_expression.rb
155
153
  test/test_mapnik_feature.rb
156
154
  test/test_mapnik_font_engine.rb
157
155
  test/test_mapnik_geometry.rb
158
- test/test_mapnik_glyph_symbolizer.rb
159
156
  test/test_mapnik_layer.rb
160
157
  test/test_mapnik_line_symbolizer.rb
161
158
  test/test_mapnik_map.rb
data/README.rdoc CHANGED
@@ -4,8 +4,9 @@ https://github.com/mapnik/Ruby-Mapnik
4
4
 
5
5
  == Requirements
6
6
 
7
- * Mapnik 2 (Currently available at http://svn.mapnik.org/trunk)
8
- * Rice >=1.4.2
7
+ * Rake
8
+ * Mapnik 2.x (Currently available at https://github.com/mapnik/mapnik)
9
+ * Rice >= 1.4.2
9
10
  * rcairo (https://github.com/rcairo/rcairo) (Optional)
10
11
 
11
12
  == Description
@@ -17,18 +18,28 @@ installed and Mapnik has been compiled with Cairo support.
17
18
 
18
19
  == Installation
19
20
 
21
+ If you have checked out this local repository code build like:
22
+
23
+ rake
24
+
25
+ The above command will compile the bindings and run the tests.
26
+
27
+ File issues at https://github.com/mapnik/Ruby-Mapnik if you hit any compile errors.
28
+
29
+ If you wish to install Ruby-Mapnik from the latest tagged release you can do:
30
+
20
31
  gem install ruby_mapnik
21
32
 
22
33
  Note: on osx the default rake compile will try to build universal, and your
23
- mapnik install is unlikely built universal. Check the architecture of libmapnik2.dylib like:
34
+ mapnik install is unlikely built universal. Check the architecture of libmapnik.dylib like:
24
35
 
25
- file /usr/local/lib/libmapnik2.dylib
36
+ file /usr/local/lib/libmapnik.dylib
26
37
 
27
38
  On a system where your compiler defaults to 64bit you'll see: 'Mach-O 64-bit dynamically linked shared library x86_64'
28
39
 
29
40
  So to avoid a linking warning like:
30
41
 
31
- ld: warning: ignoring file /usr/local/lib/libmapnik2.dylib, file was built for unsupported file format which is not the architecture being linked (i386)
42
+ ld: warning: ignoring file /usr/local/lib/libmapnik.dylib, file was built for unsupported file format which is not the architecture being linked (i386)
32
43
 
33
44
  You can pass this before rake compile:
34
45
 
@@ -47,7 +47,6 @@ void register_mapnik(){
47
47
  register_raster_colorizer(rb_mapnik);
48
48
  register_point_symbolizer(rb_mapnik);
49
49
  register_polygon_pattern_symbolizer(rb_mapnik);
50
- register_glyph_symbolizer(rb_mapnik);
51
50
  register_line_pattern_symbolizer(rb_mapnik);
52
51
  register_markers_symbolizer(rb_mapnik);
53
52
  register_shield_symbolizer(rb_mapnik);
@@ -57,12 +57,10 @@ SOFTWARE.
57
57
  #include "_mapnik_raster_symbolizer.rb.h"
58
58
  #include "_mapnik_raster_colorizer.rb.h"
59
59
  #include "_mapnik_point_symbolizer.rb.h"
60
- #include "_mapnik_polygon_pattern_symbolizer.rb.h"
61
- #include "_mapnik_glyph_symbolizer.rb.h"
60
+ #include "_mapnik_polygon_pattern_symbolizer.rb.h"
62
61
  #include "_mapnik_line_pattern_symbolizer.rb.h"
63
62
  #include "_mapnik_markers_symbolizer.rb.h"
64
- #include "_mapnik_shield_symbolizer.rb.h"
65
-
63
+ #include "_mapnik_shield_symbolizer.rb.h"
66
64
 
67
65
  void register_mapnik();
68
66
 
@@ -51,6 +51,11 @@ namespace {
51
51
  Rice::Object operator()(const std::string & str) const {
52
52
  return to_ruby<std::string>(str);
53
53
  }
54
+
55
+ Rice::Object operator()(const mapnik::value_null & value) const {
56
+ return NULL;
57
+ }
58
+
54
59
  };
55
60
 
56
61
 
@@ -29,7 +29,7 @@ SOFTWARE.
29
29
 
30
30
  // Mapnik
31
31
  #include <mapnik/feature.hpp>
32
- #include <mapnik/filter_factory.hpp>
32
+ #include <mapnik/expression.hpp>
33
33
  #include <mapnik/expression_node.hpp>
34
34
  #include <mapnik/expression_string.hpp>
35
35
  #include <mapnik/expression_evaluator.hpp>
@@ -21,6 +21,8 @@ SOFTWARE.
21
21
  *****************************************************************************/
22
22
  #include "_mapnik_feature.rb.h"
23
23
 
24
+ #include <boost/make_shared.hpp>
25
+
24
26
  // Rice
25
27
  #include <rice/Data_Type.hpp>
26
28
  #include <rice/Constructor.hpp>
@@ -30,17 +32,42 @@ SOFTWARE.
30
32
  #include <mapnik/wkt/wkt_factory.hpp>
31
33
  #include <mapnik/feature.hpp>
32
34
 
33
- void add_geometries_from_wkt(mapnik::Feature * self, std::string wkt){
34
- bool result = mapnik::from_wkt(wkt, self->paths());
35
- if (!result) throw std::runtime_error("Failed to parse WKT");
35
+ namespace {
36
+
37
+ void add_geometries_from_wkt(mapnik::Feature * self, std::string wkt){
38
+ bool result = mapnik::from_wkt(wkt, self->paths());
39
+ if (!result) throw std::runtime_error("Failed to parse WKT");
40
+ }
41
+
42
+ class context_holder {
43
+ public:
44
+ mapnik::context_ptr ptr;
45
+ context_holder(){
46
+ ptr = boost::make_shared<mapnik::context_type>();
47
+ }
48
+
49
+ int push(std::string const& str){
50
+ return ptr->push(str);
51
+ }
52
+ };
53
+
54
+ }
55
+ template<>
56
+ mapnik::context_ptr from_ruby<mapnik::context_ptr>(Rice::Object ruby_obj){
57
+ context_holder ctx = from_ruby<context_holder>(ruby_obj);
58
+ return ctx.ptr;
36
59
  }
37
60
 
38
61
  void register_feature(Rice::Module rb_mapnik){
62
+ Rice::Data_Type< context_holder > rb_ccontext = Rice::define_class_under< context_holder >(rb_mapnik, "Context");
63
+ rb_ccontext.define_constructor(Rice::Constructor< context_holder >());
64
+ rb_ccontext.define_method("push", &context_holder::push);
65
+
39
66
  /*
40
67
  @@Module_var rb_mapnik = Mapnik
41
68
  */
42
69
  Rice::Data_Type< mapnik::Feature > rb_cfeature = Rice::define_class_under< mapnik::Feature >(rb_mapnik, "Feature");
43
- rb_cfeature.define_constructor(Rice::Constructor< mapnik::Feature,int >());
70
+ rb_cfeature.define_constructor(Rice::Constructor< mapnik::Feature,mapnik::context_ptr,int >());
44
71
  rb_cfeature.define_method("id", &mapnik::Feature::id);
45
72
  rb_cfeature.define_method("to_s", &mapnik::Feature::to_string);
46
73
  rb_cfeature.define_method("number_of_geometries", &mapnik::Feature::num_geometries);
@@ -71,14 +71,10 @@ void register_geometry(Rice::Module rb_mapnik){
71
71
  geometry_enum.define_value("Point",mapnik::Point);
72
72
  geometry_enum.define_value("LineString",mapnik::LineString);
73
73
  geometry_enum.define_value("Polygon",mapnik::Polygon);
74
- geometry_enum.define_value("MultiPoint",mapnik::MultiPoint);
75
- geometry_enum.define_value("MultiLineString",mapnik::MultiLineString);
76
- geometry_enum.define_value("MultiPolygon",mapnik::MultiPolygon);
77
74
 
78
75
  Rice::Data_Type< mapnik::geometry_type > rb_cgeometry2d = Rice::define_class_under< mapnik::geometry_type >(rb_mapnik, "Geometry2d");
79
76
  rb_cgeometry2d.define_method("envelope", &mapnik::geometry_type::envelope);
80
77
  rb_cgeometry2d.define_method("type", &mapnik::geometry_type::type);
81
- rb_cgeometry2d.define_method("area", &mapnik::geometry_type::area);
82
78
 
83
79
  Rice::Data_Type< path_type > rb_cpath = Rice::define_class_under< path_type >(rb_mapnik, "Path");
84
80
  rb_cpath.define_singleton_method("from_wkt", &from_wkt_impl, Rice::Arg("wkt"));
@@ -90,36 +90,7 @@ void register_layer(Rice::Module rb_mapnik){
90
90
  * @return [nil]
91
91
  */
92
92
  rb_clayer.define_method("name=", &mapnik::layer::set_name, Rice::Arg("new_name"));
93
-
94
- /*
95
- * Document-method: title
96
- * @return [String] The layer's title
97
- */
98
- rb_clayer.define_method("title", &mapnik::layer::title);
99
-
100
- /*
101
- * Document-method: title=
102
- * call-seq:
103
- * title=(new_name)
104
- * @param [String]
105
- * @return [nil]
106
- */
107
- rb_clayer.define_method("title=", &mapnik::layer::set_title, Rice::Arg("new_title"));
108
-
109
- /*
110
- * Document-method: abstract
111
- * @return [String] the layer's abstract
112
- */
113
- rb_clayer.define_method("abstract", &mapnik::layer::abstract);
114
-
115
- /*
116
- * Document-method: abstract=
117
- * call-seq:
118
- * abstract=(new_abstract)
119
- * @param [String]
120
- */
121
- rb_clayer.define_method("abstract=", &mapnik::layer::set_abstract, Rice::Arg("new_abstract"));
122
-
93
+
123
94
  /*
124
95
  * Document-method: srs
125
96
  * @return [String] the layer's srs
@@ -41,37 +41,7 @@ void register_rule(Rice::Module rb_mapnik){
41
41
  * @return [nil]
42
42
  */
43
43
  rb_crule.define_method("name=", &mapnik::rule::set_name, Rice::Arg("new_name"));
44
-
45
- /*
46
- * Document-method: title
47
- * @return [String]
48
- */
49
- rb_crule.define_method("title", &mapnik::rule::get_title);
50
-
51
- /*
52
- * Document-method: title=
53
- * call-seq:
54
- * title=(new_title)
55
- * @param [String]
56
- * @return [nil]
57
- */
58
- rb_crule.define_method("title=", &mapnik::rule::set_title, Rice::Arg("new_title"));
59
-
60
- /*
61
- * Document-method: abstract
62
- * @return [String]
63
- */
64
- rb_crule.define_method("abstract", &mapnik::rule::get_abstract);
65
-
66
- /*
67
- * Document-method: abstract=
68
- * call-seq:
69
- * abstract=(new_abstract)
70
- * @param [String]
71
- * @return [nil]
72
- */
73
- rb_crule.define_method("abstract=", &mapnik::rule::set_abstract, Rice::Arg("new_abstract"));
74
-
44
+
75
45
  /*
76
46
  * Document-method: filter
77
47
  * @return [Mapnik::Expression]
@@ -36,8 +36,8 @@ namespace{
36
36
  Rice::Object get_shield_displacement(const mapnik::shield_symbolizer& t){
37
37
  mapnik::position pos = t.get_shield_displacement();
38
38
  Rice::Array out;
39
- out.push(boost::get<0>(pos));
40
- out.push(boost::get<1>(pos));
39
+ out.push(pos.first);
40
+ out.push(pos.second);
41
41
  return out;
42
42
  }
43
43
 
@@ -42,8 +42,6 @@ namespace {
42
42
  out = mapnik::symbolizer(from_ruby<mapnik::line_symbolizer>(obj));
43
43
  } else if(class_name == "Mapnik::TextSymbolizer"){
44
44
  out = mapnik::symbolizer(from_ruby<mapnik::text_symbolizer>(obj));
45
- } else if(class_name == "Mapnik::GlyphSymbolizer"){
46
- out = mapnik::symbolizer(from_ruby<mapnik::glyph_symbolizer>(obj));
47
45
  } else if(class_name == "Mapnik::LinePatternSymbolizer"){
48
46
  out = mapnik::symbolizer(from_ruby<mapnik::line_pattern_symbolizer>(obj));
49
47
  } else if(class_name == "Mapnik::MarkersSymbolizer"){
@@ -28,31 +28,16 @@ SOFTWARE.
28
28
  #include <rice/Enum.hpp>
29
29
 
30
30
  // Mapnik
31
- #include <mapnik/text_placements.hpp>
31
+ //#include <mapnik/text_placements.hpp>
32
32
  #include <mapnik/text_symbolizer.hpp>
33
33
 
34
34
  namespace {
35
35
 
36
- Rice::Object get_anchor(const mapnik::text_symbolizer& t){
37
- mapnik::position pos = t.get_anchor();
38
- Rice::Array out;
39
- out.push(boost::get<0>(pos));
40
- out.push(boost::get<1>(pos));
41
- return out;
42
- }
43
-
44
- void set_anchor(mapnik::text_symbolizer & t, Rice::Array ary) {
45
- double x = from_ruby<double>(ary[0]);
46
- double y = from_ruby<double>(ary[1]);
47
-
48
- t.set_anchor(x, y);
49
- }
50
-
51
36
  Rice::Object get_text_displacement(const mapnik::text_symbolizer& t){
52
37
  mapnik::position pos = t.get_displacement();
53
38
  Rice::Array out;
54
- out.push(boost::get<0>(pos));
55
- out.push(boost::get<1>(pos));
39
+ out.push(pos.first);
40
+ out.push(pos.second);
56
41
  return out;
57
42
  }
58
43
 
@@ -155,20 +140,6 @@ void register_text_symbolizer(Rice::Module rb_mapnik){
155
140
  */
156
141
  rb_ctext_symbolizer.define_constructor(Rice::Constructor< mapnik::text_symbolizer, mapnik::expression_ptr, std::string, int, mapnik::color >());
157
142
 
158
- /*
159
- * Document-method: anchor
160
- * @return [Array] Two element array [x,y]
161
- */
162
- rb_ctext_symbolizer.define_method("anchor", &get_anchor);
163
-
164
- /*
165
- * Document-method: anchor=
166
- * call-seq:
167
- * anchor=(new_anchor)
168
- * @param [Array] new_anchor Two element array [x,y]
169
- */
170
- rb_ctext_symbolizer.define_method("anchor=", &set_anchor);
171
-
172
143
  /*
173
144
  * Document-method: allow_overlap?
174
145
  * @return [Boolean]
@@ -406,12 +377,6 @@ void register_text_symbolizer(Rice::Module rb_mapnik){
406
377
  */
407
378
  rb_ctext_symbolizer.define_method("minimum_padding=", &mapnik::text_symbolizer::set_minimum_padding);
408
379
 
409
- /*
410
- * Document-method: name
411
- * @return [Mapnik::Expression]
412
- */
413
- rb_ctext_symbolizer.define_method("name", &mapnik::text_symbolizer::get_name);
414
-
415
380
  /*
416
381
  * Document-method: name=
417
382
  * call-seq:
@@ -32,16 +32,16 @@ end
32
32
 
33
33
  # Check for mapnik-config
34
34
  if %x{which mapnik-config}.length == 0
35
- abort("\n***\n mapnik-config is missing!\n Is mapnik2 installed?\n Is mapnik-config in your $PATH?\n***\n\n")
35
+ abort("\n***\n mapnik-config is missing!\n Is mapnik 2.x installed?\n Is mapnik-config in your $PATH?\n***\n\n")
36
36
  end
37
37
 
38
38
  LIBDIR = Config::CONFIG['libdir']
39
39
  INCLUDEDIR = Config::CONFIG['includedir']
40
40
 
41
- $LDFLAGS += " -lmapnik2 "
41
+ $LDFLAGS += " " + %x{mapnik-config --libs}.chomp + " "
42
42
 
43
43
  # force whitespace padding to avoid: https://github.com/mapnik/Ruby-Mapnik/issues/7
44
- $CFLAGS += " " + %x{mapnik-config --cflags} + " "
44
+ $CFLAGS += " " + %x{mapnik-config --cflags}.chomp + " "
45
45
 
46
46
  #------------------------------------------------------------------------------#
47
47
  # Ruby-Mapnik configuration
@@ -64,6 +64,9 @@ File.open(mapnik_config_file_path, 'w+') do |file|
64
64
  file.write(ruby_mapnik_config)
65
65
  end
66
66
 
67
+ if ENV['CXX']
68
+ $CXX = ENV['CXX']
69
+ end
67
70
 
68
71
  if RUBY_PLATFORM =~ /darwin/
69
72
  # In order to link the shared library into our bundle with GCC 4.x on OSX, we have to work around a bug:
data/lib/ruby_mapnik.rb CHANGED
@@ -37,7 +37,7 @@ require "#{path}/ruby_mapnik/mapnik/tile"
37
37
 
38
38
 
39
39
  module Mapnik
40
- VERSION = '0.1.2'
40
+ VERSION = '0.1.3'
41
41
 
42
42
  FontEngine.register_fonts(FONT_PATH)
43
43
  DatasourceCache.register(INPUT_PLUGIN_PATH)
@@ -1,30 +1,26 @@
1
1
  require "test_helper"
2
2
 
3
3
  class TestMapnikFeature < Test::Unit::TestCase
4
-
5
- def test_presence
6
- assert Mapnik::Feature
7
- end
8
-
4
+
9
5
  def test_should_instantiate
10
6
  feature_id = 12
11
- assert feature = Mapnik::Feature.new(feature_id)
7
+ assert feature = Mapnik::Feature.new(Mapnik::Context.new, feature_id)
12
8
  assert_equal feature_id, feature.id
13
- assert_equal "feature ( id:#{feature_id})", feature.to_s.gsub("\n", '')
9
+ assert_equal "Feature ( id=#{feature_id})", feature.to_s.gsub("\n", '')
14
10
  end
15
11
 
16
12
  def test_should_return_number_of_geometries
17
- assert feature = Mapnik::Feature.new(1)
13
+ assert feature = Mapnik::Feature.new(Mapnik::Context.new, 1)
18
14
  assert_equal 0, feature.number_of_geometries
19
15
  end
20
16
 
21
17
  def test_should_return_its_envelope
22
- assert feature = Mapnik::Feature.new(1)
18
+ assert feature = Mapnik::Feature.new(Mapnik::Context.new, 1)
23
19
  assert feature.envelope.kind_of?(Mapnik::Envelope)
24
20
  end
25
21
 
26
22
  def test_should_add_a_geometry
27
- feature = Mapnik::Feature.new(1)
23
+ feature = Mapnik::Feature.new(Mapnik::Context.new, 1)
28
24
  assert_equal(0, feature.number_of_geometries)
29
25
  feature.add_geometries_from_wkt("POINT(30 10)")
30
26
  assert_equal(1, feature.number_of_geometries)
@@ -10,8 +10,6 @@ class TestMapnikGeometry < Test::Unit::TestCase
10
10
  assert Mapnik::GeometryType::Point
11
11
  assert Mapnik::GeometryType::LineString
12
12
  assert Mapnik::GeometryType::Polygon
13
- assert Mapnik::GeometryType::MultiPoint
14
- assert Mapnik::GeometryType::MultiLineString
15
13
  end
16
14
 
17
15
  def test_should_make_point_from_wkt
@@ -29,22 +29,6 @@ class TestMapnikLayer < Test::Unit::TestCase
29
29
  assert_equal new_name, layer.name
30
30
  end
31
31
 
32
- def test_should_get_and_set_title
33
- layer = build_layer
34
- title_before = layer.title
35
- new_title = title_before + "BUT DIFFERENT"
36
- layer.title = new_title
37
- assert_equal new_title, layer.title
38
- end
39
-
40
- def test_should_get_and_set_abstract
41
- layer = build_layer
42
- abstract_before = layer.abstract
43
- new_abstract = abstract_before + "BUT DIFFERENT"
44
- layer.abstract = new_abstract
45
- assert_equal new_abstract, layer.abstract
46
- end
47
-
48
32
  def test_should_get_and_set_srs
49
33
  layer = build_layer
50
34
  srs_before = layer.srs
@@ -18,25 +18,7 @@ class TestMapnikRule < Test::Unit::TestCase
18
18
  rule.name = new_name
19
19
  assert_equal new_name, rule.name
20
20
  end
21
-
22
- def test_should_get_and_set_title
23
- rule = Mapnik::Rule.new
24
- assert_equal("", rule.title)
25
-
26
- new_title = "New title"
27
- rule.title = new_title
28
- assert_equal new_title, rule.title
29
- end
30
-
31
- def test_should_get_and_set_abstract
32
- rule = Mapnik::Rule.new
33
- assert_equal("", rule.abstract)
34
21
 
35
- new_abstract = "New abstract"
36
- rule.abstract = new_abstract
37
- assert_equal new_abstract, rule.abstract
38
- end
39
-
40
22
  def test_should_get_and_set_filter
41
23
  rule = Mapnik::Rule.new
42
24
  expression_string = "([place]='town')"
@@ -13,13 +13,6 @@ class TestMapnikShieldSymbolizer < Test::Unit::TestCase
13
13
  def test_should_instantiate
14
14
  assert @sym
15
15
  end
16
-
17
- def test_should_get_and_set_anchor
18
- assert @sym.anchor
19
- new_vals = [1,2]
20
- @sym.anchor = new_vals
21
- assert_equal new_vals, @sym.anchor
22
- end
23
16
 
24
17
  def test_should_get_and_set_allow_overlap
25
18
  @sym.allow_overlap = true
@@ -142,15 +135,6 @@ class TestMapnikShieldSymbolizer < Test::Unit::TestCase
142
135
  assert_equal 1, @sym.minimum_padding
143
136
  end
144
137
 
145
- def test_should_get_and_set_name
146
- assert @sym.name.instance_of?(Mapnik::Expression)
147
- new_expression_string = "([place]='towns')"
148
- assert_not_equal new_expression_string, @sym.name.to_s
149
- new_expression = Mapnik::Expression.parse(new_expression_string)
150
- @sym.name = new_expression
151
- assert_equal new_expression_string, @sym.name.to_s
152
- end
153
-
154
138
  def test_should_get_and_set_opactiy
155
139
  assert_equal 1, @sym.opacity
156
140
  @sym.opacity = 0
@@ -163,18 +147,6 @@ class TestMapnikShieldSymbolizer < Test::Unit::TestCase
163
147
  assert_equal 3, @sym.ratio
164
148
  end
165
149
 
166
- def test_should_get_and_set_text_size
167
- assert_equal 12, @sym.size
168
- @sym.size = 0
169
- assert_equal 0, @sym.size
170
- end
171
-
172
- def test_should_get_and_set_wrap_width
173
- assert_equal 0, @sym.wrap_width
174
- @sym.wrap_width = 30
175
- assert_equal 30, @sym.wrap_width
176
- end
177
-
178
150
  def test_should_get_and_set_wrap_character
179
151
  @sym.wrap_character = '|'
180
152
  assert_equal '|', @sym.wrap_character
@@ -182,8 +154,6 @@ class TestMapnikShieldSymbolizer < Test::Unit::TestCase
182
154
  assert_equal '%', @sym.wrap_character
183
155
  end
184
156
 
185
-
186
-
187
157
  def test_should_get_and_set_wrap_before
188
158
  assert !@sym.wrap_before
189
159
  @sym.wrap_before = true
@@ -36,13 +36,6 @@ class TestMapnikTextSymbolizer < Test::Unit::TestCase
36
36
  assert Mapnik::TEXT_TRANSFORM::CAPITALIZE
37
37
  end
38
38
 
39
- def test_should_get_and_set_anchor
40
- assert @symbolizer.anchor
41
- new_vals = [1,2]
42
- @symbolizer.anchor = new_vals
43
- assert_equal new_vals, @symbolizer.anchor
44
- end
45
-
46
39
  def test_should_get_and_set_allow_overlap
47
40
  @symbolizer.allow_overlap = true
48
41
  assert @symbolizer.allow_overlap?
@@ -145,7 +138,6 @@ class TestMapnikTextSymbolizer < Test::Unit::TestCase
145
138
  assert_equal 1, @symbolizer.line_spacing
146
139
  end
147
140
 
148
- # TODO: failure here!
149
141
  def test_should_get_and_set_max_char_angle_delta
150
142
  @symbolizer.max_char_angle_delta = 0.5
151
143
  assert_equal 0.5, @symbolizer.max_char_angle_delta
@@ -165,15 +157,6 @@ class TestMapnikTextSymbolizer < Test::Unit::TestCase
165
157
  assert_equal 1, @symbolizer.minimum_padding
166
158
  end
167
159
 
168
- def test_should_get_and_set_name
169
- assert @symbolizer.name.instance_of?(Mapnik::Expression)
170
- new_expression_string = "([place]='towns')"
171
- assert_not_equal new_expression_string, @symbolizer.name.to_s
172
- new_expression = Mapnik::Expression.parse(new_expression_string)
173
- @symbolizer.name = new_expression
174
- assert_equal new_expression_string, @symbolizer.name.to_s
175
- end
176
-
177
160
  def test_should_get_and_set_opactiy
178
161
  assert_equal 1, @symbolizer.opacity
179
162
  @symbolizer.opacity = 0
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_mapnik
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 2
10
- version: 0.1.2
9
+ - 3
10
+ version: 0.1.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Elliot Laster
@@ -15,8 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-10-09 00:00:00 -04:00
19
- default_executable:
18
+ date: 2012-02-14 00:00:00 Z
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
21
  name: rice
@@ -49,20 +48,35 @@ dependencies:
49
48
  type: :development
50
49
  version_requirements: *id002
51
50
  - !ruby/object:Gem::Dependency
52
- name: hoe
51
+ name: rdoc
53
52
  prerelease: false
54
53
  requirement: &id003 !ruby/object:Gem::Requirement
55
54
  none: false
56
55
  requirements:
57
56
  - - ~>
58
57
  - !ruby/object:Gem::Version
59
- hash: 27
58
+ hash: 19
60
59
  segments:
61
- - 2
62
- - 12
63
- version: "2.12"
60
+ - 3
61
+ - 10
62
+ version: "3.10"
64
63
  type: :development
65
64
  version_requirements: *id003
65
+ - !ruby/object:Gem::Dependency
66
+ name: hoe
67
+ prerelease: false
68
+ requirement: &id004 !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ~>
72
+ - !ruby/object:Gem::Version
73
+ hash: 25
74
+ segments:
75
+ - 2
76
+ - 13
77
+ version: "2.13"
78
+ type: :development
79
+ version_requirements: *id004
66
80
  description: |-
67
81
  A set of bindings between Ruby and Mapnik. Supports many of the common uses for
68
82
  Mapnik, and one day, might support all of them. Rendering is available using
@@ -172,8 +186,6 @@ files:
172
186
  - ext/ruby_mapnik/_mapnik_font_engine.rb.h
173
187
  - ext/ruby_mapnik/_mapnik_geometry.rb.cpp
174
188
  - ext/ruby_mapnik/_mapnik_geometry.rb.h
175
- - ext/ruby_mapnik/_mapnik_glyph_symbolizer.rb.cpp
176
- - ext/ruby_mapnik/_mapnik_glyph_symbolizer.rb.h
177
189
  - ext/ruby_mapnik/_mapnik_layer.rb.cpp
178
190
  - ext/ruby_mapnik/_mapnik_layer.rb.h
179
191
  - ext/ruby_mapnik/_mapnik_line_pattern_symbolizer.rb.cpp
@@ -236,7 +248,6 @@ files:
236
248
  - test/test_mapnik_feature.rb
237
249
  - test/test_mapnik_font_engine.rb
238
250
  - test/test_mapnik_geometry.rb
239
- - test/test_mapnik_glyph_symbolizer.rb
240
251
  - test/test_mapnik_layer.rb
241
252
  - test/test_mapnik_line_symbolizer.rb
242
253
  - test/test_mapnik_map.rb
@@ -257,7 +268,6 @@ files:
257
268
  - yard/lib/yard/parser/generic_parser.rb
258
269
  - yard/lib/yard_generic.rb
259
270
  - .gemtest
260
- has_rdoc: true
261
271
  homepage: https://github.com/mapnik/Ruby-Mapnik
262
272
  licenses: []
263
273
 
@@ -288,7 +298,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
288
298
  requirements: []
289
299
 
290
300
  rubyforge_project: ruby_mapnik
291
- rubygems_version: 1.4.2
301
+ rubygems_version: 1.8.16
292
302
  signing_key:
293
303
  specification_version: 3
294
304
  summary: A set of bindings between Ruby and Mapnik
@@ -303,7 +313,6 @@ test_files:
303
313
  - test/test_mapnik_feature.rb
304
314
  - test/test_mapnik_font_engine.rb
305
315
  - test/test_mapnik_geometry.rb
306
- - test/test_mapnik_glyph_symbolizer.rb
307
316
  - test/test_mapnik_layer.rb
308
317
  - test/test_mapnik_line_symbolizer.rb
309
318
  - test/test_mapnik_map.rb
@@ -1,250 +0,0 @@
1
- /*****************************************************************************
2
- Copyright (C) 2011 Elliot Laster
3
-
4
- Permission is hereby granted, free of charge, to any person obtaining a copy of
5
- this software and associated documentation files (the ‘Software’), to deal in
6
- the Software without restriction, including without limitation the rights to
7
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
8
- of the Software, and to permit persons to whom the Software is furnished to do
9
- so, subject to the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be included in all
12
- copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- SOFTWARE.
21
- *****************************************************************************/
22
- #include "_mapnik_glyph_symbolizer.rb.h"
23
-
24
- // Rice
25
- #include <rice/Data_Type.hpp>
26
- #include <rice/Constructor.hpp>
27
- #include <rice/Class.hpp>
28
- #include <rice/Enum.hpp>
29
-
30
- // Mapnik
31
- #include <mapnik/glyph_symbolizer.hpp>
32
-
33
- namespace {
34
- Rice::Object get_displacement(const mapnik::glyph_symbolizer& t){
35
- mapnik::position pos = t.get_displacement();
36
- Rice::Array out;
37
- out.push(boost::get<0>(pos));
38
- out.push(boost::get<1>(pos));
39
- return out;
40
- }
41
-
42
- void set_displacement(mapnik::glyph_symbolizer & t, Rice::Array ary){
43
- double x = from_ruby<double>(ary[0]);
44
- double y = from_ruby<double>(ary[1]);
45
-
46
- t.set_displacement(x,y);
47
- }
48
-
49
- mapnik::angle_mode_enum get_angle_mode(mapnik::glyph_symbolizer const & self){
50
- return self.get_angle_mode();
51
- }
52
-
53
- void set_angle_mode(mapnik::glyph_symbolizer & self, mapnik::angle_mode_enum val){
54
- self.set_angle_mode(val);
55
- }
56
- }
57
-
58
- void register_glyph_symbolizer(Rice::Module rb_mapnik){
59
- /*
60
- @@Module_var rb_mapnik = Mapnik
61
- */
62
- Rice::Enum<mapnik::angle_mode_enum> angle_enum = Rice::define_enum<mapnik::angle_mode_enum>("AngleMode", rb_mapnik);
63
- angle_enum.define_value("AZIMUTH", mapnik::AZIMUTH);
64
- angle_enum.define_value("TRIGONOMETRIC", mapnik::TRIGONOMETRIC);
65
-
66
-
67
- Rice::Data_Type< mapnik::glyph_symbolizer > rb_cglyph_symbolizer = Rice::define_class_under< mapnik::glyph_symbolizer >(rb_mapnik, "GlyphSymbolizer");
68
-
69
- /*
70
- * Document-method: new
71
- * call-seq:
72
- * new(font_name, expression)
73
- *
74
- * @param [String] font_name Name of a font registered with the FontEngine
75
- * @param [Mapnik::Expression] expression The value expression
76
- *
77
- * Returns a new Mapnik::GlyphSymbolizer
78
- */
79
- rb_cglyph_symbolizer.define_constructor(Rice::Constructor< mapnik::glyph_symbolizer, std::string, mapnik::expression_ptr >());
80
-
81
- /*
82
- * Document-method: face_name
83
- * @return [String] the font face name
84
- */
85
- rb_cglyph_symbolizer.define_method("face_name", &mapnik::glyph_symbolizer::get_face_name);
86
-
87
- /*
88
- * Document-method: face_name=
89
- * call-seq:
90
- * face_name=(new_face_name)
91
- * @param [String] The new font face name
92
- * @return [nil]
93
- */
94
- rb_cglyph_symbolizer.define_method("face_name=", &mapnik::glyph_symbolizer::set_face_name);
95
-
96
- /*
97
- * Document-method: char
98
- * @return [String]
99
- */
100
- rb_cglyph_symbolizer.define_method("char", &mapnik::glyph_symbolizer::get_char);
101
-
102
- /*
103
- * Document-method: char=
104
- * call-seq:
105
- * char=(new_char)
106
- * @param [String]
107
- * @return [nil]
108
- */
109
- rb_cglyph_symbolizer.define_method("char=", &mapnik::glyph_symbolizer::set_char);
110
-
111
- /*
112
- * Document-method: allow_overlap?
113
- * @return [Boolean] Whether or not glyphs should overlap
114
- */
115
- rb_cglyph_symbolizer.define_method("allow_overlap?", &mapnik::glyph_symbolizer::get_allow_overlap);
116
-
117
- /*
118
- * Document-method: allow_overlap=
119
- * call-seq:
120
- * allow_overlap=(new_overlap_value)
121
- * @param [Boolean]
122
- * @return [nil]
123
- */
124
- rb_cglyph_symbolizer.define_method("allow_overlap=", &mapnik::glyph_symbolizer::set_allow_overlap);
125
-
126
- /*
127
- * Document-method: displacement?
128
- * @return [Array] Two element array of the x-y displacement
129
- */
130
- rb_cglyph_symbolizer.define_method("displacement", &get_displacement);
131
-
132
- /*
133
- * Document-method: displacement=
134
- * call-seq:
135
- * displacement=(new_displacement_values)
136
- * @param [Array] array in the format [x,y]
137
- * @return [nil]
138
- */
139
- rb_cglyph_symbolizer.define_method("displacement=", &set_displacement);
140
-
141
- /*
142
- * Document-method: avoid_edges?
143
- * @return [Boolean] Whether or not glyphs should avoid edges
144
- */
145
- rb_cglyph_symbolizer.define_method("avoid_edges?", &mapnik::glyph_symbolizer::get_avoid_edges);
146
-
147
- /*
148
- * Document-method: avoid_edges=
149
- * call-seq:
150
- * avoid_edges=(new_value)
151
- * @param [Boolean]
152
- * @return [nil]
153
- */
154
- rb_cglyph_symbolizer.define_method("avoid_edges=", &mapnik::glyph_symbolizer::set_avoid_edges);
155
-
156
- /*
157
- * Document-method: halo_fill
158
- * @return [Mapnik::Color] Color of the halo around the text
159
- */
160
- rb_cglyph_symbolizer.define_method("halo_fill", &mapnik::glyph_symbolizer::get_halo_fill);
161
-
162
- /*
163
- * Document-method: halo_fill=
164
- * call-seq:
165
- * halo_fill=(color)
166
- * @param [Mapnik::Color] The color of the halo around the text.
167
- * @return [nil]
168
- */
169
- rb_cglyph_symbolizer.define_method("halo_fill=", &mapnik::glyph_symbolizer::set_halo_fill);
170
-
171
- /*
172
- * Document-method: halo_radius
173
- * @return [Integer] Thickness of the text halo
174
- */
175
- rb_cglyph_symbolizer.define_method("halo_radius", &mapnik::glyph_symbolizer::get_halo_radius);
176
-
177
- /*
178
- * Document-method: halo_radius=
179
- * call-seq:
180
- * halo_fill=(color)
181
- * @param [Integer] The thickness of the text halo
182
- * @return [nil]
183
- */
184
- rb_cglyph_symbolizer.define_method("halo_radius=", &mapnik::glyph_symbolizer::set_halo_radius);
185
-
186
- /*
187
- * Document-method: size
188
- * @return [Mapnik::Expression] Font size of the glyph
189
- */
190
- rb_cglyph_symbolizer.define_method("size", &mapnik::glyph_symbolizer::get_size);
191
-
192
- /*
193
- * Document-method: size=
194
- * call-seq:
195
- * size=(size_expression)
196
- * @param [Mapnik::Expression] The new size expression
197
- * @return [nil]
198
- */
199
- rb_cglyph_symbolizer.define_method("size=", &mapnik::glyph_symbolizer::set_size);
200
-
201
- /*
202
- * Document-method: angle
203
- * @return [Mapnik::Expression]
204
- */
205
- rb_cglyph_symbolizer.define_method("angle", &mapnik::glyph_symbolizer::get_angle);
206
-
207
- /*
208
- * Document-method: angle=
209
- * call-seq:
210
- * angle=(angle_expression)
211
- * @param [Mapnik::Expression]
212
- * @return [nil]
213
- */
214
- rb_cglyph_symbolizer.define_method("angle=", &mapnik::glyph_symbolizer::set_angle);
215
-
216
- /*
217
- * Document-method: value
218
- * @return [Mapnik::Expression]
219
- */
220
- rb_cglyph_symbolizer.define_method("value", &mapnik::glyph_symbolizer::get_value);
221
-
222
- /*
223
- * Document-method: value=
224
- * call-seq:
225
- * value=(value_expression)
226
- * @param [Mapnik::Expression]
227
- * @return [nil]
228
- */
229
- rb_cglyph_symbolizer.define_method("value=", &mapnik::glyph_symbolizer::set_value);
230
-
231
-
232
- rb_cglyph_symbolizer.define_method("angle_mode", &get_angle_mode);
233
- rb_cglyph_symbolizer.define_method("angle_mode=", &set_angle_mode);
234
-
235
- /*
236
- * Document-method: color
237
- * @return [Mapnik::Color] Color of the text
238
- */
239
- rb_cglyph_symbolizer.define_method("color", &mapnik::glyph_symbolizer::get_color);
240
-
241
- /*
242
- * Document-method: color=
243
- * call-seq:
244
- * color=(color)
245
- * @param [Mapnik::Color] The color of the text.
246
- * @return [nil]
247
- */
248
- rb_cglyph_symbolizer.define_method("color=", &mapnik::glyph_symbolizer::set_color);
249
-
250
- }
@@ -1,32 +0,0 @@
1
- /*****************************************************************************
2
- Copyright (C) 2011 Elliot Laster
3
-
4
- Permission is hereby granted, free of charge, to any person obtaining a copy of
5
- this software and associated documentation files (the ‘Software’), to deal in
6
- the Software without restriction, including without limitation the rights to
7
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
8
- of the Software, and to permit persons to whom the Software is furnished to do
9
- so, subject to the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be included in all
12
- copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- SOFTWARE.
21
- *****************************************************************************/
22
- #ifndef PIKA2_MAPNIK_GLYPH_SYMBOLIZER
23
- #define PIKA2_MAPNIK_GLYPH_SYMBOLIZER
24
-
25
- namespace Rice
26
- {
27
- class Module;
28
- }
29
-
30
- void register_glyph_symbolizer(Rice::Module rb_mapnik);
31
-
32
- #endif
@@ -1,96 +0,0 @@
1
- require "test_helper"
2
-
3
- class TestMapnikGlyphSymbolizer < Test::Unit::TestCase
4
-
5
- def setup
6
- expression = Mapnik::Expression.parse("[g]")
7
- @sym = Mapnik::GlyphSymbolizer.new("DejaVu Sans Book",expression)
8
- end
9
-
10
- def test_presence
11
- assert Mapnik::GlyphSymbolizer
12
- assert Mapnik::AngleMode::AZIMUTH
13
- assert Mapnik::AngleMode::TRIGONOMETRIC
14
- end
15
-
16
- def test_should_get_and_set_face_name
17
- assert_equal 'DejaVu Sans Book', @sym.face_name
18
- new_face_name = 'DejaVu Sans'
19
- @sym.face_name = new_face_name
20
- assert_equal new_face_name, @sym.face_name
21
- end
22
-
23
- def test_should_get_and_set_char
24
- assert @sym.char.instance_of?(Mapnik::Expression)
25
- @sym.char = Mapnik::Expression.parse("[t]")
26
- end
27
-
28
- def test_should_get_and_set_allow_overlap
29
- @sym.allow_overlap = true
30
- assert @sym.allow_overlap?
31
- @sym.allow_overlap = false
32
- assert !@sym.allow_overlap?
33
- end
34
-
35
- def test_should_get_and_set_avoid_edges
36
- @sym.avoid_edges = true
37
- assert @sym.avoid_edges?
38
- @sym.avoid_edges = false
39
- assert !@sym.avoid_edges?
40
- end
41
-
42
- def test_should_get_and_set_displacement
43
- assert @sym.displacement
44
- new_vals = [1,2]
45
- @sym.displacement = new_vals
46
- assert_equal new_vals, @sym.displacement
47
- end
48
-
49
- def test_should_get_and_set_halo_fill
50
- assert @sym.halo_fill.instance_of?(Mapnik::Color)
51
- white = Mapnik::Color.new("#fff")
52
- @sym.halo_fill = white
53
- assert_equal white, @sym.halo_fill
54
- end
55
-
56
- def test_should_get_and_set_halo_radius
57
- assert_equal 0, @sym.halo_radius
58
- @sym.halo_radius = 1
59
- assert_equal 1, @sym.halo_radius
60
- end
61
-
62
- def test_should_get_and_set_size
63
- @sym.size = Mapnik::Expression.parse("[12]")
64
- assert @sym.size.instance_of?(Mapnik::Expression)
65
- end
66
-
67
- def test_should_get_and_set_angle
68
- @sym.angle = Mapnik::Expression.parse("[90]")
69
- assert @sym.angle.instance_of?(Mapnik::Expression)
70
- end
71
-
72
- def test_should_get_and_set_angle_mode
73
- @sym.angle_mode = Mapnik::AngleMode::AZIMUTH
74
- assert_equal Mapnik::AngleMode::AZIMUTH, @sym.angle_mode
75
- @sym.angle_mode = Mapnik::AngleMode::TRIGONOMETRIC
76
- assert_equal Mapnik::AngleMode::TRIGONOMETRIC, @sym.angle_mode
77
- end
78
-
79
- def test_should_get_and_set_value
80
- @sym.value = Mapnik::Expression.parse("[town]")
81
- assert @sym.value.instance_of?(Mapnik::Expression)
82
- end
83
-
84
- # FIXME: Need Expression equality?
85
- def test_should_get_and_set_color
86
- @sym.color = Mapnik::Expression.parse("[90, 90, 90]")
87
- assert @sym.angle.instance_of?(Mapnik::Expression)
88
- end
89
-
90
- # TODO: Colorizer support
91
- # def test_should_get_and_set_colorizer
92
- # colorizer = Mapnik::RasterColorizer.new
93
- # @sym.colorizer = colorizer
94
- # end
95
-
96
- end