mapnik 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +35 -0
- data/.yardopts +1 -0
- data/Gemfile +14 -0
- data/LICENSE +19 -0
- data/Manifest.txt +172 -0
- data/README.rdoc +107 -0
- data/Rakefile +43 -0
- data/demo/data/COPYRIGHT.txt +3 -0
- data/demo/data/TM_WORLD_BORDERS_SIMPL_0.3_MOD.dbf +0 -0
- data/demo/data/TM_WORLD_BORDERS_SIMPL_0.3_MOD.prj +1 -0
- data/demo/data/TM_WORLD_BORDERS_SIMPL_0.3_MOD.shp +0 -0
- data/demo/data/TM_WORLD_BORDERS_SIMPL_0.3_MOD.shx +0 -0
- data/demo/data/boundaries.dbf +0 -0
- data/demo/data/boundaries.prj +1 -0
- data/demo/data/boundaries.sbx +0 -0
- data/demo/data/boundaries.shp +0 -0
- data/demo/data/boundaries.shx +0 -0
- data/demo/data/boundaries_l.dbf +0 -0
- data/demo/data/boundaries_l.prj +1 -0
- data/demo/data/boundaries_l.sbx +0 -0
- data/demo/data/boundaries_l.shp +0 -0
- data/demo/data/boundaries_l.shx +0 -0
- data/demo/data/ontdrainage.dbf +0 -0
- data/demo/data/ontdrainage.prj +1 -0
- data/demo/data/ontdrainage.sbx +0 -0
- data/demo/data/ontdrainage.shp +0 -0
- data/demo/data/ontdrainage.shx +0 -0
- data/demo/data/popplaces.dbf +0 -0
- data/demo/data/popplaces.prj +1 -0
- data/demo/data/popplaces.sbx +0 -0
- data/demo/data/popplaces.shp +0 -0
- data/demo/data/popplaces.shx +0 -0
- data/demo/data/qcdrainage.dbf +0 -0
- data/demo/data/qcdrainage.prj +1 -0
- data/demo/data/qcdrainage.sbx +0 -0
- data/demo/data/qcdrainage.shp +0 -0
- data/demo/data/qcdrainage.shx +0 -0
- data/demo/data/roads.dbf +0 -0
- data/demo/data/roads.prj +1 -0
- data/demo/data/roads.sbx +0 -0
- data/demo/data/roads.shp +0 -0
- data/demo/data/roads.shx +0 -0
- data/demo/data/test/charplacement.dbf +0 -0
- data/demo/data/test/charplacement.shp +0 -0
- data/demo/data/test/charplacement.shx +0 -0
- data/demo/data/test/displacement.dbf +0 -0
- data/demo/data/test/displacement.shp +0 -0
- data/demo/data/test/displacement.shx +0 -0
- data/demo/data/test/overlap.dbf +0 -0
- data/demo/data/test/overlap.shp +0 -0
- data/demo/data/test/overlap.shx +0 -0
- data/demo/data/test/raw/charplacement.gfs +25 -0
- data/demo/data/test/raw/charplacement.gml +99 -0
- data/demo/data/test/raw/charplacement.xsd +36 -0
- data/demo/data/test/raw/displacement.gfs +25 -0
- data/demo/data/test/raw/displacement.gml +173 -0
- data/demo/data/test/raw/displacement.xsd +36 -0
- data/demo/data/test/raw/overlap.gfs +25 -0
- data/demo/data/test/raw/overlap.gml +127 -0
- data/demo/data/test/raw/overlap.xsd +36 -0
- data/demo/data/test/raw/textspacing.gfs +25 -0
- data/demo/data/test/raw/textspacing.gml +117 -0
- data/demo/data/test/raw/textspacing.xsd +36 -0
- data/demo/data/test/readme.txt +3 -0
- data/demo/data/test/regenerate.sh +20 -0
- data/demo/data/test/textspacing.dbf +0 -0
- data/demo/data/test/textspacing.shp +0 -0
- data/demo/data/test/textspacing.shx +0 -0
- data/demo/rundemo.rb +145 -0
- data/demo/sinatra/demo.rb +31 -0
- data/demo/sinatra/public/css/demo_map.css +7 -0
- data/demo/sinatra/public/index.html +13 -0
- data/demo/sinatra/public/javascripts/demo_map.js +42 -0
- data/ext/ruby_mapnik/_mapnik.cpp +52 -0
- data/ext/ruby_mapnik/_mapnik.h +65 -0
- data/ext/ruby_mapnik/_mapnik_color.rb.cpp +179 -0
- data/ext/ruby_mapnik/_mapnik_color.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_coord.rb.cpp +145 -0
- data/ext/ruby_mapnik/_mapnik_coord.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_datasource.rb.cpp +170 -0
- data/ext/ruby_mapnik/_mapnik_datasource.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_datasource_cache.rb.cpp +87 -0
- data/ext/ruby_mapnik/_mapnik_datasource_cache.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_envelope.rb.cpp +220 -0
- data/ext/ruby_mapnik/_mapnik_envelope.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_expression.rb.cpp +91 -0
- data/ext/ruby_mapnik/_mapnik_expression.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_feature.rb.cpp +93 -0
- data/ext/ruby_mapnik/_mapnik_feature.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_font_engine.rb.cpp +71 -0
- data/ext/ruby_mapnik/_mapnik_font_engine.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_layer.rb.cpp +208 -0
- data/ext/ruby_mapnik/_mapnik_layer.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_line_pattern_symbolizer.rb.cpp +71 -0
- data/ext/ruby_mapnik/_mapnik_line_pattern_symbolizer.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_line_symbolizer.rb.cpp +43 -0
- data/ext/ruby_mapnik/_mapnik_line_symbolizer.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_map.rb.cpp +489 -0
- data/ext/ruby_mapnik/_mapnik_map.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_markers_symbolizer.rb.cpp +140 -0
- data/ext/ruby_mapnik/_mapnik_markers_symbolizer.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_point_symbolizer.rb.cpp +150 -0
- data/ext/ruby_mapnik/_mapnik_point_symbolizer.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_polygon_pattern_symbolizer.rb.cpp +93 -0
- data/ext/ruby_mapnik/_mapnik_polygon_pattern_symbolizer.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_polygon_symbolizer.rb.cpp +89 -0
- data/ext/ruby_mapnik/_mapnik_polygon_symbolizer.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_projection.rb.cpp +100 -0
- data/ext/ruby_mapnik/_mapnik_projection.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_raster_colorizer.rb.cpp +162 -0
- data/ext/ruby_mapnik/_mapnik_raster_colorizer.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_raster_symbolizer.rb.cpp +87 -0
- data/ext/ruby_mapnik/_mapnik_raster_symbolizer.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_rule.rb.cpp +69 -0
- data/ext/ruby_mapnik/_mapnik_rule.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_shield_symbolizer.rb.cpp +86 -0
- data/ext/ruby_mapnik/_mapnik_shield_symbolizer.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_stroke.rb.cpp +188 -0
- data/ext/ruby_mapnik/_mapnik_stroke.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_style.rb.cpp +76 -0
- data/ext/ruby_mapnik/_mapnik_style.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_symbolizer.rb.cpp +75 -0
- data/ext/ruby_mapnik/_mapnik_symbolizer.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_text_symbolizer.rb.cpp +471 -0
- data/ext/ruby_mapnik/_mapnik_text_symbolizer.rb.h +32 -0
- data/ext/ruby_mapnik/extconf.rb +80 -0
- data/ext/ruby_mapnik/ruby_mapnik.cpp +32 -0
- data/lib/mapnik.rb +1 -0
- data/lib/ruby_mapnik.rb +48 -0
- data/lib/ruby_mapnik/mapnik/font_engine.rb +35 -0
- data/lib/ruby_mapnik/mapnik/layer.rb +68 -0
- data/lib/ruby_mapnik/mapnik/map.rb +166 -0
- data/lib/ruby_mapnik/mapnik/projection.rb +44 -0
- data/lib/ruby_mapnik/mapnik/raster_colorizer.rb +55 -0
- data/lib/ruby_mapnik/mapnik/rule.rb +104 -0
- data/lib/ruby_mapnik/mapnik/stroke.rb +56 -0
- data/lib/ruby_mapnik/mapnik/style.rb +64 -0
- data/lib/ruby_mapnik/mapnik/tile.rb +93 -0
- data/script/console +2 -0
- data/test/data/TM_WORLD_BORDERS_SIMPL_0.3_MOD.dbf +0 -0
- data/test/data/TM_WORLD_BORDERS_SIMPL_0.3_MOD.prj +1 -0
- data/test/data/TM_WORLD_BORDERS_SIMPL_0.3_MOD.shp +0 -0
- data/test/data/TM_WORLD_BORDERS_SIMPL_0.3_MOD.shx +0 -0
- data/test/data/test_map.xml +15 -0
- data/test/test_helper.rb +29 -0
- data/test/test_line_pattern_symbolizer.rb +26 -0
- data/test/test_mapnik_color.rb +66 -0
- data/test/test_mapnik_coord.rb +92 -0
- data/test/test_mapnik_datasource.rb +49 -0
- data/test/test_mapnik_envelope.rb +232 -0
- data/test/test_mapnik_expression.rb +19 -0
- data/test/test_mapnik_feature.rb +29 -0
- data/test/test_mapnik_font_engine.rb +13 -0
- data/test/test_mapnik_layer.rb +121 -0
- data/test/test_mapnik_line_symbolizer.rb +25 -0
- data/test/test_mapnik_map.rb +211 -0
- data/test/test_mapnik_markers_symbolizer.rb +46 -0
- data/test/test_mapnik_point_symbolizer.rb +53 -0
- data/test/test_mapnik_polygon_symbolizer.rb +44 -0
- data/test/test_mapnik_projection.rb +46 -0
- data/test/test_mapnik_raster_colorizer.rb +56 -0
- data/test/test_mapnik_raster_symbolizer.rb +45 -0
- data/test/test_mapnik_rule.rb +45 -0
- data/test/test_mapnik_shield_symbolizer.rb +156 -0
- data/test/test_mapnik_stroke.rb +94 -0
- data/test/test_mapnik_style.rb +28 -0
- data/test/test_mapnik_symbolizer.rb +9 -0
- data/test/test_mapnik_text_symbolizer.rb +208 -0
- data/test/test_polygon_pattern_symbolizer.rb +34 -0
- data/test/test_ruby_mapnik.rb +34 -0
- data/yard/lib/yard/parser/generic_parser.rb +72 -0
- data/yard/lib/yard_generic.rb +18 -0
- metadata +333 -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_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,170 @@
|
|
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/version.hpp>
|
34
|
+
#include <mapnik/datasource.hpp>
|
35
|
+
#include <mapnik/datasource_cache.hpp>
|
36
|
+
#include <mapnik/feature_layer_desc.hpp>
|
37
|
+
#include <mapnik/box2d.hpp>
|
38
|
+
|
39
|
+
#if MAPNIK_VERSION >= 200200
|
40
|
+
typedef mapnik::value_integer value_integer;
|
41
|
+
#else
|
42
|
+
typedef int value_integer;
|
43
|
+
#endif
|
44
|
+
|
45
|
+
namespace {
|
46
|
+
class mapnik_value_holder_to_ruby_visitor : public boost::static_visitor<Rice::Object>
|
47
|
+
{
|
48
|
+
public:
|
49
|
+
|
50
|
+
Rice::Object operator()(value_integer i) const {
|
51
|
+
// TODO - support long long?
|
52
|
+
return to_ruby<int>(static_cast<int>(i));
|
53
|
+
}
|
54
|
+
|
55
|
+
Rice::Object operator()(bool i) const {
|
56
|
+
return to_ruby<bool>(i);
|
57
|
+
}
|
58
|
+
Rice::Object operator()(double i) const {
|
59
|
+
return to_ruby<double>(i);
|
60
|
+
}
|
61
|
+
|
62
|
+
Rice::Object operator()(std::string const& str) const {
|
63
|
+
return to_ruby<std::string>(str);
|
64
|
+
}
|
65
|
+
|
66
|
+
Rice::Object operator()(mapnik::value_null const& value) const {
|
67
|
+
return Rice::Object(Qnil);
|
68
|
+
}
|
69
|
+
|
70
|
+
};
|
71
|
+
|
72
|
+
|
73
|
+
std::string name(boost::shared_ptr<mapnik::datasource> self){
|
74
|
+
mapnik::layer_descriptor ld = self->get_descriptor();
|
75
|
+
return ld.get_name();
|
76
|
+
}
|
77
|
+
|
78
|
+
boost::shared_ptr<mapnik::datasource> create(Rice::Object params){
|
79
|
+
Rice::Hash options = (Rice::Hash) params;
|
80
|
+
mapnik::parameters datasource_params;
|
81
|
+
|
82
|
+
Rice::Hash::iterator it = options.begin();
|
83
|
+
Rice::Hash::iterator end = options.end();
|
84
|
+
for(; it != end; ++it) {
|
85
|
+
Rice::String keyString = it->key.to_s();
|
86
|
+
Rice::Object value = it->value;
|
87
|
+
switch (value.rb_type()) {
|
88
|
+
case T_STRING:
|
89
|
+
datasource_params[keyString.str()] = ((Rice::String) value).str();
|
90
|
+
break;
|
91
|
+
case T_FLOAT:
|
92
|
+
datasource_params[keyString.str()] = NUM2DBL(value.value());
|
93
|
+
break;
|
94
|
+
case T_FIXNUM:
|
95
|
+
// The compiler wanted this explicit cast here, not sure why...
|
96
|
+
// TODO FIXME - won't compile....
|
97
|
+
//datasource_params[keyString.str()] = static_cast<value_integer>(NUM2INT(value.value()));
|
98
|
+
break;
|
99
|
+
}
|
100
|
+
}
|
101
|
+
|
102
|
+
#if MAPNIK_VERSION >= 200200
|
103
|
+
return mapnik::datasource_cache::instance().create(datasource_params);
|
104
|
+
#else
|
105
|
+
return mapnik::datasource_cache::instance()->create(datasource_params);
|
106
|
+
#endif
|
107
|
+
}
|
108
|
+
|
109
|
+
|
110
|
+
mapnik::box2d<double> get_datasource_envelope(boost::shared_ptr<mapnik::datasource> self){
|
111
|
+
return self->envelope();
|
112
|
+
}
|
113
|
+
|
114
|
+
Rice::Object get_datasource_params(boost::shared_ptr<mapnik::datasource> const & self){
|
115
|
+
Rice::Hash params;
|
116
|
+
mapnik::parameters ds_params = self->params();
|
117
|
+
mapnik::parameters::const_iterator pos=ds_params.begin();
|
118
|
+
while(pos!=ds_params.end())
|
119
|
+
{
|
120
|
+
params[Rice::Symbol(pos->first)] = boost::apply_visitor(mapnik_value_holder_to_ruby_visitor(), pos->second);
|
121
|
+
++pos;
|
122
|
+
}
|
123
|
+
return params;
|
124
|
+
}
|
125
|
+
}
|
126
|
+
void register_datasource(Rice::Module rb_mapnik){
|
127
|
+
/*
|
128
|
+
@@Module_var rb_mapnik = Mapnik
|
129
|
+
*/
|
130
|
+
Rice::Data_Type< boost::shared_ptr<mapnik::datasource> > rb_cdatasource = Rice::define_class_under< boost::shared_ptr<mapnik::datasource> >(rb_mapnik, "Datasource");
|
131
|
+
|
132
|
+
/*
|
133
|
+
* Document-method: envelope
|
134
|
+
* @return [Mapnik::Envelope]
|
135
|
+
* Returns an envelope containing the datasource's features
|
136
|
+
*/
|
137
|
+
rb_cdatasource.define_method("envelope", &get_datasource_envelope);
|
138
|
+
|
139
|
+
/*
|
140
|
+
* Document-method: name
|
141
|
+
* @return [String]
|
142
|
+
* The name of the datasource
|
143
|
+
*/
|
144
|
+
rb_cdatasource.define_method("name", &name);
|
145
|
+
|
146
|
+
/*
|
147
|
+
* Document-method: params
|
148
|
+
* @return [Hash]
|
149
|
+
* The params used to create the datasource
|
150
|
+
*/
|
151
|
+
rb_cdatasource.define_method("params", &get_datasource_params);
|
152
|
+
|
153
|
+
/*
|
154
|
+
* Document-method: create
|
155
|
+
* call-seq:
|
156
|
+
* Mapnik::Datasource.create(params)
|
157
|
+
*
|
158
|
+
* @param [Hash] the parameters for the datasource
|
159
|
+
*
|
160
|
+
* Creates a new datasource, with the params provided. The parameters required
|
161
|
+
* will depend on the input plugin
|
162
|
+
*
|
163
|
+
* -- TODO: more
|
164
|
+
*/
|
165
|
+
rb_cdatasource.define_singleton_method("create", &create, (Rice::Arg("params")));
|
166
|
+
|
167
|
+
// TODO: Descriptor, features at point...
|
168
|
+
// rb_cdatasource.define_method("descriptor", &mapnik::datasource::get_descriptor);
|
169
|
+
|
170
|
+
}
|
@@ -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,87 @@
|
|
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/version.hpp>
|
33
|
+
#include <mapnik/datasource.hpp>
|
34
|
+
#include <mapnik/datasource_cache.hpp>
|
35
|
+
|
36
|
+
namespace {
|
37
|
+
bool rubysafe_register_sources(std::string path){
|
38
|
+
#if MAPNIK_VERSION >= 200200
|
39
|
+
mapnik::datasource_cache::instance().register_datasources(path);
|
40
|
+
#else
|
41
|
+
mapnik::datasource_cache::instance()->register_datasources(path);
|
42
|
+
#endif
|
43
|
+
return true;
|
44
|
+
}
|
45
|
+
|
46
|
+
Rice::Array rubysafe_plugin_names(){
|
47
|
+
#if MAPNIK_VERSION >= 200200
|
48
|
+
std::vector<std::string, std::allocator<std::string> > names = mapnik::datasource_cache::instance().plugin_names();
|
49
|
+
#else
|
50
|
+
std::vector<std::string, std::allocator<std::string> > names = mapnik::datasource_cache::instance()->plugin_names();
|
51
|
+
#endif
|
52
|
+
Rice::Array o;
|
53
|
+
|
54
|
+
int unsigned count = names.size();
|
55
|
+
|
56
|
+
for (unsigned i=0;i<count;++i){
|
57
|
+
Rice::String n = names[i];
|
58
|
+
o.push(n);
|
59
|
+
}
|
60
|
+
|
61
|
+
return o;
|
62
|
+
}
|
63
|
+
}
|
64
|
+
void register_datasource_cache(Rice::Module rb_mapnik) {
|
65
|
+
/*
|
66
|
+
@@Module_var rb_mapnik = Mapnik
|
67
|
+
*/
|
68
|
+
Rice::Data_Type< mapnik::datasource_cache > rb_cdatasource_cache = Rice::define_class_under< mapnik::datasource_cache >(rb_mapnik, "DatasourceCache");
|
69
|
+
|
70
|
+
/*
|
71
|
+
* Document-method: available_plugins
|
72
|
+
*
|
73
|
+
* @return [Array] the datasource plugins available. (Determined by your Mapnik install)
|
74
|
+
*/
|
75
|
+
rb_cdatasource_cache.define_singleton_method("available_plugins", &rubysafe_plugin_names);
|
76
|
+
|
77
|
+
/*
|
78
|
+
* Document-method: register
|
79
|
+
* call-seq:
|
80
|
+
* Mapnik::DatasourceCache.register(path_to_mapnik_input_plugins)
|
81
|
+
* @param [String] The path
|
82
|
+
*
|
83
|
+
* Registers the input plugins with mapnik. Used internally by Ruby-Mapnik.
|
84
|
+
* You should never have to call this.
|
85
|
+
*/
|
86
|
+
rb_cdatasource_cache.define_singleton_method("register", &rubysafe_register_sources, Rice::Arg("path"));
|
87
|
+
}
|
@@ -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
|
+
}
|