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.
- data/.autotest +35 -0
- data/.gemtest +0 -0
- data/.yardopts +1 -0
- data/Gemfile +12 -0
- data/LICENSE +19 -0
- data/Manifest.txt +177 -0
- data/README.rdoc +84 -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 +139 -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 +54 -0
- data/ext/ruby_mapnik/_mapnik.h +69 -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 +150 -0
- data/ext/ruby_mapnik/_mapnik_datasource.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_datasource_cache.rb.cpp +79 -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 +56 -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_geometry.rb.cpp +73 -0
- data/ext/ruby_mapnik/_mapnik_geometry.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_glyph_symbolizer.rb.cpp +250 -0
- data/ext/ruby_mapnik/_mapnik_glyph_symbolizer.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_layer.rb.cpp +237 -0
- data/ext/ruby_mapnik/_mapnik_layer.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_line_pattern_symbolizer.rb.cpp +70 -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 +435 -0
- data/ext/ruby_mapnik/_mapnik_map.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_markers_symbolizer.rb.cpp +139 -0
- data/ext/ruby_mapnik/_mapnik_markers_symbolizer.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_point_symbolizer.rb.cpp +147 -0
- data/ext/ruby_mapnik/_mapnik_point_symbolizer.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_polygon_pattern_symbolizer.rb.cpp +92 -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 +98 -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 +53 -0
- data/ext/ruby_mapnik/_mapnik_raster_symbolizer.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_rule.rb.cpp +99 -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 +77 -0
- data/ext/ruby_mapnik/_mapnik_symbolizer.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_text_symbolizer.rb.cpp +521 -0
- data/ext/ruby_mapnik/_mapnik_text_symbolizer.rb.h +32 -0
- data/ext/ruby_mapnik/extconf.rb +78 -0
- data/ext/ruby_mapnik/ruby_mapnik.cpp +31 -0
- data/lib/ruby_mapnik/mapnik/font_engine.rb +35 -0
- data/lib/ruby_mapnik/mapnik/layer.rb +69 -0
- data/lib/ruby_mapnik/mapnik/map.rb +144 -0
- data/lib/ruby_mapnik/mapnik/projection.rb +46 -0
- data/lib/ruby_mapnik/mapnik/raster_colorizer.rb +55 -0
- data/lib/ruby_mapnik/mapnik/rule.rb +107 -0
- data/lib/ruby_mapnik/mapnik/stroke.rb +58 -0
- data/lib/ruby_mapnik/mapnik/style.rb +66 -0
- data/lib/ruby_mapnik/mapnik/tile.rb +93 -0
- data/lib/ruby_mapnik.rb +48 -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 +27 -0
- data/test/test_line_pattern_symbolizer.rb +26 -0
- data/test/test_mapnik_color.rb +66 -0
- data/test/test_mapnik_coord.rb +112 -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 +33 -0
- data/test/test_mapnik_font_engine.rb +13 -0
- data/test/test_mapnik_geometry.rb +72 -0
- data/test/test_mapnik_glyph_symbolizer.rb +96 -0
- data/test/test_mapnik_layer.rb +137 -0
- data/test/test_mapnik_line_symbolizer.rb +25 -0
- data/test/test_mapnik_map.rb +191 -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 +40 -0
- data/test/test_mapnik_rule.rb +63 -0
- data/test/test_mapnik_shield_symbolizer.rb +193 -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 +232 -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 +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_ENVELOPE
|
|
23
|
+
#define PIKA2_MAPNIK_ENVELOPE
|
|
24
|
+
|
|
25
|
+
namespace Rice
|
|
26
|
+
{
|
|
27
|
+
class Module;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
void register_envelope(Rice::Module rb_mapnik);
|
|
31
|
+
|
|
32
|
+
#endif
|
|
@@ -0,0 +1,91 @@
|
|
|
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_expression.rb.h"
|
|
23
|
+
|
|
24
|
+
// Rice
|
|
25
|
+
#include <rice/Data_Type.hpp>
|
|
26
|
+
#include <rice/Constructor.hpp>
|
|
27
|
+
#include <rice/Class.hpp>
|
|
28
|
+
#include <rice/Enum.hpp>
|
|
29
|
+
|
|
30
|
+
// Mapnik
|
|
31
|
+
#include <mapnik/feature.hpp>
|
|
32
|
+
#include <mapnik/filter_factory.hpp>
|
|
33
|
+
#include <mapnik/expression_node.hpp>
|
|
34
|
+
#include <mapnik/expression_string.hpp>
|
|
35
|
+
#include <mapnik/expression_evaluator.hpp>
|
|
36
|
+
#include <mapnik/parse_path.hpp>
|
|
37
|
+
|
|
38
|
+
namespace {
|
|
39
|
+
boost::shared_ptr<mapnik::expr_node> parse_expression_(std::string const& wkt){
|
|
40
|
+
return mapnik::parse_expression(wkt,"utf8");
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
std::string expr_node_to_string_(boost::shared_ptr<mapnik::expr_node> node_ptr){
|
|
44
|
+
return mapnik::to_expression_string(*node_ptr);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// path expression
|
|
48
|
+
mapnik::path_expression_ptr parse_path_(std::string const& path){
|
|
49
|
+
return mapnik::parse_path(path);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
void register_expression(Rice::Module rb_mapnik){
|
|
54
|
+
/*
|
|
55
|
+
@@Module_var rb_mapnik = Mapnik
|
|
56
|
+
*/
|
|
57
|
+
Rice::Data_Type< boost::shared_ptr<mapnik::expr_node> > rb_cexpression = Rice::define_class_under< boost::shared_ptr<mapnik::expr_node> >(rb_mapnik, "Expression");
|
|
58
|
+
|
|
59
|
+
/*
|
|
60
|
+
* Document-method: parse
|
|
61
|
+
* call-seq:
|
|
62
|
+
* parse(expression_string)
|
|
63
|
+
*
|
|
64
|
+
* @param [String]
|
|
65
|
+
*
|
|
66
|
+
* @return [Mapnk::Expression] a new expression
|
|
67
|
+
*/
|
|
68
|
+
rb_cexpression.define_singleton_method("parse", &parse_expression_);
|
|
69
|
+
|
|
70
|
+
/*
|
|
71
|
+
* Document-method: to_s
|
|
72
|
+
* @return [String] a string representation of the expression
|
|
73
|
+
*/
|
|
74
|
+
rb_cexpression.define_method("to_s",&expr_node_to_string_);
|
|
75
|
+
|
|
76
|
+
Rice::Data_Type< mapnik::path_expression_ptr > rb_cpath_expression = Rice::define_class_under< mapnik::path_expression_ptr >(rb_mapnik, "PathExpression");
|
|
77
|
+
// rb_cpath_expression.define_singleton_method("evaluate", &path_evaluate_);
|
|
78
|
+
// rb_cpath_expression.define_method("to_s",&path_to_string_);
|
|
79
|
+
|
|
80
|
+
/*
|
|
81
|
+
* Document-method: parse
|
|
82
|
+
* call-seq:
|
|
83
|
+
* parse(path_expression_string)
|
|
84
|
+
*
|
|
85
|
+
* @param [String]
|
|
86
|
+
*
|
|
87
|
+
* @return [Mapnk::PathExpression] a new expression
|
|
88
|
+
*/
|
|
89
|
+
rb_cpath_expression.define_singleton_method("parse", &parse_path_);
|
|
90
|
+
|
|
91
|
+
}
|
|
@@ -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_EXPRESSION
|
|
23
|
+
#define PIKA2_MAPNIK_EXPRESSION
|
|
24
|
+
|
|
25
|
+
namespace Rice
|
|
26
|
+
{
|
|
27
|
+
class Module;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
void register_expression(Rice::Module rb_mapnik);
|
|
31
|
+
|
|
32
|
+
#endif
|
|
@@ -0,0 +1,56 @@
|
|
|
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_feature.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/wkt/wkt_factory.hpp>
|
|
31
|
+
#include <mapnik/feature.hpp>
|
|
32
|
+
|
|
33
|
+
// A cop out of sorts. I'll need to do more research on how to transfer ownership
|
|
34
|
+
// via rice.
|
|
35
|
+
void add_geometry(mapnik::Feature * self, std::string wkt){
|
|
36
|
+
std::pair<bool,mapnik::geometry_type*> result = mapnik::from_wkt(wkt);
|
|
37
|
+
if (result.first){
|
|
38
|
+
self->add_geometry(result.second);
|
|
39
|
+
} else {
|
|
40
|
+
throw std::runtime_error("Failed to parse WKT");
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
void register_feature(Rice::Module rb_mapnik){
|
|
45
|
+
/*
|
|
46
|
+
@@Module_var rb_mapnik = Mapnik
|
|
47
|
+
*/
|
|
48
|
+
Rice::Data_Type< mapnik::Feature > rb_cfeature = Rice::define_class_under< mapnik::Feature >(rb_mapnik, "Feature");
|
|
49
|
+
rb_cfeature.define_constructor(Rice::Constructor< mapnik::Feature,int >());
|
|
50
|
+
rb_cfeature.define_method("id", &mapnik::Feature::id);
|
|
51
|
+
rb_cfeature.define_method("to_s", &mapnik::Feature::to_string);
|
|
52
|
+
rb_cfeature.define_method("number_of_geometries", &mapnik::Feature::num_geometries);
|
|
53
|
+
rb_cfeature.define_method("envelope", &mapnik::Feature::envelope);
|
|
54
|
+
|
|
55
|
+
rb_cfeature.define_method("add_geometry", &add_geometry, Rice::Arg("geom"));
|
|
56
|
+
}
|
|
@@ -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_FEATURE
|
|
23
|
+
#define PIKA2_MAPNIK_FEATURE
|
|
24
|
+
|
|
25
|
+
namespace Rice
|
|
26
|
+
{
|
|
27
|
+
class Module;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
void register_feature(Rice::Module rb_mapnik);
|
|
31
|
+
|
|
32
|
+
#endif
|
|
@@ -0,0 +1,71 @@
|
|
|
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_font_engine.rb.h"
|
|
23
|
+
|
|
24
|
+
// Rice
|
|
25
|
+
#include <rice/Data_Type.hpp>
|
|
26
|
+
#include <rice/Constructor.hpp>
|
|
27
|
+
#include <rice/Class.hpp>
|
|
28
|
+
#include <rice/Enum.hpp>
|
|
29
|
+
|
|
30
|
+
// Mapnik
|
|
31
|
+
#include <mapnik/font_engine_freetype.hpp>
|
|
32
|
+
|
|
33
|
+
namespace {
|
|
34
|
+
|
|
35
|
+
Rice::Object get_font_face_names(){
|
|
36
|
+
Rice::Array out;
|
|
37
|
+
std::vector<std::string> const& names = mapnik::freetype_engine::face_names();
|
|
38
|
+
std::vector<std::string>::const_iterator end = names.end();
|
|
39
|
+
for (std::vector<std::string>::const_iterator it = names.begin(); it != end; ++it){
|
|
40
|
+
out.push(to_ruby<std::string>(*it));
|
|
41
|
+
}
|
|
42
|
+
return out;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
void register_font_name(std::string font_name){
|
|
46
|
+
mapnik::freetype_engine::register_font(font_name);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
void register_font_engine(Rice::Module rb_mapnik){
|
|
52
|
+
/*
|
|
53
|
+
@@Module_var rb_mapnik = Mapnik
|
|
54
|
+
*/
|
|
55
|
+
Rice::Data_Type< mapnik::freetype_engine > rb_cfont_engine = Rice::define_class_under< mapnik::freetype_engine >(rb_mapnik, "FontEngine");
|
|
56
|
+
|
|
57
|
+
/*
|
|
58
|
+
* Document-method: register_font
|
|
59
|
+
* call-seq:
|
|
60
|
+
* register_font(font_name)
|
|
61
|
+
* Registers a font with the FontEngine
|
|
62
|
+
* @return [nil]
|
|
63
|
+
*/
|
|
64
|
+
rb_cfont_engine.define_singleton_method("register_font", ®ister_font_name);
|
|
65
|
+
|
|
66
|
+
/*
|
|
67
|
+
* Document-method: face_names
|
|
68
|
+
* @return [Array] Names of the fonts that have been registered
|
|
69
|
+
*/
|
|
70
|
+
rb_cfont_engine.define_singleton_method("face_names", &get_font_face_names);
|
|
71
|
+
}
|
|
@@ -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_FONT_ENGINE
|
|
23
|
+
#define PIKA2_MAPNIK_FONT_ENGINE
|
|
24
|
+
|
|
25
|
+
namespace Rice
|
|
26
|
+
{
|
|
27
|
+
class Module;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
void register_font_engine(Rice::Module rb_mapnik);
|
|
31
|
+
|
|
32
|
+
#endif
|
|
@@ -0,0 +1,73 @@
|
|
|
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_geometry.rb.h>
|
|
23
|
+
|
|
24
|
+
// Rice
|
|
25
|
+
#include <rice/Data_Type.hpp>
|
|
26
|
+
#include <rice/Constructor.hpp>
|
|
27
|
+
#include <rice/Class.hpp>
|
|
28
|
+
#include <rice/Enum.hpp>
|
|
29
|
+
|
|
30
|
+
// Mapnik
|
|
31
|
+
#include <mapnik/geometry.hpp>
|
|
32
|
+
#include <mapnik/wkt/wkt_factory.hpp>
|
|
33
|
+
|
|
34
|
+
namespace{
|
|
35
|
+
// Borrowed from the python bindings...
|
|
36
|
+
mapnik::geometry_type * make_from_wkt(std::string const& wkt) {
|
|
37
|
+
std::pair<bool,mapnik::geometry_type*> result = mapnik::from_wkt(wkt);
|
|
38
|
+
if (result.first){
|
|
39
|
+
return result.second;
|
|
40
|
+
}
|
|
41
|
+
throw std::runtime_error("Failed to parse WKT");
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
Rice::Enum<mapnik::eGeomType> geometry_enum;
|
|
47
|
+
|
|
48
|
+
template<>
|
|
49
|
+
mapnik::eGeomType from_ruby<mapnik::eGeomType>(Rice::Object x) {
|
|
50
|
+
Rice::Data_Object<mapnik::eGeomType> d(x, geometry_enum);
|
|
51
|
+
return *d;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
void register_geometry(Rice::Module rb_mapnik){
|
|
56
|
+
/*
|
|
57
|
+
@@Module_var rb_mapnik = Mapnik
|
|
58
|
+
*/
|
|
59
|
+
geometry_enum = Rice::define_enum<mapnik::eGeomType>("GeometryType", rb_mapnik);
|
|
60
|
+
geometry_enum.define_value("Point",mapnik::Point);
|
|
61
|
+
geometry_enum.define_value("LineString",mapnik::LineString);
|
|
62
|
+
geometry_enum.define_value("Polygon",mapnik::Polygon);
|
|
63
|
+
geometry_enum.define_value("MultiPoint",mapnik::MultiPoint);
|
|
64
|
+
geometry_enum.define_value("MultiLineString",mapnik::MultiLineString);
|
|
65
|
+
geometry_enum.define_value("MultiPolygon",mapnik::MultiPolygon);
|
|
66
|
+
|
|
67
|
+
Rice::Data_Type< mapnik::geometry_type > rb_cgeometry2d = Rice::define_class_under< mapnik::geometry_type >(rb_mapnik, "Geometry2d");
|
|
68
|
+
rb_cgeometry2d.define_singleton_method("from_wkt", &make_from_wkt, Rice::Arg("wkt"));
|
|
69
|
+
rb_cgeometry2d.define_method("envelope", &mapnik::geometry_type::envelope);
|
|
70
|
+
rb_cgeometry2d.define_method("type", &mapnik::geometry_type::type);
|
|
71
|
+
rb_cgeometry2d.define_method("area", &mapnik::geometry_type::area);
|
|
72
|
+
}
|
|
73
|
+
|
|
@@ -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_GEOMETRY
|
|
23
|
+
#define PIKA2_MAPNIK_GEOMETRY
|
|
24
|
+
|
|
25
|
+
namespace Rice
|
|
26
|
+
{
|
|
27
|
+
class Module;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
void register_geometry(Rice::Module rb_mapnik);
|
|
31
|
+
|
|
32
|
+
#endif
|