ruby_mapnik 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -0
- data/Manifest.txt +0 -3
- data/Rakefile +1 -1
- data/ext/ruby_mapnik/_mapnik.cpp +0 -1
- data/ext/ruby_mapnik/_mapnik.h +0 -1
- data/ext/ruby_mapnik/_mapnik_feature.rb.cpp +13 -4
- data/ext/ruby_mapnik/_mapnik_layer.rb.cpp +9 -9
- data/ext/ruby_mapnik/_mapnik_map.rb.cpp +11 -3
- data/lib/ruby_mapnik.rb +1 -1
- data/lib/ruby_mapnik/mapnik/font_engine.rb +1 -1
- data/lib/ruby_mapnik/mapnik/map.rb +8 -3
- data/lib/ruby_mapnik/mapnik/tile.rb +2 -2
- data/test/test_helper.rb +1 -1
- data/test/test_mapnik_coord.rb +15 -35
- data/test/test_mapnik_map.rb +12 -1
- metadata +58 -94
- data/ext/ruby_mapnik/_mapnik_geometry.rb.cpp +0 -82
- data/ext/ruby_mapnik/_mapnik_geometry.rb.h +0 -32
- data/test/test_mapnik_geometry.rb +0 -84
data/Gemfile
CHANGED
data/Manifest.txt
CHANGED
@@ -89,8 +89,6 @@ ext/ruby_mapnik/_mapnik_feature.rb.cpp
|
|
89
89
|
ext/ruby_mapnik/_mapnik_feature.rb.h
|
90
90
|
ext/ruby_mapnik/_mapnik_font_engine.rb.cpp
|
91
91
|
ext/ruby_mapnik/_mapnik_font_engine.rb.h
|
92
|
-
ext/ruby_mapnik/_mapnik_geometry.rb.cpp
|
93
|
-
ext/ruby_mapnik/_mapnik_geometry.rb.h
|
94
92
|
ext/ruby_mapnik/_mapnik_layer.rb.cpp
|
95
93
|
ext/ruby_mapnik/_mapnik_layer.rb.h
|
96
94
|
ext/ruby_mapnik/_mapnik_line_pattern_symbolizer.rb.cpp
|
@@ -152,7 +150,6 @@ test/test_mapnik_envelope.rb
|
|
152
150
|
test/test_mapnik_expression.rb
|
153
151
|
test/test_mapnik_feature.rb
|
154
152
|
test/test_mapnik_font_engine.rb
|
155
|
-
test/test_mapnik_geometry.rb
|
156
153
|
test/test_mapnik_layer.rb
|
157
154
|
test/test_mapnik_line_symbolizer.rb
|
158
155
|
test/test_mapnik_map.rb
|
data/Rakefile
CHANGED
@@ -31,7 +31,7 @@ Hoe.spec 'ruby_mapnik' do
|
|
31
31
|
self.history_file = 'History.txt'
|
32
32
|
self.extra_deps << ['rice', '>= 1.4.2']
|
33
33
|
self.extra_dev_deps << ['rake-compiler', '>= 0']
|
34
|
-
|
34
|
+
self.extra_dev_deps << ['chunky_png', '>= 0']
|
35
35
|
|
36
36
|
self.spec_extras = { :extensions => ["ext/ruby_mapnik/extconf.rb"] }
|
37
37
|
|
data/ext/ruby_mapnik/_mapnik.cpp
CHANGED
@@ -30,7 +30,6 @@ void register_mapnik(){
|
|
30
30
|
register_datasource_cache(rb_mapnik);
|
31
31
|
register_envelope(rb_mapnik);
|
32
32
|
register_feature(rb_mapnik);
|
33
|
-
register_geometry(rb_mapnik);
|
34
33
|
register_polygon_symbolizer(rb_mapnik);
|
35
34
|
register_line_symbolizer(rb_mapnik);
|
36
35
|
register_stroke(rb_mapnik);
|
data/ext/ruby_mapnik/_mapnik.h
CHANGED
@@ -40,22 +40,31 @@ namespace {
|
|
40
40
|
}
|
41
41
|
|
42
42
|
class context_holder {
|
43
|
+
private:
|
44
|
+
mapnik::context_ptr ptr;
|
43
45
|
public:
|
44
|
-
|
45
|
-
context_holder()
|
46
|
-
ptr
|
46
|
+
|
47
|
+
context_holder()
|
48
|
+
: ptr (boost::make_shared<mapnik::context_type>())
|
49
|
+
{
|
50
|
+
return;
|
47
51
|
}
|
48
52
|
|
49
53
|
int push(std::string const& str){
|
50
54
|
return ptr->push(str);
|
51
55
|
}
|
56
|
+
|
57
|
+
mapnik::context_ptr get_ptr(){
|
58
|
+
return ptr;
|
59
|
+
}
|
60
|
+
|
52
61
|
};
|
53
62
|
|
54
63
|
}
|
55
64
|
template<>
|
56
65
|
mapnik::context_ptr from_ruby<mapnik::context_ptr>(Rice::Object ruby_obj){
|
57
66
|
context_holder ctx = from_ruby<context_holder>(ruby_obj);
|
58
|
-
return ctx.
|
67
|
+
return ctx.get_ptr();
|
59
68
|
}
|
60
69
|
|
61
70
|
void register_feature(Rice::Module rb_mapnik){
|
@@ -109,7 +109,7 @@ void register_layer(Rice::Module rb_mapnik){
|
|
109
109
|
* Document-method: min_zoom
|
110
110
|
* @return [Integer] the layer's minimum zoom factor
|
111
111
|
*/
|
112
|
-
rb_clayer.define_method("min_zoom", &mapnik::layer::
|
112
|
+
rb_clayer.define_method("min_zoom", &mapnik::layer::min_zoom);
|
113
113
|
|
114
114
|
/*
|
115
115
|
* Document-method: min_zoom=
|
@@ -117,13 +117,13 @@ void register_layer(Rice::Module rb_mapnik){
|
|
117
117
|
* min_zoom=(min_zoom)
|
118
118
|
* @return [nil]
|
119
119
|
*/
|
120
|
-
rb_clayer.define_method("min_zoom=", &mapnik::layer::
|
120
|
+
rb_clayer.define_method("min_zoom=", &mapnik::layer::set_min_zoom, Rice::Arg("new_min_zoom"));
|
121
121
|
|
122
122
|
/*
|
123
123
|
* Document-method: max_zoom
|
124
124
|
* @return [Integer] the layer's maximum zoom factor
|
125
125
|
*/
|
126
|
-
rb_clayer.define_method("max_zoom", &mapnik::layer::
|
126
|
+
rb_clayer.define_method("max_zoom", &mapnik::layer::max_zoom);
|
127
127
|
|
128
128
|
|
129
129
|
/*
|
@@ -132,19 +132,19 @@ void register_layer(Rice::Module rb_mapnik){
|
|
132
132
|
* min_zoom=(min_zoom)
|
133
133
|
* @return [nil]
|
134
134
|
*/
|
135
|
-
rb_clayer.define_method("max_zoom=", &mapnik::layer::
|
135
|
+
rb_clayer.define_method("max_zoom=", &mapnik::layer::set_max_zoom, Rice::Arg("new_max_zoom"));
|
136
136
|
|
137
137
|
/*
|
138
138
|
* Document-method: visible_at_scale?
|
139
139
|
* @return [Boolean]
|
140
140
|
*/
|
141
|
-
rb_clayer.define_method("visible_at_scale?", &mapnik::layer::
|
141
|
+
rb_clayer.define_method("visible_at_scale?", &mapnik::layer::visible, Rice::Arg("scale"));
|
142
142
|
|
143
143
|
/*
|
144
144
|
* Document-method: active?
|
145
145
|
* @return [Boolean]
|
146
146
|
*/
|
147
|
-
rb_clayer.define_method("active?", &mapnik::layer::
|
147
|
+
rb_clayer.define_method("active?", &mapnik::layer::active);
|
148
148
|
|
149
149
|
/*
|
150
150
|
* Document-method: active=
|
@@ -152,13 +152,13 @@ void register_layer(Rice::Module rb_mapnik){
|
|
152
152
|
* active=(new_active_value)
|
153
153
|
* @return [nil]
|
154
154
|
*/
|
155
|
-
rb_clayer.define_method("active=", &mapnik::layer::
|
155
|
+
rb_clayer.define_method("active=", &mapnik::layer::set_active, Rice::Arg("new_active_value"));
|
156
156
|
|
157
157
|
/*
|
158
158
|
* Document-method: queryable?
|
159
159
|
* @return [Boolean]
|
160
160
|
*/
|
161
|
-
rb_clayer.define_method("queryable?", &mapnik::layer::
|
161
|
+
rb_clayer.define_method("queryable?", &mapnik::layer::queryable);
|
162
162
|
|
163
163
|
/*
|
164
164
|
* Document-method: queryable=
|
@@ -166,7 +166,7 @@ void register_layer(Rice::Module rb_mapnik){
|
|
166
166
|
* queryable=(new_queryable_value)
|
167
167
|
* @return [nil]
|
168
168
|
*/
|
169
|
-
rb_clayer.define_method("queryable=", &mapnik::layer::
|
169
|
+
rb_clayer.define_method("queryable=", &mapnik::layer::set_queryable, Rice::Arg("new_queryable_value"));
|
170
170
|
|
171
171
|
/*
|
172
172
|
* Document-method: cache_features?
|
@@ -82,8 +82,7 @@ std::vector<mapnik::layer> & (mapnik::Map::*_map_layers_)() = &mapnik::Map::laye
|
|
82
82
|
|
83
83
|
namespace {
|
84
84
|
|
85
|
-
void
|
86
|
-
std::string format = mapnik::guess_type(filename);
|
85
|
+
void render_map_to_file_with_format(const mapnik::Map& map, const std::string& filename, const std::string& format){
|
87
86
|
if (format == "pdf" || format == "svg" || format =="ps") {
|
88
87
|
#if defined(HAVE_CAIRO)
|
89
88
|
mapnik::save_to_cairo_file(map,filename,format);
|
@@ -94,10 +93,14 @@ namespace {
|
|
94
93
|
mapnik::image_32 image(map.width(),map.height());
|
95
94
|
mapnik::agg_renderer<mapnik::image_32> ren(map,image,1.0,0,0);
|
96
95
|
ren.apply();
|
97
|
-
mapnik::save_to_file(image,filename);
|
96
|
+
mapnik::save_to_file(image,filename, format);
|
98
97
|
}
|
99
98
|
}
|
100
99
|
|
100
|
+
void render_map_to_file(const mapnik::Map& map, const std::string& filename){
|
101
|
+
render_map_to_file_with_format(map, filename, mapnik::guess_type(filename));
|
102
|
+
}
|
103
|
+
|
101
104
|
std::string render_map_to_string(const mapnik::Map& map, std::string const& format){
|
102
105
|
mapnik::image_32 image(map.width(),map.height());
|
103
106
|
mapnik::agg_renderer<mapnik::image_32> ren(map,image,1.0,0,0);
|
@@ -417,6 +420,11 @@ void register_map(Rice::Module rb_mapnik){
|
|
417
420
|
*/
|
418
421
|
rb_cmap.define_method("__render_to_file__", &render_map_to_file);
|
419
422
|
|
423
|
+
/*
|
424
|
+
* Dont-Document-method: __render_to_file_with_format__
|
425
|
+
*/
|
426
|
+
rb_cmap.define_method("__render_to_file_with_format__", &render_map_to_file_with_format);
|
427
|
+
|
420
428
|
/*
|
421
429
|
* Document-method: to_xml
|
422
430
|
* @return [String]
|
data/lib/ruby_mapnik.rb
CHANGED
@@ -26,7 +26,7 @@ module Mapnik
|
|
26
26
|
DEFAULT_VALID_EXTENSIONS = ['ttf','otf','ttc','pfa','pfb','ttc','dfont']
|
27
27
|
|
28
28
|
def self.register_fonts(path, valid_extensions = DEFAULT_VALID_EXTENSIONS)
|
29
|
-
file_names = Dir.glob(File.join("#{path}", "*.{#{valid_extensions.join(',')}}"))
|
29
|
+
file_names = Dir.glob(File.join("#{path}", "**", "*.{#{valid_extensions.join(',')}}"))
|
30
30
|
file_names.each{|filename| register_font(filename)}
|
31
31
|
end
|
32
32
|
|
@@ -149,10 +149,15 @@ module Mapnik
|
|
149
149
|
|
150
150
|
# Renders the map to a file. Returns true or false depending if the
|
151
151
|
# render was successful. The image type is inferred from the filename.
|
152
|
-
# @param [String] filename Should end in one of "png", "jpg", or "tiff"
|
152
|
+
# @param [String] filename Should end in one of "png", "jpg", or "tiff" if format not specified
|
153
|
+
# @param [String] format Should be one of formats supported by Mapnik or nil (to be guessed from filename)
|
153
154
|
# @return [Boolean]
|
154
|
-
def render_to_file(filename)
|
155
|
-
|
155
|
+
def render_to_file(filename, format = nil)
|
156
|
+
if format
|
157
|
+
__render_to_file_with_format__(filename, format)
|
158
|
+
else
|
159
|
+
__render_to_file__(filename)
|
160
|
+
end
|
156
161
|
return File.exists?(filename)
|
157
162
|
end
|
158
163
|
|
@@ -44,11 +44,11 @@ module Mapnik
|
|
44
44
|
setup_bounds
|
45
45
|
end
|
46
46
|
|
47
|
-
def render(map, filename)
|
47
|
+
def render(map, filename, format=nil)
|
48
48
|
map.height = @height
|
49
49
|
map.width = @width
|
50
50
|
map.zoom_to_box(forwarded_envelope)
|
51
|
-
map.render_to_file(filename)
|
51
|
+
map.render_to_file(filename, format)
|
52
52
|
end
|
53
53
|
|
54
54
|
def render_to_string(map)
|
data/test/test_helper.rb
CHANGED
@@ -25,5 +25,5 @@ CURRENT_PATH = File.expand_path(File.dirname(__FILE__))
|
|
25
25
|
require File.join(CURRENT_PATH, '..', 'lib', 'ruby_mapnik')
|
26
26
|
|
27
27
|
unless defined?(SHAPEFILE)
|
28
|
-
SHAPEFILE =
|
28
|
+
SHAPEFILE = File.join(CURRENT_PATH, 'data', 'TM_WORLD_BORDERS_SIMPL_0.3_MOD')
|
29
29
|
end
|
data/test/test_mapnik_coord.rb
CHANGED
@@ -58,55 +58,35 @@ class TestMapnikCoord < Test::Unit::TestCase
|
|
58
58
|
|
59
59
|
# These could be refactored, I suppose...
|
60
60
|
def test_should_return_a_new_coord_when_multiplied_by_a_number
|
61
|
-
|
62
|
-
start_y = 2
|
63
|
-
factor = 3
|
64
|
-
coord2d = Mapnik::Coord2d.new(start_x, start_y)
|
65
|
-
multiplied_coord = coord2d * factor
|
66
|
-
assert_not_equal(coord2d.object_id, multiplied_coord.object_id)
|
67
|
-
assert_equal(coord2d.x * factor, multiplied_coord.x)
|
68
|
-
assert_equal(coord2d.y * factor, multiplied_coord.y)
|
69
|
-
assert_equal(coord2d.x, start_x)
|
70
|
-
assert_equal(coord2d.y, start_y)
|
61
|
+
coord_check_with_operator(:*)
|
71
62
|
end
|
72
63
|
|
73
64
|
def test_should_return_a_new_coord_when_added_to_by_a_number
|
74
|
-
|
75
|
-
start_y = 2
|
76
|
-
factor = 3
|
77
|
-
coord2d = Mapnik::Coord2d.new(start_x, start_y)
|
78
|
-
added_coord = coord2d + factor
|
79
|
-
assert_not_equal(coord2d.object_id, added_coord.object_id)
|
80
|
-
assert_equal(coord2d.x + factor, added_coord.x)
|
81
|
-
assert_equal(coord2d.y + factor, added_coord.y)
|
82
|
-
assert_equal(coord2d.x, start_x)
|
83
|
-
assert_equal(coord2d.y, start_y)
|
65
|
+
coord_check_with_operator(:+)
|
84
66
|
end
|
85
67
|
|
86
68
|
def test_should_return_a_new_coord_when_subtracted_from_by_a_number
|
87
|
-
|
88
|
-
start_y = 2
|
89
|
-
factor = 3
|
90
|
-
coord2d = Mapnik::Coord2d.new(start_x, start_y)
|
91
|
-
subtracted_coord = coord2d - factor
|
92
|
-
assert_not_equal(coord2d.object_id, subtracted_coord.object_id)
|
93
|
-
assert_equal(coord2d.x - factor, subtracted_coord.x)
|
94
|
-
assert_equal(coord2d.y - factor, subtracted_coord.y)
|
95
|
-
assert_equal(coord2d.x, start_x)
|
96
|
-
assert_equal(coord2d.y, start_y)
|
69
|
+
coord_check_with_operator(:-)
|
97
70
|
end
|
98
71
|
|
99
72
|
def test_should_return_a_new_coord_when_divided_by_a_number
|
73
|
+
coord_check_with_operator(:/)
|
74
|
+
end
|
75
|
+
|
76
|
+
private
|
77
|
+
|
78
|
+
def coord_check_with_operator(operator)
|
100
79
|
start_x = 1
|
101
80
|
start_y = 2
|
102
81
|
factor = 3
|
103
82
|
coord2d = Mapnik::Coord2d.new(start_x, start_y)
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
assert_equal(coord2d.
|
83
|
+
updated_coord = coord2d.send(operator, factor)
|
84
|
+
|
85
|
+
assert_not_equal(coord2d.object_id, updated_coord.object_id)
|
86
|
+
assert_equal(coord2d.x.send(operator, factor), updated_coord.x)
|
87
|
+
assert_equal(coord2d.y.send(operator, factor), updated_coord.y)
|
108
88
|
assert_equal(coord2d.x, start_x)
|
109
89
|
assert_equal(coord2d.y, start_y)
|
110
90
|
end
|
111
|
-
|
91
|
+
|
112
92
|
end
|
data/test/test_mapnik_map.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "test_helper"
|
2
|
+
require "chunky_png"
|
2
3
|
|
3
4
|
class TestMapnikMap < Test::Unit::TestCase
|
4
5
|
|
@@ -151,7 +152,17 @@ class TestMapnikMap < Test::Unit::TestCase
|
|
151
152
|
assert File.exists?(filename)
|
152
153
|
File.delete(filename)
|
153
154
|
end
|
154
|
-
|
155
|
+
|
156
|
+
def test_should_render_to_file_with_explicit_format
|
157
|
+
map = build_complete_map
|
158
|
+
filename = File.join(File.expand_path(File.dirname(__FILE__)), "../tmp/world-256.png")
|
159
|
+
assert_equal 0, File.size(filename) if File.exists?(filename)
|
160
|
+
assert map.render_to_file(filename, "png256")
|
161
|
+
assert File.exists?(filename)
|
162
|
+
assert_not_nil ChunkyPNG::Datastream.from_file(filename).palette_chunk
|
163
|
+
File.delete(filename)
|
164
|
+
end
|
165
|
+
|
155
166
|
def test_should_load_from_xml_string
|
156
167
|
map_1 = build_complete_map
|
157
168
|
map_2 = Mapnik::Map.from_xml(map_1.to_xml)
|
metadata
CHANGED
@@ -1,98 +1,74 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_mapnik
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.4
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
- 3
|
10
|
-
version: 0.1.3
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Elliot Laster
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-03-27 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: rice
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &2166805120 !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
hash: 3
|
29
|
-
segments:
|
30
|
-
- 1
|
31
|
-
- 4
|
32
|
-
- 2
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
33
21
|
version: 1.4.2
|
34
22
|
type: :runtime
|
35
|
-
version_requirements: *id001
|
36
|
-
- !ruby/object:Gem::Dependency
|
37
|
-
name: rake-compiler
|
38
23
|
prerelease: false
|
39
|
-
|
24
|
+
version_requirements: *2166805120
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rake-compiler
|
27
|
+
requirement: &2166804600 !ruby/object:Gem::Requirement
|
40
28
|
none: false
|
41
|
-
requirements:
|
42
|
-
- -
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
|
45
|
-
segments:
|
46
|
-
- 0
|
47
|
-
version: "0"
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
48
33
|
type: :development
|
49
|
-
version_requirements: *id002
|
50
|
-
- !ruby/object:Gem::Dependency
|
51
|
-
name: rdoc
|
52
34
|
prerelease: false
|
53
|
-
|
35
|
+
version_requirements: *2166804600
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: chunky_png
|
38
|
+
requirement: &2166803860 !ruby/object:Gem::Requirement
|
54
39
|
none: false
|
55
|
-
requirements:
|
56
|
-
- -
|
57
|
-
- !ruby/object:Gem::Version
|
58
|
-
|
59
|
-
segments:
|
60
|
-
- 3
|
61
|
-
- 10
|
62
|
-
version: "3.10"
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
63
44
|
type: :development
|
64
|
-
version_requirements: *id003
|
65
|
-
- !ruby/object:Gem::Dependency
|
66
|
-
name: hoe
|
67
45
|
prerelease: false
|
68
|
-
|
46
|
+
version_requirements: *2166803860
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: hoe
|
49
|
+
requirement: &2166800680 !ruby/object:Gem::Requirement
|
69
50
|
none: false
|
70
|
-
requirements:
|
51
|
+
requirements:
|
71
52
|
- - ~>
|
72
|
-
- !ruby/object:Gem::Version
|
73
|
-
|
74
|
-
segments:
|
75
|
-
- 2
|
76
|
-
- 13
|
77
|
-
version: "2.13"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.12'
|
78
55
|
type: :development
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
email:
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *2166800680
|
58
|
+
description: ! "A set of bindings between Ruby and Mapnik. Supports many of the common
|
59
|
+
uses for \nMapnik, and one day, might support all of them. Rendering is available
|
60
|
+
using\nthe standard AGG library, or additionally via Cairo, if the rcairo gem is
|
61
|
+
\ninstalled and Mapnik has been compiled with Cairo support."
|
62
|
+
email:
|
86
63
|
- elliotlaster@gmail.com
|
87
64
|
executables: []
|
88
|
-
|
89
|
-
extensions:
|
65
|
+
extensions:
|
90
66
|
- ext/ruby_mapnik/extconf.rb
|
91
|
-
extra_rdoc_files:
|
67
|
+
extra_rdoc_files:
|
92
68
|
- Manifest.txt
|
93
69
|
- demo/data/COPYRIGHT.txt
|
94
70
|
- demo/data/test/readme.txt
|
95
|
-
files:
|
71
|
+
files:
|
96
72
|
- .autotest
|
97
73
|
- .yardopts
|
98
74
|
- Gemfile
|
@@ -184,8 +160,6 @@ files:
|
|
184
160
|
- ext/ruby_mapnik/_mapnik_feature.rb.h
|
185
161
|
- ext/ruby_mapnik/_mapnik_font_engine.rb.cpp
|
186
162
|
- ext/ruby_mapnik/_mapnik_font_engine.rb.h
|
187
|
-
- ext/ruby_mapnik/_mapnik_geometry.rb.cpp
|
188
|
-
- ext/ruby_mapnik/_mapnik_geometry.rb.h
|
189
163
|
- ext/ruby_mapnik/_mapnik_layer.rb.cpp
|
190
164
|
- ext/ruby_mapnik/_mapnik_layer.rb.h
|
191
165
|
- ext/ruby_mapnik/_mapnik_line_pattern_symbolizer.rb.cpp
|
@@ -247,7 +221,6 @@ files:
|
|
247
221
|
- test/test_mapnik_expression.rb
|
248
222
|
- test/test_mapnik_feature.rb
|
249
223
|
- test/test_mapnik_font_engine.rb
|
250
|
-
- test/test_mapnik_geometry.rb
|
251
224
|
- test/test_mapnik_layer.rb
|
252
225
|
- test/test_mapnik_line_symbolizer.rb
|
253
226
|
- test/test_mapnik_map.rb
|
@@ -270,39 +243,31 @@ files:
|
|
270
243
|
- .gemtest
|
271
244
|
homepage: https://github.com/mapnik/Ruby-Mapnik
|
272
245
|
licenses: []
|
273
|
-
|
274
246
|
post_install_message:
|
275
|
-
rdoc_options:
|
247
|
+
rdoc_options:
|
276
248
|
- --main
|
277
249
|
- README.rdoc
|
278
|
-
require_paths:
|
250
|
+
require_paths:
|
279
251
|
- lib
|
280
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
252
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
281
253
|
none: false
|
282
|
-
requirements:
|
283
|
-
- -
|
284
|
-
- !ruby/object:Gem::Version
|
285
|
-
|
286
|
-
|
287
|
-
- 0
|
288
|
-
version: "0"
|
289
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
254
|
+
requirements:
|
255
|
+
- - ! '>='
|
256
|
+
- !ruby/object:Gem::Version
|
257
|
+
version: '0'
|
258
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
290
259
|
none: false
|
291
|
-
requirements:
|
292
|
-
- -
|
293
|
-
- !ruby/object:Gem::Version
|
294
|
-
|
295
|
-
segments:
|
296
|
-
- 0
|
297
|
-
version: "0"
|
260
|
+
requirements:
|
261
|
+
- - ! '>='
|
262
|
+
- !ruby/object:Gem::Version
|
263
|
+
version: '0'
|
298
264
|
requirements: []
|
299
|
-
|
300
265
|
rubyforge_project: ruby_mapnik
|
301
|
-
rubygems_version: 1.8.
|
266
|
+
rubygems_version: 1.8.10
|
302
267
|
signing_key:
|
303
268
|
specification_version: 3
|
304
269
|
summary: A set of bindings between Ruby and Mapnik
|
305
|
-
test_files:
|
270
|
+
test_files:
|
306
271
|
- test/test_helper.rb
|
307
272
|
- test/test_line_pattern_symbolizer.rb
|
308
273
|
- test/test_mapnik_color.rb
|
@@ -312,7 +277,6 @@ test_files:
|
|
312
277
|
- test/test_mapnik_expression.rb
|
313
278
|
- test/test_mapnik_feature.rb
|
314
279
|
- test/test_mapnik_font_engine.rb
|
315
|
-
- test/test_mapnik_geometry.rb
|
316
280
|
- test/test_mapnik_layer.rb
|
317
281
|
- test/test_mapnik_line_symbolizer.rb
|
318
282
|
- test/test_mapnik_map.rb
|
@@ -1,82 +0,0 @@
|
|
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
|
-
|
36
|
-
typedef boost::ptr_vector<mapnik::geometry_type> path_type;
|
37
|
-
|
38
|
-
// Borrowed from the python bindings...
|
39
|
-
void from_wkt_impl(path_type& p, std::string const& wkt)
|
40
|
-
{
|
41
|
-
bool result = mapnik::from_wkt(wkt, p);
|
42
|
-
if (!result) throw std::runtime_error("Failed to parse WKT");
|
43
|
-
}
|
44
|
-
|
45
|
-
/*
|
46
|
-
mapnik::geometry_type * from_wkt_impl(std::string const& wkt) {
|
47
|
-
std::pair<bool,mapnik::geometry_type*> result = mapnik::from_wkt(wkt);
|
48
|
-
if (result.first){
|
49
|
-
return result.second;
|
50
|
-
}
|
51
|
-
throw std::runtime_error("Failed to parse WKT");
|
52
|
-
}
|
53
|
-
*/
|
54
|
-
|
55
|
-
}
|
56
|
-
|
57
|
-
Rice::Enum<mapnik::eGeomType> geometry_enum;
|
58
|
-
|
59
|
-
template<>
|
60
|
-
mapnik::eGeomType from_ruby<mapnik::eGeomType>(Rice::Object x) {
|
61
|
-
Rice::Data_Object<mapnik::eGeomType> d(x, geometry_enum);
|
62
|
-
return *d;
|
63
|
-
}
|
64
|
-
|
65
|
-
|
66
|
-
void register_geometry(Rice::Module rb_mapnik){
|
67
|
-
/*
|
68
|
-
@@Module_var rb_mapnik = Mapnik
|
69
|
-
*/
|
70
|
-
geometry_enum = Rice::define_enum<mapnik::eGeomType>("GeometryType", rb_mapnik);
|
71
|
-
geometry_enum.define_value("Point",mapnik::Point);
|
72
|
-
geometry_enum.define_value("LineString",mapnik::LineString);
|
73
|
-
geometry_enum.define_value("Polygon",mapnik::Polygon);
|
74
|
-
|
75
|
-
Rice::Data_Type< mapnik::geometry_type > rb_cgeometry2d = Rice::define_class_under< mapnik::geometry_type >(rb_mapnik, "Geometry2d");
|
76
|
-
rb_cgeometry2d.define_method("envelope", &mapnik::geometry_type::envelope);
|
77
|
-
rb_cgeometry2d.define_method("type", &mapnik::geometry_type::type);
|
78
|
-
|
79
|
-
Rice::Data_Type< path_type > rb_cpath = Rice::define_class_under< path_type >(rb_mapnik, "Path");
|
80
|
-
rb_cpath.define_singleton_method("from_wkt", &from_wkt_impl, Rice::Arg("wkt"));
|
81
|
-
}
|
82
|
-
|
@@ -1,32 +0,0 @@
|
|
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
|
@@ -1,84 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
class TestMapnikGeometry < Test::Unit::TestCase
|
4
|
-
|
5
|
-
STATEMENT = "Geometry tests no longer valid. See https://github.com/mapnik/Ruby-Mapnik/issues/11"
|
6
|
-
|
7
|
-
def test_presence
|
8
|
-
assert Mapnik::GeometryType
|
9
|
-
assert Mapnik::Geometry2d
|
10
|
-
assert Mapnik::GeometryType::Point
|
11
|
-
assert Mapnik::GeometryType::LineString
|
12
|
-
assert Mapnik::GeometryType::Polygon
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_should_make_point_from_wkt
|
16
|
-
omit(STATEMENT)
|
17
|
-
# point = Mapnik::Geometry2d.from_wkt("POINT(30 10)")
|
18
|
-
# assert_equal Mapnik::GeometryType::Point, point.type
|
19
|
-
# assert_equal 30, point.envelope.min_x
|
20
|
-
# assert_equal 30, point.envelope.max_x
|
21
|
-
# assert_equal 10, point.envelope.max_y
|
22
|
-
# assert_equal 10, point.envelope.min_y
|
23
|
-
# assert_equal 0, point.area
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_should_make_linestring_from_wkt
|
27
|
-
omit(STATEMENT)
|
28
|
-
# linestring = Mapnik::Geometry2d.from_wkt("LINESTRING (29 11, 12 30, 41 40)")
|
29
|
-
# assert_equal Mapnik::GeometryType::LineString, linestring.type
|
30
|
-
# assert_equal 12, linestring.envelope.min_x
|
31
|
-
# assert_equal 41, linestring.envelope.max_x
|
32
|
-
# assert_equal 40, linestring.envelope.max_y
|
33
|
-
# assert_equal 11, linestring.envelope.min_y
|
34
|
-
# assert_equal 0, linestring.area -> Not sure what the correct value is here
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_should_make_polygon_from_wkt
|
38
|
-
omit(STATEMENT)
|
39
|
-
# polygon = Mapnik::Geometry2d.from_wkt("POLYGON ((30 10, 10 20, 20 40, 40 40, 30 10))")
|
40
|
-
# assert_equal Mapnik::GeometryType::Polygon, polygon.type
|
41
|
-
# assert_equal 10, polygon.envelope.min_x
|
42
|
-
# assert_equal 40, polygon.envelope.max_x
|
43
|
-
# assert_equal 40, polygon.envelope.max_y
|
44
|
-
# assert_equal 10, polygon.envelope.min_y
|
45
|
-
# assert_equal 0, polygon.area
|
46
|
-
end
|
47
|
-
|
48
|
-
def test_should_make_multipoint_from_wkt
|
49
|
-
omit(STATEMENT)
|
50
|
-
# multipoint = Mapnik::Geometry2d.from_wkt("MULTIPOINT (10 40, 40 30, 20 20, 30 10)")
|
51
|
-
# assert_equal Mapnik::GeometryType::MultiPoint, multipoint.type
|
52
|
-
# assert_equal 10, multipoint.envelope.min_x
|
53
|
-
# assert_equal 40, multipoint.envelope.max_x
|
54
|
-
# assert_equal 40, multipoint.envelope.max_y
|
55
|
-
# assert_equal 10, multipoint.envelope.min_y
|
56
|
-
end
|
57
|
-
|
58
|
-
def test_should_make_multilinestring_from_wkt
|
59
|
-
omit(STATEMENT)
|
60
|
-
# multi_line = Mapnik::Geometry2d.from_wkt("MULTILINESTRING ((10 10, 20 20, 10 40), (40 40, 30 30, 40 20, 30 10))")
|
61
|
-
# assert_equal Mapnik::GeometryType::MultiLineString, multi_line.type
|
62
|
-
# assert_equal 10, multi_line.envelope.min_x
|
63
|
-
# assert_equal 40, multi_line.envelope.max_x
|
64
|
-
# assert_equal 40, multi_line.envelope.max_y
|
65
|
-
# assert_equal 10, multi_line.envelope.min_y
|
66
|
-
end
|
67
|
-
|
68
|
-
def test_should_make_multipolygon_from_wkt
|
69
|
-
omit(STATEMENT)
|
70
|
-
# multi_polygon = Mapnik::Geometry2d.from_wkt("MULTIPOLYGON (((30 20, 10 40, 45 40, 30 20)), ((15 5, 40 10, 10 20, 5 10, 15 5)))")
|
71
|
-
# assert_equal Mapnik::GeometryType::MultiPolygon, multi_polygon.type
|
72
|
-
# assert_equal 5, multi_polygon.envelope.min_x
|
73
|
-
# assert_equal 45, multi_polygon.envelope.max_x
|
74
|
-
# assert_equal 40, multi_polygon.envelope.max_y
|
75
|
-
# assert_equal 5, multi_polygon.envelope.min_y
|
76
|
-
end
|
77
|
-
|
78
|
-
private
|
79
|
-
|
80
|
-
def omit(str)
|
81
|
-
puts str
|
82
|
-
end
|
83
|
-
|
84
|
-
end
|