ruby_mapnik 0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,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_LINE_SYMBOLIZER
23
+ #define PIKA2_MAPNIK_LINE_SYMBOLIZER
24
+
25
+ namespace Rice
26
+ {
27
+ class Module;
28
+ }
29
+
30
+ void register_line_symbolizer(Rice::Module rb_mapnik);
31
+
32
+ #endif
@@ -0,0 +1,435 @@
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_map.rb.h"
23
+
24
+ // Rice
25
+ #include <rice/Data_Type.hpp>
26
+ #include <rice/Constructor.hpp>
27
+ #include <rice/Class.hpp>
28
+ #include <rice/Hash.hpp>
29
+ #include <rice/Array.hpp>
30
+
31
+ // Mapnik
32
+ #include <mapnik/map.hpp>
33
+ #include <mapnik/agg_renderer.hpp>
34
+ #include <mapnik/graphics.hpp>
35
+ #ifdef HAVE_CAIRO
36
+ #include <mapnik/cairo_renderer.hpp>
37
+ #endif
38
+ #include <mapnik/image_util.hpp>
39
+ #include <mapnik/load_map.hpp>
40
+ #include <mapnik/save_map.hpp>
41
+
42
+
43
+ // Seems like one could metaprogram these two away...
44
+ template<>
45
+ Rice::Object to_ruby<boost::optional<mapnik::color> >(boost::optional<mapnik::color> const & x){
46
+ if(x)
47
+ {
48
+ return to_ruby<mapnik::color>(x.get());
49
+ } else{
50
+ return Rice::Object();
51
+ }
52
+ }
53
+
54
+ template<>
55
+ Rice::Object to_ruby<boost::optional<mapnik::box2d<double> > >(boost::optional<mapnik::box2d<double> > const & x){
56
+ if(x)
57
+ {
58
+ return to_ruby<mapnik::box2d<double> >(x.get());
59
+ } else{
60
+ return Rice::Object();
61
+ }
62
+ }
63
+
64
+ template<>
65
+ Rice::Object to_ruby<std::map<std::string,mapnik::feature_type_style> >(std::map<std::string,mapnik::feature_type_style> const & x){
66
+ Rice::Hash h;
67
+ std::map<std::string,mapnik::feature_type_style>::const_iterator end = x.end();
68
+ for (std::map<std::string,mapnik::feature_type_style>::const_iterator it = x.begin(); it != end; ++it){
69
+ h[to_ruby<std::string>(it->first)] = to_ruby<mapnik::feature_type_style>(it->second);
70
+ }
71
+ return h;
72
+ }
73
+
74
+ template<>
75
+ Rice::Object to_ruby<std::vector<mapnik::layer> >(std::vector<mapnik::layer> const & x)
76
+ {
77
+ return Rice::Array(x.begin(), x.end());
78
+ }
79
+
80
+ std::map<std::string,mapnik::feature_type_style> & (mapnik::Map::*_map_styles_)() = &mapnik::Map::styles;
81
+ std::vector<mapnik::layer> & (mapnik::Map::*_map_layers_)() = &mapnik::Map::layers;
82
+
83
+ namespace {
84
+
85
+ void render_map_to_file(const mapnik::Map& map, const std::string& filename){
86
+ std::string format = mapnik::guess_type(filename);
87
+ if (format == "pdf" || format == "svg" || format =="ps") {
88
+ #if defined(HAVE_CAIRO)
89
+ mapnik::save_to_cairo_file(map,filename,format);
90
+ #else
91
+ throw mapnik::ImageWriterException("Cairo backend not available, cannot write to format: " + format);
92
+ #endif
93
+ } else {
94
+ mapnik::image_32 image(map.width(),map.height());
95
+ mapnik::agg_renderer<mapnik::image_32> ren(map,image,1.0,0,0);
96
+ ren.apply();
97
+ mapnik::save_to_file(image,filename);
98
+ }
99
+ }
100
+
101
+ std::string render_map_to_string(const mapnik::Map& map, std::string const& format){
102
+ mapnik::image_32 image(map.width(),map.height());
103
+ mapnik::agg_renderer<mapnik::image_32> ren(map,image,1.0,0,0);
104
+ ren.apply();
105
+ return mapnik::save_to_string(image,format);
106
+ }
107
+
108
+ std::string map_to_string(const mapnik::Map& map){
109
+ return mapnik::save_map_to_string(map);
110
+ }
111
+
112
+ #if defined(HAVE_CAIRO)
113
+
114
+ // TODO: These are temporarily boosted from the ruby cairo gem...
115
+ cairo_surface_t * rb_cairo_surface_from_ruby_object (VALUE obj) {
116
+ cairo_surface_t *surface;
117
+ // if (!rb_cairo__is_kind_of (obj, rb_cCairo_Surface))
118
+ // {
119
+ // rb_raise (rb_eTypeError, "not a cairo surface");
120
+ // }
121
+ Data_Get_Struct (obj, cairo_surface_t, surface);
122
+ // if (!surface)
123
+ // rb_cairo_check_status (CAIRO_STATUS_NULL_POINTER);
124
+ return surface;
125
+ }
126
+
127
+ cairo_t * rb_cairo_context_from_ruby_object (VALUE obj) {
128
+ cairo_t *context;
129
+ // if (!rb_cairo__is_kind_of (obj, rb_cCairo_Surface))
130
+ // {
131
+ // rb_raise (rb_eTypeError, "not a cairo surface");
132
+ // }
133
+ Data_Get_Struct (obj, cairo_t, context);
134
+ // if (!surface)
135
+ // rb_cairo_check_status (CAIRO_STATUS_NULL_POINTER);
136
+ return context;
137
+ }
138
+
139
+ void render_to_cairo_surface(mapnik::Map const & map, Rice::Object rb_surface, unsigned offset_x = 0, unsigned offset_y = 0){
140
+ cairo_surface_t * surface = rb_cairo_surface_from_ruby_object(rb_surface);
141
+ Cairo::RefPtr<Cairo::Surface> s(new Cairo::Surface(surface));
142
+ mapnik::cairo_renderer<Cairo::Surface> ren(map,s,offset_x, offset_y);
143
+ ren.apply();
144
+ }
145
+
146
+ void render_to_cairo_context(mapnik::Map const & map, Rice::Object rb_context, unsigned offset_x = 0, unsigned offset_y = 0){
147
+ cairo_t * context = rb_cairo_context_from_ruby_object(rb_context);
148
+ Cairo::RefPtr<Cairo::Context> c(new Cairo::Context(context));
149
+ mapnik::cairo_renderer<Cairo::Context> ren(map, c, offset_x, offset_y);
150
+ ren.apply();
151
+ }
152
+ #endif
153
+
154
+ void initialize_map(Rice::Object self){
155
+ DATA_PTR(self.value()) = new mapnik::Map();
156
+ if(rb_block_given_p()) {
157
+ rb_yield(self);
158
+ }
159
+ }
160
+
161
+ }
162
+
163
+ void register_map(Rice::Module rb_mapnik){
164
+ /*
165
+ @@Module_var rb_mapnik = Mapnik
166
+ */
167
+ Rice::Data_Type< mapnik::Map > rb_cmap = Rice::define_class_under< mapnik::Map >(rb_mapnik, "Map");
168
+
169
+ /*
170
+ * Document-method: new
171
+ * @return [Mapnik::Map] a new map object
172
+ * @yield [map] the new map object
173
+ */
174
+ rb_cmap.define_constructor(Rice::Constructor< mapnik::Map >());
175
+
176
+ /*
177
+ * Dont-Document-method: __load_map_string__
178
+ */
179
+ rb_cmap.define_singleton_method("__load_map_string__", &mapnik::load_map_string);
180
+
181
+ /*
182
+ * Dont-Document-method: __load_map__
183
+ */
184
+ rb_cmap.define_singleton_method("__load_map__", &mapnik::load_map);
185
+
186
+ /*
187
+ * Dont-document-method: initialize
188
+ */
189
+ rb_cmap.define_method("initialize", &initialize_map);
190
+
191
+ /*
192
+ * Document-method: background
193
+ * @return [Mapnik::Color]
194
+ */
195
+ rb_cmap.define_method("background", &mapnik::Map::background);
196
+
197
+ /*
198
+ * Document-method: background=
199
+ * call-seq:
200
+ * background=(color)
201
+ * @param [Mapnik::Color]
202
+ * @return [nil]
203
+ */
204
+ rb_cmap.define_method("background=", &mapnik::Map::set_background);
205
+
206
+ /*
207
+ * Document-method: base_path
208
+ * @return [String] The path all relative paths will be resolved with
209
+ */
210
+ rb_cmap.define_method("base_path", &mapnik::Map::base_path);
211
+
212
+ /*
213
+ * Document-method: base_path=
214
+ * call-seq:
215
+ * base_path=(path)
216
+ * @param [String]
217
+ * @return [nil]
218
+ */
219
+ rb_cmap.define_method("base_path=", &mapnik::Map::set_base_path);
220
+
221
+ /*
222
+ * Document-method: buffer_size
223
+ * @return [Integer]
224
+ */
225
+ rb_cmap.define_method("buffer_size", &mapnik::Map::buffer_size);
226
+
227
+ /*
228
+ * Document-method: buffer_size=
229
+ * call-seq:
230
+ * buffer_size=(size)
231
+ * @param [Integer]
232
+ * @return [nil]
233
+ */
234
+ rb_cmap.define_method("buffer_size=", &mapnik::Map::set_buffer_size);
235
+
236
+ /*
237
+ * Document-method: height
238
+ * @return [Integer]
239
+ */
240
+ rb_cmap.define_method("height", &mapnik::Map::height);
241
+
242
+ /*
243
+ * Document-method: height=
244
+ * call-seq:
245
+ * height=(height_in_pixels)
246
+ * @param [Integer]
247
+ * @return [nil]
248
+ */
249
+ rb_cmap.define_method("height=", &mapnik::Map::set_height);
250
+
251
+ /*
252
+ * Document-method: maximum_extent
253
+ * @return [Mapnik::Envelope]
254
+ */
255
+ rb_cmap.define_method("maximum_extent", &mapnik::Map::maximum_extent);
256
+
257
+ /*
258
+ * Document-method: maximum_extent=
259
+ * call-seq:
260
+ * maximum_extent=(new_extent)
261
+ * @param [Mapnik::Envelope] new_extent
262
+ * @return [nil]
263
+ */
264
+ rb_cmap.define_method("maximum_extent=", &mapnik::Map::set_maximum_extent, Rice::Arg("new_extent"));
265
+
266
+ /*
267
+ * Document-method: srs
268
+ * @return [String]
269
+ */
270
+ rb_cmap.define_method("srs", &mapnik::Map::srs);
271
+
272
+ /*
273
+ * Document-method: srs=
274
+ * call-seq:
275
+ * srs=(new_srs)
276
+ * @param [String]
277
+ * @return [nil]
278
+ */
279
+ rb_cmap.define_method("srs=", &mapnik::Map::set_srs);
280
+
281
+ /*
282
+ * Document-method: width
283
+ * @return [Integer]
284
+ */
285
+ rb_cmap.define_method("width", &mapnik::Map::width);
286
+
287
+ /*
288
+ * Document-method width=
289
+ * call-seq:
290
+ * width=(new_width)
291
+ * @param [Integer] new_width in pixels
292
+ * @return [nil]
293
+ */
294
+ rb_cmap.define_method("width=", &mapnik::Map::set_width);
295
+
296
+ /*
297
+ * Document-method: envelope
298
+ * @return [Mapnik::Envelope]
299
+ */
300
+ rb_cmap.define_method("envelope", &mapnik::Map::get_current_extent);
301
+
302
+ /*
303
+ * Document-method: buffered_envelope
304
+ * @return [Mapnik::Envelope]
305
+ * The envelope plus any buffer set in buffer_size
306
+ */
307
+ rb_cmap.define_method("buffered_envelope", &mapnik::Map::get_buffered_extent);
308
+
309
+ /*
310
+ * Document-method: pan
311
+ * call-seq:
312
+ * pan(x, y)
313
+ * @param [Integer] x
314
+ * @param [Integer] y
315
+ * @return [nil]
316
+ */
317
+ rb_cmap.define_method("pan", &mapnik::Map::pan);
318
+
319
+ /*
320
+ * Document-method: zoom
321
+ * call-seq:
322
+ * zoom(zoom_factor)
323
+ * @param [Integer] zoom_factor
324
+ * @return [nil]
325
+ */
326
+ rb_cmap.define_method("zoom", &mapnik::Map::zoom);
327
+
328
+ /*
329
+ * Document-method: zoom_all
330
+ * @return [nil]
331
+ */
332
+ rb_cmap.define_method("zoom_all", &mapnik::Map::zoom_all);
333
+
334
+ /*
335
+ * Document-method: zoom_to_box
336
+ * call-seq:
337
+ * zoom_to_box(envelope)
338
+ * @param [Mapnik::Envelope] envelope
339
+ * @return [nil]
340
+ */
341
+ rb_cmap.define_method("zoom_to_box", &mapnik::Map::zoom_to_box, Rice::Arg("envelope"));
342
+
343
+ /*
344
+ * Document-method: resize
345
+ * call-seq:
346
+ * resize(new_width, new_height)
347
+ * @param [Integer] new_width in pixels
348
+ * @param [Integer] new_height in pixels
349
+ * @return [nil]
350
+ */
351
+ rb_cmap.define_method("resize", &mapnik::Map::resize);
352
+
353
+ /*
354
+ * Document-method: scale
355
+ * @return [Float]
356
+ */
357
+ rb_cmap.define_method("scale", &mapnik::Map::scale);
358
+
359
+ /*
360
+ * Dont-Document-method: __styles__
361
+ */
362
+ rb_cmap.define_method("__styles__", _map_styles_);
363
+
364
+ /*
365
+ * Dont-Document-method: __insert_style__
366
+ */
367
+ rb_cmap.define_method("__insert_style__", &mapnik::Map::insert_style);
368
+
369
+ /*
370
+ * Dont-Document-method: __remove_style__
371
+ */
372
+ rb_cmap.define_method("__remove_style__", &mapnik::Map::remove_style);
373
+
374
+ /*
375
+ * Dont-Document-method: __layers__
376
+ */
377
+ rb_cmap.define_method("__layers__", _map_layers_);
378
+
379
+ /*
380
+ * Dont-Document-method: __add_layer__
381
+ */
382
+ rb_cmap.define_method("__add_layer__", &mapnik::Map::addLayer);
383
+
384
+ /*
385
+ * Dont-Document-method: __remove_layer__
386
+ */
387
+ rb_cmap.define_method("__remove_layer__", &mapnik::Map::removeLayer);
388
+
389
+ /*
390
+ * Dont-Document-method: __render_to_file__
391
+ */
392
+ rb_cmap.define_method("__render_to_file__", &render_map_to_file);
393
+
394
+ /*
395
+ * Document-method: to_xml
396
+ * @return [String]
397
+ * An XML representation of the map that can be loaded via the from_xml method, or by other mapnik implementations
398
+ */
399
+ rb_cmap.define_method("to_xml", &map_to_string);
400
+
401
+ /*
402
+ * Document-method: render_to_string
403
+ * call-seq:
404
+ * render_to_string(file_format)
405
+ * @param [String] file_format One of 'png', 'jpg' or 'tiff'
406
+ * @return [String] A string of the data for the image
407
+ */
408
+ rb_cmap.define_method("render_to_string", &render_map_to_string);
409
+
410
+ #if defined(HAVE_CAIRO)
411
+
412
+ /*
413
+ * Document-method: render_to_cairo_surface
414
+ * call-seq:
415
+ * render_to_cairo_surface(cairo_surface)
416
+ * @param [Cairo::Surface]
417
+ * @return [nil]
418
+ * Only available if Ruby-Mapnik was compiled with Cairo support and the
419
+ * Ruby Cairo gem is available
420
+ */
421
+ rb_cmap.define_method("render_to_cairo_surface", &render_to_cairo_surface);
422
+
423
+ /*
424
+ * Document-method: render_to_cairo_context
425
+ * call-seq:
426
+ * render_to_cairo_context(cairo_context)
427
+ * @param [Cairo::Context]
428
+ * @return [nil]
429
+ * Only available if Ruby-Mapnik was compiled with Cairo support and the
430
+ * Ruby Cairo gem is available
431
+ */
432
+ rb_cmap.define_method("render_to_cairo_context", &render_to_cairo_context);
433
+ #endif
434
+
435
+ }
@@ -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_MAP
23
+ #define PIKA2_MAPNIK_MAP
24
+
25
+ namespace Rice
26
+ {
27
+ class Module;
28
+ }
29
+
30
+ void register_map(Rice::Module rb_mapnik);
31
+
32
+ #endif
@@ -0,0 +1,139 @@
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_markers_symbolizer.rb.h"
23
+
24
+ // Rice
25
+ #include <rice/Data_Type.hpp>
26
+ #include <rice/Constructor.hpp>
27
+ #include <rice/Class.hpp>
28
+
29
+ // Mapnik
30
+ #include <mapnik/markers_symbolizer.hpp>
31
+
32
+ namespace {
33
+ const std::string get_filename(mapnik::markers_symbolizer const& t) {
34
+ return mapnik::path_processor_type::to_string(*t.get_filename());
35
+ }
36
+
37
+ void set_filename(mapnik::markers_symbolizer & t, std::string const& file_expr) {
38
+ t.set_filename(mapnik::parse_path(file_expr));
39
+ }
40
+
41
+ const double get_markers_opacity(mapnik::markers_symbolizer const& t){
42
+ return t.get_opacity();
43
+ }
44
+
45
+ void set_markers_opacity(mapnik::markers_symbolizer & t, double value){
46
+ t.set_opacity(value);
47
+ }
48
+ }
49
+ void register_markers_symbolizer(Rice::Module rb_mapnik){
50
+ /*
51
+ @@Module_var rb_mapnik = Mapnik
52
+ */
53
+ Rice::Data_Type< mapnik::markers_symbolizer > rb_cmarkers_symbolizer = Rice::define_class_under< mapnik::markers_symbolizer >(rb_mapnik, "MarkersSymbolizer");
54
+
55
+ /*
56
+ * Document-method: new
57
+ * call-seq:
58
+ * new(path_expression)
59
+ * @param [Mapnik::PathExpression]
60
+ * @return [Mapnik::MarkersSymbolizer]
61
+ */
62
+ rb_cmarkers_symbolizer.define_constructor(Rice::Constructor< mapnik::markers_symbolizer, mapnik::path_expression_ptr>());
63
+
64
+ /*
65
+ * Document-method: filename
66
+ * @return [String]
67
+ */
68
+ rb_cmarkers_symbolizer.define_method("filename", &get_filename);
69
+
70
+ /*
71
+ * Document-method: filename=
72
+ * call-seq:
73
+ * filename=(new_filename)
74
+ * @param [String] filename
75
+ * @return [nil]
76
+ */
77
+ rb_cmarkers_symbolizer.define_method("filename=", &set_filename);
78
+
79
+ /*
80
+ * Document-method: allow_overlap?
81
+ * @return [Boolean]
82
+ */
83
+ rb_cmarkers_symbolizer.define_method("allow_overlap?", &mapnik::markers_symbolizer::get_allow_overlap);
84
+
85
+ /*
86
+ * Document-method: allow_overlap=
87
+ * call-seq:
88
+ * allow_overlap=(new_value)
89
+ * @param [Boolean] new_value
90
+ * @return [nil]
91
+ */
92
+ rb_cmarkers_symbolizer.define_method("allow_overlap=", &mapnik::markers_symbolizer::set_allow_overlap);
93
+
94
+ /*
95
+ * Document-method: spacing
96
+ * @return [Integer]
97
+ */
98
+ rb_cmarkers_symbolizer.define_method("spacing", &mapnik::markers_symbolizer::get_spacing);
99
+
100
+ /*
101
+ * Document-method: spacing=
102
+ * call-seq:
103
+ * spacing=(new_spacing_value)
104
+ * @param [Integer] new_spacing_value
105
+ * @return [nil]
106
+ */
107
+ rb_cmarkers_symbolizer.define_method("spacing=", &mapnik::markers_symbolizer::set_spacing);
108
+
109
+ /*
110
+ * Document-method: max_error
111
+ * @return [Integer]
112
+ */
113
+ rb_cmarkers_symbolizer.define_method("max_error", &mapnik::markers_symbolizer::get_max_error);
114
+
115
+ /*
116
+ * Document-method:max_error=
117
+ * call-seq:
118
+ * max_error=(new_value)
119
+ * @param [Integer] new_value
120
+ * @return [nil]
121
+ */
122
+ rb_cmarkers_symbolizer.define_method("max_error=", &mapnik::markers_symbolizer::set_max_error);
123
+
124
+ /*
125
+ * Document-method: opacity
126
+ * @return [Float]
127
+ */
128
+ rb_cmarkers_symbolizer.define_method("opacity", &get_markers_opacity);
129
+
130
+ /*
131
+ * Document-method: opacity=
132
+ * call-seq:
133
+ * opacity=(new_value)
134
+ * @param [Float]
135
+ * @return [nil]
136
+ */
137
+ rb_cmarkers_symbolizer.define_method("opacity=", &set_markers_opacity);
138
+
139
+ }
@@ -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_MARKERS_SYMBOLIZER
23
+ #define PIKA2_MAPNIK_MARKERS_SYMBOLIZER
24
+
25
+ namespace Rice
26
+ {
27
+ class Module;
28
+ }
29
+
30
+ void register_markers_symbolizer(Rice::Module rb_mapnik);
31
+
32
+ #endif