Created
January 2, 2013 00:31
-
-
Save cheald/4431281 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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