ruby_mapnik 0.1
Sign up to get free protection for your applications and to get access to all the features.
- 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,40 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class TestMapnikRasterSymbolizer < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@sym = Mapnik::RasterSymbolizer.new
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_presence
|
10
|
+
assert Mapnik::RasterSymbolizer
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_should_get_and_set_mode
|
14
|
+
possible_values = ["normal", "grain_merge", "grain_merge2", "multiply",
|
15
|
+
"multiply2", "divide", "divide2", "screen", "hard_light"]
|
16
|
+
possible_values.each do |value|
|
17
|
+
@sym.mode = value
|
18
|
+
assert_equal value, @sym.mode
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_should_get_and_set_scaling
|
23
|
+
possible_values = [ "fast","bilinear","bilinear8"]
|
24
|
+
possible_values.each do |value|
|
25
|
+
@sym.scaling = value
|
26
|
+
assert_equal value, @sym.scaling
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_should_get_and_set_opacity
|
31
|
+
@sym.opacity = 0.5
|
32
|
+
assert_equal 0.5, @sym.opacity
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_should_get_and_set_filter_factor
|
36
|
+
@sym.filter_factor = 0.5
|
37
|
+
assert_equal 0.5, @sym.filter_factor
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class TestMapnikRule < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def test_presence
|
6
|
+
assert Mapnik::Rule
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_should_instantiate
|
10
|
+
assert Mapnik::Rule.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_should_get_and_set_name
|
14
|
+
rule = Mapnik::Rule.new
|
15
|
+
assert_equal("", rule.name)
|
16
|
+
|
17
|
+
new_name = "New name"
|
18
|
+
rule.name = new_name
|
19
|
+
assert_equal new_name, rule.name
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_should_get_and_set_title
|
23
|
+
rule = Mapnik::Rule.new
|
24
|
+
assert_equal("", rule.title)
|
25
|
+
|
26
|
+
new_title = "New title"
|
27
|
+
rule.title = new_title
|
28
|
+
assert_equal new_title, rule.title
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_should_get_and_set_abstract
|
32
|
+
rule = Mapnik::Rule.new
|
33
|
+
assert_equal("", rule.abstract)
|
34
|
+
|
35
|
+
new_abstract = "New abstract"
|
36
|
+
rule.abstract = new_abstract
|
37
|
+
assert_equal new_abstract, rule.abstract
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_should_get_and_set_filter
|
41
|
+
rule = Mapnik::Rule.new
|
42
|
+
expression_string = "([place]='town')"
|
43
|
+
expression = Mapnik::Expression.parse(expression_string)
|
44
|
+
rule.filter = expression
|
45
|
+
assert_equal expression_string, rule.filter.to_s
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_should_append_and_remove_symbols
|
49
|
+
rule = Mapnik::Rule.new
|
50
|
+
assert_equal 0, rule.symbols.count
|
51
|
+
rule.symbols << Mapnik::PolygonSymbolizer.new
|
52
|
+
assert_equal 1, rule.symbols.count
|
53
|
+
rule.symbols << Mapnik::LineSymbolizer.new
|
54
|
+
assert_equal 2, rule.symbols.count
|
55
|
+
|
56
|
+
obj = rule.symbols.delete_at(0)
|
57
|
+
assert obj
|
58
|
+
assert_equal 1, rule.symbols.count
|
59
|
+
assert rule.symbols.pop
|
60
|
+
assert_equal 0, rule.symbols.count
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
@@ -0,0 +1,193 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class TestMapnikShieldSymbolizer < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
expression = Mapnik::Expression.parse("[place]")
|
7
|
+
face_name = "DejaVu Sans Book"
|
8
|
+
fill = Mapnik::Color.new("#fff")
|
9
|
+
file = Mapnik::PathExpression.parse("myfile.png")
|
10
|
+
@sym = Mapnik::ShieldSymbolizer.new(expression, face_name, 12, fill, file)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_should_instantiate
|
14
|
+
assert @sym
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_should_get_and_set_anchor
|
18
|
+
assert @sym.anchor
|
19
|
+
new_vals = [1,2]
|
20
|
+
@sym.anchor = new_vals
|
21
|
+
assert_equal new_vals, @sym.anchor
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_should_get_and_set_allow_overlap
|
25
|
+
@sym.allow_overlap = true
|
26
|
+
assert @sym.allow_overlap?
|
27
|
+
@sym.allow_overlap = false
|
28
|
+
assert !@sym.allow_overlap?
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_should_get_and_set_displacement
|
32
|
+
assert @sym.displacement
|
33
|
+
new_vals = [1,2]
|
34
|
+
@sym.displacement = new_vals
|
35
|
+
assert_equal new_vals, @sym.displacement
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_should_get_and_set_shield_displacement
|
39
|
+
assert @sym.shield_displacement
|
40
|
+
new_vals = [1,2]
|
41
|
+
@sym.shield_displacement = new_vals
|
42
|
+
assert_equal new_vals, @sym.shield_displacement
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_should_get_and_set_avoid_edges
|
46
|
+
@sym.avoid_edges = true
|
47
|
+
assert @sym.avoid_edges?
|
48
|
+
@sym.avoid_edges = false
|
49
|
+
assert !@sym.avoid_edges?
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_should_get_and_set_character_spacing
|
53
|
+
assert_equal 0, @sym.character_spacing
|
54
|
+
@sym.character_spacing = 1
|
55
|
+
assert_equal 1, @sym.character_spacing
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_should_get_and_set_face_name
|
59
|
+
assert_equal "DejaVu Sans Book", @sym.face_name
|
60
|
+
@sym.face_name = "DejaVu Sans"
|
61
|
+
assert_equal "DejaVu Sans", @sym.face_name
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_should_get_and_set_fill
|
65
|
+
assert @sym.fill.instance_of?(Mapnik::Color)
|
66
|
+
white = Mapnik::Color.new("#fff")
|
67
|
+
@sym.fill = white
|
68
|
+
assert_equal white, @sym.fill
|
69
|
+
end
|
70
|
+
|
71
|
+
# TODO: Need fontset
|
72
|
+
# def test_should_get_and_set_fontset
|
73
|
+
# raise @sym.fontset.inspect
|
74
|
+
# end
|
75
|
+
|
76
|
+
def test_should_get_and_set_force_odd_labels
|
77
|
+
@sym.force_odd_labels = true
|
78
|
+
assert @sym.force_odd_labels?
|
79
|
+
@sym.force_odd_labels = false
|
80
|
+
assert !@sym.force_odd_labels?
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_should_get_and_set_halo_fill
|
84
|
+
assert @sym.halo_fill.instance_of?(Mapnik::Color)
|
85
|
+
white = Mapnik::Color.new("#fff")
|
86
|
+
@sym.halo_fill = white
|
87
|
+
assert_equal white, @sym.halo_fill
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_should_get_and_set_halo_radius
|
91
|
+
assert_equal 0, @sym.halo_radius
|
92
|
+
@sym.halo_radius = 1
|
93
|
+
assert_equal 1, @sym.halo_radius
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_should_get_and_set_horizontal_alignment
|
97
|
+
@sym.horizontal_alignment = Mapnik::HORIZONTAL_ALIGNMENT::LEFT
|
98
|
+
assert_equal Mapnik::HORIZONTAL_ALIGNMENT::LEFT, @sym.horizontal_alignment
|
99
|
+
|
100
|
+
@sym.horizontal_alignment = Mapnik::HORIZONTAL_ALIGNMENT::MIDDLE
|
101
|
+
assert_equal Mapnik::HORIZONTAL_ALIGNMENT::MIDDLE, @sym.horizontal_alignment
|
102
|
+
|
103
|
+
@sym.horizontal_alignment = Mapnik::HORIZONTAL_ALIGNMENT::RIGHT
|
104
|
+
assert_equal Mapnik::HORIZONTAL_ALIGNMENT::RIGHT, @sym.horizontal_alignment
|
105
|
+
end
|
106
|
+
|
107
|
+
def test_should_get_and_set_label_position_tolerance
|
108
|
+
assert_equal 0, @sym.label_position_tolerance
|
109
|
+
@sym.label_position_tolerance = 1
|
110
|
+
assert_equal 1, @sym.label_position_tolerance
|
111
|
+
end
|
112
|
+
|
113
|
+
def test_should_get_and_set_label_spacing
|
114
|
+
assert_equal 0, @sym.label_spacing
|
115
|
+
@sym.label_spacing = 1
|
116
|
+
assert_equal 1, @sym.label_spacing
|
117
|
+
end
|
118
|
+
|
119
|
+
def test_should_get_and_set_line_spacing
|
120
|
+
assert_equal 0, @sym.line_spacing
|
121
|
+
@sym.line_spacing = 1
|
122
|
+
assert_equal 1, @sym.line_spacing
|
123
|
+
end
|
124
|
+
|
125
|
+
# TODO: failure here!
|
126
|
+
def test_should_get_and_set_max_char_angle_delta
|
127
|
+
@sym.max_char_angle_delta = 0.5
|
128
|
+
assert_equal 0.5, @sym.max_char_angle_delta
|
129
|
+
@sym.max_char_angle_delta = 0.7
|
130
|
+
assert_equal 0.7, @sym.max_char_angle_delta
|
131
|
+
end
|
132
|
+
|
133
|
+
def test_should_get_and_set_minimum_distance
|
134
|
+
assert_equal 0, @sym.minimum_distance
|
135
|
+
@sym.minimum_distance = 1
|
136
|
+
assert_equal 1, @sym.minimum_distance
|
137
|
+
end
|
138
|
+
|
139
|
+
def test_should_get_and_set_minimum_padding
|
140
|
+
assert_equal 0, @sym.minimum_padding
|
141
|
+
@sym.minimum_padding = 1
|
142
|
+
assert_equal 1, @sym.minimum_padding
|
143
|
+
end
|
144
|
+
|
145
|
+
def test_should_get_and_set_name
|
146
|
+
assert @sym.name.instance_of?(Mapnik::Expression)
|
147
|
+
new_expression_string = "([place]='towns')"
|
148
|
+
assert_not_equal new_expression_string, @sym.name.to_s
|
149
|
+
new_expression = Mapnik::Expression.parse(new_expression_string)
|
150
|
+
@sym.name = new_expression
|
151
|
+
assert_equal new_expression_string, @sym.name.to_s
|
152
|
+
end
|
153
|
+
|
154
|
+
def test_should_get_and_set_opactiy
|
155
|
+
assert_equal 1, @sym.opacity
|
156
|
+
@sym.opacity = 0
|
157
|
+
assert_equal 0, @sym.opacity
|
158
|
+
end
|
159
|
+
|
160
|
+
def test_should_get_and_set_text_ratio
|
161
|
+
assert_equal 0, @sym.ratio
|
162
|
+
@sym.ratio = 3
|
163
|
+
assert_equal 3, @sym.ratio
|
164
|
+
end
|
165
|
+
|
166
|
+
def test_should_get_and_set_text_size
|
167
|
+
assert_equal 12, @sym.size
|
168
|
+
@sym.size = 0
|
169
|
+
assert_equal 0, @sym.size
|
170
|
+
end
|
171
|
+
|
172
|
+
def test_should_get_and_set_wrap_width
|
173
|
+
assert_equal 0, @sym.wrap_width
|
174
|
+
@sym.wrap_width = 30
|
175
|
+
assert_equal 30, @sym.wrap_width
|
176
|
+
end
|
177
|
+
|
178
|
+
def test_should_get_and_set_wrap_character
|
179
|
+
@sym.wrap_character = '|'
|
180
|
+
assert_equal '|', @sym.wrap_character
|
181
|
+
@sym.wrap_character = '%'
|
182
|
+
assert_equal '%', @sym.wrap_character
|
183
|
+
end
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
def test_should_get_and_set_wrap_before
|
188
|
+
assert !@sym.wrap_before
|
189
|
+
@sym.wrap_before = true
|
190
|
+
assert @sym.wrap_before
|
191
|
+
end
|
192
|
+
|
193
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class TestMapnikStroke < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@color = Mapnik::Color.new("#ccc")
|
7
|
+
@stroke = Mapnik::Stroke.new(@color, 1.0)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_should_instantiate
|
11
|
+
assert @stroke
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_should_get_and_set_color
|
15
|
+
assert @stroke.color == @color
|
16
|
+
new_color = Mapnik::Color.new("#fff")
|
17
|
+
@stroke.color = new_color
|
18
|
+
assert @stroke.color == new_color
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_should_get_and_set_opacity
|
22
|
+
opacity_before = @stroke.opacity
|
23
|
+
assert_equal 1, opacity_before
|
24
|
+
|
25
|
+
new_opacity = 0.5
|
26
|
+
@stroke.opacity = new_opacity
|
27
|
+
assert_equal new_opacity, @stroke.opacity
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_should_get_and_set_gamma
|
31
|
+
|
32
|
+
gamma_before = @stroke.gamma
|
33
|
+
assert_equal 1, gamma_before
|
34
|
+
|
35
|
+
new_gamma = 0.5
|
36
|
+
@stroke.gamma = new_gamma
|
37
|
+
assert_equal new_gamma, @stroke.gamma
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_should_get_and_set_width
|
41
|
+
width_before = @stroke.width
|
42
|
+
assert_equal 1, width_before
|
43
|
+
|
44
|
+
new_width = 0.5
|
45
|
+
@stroke.width = new_width
|
46
|
+
assert_equal new_width, @stroke.width
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_should_have_line_caps
|
50
|
+
assert Mapnik::LineCap
|
51
|
+
assert Mapnik::LineCap::BUTT_CAP
|
52
|
+
assert Mapnik::LineCap::SQUARE_CAP
|
53
|
+
assert Mapnik::LineCap::ROUND_CAP
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_should_have_line_joins
|
57
|
+
assert Mapnik::LineJoin
|
58
|
+
assert Mapnik::LineJoin::MITER_JOIN
|
59
|
+
assert Mapnik::LineJoin::MITER_REVERT_JOIN
|
60
|
+
assert Mapnik::LineJoin::ROUND_JOIN
|
61
|
+
assert Mapnik::LineJoin::BEVEL_JOIN
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_should_get_and_set_line_cap
|
65
|
+
Mapnik::LineCap.constants.each do |const_name|
|
66
|
+
const = Mapnik::LineCap.const_get(const_name)
|
67
|
+
@stroke.line_cap = const
|
68
|
+
assert_equal const, @stroke.line_cap
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_should_get_and_set_line_join
|
73
|
+
Mapnik::LineJoin.constants.each do |const_name|
|
74
|
+
const = Mapnik::LineJoin.const_get(const_name)
|
75
|
+
@stroke.line_join = const
|
76
|
+
assert_equal const, @stroke.line_join
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_should_have_dashes
|
81
|
+
assert_equal 0, @stroke.dashes.length
|
82
|
+
dash_hash = {:gap => 1, :length => 1.2}
|
83
|
+
@stroke.dashes << dash_hash
|
84
|
+
assert_equal dash_hash, @stroke.dashes.first
|
85
|
+
assert_equal 1, @stroke.dashes.length
|
86
|
+
end
|
87
|
+
|
88
|
+
def test_should_have_dash_offset
|
89
|
+
assert_equal 0, @stroke.dash_offset
|
90
|
+
@stroke.dash_offset = 1.4
|
91
|
+
assert_equal 1.4, @stroke.dash_offset
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class TestMapnikStyle < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def test_presence
|
6
|
+
assert Mapnik::Style
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_should_have_rules
|
10
|
+
style = Mapnik::Style.new
|
11
|
+
assert style.rules.empty?
|
12
|
+
rule = Mapnik::Rule.new
|
13
|
+
style.rules << rule
|
14
|
+
assert !style.rules.empty?
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_should_have_filter_types
|
18
|
+
assert Mapnik::FilterMode::ALL
|
19
|
+
assert Mapnik::FilterMode::FIRST
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_should_get_and_set_filter
|
23
|
+
style = Mapnik::Style.new
|
24
|
+
style.filter_mode = Mapnik::FilterMode::ALL
|
25
|
+
assert_equal Mapnik::FilterMode::ALL, style.filter_mode
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,232 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class TestMapnikTextSymbolizer < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
expression = Mapnik::Expression.parse("([place]='town')")
|
7
|
+
@symbolizer = Mapnik::TextSymbolizer.new(expression, "DejaVu Sans Book", 10, Mapnik::Color.new("#fff"))
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_should_instantiate
|
11
|
+
assert @symbolizer
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_enums_should_exist
|
15
|
+
assert Mapnik::LABEL_PLACEMENT::LINE_PLACEMENT
|
16
|
+
assert Mapnik::LABEL_PLACEMENT::POINT_PLACEMENT
|
17
|
+
assert Mapnik::LABEL_PLACEMENT::VERTEX_PLACEMENT
|
18
|
+
assert Mapnik::LABEL_PLACEMENT::INTERIOR_PLACEMENT
|
19
|
+
|
20
|
+
assert Mapnik::VERTICAL_ALIGNMENT::TOP
|
21
|
+
assert Mapnik::VERTICAL_ALIGNMENT::MIDDLE
|
22
|
+
assert Mapnik::VERTICAL_ALIGNMENT::BOTTOM
|
23
|
+
assert Mapnik::VERTICAL_ALIGNMENT::AUTO
|
24
|
+
|
25
|
+
assert Mapnik::HORIZONTAL_ALIGNMENT::LEFT
|
26
|
+
assert Mapnik::HORIZONTAL_ALIGNMENT::MIDDLE
|
27
|
+
assert Mapnik::HORIZONTAL_ALIGNMENT::RIGHT
|
28
|
+
|
29
|
+
assert Mapnik::JUSTIFY_ALIGNMENT::LEFT
|
30
|
+
assert Mapnik::JUSTIFY_ALIGNMENT::MIDDLE
|
31
|
+
assert Mapnik::JUSTIFY_ALIGNMENT::RIGHT
|
32
|
+
|
33
|
+
assert Mapnik::TEXT_TRANSFORM::NONE
|
34
|
+
assert Mapnik::TEXT_TRANSFORM::UPPERCASE
|
35
|
+
assert Mapnik::TEXT_TRANSFORM::LOWERCASE
|
36
|
+
assert Mapnik::TEXT_TRANSFORM::CAPITALIZE
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_should_get_and_set_anchor
|
40
|
+
assert @symbolizer.anchor
|
41
|
+
new_vals = [1,2]
|
42
|
+
@symbolizer.anchor = new_vals
|
43
|
+
assert_equal new_vals, @symbolizer.anchor
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_should_get_and_set_allow_overlap
|
47
|
+
@symbolizer.allow_overlap = true
|
48
|
+
assert @symbolizer.allow_overlap?
|
49
|
+
@symbolizer.allow_overlap = false
|
50
|
+
assert !@symbolizer.allow_overlap?
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_should_get_and_set_displacement
|
54
|
+
assert @symbolizer.displacement
|
55
|
+
new_vals = [1,2]
|
56
|
+
@symbolizer.displacement = new_vals
|
57
|
+
assert_equal new_vals, @symbolizer.displacement
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_should_get_and_set_avoid_edges
|
61
|
+
@symbolizer.avoid_edges = true
|
62
|
+
assert @symbolizer.avoid_edges?
|
63
|
+
@symbolizer.avoid_edges = false
|
64
|
+
assert !@symbolizer.avoid_edges?
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_should_get_and_set_character_spacing
|
68
|
+
assert_equal 0, @symbolizer.character_spacing
|
69
|
+
@symbolizer.character_spacing = 1
|
70
|
+
assert_equal 1, @symbolizer.character_spacing
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_should_get_and_set_face_name
|
74
|
+
assert_equal "DejaVu Sans Book", @symbolizer.face_name
|
75
|
+
@symbolizer.face_name = "DejaVu Sans"
|
76
|
+
assert_equal "DejaVu Sans", @symbolizer.face_name
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_should_get_and_set_fill
|
80
|
+
assert @symbolizer.fill.instance_of?(Mapnik::Color)
|
81
|
+
white = Mapnik::Color.new("#fff")
|
82
|
+
@symbolizer.fill = white
|
83
|
+
assert_equal white, @symbolizer.fill
|
84
|
+
end
|
85
|
+
|
86
|
+
# TODO: Need fontset
|
87
|
+
# def test_should_get_and_set_fontset
|
88
|
+
# raise @symbolizer.fontset.inspect
|
89
|
+
# end
|
90
|
+
|
91
|
+
def test_should_get_and_set_force_odd_labels
|
92
|
+
@symbolizer.force_odd_labels = true
|
93
|
+
assert @symbolizer.force_odd_labels?
|
94
|
+
@symbolizer.force_odd_labels = false
|
95
|
+
assert !@symbolizer.force_odd_labels?
|
96
|
+
end
|
97
|
+
|
98
|
+
def test_should_get_and_set_halo_fill
|
99
|
+
assert @symbolizer.halo_fill.instance_of?(Mapnik::Color)
|
100
|
+
white = Mapnik::Color.new("#fff")
|
101
|
+
@symbolizer.halo_fill = white
|
102
|
+
assert_equal white, @symbolizer.halo_fill
|
103
|
+
end
|
104
|
+
|
105
|
+
def test_should_get_and_set_halo_radius
|
106
|
+
assert_equal 0, @symbolizer.halo_radius
|
107
|
+
@symbolizer.halo_radius = 1
|
108
|
+
assert_equal 1, @symbolizer.halo_radius
|
109
|
+
end
|
110
|
+
|
111
|
+
def test_should_get_and_set_horizontal_alignment
|
112
|
+
@symbolizer.horizontal_alignment = Mapnik::HORIZONTAL_ALIGNMENT::LEFT
|
113
|
+
assert_equal Mapnik::HORIZONTAL_ALIGNMENT::LEFT, @symbolizer.horizontal_alignment
|
114
|
+
|
115
|
+
@symbolizer.horizontal_alignment = Mapnik::HORIZONTAL_ALIGNMENT::MIDDLE
|
116
|
+
assert_equal Mapnik::HORIZONTAL_ALIGNMENT::MIDDLE, @symbolizer.horizontal_alignment
|
117
|
+
|
118
|
+
@symbolizer.horizontal_alignment = Mapnik::HORIZONTAL_ALIGNMENT::RIGHT
|
119
|
+
assert_equal Mapnik::HORIZONTAL_ALIGNMENT::RIGHT, @symbolizer.horizontal_alignment
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_should_get_and_set_justify_alignment
|
123
|
+
check_constant_setting(Mapnik::JUSTIFY_ALIGNMENT, :justify_alignment)
|
124
|
+
end
|
125
|
+
|
126
|
+
def test_should_get_and_set_label_placement
|
127
|
+
check_constant_setting(Mapnik::LABEL_PLACEMENT, :label_placement)
|
128
|
+
end
|
129
|
+
|
130
|
+
def test_should_get_and_set_label_position_tolerance
|
131
|
+
assert_equal 0, @symbolizer.label_position_tolerance
|
132
|
+
@symbolizer.label_position_tolerance = 1
|
133
|
+
assert_equal 1, @symbolizer.label_position_tolerance
|
134
|
+
end
|
135
|
+
|
136
|
+
def test_should_get_and_set_label_spacing
|
137
|
+
assert_equal 0, @symbolizer.label_spacing
|
138
|
+
@symbolizer.label_spacing = 1
|
139
|
+
assert_equal 1, @symbolizer.label_spacing
|
140
|
+
end
|
141
|
+
|
142
|
+
def test_should_get_and_set_line_spacing
|
143
|
+
assert_equal 0, @symbolizer.line_spacing
|
144
|
+
@symbolizer.line_spacing = 1
|
145
|
+
assert_equal 1, @symbolizer.line_spacing
|
146
|
+
end
|
147
|
+
|
148
|
+
# TODO: failure here!
|
149
|
+
def test_should_get_and_set_max_char_angle_delta
|
150
|
+
@symbolizer.max_char_angle_delta = 0.5
|
151
|
+
assert_equal 0.5, @symbolizer.max_char_angle_delta
|
152
|
+
@symbolizer.max_char_angle_delta = 0.7
|
153
|
+
assert_equal 0.7, @symbolizer.max_char_angle_delta
|
154
|
+
end
|
155
|
+
|
156
|
+
def test_should_get_and_set_minimum_distance
|
157
|
+
assert_equal 0, @symbolizer.minimum_distance
|
158
|
+
@symbolizer.minimum_distance = 1
|
159
|
+
assert_equal 1, @symbolizer.minimum_distance
|
160
|
+
end
|
161
|
+
|
162
|
+
def test_should_get_and_set_minimum_padding
|
163
|
+
assert_equal 0, @symbolizer.minimum_padding
|
164
|
+
@symbolizer.minimum_padding = 1
|
165
|
+
assert_equal 1, @symbolizer.minimum_padding
|
166
|
+
end
|
167
|
+
|
168
|
+
def test_should_get_and_set_name
|
169
|
+
assert @symbolizer.name.instance_of?(Mapnik::Expression)
|
170
|
+
new_expression_string = "([place]='towns')"
|
171
|
+
assert_not_equal new_expression_string, @symbolizer.name.to_s
|
172
|
+
new_expression = Mapnik::Expression.parse(new_expression_string)
|
173
|
+
@symbolizer.name = new_expression
|
174
|
+
assert_equal new_expression_string, @symbolizer.name.to_s
|
175
|
+
end
|
176
|
+
|
177
|
+
def test_should_get_and_set_opactiy
|
178
|
+
assert_equal 1, @symbolizer.opacity
|
179
|
+
@symbolizer.opacity = 0
|
180
|
+
assert_equal 0, @symbolizer.opacity
|
181
|
+
end
|
182
|
+
|
183
|
+
def test_should_get_and_set_text_transform
|
184
|
+
check_constant_setting(Mapnik::TEXT_TRANSFORM, :text_transform)
|
185
|
+
end
|
186
|
+
|
187
|
+
def test_should_get_and_set_text_ratio
|
188
|
+
assert_equal 0, @symbolizer.ratio
|
189
|
+
@symbolizer.ratio = 3
|
190
|
+
assert_equal 3, @symbolizer.ratio
|
191
|
+
end
|
192
|
+
|
193
|
+
def test_should_get_and_set_text_size
|
194
|
+
assert_equal 10, @symbolizer.size
|
195
|
+
@symbolizer.size = 0
|
196
|
+
assert_equal 0, @symbolizer.size
|
197
|
+
end
|
198
|
+
|
199
|
+
def test_should_get_and_set_vertical_alignment
|
200
|
+
check_constant_setting(Mapnik::VERTICAL_ALIGNMENT, :vertical_alignment)
|
201
|
+
end
|
202
|
+
|
203
|
+
def test_should_get_and_set_wrap_width
|
204
|
+
assert_equal 0, @symbolizer.wrap_width
|
205
|
+
@symbolizer.wrap_width = 30
|
206
|
+
assert_equal 30, @symbolizer.wrap_width
|
207
|
+
end
|
208
|
+
|
209
|
+
def test_should_get_and_set_wrap_character
|
210
|
+
@symbolizer.wrap_character = '|'
|
211
|
+
assert_equal '|', @symbolizer.wrap_character
|
212
|
+
@symbolizer.wrap_character = '%'
|
213
|
+
assert_equal '%', @symbolizer.wrap_character
|
214
|
+
end
|
215
|
+
|
216
|
+
def test_should_get_and_set_wrap_before
|
217
|
+
assert !@symbolizer.wrap_before
|
218
|
+
@symbolizer.wrap_before = true
|
219
|
+
assert @symbolizer.wrap_before
|
220
|
+
end
|
221
|
+
|
222
|
+
private
|
223
|
+
|
224
|
+
def check_constant_setting(enum, property)
|
225
|
+
enum.constants.each do |const_name|
|
226
|
+
const = enum.const_get(const_name)
|
227
|
+
@symbolizer.send(property.to_s + '=', const)
|
228
|
+
assert_equal const, @symbolizer.send(property)
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class TestPolygonPatternSymbolizer < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@filename = "/my/file.png"
|
7
|
+
path_expression = Mapnik::PathExpression.parse("/my/file.png")
|
8
|
+
@sym = Mapnik::PolygonPatternSymbolizer.new(path_expression)
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_presence
|
12
|
+
assert Mapnik::PolygonPatternSymbolizer
|
13
|
+
assert Mapnik::PatternAlignment::LOCAL
|
14
|
+
assert Mapnik::PatternAlignment::GLOBAL
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_should_instantiate
|
18
|
+
assert @sym
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_should_get_and_set_filename
|
22
|
+
assert_equal @filename, @sym.filename
|
23
|
+
new_filename = "/something/else.png"
|
24
|
+
@sym.filename = new_filename
|
25
|
+
assert_equal new_filename, @sym.filename
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_should_get_and_set_pattern_alignment
|
29
|
+
assert_equal Mapnik::PatternAlignment::LOCAL, @sym.alignment
|
30
|
+
@sym.alignment = Mapnik::PatternAlignment::GLOBAL
|
31
|
+
assert_equal Mapnik::PatternAlignment::GLOBAL, @sym.alignment
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|