ruby_mapnik 0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (179) hide show
  1. data/.autotest +35 -0
  2. data/.gemtest +0 -0
  3. data/.yardopts +1 -0
  4. data/Gemfile +12 -0
  5. data/LICENSE +19 -0
  6. data/Manifest.txt +177 -0
  7. data/README.rdoc +84 -0
  8. data/Rakefile +43 -0
  9. data/demo/data/COPYRIGHT.txt +3 -0
  10. data/demo/data/TM_WORLD_BORDERS_SIMPL_0.3_MOD.dbf +0 -0
  11. data/demo/data/TM_WORLD_BORDERS_SIMPL_0.3_MOD.prj +1 -0
  12. data/demo/data/TM_WORLD_BORDERS_SIMPL_0.3_MOD.shp +0 -0
  13. data/demo/data/TM_WORLD_BORDERS_SIMPL_0.3_MOD.shx +0 -0
  14. data/demo/data/boundaries.dbf +0 -0
  15. data/demo/data/boundaries.prj +1 -0
  16. data/demo/data/boundaries.sbx +0 -0
  17. data/demo/data/boundaries.shp +0 -0
  18. data/demo/data/boundaries.shx +0 -0
  19. data/demo/data/boundaries_l.dbf +0 -0
  20. data/demo/data/boundaries_l.prj +1 -0
  21. data/demo/data/boundaries_l.sbx +0 -0
  22. data/demo/data/boundaries_l.shp +0 -0
  23. data/demo/data/boundaries_l.shx +0 -0
  24. data/demo/data/ontdrainage.dbf +0 -0
  25. data/demo/data/ontdrainage.prj +1 -0
  26. data/demo/data/ontdrainage.sbx +0 -0
  27. data/demo/data/ontdrainage.shp +0 -0
  28. data/demo/data/ontdrainage.shx +0 -0
  29. data/demo/data/popplaces.dbf +0 -0
  30. data/demo/data/popplaces.prj +1 -0
  31. data/demo/data/popplaces.sbx +0 -0
  32. data/demo/data/popplaces.shp +0 -0
  33. data/demo/data/popplaces.shx +0 -0
  34. data/demo/data/qcdrainage.dbf +0 -0
  35. data/demo/data/qcdrainage.prj +1 -0
  36. data/demo/data/qcdrainage.sbx +0 -0
  37. data/demo/data/qcdrainage.shp +0 -0
  38. data/demo/data/qcdrainage.shx +0 -0
  39. data/demo/data/roads.dbf +0 -0
  40. data/demo/data/roads.prj +1 -0
  41. data/demo/data/roads.sbx +0 -0
  42. data/demo/data/roads.shp +0 -0
  43. data/demo/data/roads.shx +0 -0
  44. data/demo/data/test/charplacement.dbf +0 -0
  45. data/demo/data/test/charplacement.shp +0 -0
  46. data/demo/data/test/charplacement.shx +0 -0
  47. data/demo/data/test/displacement.dbf +0 -0
  48. data/demo/data/test/displacement.shp +0 -0
  49. data/demo/data/test/displacement.shx +0 -0
  50. data/demo/data/test/overlap.dbf +0 -0
  51. data/demo/data/test/overlap.shp +0 -0
  52. data/demo/data/test/overlap.shx +0 -0
  53. data/demo/data/test/raw/charplacement.gfs +25 -0
  54. data/demo/data/test/raw/charplacement.gml +99 -0
  55. data/demo/data/test/raw/charplacement.xsd +36 -0
  56. data/demo/data/test/raw/displacement.gfs +25 -0
  57. data/demo/data/test/raw/displacement.gml +173 -0
  58. data/demo/data/test/raw/displacement.xsd +36 -0
  59. data/demo/data/test/raw/overlap.gfs +25 -0
  60. data/demo/data/test/raw/overlap.gml +127 -0
  61. data/demo/data/test/raw/overlap.xsd +36 -0
  62. data/demo/data/test/raw/textspacing.gfs +25 -0
  63. data/demo/data/test/raw/textspacing.gml +117 -0
  64. data/demo/data/test/raw/textspacing.xsd +36 -0
  65. data/demo/data/test/readme.txt +3 -0
  66. data/demo/data/test/regenerate.sh +20 -0
  67. data/demo/data/test/textspacing.dbf +0 -0
  68. data/demo/data/test/textspacing.shp +0 -0
  69. data/demo/data/test/textspacing.shx +0 -0
  70. data/demo/rundemo.rb +139 -0
  71. data/demo/sinatra/demo.rb +31 -0
  72. data/demo/sinatra/public/css/demo_map.css +7 -0
  73. data/demo/sinatra/public/index.html +13 -0
  74. data/demo/sinatra/public/javascripts/demo_map.js +42 -0
  75. data/ext/ruby_mapnik/_mapnik.cpp +54 -0
  76. data/ext/ruby_mapnik/_mapnik.h +69 -0
  77. data/ext/ruby_mapnik/_mapnik_color.rb.cpp +179 -0
  78. data/ext/ruby_mapnik/_mapnik_color.rb.h +32 -0
  79. data/ext/ruby_mapnik/_mapnik_coord.rb.cpp +145 -0
  80. data/ext/ruby_mapnik/_mapnik_coord.rb.h +32 -0
  81. data/ext/ruby_mapnik/_mapnik_datasource.rb.cpp +150 -0
  82. data/ext/ruby_mapnik/_mapnik_datasource.rb.h +32 -0
  83. data/ext/ruby_mapnik/_mapnik_datasource_cache.rb.cpp +79 -0
  84. data/ext/ruby_mapnik/_mapnik_datasource_cache.rb.h +32 -0
  85. data/ext/ruby_mapnik/_mapnik_envelope.rb.cpp +220 -0
  86. data/ext/ruby_mapnik/_mapnik_envelope.rb.h +32 -0
  87. data/ext/ruby_mapnik/_mapnik_expression.rb.cpp +91 -0
  88. data/ext/ruby_mapnik/_mapnik_expression.rb.h +32 -0
  89. data/ext/ruby_mapnik/_mapnik_feature.rb.cpp +56 -0
  90. data/ext/ruby_mapnik/_mapnik_feature.rb.h +32 -0
  91. data/ext/ruby_mapnik/_mapnik_font_engine.rb.cpp +71 -0
  92. data/ext/ruby_mapnik/_mapnik_font_engine.rb.h +32 -0
  93. data/ext/ruby_mapnik/_mapnik_geometry.rb.cpp +73 -0
  94. data/ext/ruby_mapnik/_mapnik_geometry.rb.h +32 -0
  95. data/ext/ruby_mapnik/_mapnik_glyph_symbolizer.rb.cpp +250 -0
  96. data/ext/ruby_mapnik/_mapnik_glyph_symbolizer.rb.h +32 -0
  97. data/ext/ruby_mapnik/_mapnik_layer.rb.cpp +237 -0
  98. data/ext/ruby_mapnik/_mapnik_layer.rb.h +32 -0
  99. data/ext/ruby_mapnik/_mapnik_line_pattern_symbolizer.rb.cpp +70 -0
  100. data/ext/ruby_mapnik/_mapnik_line_pattern_symbolizer.rb.h +32 -0
  101. data/ext/ruby_mapnik/_mapnik_line_symbolizer.rb.cpp +43 -0
  102. data/ext/ruby_mapnik/_mapnik_line_symbolizer.rb.h +32 -0
  103. data/ext/ruby_mapnik/_mapnik_map.rb.cpp +435 -0
  104. data/ext/ruby_mapnik/_mapnik_map.rb.h +32 -0
  105. data/ext/ruby_mapnik/_mapnik_markers_symbolizer.rb.cpp +139 -0
  106. data/ext/ruby_mapnik/_mapnik_markers_symbolizer.rb.h +32 -0
  107. data/ext/ruby_mapnik/_mapnik_point_symbolizer.rb.cpp +147 -0
  108. data/ext/ruby_mapnik/_mapnik_point_symbolizer.rb.h +32 -0
  109. data/ext/ruby_mapnik/_mapnik_polygon_pattern_symbolizer.rb.cpp +92 -0
  110. data/ext/ruby_mapnik/_mapnik_polygon_pattern_symbolizer.rb.h +32 -0
  111. data/ext/ruby_mapnik/_mapnik_polygon_symbolizer.rb.cpp +89 -0
  112. data/ext/ruby_mapnik/_mapnik_polygon_symbolizer.rb.h +32 -0
  113. data/ext/ruby_mapnik/_mapnik_projection.rb.cpp +98 -0
  114. data/ext/ruby_mapnik/_mapnik_projection.rb.h +32 -0
  115. data/ext/ruby_mapnik/_mapnik_raster_colorizer.rb.cpp +162 -0
  116. data/ext/ruby_mapnik/_mapnik_raster_colorizer.rb.h +32 -0
  117. data/ext/ruby_mapnik/_mapnik_raster_symbolizer.rb.cpp +53 -0
  118. data/ext/ruby_mapnik/_mapnik_raster_symbolizer.rb.h +32 -0
  119. data/ext/ruby_mapnik/_mapnik_rule.rb.cpp +99 -0
  120. data/ext/ruby_mapnik/_mapnik_rule.rb.h +32 -0
  121. data/ext/ruby_mapnik/_mapnik_shield_symbolizer.rb.cpp +86 -0
  122. data/ext/ruby_mapnik/_mapnik_shield_symbolizer.rb.h +32 -0
  123. data/ext/ruby_mapnik/_mapnik_stroke.rb.cpp +188 -0
  124. data/ext/ruby_mapnik/_mapnik_stroke.rb.h +32 -0
  125. data/ext/ruby_mapnik/_mapnik_style.rb.cpp +76 -0
  126. data/ext/ruby_mapnik/_mapnik_style.rb.h +32 -0
  127. data/ext/ruby_mapnik/_mapnik_symbolizer.rb.cpp +77 -0
  128. data/ext/ruby_mapnik/_mapnik_symbolizer.rb.h +32 -0
  129. data/ext/ruby_mapnik/_mapnik_text_symbolizer.rb.cpp +521 -0
  130. data/ext/ruby_mapnik/_mapnik_text_symbolizer.rb.h +32 -0
  131. data/ext/ruby_mapnik/extconf.rb +78 -0
  132. data/ext/ruby_mapnik/ruby_mapnik.cpp +31 -0
  133. data/lib/ruby_mapnik/mapnik/font_engine.rb +35 -0
  134. data/lib/ruby_mapnik/mapnik/layer.rb +69 -0
  135. data/lib/ruby_mapnik/mapnik/map.rb +144 -0
  136. data/lib/ruby_mapnik/mapnik/projection.rb +46 -0
  137. data/lib/ruby_mapnik/mapnik/raster_colorizer.rb +55 -0
  138. data/lib/ruby_mapnik/mapnik/rule.rb +107 -0
  139. data/lib/ruby_mapnik/mapnik/stroke.rb +58 -0
  140. data/lib/ruby_mapnik/mapnik/style.rb +66 -0
  141. data/lib/ruby_mapnik/mapnik/tile.rb +93 -0
  142. data/lib/ruby_mapnik.rb +48 -0
  143. data/script/console +2 -0
  144. data/test/data/TM_WORLD_BORDERS_SIMPL_0.3_MOD.dbf +0 -0
  145. data/test/data/TM_WORLD_BORDERS_SIMPL_0.3_MOD.prj +1 -0
  146. data/test/data/TM_WORLD_BORDERS_SIMPL_0.3_MOD.shp +0 -0
  147. data/test/data/TM_WORLD_BORDERS_SIMPL_0.3_MOD.shx +0 -0
  148. data/test/data/test_map.xml +15 -0
  149. data/test/test_helper.rb +27 -0
  150. data/test/test_line_pattern_symbolizer.rb +26 -0
  151. data/test/test_mapnik_color.rb +66 -0
  152. data/test/test_mapnik_coord.rb +112 -0
  153. data/test/test_mapnik_datasource.rb +49 -0
  154. data/test/test_mapnik_envelope.rb +232 -0
  155. data/test/test_mapnik_expression.rb +19 -0
  156. data/test/test_mapnik_feature.rb +33 -0
  157. data/test/test_mapnik_font_engine.rb +13 -0
  158. data/test/test_mapnik_geometry.rb +72 -0
  159. data/test/test_mapnik_glyph_symbolizer.rb +96 -0
  160. data/test/test_mapnik_layer.rb +137 -0
  161. data/test/test_mapnik_line_symbolizer.rb +25 -0
  162. data/test/test_mapnik_map.rb +191 -0
  163. data/test/test_mapnik_markers_symbolizer.rb +46 -0
  164. data/test/test_mapnik_point_symbolizer.rb +53 -0
  165. data/test/test_mapnik_polygon_symbolizer.rb +44 -0
  166. data/test/test_mapnik_projection.rb +46 -0
  167. data/test/test_mapnik_raster_colorizer.rb +56 -0
  168. data/test/test_mapnik_raster_symbolizer.rb +40 -0
  169. data/test/test_mapnik_rule.rb +63 -0
  170. data/test/test_mapnik_shield_symbolizer.rb +193 -0
  171. data/test/test_mapnik_stroke.rb +94 -0
  172. data/test/test_mapnik_style.rb +28 -0
  173. data/test/test_mapnik_symbolizer.rb +9 -0
  174. data/test/test_mapnik_text_symbolizer.rb +232 -0
  175. data/test/test_polygon_pattern_symbolizer.rb +34 -0
  176. data/test/test_ruby_mapnik.rb +34 -0
  177. data/yard/lib/yard/parser/generic_parser.rb +72 -0
  178. data/yard/lib/yard_generic.rb +18 -0
  179. metadata +322 -0
