ffi-geos 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +14 -3
- data/VERSION +1 -1
- data/ffi-geos.gemspec +6 -3
- data/lib/ffi-geos.rb +14 -10
- data/lib/ffi-geos/polygon.rb +6 -0
- data/lib/ffi-geos/utils.rb +4 -0
- data/test/geometry_tests.rb +36 -1
- data/test/test_helper.rb +2 -1
- data/test/utils_tests.rb +6 -0
- metadata +15 -4
data/Rakefile
CHANGED
@@ -2,9 +2,20 @@
|
|
2
2
|
# -*- ruby -*-
|
3
3
|
|
4
4
|
require 'rubygems'
|
5
|
+
|
6
|
+
gem 'rdoc', '~> 3.12'
|
7
|
+
|
5
8
|
require 'rubygems/package_task'
|
6
9
|
require 'rake/testtask'
|
7
|
-
require '
|
10
|
+
require 'rdoc/task'
|
11
|
+
|
12
|
+
if RUBY_VERSION >= '1.9'
|
13
|
+
begin
|
14
|
+
gem 'psych'
|
15
|
+
rescue Exception => e
|
16
|
+
# it's okay, fall back on the bundled psych
|
17
|
+
end
|
18
|
+
end
|
8
19
|
|
9
20
|
$:.push 'lib'
|
10
21
|
|
@@ -19,6 +30,7 @@ begin
|
|
19
30
|
gem.email = "dark.panda@gmail.com"
|
20
31
|
gem.homepage = "http://github.com/dark-panda/ffi-geos"
|
21
32
|
gem.authors = [ "J Smith" ]
|
33
|
+
gem.add_dependency "ffi", "~> 1.0.0"
|
22
34
|
end
|
23
35
|
Jeweler::GemcutterTasks.new
|
24
36
|
rescue LoadError
|
@@ -27,13 +39,12 @@ end
|
|
27
39
|
|
28
40
|
desc 'Test GEOS interface'
|
29
41
|
Rake::TestTask.new(:test) do |t|
|
30
|
-
t.
|
42
|
+
t.test_files = FileList['test/**/*_tests.rb']
|
31
43
|
t.verbose = !!ENV['VERBOSE_TESTS']
|
32
44
|
end
|
33
45
|
|
34
46
|
desc 'Build docs'
|
35
47
|
Rake::RDocTask.new do |t|
|
36
|
-
require 'rdoc'
|
37
48
|
t.title = "ffi-geos #{version}"
|
38
49
|
t.main = 'README.rdoc'
|
39
50
|
t.rdoc_dir = 'doc'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.4
|
data/ffi-geos.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{ffi-geos}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = [%q{J Smith}]
|
12
|
-
s.date = %q{
|
12
|
+
s.date = %q{2012-02-28}
|
13
13
|
s.description = %q{An ffi wrapper for GEOS, a C++ port of the Java Topology Suite (JTS).}
|
14
14
|
s.email = %q{dark.panda@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -56,16 +56,19 @@ Gem::Specification.new do |s|
|
|
56
56
|
]
|
57
57
|
s.homepage = %q{http://github.com/dark-panda/ffi-geos}
|
58
58
|
s.require_paths = [%q{lib}]
|
59
|
-
s.rubygems_version = %q{1.8.
|
59
|
+
s.rubygems_version = %q{1.8.9}
|
60
60
|
s.summary = %q{An ffi wrapper for GEOS, a C++ port of the Java Topology Suite (JTS).}
|
61
61
|
|
62
62
|
if s.respond_to? :specification_version then
|
63
63
|
s.specification_version = 3
|
64
64
|
|
65
65
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
66
|
+
s.add_runtime_dependency(%q<ffi>, ["~> 1.0.0"])
|
66
67
|
else
|
68
|
+
s.add_dependency(%q<ffi>, ["~> 1.0.0"])
|
67
69
|
end
|
68
70
|
else
|
71
|
+
s.add_dependency(%q<ffi>, ["~> 1.0.0"])
|
69
72
|
end
|
70
73
|
end
|
71
74
|
|
data/lib/ffi-geos.rb
CHANGED
@@ -58,24 +58,27 @@ module Geos
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def self.find_lib(lib)
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
}.flatten.sort.compact.first
|
61
|
+
Dir.glob(search_paths.map { |path|
|
62
|
+
File.expand_path(File.join(path, "#{lib}.#{FFI::Platform::LIBSUFFIX}"))
|
63
|
+
}).first
|
65
64
|
end
|
66
65
|
|
67
|
-
def self.
|
68
|
-
@
|
66
|
+
def self.geos_library_path
|
67
|
+
@geos_library_path ||= begin
|
69
68
|
# On MingW the libraries have version numbers
|
70
|
-
|
71
|
-
find_lib(lib)
|
72
|
-
}.compact
|
69
|
+
find_lib('libgeos_c{,-?}')
|
73
70
|
end
|
74
71
|
end
|
75
72
|
|
73
|
+
# For backwards compatibility with older ffi-geos versions where this
|
74
|
+
# used to return an Array.
|
75
|
+
def self.geos_library_paths
|
76
|
+
[ self.geos_library_path ]
|
77
|
+
end
|
78
|
+
|
76
79
|
extend ::FFI::Library
|
77
80
|
|
78
|
-
ffi_lib(
|
81
|
+
ffi_lib(geos_library_path)
|
79
82
|
|
80
83
|
Geos::DimensionTypes = enum(:dimension_type, [
|
81
84
|
:dontcare, -3,
|
@@ -1004,6 +1007,7 @@ module Geos
|
|
1004
1007
|
create_empty_multi_polygon
|
1005
1008
|
create_empty_geometry_collection
|
1006
1009
|
create_empty_collection
|
1010
|
+
create_empty_linear_ring
|
1007
1011
|
}.each do |m|
|
1008
1012
|
self.class_eval <<-EOF
|
1009
1013
|
def #{m}(*args)
|
data/lib/ffi-geos/polygon.rb
CHANGED
@@ -16,5 +16,11 @@ module Geos
|
|
16
16
|
def exterior_ring
|
17
17
|
cast_geometry_ptr(FFIGeos.GEOSGetExteriorRing_r(Geos.current_handle, self.ptr), false)
|
18
18
|
end
|
19
|
+
|
20
|
+
def interior_rings
|
21
|
+
self.num_interior_rings.times.collect do |n|
|
22
|
+
self.interior_ring_n(n)
|
23
|
+
end
|
24
|
+
end
|
19
25
|
end
|
20
26
|
end
|
data/lib/ffi-geos/utils.rb
CHANGED
@@ -113,6 +113,10 @@ module Geos
|
|
113
113
|
create_empty_collection(:geometry_collection)
|
114
114
|
end
|
115
115
|
|
116
|
+
def create_empty_linear_ring
|
117
|
+
Geos::WktReader.new.read('LINEARRING EMPTY')
|
118
|
+
end
|
119
|
+
|
116
120
|
def create_collection(t, *geoms)
|
117
121
|
check_enum_value(Geos::GeometryTypes, t)
|
118
122
|
|
data/test/geometry_tests.rb
CHANGED
@@ -1005,6 +1005,41 @@ class GeometryTests < Test::Unit::TestCase
|
|
1005
1005
|
end
|
1006
1006
|
end
|
1007
1007
|
|
1008
|
+
def test_interior_rings
|
1009
|
+
tester = lambda { |expected, g|
|
1010
|
+
geom = read(g)
|
1011
|
+
result = geom.interior_rings
|
1012
|
+
|
1013
|
+
if expected.nil?
|
1014
|
+
assert_nil(result)
|
1015
|
+
else
|
1016
|
+
assert_equal(expected, result.collect { |r| write(r) } )
|
1017
|
+
end
|
1018
|
+
}
|
1019
|
+
|
1020
|
+
writer.trim = true
|
1021
|
+
|
1022
|
+
tester[
|
1023
|
+
[ 'LINEARRING (11 11, 11 12, 12 12, 12 11, 11 11)' ],
|
1024
|
+
'POLYGON(
|
1025
|
+
(10 10, 10 14, 14 14, 14 10, 10 10),
|
1026
|
+
(11 11, 11 12, 12 12, 12 11, 11 11)
|
1027
|
+
)'
|
1028
|
+
]
|
1029
|
+
|
1030
|
+
tester[
|
1031
|
+
[
|
1032
|
+
'LINEARRING (11 11, 11 12, 12 12, 12 11, 11 11)',
|
1033
|
+
'LINEARRING (13 11, 13 12, 13.5 12, 13.5 11, 13 11)'
|
1034
|
+
],
|
1035
|
+
'POLYGON (
|
1036
|
+
(10 10, 10 14, 14 14, 14 10, 10 10),
|
1037
|
+
(11 11, 11 12, 12 12, 12 11, 11 11),
|
1038
|
+
(13 11, 13 12, 13.5 12, 13.5 11, 13 11)
|
1039
|
+
)'
|
1040
|
+
]
|
1041
|
+
end
|
1042
|
+
|
1008
1043
|
if ENV['FORCE_TESTS'] || Geos::Geometry.method_defined?(:num_coordinates)
|
1009
1044
|
def test_num_coordinates
|
1010
1045
|
tester = lambda { |expected, g|
|
@@ -1033,7 +1068,7 @@ class GeometryTests < Test::Unit::TestCase
|
|
1033
1068
|
POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0)),
|
1034
1069
|
MULTILINESTRING ((0 0, 2 3), (10 10, 3 4)),
|
1035
1070
|
LINESTRING (0 0, 2 3),
|
1036
|
-
MULTIPOINT (0 0, 2 3),
|
1071
|
+
MULTIPOINT ((0 0), (2 3)),
|
1037
1072
|
POINT (9 0)
|
1038
1073
|
)']
|
1039
1074
|
end
|
data/test/test_helper.rb
CHANGED
@@ -9,10 +9,11 @@ else
|
|
9
9
|
end
|
10
10
|
|
11
11
|
puts "Ruby version #{RUBY_VERSION} - #{RbConfig::CONFIG['RUBY_INSTALL_NAME']}"
|
12
|
+
puts "ffi version #{Gem.loaded_specs['ffi'].version}" if Gem.loaded_specs['ffi']
|
12
13
|
puts "GEOS version #{Geos::GEOS_VERSION}"
|
13
14
|
puts "ffi-geos version #{Geos::VERSION}" if defined?(Geos::VERSION)
|
14
15
|
if defined?(Geos::FFIGeos)
|
15
|
-
puts "Using #{Geos::FFIGeos.
|
16
|
+
puts "Using #{Geos::FFIGeos.geos_library_path}"
|
16
17
|
end
|
17
18
|
|
18
19
|
module TestHelper
|
data/test/utils_tests.rb
CHANGED
@@ -340,4 +340,10 @@ class UtilsTests < Test::Unit::TestCase
|
|
340
340
|
assert_equal('GEOMETRYCOLLECTION EMPTY', write(Geos.create_empty_geometry_collection))
|
341
341
|
end
|
342
342
|
end
|
343
|
+
|
344
|
+
if ENV['FORCE_TESTS'] || Geos.respond_to?(:create_empty_linear_ring)
|
345
|
+
def test_create_empty_linear_ring
|
346
|
+
assert_equal('LINEARRING EMPTY', write(Geos.create_empty_linear_ring))
|
347
|
+
end
|
348
|
+
end
|
343
349
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ffi-geos
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,8 +9,19 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
13
|
-
dependencies:
|
12
|
+
date: 2012-02-28 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: ffi
|
16
|
+
requirement: &2169057720 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.0.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *2169057720
|
14
25
|
description: An ffi wrapper for GEOS, a C++ port of the Java Topology Suite (JTS).
|
15
26
|
email: dark.panda@gmail.com
|
16
27
|
executables: []
|
@@ -75,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
75
86
|
version: '0'
|
76
87
|
requirements: []
|
77
88
|
rubyforge_project:
|
78
|
-
rubygems_version: 1.8.
|
89
|
+
rubygems_version: 1.8.16
|
79
90
|
signing_key:
|
80
91
|
specification_version: 3
|
81
92
|
summary: An ffi wrapper for GEOS, a C++ port of the Java Topology Suite (JTS).
|