Comunas de Chile
A Ruby representation of the Chilean administrative areas as described by the SUBDERE.
Disclaimer
This library is not developed, supported nor endorsed in any way by the Chilean Subsecretaría de Desarrollo Regional y Administrativo (SUBDERE), nor any related institution.
Data Sources
This library is based on the publicly available information from the SUBDERE related to the Codificación Única Territorial. The sources quoted by the document on which this library is based are:
- Decreto Supremo No 1439, del Ministerio del Interior, publicado en el Diario Oficial del 8 de Mayo de 2000
- Decreto Supremo No 1352, del Ministerio del Interior, publicado en el Diario Oficial del 23 de Agosto de 2008
- Decreto Exento No 910, del Ministerio del Interior, publicado en el Diario Oficial del 14 de Junio de 2007
- Decreto Exento No 817, del Ministerio del Interior, publicado en el Diario Oficial del 26 de Marzo de 2010
Usage
Add the gem to your Gemfile:
# Gemfile
gem 'chilean_cities', '~> 1.0' # see semver.org
Then generate the chilean administrative areas:
require 'chilean_cities'
chile = ChileanCities::Factory.instance
chile.generate!
# and use them as you want : )
chile.regiones.select{ |region| region.iso_3166_2 == 'CL-LL' }.first.name
# => "Región de los Lagos"
chile.provincias.select{ |provincia| provincia.name =~ /Magallanes/ }.first.comunas.map{ |comuna| comuna.name }
# => ["Punta Arenas", "Laguna Blanca", "Río Verde", "San Gregorio"]
Schema.org
The generated administrative areas representations do partially enforce the Place schema (see schema.org and the schemas specs for details):
# comunas, provincias and regiones do implement the `contained_in` method:
chile.comunas.select{ |comuna| comuna.name == 'Quellón' }.first.contained_in.name
# => "Chiloé"
Note about the previous version (v0.1.0
)
If you were using this gem in the past and are looking for its ancient behaviour, please modify your Gemfile
to checkout the v0.1.0
tag (it's been a few years, so this is not recommended):
# Gemfile
gem 'chilean_cities', git: 'https://github.com/gonzalo-bulnes/chilean_cities.git', tag: 'v0.1.0'
The same tag does also point to the corresponding documentation.
Code of Conduct
Please note that by participating in this project, you agree to abide by its code of conduct. That is true for pull requests, and also when participating in issues.
See Also
- The Wikipedia article about the ISO 3166-2 standard
- Comunas de Chile (gist) (a Ruby on Rails seed and a JSON document)
- The Schema.org AdministrativeArea schema
- An interesting overview of how the administrative areas can be categorized for mapping
- The OpenStreetMap relations corresponding to the described administrative areas
Credits
Part of this gem was crafted during my 10% free focus work time at Acid Labs. Thanks @acidlabs!
License
ChileanCities provides a Ruby representation of the Chilean _administrative areas_.
Copyright (C) 2013, 2020 Gonzalo Bulnes Guilpain
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.