georuby-ext 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.jrubyrc +1 -0
- data/.travis.yml +23 -0
- data/Gemfile +6 -0
- data/Guardfile +12 -2
- data/MIT-LICENSE +20 -0
- data/README.rdoc +2 -28
- data/georuby-ext.gemspec +14 -11
- data/lib/georuby-ext.rb +17 -2
- data/lib/georuby-ext/core_ext.rb +11 -0
- data/lib/georuby-ext/geokit.rb +10 -3
- data/lib/georuby-ext/georuby/envelope.rb +36 -1
- data/lib/georuby-ext/georuby/ewkb_parser.rb +11 -0
- data/lib/georuby-ext/georuby/ewkt_parser.rb +11 -0
- data/lib/georuby-ext/georuby/geometry.rb +46 -2
- data/lib/georuby-ext/georuby/line_string.rb +19 -7
- data/lib/georuby-ext/georuby/linear_ring.rb +15 -0
- data/lib/georuby-ext/georuby/locators.rb +30 -17
- data/lib/georuby-ext/georuby/multi_polygon.rb +15 -1
- data/lib/georuby-ext/georuby/point.rb +148 -24
- data/lib/georuby-ext/georuby/polygon.rb +38 -27
- data/lib/georuby-ext/georuby/rtree.rb +133 -0
- data/lib/georuby-ext/georuby/srid.rb +17 -0
- data/lib/georuby-ext/proj4.rb +15 -2
- data/lib/georuby-ext/rgeo/cartesian/feature_methods.rb +58 -0
- data/lib/georuby-ext/rgeo/feature/geometry.rb +11 -0
- data/lib/georuby-ext/rgeo/feature/geometry_collection.rb +11 -0
- data/lib/georuby-ext/rgeo/feature/rgeo.rb +157 -0
- data/lib/georuby-ext/rgeo/geos/ffi_feature_methods.rb +265 -0
- data/lib/georuby-ext/rspec_helper.rb +47 -8
- data/spec/lib/geokit_spec.rb +44 -0
- data/spec/lib/georuby/envelope_spec.rb +46 -0
- data/spec/lib/georuby/geometry_spec.rb +81 -0
- data/spec/{georuby → lib/georuby}/line_string_spec.rb +29 -14
- data/spec/lib/georuby/linear_ring_spec.rb +52 -0
- data/spec/lib/georuby/locators_spec.rb +123 -0
- data/spec/lib/georuby/multi_polygon_spec.rb +69 -0
- data/spec/lib/georuby/point_spec.rb +248 -0
- data/spec/lib/georuby/polygon_spec.rb +175 -0
- data/spec/lib/georuby/rtree_spec.rb +132 -0
- data/spec/lib/proj4_spec.rb +24 -0
- data/spec/lib/rgeo/cartesian/feature_methods_spec.rb +110 -0
- data/spec/lib/rgeo/geos/ffi_feature_methods_spec.rb +234 -0
- data/spec/spec_helper.rb +12 -8
- metadata +224 -189
- data/lib/georuby-ext/rgeo.rb +0 -23
- data/spec/georuby/linear_ring_spec.rb +0 -33
- data/spec/georuby/locators_spec.rb +0 -120
- data/spec/georuby/multi_polygon_spec.rb +0 -29
- data/spec/georuby/point_spec.rb +0 -44
- data/spec/georuby/polygon_spec.rb +0 -134
- data/spec/rgeo_spec.rb +0 -81
@@ -0,0 +1,132 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GeoRuby::Rtree::STRBuilder do
|
4
|
+
|
5
|
+
subject { GeoRuby::Rtree::STRBuilder.new points("0 2,1 1,2 0").reverse }
|
6
|
+
|
7
|
+
let(:element) { "element" }
|
8
|
+
|
9
|
+
def slice(points)
|
10
|
+
GeoRuby::Rtree::STRBuilder::Slice.new points(points)
|
11
|
+
end
|
12
|
+
|
13
|
+
def node(*children)
|
14
|
+
children = points(children.first) if children.size == 1 and String === children.first
|
15
|
+
GeoRuby::Rtree::Node.new children
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "#root_node" do
|
19
|
+
|
20
|
+
it "should return ..." do
|
21
|
+
subject.root_node.should == node(node("1 1, 0 2"), node("2 0"))
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "#leaf_nodes" do
|
27
|
+
it "should return nodes from slices" do
|
28
|
+
subject.stub :slices => [ slice("0 2, 1 1"), slice("2 0") ]
|
29
|
+
subject.leaf_nodes.should == [ node("1 1, 0 2"), node("2 0") ]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "#slices" do
|
34
|
+
it "should fill slices with sorted elements (by x)" do
|
35
|
+
subject.slices.should == [ slice("0 2, 1 1"), slice("2 0") ]
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should return slices with specified size" do
|
39
|
+
subject.slices.each do |slice|
|
40
|
+
slice.size.should <= subject.slice_size
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "#leaf_nodes_count" do
|
46
|
+
|
47
|
+
it "should return 10 for 39 elements with a node size of 4" do
|
48
|
+
GeoRuby::Rtree::STRBuilder.new([element] * 39, 4).leaf_nodes_count.should == 10
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "#slice_size" do
|
54
|
+
|
55
|
+
it "should return 3 for 27 elements with a node size of 3" do
|
56
|
+
GeoRuby::Rtree::STRBuilder.new([element] * 27, 3).slice_size.should == 3
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should return 4 for 30 elements with a node size of 3" do
|
60
|
+
GeoRuby::Rtree::STRBuilder.new([element] * 30, 3).slice_size.should == 4
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
describe GeoRuby::Rtree::STRBuilder::Slice do
|
69
|
+
|
70
|
+
subject { GeoRuby::Rtree::STRBuilder::Slice.new points("2 0,1 1,0 2").reverse, 2 }
|
71
|
+
|
72
|
+
describe "#sort_y" do
|
73
|
+
|
74
|
+
it "should return elements classified by y" do
|
75
|
+
subject.sort_y.should == points("2 0, 1 1, 0 2")
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
describe "#nodes" do
|
81
|
+
|
82
|
+
def node(points)
|
83
|
+
GeoRuby::Rtree::Node.new points(points)
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should fill nodes with sorted elements" do
|
87
|
+
subject.nodes.should == [ node("2 0, 1 1"), node("0 2") ]
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should return nodes with specified size" do
|
91
|
+
subject.nodes.each do |node|
|
92
|
+
node.size.should <= subject.node_size
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
|
100
|
+
describe GeoRuby::Rtree::Node do
|
101
|
+
|
102
|
+
describe "bounds" do
|
103
|
+
|
104
|
+
it "should return a global bounds of children" do
|
105
|
+
subject.children << polygon("(0 0,1 1,1 0,0 0)")
|
106
|
+
subject.children << polygon("(1 1,2 2,2 0,1 1)")
|
107
|
+
|
108
|
+
subject.bounds.should == envelope("0 0","2 2")
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
112
|
+
|
113
|
+
describe "#==" do
|
114
|
+
|
115
|
+
it "should be true when children are the same" do
|
116
|
+
GeoRuby::Rtree::Node.new(1,2,3).should == GeoRuby::Rtree::Node.new(1,2,3)
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|
120
|
+
|
121
|
+
describe "#containing" do
|
122
|
+
bound = envelope("0 0","1 1")
|
123
|
+
let(:children) { [ polygon("(0 0,0 1,1 1,1 0,0 0)"), polygon("(0 0,0 2,2 2,2 0,0 0)"), polygon("(0 0,0 0.5,0.5 0.5,0.5 0,0 0)") ] }
|
124
|
+
|
125
|
+
it "should return elements if containing bounds" do
|
126
|
+
GeoRuby::Rtree::Node.new(children).containing(bound).should == children
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|
130
|
+
|
131
|
+
|
132
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Proj4::Projection do
|
4
|
+
|
5
|
+
describe ".for_srid" do
|
6
|
+
|
7
|
+
it "should return wgs84 projection for srid 4326" do
|
8
|
+
Proj4::Projection.for_srid(4326).should == Proj4::Projection.wgs84
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should return wgs84 projection for srid 900913" do
|
12
|
+
Proj4::Projection.for_srid(900913).should == Proj4::Projection.google
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should raise an error when srid isn't supported" do
|
16
|
+
lambda do
|
17
|
+
Proj4::Projection.for_srid(123)
|
18
|
+
end.should raise_error
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module RGeo
|
4
|
+
module Cartesian
|
5
|
+
|
6
|
+
describe PointImpl do
|
7
|
+
|
8
|
+
subject { rgeo_point }
|
9
|
+
|
10
|
+
describe "#to_georuby" do
|
11
|
+
|
12
|
+
it "should return a GeoRuby::SimpleFeatures::Point" do
|
13
|
+
subject.to_georuby.should be_instance_of(GeoRuby::SimpleFeatures::Point)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should have the same x, y and srid" do
|
17
|
+
subject.to_georuby.should have_same(:x, :y, :srid).than(subject)
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
describe LineStringImpl do
|
25
|
+
|
26
|
+
subject { rgeometry("LINESTRING(0 0, 1 1, 2 2)") }
|
27
|
+
|
28
|
+
describe "#to_linear_ring" do
|
29
|
+
|
30
|
+
it "should return a GeoRuby::SimpleFeatures::LinearRing" do
|
31
|
+
subject.to_linear_ring.should == rgeometry("LINESTRING(0 0, 1 1, 2 2, 0 0)")
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "#to_georuby" do
|
37
|
+
|
38
|
+
it "should return a GeoRuby::SimpleFeatures::LineString" do
|
39
|
+
subject.to_georuby.should be_instance_of(GeoRuby::SimpleFeatures::LineString)
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should return a LineString with the same information" do
|
43
|
+
subject.to_georuby.should == geometry("LINESTRING(0 0, 1 1, 2 2)")
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
# describe RGeo::Geos::LinearRingImpl do
|
51
|
+
|
52
|
+
# subject { rgeometry("LINEARRING(0 0, 1 1, 0 0)") }
|
53
|
+
|
54
|
+
# describe "#to_georuby" do
|
55
|
+
|
56
|
+
# it "should return a GeoRuby::SimpleFeatures::LineString" do
|
57
|
+
# subject.to_georuby.should be_instance_of(GeoRuby::SimpleFeatures::LinearRing)
|
58
|
+
# end
|
59
|
+
|
60
|
+
# it "should return a LineString with the same information" do
|
61
|
+
# subject.to_georuby.should == geometry("LINEARRING(0 0, 1 1, 1 1)")
|
62
|
+
# end
|
63
|
+
|
64
|
+
# end
|
65
|
+
|
66
|
+
# end
|
67
|
+
|
68
|
+
describe PolygonImpl do
|
69
|
+
|
70
|
+
subject { rgeometry("POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))") }
|
71
|
+
|
72
|
+
describe "#to_georuby" do
|
73
|
+
|
74
|
+
it "should return a GeoRuby::SimpleFeatures::Polygon" do
|
75
|
+
subject.to_georuby.should be_instance_of(GeoRuby::SimpleFeatures::Polygon)
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should return a georuby polygon with the same information" do
|
79
|
+
subject.to_georuby.should == geometry("POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))")
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should return a georuby polygon with the same information" do
|
83
|
+
rgeo_polygon = rgeometry("POLYGON((0 0, 0 1, 1 1, 1 0, 0 0), (0.25 0.25,0 0.75,0.75 0.75,0.75 0.25))")
|
84
|
+
rgeo_polygon.to_georuby.should == geometry("POLYGON((0 0, 0 1, 1 1, 1 0, 0 0), (0.25 0.25,0 0.75,0.75 0.75,0.75 0.25))")
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
describe MultiPolygonImpl do
|
92
|
+
|
93
|
+
subject { rgeometry("MULTIPOLYGON ( ((0 0, 0 1, 1 1, 1 0, 0 0), (0.25 0.25,0 0.75,0.75 0.75,0.75 0.25, 0.25 0.25)), ((15 5, 40 10, 10 20, 5 10, 15 5)) )") }
|
94
|
+
|
95
|
+
describe "#to_georuby" do
|
96
|
+
|
97
|
+
it "should return a GeoRuby::SimpleFeatures::MultiPolygon" do
|
98
|
+
subject.to_georuby.should be_instance_of(GeoRuby::SimpleFeatures::MultiPolygon)
|
99
|
+
end
|
100
|
+
|
101
|
+
it "should return a MultiPolygon with the same information" do
|
102
|
+
subject.to_georuby.should == geometry("MULTIPOLYGON ( ((0 0, 0 1, 1 1, 1 0, 0 0), (0.25 0.25,0 0.75,0.75 0.75,0.75 0.25, 0.25 0.25)), ((15 5, 40 10, 10 20, 5 10, 15 5)) )")
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|
110
|
+
end
|
@@ -0,0 +1,234 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module RGeo
|
4
|
+
module Geos
|
5
|
+
|
6
|
+
describe FFIPointImpl do
|
7
|
+
|
8
|
+
subject { rgeo_point }
|
9
|
+
|
10
|
+
describe "#to_georuby" do
|
11
|
+
|
12
|
+
it "should return a GeoRuby::SimpleFeatures::Point" do
|
13
|
+
subject.to_georuby.should be_instance_of(GeoRuby::SimpleFeatures::Point)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should have the same x, y and srid" do
|
17
|
+
subject.to_georuby.should have_same(:x, :y, :srid).than(subject)
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
describe FFILineStringImpl do
|
25
|
+
|
26
|
+
subject { rgeometry("LINESTRING(0 0, 1 1, 2 2)") }
|
27
|
+
|
28
|
+
describe "#to_linear_ring" do
|
29
|
+
|
30
|
+
it "should return a GeoRuby::SimpleFeatures::LinearRing" do
|
31
|
+
subject.to_linear_ring.should == rgeometry("LINESTRING(0 0, 1 1, 2 2, 0 0)")
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "#to_georuby" do
|
37
|
+
|
38
|
+
it "should return a GeoRuby::SimpleFeatures::LineString" do
|
39
|
+
subject.to_georuby.should be_instance_of(GeoRuby::SimpleFeatures::LineString)
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should return a LineString with the same information" do
|
43
|
+
subject.to_georuby.should == geometry("LINESTRING(0 0, 1 1, 2 2)")
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "#distance_on_line" do
|
49
|
+
|
50
|
+
it "should return distance on line" do
|
51
|
+
#subject.stub :nearest_locator =>
|
52
|
+
#subject.distance_on_line().should ==
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
describe "#distance_from_line" do
|
58
|
+
|
59
|
+
it "should return distance from line" do
|
60
|
+
#subject.distance_from_line().should ==
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
describe RGeo::Geos::FFILineStringImpl::Segment do
|
68
|
+
subject { RGeo::Geos::FFILineStringImpl::Segment.new(rgeo_point(0, 1.0), rgeo_point(0, 2.0)) }
|
69
|
+
|
70
|
+
before :each do
|
71
|
+
subject.stub :line_distance_at_departure => 1
|
72
|
+
subject.stub :line => rgeometry("LINESTRING(0 0, 0 1.0, 0 2.0)")
|
73
|
+
end
|
74
|
+
|
75
|
+
describe "#line_distance_at_arrival" do
|
76
|
+
it "should return distance between departure and arrival for Segment" do
|
77
|
+
subject.line_distance_at_arrival.should == 2
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should return distance between departure and arrival for Segment and line distance" do
|
81
|
+
subject.stub :line_distance_at_departure => 0
|
82
|
+
subject.line_distance_at_arrival.should == 1
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe "#location_in_line" do
|
87
|
+
it "should return the distance at the beginning of the segment" do
|
88
|
+
subject.location_in_line.should == 0.5
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
describe RGeo::Geos::FFILineStringImpl::PointLocator do
|
95
|
+
|
96
|
+
let(:departure) { rgeo_point(0, 0) }
|
97
|
+
let(:arrival) { rgeo_point(2.0, 0) }
|
98
|
+
let(:point_on_segment) { rgeo_point(1.0, 0) }
|
99
|
+
|
100
|
+
def locator(target, departure, arrival)
|
101
|
+
RGeo::Geos::FFILineStringImpl::PointLocator.new target, departure, arrival
|
102
|
+
end
|
103
|
+
|
104
|
+
describe "distance_from_segment" do
|
105
|
+
|
106
|
+
it "should be zero if target is on the segment" do
|
107
|
+
locator(departure, departure, arrival).distance_from_segment.should be_zero
|
108
|
+
end
|
109
|
+
|
110
|
+
it "should be 0 if target is on the middle of the segment" do
|
111
|
+
locator(point_on_segment, departure, arrival).distance_from_segment.should == 0
|
112
|
+
end
|
113
|
+
|
114
|
+
it "should be 1 if target is on the x axis of the middle of the segment" do
|
115
|
+
locator(rgeo_point(1.0,1.0), departure, arrival).distance_from_segment.should be_within(0.01).of(1.0)
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
119
|
+
|
120
|
+
describe "distance_on_segment" do
|
121
|
+
|
122
|
+
it "should be zero if target is the departure" do
|
123
|
+
locator(departure, departure, arrival).distance_on_segment.should be_zero
|
124
|
+
end
|
125
|
+
|
126
|
+
it "should be 1 if target is on the middle of the segment" do
|
127
|
+
locator(point_on_segment, departure, arrival).distance_on_segment.should == 1.0
|
128
|
+
end
|
129
|
+
|
130
|
+
it "should be 1 if target is on the x axis of the middle of the segment" do
|
131
|
+
locator(rgeo_point(1.0,1.0), departure, arrival).distance_on_segment.should be_within(0.01).of(1.0)
|
132
|
+
end
|
133
|
+
|
134
|
+
end
|
135
|
+
|
136
|
+
end
|
137
|
+
|
138
|
+
# describe RGeo::Geos::FFILinearRingImpl do
|
139
|
+
|
140
|
+
# subject { rgeometry("LINEARRING(0 0, 1 1, 0 0)") }
|
141
|
+
|
142
|
+
# describe "#to_georuby" do
|
143
|
+
|
144
|
+
# it "should return a GeoRuby::SimpleFeatures::LineString" do
|
145
|
+
# subject.to_georuby.should be_instance_of(GeoRuby::SimpleFeatures::LinearRing)
|
146
|
+
# end
|
147
|
+
|
148
|
+
# it "should return a LineString with the same information" do
|
149
|
+
# subject.to_georuby.should == geometry("LINEARRING(0 0, 1 1, 1 1)")
|
150
|
+
# end
|
151
|
+
|
152
|
+
# end
|
153
|
+
|
154
|
+
# end
|
155
|
+
|
156
|
+
describe FFIPolygonImpl do
|
157
|
+
|
158
|
+
subject { rgeometry("POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))") }
|
159
|
+
|
160
|
+
describe "#to_georuby" do
|
161
|
+
|
162
|
+
it "should return a GeoRuby::SimpleFeatures::Polygon" do
|
163
|
+
subject.to_georuby.should be_instance_of(GeoRuby::SimpleFeatures::Polygon)
|
164
|
+
end
|
165
|
+
|
166
|
+
it "should return a georuby polygon with the same information" do
|
167
|
+
subject.to_georuby.should == geometry("POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))")
|
168
|
+
end
|
169
|
+
|
170
|
+
it "should return a georuby polygon with the same information" do
|
171
|
+
rgeo_polygon = rgeometry("POLYGON((0 0, 0 1, 1 1, 1 0, 0 0), (0.25 0.25,0 0.75,0.75 0.75,0.75 0.25))")
|
172
|
+
rgeo_polygon.to_georuby.should == geometry("POLYGON((0 0, 0 1, 1 1, 1 0, 0 0), (0.25 0.25,0 0.75,0.75 0.75,0.75 0.25))")
|
173
|
+
end
|
174
|
+
|
175
|
+
end
|
176
|
+
|
177
|
+
end
|
178
|
+
|
179
|
+
describe RGeo::Geos::FFIMultiLineStringImpl do
|
180
|
+
|
181
|
+
describe "locate_point" do
|
182
|
+
|
183
|
+
context "examples" do
|
184
|
+
|
185
|
+
# it "should find 2,1 at 0.5 between 0,0 and 4,0" do
|
186
|
+
# multi_line_string("(0 0,4 0)").locate_point(point(2,1)).should == 0.5
|
187
|
+
# end
|
188
|
+
|
189
|
+
# it "should find 2,1 at 1.5 for (0,4)...(0,1) and (0,0)...(4,0)" do
|
190
|
+
# multi_line_string("(0 4,0 1),(0 0,4 0)").locate_point(point(2,1)).should == 1.5
|
191
|
+
# end
|
192
|
+
|
193
|
+
end
|
194
|
+
|
195
|
+
end
|
196
|
+
|
197
|
+
# describe "interpolate_point" do
|
198
|
+
|
199
|
+
# context "examples" do
|
200
|
+
|
201
|
+
# it "should find 0.5 at (2,0) between 0,0 and 4,0" do
|
202
|
+
# rgeometry("MULTILINESTRING((0 0,4 0))").interpolate_point(0.5).should == point(2,0)
|
203
|
+
# end
|
204
|
+
|
205
|
+
# it "should find 1.5 at (2,0) for (0,4)...(0,1) and (0,0)...(4,0)" do
|
206
|
+
# rgeometry("MULTILINESTRING((0 4,0 1),(0 0,4 0))").interpolate_point(1.5).should == point(2,0)
|
207
|
+
# end
|
208
|
+
|
209
|
+
# end
|
210
|
+
|
211
|
+
# end
|
212
|
+
|
213
|
+
end
|
214
|
+
|
215
|
+
|
216
|
+
describe FFIMultiPolygonImpl do
|
217
|
+
|
218
|
+
subject { rgeometry("MULTIPOLYGON ( ((0 0, 0 1, 1 1, 1 0, 0 0), (0.25 0.25,0 0.75,0.75 0.75,0.75 0.25, 0.25 0.25)), ((15 5, 40 10, 10 20, 5 10, 15 5)) )") }
|
219
|
+
|
220
|
+
describe "#to_georuby" do
|
221
|
+
|
222
|
+
it "should return a GeoRuby::SimpleFeatures::MultiPolygon" do
|
223
|
+
subject.to_georuby.should be_instance_of(GeoRuby::SimpleFeatures::MultiPolygon)
|
224
|
+
end
|
225
|
+
|
226
|
+
it "should return a MultiPolygon with the same information" do
|
227
|
+
subject.to_georuby.should == geometry("MULTIPOLYGON ( ((0 0, 0 1, 1 1, 1 0, 0 0), (0.25 0.25,0 0.75,0.75 0.75,0.75 0.25, 0.25 0.25)), ((15 5, 40 10, 10 20, 5 10, 15 5)) )")
|
228
|
+
end
|
229
|
+
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
end
|
234
|
+
end
|