makeCountries.frink

Download or view makeCountries.frink in plain text format


use navigation.frink

println["""
/** This class contains polygons for the outlines of all the countries in
    the world.  For examples of using this to draw maps of the world, see the
    programs drawDymaxion.frink and drawCountries.frink. */

class Country
{
   // The two-letter ISO code for the country
   var ISO2

   // The name of the country
   var name

   // A list of vertices of polygons for the country.
   var borders

   // A dictionary of Country objects.  The key is the two-letter ISO code,
   // and the value is a Country object.
   class var countryList = new dict

   class addCountry[code, cname, borderlist] :=
   {
      c = new Country[code, cname, borderlist]
      countryList@code = c
      return c
   }

   new[code, cname, borderlist] :=
   {
      ISO2 = code
      name = cname
      borders = borderlist
   }

   // This method can be used to get a dictionary containing all countries.
   // see documentation for the countryList variable above.
   class getCountryList[] := countryList
"""]

for line = lines["file:countries.js"]
   if [code, name, borders] = line =~ %r/{code:"(\w+?)",\s*name:"(.*?)",\s*borders:(.*?)}/
   {
      // Sort polygons by size
      borders = eval[borders]
      sort[borders, {|a,b| earthArea[a] <=> earthArea[b]}]
      tBorders = toString[borders] =~ %s/\s+//g  // Remove spaces
      println["  class var $code = Country.addCountry[\"$code\", \"$name\", $tBorders]"]
   }

println["""
}
"""]


Download or view makeCountries.frink in plain text format


This is a program written in the programming language Frink.
For more information, view the Frink Documentation or see More Sample Frink Programs.

Alan Eliasen was born 20145 days, 5 hours, 24 minutes ago.