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,145 @@
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_coord.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/coord.hpp>
31
+
32
+ namespace {
33
+ void wrap_mapnik_coord_double__2__x_set(mapnik::coord2d* self, double val) {
34
+ self->x = val;
35
+ }
36
+ double wrap_mapnik_coord_double__2__x_get(mapnik::coord2d* self) {
37
+ return self->x;
38
+ }
39
+ void wrap_mapnik_coord_double__2__y_set(mapnik::coord2d* self, double val) {
40
+ self->y = val;
41
+ }
42
+ double wrap_mapnik_coord_double__2__y_get(mapnik::coord2d* self) {
43
+ return self->y;
44
+ }
45
+
46
+ mapnik::coord2d wrap_mapnik_coord_double__2__times_equals(mapnik::coord2d self, float value){
47
+ return self *= value;
48
+ }
49
+
50
+ mapnik::coord2d wrap_mapnik_coord_double__2__addition(mapnik::coord2d self, float value){
51
+ return self += value;
52
+ }
53
+
54
+ mapnik::coord2d wrap_mapnik_coord_double__2__subtraction(mapnik::coord2d self, float value){
55
+ return self -= value;
56
+ }
57
+
58
+ mapnik::coord2d wrap_mapnik_coord_double__2__division(mapnik::coord2d self, float value){
59
+ return self /= value;
60
+ }
61
+
62
+ bool wrap_mapnik_coord_double__2__equality(mapnik::coord2d self, mapnik::coord2d rhs){
63
+ return self == rhs;
64
+ }
65
+ }
66
+ void register_coord(Rice::Module rb_mapnik) {
67
+ /*
68
+ * @@Module_var rb_mapnik = Mapnik
69
+ *
70
+ * Document-class: Mapnik::Coord2d
71
+ * A two dimensional coordinate
72
+ */
73
+ Rice::Data_Type< mapnik::coord2d > rb_ccoord2d = Rice::define_class_under< mapnik::coord2d >(rb_mapnik, "Coord2d");
74
+
75
+ /*
76
+ * Document-method: new
77
+ * call-seq:
78
+ * new(x,y)
79
+ * Returns a new Coord2d object
80
+ */
81
+ rb_ccoord2d.define_constructor(Rice::Constructor< mapnik::coord2d,double,double >());
82
+
83
+ /*
84
+ * Document-method: x=
85
+ * @param [Float]
86
+ * Sets the x value of the coord
87
+ */
88
+ rb_ccoord2d.define_method("x=", &wrap_mapnik_coord_double__2__x_set);
89
+ rb_ccoord2d.define_method("x", &wrap_mapnik_coord_double__2__x_get);
90
+
91
+ /*
92
+ * Document-method: y=
93
+ * @param [Float]
94
+ * Sets the y value of the coord
95
+ */
96
+ rb_ccoord2d.define_method("y=", &wrap_mapnik_coord_double__2__y_set);
97
+ rb_ccoord2d.define_method("y", &wrap_mapnik_coord_double__2__y_get);
98
+
99
+
100
+ /*
101
+ * Document-method: *
102
+ * call-seq:
103
+ * * value
104
+ * @param [Float]
105
+ * Multiplies the x and y coordinates of the receiver by the value provided
106
+ */
107
+ rb_ccoord2d.define_method("*", &wrap_mapnik_coord_double__2__times_equals, (Rice::Arg("value")));
108
+
109
+ /*
110
+ * Document-method: ==
111
+ * call-seq:
112
+ * ==(other_coord)
113
+ * @param [Mapnik::Coord2d]
114
+ * Returns true if the x and y values of other_coord equal those of the reciever
115
+ */
116
+ rb_ccoord2d.define_method("==", &wrap_mapnik_coord_double__2__equality, (Rice::Arg("rhs")));
117
+
118
+ /*
119
+ * Document-method: +=
120
+ * call-seq:
121
+ * + value
122
+ * @param [Float]
123
+ * Adds the x and y coordinates of the receiver by the value provided
124
+ */
125
+ rb_ccoord2d.define_method("+", &wrap_mapnik_coord_double__2__addition, (Rice::Arg("value")));
126
+
127
+ /*
128
+ * Document-method: -=
129
+ * call-seq:
130
+ * - value
131
+ * @param [Float]
132
+ * Subtracts the x and y coordinates of the receiver by the value provided
133
+ */
134
+ rb_ccoord2d.define_method("-", &wrap_mapnik_coord_double__2__subtraction, (Rice::Arg("value")));
135
+
136
+ /*
137
+ * Document-method: /=
138
+ * call-seq:
139
+ * /=(value)
140
+ * @param [Float]
141
+ * Divides the x and y coordinates of the receiver by the value provided
142
+ */
143
+ rb_ccoord2d.define_method("/", &wrap_mapnik_coord_double__2__division, (Rice::Arg("value")));
144
+
145
+ }
@@ -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_COORD
23
+ #define PIKA2_MAPNIK_COORD
24
+
25
+ namespace Rice
26
+ {
27
+ class Module;
28
+ }
29
+
30
+ void register_coord(Rice::Module rb_mapnik);
31
+
32
+ #endif
@@ -0,0 +1,150 @@
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_datasource.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/layer.hpp>
33
+ #include <mapnik/datasource.hpp>
34
+ #include <mapnik/datasource_cache.hpp>
35
+ #include <mapnik/feature_layer_desc.hpp>
36
+ #include <mapnik/box2d.hpp>
37
+
38
+ namespace {
39
+ class mapnik_value_holder_to_ruby_visitor : public boost::static_visitor<Rice::Object>
40
+ {
41
+ public:
42
+
43
+ Rice::Object operator()(int i) const {
44
+ return to_ruby<int>(i);
45
+ }
46
+
47
+ Rice::Object operator()(double i) const {
48
+ return to_ruby<double>(i);
49
+ }
50
+
51
+ Rice::Object operator()(const std::string & str) const {
52
+ return to_ruby<std::string>(str);
53
+ }
54
+ };
55
+
56
+
57
+ std::string name(boost::shared_ptr<mapnik::datasource> self){
58
+ mapnik::layer_descriptor ld = self->get_descriptor();
59
+ return ld.get_name();
60
+ }
61
+
62
+ boost::shared_ptr<mapnik::datasource> create(Rice::Object params){
63
+ bool bind=true;
64
+ Rice::Hash options = (Rice::Hash) params;
65
+ mapnik::parameters datasource_params;
66
+
67
+ Rice::Hash::iterator it = options.begin();
68
+ Rice::Hash::iterator end = options.end();
69
+ for(; it != end; ++it) {
70
+ Rice::String keyString = it->key.to_s();
71
+ Rice::Object value = it->value;
72
+ switch (value.rb_type()) {
73
+ case T_STRING:
74
+ datasource_params[keyString.str()] = ((Rice::String) value).str();
75
+ break;
76
+ case T_FLOAT:
77
+ datasource_params[keyString.str()] = NUM2DBL(value.value());
78
+ break;
79
+ case T_FIXNUM:
80
+ // The compiler wanted this explicit cast here, not sure why...
81
+ datasource_params[keyString.str()] = (int)NUM2INT(value.value());
82
+ break;
83
+ }
84
+ }
85
+
86
+ return mapnik::datasource_cache::create(datasource_params, bind);
87
+ }
88
+
89
+
90
+ mapnik::box2d<double> get_datasource_envelope(boost::shared_ptr<mapnik::datasource> self){
91
+ return self->envelope();
92
+ }
93
+
94
+ Rice::Object get_datasource_params(boost::shared_ptr<mapnik::datasource> const & self){
95
+ Rice::Hash params;
96
+ mapnik::parameters ds_params = self->params();
97
+ mapnik::parameters::const_iterator pos=ds_params.begin();
98
+ while(pos!=ds_params.end())
99
+ {
100
+ params[Rice::Symbol(pos->first)] = boost::apply_visitor(mapnik_value_holder_to_ruby_visitor(), pos->second);
101
+ ++pos;
102
+ }
103
+ return params;
104
+ }
105
+ }
106
+ void register_datasource(Rice::Module rb_mapnik){
107
+ /*
108
+ @@Module_var rb_mapnik = Mapnik
109
+ */
110
+ Rice::Data_Type< boost::shared_ptr<mapnik::datasource> > rb_cdatasource = Rice::define_class_under< boost::shared_ptr<mapnik::datasource> >(rb_mapnik, "Datasource");
111
+
112
+ /*
113
+ * Document-method: envelope
114
+ * @return [Mapnik::Envelope]
115
+ * Returns an envelope containing the datasource's features
116
+ */
117
+ rb_cdatasource.define_method("envelope", &get_datasource_envelope);
118
+
119
+ /*
120
+ * Document-method: name
121
+ * @return [String]
122
+ * The name of the datasource
123
+ */
124
+ rb_cdatasource.define_method("name", &name);
125
+
126
+ /*
127
+ * Document-method: params
128
+ * @return [Hash]
129
+ * The params used to create the datasource
130
+ */
131
+ rb_cdatasource.define_method("params", &get_datasource_params);
132
+
133
+ /*
134
+ * Document-method: create
135
+ * call-seq:
136
+ * Mapnik::Datasource.create(params)
137
+ *
138
+ * @param [Hash] the parameters for the datasource
139
+ *
140
+ * Creates a new datasource, with the params provided. The parameters required
141
+ * will depend on the input plugin
142
+ *
143
+ * -- TODO: more
144
+ */
145
+ rb_cdatasource.define_singleton_method("create", &create, (Rice::Arg("params")));
146
+
147
+ // TODO: Descriptor, features at point...
148
+ // rb_cdatasource.define_method("descriptor", &mapnik::datasource::get_descriptor);
149
+
150
+ }
@@ -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_DATASOURCE
23
+ #define PIKA2_MAPNIK_DATASOURCE
24
+
25
+ namespace Rice
26
+ {
27
+ class Module;
28
+ }
29
+
30
+ void register_datasource(Rice::Module rb_mapnik);
31
+
32
+ #endif
@@ -0,0 +1,79 @@
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_datasource_cache.rb.h"
23
+
24
+ // Rice
25
+ #include <rice/Data_Type.hpp>
26
+ #include <rice/Constructor.hpp>
27
+ #include <rice/Class.hpp>
28
+ #include <rice/Array.hpp>
29
+ #include <rice/Hash.hpp>
30
+
31
+ // Mapnik
32
+ #include <mapnik/datasource.hpp>
33
+ #include <mapnik/datasource_cache.hpp>
34
+
35
+ namespace {
36
+ bool rubysafe_register_sources(std::string path){
37
+ mapnik::datasource_cache::instance()->register_datasources(path);
38
+ return true;
39
+ }
40
+
41
+ Rice::Array rubysafe_plugin_names(){
42
+ std::vector<std::string, std::allocator<std::string> > names = mapnik::datasource_cache::instance()->plugin_names();
43
+
44
+ Rice::Array o;
45
+
46
+ int unsigned count = names.size();
47
+
48
+ for (unsigned i=0;i<count;++i){
49
+ Rice::String n = names[i];
50
+ o.push(n);
51
+ }
52
+
53
+ return o;
54
+ }
55
+ }
56
+ void register_datasource_cache(Rice::Module rb_mapnik) {
57
+ /*
58
+ @@Module_var rb_mapnik = Mapnik
59
+ */
60
+ Rice::Data_Type< mapnik::datasource_cache > rb_cdatasource_cache = Rice::define_class_under< mapnik::datasource_cache >(rb_mapnik, "DatasourceCache");
61
+
62
+ /*
63
+ * Document-method: available_plugins
64
+ *
65
+ * @return [Array] the datasource plugins available. (Determined by your Mapnik install)
66
+ */
67
+ rb_cdatasource_cache.define_singleton_method("available_plugins", &rubysafe_plugin_names);
68
+
69
+ /*
70
+ * Document-method: register
71
+ * call-seq:
72
+ * Mapnik::DatasourceCache.register(path_to_mapnik_input_plugins)
73
+ * @param [String] The path
74
+ *
75
+ * Registers the input plugins with mapnik. Used internally by Ruby-Mapnik.
76
+ * You should never have to call this.
77
+ */
78
+ rb_cdatasource_cache.define_singleton_method("register", &rubysafe_register_sources, Rice::Arg("path"));
79
+ }
@@ -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_DATASOURCE_CACHE
23
+ #define PIKA2_MAPNIK_DATASOURCE_CACHE
24
+
25
+ namespace Rice
26
+ {
27
+ class Module;
28
+ }
29
+
30
+ void register_datasource_cache(Rice::Module rb_mapnik);
31
+
32
+ #endif
@@ -0,0 +1,220 @@
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_envelope.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/box2d.hpp>
31
+
32
+ namespace {
33
+ // Height
34
+ typedef double ( mapnik::box2d<double>::*height_func_type )() const;
35
+ typedef void ( mapnik::box2d<double>::*set_height_func_type )(double h);
36
+
37
+ // Width
38
+ typedef double ( mapnik::box2d<double>::*width_func_type )() const;
39
+ typedef void ( mapnik::box2d<double>::*set_width_func_type )(double w);
40
+
41
+ // Re-center
42
+ typedef void ( mapnik::box2d<double>::*re_center_func_type )( double x, double y );
43
+ typedef void ( mapnik::box2d<double>::*re_center_func_type_coord )( const mapnik::coord2d& other );
44
+
45
+ // Contains
46
+ typedef bool (mapnik::box2d<double>::*contains_xy_func_type)(double x,double y) const;
47
+ typedef bool (mapnik::box2d<double>::*contains_coord_func_type)(const mapnik::coord2d &c) const;
48
+ typedef bool (mapnik::box2d<double>::*contains_envelope_func_type)(const mapnik::box2d<double> &other) const;
49
+
50
+ // Intersects
51
+ typedef bool (mapnik::box2d<double>::*intersects_xy_func_type)(double x,double y) const;
52
+ typedef bool (mapnik::box2d<double>::*intersects_coord_func_type)(const mapnik::coord2d &c) const;
53
+ typedef bool (mapnik::box2d<double>::*intersects_envelope_func_type)(const mapnik::box2d<double> &other) const;
54
+
55
+ // Expand to include
56
+ typedef void ( mapnik::box2d<double>::*expand_to_include_xy_func_type )( double x, double y );
57
+ typedef void ( mapnik::box2d<double>::*expand_to_include_coord_func_type )( const mapnik::coord2d& c );
58
+ typedef void ( mapnik::box2d<double>::*expand_to_include_envelope_func_type )( const mapnik::box2d<double>& other );
59
+
60
+ bool wrap_mapnik_box2d_double__2__equality(mapnik::box2d<double> self, mapnik::box2d<double> rhs){
61
+ return self == rhs;
62
+ }
63
+ }
64
+ void register_envelope(Rice::Module rb_mapnik){
65
+ /*
66
+ @@Module_var rb_mapnik = Mapnik
67
+ */
68
+ Rice::Data_Type< mapnik::box2d<double> > rb_cenvelope = Rice::define_class_under< mapnik::box2d<double> >(rb_mapnik, "Envelope");
69
+
70
+ /*
71
+ * Document-method: new
72
+ * call-seq:
73
+ * new(min_x, min_y, max_x, max_y)
74
+ *
75
+ * @param [Float] min_x
76
+ * @param [Float] min_y
77
+ * @param [Float] max_x
78
+ * @param [Float] max_y
79
+ *
80
+ * Returns a new Mapnik::Envelope
81
+ */
82
+ rb_cenvelope.define_constructor(Rice::Constructor< mapnik::box2d<double>,double,double,double,double >());
83
+
84
+ /*
85
+ * Document-method: min_x
86
+ * @return [Float]
87
+ */
88
+ rb_cenvelope.define_method("min_x", &mapnik::box2d<double>::minx);
89
+
90
+ /*
91
+ * Document-method: min_y
92
+ * @return [Float]
93
+ */
94
+ rb_cenvelope.define_method("min_y", &mapnik::box2d<double>::miny);
95
+
96
+ /*
97
+ * Document-method: max_x
98
+ * @return [Float]
99
+ */
100
+ rb_cenvelope.define_method("max_x", &mapnik::box2d<double>::maxx);
101
+
102
+ /*
103
+ * Document-method: max_y
104
+ * @return [Float]
105
+ */
106
+ rb_cenvelope.define_method("max_y", &mapnik::box2d<double>::maxy);
107
+
108
+ /*
109
+ * Document-method: center
110
+ * @return [Mapnik::Coord2d] the center of the envelope.
111
+ */
112
+ rb_cenvelope.define_method("center", &mapnik::box2d<double>::center);
113
+
114
+ /*
115
+ * Dont-Document-method: re_center_to_xy!
116
+ */
117
+ rb_cenvelope.define_method("re_center_to_xy!", re_center_func_type( &mapnik::box2d<double>::re_center ), (Rice::Arg("x"), Rice::Arg("y")));
118
+
119
+ /*
120
+ * Dont-Document-method: re_center_to_coord!
121
+ */
122
+ rb_cenvelope.define_method("re_center_to_coord!", re_center_func_type_coord( &mapnik::box2d<double>::re_center ), (Rice::Arg("other")));
123
+
124
+
125
+ rb_cenvelope.define_method("height", height_func_type( &mapnik::box2d<double>::height ));
126
+ rb_cenvelope.define_method("height=", set_height_func_type( &mapnik::box2d<double>::height ), (Rice::Arg("h")));
127
+
128
+ rb_cenvelope.define_method("width", height_func_type( &mapnik::box2d<double>::width ));
129
+ rb_cenvelope.define_method("width=", set_height_func_type( &mapnik::box2d<double>::width ), (Rice::Arg("w")));
130
+
131
+ /*
132
+ * Dont-Document-method: contains_xy?
133
+ */
134
+ rb_cenvelope.define_method("contains_xy?", contains_xy_func_type( &mapnik::box2d<double>::contains ), (Rice::Arg("x"), Rice::Arg("y")));
135
+
136
+ /*
137
+ * Dont-Document-method: contains_coord?
138
+ */
139
+ rb_cenvelope.define_method("contains_coord?", contains_coord_func_type( &mapnik::box2d<double>::contains ), (Rice::Arg("c")));
140
+
141
+ /*
142
+ * Dont-Document-method: contains_envelope?
143
+ */
144
+ rb_cenvelope.define_method("contains_envelope?", contains_envelope_func_type( &mapnik::box2d<double>::contains ), (Rice::Arg("other")));
145
+
146
+ /*
147
+ * Dont-Document-method: intersects_xy?
148
+ */
149
+ rb_cenvelope.define_method("intersects_xy?", intersects_xy_func_type( &mapnik::box2d<double>::intersects ), (Rice::Arg("x"), Rice::Arg("y")));
150
+
151
+ /*
152
+ * Dont-Document-method: intersects_coord?
153
+ */
154
+ rb_cenvelope.define_method("intersects_coord?", intersects_coord_func_type( &mapnik::box2d<double>::intersects ), (Rice::Arg("c")));
155
+
156
+ /*
157
+ * Dont-Document-method: intersects_envelope?
158
+ */
159
+ rb_cenvelope.define_method("intersects_envelope?", intersects_envelope_func_type( &mapnik::box2d<double>::intersects ), (Rice::Arg("other")));
160
+
161
+ /*
162
+ * Dont-Document-method: expand_to_include_xy!
163
+ */
164
+ rb_cenvelope.define_method("expand_to_include_xy!", expand_to_include_xy_func_type( &mapnik::box2d<double>::expand_to_include ), (Rice::Arg("x"), Rice::Arg("y")));
165
+
166
+ /*
167
+ * Dont-Document-method: expand_to_include_coord!
168
+ */
169
+ rb_cenvelope.define_method("expand_to_include_coord!", expand_to_include_coord_func_type( &mapnik::box2d<double>::expand_to_include ), (Rice::Arg("c")));
170
+
171
+ /*
172
+ * Dont-Document-method: expand_to_include_envelope!
173
+ */
174
+ rb_cenvelope.define_method("expand_to_include_envelope!", expand_to_include_envelope_func_type( &mapnik::box2d<double>::expand_to_include ), (Rice::Arg("other")));
175
+
176
+ /*
177
+ * Document-method: intersection
178
+ * call-seq:
179
+ * intersection(other_envelope)
180
+ *
181
+ * @param [Mapnik::Envelope] the other envelope
182
+ *
183
+ * Returns a new envelope that is the intersection of another envelope and
184
+ * the reciever.
185
+ *
186
+ * @return [Mapnik::Envelope]
187
+ */
188
+ rb_cenvelope.define_method("intersection", &mapnik::box2d<double>::intersect, Rice::Arg("other"));
189
+
190
+ /*
191
+ * Document-method: clip!
192
+ * call-seq:
193
+ * clip!(other_envelope)
194
+ *
195
+ * @param [Mapnik::Envelope] the other envelope
196
+ *
197
+ * Clips the reciever by another other envelope
198
+ * @return [nil]
199
+ */
200
+ rb_cenvelope.define_method("clip!", &mapnik::box2d<double>::clip, Rice::Arg("other"));
201
+
202
+ /*
203
+ * Document-method: valid?
204
+ * Returns true if the envelope is sound.
205
+ * @return [Boolean]
206
+ */
207
+ rb_cenvelope.define_method("valid?", &mapnik::box2d<double>::valid);
208
+
209
+ /*
210
+ * Document-method: ==
211
+ * call-seq:
212
+ * ==(other_envelope)
213
+ *
214
+ * Returns true if the other envelope's coordinates match the reciever's
215
+ *
216
+ * @return [Boolean]
217
+ */
218
+ rb_cenvelope.define_method("==", &wrap_mapnik_box2d_double__2__equality, (Rice::Arg("rhs")));
219
+
220
+ }