Class: GeoRuby::SimpleFeatures::Geometry

Inherits:
Object
  • Object
show all
Defined in:
lib/georuby-ext/georuby/geometry.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.srid!(geometries) ⇒ Object



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

def self.srid!(geometries)
  geometries.first.srid.tap do |srid|
    raise "SRIDs are not uniq in #{geometries.inspect}" if geometries.any? { |geometry| geometry.srid != srid }
  end unless geometries.blank?
end

.to_kml(*geometries) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/georuby-ext/georuby/geometry.rb', line 38

def self.to_kml(*geometries)
  <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
  <Document>
    <Placemark>
    <MultiGeometry>
    #{geometries.map(&:kml_representation).join("\n")}
    </MultiGeometry>
  </Placemark>
  </Document>
</kml>
EOF
end

Instance Method Details

#inspectObject



3
4
5
# File 'lib/georuby-ext/georuby/geometry.rb', line 3

def inspect
  "#<#{self.class}:#{object_id} \"#{to_ewkt}>\""
end

#srid_instanceObject



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

def srid_instance
  @srid_instance ||= GeoRuby::SimpleFeatures::Srid.new(srid)
end

#to_geometryObject



21
22
23
# File 'lib/georuby-ext/georuby/geometry.rb', line 21

def to_geometry
  self
end

#to_googleObject



17
18
19
# File 'lib/georuby-ext/georuby/geometry.rb', line 17

def to_google
  project_to 900913
end

#to_wgs84Object



13
14
15
# File 'lib/georuby-ext/georuby/geometry.rb', line 13

def to_wgs84
  project_to 4326
end

#wgs84?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/georuby-ext/georuby/geometry.rb', line 9

def wgs84?
  srid == 4326
end