ruby_mapnik 0.1 → 0.1.2
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/README.rdoc +4 -4
- data/Rakefile +1 -1
- data/ext/ruby_mapnik/_mapnik_feature.rb.cpp +4 -10
- data/ext/ruby_mapnik/_mapnik_geometry.rb.cpp +15 -2
- data/ext/ruby_mapnik/_mapnik_map.rb.cpp +28 -2
- data/ext/ruby_mapnik/extconf.rb +4 -2
- data/lib/ruby_mapnik/mapnik/layer.rb +0 -1
- data/lib/ruby_mapnik/mapnik/map.rb +24 -7
- data/lib/ruby_mapnik/mapnik/projection.rb +1 -3
- data/lib/ruby_mapnik/mapnik/rule.rb +1 -3
- data/lib/ruby_mapnik/mapnik/stroke.rb +1 -3
- data/lib/ruby_mapnik/mapnik/style.rb +1 -3
- data/lib/ruby_mapnik.rb +2 -2
- data/test/test_helper.rb +3 -1
- data/test/test_mapnik_feature.rb +1 -1
- data/test/test_mapnik_geometry.rb +51 -37
- data/test/test_mapnik_map.rb +12 -3
- metadata +7 -6
data/README.rdoc
CHANGED
@@ -11,13 +11,13 @@ https://github.com/mapnik/Ruby-Mapnik
|
|
11
11
|
== Description
|
12
12
|
|
13
13
|
A set of bindings between Ruby and Mapnik. Supports many of the common uses for
|
14
|
-
Mapnik, and one day, might support
|
15
|
-
the
|
16
|
-
Mapnik has been compiled with Cairo support.
|
14
|
+
Mapnik, and one day, might support all of them. Rendering is available using
|
15
|
+
the standard AGG library, or additionally via Cairo, if the rcairo gem is
|
16
|
+
installed and Mapnik has been compiled with Cairo support.
|
17
17
|
|
18
18
|
== Installation
|
19
19
|
|
20
|
-
|
20
|
+
gem install ruby_mapnik
|
21
21
|
|
22
22
|
Note: on osx the default rake compile will try to build universal, and your
|
23
23
|
mapnik install is unlikely built universal. Check the architecture of libmapnik2.dylib like:
|
data/Rakefile
CHANGED
@@ -28,7 +28,7 @@ Hoe.plugin :bundler, :rubygems, :doofus, :git
|
|
28
28
|
Hoe.spec 'ruby_mapnik' do
|
29
29
|
developer('Elliot Laster', 'elliotlaster@gmail.com')
|
30
30
|
self.readme_file = 'README.rdoc'
|
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
|
|
@@ -30,15 +30,9 @@ SOFTWARE.
|
|
30
30
|
#include <mapnik/wkt/wkt_factory.hpp>
|
31
31
|
#include <mapnik/feature.hpp>
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
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
|
-
}
|
33
|
+
void add_geometries_from_wkt(mapnik::Feature * self, std::string wkt){
|
34
|
+
bool result = mapnik::from_wkt(wkt, self->paths());
|
35
|
+
if (!result) throw std::runtime_error("Failed to parse WKT");
|
42
36
|
}
|
43
37
|
|
44
38
|
void register_feature(Rice::Module rb_mapnik){
|
@@ -52,5 +46,5 @@ void register_feature(Rice::Module rb_mapnik){
|
|
52
46
|
rb_cfeature.define_method("number_of_geometries", &mapnik::Feature::num_geometries);
|
53
47
|
rb_cfeature.define_method("envelope", &mapnik::Feature::envelope);
|
54
48
|
|
55
|
-
rb_cfeature.define_method("
|
49
|
+
rb_cfeature.define_method("add_geometries_from_wkt", &add_geometries_from_wkt, Rice::Arg("geom"));
|
56
50
|
}
|
@@ -32,14 +32,25 @@ SOFTWARE.
|
|
32
32
|
#include <mapnik/wkt/wkt_factory.hpp>
|
33
33
|
|
34
34
|
namespace{
|
35
|
+
|
36
|
+
typedef boost::ptr_vector<mapnik::geometry_type> path_type;
|
37
|
+
|
35
38
|
// Borrowed from the python bindings...
|
36
|
-
|
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) {
|
37
47
|
std::pair<bool,mapnik::geometry_type*> result = mapnik::from_wkt(wkt);
|
38
48
|
if (result.first){
|
39
49
|
return result.second;
|
40
50
|
}
|
41
51
|
throw std::runtime_error("Failed to parse WKT");
|
42
52
|
}
|
53
|
+
*/
|
43
54
|
|
44
55
|
}
|
45
56
|
|
@@ -65,9 +76,11 @@ void register_geometry(Rice::Module rb_mapnik){
|
|
65
76
|
geometry_enum.define_value("MultiPolygon",mapnik::MultiPolygon);
|
66
77
|
|
67
78
|
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
79
|
rb_cgeometry2d.define_method("envelope", &mapnik::geometry_type::envelope);
|
70
80
|
rb_cgeometry2d.define_method("type", &mapnik::geometry_type::type);
|
71
81
|
rb_cgeometry2d.define_method("area", &mapnik::geometry_type::area);
|
82
|
+
|
83
|
+
Rice::Data_Type< path_type > rb_cpath = Rice::define_class_under< path_type >(rb_mapnik, "Path");
|
84
|
+
rb_cpath.define_singleton_method("from_wkt", &from_wkt_impl, Rice::Arg("wkt"));
|
72
85
|
}
|
73
86
|
|
@@ -163,13 +163,25 @@ namespace {
|
|
163
163
|
void register_map(Rice::Module rb_mapnik){
|
164
164
|
/*
|
165
165
|
@@Module_var rb_mapnik = Mapnik
|
166
|
+
Document-class: Mapnik::Map
|
167
|
+
|
168
|
+
Maps are exactly what they sound like: the reason you are using mapnik. Maps
|
169
|
+
have layers, which wrap a datasource, and styles, which contain instructions
|
170
|
+
on how to render those layers.
|
171
|
+
|
172
|
+
Maps can be rendered to basic image formats (jpg, png), as well as to cairo
|
173
|
+
surfaces and contexts, if mapnik has been compiled with cairo support, and if
|
174
|
+
the rcairo gem is installed.
|
175
|
+
|
166
176
|
*/
|
167
177
|
Rice::Data_Type< mapnik::Map > rb_cmap = Rice::define_class_under< mapnik::Map >(rb_mapnik, "Map");
|
168
178
|
|
169
179
|
/*
|
170
180
|
* Document-method: new
|
181
|
+
* Instantiates a new map object. The map is yielded if a block is given.
|
171
182
|
* @return [Mapnik::Map] a new map object
|
172
183
|
* @yield [map] the new map object
|
184
|
+
|
173
185
|
*/
|
174
186
|
rb_cmap.define_constructor(Rice::Constructor< mapnik::Map >());
|
175
187
|
|
@@ -235,6 +247,7 @@ void register_map(Rice::Module rb_mapnik){
|
|
235
247
|
|
236
248
|
/*
|
237
249
|
* Document-method: height
|
250
|
+
* The height of the rendered image in pixels.
|
238
251
|
* @return [Integer]
|
239
252
|
*/
|
240
253
|
rb_cmap.define_method("height", &mapnik::Map::height);
|
@@ -243,7 +256,8 @@ void register_map(Rice::Module rb_mapnik){
|
|
243
256
|
* Document-method: height=
|
244
257
|
* call-seq:
|
245
258
|
* height=(height_in_pixels)
|
246
|
-
*
|
259
|
+
* Sets the height of the rendered image.
|
260
|
+
* @param [Integer] height_in_pixels
|
247
261
|
* @return [nil]
|
248
262
|
*/
|
249
263
|
rb_cmap.define_method("height=", &mapnik::Map::set_height);
|
@@ -265,6 +279,8 @@ void register_map(Rice::Module rb_mapnik){
|
|
265
279
|
|
266
280
|
/*
|
267
281
|
* Document-method: srs
|
282
|
+
* The spatial reference system string for the map. It does not need to match
|
283
|
+
* the srs of any of the layers.
|
268
284
|
* @return [String]
|
269
285
|
*/
|
270
286
|
rb_cmap.define_method("srs", &mapnik::Map::srs);
|
@@ -273,6 +289,9 @@ void register_map(Rice::Module rb_mapnik){
|
|
273
289
|
* Document-method: srs=
|
274
290
|
* call-seq:
|
275
291
|
* srs=(new_srs)
|
292
|
+
* Sets the spatial reference system that will be used to render the map. All
|
293
|
+
* layers will have thier data reprojected to this srs behind the scenes.
|
294
|
+
*
|
276
295
|
* @param [String]
|
277
296
|
* @return [nil]
|
278
297
|
*/
|
@@ -280,14 +299,16 @@ void register_map(Rice::Module rb_mapnik){
|
|
280
299
|
|
281
300
|
/*
|
282
301
|
* Document-method: width
|
302
|
+
* The width of the image in pixels.
|
283
303
|
* @return [Integer]
|
284
304
|
*/
|
285
305
|
rb_cmap.define_method("width", &mapnik::Map::width);
|
286
306
|
|
287
307
|
/*
|
288
|
-
* Document-method width=
|
308
|
+
* Document-method: width=
|
289
309
|
* call-seq:
|
290
310
|
* width=(new_width)
|
311
|
+
* Sets the width of the image.
|
291
312
|
* @param [Integer] new_width in pixels
|
292
313
|
* @return [nil]
|
293
314
|
*/
|
@@ -327,6 +348,7 @@ void register_map(Rice::Module rb_mapnik){
|
|
327
348
|
|
328
349
|
/*
|
329
350
|
* Document-method: zoom_all
|
351
|
+
* Zooms the map so that all of the envelopes of the layers are visible.
|
330
352
|
* @return [nil]
|
331
353
|
*/
|
332
354
|
rb_cmap.define_method("zoom_all", &mapnik::Map::zoom_all);
|
@@ -335,6 +357,9 @@ void register_map(Rice::Module rb_mapnik){
|
|
335
357
|
* Document-method: zoom_to_box
|
336
358
|
* call-seq:
|
337
359
|
* zoom_to_box(envelope)
|
360
|
+
* Zooms the map such that the envelope provided is all that will be rendered.
|
361
|
+
* The height and width of the map will stay the same, but the content will be
|
362
|
+
* zoomed.
|
338
363
|
* @param [Mapnik::Envelope] envelope
|
339
364
|
* @return [nil]
|
340
365
|
*/
|
@@ -344,6 +369,7 @@ void register_map(Rice::Module rb_mapnik){
|
|
344
369
|
* Document-method: resize
|
345
370
|
* call-seq:
|
346
371
|
* resize(new_width, new_height)
|
372
|
+
* Resizes the height and width of the map in one step.
|
347
373
|
* @param [Integer] new_width in pixels
|
348
374
|
* @param [Integer] new_height in pixels
|
349
375
|
* @return [nil]
|
data/ext/ruby_mapnik/extconf.rb
CHANGED
@@ -39,7 +39,9 @@ LIBDIR = Config::CONFIG['libdir']
|
|
39
39
|
INCLUDEDIR = Config::CONFIG['includedir']
|
40
40
|
|
41
41
|
$LDFLAGS += " -lmapnik2 "
|
42
|
-
|
42
|
+
|
43
|
+
# force whitespace padding to avoid: https://github.com/mapnik/Ruby-Mapnik/issues/7
|
44
|
+
$CFLAGS += " " + %x{mapnik-config --cflags} + " "
|
43
45
|
|
44
46
|
#------------------------------------------------------------------------------#
|
45
47
|
# Ruby-Mapnik configuration
|
@@ -75,4 +77,4 @@ if RUBY_PLATFORM =~ /darwin/
|
|
75
77
|
append_ld_flags '-all_load'
|
76
78
|
end
|
77
79
|
|
78
|
-
create_makefile("ruby_mapnik")
|
80
|
+
create_makefile("ruby_mapnik/ruby_mapnik")
|
@@ -86,6 +86,7 @@ module Mapnik
|
|
86
86
|
|
87
87
|
class << self
|
88
88
|
|
89
|
+
# Loads a map from an xml string.
|
89
90
|
# @return [Mapnik::Map]
|
90
91
|
def from_xml(xml, strict = false, base_path = "")
|
91
92
|
map = new
|
@@ -93,15 +94,25 @@ module Mapnik
|
|
93
94
|
map
|
94
95
|
end
|
95
96
|
|
97
|
+
# Loads a map from an xml file.
|
96
98
|
# @return [Mapnik::Map]
|
97
|
-
|
99
|
+
# @param [File, String] file Can be a string representing a file path, or a file object
|
100
|
+
def from_file(file, strict = false)
|
101
|
+
if file.is_a?(File)
|
102
|
+
path = File.expand_path(file.path)
|
103
|
+
else
|
104
|
+
path = file
|
105
|
+
end
|
98
106
|
map = new
|
99
|
-
__load_map__(map,
|
107
|
+
__load_map__(map, path, strict)
|
100
108
|
map
|
101
109
|
end
|
102
110
|
|
103
111
|
end
|
104
112
|
|
113
|
+
# Creates and yeilds a new style object, then adds that style to the
|
114
|
+
# map's collection of styles, under the name passed in. Makes no effort
|
115
|
+
# to de-dupe style name collisions.
|
105
116
|
# @return [Mapnik::Style]
|
106
117
|
def style(name)
|
107
118
|
style = Mapnik::Style.new
|
@@ -109,6 +120,7 @@ module Mapnik
|
|
109
120
|
styles[name] = style
|
110
121
|
end
|
111
122
|
|
123
|
+
# The styles for this map.
|
112
124
|
# @return [Mapnik::StyleContainer]
|
113
125
|
def styles
|
114
126
|
styles = MapStyleContainer[__styles__]
|
@@ -116,6 +128,9 @@ module Mapnik
|
|
116
128
|
styles
|
117
129
|
end
|
118
130
|
|
131
|
+
# Creates and yields a new layer object, then adds that layer to the map's
|
132
|
+
# collection of layers. If the srs is not provided in the initial call,
|
133
|
+
# it will need to be provided in the block.
|
119
134
|
# @return [Mapnik::Layer]
|
120
135
|
def layer(name, srs = nil)
|
121
136
|
layer = Mapnik::Layer.new(name, srs)
|
@@ -124,20 +139,22 @@ module Mapnik
|
|
124
139
|
layers << layer
|
125
140
|
end
|
126
141
|
|
142
|
+
# The layers associated with this map
|
127
143
|
# @return [Mapnik::MapLayerContainer]
|
128
144
|
def layers
|
129
145
|
layers = MapLayerContainer.new(__layers__)
|
130
146
|
layers.map = self
|
131
147
|
layers
|
132
148
|
end
|
133
|
-
|
134
|
-
#
|
149
|
+
|
150
|
+
# Renders the map to a file. Returns true or false depending if the
|
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"
|
153
|
+
# @return [Boolean]
|
135
154
|
def render_to_file(filename)
|
136
155
|
__render_to_file__(filename)
|
156
|
+
return File.exists?(filename)
|
137
157
|
end
|
138
|
-
|
139
|
-
private :__styles__, :__insert_style__, :__remove_style__, :__layers__,
|
140
|
-
:__add_layer__, :__remove_layer__
|
141
158
|
|
142
159
|
end
|
143
160
|
|
data/lib/ruby_mapnik.rb
CHANGED
@@ -23,7 +23,7 @@ require 'forwardable'
|
|
23
23
|
|
24
24
|
path = File.expand_path(File.dirname(__FILE__))
|
25
25
|
|
26
|
-
require
|
26
|
+
require "#{path}/ruby_mapnik_config"
|
27
27
|
require "#{path}/ruby_mapnik/ruby_mapnik"
|
28
28
|
require "#{path}/ruby_mapnik/mapnik/rule"
|
29
29
|
require "#{path}/ruby_mapnik/mapnik/style"
|
@@ -37,7 +37,7 @@ require "#{path}/ruby_mapnik/mapnik/tile"
|
|
37
37
|
|
38
38
|
|
39
39
|
module Mapnik
|
40
|
-
VERSION = '0.1'
|
40
|
+
VERSION = '0.1.2'
|
41
41
|
|
42
42
|
FontEngine.register_fonts(FONT_PATH)
|
43
43
|
DatasourceCache.register(INPUT_PLUGIN_PATH)
|
data/test/test_helper.rb
CHANGED
@@ -20,7 +20,9 @@
|
|
20
20
|
******************************************************************************
|
21
21
|
=end
|
22
22
|
require "test/unit"
|
23
|
-
|
23
|
+
|
24
|
+
CURRENT_PATH = File.expand_path(File.dirname(__FILE__))
|
25
|
+
require File.join(CURRENT_PATH, '..', 'lib', 'ruby_mapnik')
|
24
26
|
|
25
27
|
unless defined?(SHAPEFILE)
|
26
28
|
SHAPEFILE = "#{File.expand_path(File.dirname(__FILE__))}/data/TM_WORLD_BORDERS_SIMPL_0.3_MOD"
|
data/test/test_mapnik_feature.rb
CHANGED
@@ -26,7 +26,7 @@ class TestMapnikFeature < Test::Unit::TestCase
|
|
26
26
|
def test_should_add_a_geometry
|
27
27
|
feature = Mapnik::Feature.new(1)
|
28
28
|
assert_equal(0, feature.number_of_geometries)
|
29
|
-
feature.
|
29
|
+
feature.add_geometries_from_wkt("POINT(30 10)")
|
30
30
|
assert_equal(1, feature.number_of_geometries)
|
31
31
|
end
|
32
32
|
|
@@ -2,6 +2,8 @@ require "test_helper"
|
|
2
2
|
|
3
3
|
class TestMapnikGeometry < Test::Unit::TestCase
|
4
4
|
|
5
|
+
STATEMENT = "Geometry tests no longer valid. See https://github.com/mapnik/Ruby-Mapnik/issues/11"
|
6
|
+
|
5
7
|
def test_presence
|
6
8
|
assert Mapnik::GeometryType
|
7
9
|
assert Mapnik::Geometry2d
|
@@ -13,60 +15,72 @@ class TestMapnikGeometry < Test::Unit::TestCase
|
|
13
15
|
end
|
14
16
|
|
15
17
|
def test_should_make_point_from_wkt
|
16
|
-
|
17
|
-
|
18
|
-
assert_equal
|
19
|
-
assert_equal 30, point.envelope.
|
20
|
-
assert_equal
|
21
|
-
assert_equal 10, point.envelope.
|
22
|
-
assert_equal
|
18
|
+
omit(STATEMENT)
|
19
|
+
# point = Mapnik::Geometry2d.from_wkt("POINT(30 10)")
|
20
|
+
# assert_equal Mapnik::GeometryType::Point, point.type
|
21
|
+
# assert_equal 30, point.envelope.min_x
|
22
|
+
# assert_equal 30, point.envelope.max_x
|
23
|
+
# assert_equal 10, point.envelope.max_y
|
24
|
+
# assert_equal 10, point.envelope.min_y
|
25
|
+
# assert_equal 0, point.area
|
23
26
|
end
|
24
27
|
|
25
28
|
def test_should_make_linestring_from_wkt
|
26
|
-
|
27
|
-
|
28
|
-
assert_equal
|
29
|
-
assert_equal
|
30
|
-
assert_equal
|
31
|
-
assert_equal
|
29
|
+
omit(STATEMENT)
|
30
|
+
# linestring = Mapnik::Geometry2d.from_wkt("LINESTRING (29 11, 12 30, 41 40)")
|
31
|
+
# assert_equal Mapnik::GeometryType::LineString, linestring.type
|
32
|
+
# assert_equal 12, linestring.envelope.min_x
|
33
|
+
# assert_equal 41, linestring.envelope.max_x
|
34
|
+
# assert_equal 40, linestring.envelope.max_y
|
35
|
+
# assert_equal 11, linestring.envelope.min_y
|
32
36
|
# assert_equal 0, linestring.area -> Not sure what the correct value is here
|
33
37
|
end
|
34
38
|
|
35
39
|
def test_should_make_polygon_from_wkt
|
36
|
-
|
37
|
-
|
38
|
-
assert_equal
|
39
|
-
assert_equal
|
40
|
-
assert_equal 40, polygon.envelope.
|
41
|
-
assert_equal
|
40
|
+
omit(STATEMENT)
|
41
|
+
# polygon = Mapnik::Geometry2d.from_wkt("POLYGON ((30 10, 10 20, 20 40, 40 40, 30 10))")
|
42
|
+
# assert_equal Mapnik::GeometryType::Polygon, polygon.type
|
43
|
+
# assert_equal 10, polygon.envelope.min_x
|
44
|
+
# assert_equal 40, polygon.envelope.max_x
|
45
|
+
# assert_equal 40, polygon.envelope.max_y
|
46
|
+
# assert_equal 10, polygon.envelope.min_y
|
42
47
|
# assert_equal 0, polygon.area
|
43
48
|
end
|
44
49
|
|
45
50
|
def test_should_make_multipoint_from_wkt
|
46
|
-
|
47
|
-
|
48
|
-
assert_equal
|
49
|
-
assert_equal
|
50
|
-
assert_equal 40, multipoint.envelope.
|
51
|
-
assert_equal
|
51
|
+
omit(STATEMENT)
|
52
|
+
# multipoint = Mapnik::Geometry2d.from_wkt("MULTIPOINT (10 40, 40 30, 20 20, 30 10)")
|
53
|
+
# assert_equal Mapnik::GeometryType::MultiPoint, multipoint.type
|
54
|
+
# assert_equal 10, multipoint.envelope.min_x
|
55
|
+
# assert_equal 40, multipoint.envelope.max_x
|
56
|
+
# assert_equal 40, multipoint.envelope.max_y
|
57
|
+
# assert_equal 10, multipoint.envelope.min_y
|
52
58
|
end
|
53
59
|
|
54
60
|
def test_should_make_multilinestring_from_wkt
|
55
|
-
|
56
|
-
|
57
|
-
assert_equal
|
58
|
-
assert_equal
|
59
|
-
assert_equal 40, multi_line.envelope.
|
60
|
-
assert_equal
|
61
|
+
omit(STATEMENT)
|
62
|
+
# multi_line = Mapnik::Geometry2d.from_wkt("MULTILINESTRING ((10 10, 20 20, 10 40), (40 40, 30 30, 40 20, 30 10))")
|
63
|
+
# assert_equal Mapnik::GeometryType::MultiLineString, multi_line.type
|
64
|
+
# assert_equal 10, multi_line.envelope.min_x
|
65
|
+
# assert_equal 40, multi_line.envelope.max_x
|
66
|
+
# assert_equal 40, multi_line.envelope.max_y
|
67
|
+
# assert_equal 10, multi_line.envelope.min_y
|
61
68
|
end
|
62
69
|
|
63
70
|
def test_should_make_multipolygon_from_wkt
|
64
|
-
|
65
|
-
|
66
|
-
assert_equal
|
67
|
-
assert_equal
|
68
|
-
assert_equal
|
69
|
-
assert_equal
|
71
|
+
omit(STATEMENT)
|
72
|
+
# 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)))")
|
73
|
+
# assert_equal Mapnik::GeometryType::MultiPolygon, multi_polygon.type
|
74
|
+
# assert_equal 5, multi_polygon.envelope.min_x
|
75
|
+
# assert_equal 45, multi_polygon.envelope.max_x
|
76
|
+
# assert_equal 40, multi_polygon.envelope.max_y
|
77
|
+
# assert_equal 5, multi_polygon.envelope.min_y
|
70
78
|
end
|
79
|
+
|
80
|
+
private
|
71
81
|
|
82
|
+
def omit(str)
|
83
|
+
puts str
|
84
|
+
end
|
85
|
+
|
72
86
|
end
|
data/test/test_mapnik_map.rb
CHANGED
@@ -147,7 +147,8 @@ class TestMapnikMap < Test::Unit::TestCase
|
|
147
147
|
map = build_complete_map
|
148
148
|
filename = File.join(File.expand_path(File.dirname(__FILE__)), "../tmp/world.png")
|
149
149
|
assert_equal 0, File.size(filename) if File.exists?(filename)
|
150
|
-
map.render_to_file(filename)
|
150
|
+
assert map.render_to_file(filename)
|
151
|
+
assert File.exists?(filename)
|
151
152
|
File.delete(filename)
|
152
153
|
end
|
153
154
|
|
@@ -158,15 +159,23 @@ class TestMapnikMap < Test::Unit::TestCase
|
|
158
159
|
assert_equal map_1.srs, map_2.srs
|
159
160
|
end
|
160
161
|
|
161
|
-
def
|
162
|
+
def test_should_load_from_file_path_string
|
162
163
|
file_path = File.join(File.expand_path(File.dirname(__FILE__)), "data", "test_map.xml")
|
163
164
|
map = Mapnik::Map.from_file(file_path)
|
164
165
|
assert map.layers.any?
|
165
166
|
assert map.styles['My Style']
|
166
167
|
end
|
167
168
|
|
168
|
-
|
169
|
+
def test_should_load_from_file
|
170
|
+
file = File.open(File.join(File.expand_path(File.dirname(__FILE__)), "data", "test_map.xml"))
|
171
|
+
map = Mapnik::Map.from_file(file)
|
172
|
+
assert map.layers.any?
|
173
|
+
assert map.styles['My Style']
|
174
|
+
end
|
169
175
|
|
176
|
+
|
177
|
+
private
|
178
|
+
|
170
179
|
def build_complete_map
|
171
180
|
map = Mapnik::Map.new
|
172
181
|
map.width = 600
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_mapnik
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Elliot Laster
|
@@ -14,7 +15,7 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2011-
|
18
|
+
date: 2011-10-09 00:00:00 -04:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
@@ -64,9 +65,9 @@ dependencies:
|
|
64
65
|
version_requirements: *id003
|
65
66
|
description: |-
|
66
67
|
A set of bindings between Ruby and Mapnik. Supports many of the common uses for
|
67
|
-
Mapnik, and one day, might support
|
68
|
-
the
|
69
|
-
Mapnik has been compiled with Cairo support.
|
68
|
+
Mapnik, and one day, might support all of them. Rendering is available using
|
69
|
+
the standard AGG library, or additionally via Cairo, if the rcairo gem is
|
70
|
+
installed and Mapnik has been compiled with Cairo support.
|
70
71
|
email:
|
71
72
|
- elliotlaster@gmail.com
|
72
73
|
executables: []
|