@@ -0,0 +1,188 @@
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_stroke.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
+ #include <rice/Array.hpp>
30
+ #include <rice/Hash.hpp>
31
+ #include <rice/Symbol.hpp>
32
+
33
+ // Mapnik
34
+ #include <mapnik/stroke.hpp>
35
+
36
+ namespace {
37
+
38
+ Rice::Object get_dashes(const mapnik::stroke& stroke){
39
+ Rice::Array out;
40
+ if (stroke.has_dash()) {
41
+ mapnik::dash_array const& dash = stroke.get_dash_array();
42
+ mapnik::dash_array::const_iterator iter = dash.begin();
43
+ mapnik::dash_array::const_iterator end = dash.end();
44
+ for (; iter != end; ++iter) {
45
+ Rice::Array tuple;
46
+ tuple.push(iter->first);
47
+ tuple.push(iter->second);
48
+ out.push(tuple);
49
+ }
50
+ }
51
+ return out;
52
+ }
53
+
54
+ mapnik::line_cap_enum get_stroke_line_cap(mapnik::stroke const & self){
55
+ mapnik::line_cap_enum line_cap = self.get_line_cap();
56
+ return line_cap;
57
+ }
58
+
59
+ void set_stroke_line_cap(mapnik::stroke & self, mapnik::line_cap_enum val){
60
+ self.set_line_cap(val);
61
+ }
62
+
63
+ mapnik::line_join_enum get_stroke_line_join(mapnik::stroke const & self){
64
+ mapnik::line_join_enum line_join = self.get_line_join();
65
+ return line_join;
66
+ }
67
+
68
+ void set_stroke_line_join(mapnik::stroke & self, mapnik::line_join_enum val){
69
+ self.set_line_join(val);
70
+ }
71
+
72
+ }
73
+
74
+ void register_stroke(Rice::Module rb_mapnik){
75
+ /*
76
+ @@Module_var rb_mapnik = Mapnik
77
+ */
78
+ Rice::Data_Type< mapnik::stroke > rb_cstroke = Rice::define_class_under< mapnik::stroke >(rb_mapnik, "Stroke");
79
+
80
+ /*
81
+ * Document-method: new
82
+ * call-seq:
83
+ * new(color, width)
84
+ * @param [Mapnik::Color] color
85
+ * @param [Float] width
86
+ *
87
+ * @return [Mapnik::Stroke]
88
+ */
89
+ rb_cstroke.define_constructor(Rice::Constructor< mapnik::stroke, mapnik::color, float >());
90
+
91
+ /*
92
+ * Document-method: color
93
+ * @return [Mapnik::Color]
94
+ */
95
+ rb_cstroke.define_method("color", &mapnik::stroke::get_color);
96
+
97
+ /*
98
+ * Document-method: color=
99
+ * call-seq:
100
+ * color=(color)
101
+ * @param [Mapnik::Color] color
102
+ * @return [nil]
103
+ */
104
+ rb_cstroke.define_method("color=", &mapnik::stroke::set_color, Rice::Arg("new_color"));
105
+
106
+ /*
107
+ * Document-method: opacity
108
+ * @return [Float]
109
+ */
110
+ rb_cstroke.define_method("opacity", &mapnik::stroke::get_opacity);
111
+
112
+ /*
113
+ * Document-method: opacity=
114
+ * call-seq:
115
+ * opactiy=(new_value)
116
+ * @param [Float] new_value
117
+ * @return [nil]
118
+ */
119
+ rb_cstroke.define_method("opacity=", &mapnik::stroke::set_opacity, Rice::Arg("new_opacity"));
120
+
121
+ /*
122
+ * Document-method: gamma
123
+ * @return [Float]
124
+ */
125
+ rb_cstroke.define_method("gamma", &mapnik::stroke::get_gamma);
126
+
127
+ /*
128
+ * Document-method: gamma=
129
+ * call-seq:
130
+ * gamma=(new_value)
131
+ * @param [Float] new_value
132
+ * @return [nil]
133
+ */
134
+ rb_cstroke.define_method("gamma=", &mapnik::stroke::set_gamma, Rice::Arg("new_gamma"));
135
+
136
+ /*
137
+ * Document-method: width
138
+ * @return [Float]
139
+ */
140
+ rb_cstroke.define_method("width", &mapnik::stroke::get_width);
141
+
142
+ /*
143
+ * Document-method: width=
144
+ * call-seq:
145
+ * width=(new_value)
146
+ * @param [Float] new_value
147
+ * @return [nil]
148
+ */
149
+ rb_cstroke.define_method("width=", &mapnik::stroke::set_width, Rice::Arg("new_width"));
150
+
151
+ /*
152
+ * Document-method: dash_offset
153
+ * @return [Float]
154
+ */
155
+ rb_cstroke.define_method("dash_offset", &mapnik::stroke::dash_offset);
156
+
157
+ /*
158
+ * Document-method: dash_offset=
159
+ * call-seq:
160
+ * dash_offset=(new_value)
161
+ * @param [Float] new_value
162
+ * @return [nil]
163
+ */
164
+ rb_cstroke.define_method("dash_offset=", &mapnik::stroke::set_dash_offset, Rice::Arg("new_dash_offset"));
165
+
166
+ rb_cstroke.define_method("line_cap", &get_stroke_line_cap);
167
+ rb_cstroke.define_method("line_cap=", &set_stroke_line_cap);
168
+
169
+ rb_cstroke.define_method("line_join", &get_stroke_line_join);
170
+ rb_cstroke.define_method("line_join=", &set_stroke_line_join);
171
+
172
+ // Dont-Document-method: __dashes__
173
+ rb_cstroke.define_method("__dashes__", &get_dashes);
174
+
175
+ // Dont-Document-method: __add_dash__
176
+ rb_cstroke.define_method("__add_dash__", &mapnik::stroke::add_dash);
177
+
178
+ Rice::Enum<mapnik::line_cap_enum> rb_eline_cap_enum = Rice::define_enum<mapnik::line_cap_enum>("LineCap", rb_mapnik);
179
+ rb_eline_cap_enum.define_value("BUTT_CAP", mapnik::BUTT_CAP);
180
+ rb_eline_cap_enum.define_value("SQUARE_CAP", mapnik::SQUARE_CAP);
181
+ rb_eline_cap_enum.define_value("ROUND_CAP", mapnik::ROUND_CAP);
182
+
183
+ Rice::Enum<mapnik::line_join_enum> rb_eline_join_enum = Rice::define_enum<mapnik::line_join_enum>("LineJoin", rb_mapnik);
184
+ rb_eline_join_enum.define_value("MITER_JOIN", mapnik::MITER_JOIN);
185
+ rb_eline_join_enum.define_value("MITER_REVERT_JOIN", mapnik::MITER_REVERT_JOIN);
186
+ rb_eline_join_enum.define_value("ROUND_JOIN", mapnik::ROUND_JOIN);
187
+ rb_eline_join_enum.define_value("BEVEL_JOIN", mapnik::BEVEL_JOIN);
188
+ }
@@ -0,0 +1,32 @@
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_STROKE
23
+ #define PIKA2_MAPNIK_STROKE
24
+
25
+ namespace Rice
26
+ {
27
+ class Module;
28
+ }
29
+
30
+ void register_stroke(Rice::Module rb_mapnik);
31
+
32
+ #endif
@@ -0,0 +1,76 @@
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_style.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/feature_type_style.hpp>
32
+
33
+
34
+ template<>
35
+ Rice::Object to_ruby<std::vector<mapnik::rule> >(std::vector<mapnik::rule> const & x)
36
+ {
37
+ return Rice::Array(x.begin(), x.end());
38
+ }
39
+
40
+ namespace {
41
+
42
+ void set_style_filter(mapnik::feature_type_style& self, mapnik::filter_mode_enum value){
43
+ mapnik::filter_mode_e v(value);
44
+ self.set_filter_mode(v);
45
+ }
46
+
47
+ mapnik::filter_mode_enum get_style_filter(const mapnik::feature_type_style& self){
48
+ return self.get_filter_mode();
49
+ }
50
+
51
+ }
52
+ void register_style(Rice::Module rb_mapnik){
53
+ /*
54
+ @@Module_var rb_mapnik = Mapnik
55
+ */
56
+ Rice::Data_Type< mapnik::feature_type_style > rb_cstyle = Rice::define_class_under< mapnik::feature_type_style >(rb_mapnik, "Style");
57
+
58
+ /*
59
+ * Document-method: new
60
+ * @return [Mapnik::Style]
61
+ */
62
+ rb_cstyle.define_constructor(Rice::Constructor< mapnik::feature_type_style >());
63
+
64
+ // Dont-Document-method: __rules__
65
+ rb_cstyle.define_method("__rules__", &mapnik::feature_type_style::get_rules);
66
+
67
+ // Dont-Document-method: __add_rule__
68
+ rb_cstyle.define_method("__add_rule__", &mapnik::feature_type_style::add_rule);
69
+
70
+ rb_cstyle.define_method("filter_mode=", &set_style_filter);
71
+ rb_cstyle.define_method("filter_mode", &get_style_filter);
72
+
73
+ Rice::Enum<mapnik::filter_mode_enum> rb_cfilter_mode_enum = Rice::define_enum<mapnik::filter_mode_enum>("FilterMode", rb_mapnik);
74
+ rb_cfilter_mode_enum.define_value("ALL",mapnik::FILTER_ALL);
75
+ rb_cfilter_mode_enum.define_value("FIRST",mapnik::FILTER_FIRST);
76
+ }
@@ -0,0 +1,32 @@
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_STYLE
23
+ #define PIKA2_MAPNIK_STYLE
24
+
25
+ namespace Rice
26
+ {
27
+ class Module;
28
+ }
29
+
30
+ void register_style(Rice::Module rb_mapnik);
31
+
32
+ #endif
@@ -0,0 +1,77 @@
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_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/rule.hpp>
32
+
33
+ namespace {
34
+
35
+ // TODO: This is just terrible...
36
+ mapnik::symbolizer from_subtype(Rice::Object obj){
37
+ mapnik::symbolizer out;
38
+ std::string class_name = obj.class_of().to_s().str();
39
+ if(class_name == "Mapnik::PolygonSymbolizer") {
40
+ out = mapnik::symbolizer(from_ruby<mapnik::polygon_symbolizer>(obj));
41
+ } else if(class_name == "Mapnik::LineSymbolizer") {
42
+ out = mapnik::symbolizer(from_ruby<mapnik::line_symbolizer>(obj));
43
+ } else if(class_name == "Mapnik::TextSymbolizer"){
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
+ } else if(class_name == "Mapnik::LinePatternSymbolizer"){
48
+ out = mapnik::symbolizer(from_ruby<mapnik::line_pattern_symbolizer>(obj));
49
+ } else if(class_name == "Mapnik::MarkersSymbolizer"){
50
+ out = mapnik::symbolizer(from_ruby<mapnik::markers_symbolizer>(obj));
51
+ } else if(class_name == "Mapnik::PointSymbolizer") {
52
+ out = mapnik::symbolizer(from_ruby<mapnik::point_symbolizer>(obj));
53
+ } else if(class_name == "Mapnik::PolygonPatternSymbolizer"){
54
+ out = mapnik::symbolizer(from_ruby<mapnik::polygon_pattern_symbolizer>(obj));
55
+ } else if(class_name == "Mapnik::RasterSymbolizer"){
56
+ out = mapnik::symbolizer(from_ruby<mapnik::raster_symbolizer>(obj));
57
+ } else if(class_name == "Mapnik::ShieldSymbolizer"){
58
+ out = mapnik::symbolizer(from_ruby<mapnik::shield_symbolizer>(obj));
59
+ }
60
+ return out;
61
+ }
62
+
63
+ }
64
+ void register_symbolizer(Rice::Module rb_mapnik){
65
+ /*
66
+ @@Module_var rb_mapnik = Mapnik
67
+ */
68
+ Rice::Data_Type< mapnik::symbolizer > rb_csymbolizer = Rice::define_class_under< mapnik::symbolizer >(rb_mapnik, "Symbolizer");
69
+
70
+ /*
71
+ * Document-method: from_subtype
72
+ * call-seq:
73
+ * from_subtype(symbolizer)
74
+ * @return [Mapnik::Symbolizer]
75
+ */
76
+ rb_csymbolizer.define_singleton_method("from_subtype", &from_subtype, Rice::Arg("obj"));
77
+ }
@@ -0,0 +1,32 @@
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_SYMBOLIZER
23
+ #define PIKA2_MAPNIK_SYMBOLIZER
24
+
25
+ namespace Rice
26
+ {
27
+ class Module;
28
+ }
29
+
30
+ void register_symbolizer(Rice::Module rb_mapnik);
31
+
32
+ #endif