ffi-geos 0.1.2 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ffi-geos.rb +9 -6
- data/lib/ffi-geos/geometry.rb +7 -2
- data/lib/ffi-geos/linear_ring.rb +4 -0
- data/lib/ffi-geos/polygon.rb +4 -2
- data/lib/ffi-geos/prepared_geometry.rb +7 -8
- data/lib/ffi-geos/tools.rb +1 -1
- data/lib/ffi-geos/version.rb +1 -1
- data/test/linear_ring_tests.rb +13 -1
- metadata +12 -8
- checksums.yaml +0 -15
data/lib/ffi-geos.rb
CHANGED
@@ -975,14 +975,17 @@ module Geos
|
|
975
975
|
attr_reader :ptr
|
976
976
|
|
977
977
|
def initialize
|
978
|
-
@ptr =
|
979
|
-
|
980
|
-
|
978
|
+
@ptr = FFI::AutoPointer.new(
|
979
|
+
FFIGeos.initGEOS_r(
|
980
|
+
@notice_handler = self.method(:notice_handler),
|
981
|
+
@error_handler = self.method(:error_handler)
|
982
|
+
),
|
983
|
+
self.class.method(:release)
|
981
984
|
)
|
985
|
+
end
|
982
986
|
|
983
|
-
|
984
|
-
|
985
|
-
}
|
987
|
+
def self.release(ptr)
|
988
|
+
FFIGeos.finishGEOS_r(ptr)
|
986
989
|
end
|
987
990
|
|
988
991
|
def notice_handler(*args)
|
data/lib/ffi-geos/geometry.rb
CHANGED
@@ -8,13 +8,18 @@ module Geos
|
|
8
8
|
|
9
9
|
# For internal use. Geometry objects should be created via WkbReader,
|
10
10
|
# WktReader and the various Geos.create_* methods.
|
11
|
-
def initialize(ptr,
|
11
|
+
def initialize(ptr, options = {})
|
12
|
+
options = {
|
13
|
+
:auto_free => true
|
14
|
+
}.merge(options)
|
15
|
+
|
12
16
|
@ptr = FFI::AutoPointer.new(
|
13
17
|
ptr,
|
14
18
|
self.class.method(:release)
|
15
19
|
)
|
16
20
|
|
17
|
-
@ptr.autorelease = auto_free
|
21
|
+
@ptr.autorelease = !!options[:auto_free]
|
22
|
+
@parent = options[:parent] if options[:parent]
|
18
23
|
end
|
19
24
|
|
20
25
|
def initialize_copy(source)
|
data/lib/ffi-geos/linear_ring.rb
CHANGED
data/lib/ffi-geos/polygon.rb
CHANGED
@@ -13,7 +13,8 @@ module Geos
|
|
13
13
|
cast_geometry_ptr(
|
14
14
|
FFIGeos.GEOSGetInteriorRingN_r(Geos.current_handle, self.ptr, n), {
|
15
15
|
:auto_free => false,
|
16
|
-
:srid_copy => self.srid
|
16
|
+
:srid_copy => self.srid,
|
17
|
+
:parent => self
|
17
18
|
}
|
18
19
|
)
|
19
20
|
end
|
@@ -24,7 +25,8 @@ module Geos
|
|
24
25
|
cast_geometry_ptr(
|
25
26
|
FFIGeos.GEOSGetExteriorRing_r(Geos.current_handle, self.ptr), {
|
26
27
|
:auto_free => false,
|
27
|
-
:srid_copy => self.srid
|
28
|
+
:srid_copy => self.srid,
|
29
|
+
:parent => self
|
28
30
|
}
|
29
31
|
)
|
30
32
|
end
|
@@ -8,21 +8,20 @@ module Geos
|
|
8
8
|
|
9
9
|
undef :clone, :dup
|
10
10
|
|
11
|
-
def initialize(geom,
|
11
|
+
def initialize(geom, options = {})
|
12
12
|
check_geometry(geom)
|
13
13
|
|
14
|
+
options = {
|
15
|
+
:auto_free => true
|
16
|
+
}.merge(options)
|
17
|
+
|
14
18
|
@ptr = FFI::AutoPointer.new(
|
15
19
|
FFIGeos.GEOSPrepare_r(Geos.current_handle, geom.ptr),
|
16
|
-
|
20
|
+
self.class.method(:release)
|
17
21
|
)
|
18
22
|
@geometry = geom
|
19
23
|
|
20
|
-
|
21
|
-
@ptr.autorelease = false
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.no_release(ptr) #:nodoc:
|
24
|
+
@ptr.autorelease = !!options[:auto_free]
|
26
25
|
end
|
27
26
|
|
28
27
|
def self.release(ptr) #:nodoc:
|
data/lib/ffi-geos/tools.rb
CHANGED
data/lib/ffi-geos/version.rb
CHANGED
data/test/linear_ring_tests.rb
CHANGED
@@ -6,11 +6,23 @@ require 'test_helper'
|
|
6
6
|
class LinearRingTests < MiniTest::Unit::TestCase
|
7
7
|
include TestHelper
|
8
8
|
|
9
|
+
def setup
|
10
|
+
super
|
11
|
+
writer.trim = true
|
12
|
+
end
|
13
|
+
|
9
14
|
def test_to_polygon
|
10
15
|
geom = read('POLYGON ((0 0, 5 0, 5 5, 0 5, 0 0))')
|
11
16
|
ring = geom.exterior_ring
|
12
17
|
|
13
|
-
assert_equal(
|
18
|
+
assert_equal('POLYGON ((0 0, 5 0, 5 5, 0 5, 0 0))', write(ring.to_polygon))
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_to_line_string
|
22
|
+
geom = read('POLYGON ((0 0, 5 0, 5 5, 0 5, 0 0))')
|
23
|
+
ring = geom.exterior_ring
|
24
|
+
|
25
|
+
assert_equal('LINESTRING (0 0, 5 0, 5 5, 0 5, 0 0)', write(ring.to_line_string))
|
14
26
|
end
|
15
27
|
|
16
28
|
def test_to_polygon_with_srid
|
metadata
CHANGED
@@ -1,29 +1,32 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ffi-geos
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease:
|
5
|
+
version: 0.2.1
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- J Smith
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2013-
|
12
|
+
date: 2013-08-02 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
15
|
+
name: ffi
|
16
|
+
type: :runtime
|
14
17
|
requirement: !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
15
19
|
requirements:
|
16
20
|
- - ! '>='
|
17
21
|
- !ruby/object:Gem::Version
|
18
22
|
version: 1.0.0
|
23
|
+
prerelease: false
|
19
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
20
26
|
requirements:
|
21
27
|
- - ! '>='
|
22
28
|
- !ruby/object:Gem::Version
|
23
29
|
version: 1.0.0
|
24
|
-
type: :runtime
|
25
|
-
prerelease: false
|
26
|
-
name: ffi
|
27
30
|
description: An ffi wrapper for GEOS, a C++ port of the Java Topology Suite (JTS).
|
28
31
|
email: dark.panda@gmail.com
|
29
32
|
executables: []
|
@@ -78,26 +81,27 @@ files:
|
|
78
81
|
- test/wkt_writer_tests.rb
|
79
82
|
homepage: http://github.com/dark-panda/ffi-geos
|
80
83
|
licenses: []
|
81
|
-
metadata: {}
|
82
84
|
post_install_message:
|
83
85
|
rdoc_options: []
|
84
86
|
require_paths:
|
85
87
|
- lib
|
86
88
|
required_ruby_version: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
87
90
|
requirements:
|
88
91
|
- - ! '>='
|
89
92
|
- !ruby/object:Gem::Version
|
90
93
|
version: '0'
|
91
94
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
|
+
none: false
|
92
96
|
requirements:
|
93
97
|
- - ! '>='
|
94
98
|
- !ruby/object:Gem::Version
|
95
99
|
version: '0'
|
96
100
|
requirements: []
|
97
101
|
rubyforge_project:
|
98
|
-
rubygems_version:
|
102
|
+
rubygems_version: 1.8.23
|
99
103
|
signing_key:
|
100
|
-
specification_version:
|
104
|
+
specification_version: 3
|
101
105
|
summary: An ffi wrapper for GEOS, a C++ port of the Java Topology Suite (JTS).
|
102
106
|
test_files:
|
103
107
|
- test/coordinate_sequence_tests.rb
|
checksums.yaml
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
---
|
2
|
-
!binary "U0hBMQ==":
|
3
|
-
metadata.gz: !binary |-
|
4
|
-
OTIxMDI2MjAzYTBlNmI2MTJlNDU2NzVkN2I2ZGJhY2U5MmVmMWNmYQ==
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
MjY3YWI1MzAzMTNkZDhlNDEyMzRkNTlmOGE1NzA5MWQ3NzliNWU1Yw==
|
7
|
-
!binary "U0hBNTEy":
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
ZjRhYjc0ZDdjMWE3YzllYmRlYmQ4MmZjMDM1MWFhNTZjNTFjOTUzNWY0YmFm
|
10
|
-
ODcxNzY0MTBkOWVhNmUxNzdjZjE2ZTZiOTA4YTM2OGI5YTRiNDgzMWM4Mzdk
|
11
|
-
YWQ3NWNjOThmM2VlOThmMTI4YmQwNDQyMjcxOTMzOWZkMjcwNGE=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
YjU2NTI1NjZjM2VhNDE0ZmI4Y2NlMzhmYmEwNzY3OWQzNjk3NWY4ZmE1MDhl
|
14
|
-
NzAxOGJlYmJmZWIxMTcyZTlmZGI1YzBmODMwNmFmM2Y2MDBhZTZjZGFiMzUz
|
15
|
-
MTljMGQ3NThjYTYxMTdlODYyMWQzMjhjMjIwMGRmNWFmMzNlOTM=
|