simple_mapnik 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1 @@
1
+ PROJCS["Google Maps Global Mercator",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Mercator_2SP"],PARAMETER["standard_parallel_1",0],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",0],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["Meter",1]]
Binary file
Binary file
@@ -0,0 +1,85 @@
1
+ world_merc
2
+ ==========
3
+
4
+ 'world_merc.shp' is a version of TM_WORLD_BORDERS_SIMPL-0.3.shp
5
+ downloaded from http://thematicmapping.org/downloads/world_borders.php.
6
+
7
+ Coodinates near 180 degress longitude were clipped to faciliate reprojection
8
+ to Google mercator (EPSG:900913).
9
+
10
+ Details from original readme are below:
11
+
12
+ -------------
13
+
14
+ TM_WORLD_BORDERS-0.1.ZIP
15
+
16
+ Provided by Bjorn Sandvik, thematicmapping.org
17
+
18
+ Use this dataset with care, as several of the borders are disputed.
19
+
20
+ The original shapefile (world_borders.zip, 3.2 MB) was downloaded from the Mapping Hacks website:
21
+ http://www.mappinghacks.com/data/
22
+
23
+ The dataset was derived by Schuyler Erle from public domain sources.
24
+ Sean Gilles did some clean up and made some enhancements.
25
+
26
+
27
+ COLUMN TYPE DESCRIPTION
28
+
29
+ Shape Polygon Country/area border as polygon(s)
30
+ FIPS String(2) FIPS 10-4 Country Code
31
+ ISO2 String(2) ISO 3166-1 Alpha-2 Country Code
32
+ ISO3 String(3) ISO 3166-1 Alpha-3 Country Code
33
+ UN Short Integer(3) ISO 3166-1 Numeric-3 Country Code
34
+ NAME String(50) Name of country/area
35
+ AREA Long Integer(7) Land area, FAO Statistics (2002)
36
+ POP2005 Double(10,0) Population, World Polulation Prospects (2005)
37
+ REGION Short Integer(3) Macro geographical (continental region), UN Statistics
38
+ SUBREGION Short Integer(3) Geogrpahical sub-region, UN Statistics
39
+ LON FLOAT (7,3) Longitude
40
+ LAT FLOAT (6,3) Latitude
41
+
42
+
43
+ CHANGELOG VERSION 0.3 - 30 July 2008
44
+
45
+ - Corrected spelling mistake (United Arab Emirates)
46
+ - Corrected population number for Japan
47
+ - Adjusted long/lat values for India, Italy and United Kingdom
48
+
49
+
50
+ CHANGELOG VERSION 0.2 - 1 April 2008
51
+
52
+ - Made new ZIP archieves. No change in dataset.
53
+
54
+
55
+ CHANGELOG VERSION 0.1 - 13 March 2008
56
+
57
+ - Polygons representing each country were merged into one feature
58
+ - ≈land Islands was extracted from Finland
59
+ - Hong Kong was extracted from China
60
+ - Holy See (Vatican City) was added
61
+ - Gaza Strip and West Bank was merged into "Occupied Palestinean Territory"
62
+ - Saint-Barthelemy was extracted from Netherlands Antilles
63
+ - Saint-Martin (Frensh part) was extracted from Guadeloupe
64
+ - Svalbard and Jan Mayen was merged into "Svalbard and Jan Mayen Islands"
65
+ - Timor-Leste was extracted from Indonesia
66
+ - Juan De Nova Island was merged with "French Southern & Antarctic Land"
67
+ - Baker Island, Howland Island, Jarvis Island, Johnston Atoll, Midway Islands
68
+ and Wake Island was merged into "United States Minor Outlying Islands"
69
+ - Glorioso Islands, Parcel Islands, Spartly Islands was removed
70
+ (almost uninhabited and missing ISO-3611-1 code)
71
+
72
+ - Added ISO-3166-1 codes (alpha-2, alpha-3, numeric-3). Source:
73
+ https://www.cia.gov/library/publications/the-world-factbook/appendix/appendix-d.html
74
+ http://unstats.un.org/unsd/methods/m49/m49alpha.htm
75
+ http://www.fysh.org/~katie/development/geography.txt
76
+ - AREA column has been replaced with data from UNdata:
77
+ Land area, 1000 hectares, 2002, FAO Statistics
78
+ - POPULATION column (POP2005) has been replaced with data from UNdata:
79
+ Population, 2005, Medium variant, World Population Prospects: The 2006 Revision
80
+ - Added region and sub-region codes from UN Statistics Division. Source:
81
+ http://unstats.un.org/unsd/methods/m49/m49regin.htm
82
+ - Added LAT, LONG values for each country
83
+
84
+
85
+
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ describe SimpleMapnik::Api do
4
+ let(:output_dir) { './tmp/' }
5
+ let(:lib_path) { File.expand_path(File.join(output_dir, subject.lib)) }
6
+
7
+ subject { described_class.new(output_dir) }
8
+
9
+ describe '#check_and_install' do
10
+ context 'with an existing mapnik c api library' do
11
+ it 'does not compile and install the library' do
12
+ allow(File).to receive(:exist?).and_return(true)
13
+ expect(subject).not_to receive(:install)
14
+ subject.check_and_install
15
+ end
16
+ end
17
+
18
+ context 'without an existing mapnik c api library' do
19
+ after do
20
+ File.delete(lib_path) if File.exist? lib_path
21
+ end
22
+ it 'compiles and installs the library' do
23
+ expect { subject.check_and_install }
24
+ .to change { File.exist?(lib_path) }
25
+ .from(false).to(true)
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe SimpleMapnik::Bounds do
4
+ subject { described_class.new(-180, -90, 180, 90) }
5
+
6
+ context 'with initial bounding values' do
7
+ it 'returns an auto pointer' do
8
+ expect(subject.ptr).to be_a(FFI::AutoPointer)
9
+ end
10
+ end
11
+
12
+ describe '#free' do
13
+ it 'calls mapnik_map_free method' do
14
+ expect(subject).to receive(:mapnik_bbox_free)
15
+ subject.free
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe SimpleMapnik::Coordinate do
4
+ subject { described_class.new(-100, 100) }
5
+
6
+ context 'with initial x y values' do
7
+ it 'returns a memory pointer' do
8
+ expect(subject.ptr).to be_a(FFI::MemoryPointer)
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,58 @@
1
+ require 'spec_helper'
2
+
3
+ describe SimpleMapnik::Map do
4
+ let(:datasources) { '/usr/local/lib/mapnik/input' }
5
+ let(:stylesheet) { './spec/fixtures/sample/stylesheet.xml' }
6
+ let(:out_file) { './tmp/test.png' }
7
+
8
+ subject { described_class.new(256, 256) }
9
+
10
+ before do
11
+ SimpleMapnik.register_datasources '/usr/local/lib/mapnik/input'
12
+ end
13
+
14
+ after(:each) do
15
+ File.delete(out_file) if File.exist? out_file
16
+ end
17
+
18
+ context 'with an xml stylesheet' do
19
+ it 'renders a shapefile into an image' do
20
+ subject.load(stylesheet)
21
+ subject.zoom_all
22
+ expect { subject.to_file(out_file) }
23
+ .to change { File.exist?(out_file) }
24
+ .from(false).to(true)
25
+ end
26
+ end
27
+
28
+ describe '#zoom_to' do
29
+ let(:bounds) { double }
30
+ let(:ptr) { double }
31
+ it 'calls mapnik_map_zoom_to_box method' do
32
+ allow(bounds).to receive(:ptr).and_return(ptr)
33
+ expect(subject).to receive(:mapnik_map_zoom_to_box)
34
+ subject.zoom_to(bounds)
35
+ end
36
+ end
37
+
38
+ describe '#to_image' do
39
+ it 'calls mapnik_map_render_to_image method' do
40
+ expect(subject).to receive(:mapnik_map_render_to_image)
41
+ subject.to_image
42
+ end
43
+ end
44
+
45
+ describe '#to_png' do
46
+ it 'calls mapnik_image_to_png_blob method' do
47
+ expect(subject).to receive(:mapnik_image_to_png_blob)
48
+ subject.to_png
49
+ end
50
+ end
51
+
52
+ describe '#free' do
53
+ it 'calls mapnik_map_free method' do
54
+ expect(subject).to receive(:mapnik_map_free)
55
+ subject.free
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ describe SimpleMapnik do
4
+ describe '#error_ptr' do
5
+ it 'returns an error pointer' do
6
+ expect(described_class.error_ptr).to be_a(FFI::MemoryPointer)
7
+ end
8
+ end
9
+
10
+ describe '#register_fonts' do
11
+ let(:fonts) { double }
12
+ it 'calls mapnik_register_fonts method' do
13
+ expect(SimpleMapnik::FFI).to receive(:mapnik_register_fonts)
14
+ described_class.register_fonts(fonts)
15
+ end
16
+ end
17
+
18
+ context 'with no mapnik c api library' do
19
+ it 'raises a load error' do
20
+ allow(SimpleMapnik::FFI).to receive(:mapnik_c_api_path).and_return(nil)
21
+ expect { SimpleMapnik::FFI.attach_functions }.to raise_error(LoadError)
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,45 @@
1
+ require 'simplecov'
2
+
3
+ if ENV['CI']
4
+ require 'coveralls'
5
+ SimpleCov.formatter = Coveralls::SimpleCov::Formatter
6
+ end
7
+
8
+ if ENV['COVERAGE'] || ENV['CI']
9
+ SimpleCov.start do
10
+ add_filter '/spec'
11
+ add_filter '/lib/simple_mapnik/version.rb'
12
+ end
13
+ end
14
+
15
+ require 'simple_mapnik/api'
16
+ require 'ffi'
17
+
18
+ # Check if c api lib exists, and compile if not.
19
+ SimpleMapnik::Api.new.check_and_install
20
+
21
+ # Require all simple mapnik modules. They need the c api lib,
22
+ # so this must happen after a check is done and the lib is compiled.
23
+ require 'simple_mapnik'
24
+
25
+ RSpec.configure do |config|
26
+ config.expect_with :rspec do |expectations|
27
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
28
+ end
29
+
30
+ config.mock_with :rspec do |mocks|
31
+ mocks.verify_partial_doubles = true
32
+ end
33
+
34
+ # Create a temp directory before running tests.
35
+ config.before(:suite) do
36
+ tmp = File.expand_path(File.join('.', 'tmp'))
37
+ Dir.mkdir(tmp) unless Dir.exist? tmp
38
+ end
39
+
40
+ # Delete the temp directory after running tests.
41
+ config.after(:suite) do
42
+ tmp = File.expand_path(File.join('.', 'tmp'))
43
+ FileUtils.rm_rf(tmp) if Dir.exist? tmp
44
+ end
45
+ end
metadata ADDED
@@ -0,0 +1,220 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: simple_mapnik
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Eliot Jordan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-05-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ffi
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.9.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.9.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rubyzip
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 1.2.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 1.2.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.39'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.39'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop-rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 1.4.1
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 1.4.1
97
+ - !ruby/object:Gem::Dependency
98
+ name: simplecov
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: coveralls
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: bundler
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '1.12'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '1.12'
139
+ description: Simple FFI wrapper for Mapnik
140
+ email:
141
+ - eliotj@princeton.edu
142
+ executables:
143
+ - mapnik_console
144
+ extensions:
145
+ - Rakefile
146
+ extra_rdoc_files: []
147
+ files:
148
+ - ".gitignore"
149
+ - ".rspec"
150
+ - ".rubocop.yml"
151
+ - ".travis.yml"
152
+ - Gemfile
153
+ - LICENSE
154
+ - LICENSE-ffi-mapnik
155
+ - README.md
156
+ - Rakefile
157
+ - bin/mapnik_console
158
+ - coveralls.yml
159
+ - lib/simple_mapnik.rb
160
+ - lib/simple_mapnik/api.rb
161
+ - lib/simple_mapnik/bounds.rb
162
+ - lib/simple_mapnik/coordinate.rb
163
+ - lib/simple_mapnik/map.rb
164
+ - lib/simple_mapnik/version.rb
165
+ - simple_mapnik.gemspec
166
+ - spec/fixtures/sample/missing_attribute.xml
167
+ - spec/fixtures/sample/stylesheet.xml
168
+ - spec/fixtures/sample/world_merc.dbf
169
+ - spec/fixtures/sample/world_merc.index
170
+ - spec/fixtures/sample/world_merc.json
171
+ - spec/fixtures/sample/world_merc.prj
172
+ - spec/fixtures/sample/world_merc.shp
173
+ - spec/fixtures/sample/world_merc.shx
174
+ - spec/fixtures/sample/world_merc_license.txt
175
+ - spec/lib/simple_mapnik/api_spec.rb
176
+ - spec/lib/simple_mapnik/bounds_spec.rb
177
+ - spec/lib/simple_mapnik/coordinate_spec.rb
178
+ - spec/lib/simple_mapnik/map_spec.rb
179
+ - spec/lib/simple_mapnik_spec.rb
180
+ - spec/spec_helper.rb
181
+ homepage: https://github.com/geoconcerns/simple_mapnik
182
+ licenses:
183
+ - MIT
184
+ metadata: {}
185
+ post_install_message:
186
+ rdoc_options: []
187
+ require_paths:
188
+ - lib
189
+ required_ruby_version: !ruby/object:Gem::Requirement
190
+ requirements:
191
+ - - ">="
192
+ - !ruby/object:Gem::Version
193
+ version: '0'
194
+ required_rubygems_version: !ruby/object:Gem::Requirement
195
+ requirements:
196
+ - - ">="
197
+ - !ruby/object:Gem::Version
198
+ version: '0'
199
+ requirements: []
200
+ rubyforge_project:
201
+ rubygems_version: 2.4.5
202
+ signing_key:
203
+ specification_version: 4
204
+ summary: Simple access to Mapnik library from Ruby
205
+ test_files:
206
+ - spec/fixtures/sample/missing_attribute.xml
207
+ - spec/fixtures/sample/stylesheet.xml
208
+ - spec/fixtures/sample/world_merc.dbf
209
+ - spec/fixtures/sample/world_merc.index
210
+ - spec/fixtures/sample/world_merc.json
211
+ - spec/fixtures/sample/world_merc.prj
212
+ - spec/fixtures/sample/world_merc.shp
213
+ - spec/fixtures/sample/world_merc.shx
214
+ - spec/fixtures/sample/world_merc_license.txt
215
+ - spec/lib/simple_mapnik/api_spec.rb
216
+ - spec/lib/simple_mapnik/bounds_spec.rb
217
+ - spec/lib/simple_mapnik/coordinate_spec.rb
218
+ - spec/lib/simple_mapnik/map_spec.rb
219
+ - spec/lib/simple_mapnik_spec.rb
220
+ - spec/spec_helper.rb