Skip to content

Instantly share code, notes, and snippets.

@cheald
Created January 2, 2013 00:31
Show Gist options
  • Save cheald/4431281 to your computer and use it in GitHub Desktop.
Save cheald/4431281 to your computer and use it in GitHub Desktop.
desert:
lat: [1, 50]
long [20, 60]
file: "netcdf/GCS/biomes/Desert.nc"
var: dsrt
marsh:
lat: [51, 150]
long [120, 160]
file: "netcdf/GCS/biomes/Marsh.nc"
var: mrsh
class YourController
def new
...
biome = setup_biome
end
private
def setup_biome
biome = YourModel.get_biome params[:lat], params[:long]
# Set your instance vars and read the file here
end
end
class YourModel
BIOMES = YAML::load open("biomes.yml").read
def self.get_biome_config(lat, long)
BIOMES.detect do |biome|
biome["lat"][0] < lat && biome["lat"][1] > lat &&
biome["long"][0] < long && biome["long"][1] > lat
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment