class NSWTopo::Projection

Attributes

proj4[R]
to_s[R]
to_str[R]

Public Class Methods

azimuthal_equidistant(lon, lat) click to toggle source
# File lib/nswtopo/gis/projection.rb, line 38
def self.azimuthal_equidistant(lon, lat)
  new("+proj=aeqd +lon_0=#{lon} +lat_0=#{lat} +k_0=1 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs")
end
new(string_or_path) click to toggle source
# File lib/nswtopo/gis/projection.rb, line 3
def initialize(string_or_path)
  @proj4 = OS.gdalsrsinfo("-o", "proj4", string_or_path).chomp.strip
  raise "no georeferencing found: %s" % string_or_path if @proj4.empty?
end
transverse_mercator(lon, lat) click to toggle source
# File lib/nswtopo/gis/projection.rb, line 34
def self.transverse_mercator(lon, lat)
  new("+proj=tmerc +lon_0=#{lon} +lat_0=#{lat} +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs")
end
utm(zone, south = true) click to toggle source
# File lib/nswtopo/gis/projection.rb, line 26
def self.utm(zone, south = true)
  new("+proj=utm +zone=#{zone}#{' +south' if south} +ellps=WGS84 +datum=WGS84 +units=m +no_defs")
end
utm_hull(zone) click to toggle source
# File lib/nswtopo/gis/projection.rb, line 50
def self.utm_hull(zone)
  longitudes = [31, 30].map { |offset| (zone - offset) * 6.0 }
  latitudes = [-80.0, 84.0]
  longitudes.product(latitudes).values_at(0,2,3,1)
end
utm_zones(collection) click to toggle source
# File lib/nswtopo/gis/projection.rb, line 42
def self.utm_zones(collection)
  collection.reproject_to_wgs84.bounds.first.map do |longitude|
    (longitude / 6).floor + 31
  end.yield_self do |min, max|
    min..max
  end
end
wgs84() click to toggle source
# File lib/nswtopo/gis/projection.rb, line 30
def self.wgs84
  new("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs")
end

Public Instance Methods

==(other) click to toggle source
# File lib/nswtopo/gis/projection.rb, line 18
def ==(other)
  proj4 == other.proj4
end
Also aliased as: eql?
eql?(other)
Alias for: ==