Class GeoRuby::SimpleFeatures::Envelope
In: lib/geo_ruby/simple_features/envelope.rb
Parent: Object

Contains the bounding box of a geometry

Methods

==   as_georss   as_kml   center   extend   extend!   from_coordinates   from_points   new  

Attributes

lower_corner  [RW] 
srid  [RW] 
upper_corner  [RW] 
with_z  [RW] 

Public Class methods

Creates a new envelope. Accept a sequence of point coordinates as argument : ((x,y),(x,y))

[Source]

     # File lib/geo_ruby/simple_features/envelope.rb, line 126
126:       def self.from_coordinates(points,srid=DEFAULT_SRID,with_z=false)
127:         e = Envelope.new(srid,with_z)
128:         e.lower_corner, e.upper_corner =  points.collect{|point_coords| Point.from_coordinates(point_coords,srid,with_z)}
129:         e
130:       end

Creates a new envelope. Accept an array of 2 points as argument

[Source]

     # File lib/geo_ruby/simple_features/envelope.rb, line 119
119:       def self.from_points(points,srid=DEFAULT_SRID,with_z=false)
120:         e = Envelope.new(srid,with_z)
121:         e.lower_corner, e.upper_corner = points
122:         e
123:       end

Creates a enw Envelope with lower_corner as the first element of the corners array and upper_corner as the second element

[Source]

    # File lib/geo_ruby/simple_features/envelope.rb, line 10
10:       def initialize(srid = DEFAULT_SRID, with_z = false)
11:         @srid = srid
12:         @with_z = with_z
13:       end

Public Instance methods

Tests the equality of line strings

[Source]

    # File lib/geo_ruby/simple_features/envelope.rb, line 39
39:       def ==(other_envelope)
40:         if other_envelope.class != self.class
41:           false
42:         else
43:           upper_corner == other_envelope.upper_corner and lower_corner == other_envelope.lower_corner
44:         end
45:       end

georss serialization: Dialect can be passed as option :dialect and set to :simple (default) :w3cgeo or :gml. Options <tt>:featuretypetag

[Source]

    # File lib/geo_ruby/simple_features/envelope.rb, line 49
49:       def as_georss(options = {})
50:         dialect= options[:dialect] || :simple
51:         case(dialect)
52:         when :simple
53:           geom_attr = ""
54:           geom_attr += " featuretypetag=\"#{options[:featuretypetag]}\"" if options[:featuretypetag]
55:           geom_attr += " relationshiptag=\"#{options[:relationshiptag]}\"" if options[:relationshiptag]
56:           geom_attr += " floor=\"#{options[:floor]}\"" if options[:floor]
57:           geom_attr += " radius=\"#{options[:radius]}\"" if options[:radius]
58:           geom_attr += " elev=\"#{options[:elev]}\"" if options[:elev]
59:           
60:           georss_simple_representation(options.merge(:geom_attr => geom_attr))
61:         when :w3cgeo
62:           georss_w3cgeo_representation(options)
63:         when :gml
64:           georss_gml_representation(options)
65:         end
66:       end

Sends back a latlonaltbox

[Source]

     # File lib/geo_ruby/simple_features/envelope.rb, line 93
 93:       def as_kml(options = {})
 94:         geom_data = ""
 95:         geom_data = "<altitudeMode>#{options[:altitude_mode]}</altitudeMode>\n" if options[:altitude_mode]
 96:         
 97:         allow_z = with_z && (!options[:altitude_mode].nil?) && options[:atitude_mode] != "clampToGround"
 98:         
 99:         kml_representation(options.merge(:geom_data => geom_data,:allow_z => allow_z))
100:       end

Sends back the center of the envelope

[Source]

    # File lib/geo_ruby/simple_features/envelope.rb, line 34
34:       def center
35:         Point.from_x_y((lower_corner.x + upper_corner.x)/2,(lower_corner.y + upper_corner.y)/2)
36:       end

Merges the argument with the current evelope and sends back a new envelope without changing the current one

[Source]

    # File lib/geo_ruby/simple_features/envelope.rb, line 26
26:       def extend(envelope)
27:         e = Envelope.from_points([Point.from_x_y(lower_corner.x,lower_corner.y),
28:                           Point.from_x_y(upper_corner.x,upper_corner.y)],srid,with_z)
29:         e.extend!(envelope)
30:         e
31:       end

Merges the argument with the current evelope

[Source]

    # File lib/geo_ruby/simple_features/envelope.rb, line 16
16:       def extend!(envelope)
17:         lower_corner.x = [lower_corner.x,envelope.lower_corner.x].min
18:         lower_corner.y = [lower_corner.y,envelope.lower_corner.y].min
19:         upper_corner.x = [upper_corner.x,envelope.upper_corner.x].max
20:         upper_corner.y = [upper_corner.y,envelope.upper_corner.y].max
21:         self
22:       end

[Validate]