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,32 @@
|
|
1
|
+
/*****************************************************************************
|
2
|
+
Copyright (C) 2011 Elliot Laster
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
5
|
+
this software and associated documentation files (the ‘Software’), to deal in
|
6
|
+
the Software without restriction, including without limitation the rights to
|
7
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
8
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
9
|
+
so, subject to the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be included in all
|
12
|
+
copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
20
|
+
SOFTWARE.
|
21
|
+
*****************************************************************************/
|
22
|
+
#ifndef PIKA2_MAPNIK_TEXT_SYMBOLIZER
|
23
|
+
#define PIKA2_MAPNIK_TEXT_SYMBOLIZER
|
24
|
+
|
25
|
+
namespace Rice
|
26
|
+
{
|
27
|
+
class Module;
|
28
|
+
}
|
29
|
+
|
30
|
+
void register_text_symbolizer(Rice::Module rb_mapnik);
|
31
|
+
|
32
|
+
#endif
|
@@ -0,0 +1,80 @@
|
|
1
|
+
=begin
|
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
|
+
=end
|
22
|
+
|
23
|
+
# Compile with Rice rather than straight mkmf
|
24
|
+
require 'rubygems'
|
25
|
+
require 'mkmf-rice'
|
26
|
+
|
27
|
+
# Add the arguments to the linker flags.
|
28
|
+
def append_ld_flags(flags)
|
29
|
+
flags = [flags] unless flags.is_a?(Array)
|
30
|
+
with_ldflags("#{$LDFLAGS} #{flags.join(' ')}") { true }
|
31
|
+
end
|
32
|
+
|
33
|
+
# Check for mapnik-config
|
34
|
+
if %x{which mapnik-config}.length == 0
|
35
|
+
abort("\n***\n mapnik-config is missing!\n Is mapnik 2.x installed?\n Is mapnik-config in your $PATH?\n***\n\n")
|
36
|
+
end
|
37
|
+
|
38
|
+
$LDFLAGS += " " + %x{mapnik-config --libs}.chomp + " "
|
39
|
+
|
40
|
+
# force whitespace padding to avoid: https://github.com/mapnik/Ruby-Mapnik/issues/7
|
41
|
+
$CFLAGS += " " + %x{mapnik-config --cflags}.chomp + " "
|
42
|
+
|
43
|
+
#------------------------------------------------------------------------------#
|
44
|
+
# Ruby-Mapnik configuration
|
45
|
+
#
|
46
|
+
# Creates a ruby file with the constants for the input and font paths.
|
47
|
+
#------------------------------------------------------------------------------#
|
48
|
+
input_plugin_path = %x{mapnik-config --input-plugins}.chomp
|
49
|
+
font_path = %x{mapnik-config --fonts}.chomp
|
50
|
+
ruby_mapnik_config = <<-EOF
|
51
|
+
# This file is generated by extconf.rb DO NOT MODIFY!
|
52
|
+
module Mapnik
|
53
|
+
INPUT_PLUGIN_PATH = '#{input_plugin_path}'
|
54
|
+
FONT_PATH = '#{font_path}'
|
55
|
+
end
|
56
|
+
EOF
|
57
|
+
|
58
|
+
mapnik_config_file_path = File.join(File.expand_path(File.dirname(__FILE__)), '..', '..', 'lib', 'ruby_mapnik_config.rb')
|
59
|
+
FileUtils.rm(mapnik_config_file_path) if File.exists?(mapnik_config_file_path)
|
60
|
+
File.open(mapnik_config_file_path, 'w+') do |file|
|
61
|
+
file.write(ruby_mapnik_config)
|
62
|
+
end
|
63
|
+
|
64
|
+
if ENV['CXX']
|
65
|
+
$CXX = ENV['CXX']
|
66
|
+
end
|
67
|
+
|
68
|
+
if RUBY_PLATFORM =~ /darwin/
|
69
|
+
# In order to link the shared library into our bundle with GCC 4.x on OSX, we have to work around a bug:
|
70
|
+
# GCC redefines symbols - which the -fno-common prohibits. In order to keep the -fno-common, we
|
71
|
+
# remove the flat_namespace (we now have two namespaces, which fixes the GCC clash). Also, we now lookup
|
72
|
+
# symbols in both the namespaces (dynamic_lookup).
|
73
|
+
|
74
|
+
$LDSHARED_CXX.gsub!('suppress', 'dynamic_lookup')
|
75
|
+
$LDSHARED_CXX.gsub!('-flat_namespace', '')
|
76
|
+
|
77
|
+
append_ld_flags '-all_load'
|
78
|
+
end
|
79
|
+
|
80
|
+
create_makefile("ruby_mapnik/ruby_mapnik")
|
@@ -0,0 +1,32 @@
|
|
1
|
+
/*****************************************************************************
|
2
|
+
Copyright (C) 2011 Elliot Laster
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
5
|
+
this software and associated documentation files (the ‘Software’), to deal in
|
6
|
+
the Software without restriction, including without limitation the rights to
|
7
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
8
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
9
|
+
so, subject to the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be included in all
|
12
|
+
copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
20
|
+
SOFTWARE.
|
21
|
+
*****************************************************************************/
|
22
|
+
#include <rice/Module.hpp>
|
23
|
+
#include "_mapnik.h"
|
24
|
+
#include <mapnik/config.hpp>
|
25
|
+
|
26
|
+
extern "C"
|
27
|
+
|
28
|
+
MAPNIK_DECL void Init_ruby_mapnik() {
|
29
|
+
RUBY_TRY {
|
30
|
+
register_mapnik();
|
31
|
+
} RUBY_CATCH
|
32
|
+
}
|
data/lib/mapnik.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require File.join(path = File.expand_path(File.dirname(__FILE__)), 'ruby_mapnik')
|
data/lib/ruby_mapnik.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
=begin
|
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
|
+
=end
|
22
|
+
require 'forwardable'
|
23
|
+
|
24
|
+
path = File.expand_path(File.dirname(__FILE__))
|
25
|
+
|
26
|
+
require "#{path}/ruby_mapnik_config"
|
27
|
+
require "#{path}/ruby_mapnik/ruby_mapnik"
|
28
|
+
require "#{path}/ruby_mapnik/mapnik/rule"
|
29
|
+
require "#{path}/ruby_mapnik/mapnik/style"
|
30
|
+
require "#{path}/ruby_mapnik/mapnik/layer"
|
31
|
+
require "#{path}/ruby_mapnik/mapnik/map"
|
32
|
+
require "#{path}/ruby_mapnik/mapnik/stroke"
|
33
|
+
require "#{path}/ruby_mapnik/mapnik/projection"
|
34
|
+
require "#{path}/ruby_mapnik/mapnik/font_engine"
|
35
|
+
require "#{path}/ruby_mapnik/mapnik/raster_colorizer"
|
36
|
+
require "#{path}/ruby_mapnik/mapnik/tile"
|
37
|
+
|
38
|
+
|
39
|
+
module Mapnik
|
40
|
+
VERSION = '0.2.0'
|
41
|
+
|
42
|
+
FontEngine.register_fonts(FONT_PATH)
|
43
|
+
DatasourceCache.register(INPUT_PLUGIN_PATH)
|
44
|
+
|
45
|
+
if DatasourceCache.available_plugins.empty?
|
46
|
+
puts "RUBY-MAPNIK WARNING: No datasource plugins were found!"
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
=begin
|
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
|
+
=end
|
22
|
+
module Mapnik
|
23
|
+
|
24
|
+
class FontEngine
|
25
|
+
|
26
|
+
DEFAULT_VALID_EXTENSIONS = ['ttf','otf','ttc','pfa','pfb','ttc','dfont']
|
27
|
+
|
28
|
+
def self.register_fonts(path, valid_extensions = DEFAULT_VALID_EXTENSIONS)
|
29
|
+
file_names = Dir.glob(File.join("#{path}", "**", "*.{#{valid_extensions.join(',')}}"))
|
30
|
+
file_names.each{|filename| register_font(filename)}
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
=begin
|
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
|
+
=end
|
22
|
+
module Mapnik
|
23
|
+
|
24
|
+
class LayerStyleContainer
|
25
|
+
|
26
|
+
extend Forwardable
|
27
|
+
|
28
|
+
def_delegators :@collection, :empty?, :any?, :length, :first, :[], :count, :each, :map
|
29
|
+
|
30
|
+
def initialize(collection)
|
31
|
+
@collection = collection
|
32
|
+
end
|
33
|
+
|
34
|
+
def layer=(layer)
|
35
|
+
@layer = layer
|
36
|
+
end
|
37
|
+
|
38
|
+
def <<(object)
|
39
|
+
@layer.send(:__append_style__, object)
|
40
|
+
@collection << object
|
41
|
+
end
|
42
|
+
|
43
|
+
alias :push :<<
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
class Layer
|
48
|
+
|
49
|
+
attr_writer :map
|
50
|
+
|
51
|
+
def style(override_style_name = nil)
|
52
|
+
style_name = override_style_name || name
|
53
|
+
style = Mapnik::Style.new
|
54
|
+
yield style
|
55
|
+
@map.styles[style_name] = style
|
56
|
+
styles << style_name
|
57
|
+
end
|
58
|
+
|
59
|
+
def styles
|
60
|
+
styles = LayerStyleContainer.new(__style_list__)
|
61
|
+
styles.layer = self
|
62
|
+
styles
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
@@ -0,0 +1,166 @@
|
|
1
|
+
=begin
|
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
|
+
=end
|
22
|
+
module Mapnik
|
23
|
+
|
24
|
+
class MapStyleContainer < Hash
|
25
|
+
|
26
|
+
def map=(map)
|
27
|
+
@map = map
|
28
|
+
end
|
29
|
+
|
30
|
+
def []=(key, object)
|
31
|
+
@map.send(:__insert_style__, key, object)
|
32
|
+
super(key, object)
|
33
|
+
end
|
34
|
+
|
35
|
+
def delete(key)
|
36
|
+
@map.send(:__remove_style__, key)
|
37
|
+
super(key)
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
class MapLayerContainer
|
43
|
+
|
44
|
+
extend Forwardable
|
45
|
+
|
46
|
+
def_delegators :@collection, :empty?, :any?, :length, :first, :[], :count, :each, :map
|
47
|
+
|
48
|
+
def initialize(collection)
|
49
|
+
@collection = collection
|
50
|
+
end
|
51
|
+
|
52
|
+
def <<(object)
|
53
|
+
@map.send(:__add_layer__, object)
|
54
|
+
@collection << (object)
|
55
|
+
end
|
56
|
+
|
57
|
+
alias :push :<<
|
58
|
+
|
59
|
+
def clear
|
60
|
+
(0..length-1).each{|index| remove_object_at_index(index)}
|
61
|
+
@collection.clear
|
62
|
+
end
|
63
|
+
|
64
|
+
def delete_at(index)
|
65
|
+
remove_object_at_index(index)
|
66
|
+
@collection.delete_at(index)
|
67
|
+
end
|
68
|
+
|
69
|
+
def map=(map)
|
70
|
+
@map = map
|
71
|
+
end
|
72
|
+
|
73
|
+
def pop
|
74
|
+
delete_at(length - 1) unless length.zero?
|
75
|
+
end
|
76
|
+
|
77
|
+
private
|
78
|
+
|
79
|
+
def remove_object_at_index(index)
|
80
|
+
@map.send(:__remove_layer__, index)
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
class Map
|
86
|
+
|
87
|
+
class << self
|
88
|
+
|
89
|
+
# Loads a map from an xml string.
|
90
|
+
# @return [Mapnik::Map]
|
91
|
+
def from_xml(xml, strict = false, base_path = "")
|
92
|
+
map = new
|
93
|
+
__load_map_string__(map, xml, strict, base_path)
|
94
|
+
map
|
95
|
+
end
|
96
|
+
|
97
|
+
# Loads a map from an xml file.
|
98
|
+
# @return [Mapnik::Map]
|
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
|
106
|
+
map = new
|
107
|
+
__load_map__(map, path, strict)
|
108
|
+
map
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
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.
|
116
|
+
# @return [Mapnik::Style]
|
117
|
+
def style(name)
|
118
|
+
style = Mapnik::Style.new
|
119
|
+
yield style
|
120
|
+
styles[name] = style
|
121
|
+
end
|
122
|
+
|
123
|
+
# The styles for this map.
|
124
|
+
# @return [Mapnik::StyleContainer]
|
125
|
+
def styles
|
126
|
+
styles = MapStyleContainer[__styles__]
|
127
|
+
styles.map = self
|
128
|
+
styles
|
129
|
+
end
|
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.
|
134
|
+
# @return [Mapnik::Layer]
|
135
|
+
def layer(name, srs = nil)
|
136
|
+
layer = Mapnik::Layer.new(name, srs)
|
137
|
+
layer.map = self
|
138
|
+
yield layer
|
139
|
+
layers << layer
|
140
|
+
end
|
141
|
+
|
142
|
+
# The layers associated with this map
|
143
|
+
# @return [Mapnik::MapLayerContainer]
|
144
|
+
def layers
|
145
|
+
layers = MapLayerContainer.new(__layers__)
|
146
|
+
layers.map = self
|
147
|
+
layers
|
148
|
+
end
|
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" if format not specified
|
153
|
+
# @param [String] format Should be one of formats supported by Mapnik or nil (to be guessed from filename)
|
154
|
+
# @return [Boolean]
|
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
|
161
|
+
return File.exists?(filename)
|
162
|
+
end
|
163
|
+
|
164
|
+
end
|
165
|
+
|
166
|
+
end
|