mapnik 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +35 -0
- data/.yardopts +1 -0
- data/Gemfile +14 -0
- data/LICENSE +19 -0
- data/Manifest.txt +172 -0
- data/README.rdoc +107 -0
- data/Rakefile +43 -0
- data/demo/data/COPYRIGHT.txt +3 -0
- data/demo/data/TM_WORLD_BORDERS_SIMPL_0.3_MOD.dbf +0 -0
- data/demo/data/TM_WORLD_BORDERS_SIMPL_0.3_MOD.prj +1 -0
- data/demo/data/TM_WORLD_BORDERS_SIMPL_0.3_MOD.shp +0 -0
- data/demo/data/TM_WORLD_BORDERS_SIMPL_0.3_MOD.shx +0 -0
- data/demo/data/boundaries.dbf +0 -0
- data/demo/data/boundaries.prj +1 -0
- data/demo/data/boundaries.sbx +0 -0
- data/demo/data/boundaries.shp +0 -0
- data/demo/data/boundaries.shx +0 -0
- data/demo/data/boundaries_l.dbf +0 -0
- data/demo/data/boundaries_l.prj +1 -0
- data/demo/data/boundaries_l.sbx +0 -0
- data/demo/data/boundaries_l.shp +0 -0
- data/demo/data/boundaries_l.shx +0 -0
- data/demo/data/ontdrainage.dbf +0 -0
- data/demo/data/ontdrainage.prj +1 -0
- data/demo/data/ontdrainage.sbx +0 -0
- data/demo/data/ontdrainage.shp +0 -0
- data/demo/data/ontdrainage.shx +0 -0
- data/demo/data/popplaces.dbf +0 -0
- data/demo/data/popplaces.prj +1 -0
- data/demo/data/popplaces.sbx +0 -0
- data/demo/data/popplaces.shp +0 -0
- data/demo/data/popplaces.shx +0 -0
- data/demo/data/qcdrainage.dbf +0 -0
- data/demo/data/qcdrainage.prj +1 -0
- data/demo/data/qcdrainage.sbx +0 -0
- data/demo/data/qcdrainage.shp +0 -0
- data/demo/data/qcdrainage.shx +0 -0
- data/demo/data/roads.dbf +0 -0
- data/demo/data/roads.prj +1 -0
- data/demo/data/roads.sbx +0 -0
- data/demo/data/roads.shp +0 -0
- data/demo/data/roads.shx +0 -0
- data/demo/data/test/charplacement.dbf +0 -0
- data/demo/data/test/charplacement.shp +0 -0
- data/demo/data/test/charplacement.shx +0 -0
- data/demo/data/test/displacement.dbf +0 -0
- data/demo/data/test/displacement.shp +0 -0
- data/demo/data/test/displacement.shx +0 -0
- data/demo/data/test/overlap.dbf +0 -0
- data/demo/data/test/overlap.shp +0 -0
- data/demo/data/test/overlap.shx +0 -0
- data/demo/data/test/raw/charplacement.gfs +25 -0
- data/demo/data/test/raw/charplacement.gml +99 -0
- data/demo/data/test/raw/charplacement.xsd +36 -0
- data/demo/data/test/raw/displacement.gfs +25 -0
- data/demo/data/test/raw/displacement.gml +173 -0
- data/demo/data/test/raw/displacement.xsd +36 -0
- data/demo/data/test/raw/overlap.gfs +25 -0
- data/demo/data/test/raw/overlap.gml +127 -0
- data/demo/data/test/raw/overlap.xsd +36 -0
- data/demo/data/test/raw/textspacing.gfs +25 -0
- data/demo/data/test/raw/textspacing.gml +117 -0
- data/demo/data/test/raw/textspacing.xsd +36 -0
- data/demo/data/test/readme.txt +3 -0
- data/demo/data/test/regenerate.sh +20 -0
- data/demo/data/test/textspacing.dbf +0 -0
- data/demo/data/test/textspacing.shp +0 -0
- data/demo/data/test/textspacing.shx +0 -0
- data/demo/rundemo.rb +145 -0
- data/demo/sinatra/demo.rb +31 -0
- data/demo/sinatra/public/css/demo_map.css +7 -0
- data/demo/sinatra/public/index.html +13 -0
- data/demo/sinatra/public/javascripts/demo_map.js +42 -0
- data/ext/ruby_mapnik/_mapnik.cpp +52 -0
- data/ext/ruby_mapnik/_mapnik.h +65 -0
- data/ext/ruby_mapnik/_mapnik_color.rb.cpp +179 -0
- data/ext/ruby_mapnik/_mapnik_color.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_coord.rb.cpp +145 -0
- data/ext/ruby_mapnik/_mapnik_coord.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_datasource.rb.cpp +170 -0
- data/ext/ruby_mapnik/_mapnik_datasource.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_datasource_cache.rb.cpp +87 -0
- data/ext/ruby_mapnik/_mapnik_datasource_cache.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_envelope.rb.cpp +220 -0
- data/ext/ruby_mapnik/_mapnik_envelope.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_expression.rb.cpp +91 -0
- data/ext/ruby_mapnik/_mapnik_expression.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_feature.rb.cpp +93 -0
- data/ext/ruby_mapnik/_mapnik_feature.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_font_engine.rb.cpp +71 -0
- data/ext/ruby_mapnik/_mapnik_font_engine.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_layer.rb.cpp +208 -0
- data/ext/ruby_mapnik/_mapnik_layer.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_line_pattern_symbolizer.rb.cpp +71 -0
- data/ext/ruby_mapnik/_mapnik_line_pattern_symbolizer.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_line_symbolizer.rb.cpp +43 -0
- data/ext/ruby_mapnik/_mapnik_line_symbolizer.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_map.rb.cpp +489 -0
- data/ext/ruby_mapnik/_mapnik_map.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_markers_symbolizer.rb.cpp +140 -0
- data/ext/ruby_mapnik/_mapnik_markers_symbolizer.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_point_symbolizer.rb.cpp +150 -0
- data/ext/ruby_mapnik/_mapnik_point_symbolizer.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_polygon_pattern_symbolizer.rb.cpp +93 -0
- data/ext/ruby_mapnik/_mapnik_polygon_pattern_symbolizer.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_polygon_symbolizer.rb.cpp +89 -0
- data/ext/ruby_mapnik/_mapnik_polygon_symbolizer.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_projection.rb.cpp +100 -0
- data/ext/ruby_mapnik/_mapnik_projection.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_raster_colorizer.rb.cpp +162 -0
- data/ext/ruby_mapnik/_mapnik_raster_colorizer.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_raster_symbolizer.rb.cpp +87 -0
- data/ext/ruby_mapnik/_mapnik_raster_symbolizer.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_rule.rb.cpp +69 -0
- data/ext/ruby_mapnik/_mapnik_rule.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_shield_symbolizer.rb.cpp +86 -0
- data/ext/ruby_mapnik/_mapnik_shield_symbolizer.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_stroke.rb.cpp +188 -0
- data/ext/ruby_mapnik/_mapnik_stroke.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_style.rb.cpp +76 -0
- data/ext/ruby_mapnik/_mapnik_style.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_symbolizer.rb.cpp +75 -0
- data/ext/ruby_mapnik/_mapnik_symbolizer.rb.h +32 -0
- data/ext/ruby_mapnik/_mapnik_text_symbolizer.rb.cpp +471 -0
- data/ext/ruby_mapnik/_mapnik_text_symbolizer.rb.h +32 -0
- data/ext/ruby_mapnik/extconf.rb +80 -0
- data/ext/ruby_mapnik/ruby_mapnik.cpp +32 -0
- data/lib/mapnik.rb +1 -0
- data/lib/ruby_mapnik.rb +48 -0
- data/lib/ruby_mapnik/mapnik/font_engine.rb +35 -0
- data/lib/ruby_mapnik/mapnik/layer.rb +68 -0
- data/lib/ruby_mapnik/mapnik/map.rb +166 -0
- data/lib/ruby_mapnik/mapnik/projection.rb +44 -0
- data/lib/ruby_mapnik/mapnik/raster_colorizer.rb +55 -0
- data/lib/ruby_mapnik/mapnik/rule.rb +104 -0
- data/lib/ruby_mapnik/mapnik/stroke.rb +56 -0
- data/lib/ruby_mapnik/mapnik/style.rb +64 -0
- data/lib/ruby_mapnik/mapnik/tile.rb +93 -0
- data/script/console +2 -0
- data/test/data/TM_WORLD_BORDERS_SIMPL_0.3_MOD.dbf +0 -0
- data/test/data/TM_WORLD_BORDERS_SIMPL_0.3_MOD.prj +1 -0
- data/test/data/TM_WORLD_BORDERS_SIMPL_0.3_MOD.shp +0 -0
- data/test/data/TM_WORLD_BORDERS_SIMPL_0.3_MOD.shx +0 -0
- data/test/data/test_map.xml +15 -0
- data/test/test_helper.rb +29 -0
- data/test/test_line_pattern_symbolizer.rb +26 -0
- data/test/test_mapnik_color.rb +66 -0
- data/test/test_mapnik_coord.rb +92 -0
- data/test/test_mapnik_datasource.rb +49 -0
- data/test/test_mapnik_envelope.rb +232 -0
- data/test/test_mapnik_expression.rb +19 -0
- data/test/test_mapnik_feature.rb +29 -0
- data/test/test_mapnik_font_engine.rb +13 -0
- data/test/test_mapnik_layer.rb +121 -0
- data/test/test_mapnik_line_symbolizer.rb +25 -0
- data/test/test_mapnik_map.rb +211 -0
- data/test/test_mapnik_markers_symbolizer.rb +46 -0
- data/test/test_mapnik_point_symbolizer.rb +53 -0
- data/test/test_mapnik_polygon_symbolizer.rb +44 -0
- data/test/test_mapnik_projection.rb +46 -0
- data/test/test_mapnik_raster_colorizer.rb +56 -0
- data/test/test_mapnik_raster_symbolizer.rb +45 -0
- data/test/test_mapnik_rule.rb +45 -0
- data/test/test_mapnik_shield_symbolizer.rb +156 -0
- data/test/test_mapnik_stroke.rb +94 -0
- data/test/test_mapnik_style.rb +28 -0
- data/test/test_mapnik_symbolizer.rb +9 -0
- data/test/test_mapnik_text_symbolizer.rb +208 -0
- data/test/test_polygon_pattern_symbolizer.rb +34 -0
- data/test/test_ruby_mapnik.rb +34 -0
- data/yard/lib/yard/parser/generic_parser.rb +72 -0
- data/yard/lib/yard_generic.rb +18 -0
- metadata +333 -0
@@ -0,0 +1,53 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class TestMapnikPointSymbolizer < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@sym = Mapnik::PointSymbolizer.new
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_presence
|
10
|
+
assert Mapnik::PointSymbolizer
|
11
|
+
assert Mapnik::PointPlacement::CENTROID
|
12
|
+
assert Mapnik::PointPlacement::INTERIOR
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_should_initialize
|
16
|
+
assert @sym
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_should_get_and_set_filename
|
20
|
+
assert_equal "", @sym.filename
|
21
|
+
new_filename = "/my/incredible/graphic.png"
|
22
|
+
@sym.filename = new_filename
|
23
|
+
assert_equal new_filename, @sym.filename
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_should_get_and_set_allows_overlap
|
27
|
+
assert !@sym.allows_overlap?
|
28
|
+
@sym.allows_overlap = true
|
29
|
+
assert @sym.allows_overlap?
|
30
|
+
@sym.allows_overlap = false
|
31
|
+
assert !@sym.allows_overlap?
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_should_get_and_set_opacity
|
35
|
+
assert_equal 1, @sym.opacity
|
36
|
+
new_opacity = 0.5
|
37
|
+
@sym.opacity = new_opacity
|
38
|
+
assert_equal new_opacity, @sym.opacity
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_should_get_and_set_ignore_placement
|
42
|
+
assert !@sym.ignores_placement?
|
43
|
+
@sym.ignores_placement = true
|
44
|
+
assert @sym.ignores_placement?
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_should_get_and_set_placement
|
48
|
+
assert_equal Mapnik::PointPlacement::CENTROID, @sym.placement
|
49
|
+
@sym.placement = Mapnik::PointPlacement::INTERIOR
|
50
|
+
assert_equal Mapnik::PointPlacement::INTERIOR, @sym.placement
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class TestMapnikPolygonSymbolizer < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def test_presence
|
6
|
+
assert Mapnik::PolygonSymbolizer
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_should_instantiate
|
10
|
+
assert Mapnik::PolygonSymbolizer.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_should_get_and_set_fill_to_a_color
|
14
|
+
polygon = Mapnik::PolygonSymbolizer.new
|
15
|
+
color_before = polygon.fill
|
16
|
+
assert color_before.kind_of?(Mapnik::Color)
|
17
|
+
|
18
|
+
new_color = Mapnik::Color.new("#000")
|
19
|
+
polygon.fill = new_color
|
20
|
+
|
21
|
+
assert [:red, :green, :blue, :alpha].all?{|x| polygon.fill.send(x) == new_color.send(x)}
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_should_get_and_set_opacity
|
25
|
+
polygon = Mapnik::PolygonSymbolizer.new
|
26
|
+
opacity_before = polygon.opacity
|
27
|
+
assert_equal 1, opacity_before
|
28
|
+
|
29
|
+
new_opacity = 0.5
|
30
|
+
polygon.opacity = new_opacity
|
31
|
+
assert_equal new_opacity, polygon.opacity
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_should_get_and_set_gamma
|
35
|
+
polygon = Mapnik::PolygonSymbolizer.new
|
36
|
+
gamma_before = polygon.gamma
|
37
|
+
assert_equal 1, gamma_before
|
38
|
+
|
39
|
+
new_gamma = 0.5
|
40
|
+
polygon.gamma = new_gamma
|
41
|
+
assert_equal new_gamma, polygon.gamma
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class TestMapnikProjection < Test::Unit::TestCase
|
4
|
+
|
5
|
+
PARAMS = '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs'
|
6
|
+
|
7
|
+
def test_presence
|
8
|
+
assert Mapnik::Projection
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_should_instantiate_and_return_params
|
12
|
+
assert proj = Mapnik::Projection.new(PARAMS)
|
13
|
+
assert_equal PARAMS, proj.params
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_should_return_expanded_params
|
17
|
+
assert proj = Mapnik::Projection.new(PARAMS)
|
18
|
+
assert_not_equal PARAMS, proj.expanded_params
|
19
|
+
assert proj.expanded_params.include?(PARAMS)
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_should_respond_to_geographic
|
23
|
+
assert Mapnik::Projection.new(PARAMS).geographic?
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_should_inverse_points
|
27
|
+
proj = Mapnik::Projection.new(PARAMS)
|
28
|
+
assert proj.inverse(Mapnik::Coord2d.new(2,3))
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_should_inverse_envelopes
|
32
|
+
proj = Mapnik::Projection.new(PARAMS)
|
33
|
+
assert proj.inverse(Mapnik::Envelope.new(2,3,4,5))
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_should_forward_points
|
37
|
+
proj = Mapnik::Projection.new(PARAMS)
|
38
|
+
assert proj.forward(Mapnik::Coord2d.new(2,3))
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_should_forward_envelopes
|
42
|
+
proj = Mapnik::Projection.new(PARAMS)
|
43
|
+
assert proj.forward(Mapnik::Envelope.new(2,3,4,5))
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class TestMapnikRasterColorizer < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@colorizer = Mapnik::RasterColorizer.new
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_presence
|
10
|
+
assert Mapnik::RasterColorizer
|
11
|
+
["INHERIT","LINEAR","DISCRETE","EXACT"].each do |colorizer_mode|
|
12
|
+
assert Mapnik::ColorizerMode.const_get(colorizer_mode)
|
13
|
+
end
|
14
|
+
assert Mapnik::ColorizerStop
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_should_get_and_set_default_color
|
18
|
+
color = Mapnik::Color.new("#fff")
|
19
|
+
@colorizer.default_color = color
|
20
|
+
assert_equal 255, @colorizer.default_color.red
|
21
|
+
assert_equal 255, @colorizer.default_color.green
|
22
|
+
assert_equal 255, @colorizer.default_color.blue
|
23
|
+
assert_equal 255, @colorizer.default_color.alpha
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_should_get_and_set_default_mode
|
27
|
+
["LINEAR", "DISCRETE","EXACT"].each do |mode_name|
|
28
|
+
const = Mapnik::ColorizerMode.const_get(mode_name)
|
29
|
+
@colorizer.default_mode = const
|
30
|
+
assert_equal const, @colorizer.default_mode
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_should_get_and_set_epsilon
|
35
|
+
@colorizer.epsilon = 5
|
36
|
+
assert_equal 5, @colorizer.epsilon
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_should_instantiate_a_stop
|
40
|
+
value = 45.5
|
41
|
+
mode = Mapnik::ColorizerMode::EXACT
|
42
|
+
color = Mapnik::Color.new("#fff")
|
43
|
+
assert stop = Mapnik::ColorizerStop.new(value,mode,color)
|
44
|
+
assert_equal value, stop.value
|
45
|
+
assert_equal mode, stop.mode
|
46
|
+
assert_equal color, stop.color
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_should_get_and_add_stops
|
50
|
+
assert @colorizer.stops.empty?
|
51
|
+
stop = Mapnik::ColorizerStop.new(45.45, Mapnik::ColorizerMode::EXACT, Mapnik::Color.new("#fff"))
|
52
|
+
@colorizer.stops << stop
|
53
|
+
assert_equal @colorizer.stops.first, stop
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
@@ -0,0 +1,45 @@
|
|
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_should_have_scaling_method
|
10
|
+
scaling_methods = [:NEAR, :BILINEAR, :BICUBIC,
|
11
|
+
:SPLINE16, :SPLINE36, :HANNING,
|
12
|
+
:HAMMING, :HERMITE, :KAISER, :QUADRIC,
|
13
|
+
:CATROM, :GAUSSIAN, :BESSEL, :MITCHELL,
|
14
|
+
:SINC, :LANCZOS, :BLACKMAN, :BILINEAR8]
|
15
|
+
assert_equal scaling_methods, Mapnik::ScalingMethod.constants
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_should_get_and_set_mode
|
19
|
+
possible_values = ["normal", "grain_merge", "grain_merge2", "multiply",
|
20
|
+
"multiply2", "divide", "divide2", "screen", "hard_light"]
|
21
|
+
possible_values.each do |value|
|
22
|
+
@sym.mode = value
|
23
|
+
assert_equal value, @sym.mode
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_should_get_and_set_scaling
|
28
|
+
Mapnik::ScalingMethod.constants.each do |const_sym|
|
29
|
+
value = Mapnik::ScalingMethod.const_get(const_sym)
|
30
|
+
@sym.scaling = value
|
31
|
+
assert_equal value, @sym.scaling
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_should_get_and_set_opacity
|
36
|
+
@sym.opacity = 0.5
|
37
|
+
assert_equal 0.5, @sym.opacity
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_should_get_and_set_filter_factor
|
41
|
+
@sym.filter_factor = 0.5
|
42
|
+
assert_equal 0.5, @sym.filter_factor
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
@@ -0,0 +1,45 @@
|
|
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_filter
|
23
|
+
rule = Mapnik::Rule.new
|
24
|
+
expression_string = "([place]='town')"
|
25
|
+
expression = Mapnik::Expression.parse(expression_string)
|
26
|
+
rule.filter = expression
|
27
|
+
assert_equal expression_string, rule.filter.to_s
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_should_append_and_remove_symbols
|
31
|
+
rule = Mapnik::Rule.new
|
32
|
+
assert_equal 0, rule.symbols.count
|
33
|
+
rule.symbols << Mapnik::PolygonSymbolizer.new
|
34
|
+
assert_equal 1, rule.symbols.count
|
35
|
+
rule.symbols << Mapnik::LineSymbolizer.new
|
36
|
+
assert_equal 2, rule.symbols.count
|
37
|
+
|
38
|
+
obj = rule.symbols.delete_at(0)
|
39
|
+
assert obj
|
40
|
+
assert_equal 1, rule.symbols.count
|
41
|
+
assert rule.symbols.pop
|
42
|
+
assert_equal 0, rule.symbols.count
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
@@ -0,0 +1,156 @@
|
|
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_allow_overlap
|
18
|
+
@sym.allow_overlap = true
|
19
|
+
assert @sym.allow_overlap?
|
20
|
+
@sym.allow_overlap = false
|
21
|
+
assert !@sym.allow_overlap?
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_should_get_and_set_displacement
|
25
|
+
assert @sym.displacement
|
26
|
+
new_vals = [1,2]
|
27
|
+
@sym.displacement = new_vals
|
28
|
+
assert_equal new_vals, @sym.displacement
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_should_get_and_set_shield_displacement
|
32
|
+
assert @sym.shield_displacement
|
33
|
+
new_vals = [1,2]
|
34
|
+
@sym.shield_displacement = new_vals
|
35
|
+
assert_equal new_vals, @sym.shield_displacement
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_should_get_and_set_avoid_edges
|
39
|
+
@sym.avoid_edges = true
|
40
|
+
assert @sym.avoid_edges?
|
41
|
+
@sym.avoid_edges = false
|
42
|
+
assert !@sym.avoid_edges?
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_should_get_and_set_character_spacing
|
46
|
+
assert_equal 0, @sym.character_spacing
|
47
|
+
@sym.character_spacing = 1
|
48
|
+
assert_equal 1, @sym.character_spacing
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_should_get_and_set_face_name
|
52
|
+
assert_equal "DejaVu Sans Book", @sym.face_name
|
53
|
+
@sym.face_name = "DejaVu Sans"
|
54
|
+
assert_equal "DejaVu Sans", @sym.face_name
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_should_get_and_set_fill
|
58
|
+
assert @sym.fill.instance_of?(Mapnik::Color)
|
59
|
+
white = Mapnik::Color.new("#fff")
|
60
|
+
@sym.fill = white
|
61
|
+
assert_equal white, @sym.fill
|
62
|
+
end
|
63
|
+
|
64
|
+
# TODO: Need fontset
|
65
|
+
# def test_should_get_and_set_fontset
|
66
|
+
# raise @sym.fontset.inspect
|
67
|
+
# end
|
68
|
+
|
69
|
+
def test_should_get_and_set_halo_fill
|
70
|
+
assert @sym.halo_fill.instance_of?(Mapnik::Color)
|
71
|
+
white = Mapnik::Color.new("#fff")
|
72
|
+
@sym.halo_fill = white
|
73
|
+
assert_equal white, @sym.halo_fill
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_should_get_and_set_halo_radius
|
77
|
+
assert_equal 0, @sym.halo_radius
|
78
|
+
@sym.halo_radius = 1
|
79
|
+
assert_equal 1, @sym.halo_radius
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_should_get_and_set_horizontal_alignment
|
83
|
+
@sym.horizontal_alignment = Mapnik::HORIZONTAL_ALIGNMENT::LEFT
|
84
|
+
assert_equal Mapnik::HORIZONTAL_ALIGNMENT::LEFT, @sym.horizontal_alignment
|
85
|
+
|
86
|
+
@sym.horizontal_alignment = Mapnik::HORIZONTAL_ALIGNMENT::MIDDLE
|
87
|
+
assert_equal Mapnik::HORIZONTAL_ALIGNMENT::MIDDLE, @sym.horizontal_alignment
|
88
|
+
|
89
|
+
@sym.horizontal_alignment = Mapnik::HORIZONTAL_ALIGNMENT::RIGHT
|
90
|
+
assert_equal Mapnik::HORIZONTAL_ALIGNMENT::RIGHT, @sym.horizontal_alignment
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_should_get_and_set_label_position_tolerance
|
94
|
+
assert_equal 0, @sym.label_position_tolerance
|
95
|
+
@sym.label_position_tolerance = 1
|
96
|
+
assert_equal 1, @sym.label_position_tolerance
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_should_get_and_set_label_spacing
|
100
|
+
assert_equal 0, @sym.label_spacing
|
101
|
+
@sym.label_spacing = 1
|
102
|
+
assert_equal 1, @sym.label_spacing
|
103
|
+
end
|
104
|
+
|
105
|
+
def test_should_get_and_set_line_spacing
|
106
|
+
assert_equal 0, @sym.line_spacing
|
107
|
+
@sym.line_spacing = 1
|
108
|
+
assert_equal 1, @sym.line_spacing
|
109
|
+
end
|
110
|
+
|
111
|
+
# TODO: failure here!
|
112
|
+
def test_should_get_and_set_max_char_angle_delta
|
113
|
+
@sym.max_char_angle_delta = 0.5
|
114
|
+
assert_equal 0.5, @sym.max_char_angle_delta
|
115
|
+
@sym.max_char_angle_delta = 0.7
|
116
|
+
assert_equal 0.7, @sym.max_char_angle_delta
|
117
|
+
end
|
118
|
+
|
119
|
+
def test_should_get_and_set_minimum_distance
|
120
|
+
assert_equal 0, @sym.minimum_distance
|
121
|
+
@sym.minimum_distance = 1
|
122
|
+
assert_equal 1, @sym.minimum_distance
|
123
|
+
end
|
124
|
+
|
125
|
+
def test_should_get_and_set_minimum_padding
|
126
|
+
assert_equal 0, @sym.minimum_padding
|
127
|
+
@sym.minimum_padding = 1
|
128
|
+
assert_equal 1, @sym.minimum_padding
|
129
|
+
end
|
130
|
+
|
131
|
+
def test_should_get_and_set_opactiy
|
132
|
+
assert_equal 1, @sym.opacity
|
133
|
+
@sym.opacity = 0
|
134
|
+
assert_equal 0, @sym.opacity
|
135
|
+
end
|
136
|
+
|
137
|
+
def test_should_get_and_set_text_ratio
|
138
|
+
assert_equal 0, @sym.ratio
|
139
|
+
@sym.ratio = 3
|
140
|
+
assert_equal 3, @sym.ratio
|
141
|
+
end
|
142
|
+
|
143
|
+
def test_should_get_and_set_wrap_character
|
144
|
+
@sym.wrap_character = '|'
|
145
|
+
assert_equal '|', @sym.wrap_character
|
146
|
+
@sym.wrap_character = '%'
|
147
|
+
assert_equal '%', @sym.wrap_character
|
148
|
+
end
|
149
|
+
|
150
|
+
def test_should_get_and_set_wrap_before
|
151
|
+
assert !@sym.wrap_before
|
152
|
+
@sym.wrap_before = true
|
153
|
+
assert @sym.wrap_before
|
154
|
+
end
|
155
|
+
|
156
|
+
end
|