ffi-geos 0.0.2 → 0.0.3
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 +3 -0
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/ffi-geos.gemspec +5 -5
- data/lib/ffi-geos.rb +23 -20
- data/lib/ffi-geos/coordinate_sequence.rb +14 -0
- data/lib/ffi-geos/geometry.rb +3 -0
- data/test/coordinate_sequence_tests.rb +21 -0
- data/test/geometry_tests.rb +19 -0
- metadata +3 -5
data/README.rdoc
CHANGED
@@ -146,3 +146,6 @@ Ruby bindings along with the following enhancements and additions:
|
|
146
146
|
* Christopher Meiklejohn for the bug reporting and PreparedGeometry fix.
|
147
147
|
|
148
148
|
* Wayne Meissner for some help with some ffi issues.
|
149
|
+
|
150
|
+
* Charlie Savage for the original SWIG-based GEOS bindings implementation and
|
151
|
+
some fixes for MinGW.
|
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
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.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = [
|
12
|
-
s.date = %q{2011-
|
11
|
+
s.authors = [%q{J Smith}]
|
12
|
+
s.date = %q{2011-08-22}
|
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 = [
|
@@ -55,8 +55,8 @@ Gem::Specification.new do |s|
|
|
55
55
|
"test/wkt_writer_tests.rb"
|
56
56
|
]
|
57
57
|
s.homepage = %q{http://github.com/dark-panda/ffi-geos}
|
58
|
-
s.require_paths = [
|
59
|
-
s.rubygems_version = %q{1.
|
58
|
+
s.require_paths = [%q{lib}]
|
59
|
+
s.rubygems_version = %q{1.8.8}
|
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
|
data/lib/ffi-geos.rb
CHANGED
@@ -45,29 +45,32 @@ module Geos
|
|
45
45
|
File.join(GEOS_BASE, 'utils')
|
46
46
|
|
47
47
|
module FFIGeos
|
48
|
-
def self.
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
48
|
+
def self.search_paths
|
49
|
+
@search_paths ||= begin
|
50
|
+
if ENV['GEOS_LIBRARY_PATH']
|
51
|
+
[ ENV['GEOS_LIBRARY_PATH'] ]
|
52
|
+
elsif FFI::Platform::IS_WINDOWS
|
53
|
+
ENV['PATH'].split(File::PATH_SEPARATOR)
|
54
|
+
else
|
55
|
+
[ '/usr/local/{lib64,lib}', '/opt/local/{lib64,lib}', '/usr/{lib64,lib}' ]
|
56
|
+
end
|
55
57
|
end
|
58
|
+
end
|
56
59
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
%w{ libgeos.so libgeos_c.so }
|
64
|
-
end
|
60
|
+
def self.find_lib(lib)
|
61
|
+
search_paths.inject(Array.new) { |array, path|
|
62
|
+
file_name = File.expand_path(File.join(path, "#{lib}.#{FFI::Platform::LIBSUFFIX}"))
|
63
|
+
array << Dir.glob(file_name)
|
64
|
+
}.flatten.sort.compact.first
|
65
|
+
end
|
65
66
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
}
|
70
|
-
|
67
|
+
def self.geos_library_paths
|
68
|
+
@geos_library_paths ||= begin
|
69
|
+
# On MingW the libraries have version numbers
|
70
|
+
[ 'libgeos_c{,-?}', 'libgeos{,-?-?-?}' ].map { |lib|
|
71
|
+
find_lib(lib)
|
72
|
+
}.compact
|
73
|
+
end
|
71
74
|
end
|
72
75
|
|
73
76
|
extend ::FFI::Library
|
@@ -154,12 +154,20 @@ module Geos
|
|
154
154
|
end
|
155
155
|
alias :size :length
|
156
156
|
|
157
|
+
def empty?
|
158
|
+
self.length == 0
|
159
|
+
end
|
160
|
+
|
157
161
|
def dimensions
|
158
162
|
@dimensions ||= FFI::MemoryPointer.new(:int).tap { |ret|
|
159
163
|
FFIGeos.GEOSCoordSeq_getDimensions_r(Geos.current_handle, self.ptr, ret)
|
160
164
|
}.read_int
|
161
165
|
end
|
162
166
|
|
167
|
+
def to_point
|
168
|
+
Geos.create_point(self)
|
169
|
+
end
|
170
|
+
|
163
171
|
def to_linear_ring
|
164
172
|
Geos.create_linear_ring(self)
|
165
173
|
end
|
@@ -172,6 +180,12 @@ module Geos
|
|
172
180
|
Geos.create_polygon(self)
|
173
181
|
end
|
174
182
|
|
183
|
+
def to_s
|
184
|
+
self.entries.collect { |entry|
|
185
|
+
entry.join(' ')
|
186
|
+
}.join(', ')
|
187
|
+
end
|
188
|
+
|
175
189
|
protected
|
176
190
|
|
177
191
|
def check_bounds(idx) #:nodoc:
|
data/lib/ffi-geos/geometry.rb
CHANGED
@@ -123,6 +123,11 @@ class CoordinateSequenceTests < Test::Unit::TestCase
|
|
123
123
|
end
|
124
124
|
end
|
125
125
|
|
126
|
+
def test_to_point
|
127
|
+
cs = Geos::CoordinateSequence.new([5,7])
|
128
|
+
assert_equal('POINT (5 7)', write(cs.to_point, :trim => true))
|
129
|
+
end
|
130
|
+
|
126
131
|
def test_to_to_linear_ring
|
127
132
|
cs = Geos::CoordinateSequence.new([
|
128
133
|
[ 0, 0 ],
|
@@ -135,6 +140,14 @@ class CoordinateSequenceTests < Test::Unit::TestCase
|
|
135
140
|
assert_equal('LINEARRING (0 0, 0 5, 5 5, 5 0, 0 0)', write(cs.to_linear_ring, :trim => true))
|
136
141
|
end
|
137
142
|
|
143
|
+
def test_empty
|
144
|
+
cs = Geos::CoordinateSequence.new
|
145
|
+
assert(cs.empty?)
|
146
|
+
|
147
|
+
cs = Geos::CoordinateSequence.new([4,1])
|
148
|
+
assert(!cs.empty?)
|
149
|
+
end
|
150
|
+
|
138
151
|
def test_to_empty_linear_ring
|
139
152
|
cs = Geos::CoordinateSequence.new
|
140
153
|
|
@@ -175,4 +188,12 @@ class CoordinateSequenceTests < Test::Unit::TestCase
|
|
175
188
|
|
176
189
|
assert_equal('POLYGON EMPTY', write(cs.to_polygon, :trim => true))
|
177
190
|
end
|
191
|
+
|
192
|
+
def test_to_s
|
193
|
+
cs = Geos::CoordinateSequence.new([[1, 2], [10, 11]])
|
194
|
+
assert_equal("1.0 2.0, 10.0 11.0", cs.to_s)
|
195
|
+
|
196
|
+
cs = Geos::CoordinateSequence.new([[1, 2, 3], [10, 11, 12]])
|
197
|
+
assert_equal("1.0 2.0 3.0, 10.0 11.0 12.0", cs.to_s)
|
198
|
+
end
|
178
199
|
end
|
data/test/geometry_tests.rb
CHANGED
@@ -1524,6 +1524,16 @@ class GeometryTests < Test::Unit::TestCase
|
|
1524
1524
|
assert(geom_a.eql?(geom_b))
|
1525
1525
|
end
|
1526
1526
|
|
1527
|
+
def test_clone_srid
|
1528
|
+
srid = 4326
|
1529
|
+
geom_a = read('POINT(0 0)')
|
1530
|
+
geom_a.srid = srid
|
1531
|
+
geom_b = geom_a.clone
|
1532
|
+
|
1533
|
+
assert(geom_a.eql?(geom_b))
|
1534
|
+
assert_equal(srid, geom_b.srid)
|
1535
|
+
end
|
1536
|
+
|
1527
1537
|
def test_dup
|
1528
1538
|
geom_a = read('POINT(0 0)')
|
1529
1539
|
geom_b = geom_a.dup
|
@@ -1531,6 +1541,15 @@ class GeometryTests < Test::Unit::TestCase
|
|
1531
1541
|
assert(geom_a.eql?(geom_b))
|
1532
1542
|
end
|
1533
1543
|
|
1544
|
+
def test_dup_srid
|
1545
|
+
srid = 4326
|
1546
|
+
geom_a = read('POINT(0 0)')
|
1547
|
+
geom_a.srid = srid
|
1548
|
+
geom_b = geom_a.dup
|
1549
|
+
assert(geom_a.eql?(geom_b))
|
1550
|
+
assert_equal(srid, geom_b.srid)
|
1551
|
+
end
|
1552
|
+
|
1534
1553
|
def test_geometry_collection_enumerator
|
1535
1554
|
geom = read('GEOMETRYCOLLECTION(POINT(0 0))')
|
1536
1555
|
assert_kind_of(Enumerable, geom.each)
|
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.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,8 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
13
|
-
default_executable:
|
12
|
+
date: 2011-08-22 00:00:00.000000000Z
|
14
13
|
dependencies: []
|
15
14
|
description: An ffi wrapper for GEOS, a C++ port of the Java Topology Suite (JTS).
|
16
15
|
email: dark.panda@gmail.com
|
@@ -56,7 +55,6 @@ files:
|
|
56
55
|
- test/wkb_writer_tests.rb
|
57
56
|
- test/wkt_reader_tests.rb
|
58
57
|
- test/wkt_writer_tests.rb
|
59
|
-
has_rdoc: true
|
60
58
|
homepage: http://github.com/dark-panda/ffi-geos
|
61
59
|
licenses: []
|
62
60
|
post_install_message:
|
@@ -77,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
75
|
version: '0'
|
78
76
|
requirements: []
|
79
77
|
rubyforge_project:
|
80
|
-
rubygems_version: 1.
|
78
|
+
rubygems_version: 1.8.8
|
81
79
|
signing_key:
|
82
80
|
specification_version: 3
|
83
81
|
summary: An ffi wrapper for GEOS, a C++ port of the Java Topology Suite (JTS).
|