ffi-geos 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/ffi-geos.gemspec +1 -1
- data/lib/ffi-geos.rb +11 -4
- data/lib/ffi-geos/geometry.rb +7 -2
- data/lib/ffi-geos/version.rb +1 -1
- data/test/geometry_tests.rb +18 -0
- data/test/test_helper.rb +8 -1
- metadata +5 -5
data/ffi-geos.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.homepage = "http://github.com/dark-panda/ffi-geos"
|
21
21
|
s.require_paths = ["lib"]
|
22
22
|
|
23
|
-
s.add_dependency("ffi", ["
|
23
|
+
s.add_dependency("ffi", [">= 1.0.0"])
|
24
24
|
s.add_dependency("rdoc")
|
25
25
|
s.add_dependency("rake", ["~> 0.9"])
|
26
26
|
end
|
data/lib/ffi-geos.rb
CHANGED
@@ -340,7 +340,7 @@ module Geos
|
|
340
340
|
],
|
341
341
|
|
342
342
|
:GEOSBufferWithParams_r => [
|
343
|
-
# *geom, *handle, *geom, *
|
343
|
+
# *geom, *handle, *geom, *params, width
|
344
344
|
:pointer, :pointer, :pointer, :pointer, :double
|
345
345
|
],
|
346
346
|
|
@@ -1035,8 +1035,14 @@ module Geos
|
|
1035
1035
|
GEOS_VERSION,
|
1036
1036
|
GEOS_VERSION_MAJOR, GEOS_VERSION_MINOR, GEOS_VERSION_PATCH, GEOS_VERSION_PRERELEASE,
|
1037
1037
|
GEOS_CAPI_VERSION,
|
1038
|
-
GEOS_CAPI_VERSION_MAJOR, GEOS_CAPI_VERSION_MINOR, GEOS_CAPI_VERSION_PATCH
|
1039
|
-
|
1038
|
+
GEOS_CAPI_VERSION_MAJOR, GEOS_CAPI_VERSION_MINOR, GEOS_CAPI_VERSION_PATCH,
|
1039
|
+
GEOS_SVN_REVISION =
|
1040
|
+
if !(versions = Geos.version.scan(/^
|
1041
|
+
((\d+)\.(\d+)\.(\d+)((?:dev|rc|beta|alpha)\d*)?)
|
1042
|
+
-CAPI-
|
1043
|
+
((\d+)\.(\d+)\.(\d+))
|
1044
|
+
(?:\s+r(\d+))?
|
1045
|
+
$/x)).empty?
|
1040
1046
|
versions = versions[0]
|
1041
1047
|
[
|
1042
1048
|
versions[0],
|
@@ -1047,7 +1053,8 @@ module Geos
|
|
1047
1053
|
versions[5],
|
1048
1054
|
versions[6].to_i,
|
1049
1055
|
versions[7].to_i,
|
1050
|
-
versions[8].to_i
|
1056
|
+
versions[8].to_i,
|
1057
|
+
(versions[9].to_i if versions[9])
|
1051
1058
|
]
|
1052
1059
|
else
|
1053
1060
|
[ '0.0.0', 0, 0, 0, nil, '0.0.0', 0, 0, 0 ]
|
data/lib/ffi-geos/geometry.rb
CHANGED
@@ -45,9 +45,14 @@ module Geos
|
|
45
45
|
FFIGeos.GEOSGeomTypeId_r(Geos.current_handle, self.ptr)
|
46
46
|
end
|
47
47
|
|
48
|
-
def normalize
|
49
|
-
FFIGeos.GEOSNormalize_r(Geos.current_handle, self.ptr)
|
48
|
+
def normalize!
|
49
|
+
if FFIGeos.GEOSNormalize_r(Geos.current_handle, self.ptr) == -1
|
50
|
+
raise RuntimeError.new("Couldn't normalize #{self.class}")
|
51
|
+
end
|
52
|
+
|
53
|
+
self
|
50
54
|
end
|
55
|
+
alias :normalize :normalize!
|
51
56
|
|
52
57
|
def srid
|
53
58
|
FFIGeos.GEOSGetSRID_r(Geos.current_handle, self.ptr)
|
data/lib/ffi-geos/version.rb
CHANGED
data/test/geometry_tests.rb
CHANGED
@@ -1598,4 +1598,22 @@ class GeometryTests < Test::Unit::TestCase
|
|
1598
1598
|
assert_kind_of(Enumerable, geom.to_enum)
|
1599
1599
|
assert_equal(geom, geom.each {})
|
1600
1600
|
end
|
1601
|
+
|
1602
|
+
def test_normalize
|
1603
|
+
geom = read('POLYGON((0 0, 5 0, 5 5, 0 5, 0 0))')
|
1604
|
+
geom.normalize
|
1605
|
+
assert_equal('POLYGON ((0 0, 0 5, 5 5, 5 0, 0 0))', write(geom, :trim => true))
|
1606
|
+
|
1607
|
+
geom = read('POLYGON((0 0, 5 0, 5 5, 0 5, 0 0))').normalize
|
1608
|
+
assert_equal('POLYGON ((0 0, 0 5, 5 5, 5 0, 0 0))', write(geom, :trim => true))
|
1609
|
+
end
|
1610
|
+
|
1611
|
+
def test_normalize_bang
|
1612
|
+
geom = read('POLYGON((0 0, 5 0, 5 5, 0 5, 0 0))')
|
1613
|
+
geom.normalize!
|
1614
|
+
assert_equal('POLYGON ((0 0, 0 5, 5 5, 5 0, 0 0))', write(geom, :trim => true))
|
1615
|
+
|
1616
|
+
geom = read('POLYGON((0 0, 5 0, 5 5, 0 5, 0 0))').normalize!
|
1617
|
+
assert_equal('POLYGON ((0 0, 0 5, 5 5, 5 0, 0 0))', write(geom, :trim => true))
|
1618
|
+
end
|
1601
1619
|
end
|
data/test/test_helper.rb
CHANGED
@@ -10,8 +10,15 @@ end
|
|
10
10
|
|
11
11
|
puts "Ruby version #{RUBY_VERSION}-p#{RUBY_PATCHLEVEL} - #{RbConfig::CONFIG['RUBY_INSTALL_NAME']}"
|
12
12
|
puts "ffi version #{Gem.loaded_specs['ffi'].version}" if Gem.loaded_specs['ffi']
|
13
|
-
|
13
|
+
|
14
|
+
if Geos.respond_to?(:version)
|
15
|
+
puts "GEOS version #{Geos.version}"
|
16
|
+
else
|
17
|
+
puts "GEOS version #{Geos::GEOS_VERSION}"
|
18
|
+
end
|
19
|
+
|
14
20
|
puts "ffi-geos version #{Geos::VERSION}" if defined?(Geos::VERSION)
|
21
|
+
|
15
22
|
if defined?(Geos::FFIGeos)
|
16
23
|
puts "Using #{Geos::FFIGeos.geos_library_path}"
|
17
24
|
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.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,14 +9,14 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-08-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ffi
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
21
|
version: 1.0.0
|
22
22
|
type: :runtime
|
@@ -24,7 +24,7 @@ dependencies:
|
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: 1.0.0
|
30
30
|
- !ruby/object:Gem::Dependency
|
@@ -125,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
125
125
|
version: '0'
|
126
126
|
requirements: []
|
127
127
|
rubyforge_project:
|
128
|
-
rubygems_version: 1.8.
|
128
|
+
rubygems_version: 1.8.24
|
129
129
|
signing_key:
|
130
130
|
specification_version: 3
|
131
131
|
summary: An ffi wrapper for GEOS, a C++ port of the Java Topology Suite (JTS).
|