Top Level Namespace

Defined Under Namespace

Modules: GeoKit, GeoRuby, RGeo Classes: Numeric

Instance Method Summary collapse

Instance Method Details

#envelope(lower_corner, upper_corner) ⇒ Object



55
56
57
58
59
60
# File 'lib/georuby-ext/rspec_helper.rb', line 55

def envelope(lower_corner, upper_corner)
  lower_corner = point(lower_corner) if String === lower_corner
  upper_corner = point(upper_corner) if String === upper_corner

  GeoRuby::SimpleFeatures::Envelope.from_points([lower_corner, upper_corner], lower_corner.srid)
end

#geometry(text, srid = 4326) ⇒ Object



19
20
21
# File 'lib/georuby-ext/rspec_helper.rb', line 19

def geometry(text, srid = 4326)
  GeoRuby::SimpleFeatures::Geometry.from_ewkt "SRID=#{srid};#{text}"
end

#line_string(*points) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/georuby-ext/rspec_helper.rb', line 35

def line_string(*points)
  if points.one? and String === points.first
    geometry("LINESTRING(#{points.join(",")})")
  else
    GeoRuby::SimpleFeatures::LineString.from_points(points, points.first.srid)
  end
end

#linear_ring(*points) ⇒ Object



51
52
53
# File 'lib/georuby-ext/rspec_helper.rb', line 51

def linear_ring(*points)
  GeoRuby::SimpleFeatures::LinearRing.from_points(points, points.first.srid)
end

#multi_line_string(*lines) ⇒ Object



43
44
45
46
47
48
49
# File 'lib/georuby-ext/rspec_helper.rb', line 43

def multi_line_string(*lines)
  if lines.one? and String === lines.first
    geometry("MULTILINESTRING(#{lines.join(",")})")
  else
    GeoRuby::SimpleFeatures::MultiLineString.from_line_strings lines, lines.first.srid
  end
end

#multi_polygon(*polygons) ⇒ Object



70
71
72
# File 'lib/georuby-ext/rspec_helper.rb', line 70

def multi_polygon(*polygons)
  GeoRuby::SimpleFeatures::MultiPolygon.from_polygons([polygons], polygons.first.srid)
end

#point(x = 0.0, y = 0.0, srid = 4326) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/georuby-ext/rspec_helper.rb', line 23

def point(x=0.0, y=0.0, srid = 4326)
  if String === x
    geometry("POINT(#{x})")
  else
    GeoRuby::SimpleFeatures::Point.from_x_y x, y, srid
  end
end

#points(text) ⇒ Object



31
32
33
# File 'lib/georuby-ext/rspec_helper.rb', line 31

def points(text)
  text.split(",").collect { |definition| point definition }
end

#polygon(*points) ⇒ Object



62
63
64
65
66
67
68
# File 'lib/georuby-ext/rspec_helper.rb', line 62

def polygon(*points)
  if points.one? and String === points.first
    geometry("POLYGON(#{points.join(",")})")
  else
    GeoRuby::SimpleFeatures::Polygon.from_points([points], points.first.srid)
  end
end

#rgeo_factoryObject



74
75
76
# File 'lib/georuby-ext/rspec_helper.rb', line 74

def rgeo_factory
  @rgeo_factory ||= RGeo::Geos.factory(:srid => 4326, :native_interface => :ffi, :wkt_parser => {:support_ewkt => true})
end

#rgeo_line_string(text, srid = 4326) ⇒ Object



98
99
100
# File 'lib/georuby-ext/rspec_helper.rb', line 98

def rgeo_line_string(text, srid = 4326)
  rgeometry "LINESTRING(#{text})"
end

#rgeo_multi_line_string(multi_line_string, srid = 4326) ⇒ Object



86
87
88
89
90
91
92
# File 'lib/georuby-ext/rspec_helper.rb', line 86

def rgeo_multi_line_string(multi_line_string, srid = 4326)
  if lines.one? and String === lines.first
    geometry("MULTILINESTRING(#{lines})")
  else
    Rgeo::Geos::MultiLineString.from_line_strings lines, lines.first.srid
  end
end

#rgeo_multi_polygon(polygons, srid = 4326) ⇒ Object



82
83
84
# File 'lib/georuby-ext/rspec_helper.rb', line 82

def rgeo_multi_polygon(polygons, srid = 4326)
  rgeo_factory.multi_polygon(polygons)
end

#rgeo_point(x = 0, y = 0, srid = 4326) ⇒ Object



78
79
80
# File 'lib/georuby-ext/rspec_helper.rb', line 78

def rgeo_point(x = 0, y = 0, srid = 4326)
  rgeo_factory.point(x, y)
end

#rgeometry(text, srid = 4326) ⇒ Object



94
95
96
# File 'lib/georuby-ext/rspec_helper.rb', line 94

def rgeometry(text, srid = 4326)
  rgeo_factory.parse_wkt text
end