A set of plugins to help on managing geographic information

This commit is contained in:
ahwelp
2023-01-24 20:41:37 +00:00
parent 616a97f16c
commit a60cfcec3a
61 changed files with 7895 additions and 0 deletions
+9
View File
@@ -0,0 +1,9 @@
<?php
use App\Core\Template\Output as Output;
use Routes\RouteCollection as RouteCollection;
RouteCollection::get('*', function() {
Output::addSubmenu('geo', 'Geográfico', "<i class='fa fa-globe'></i>", ['class' => 'nav-link'] );
//Output::addOnSubmenu('geo', '/auth', 'Usuários', "<i class='fa fa-globe'></i>", ['class' => 'nav-link']);
}, -10)->doIgnore();
+179
View File
@@ -0,0 +1,179 @@
<?php
namespace App\Geo\City;
use ORM\DBInstance;
use \App\Core\Template\Output as Output;
use App\Core\Datatables\Datatables as Datatables;
use \App\Geo\City\Classes\City as City;
class CityController extends \DefaultController
{
protected $_class = City::class;
protected $_baseUrl = 'city';
/**
* Index
* Show the main City list
*/
function index()
{
Output::render('index');
}
/**
* Create
*
* Render the main City formulary
*/
function create()
{
Output::render('form', ['id' => 0]);
}
/**
* Store
*
* Store the param on the database
* @param City $city
*/
function store(City $city)
{
}
/**
* Search
*
* Store the param on the database
* @param City $city
*/
function search()
{
}
/**
* Show
*
* Render one register
*
* @param City $city
*/
function show($city)
{
if(is_ajax_request()){
\RR\Response::json( City::findOne(['code' => ['=', $city]]) )->send();
return;
}else{
$city = City::findOne($city);
}
}
/**
* Edit
*
* Render the formular for a database City
*
* @param City $city
*/
function edit(City $city)
{
Output::render('form', $city);
}
/**
* Update
* Store the changes of the param on the database
*
* @param City $city
*/
function update(City $city)
{
}
/**
* Destroy
* If the object has soft delete.
*
* @param City $city
*/
function destroy(City $city)
{
}
/**
* Purge
* Remove object even with soft delete.
*
* @param City $city
*/
function purge(City $city)
{
}
public static function searchOrCreate($data)
{
if ($city = City::findOne(['code' => ['=', $data->ibge]])) {
return $city;
}
$city = new City();
$city->name = $data->localidade;
$city->code = $data->ibge;
$city->state_id = $data->state;
$city->country_id = $data->country;
$city->save();
return $city;
}
function searchTable()
{
$records = [];
$total = 0;
try {
if ($_POST['search']['value'] != '') {
$search = [];
foreach ($this->_class::_searchable as $searchable) {
$search[$searchable] = ['OR like', $_POST['search']['value']];
}
$records = $this->_class::findMany($search, $this->_class::_listable)->get(true);
} else {
$records = $this->_class::findAll($this->_class::_listable, ['limit' => $_POST['length'], 'offset' => $_POST['start']])->get();
}
$total = DBInstance::queryOne("SELECT count(*) as count FROM {" . $this->_class::_tableName . '}')->count;
} catch (\Exception $e) {
if (APP_STATUS != 'production') {
for ($i = $_POST['start']; $i <= $_POST['length'] + $_POST['start']; $i++) {
$line = new \stdClass();
$line->id = $i;
$line->name = md5($i);
$records[] = $line;
}
$total = 10000;
}
}
if (!is_array($records)) {
$records = [$records];
}
foreach ($records as $record) {
if ($_GET['selective'] == 'true') {
$record->id = Datatables::getActionMenu($record->id, $this->_baseUrl);
} else {
$record->id = Datatables::getSelectMenu($record->code);
}
}
\RR\Response::json([
'draw' => $_POST['draw'],
'recordsTotal' => $total,
'recordsFiltered' => $total,
'data' => $records
])->send();
}
}
+35
View File
@@ -0,0 +1,35 @@
<?php
use App\Core\Template\Output as Output;
use Routes\RouteCollection as RouteCollection;
use \App\Geo\City\Classes\City as City;
//Menu itens
RouteCollection::get('*', function () {
//Output::addMenu('/city', 'city', "<i class='fa fa-fa-cubes'></i>", ['class' => 'nav-link']);
Output::addOnSubmenu('geo', '/city', 'Cidades', "", ['class' => 'nav-link']);
}, -10)->doIgnore();
RouteCollection::group("/city", function () {
RouteCollection::get("/", "\App\Geo\City\CityController@index");
RouteCollection::get("/table", "\App\Geo\City\CityController@table");
RouteCollection::post("/table", "\App\Geo\City\CityController@searchTable");
RouteCollection::get("/form", "\App\Geo\City\CityController@create");
RouteCollection::post("/", "\App\Geo\City\CityController@store");
RouteCollection::post("/search", "\App\Geo\City\CityController@search");
RouteCollection::get("/[i:id]", "\App\Geo\City\CityController@show");
RouteCollection::get("/[i:id]/edit", "\App\Geo\City\CityController@edit");
RouteCollection::put("/[i:id]/edit", "\App\Geo\City\CityController@update");
RouteCollection::delete("/[i:id]", "\App\Geo\City\CityController@destroy");
RouteCollection::get("/test", function () {
$city = City::findOne(180)->with(['country']);
$form = file_get_contents(__DIR__ . '/views/form.mustache');
$m = new Mustache_Engine(array('entity_flags' => ENT_QUOTES));
echo $m->render($form, $city); // "Hello World!"
});
});
+61
View File
@@ -0,0 +1,61 @@
<?php
namespace App\Geo\City\Classes;
use ORM\Entity as Entity;
use App\geo\State\Classes\State as State;
use App\Geo\Country\Classes\Country as country;
use App\Geo\Postal\Classes\Postal;
class City extends Entity {
const _tableName = "geo_cities";
protected $_timestamps = true;
protected $_softdelete = true;
const _properties = Array(
'code',
'name',
'description',
'state_id',
'country_id',
);
protected $_ignore = Array(
'state',
'postals',
'country'
);
const _listable = Array(
'id',
'name',
'code',
'state_id'
);
const _searchable = Array(
'name',
'code'
);
const _orderable = Array(
'id',
'code',
'name'
);
function state(){
return $this->belongsTo(State::class, 'state_id');
}
function country(){
return $this->belongsTo(Country::class, 'country_id');
}
function postal(){
return $this->hasMany(Postal::class, 'city_id');
}
}
File diff suppressed because it is too large Load Diff
+497
View File
@@ -0,0 +1,497 @@
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Aceguá', 4300034, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Água Santa', 4300059, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Agudo', 4300109, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Ajuricaba', 4300208, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Alecrim', 4300307, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Alegrete', 4300406, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Alegria', 4300455, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Almirante Tamandaré do Sul', 4300471, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Alpestre', 4300505, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Alto Alegre', 4300554, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Alto Feliz', 4300570, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Alvorada', 4300604, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Amaral Ferrador', 4300638, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Ametista do Sul', 4300646, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('André da Rocha', 4300661, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Anta Gorda', 4300703, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Antônio Prado', 4300802, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Arambaré', 4300851, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Araricá', 4300877, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Aratiba', 4300901, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Arroio Grande', 4301305, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Arroio do Meio', 4301008, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Arroio do Padre', 4301073, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Arroio do Sal', 4301057, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Arroio do Tigre', 4301206, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Arroio dos Ratos', 4301107, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Arvorezinha', 4301404, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Augusto Pestana', 4301503, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Áurea', 4301552, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Bagé', 4301602, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Balneário Pinhal', 4301636, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Barão', 4301651, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Barão de Cotegipe', 4301701, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Barão do Triunfo', 4301750, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Barra Funda', 4301958, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Barra do Guarita', 4301859, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Barra do Quaraí', 4301875, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Barra do Ribeiro', 4301909, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Barra do Rio Azul', 4301925, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Barracão', 4301800, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Barros Cassal', 4302006, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Benjamin Constant do Sul', 4302055, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Bento Gonçalves', 4302105, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Boa Vista das Missões', 4302154, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Boa Vista do Buricá', 4302204, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Boa Vista do Cadeado', 4302220, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Boa Vista do Incra', 4302238, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Boa Vista do Sul', 4302253, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Bom Jesus', 4302303, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Bom Princípio', 4302352, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Bom Progresso', 4302378, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Bom Retiro do Sul', 4302402, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Boqueirão do Leão', 4302451, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Bossoroca', 4302501, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Bozano', 4302584, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Braga', 4302600, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Brochier', 4302659, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Butiá', 4302709, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Caçapava do Sul', 4302808, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Cacequi', 4302907, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Cachoeira do Sul', 4303004, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Cachoeirinha', 4303103, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Cacique Doble', 4303202, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Caibaté', 4303301, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Caiçara', 4303400, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Camaquã', 4303509, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Camargo', 4303558, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Cambará do Sul', 4303608, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Campestre da Serra', 4303673, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Campina das Missões', 4303707, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Campinas do Sul', 4303806, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Campo Bom', 4303905, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Campo Novo', 4304002, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Campos Borges', 4304101, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Candelária', 4304200, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Cândido Godói', 4304309, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Candiota', 4304358, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Canela', 4304408, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Canguçu', 4304507, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Canoas', 4304606, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Canudos do Vale', 4304614, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Capão Bonito do Sul', 4304622, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Capão da Canoa', 4304630, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Capão do Cipó', 4304655, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Capão do Leão', 4304663, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Capela de Santana', 4304689, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Capitão', 4304697, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Capivari do Sul', 4304671, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Caraá', 4304713, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Carazinho', 4304705, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Carlos Barbosa', 4304804, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Carlos Gomes', 4304853, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Casca', 4304903, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Caseiros', 4304952, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Catuípe', 4305009, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Caxias do Sul', 4305108, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Centenário', 4305116, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Cerrito', 4305124, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Cerro Branco', 4305132, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Cerro Grande', 4305157, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Cerro Grande do Sul', 4305173, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Cerro Largo', 4305207, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Chapada', 4305306, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Charqueadas', 4305355, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Charrua', 4305371, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Chiapetta', 4305405, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Chuí', 4305439, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Chuvisca', 4305447, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Cidreira', 4305454, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Ciríaco', 4305504, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Colinas', 4305587, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Colorado', 4305603, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Condor', 4305702, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Constantina', 4305801, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Coqueiro Baixo', 4305835, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Coqueiros do Sul', 4305850, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Coronel Barros', 4305871, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Coronel Bicaco', 4305900, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Coronel Pilar', 4305934, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Cotiporã', 4305959, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Coxilha', 4305975, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Crissiumal', 4306007, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Cristal', 4306056, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Cristal do Sul', 4306072, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Cruz Alta', 4306106, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Cruzaltense', 4306130, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Cruzeiro do Sul', 4306205, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('David Canabarro', 4306304, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Derrubadas', 4306320, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Dezesseis de Novembro', 4306353, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Dilermando de Aguiar', 4306379, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Dois Irmãos', 4306403, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Dois Irmãos das Missões', 4306429, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Dois Lajeados', 4306452, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Dom Feliciano', 4306502, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Dom Pedrito', 4306601, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Dom Pedro de Alcântara', 4306551, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Dona Francisca', 4306700, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Doutor Maurício Cardoso', 4306734, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Doutor Ricardo', 4306759, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Eldorado do Sul', 4306767, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Encantado', 4306809, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Encruzilhada do Sul', 4306908, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Engenho Velho', 4306924, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Entre Rios do Sul', 4306957, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Entre-Ijuís', 4306932, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Erebango', 4306973, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Erechim', 4307005, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Ernestina', 4307054, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Erval Grande', 4307203, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Erval Seco', 4307302, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Esmeralda', 4307401, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Esperança do Sul', 4307450, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Espumoso', 4307500, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Estação', 4307559, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Estância Velha', 4307609, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Esteio', 4307708, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Estrela', 4307807, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Estrela Velha', 4307815, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Eugênio de Castro', 4307831, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Fagundes Varela', 4307864, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Farroupilha', 4307906, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Faxinal do Soturno', 4308003, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Faxinalzinho', 4308052, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Fazenda Vilanova', 4308078, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Feliz', 4308102, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Flores da Cunha', 4308201, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Floriano Peixoto', 4308250, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Fontoura Xavier', 4308300, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Formigueiro', 4308409, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Forquetinha', 4308433, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Fortaleza dos Valos', 4308458, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Frederico Westphalen', 4308508, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Garibaldi', 4308607, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Garruchos', 4308656, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Gaurama', 4308706, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('General Câmara', 4308805, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Gentil', 4308854, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Getúlio Vargas', 4308904, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Giruá', 4309001, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Glorinha', 4309050, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Gramado', 4309100, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Gramado Xavier', 4309159, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Gramado dos Loureiros', 4309126, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Gravataí', 4309209, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Guabiju', 4309258, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Guaíba', 4309308, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Guaporé', 4309407, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Guarani das Missões', 4309506, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Harmonia', 4309555, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Herval', 4307104, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Herveiras', 4309571, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Horizontina', 4309605, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Hulha Negra', 4309654, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Humaitá', 4309704, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Ibarama', 4309753, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Ibiaçá', 4309803, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Ibiraiaras', 4309902, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Ibirapuitã', 4309951, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Ibirubá', 4310009, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Igrejinha', 4310108, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Ijuí', 4310207, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Ilópolis', 4310306, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Imbé', 4310330, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Imigrante', 4310363, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Independência', 4310405, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Inhacorá', 4310413, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Ipê', 4310439, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Ipiranga do Sul', 4310462, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Iraí', 4310504, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Itaara', 4310538, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Itacurubi', 4310553, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Itapuca', 4310579, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Itaqui', 4310603, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Itati', 4310652, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Itatiba do Sul', 4310702, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Ivorá', 4310751, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Ivoti', 4310801, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Jaboticaba', 4310850, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Jacuizinho', 4310876, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Jacutinga', 4310900, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Jaguarão', 4311007, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Jaguari', 4311106, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Jaquirana', 4311122, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Jari', 4311130, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Jóia', 4311155, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Júlio de Castilhos', 4311205, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Lagoa Bonita do Sul', 4311239, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Lagoa Vermelha', 4311304, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Lagoa dos Três Cantos', 4311270, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Lagoão', 4311254, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Lajeado', 4311403, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Lajeado do Bugre', 4311429, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Lavras do Sul', 4311502, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Liberato Salzano', 4311601, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Lindolfo Collor', 4311627, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Linha Nova', 4311643, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Maçambará', 4311718, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Machadinho', 4311700, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Mampituba', 4311734, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Manoel Viana', 4311759, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Maquiné', 4311775, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Maratá', 4311791, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Marau', 4311809, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Marcelino Ramos', 4311908, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Mariana Pimentel', 4311981, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Mariano Moro', 4312005, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Marques de Souza', 4312054, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Mata', 4312104, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Mato Castelhano', 4312138, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Mato Leitão', 4312153, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Mato Queimado', 4312179, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Maximiliano de Almeida', 4312203, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Minas do Leão', 4312252, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Miraguaí', 4312302, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Montauri', 4312351, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Monte Alegre dos Campos', 4312377, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Monte Belo do Sul', 4312385, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Montenegro', 4312401, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Mormaço', 4312427, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Morrinhos do Sul', 4312443, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Morro Redondo', 4312450, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Morro Reuter', 4312476, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Mostardas', 4312500, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Muçum', 4312609, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Muitos Capões', 4312617, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Muliterno', 4312625, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Não-Me-Toque', 4312658, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Nicolau Vergueiro', 4312674, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Nonoai', 4312708, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Nova Alvorada', 4312757, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Nova Araçá', 4312807, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Nova Bassano', 4312906, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Nova Boa Vista', 4312955, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Nova Bréscia', 4313003, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Nova Candelária', 4313011, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Nova Esperança do Sul', 4313037, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Nova Hartz', 4313060, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Nova Pádua', 4313086, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Nova Palma', 4313102, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Nova Petrópolis', 4313201, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Nova Prata', 4313300, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Nova Ramada', 4313334, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Nova Roma do Sul', 4313359, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Nova Santa Rita', 4313375, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Novo Barreiro', 4313490, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Novo Cabrais', 4313391, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Novo Hamburgo', 4313409, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Novo Machado', 4313425, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Novo Tiradentes', 4313441, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Novo Xingu', 4313466, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Osório', 4313508, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Paim Filho', 4313607, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Palmares do Sul', 4313656, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Palmeira das Missões', 4313706, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Palmitinho', 4313805, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Panambi', 4313904, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Pantano Grande', 4313953, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Paraí', 4314001, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Paraíso do Sul', 4314027, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Pareci Novo', 4314035, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Parobé', 4314050, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Passa Sete', 4314068, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Passo Fundo', 4314100, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Passo do Sobrado', 4314076, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Paulo Bento', 4314134, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Paverama', 4314159, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Pedras Altas', 4314175, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Pedro Osório', 4314209, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Pejuçara', 4314308, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Pelotas', 4314407, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Picada Café', 4314423, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Pinhal', 4314456, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Pinhal Grande', 4314472, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Pinhal da Serra', 4314464, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Pinheirinho do Vale', 4314498, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Pinheiro Machado', 4314506, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Pinto Bandeira', 4314548, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Pirapó', 4314555, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Piratini', 4314605, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Planalto', 4314704, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Poço das Antas', 4314753, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Pontão', 4314779, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Ponte Preta', 4314787, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Portão', 4314803, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Porto Alegre', 4314902, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Porto Lucena', 4315008, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Porto Mauá', 4315057, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Porto Vera Cruz', 4315073, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Porto Xavier', 4315107, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Pouso Novo', 4315131, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Presidente Lucena', 4315149, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Progresso', 4315156, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Protásio Alves', 4315172, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Putinga', 4315206, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Quaraí', 4315305, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Quatro Irmãos', 4315313, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Quevedos', 4315321, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Quinze de Novembro', 4315354, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Redentora', 4315404, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Relvado', 4315453, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Restinga Sêca', 4315503, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Rio Grande', 4315602, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Rio Pardo', 4315701, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Rio dos Índios', 4315552, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Riozinho', 4315750, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Roca Sales', 4315800, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Rodeio Bonito', 4315909, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Rolador', 4315958, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Rolante', 4316006, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Ronda Alta', 4316105, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Rondinha', 4316204, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Roque Gonzales', 4316303, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Rosário do Sul', 4316402, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Sagrada Família', 4316428, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Saldanha Marinho', 4316436, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Salto do Jacuí', 4316451, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Salvador das Missões', 4316477, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Salvador do Sul', 4316501, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Sananduva', 4316600, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('SantAna do Livramento', 4317103, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Santa Bárbara do Sul', 4316709, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Santa Cecília do Sul', 4316733, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Santa Clara do Sul', 4316758, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Santa Cruz do Sul', 4316808, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Santa Margarida do Sul', 4316972, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Santa Maria', 4316907, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Santa Maria do Herval', 4316956, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Santa Rosa', 4317202, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Santa Tereza', 4317251, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Santa Vitória do Palmar', 4317301, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Santana da Boa Vista', 4317004, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Santiago', 4317400, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Santo Ângelo', 4317509, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Santo Antônio da Patrulha', 4317608, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Santo Antônio das Missões', 4317707, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Santo Antônio do Palma', 4317558, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Santo Antônio do Planalto', 4317756, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Santo Augusto', 4317806, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Santo Cristo', 4317905, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Santo Expedito do Sul', 4317954, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('São Borja', 4318002, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('São Domingos do Sul', 4318051, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('São Francisco de Assis', 4318101, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('São Francisco de Paula', 4318200, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('São Gabriel', 4318309, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('São Jerônimo', 4318408, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('São João da Urtiga', 4318424, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('São João do Polêsine', 4318432, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('São Jorge', 4318440, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('São José das Missões', 4318457, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('São José do Herval', 4318465, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('São José do Hortêncio', 4318481, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('São José do Inhacorá', 4318499, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('São José do Norte', 4318507, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('São José do Ouro', 4318606, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('São José do Sul', 4318614, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('São José dos Ausentes', 4318622, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('São Leopoldo', 4318705, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('São Lourenço do Sul', 4318804, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('São Luiz Gonzaga', 4318903, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('São Marcos', 4319000, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('São Martinho', 4319109, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('São Martinho da Serra', 4319125, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('São Miguel das Missões', 4319158, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('São Nicolau', 4319208, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('São Paulo das Missões', 4319307, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('São Pedro da Serra', 4319356, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('São Pedro das Missões', 4319364, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('São Pedro do Butiá', 4319372, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('São Pedro do Sul', 4319406, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('São Sebastião do Caí', 4319505, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('São Sepé', 4319604, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('São Valentim', 4319703, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('São Valentim do Sul', 4319711, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('São Valério do Sul', 4319737, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('São Vendelino', 4319752, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('São Vicente do Sul', 4319802, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Sapiranga', 4319901, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Sapucaia do Sul', 4320008, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Sarandi', 4320107, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Seberi', 4320206, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Sede Nova', 4320230, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Segredo', 4320263, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Selbach', 4320305, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Senador Salgado Filho', 4320321, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Sentinela do Sul', 4320354, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Serafina Corrêa', 4320404, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Sério', 4320453, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Sertão', 4320503, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Sertão Santana', 4320552, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Sete de Setembro', 4320578, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Severiano de Almeida', 4320602, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Silveira Martins', 4320651, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Sinimbu', 4320677, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Sobradinho', 4320701, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Soledade', 4320800, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Tabaí', 4320859, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Tapejara', 4320909, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Tapera', 4321006, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Tapes', 4321105, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Taquara', 4321204, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Taquari', 4321303, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Taquaruçu do Sul', 4321329, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Tavares', 4321352, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Tenente Portela', 4321402, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Terra de Areia', 4321436, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Teutônia', 4321451, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Tio Hugo', 4321469, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Tiradentes do Sul', 4321477, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Toropi', 4321493, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Torres', 4321501, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Tramandaí', 4321600, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Travesseiro', 4321626, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Três Arroios', 4321634, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Três Cachoeiras', 4321667, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Três Coroas', 4321709, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Três Forquilhas', 4321832, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Três Palmeiras', 4321857, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Três Passos', 4321907, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Três de Maio', 4321808, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Trindade do Sul', 4321956, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Triunfo', 4322004, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Tucunduva', 4322103, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Tunas', 4322152, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Tupanci do Sul', 4322186, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Tupanciretã', 4322202, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Tupandi', 4322251, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Tuparendi', 4322301, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Turuçu', 4322327, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Ubiretama', 4322343, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('União da Serra', 4322350, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Unistalda', 4322376, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Uruguaiana', 4322400, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Vacaria', 4322509, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Vale Real', 4322541, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Vale Verde', 4322525, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Vale do Sol', 4322533, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Vanini', 4322558, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Venâncio Aires', 4322608, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Vera Cruz', 4322707, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Veranópolis', 4322806, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Vespasiano Corrêa', 4322855, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Viadutos', 4322905, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Viamão', 4323002, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Vicente Dutra', 4323101, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Victor Graeff', 4323200, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Vila Flores', 4323309, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Vila Lângaro', 4323358, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Vila Maria', 4323408, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Vila Nova do Sul', 4323457, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Vista Alegre', 4323507, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Vista Alegre do Prata', 4323606, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Vista Gaúcha', 4323705, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Vitória das Missões', 4323754, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Westfália', 4323770, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
INSERT INTO {geo_cities} (name, code, country_id, state_id) VALUES ('Xangri-lá', 4323804, (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'), (SELECT id FROM {geo_states} WHERE shortname = 'RS'));
+39
View File
@@ -0,0 +1,39 @@
<?php
use Schema\Wrapper as Wrapper;
use App\Core\Sanity\MigratorController as Migrator;
function geo_city_upgrade($pluginversion) {
if ($pluginversion < "0.0.1") {
$table = Wrapper::get_table("geo_cities");
$table->addColumn("state_id", "integer", Array("null" => false));
$table->addColumn("country_id", "integer", Array("null" => false));
$table->addColumn("code", "integer", Array("null" => true));
$table->addColumn("name", "string", Array("null" => false));
$table->addColumn("description", "text", Array("null" => true));
$table->addTimestamps();
$table->addSoftDelete();
$table->addForeignKey('state_id', Wrapper::get_table('geo_states'));
$table->addForeignKey('country_id', Wrapper::get_table('geo_countries'));
$table->create();
Wrapper::exec(file_get_contents(__DIR__.'/001_seed_rs_cities.sql') );
Migrator::getInstance()->update_plugin_version("geo_city", "1.0.0");
return;
}
//if ($pluginversion < "0.0.2") {
//$table = Wrapper::get_table("geo_city");
//Migrator::getInstance()->update_plugin_version("geo_city", "1.0.1");
//return;
//}
}
function geo_city_rollback($pluginversion) {
if($pluginversion > "0.0.1"){
$table = Wrapper::get_table("geo_cities");
$table->drop();
return;
}
}
+2
View File
@@ -0,0 +1,2 @@
<?php
$lang["city"]["module_name"] = "City";
+2
View File
@@ -0,0 +1,2 @@
<?php
$lang["city"]["module_name"] = "City";
+10
View File
@@ -0,0 +1,10 @@
<?php
$plugin->name = "geo_city";
$plugin->version = "1.0.0";
$plugin->require = Array(
Array("name" => "geo_params", "version" => "1.0.0"),
Array("name" => "geo_country", "version" => "1.0.0"),
Array("name" => "geo_state", "version" => "1.0.0")
);
+16
View File
@@ -0,0 +1,16 @@
{{#id}}
<form method="POST" action="/city/{{id}}/edit">
<input type="hidden" name="id" value="{{id}}" />
<input type="hidden" name="_method" value="put" />
{{/id}}
{{^id}}
<form method="POST" action="/city">
<input type="hidden" name="id" value="" />
{{/id}}
<input type='text' name='id' value='{{id}}' />
<input type='text' name='name' value='{{name}}' />
<input type='text' name='state' value='{{state.shortname}}' />
<input type='text' name='country' value='{{country.name}}' />
</form>
+3
View File
@@ -0,0 +1,3 @@
<a href='/city/form' >Adicionar </a>
<div class="table-responsive remote-datatable" data-source="/city/table?selective=true"></div>
+12
View File
@@ -0,0 +1,12 @@
<div class="table-responsive">
<table class='table datatable' data-src="/city/quicksearch?selective=true" style="width: 100%">
<thead>
<tr>
<th data-field='id' data-orderable="false">Id</th>
<th data-field='type'>Tipo</th>
<th data-field='name'>Nome</th>
<th data-field='number'>N Cadastro</th>
</tr>
</thead>
</table>
</div>
+115
View File
@@ -0,0 +1,115 @@
<?php
namespace App\Geo\Country;
use \App\Core\Template\Output as Output;
use \App\Geo\Country\Classes\Country as Country;
class CountryController extends \DefaultController{
protected $_class = Country::class;
protected $_baseUrl = 'country';
/**
* Index
* Show the main Country list
*/
function index(){
$list = Array();
for($i = 0; $i <= 10; $i++){
$obj = Array();
$obj['id'] = $i;
$obj['value'] = md5($i);
$obj['description'] = sha1($i);
$list[] = $obj;
}
Output::render('index', Array('list' => $list));
}
/**
* Create
*
* Render the main Country formulary
*/
function create(){
Output::render('form', ['id' => 0]);
}
/**
* Store
*
* Store the param on the database
* @param Country $country
*/
function store(Country $country){
}
/**
* Search
*
* Store the param on the database
* @param Country $country
*/
function search(){
}
/**
* Show
*
* Render one register
*
* @param Country $country
*/
function show(Country $country){
}
/**
* Edit
*
* Render the formular for a database Country
*
* @param Country $country
*/
function edit(Country $country){
Output::render('form', $country);
}
/**
* Update
* Store the changes of the param on the database
*
* @param Country $country
*/
function update(Country $country){
}
/**
* Destroy
* If the object has soft delete.
*
* @param Country $country
*/
function destroy(Country $country){
}
/**
* Purge
* Remove object even with soft delete.
*
* @param Country $country
*/
function purge(Country $country){
}
function raw(){
var_dump( Country::findOne('25')->with(['states']) );
}
}
+24
View File
@@ -0,0 +1,24 @@
<?php
use App\Core\Template\Output as Output;
use Routes\RouteCollection as RouteCollection;
//Menu itens
RouteCollection::get('*', function() {
//Output::addMenu('/country', 'country', "<i class='fa fa-fa-cubes'></i>", ['class' => 'nav-link']);
Output::addOnSubmenu('geo', '/country', 'Paises', "", ['class' => 'nav-link']);
}, -10)->doIgnore();
RouteCollection::group("/country", function(){
RouteCollection::get ("/", "\App\Geo\Country\CountryController@index");
RouteCollection::get ("/table", "\App\Geo\Country\CountryController@table");
RouteCollection::post ("/table", "\App\Geo\Country\CountryController@searchTable");
RouteCollection::get ("/form", "\App\Geo\Country\CountryController@create");
RouteCollection::get ("/raw", "\App\Geo\Country\CountryController@raw");
RouteCollection::post ("/", "\App\Geo\Country\CountryController@store");
RouteCollection::post ("/search", "\App\Geo\Country\CountryController@search");
RouteCollection::get ("/[i:id]", "\App\Geo\Country\CountryController@show");
RouteCollection::get ("/[i:id]/edit", "\App\Geo\Country\CountryController@edit");
RouteCollection::put ("/[i:id]/edit", "\App\Geo\Country\CountryController@update");
RouteCollection::delete("/[i:id]", "\App\Geo\Country\CountryController@destroy");
});
+28
View File
@@ -0,0 +1,28 @@
<?php
namespace App\Geo\Country\Classes;
use ORM\Entity as Entity;
use App\Geo\State\Classes\State as State;
class Country extends Entity {
const _tableName = "geo_countries";
const _listable = Array(
'id',
'name',
'code',
'iso2',
'iso3',
);
const _orderable = Array(
);
public function states(){
return $this->hasMany(State::class, 'country_id', $this);
}
}
@@ -0,0 +1,165 @@
-- https://pt.wikipedia.org/wiki/Lista_de_membros_da_Organiza%C3%A7%C3%A3o_Internacional_de_Normaliza%C3%A7%C3%A3o
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Afeganistão', 4, 'AF', 'AFG');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('África do Sul', 710, 'ZA', 'ZAF');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Albânia', 8, 'AL', 'ALB');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Alemanha', 276, 'DE', 'DEU');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Angola', 24, 'AO', 'AGO');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Antígua e Barbuda', 28, 'AG', 'ATG');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Arábia Saudita', 682, 'SA', 'SAU');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Argélia', 12, 'DZ', 'DZA');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Argentina', 32, 'AR', 'ARG');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Armênia', 51, 'AM', 'ARM');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Austrália', 36, 'AU', 'AUS');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Áustria', 40, 'AT', 'AUT');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Azerbaijão', 31, 'AZ', 'AZE');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Bahamas', 44, 'BS', 'BHS');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Bangladesh', 50, 'BD', 'BGD');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Barbados', 52, 'BB', 'BRB');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Barém', 48, 'BH', 'BHR');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Belarus', 112, 'BY', 'BLR');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Bélgica', 56, 'BE', 'BEL');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Belize', 84, 'BZ', 'BLZ');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Benin', 204, 'BJ', 'BEN');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Bolívia', 68, 'BO', 'BOL');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Bósnia e Herzegovina', 70, 'BA', 'BIH');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Botsuana', 72, 'BW', 'BWA');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Brasil', 76, 'BR', 'BRA');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Brunei Darussalam', 96, 'BN', 'BRN');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Bulgária', 100, 'BG', 'BGR');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Burkina Faso', 854, 'BF', 'BFA');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Burundi', 108, 'BI', 'BDI');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Butão', 64, 'BT', 'BTN');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Camarões', 120, 'CM', 'CMR');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Camboja', 116, 'KH', 'KHM');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Canadá', 124, 'CA', 'CAN');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Catar', 634, 'QA', 'QAT');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Cazaquistão', 398, 'KZ', 'KAZ');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Chile', 52, 'CL', 'CHL');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('China', 156, 'CN', 'CHN');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Chipre', 196, 'CY', 'CYP');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Cingapura', 702, 'SG', 'SGP');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Colômbia', 170, 'CO', 'COL');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('República Democrática do Congo', 160, 'CD', 'cod');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Coreia do Norte', 408, 'KP', 'PRK');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Coréia do Sul', 410, 'KR', 'KOR');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Costa do Marfim', 384, 'CI', 'CIV');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Costa Rica', 188, 'CR', 'CRI');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Croácia', 191, 'HR', 'HRV');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Cuba', 192, 'CU', 'CUB');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Dinamarca', 208, 'DK', 'DNK');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Dominica', 212, 'DM', 'DMA');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Egito', 818, 'EG', 'EGY');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('El Salvador', 222, 'SV', 'SLV');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Emirados Árabes Unidos', 784, 'AE', 'ARE');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Equador', 218, 'EC', 'ECU');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Eritréia', 232, 'ER', 'ERI');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Eslováquia', 703, 'SK', 'SVK');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Eslovênia', 705, 'SI', 'SVN');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Espanha', 724, 'ES', 'ESP');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Estados Unidos', 840, 'US', 'USA');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Estônia', 233, 'EE', 'EST');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Eswatini', 748, 'SZ', 'SWZ');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Etiópia', 231, 'ET', 'ETH');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Federação Russa', 643, 'RU', 'RUS');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Fiji', 242, 'FJ', 'FJI');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Filipinas', 608, 'PH', 'PHL');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Finlândia', 246, 'FI', 'FIN');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('França', 250, 'FR', 'FRA');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Gabão', 266, 'GA', 'GAB');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Gâmbia', 270, 'GM', 'GMB');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Gana', 288, 'GH', 'GHA');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Georgia', 268, 'GE', 'GEO');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Grécia', 300, 'GR', 'GRC');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Guatemala', 320, 'GT', 'GTM');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Guiana', 328, 'GY', 'GUY');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Guiné', 324, 'GN', 'GIN');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Haiti', 332, 'HT', 'HTI');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Honduras', 340, 'HN', 'HND');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Hong Kong', 344, 'HK', 'HKG');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Hungria', 348, 'HU', 'HUN');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Índia', 356, 'IN', 'IND');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Indonésia', 360, 'ID', 'IDN');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Togo', 768, 'TG', 'TGO');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Irão', 364, 'IR', 'IRN');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Iraque', 368, 'IQ', 'IRQ');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Irlanda', 372, 'IE', 'IRL');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Islândia', 352, 'IS', 'ISL');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Israel', 376, 'IL', 'ISR');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Itália', 380, 'IT', 'ITA');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Jamaica', 388, 'JM', 'JAM');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Japão', 392, 'JP', 'JPN');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Jordânia', 400, 'JO', 'JOR');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Kuwait', 414, 'KW', 'KWT');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Letônia', 428, 'LV', 'LVA');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Líbano', 422, 'LB', 'LBN');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Lituânia', 440, 'LT', 'LTU');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Luxemburgo', 442, 'LU', 'LUX');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Macau', 446, 'MO', 'MAC');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Macedônia do Norte', 807, 'MK', 'MKD');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Madagáscar', 450, 'MG', 'MDG');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Malásia', 458, 'MY', 'MYS');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Malawi', 454, 'MW', 'MWI');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Mali', 466, 'ML', 'MLI');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Malta', 470, 'MT', 'MLT');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Marrocos', 504, 'MA', 'MAR');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Maurício', 480, 'MU', 'MUS');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Mauritânia', 478, 'MR', 'MRT');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('México', 484, 'MX', 'MEX');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Moçambique', 508, 'MZ', 'MOZ');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Moldávia', 498, 'MD', 'MDA');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Mongólia', 496, 'MN', 'MNG');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Montenegro', 442, 'ME', 'MNE');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Myanmar', 104, 'MM', 'MMR');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Namíbia', 516, 'NA', 'NAM');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Nepal', 524, 'NP', 'NPL');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Nicarágua', 558, 'NI', 'NIC');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Níger', 562, 'NE', 'NER');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Nigéria', 566, 'NG', 'NGA');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Noruega', 578, 'NO', 'NOR');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Nova Zelândia', 554, 'NZ', 'NZL');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Omã', 512, 'OM', 'OMN');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Países Baixos', 528, 'NL', 'NLD');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Palestina', 275, 'PS', 'PSE');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Panamá', 591, 'PA', 'PAN');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Papua Nova Guiné', 598, 'PG', 'PNG');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Paquistão', 586, 'PK', 'PAK');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Paraguai', 600, 'PY', 'PRY');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Peru', 604, 'PE', 'PER');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Peru', 792, 'TR', 'TUR');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Polônia', 616, 'PL', 'POL');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Portugal', 620, 'PT', 'PRT');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Quênia', 404, 'KE', 'KEN');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Quirguistão', 417, 'KG', 'KGZ');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Reino Unido', 826, 'GB', 'GBR');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('República Árabe da Síria', 760, 'SY', 'SYR');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('República Checa', 203, 'CZ', 'CZE');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('República Democrática Popular do Laos', 418, 'LA', 'LAO');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('República Dominicana', 214, 'DO', 'DOM');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Roménia', 642, 'RO', 'ROU');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Ruanda', 646, 'RW', 'RWA');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Santa Lúcia', 662, 'LC', 'LCA');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('São Cristóvão e Névis', 659, 'KN', 'KNA');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('São Tomé e Príncipe', 678, 'ST', 'STP');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('São Vicente e Granadinas', 670, 'VC', 'VCT');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Senegal', 686, 'SN', 'SEN');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Serra Leoa', 694, 'SL', 'SLE');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Sérvia', 891, 'CS', 'SCG');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Seychelles', 690, 'SC', 'SYC');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Sri Lanka', 144, 'LK', 'LKA');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Sudão', 736, 'SD', 'SDN');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Suécia', 752, 'SE', 'SWE');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Suíça', 756, 'CH', 'CHE');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Suriname', 740, 'SR', 'SUR');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Tailândia', 764, 'TH', 'THA');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Tajiquistão', 762, 'TJ', 'TJK');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Tanzânia', 834, 'TZ', 'TZA');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Trinidad e Tobago', 780, 'TT', 'TTO');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Tunísia', 788, 'TN', 'TUN');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Turcomenistão', 795, 'TM', 'TKM');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Ucrânia', 804, 'UA', 'UKR');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Uganda', 800, 'UG', 'UGA');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Uruguai', 858, 'UY', 'URY');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Uzbequistão', 860, 'UZ', 'UZB');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Vietnã', 704, 'VN', 'VNM');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Zâmbia', 894, 'ZM', 'ZMB');
INSERT INTO {geo_countries} (name, code, iso2, iso3) VALUES('Zimbábue', 816, 'ZW', 'ZWE');
+36
View File
@@ -0,0 +1,36 @@
<?php
use Schema\Wrapper as Wrapper;
use App\Core\Sanity\MigratorController as Migrator;
function geo_country_upgrade($pluginversion) {
if ($pluginversion < "0.0.1") {
$table = Wrapper::get_table("geo_countries");
$table->addSoftDelete();
$table->addColumn("name", "string", Array("null" => false));
$table->addColumn("description", "string", Array("null" => true));
$table->addColumn("code", "integer", Array("null" => false));
$table->addColumn("iso2", "string", Array("null" => false, 'limit' => 2));
$table->addColumn("iso3", "string", Array("null" => false, 'limit' => 3));
$table->save();
Wrapper::exec(file_get_contents(__DIR__.'/001_countries_seeding.sql') );
Migrator::getInstance()->update_plugin_version("geo_country", "1.0.0");
return;
}
//if ($pluginversion < "0.0.2") {
//$table = Wrapper::get_table("geo_country");
//Migrator::getInstance()->update_plugin_version("geo_country", "1.0.1");
//return;
//}
}
function geo_country_rollback($pluginversion) {
if($pluginversion > "0.0.1"){
$table = Wrapper::get_table("geo_countries");
$table->drop();
return;
}
}
+2
View File
@@ -0,0 +1,2 @@
<?php
$lang["country"]["module_name"] = "Country";
+2
View File
@@ -0,0 +1,2 @@
<?php
$lang["country"]["module_name"] = "Country";
+8
View File
@@ -0,0 +1,8 @@
<?php
$plugin->name = "geo_country";
$plugin->version = "1.0.0";
$plugin->require = Array(
Array("name" => "geo_params", "version" => "1.0.0")
);
+10
View File
@@ -0,0 +1,10 @@
{{@ if( {{id}} ): @}}
<form method="POST" action="/country/{{id}}/edit">
<input type="hidden" name="id" value="{{id}}" />
<input type="hidden" name="_method" value="put" />
{{@ else: @}}
<form method="POST" action="/country">
<input type="hidden" name="id" value="" />
{{@ endif; @}}
</form>
+2
View File
@@ -0,0 +1,2 @@
<a href='/country/form' >Adicionar </a>
<div class="table-responsive remote-datatable" data-source="/country/table?selective=true"></div>
+111
View File
@@ -0,0 +1,111 @@
<?php
namespace App\Geo\Params;
use \App\Core\Template\Output as Output;
use \App\Geo\Params\Classes\Params as Params;
class ParamsController {
/**
* Index
* Show the main Params list
*/
function index(){
Output::setView('index');
$list = Array();
for($i = 0; $i <= 10; $i++){
$obj = Array();
$obj['id'] = $i;
$obj['value'] = md5($i);
$obj['description'] = sha1($i);
$list[] = $obj;
}
Output::addValue('list', $list );
Output::render();
}
/**
* Create
*
* Render the main Params formulary
*/
function create(){
Output::setView('form', ['id' => 0]);
Output::render();
}
/**
* Store
*
* Store the param on the database
* @param Params $params
*/
function store(Params $params){
}
/**
* Search
*
* Store the param on the database
* @param Params $params
*/
function search(){
}
/**
* Show
*
* Render one register
*
* @param Params $params
*/
function show(Params $params){
}
/**
* Edit
*
* Render the formular for a database Params
*
* @param Params $params
*/
function edit(Params $params){
Output::setView('form', $params);
Output::render();
}
/**
* Update
* Store the changes of the param on the database
*
* @param Params $params
*/
function update(Params $params){
}
/**
* Destroy
* If the object has soft delete.
*
* @param Params $params
*/
function destroy(Params $params){
}
/**
* Purge
* Remove object even with soft delete.
*
* @param Params $params
*/
function purge(Params $params){
}
}
+14
View File
@@ -0,0 +1,14 @@
<?php
use App\Core\Template\Output as Output;
use Routes\RouteCollection as RouteCollection;
//Menu itens
RouteCollection::get('*', function() {
//Output::addMenu('/params', 'params', "<i class='fa fa-fa-cubes'></i>", ['class' => 'nav-link']);
Output::addOnSubmenu('geo', '/params', 'Parametrização', "", ['class' => 'nav-link']);
}, -10)->doIgnore();
RouteCollection::group("/params", function(){
});
+21
View File
@@ -0,0 +1,21 @@
<?php
namespace App\Geo\Params\Classes;
use ORM\Entity as Entity;
class Params extends Entity {
//const _idPolice = Array("type" => "", "min" => 0, "max" => 100000, "step" => 2);
const _tableName = "params";
/*const _properties = Array(
"id" => ['listable' => true, 'searcheble' => false, 'orderable' => false],
"name" => ['listable' => true, 'searcheble' => true]);
*/
//const _timestamps = true;
//const _softdelete = true;
//const _connectionName = "";
}
+25
View File
@@ -0,0 +1,25 @@
<?php
use Schema\Wrapper as Wrapper;
use App\Core\Sanity\MigratorController as Migrator;
function geo_params_upgrade($pluginversion) {
if ($pluginversion < "0.0.1") {
$table = Wrapper::get_table("geo_params");
$table->addColumn("table", "string", Array("null" => false));
$table->addColumn("key", "string", Array("null" => false));
$table->addColumn("value", "string", Array("null" => false));
$table->create();
Migrator::getInstance()->update_plugin_version("geo_params", "1.0.0");
return;
}
}
function geo_params_rollback($pluginversion) {
if($pluginversion > "0.0.1"){
$table = Wrapper::get_table("geo_params");
$table->drop();
return;
}
}
+2
View File
@@ -0,0 +1,2 @@
<?php
$lang["params"]["module_name"] = "Params";
+2
View File
@@ -0,0 +1,2 @@
<?php
$lang["params"]["module_name"] = "Params";
+6
View File
@@ -0,0 +1,6 @@
<?php
$plugin->name = "geo_params";
$plugin->version = "1.0.0";
//$plugin->require = Array( ["name" => "plugin_name", "version" => "x.x.x"] );
+10
View File
@@ -0,0 +1,10 @@
{{@ if( {{id}} ): @}}
<form method="POST" action="/params/{{id}}/edit">
<input type="hidden" name="id" value="{{id}}" />
<input type="hidden" name="_method" value="put" />
{{@ else: @}}
<form method="POST" action="/params">
<input type="hidden" name="id" value="" />
{{@ endif; @}}
</form>
+4
View File
@@ -0,0 +1,4 @@
<a href='/params/form' >Adicionar </a>
<div class="table-responsive">
</div>
+230
View File
@@ -0,0 +1,230 @@
<?php
namespace App\Geo\Postal;
use \App\Core\Template\Output as Output;
use \App\Geo\State\Classes\State as State;
use \App\Geo\Postal\Classes\Postal as Postal;
use App\Geo\City\Classes\City;
//Facades
use ORM\DBInstance;
class PostalController
{
/**
* Index
* Show the main Postal list
*/
function index()
{
$list = array();
for ($i = 0; $i <= 10; $i++) {
$obj = array();
$obj['id'] = $i;
$obj['value'] = md5($i);
$obj['description'] = sha1($i);
$list[] = $obj;
}
Output::render('index', array('list' => $list));
}
/**
* Create
*
* Render the main Postal formulary
*/
function create()
{
Output::setView('form', ['id' => 0]);
Output::render();
}
/**
* Store
*
* Store the param on the database
* @param Postal $postal
*/
function store(Postal $postal)
{
}
/**
* Search
*
* Store the param on the database
* @param Postal $postal
*/
function search($code)
{
//Search database for the record
if ($json = DBInstance::getRecord('geo_postal_caches', ['code' => ['=', $code]])) {
$json = json_decode(stripslashes($json[0]->json));
$json->cached = true;
} else {
$json = json_decode(file_get_contents('https://viacep.com.br/ws/' . $code . '/json'));
}
//Respond with errror if fail #TODO add message
if (!$json) {
http_response_code(404);
return;
}
$state = State::findOne(['shortname' => ['=', $json->uf]]);
$json->state = $state->id;
if (!$json->cached) {
$record = [];
$record['code'] = $code;
$record['json'] = addslashes(json_encode($json));
DBInstance::insertRecord('geo_postal_caches', $record);
} else {
return \RR\Response::json($json)->send();
}
if (!$city = City::findOne(['code' => ['=', $json->ibge]])) {
$city = new City();
$city->state_id = $state->id;
$city->country_id = $state->country_id;
$city->code = $json->ibge;
$city->name = $json->localidade;
$city->save();
}
if (!$postal = Postal::findOne(['code' => ['=', $code]])) {
$postal = new Postal();
$postal->country_id = $state->country_id;
$postal->state_id = $state->id;
$postal->city_id = $city->id;
@$postal->road = $json->road;
$postal->code = preg_replace('/[^0-9]/is', '', $json->cep);
$postal->description = $json->complemento;
$postal->save();
}
return \RR\Response::json($json)->send();
}
/**
* Show *
* Render one register
*
* @param Postal $postal
*/
function show(Postal $postal)
{
}
/**
* Edit
*
* Render the formular for a database Postal
*
* @param Postal $postal
*/
function edit(Postal $postal)
{
Output::render('form', $postal);
}
/**
* Update
* Store the changes of the param on the database
*
* @param Postal $postal
*/
function update(Postal $postal)
{
}
/**
* Destroy
* If the object has soft delete.
*
* @param Postal $postal
*/
function destroy(Postal $postal)
{
}
/**
* Purge
* Remove object even with soft delete.
*
* @param Postal $postal
*/
function purge(Postal $postal)
{
}
public static function searchAndCreate($code)
{
$code = preg_replace('/[^0-9]/is', '', $code);
if ($postal = Postal::findOne(['code' => ['=', $code]])) {
return $postal;
}
//Search database for the record of load the database
if ($json = DBInstance::getRecord('geo_postal_caches', ['code' => ['=', $code]])) {
$json = json_decode(stripslashes($json[0]->json));
$json->cached = true;
} else {
$json = json_decode(file_get_contents('https://viacep.com.br/ws/' . $code . '/json/unicode'));
}
$state = State::findOne(['shortname' => ['=', $json->uf]]);
$json->state = $state->id;
if (!$json->cached) {
$record = [];
$record['code'] = $code;
$record['json'] = addslashes(json_encode($json));
DBInstance::insertRecord('geo_postal_caches', $record);
}
if (!$city = City::findOne(['code' => ['=', $json->ibge]])) {
$city = new City();
$city->state_id = $state->id;
$city->country_id = $state->country_id;
$city->code = $json->ibge;
$city->name = $json->localidade;
$city->save();
}
if (!$postal = Postal::findOne(['code' => ['=', $code]])) {
$postal = new Postal();
$postal->country_id = $state->country_id;
$postal->state_id = $state->id;
$postal->city_id = $city->id;
$postal->road = $json->logradouro;
$postal->code = preg_replace('/[^0-9]/is', '', $json->cep);
$postal->description = $json->complemento;
$postal->save();
}
return $postal;
}
public static function fixPostal($postal)
{
$json = DBInstance::getRecord('geo_postal_caches', ['code' => ['=', $postal->code]]);
$json = json_decode(stripslashes($json[0]->json));
$city = City::findOne(['code' => ['=', $json->ibge]]);
$postal->code = preg_replace('/[^0-9]/is', '', $json->cep);
$postal->city_id = $city->id;
$postal->state_id = $city->state_id;
$postal->country_id = $city->country_id;
$postal->save();
return $postal;
}
}
+21
View File
@@ -0,0 +1,21 @@
<?php
use App\Core\Template\Output as Output;
use Routes\RouteCollection as RouteCollection;
//Menu itens
RouteCollection::get('*', function() {
//Output::addMenu('/postal', 'postal', "<i class='fa fa-fa-cubes'></i>", ['class' => 'nav-link']);
Output::addOnSubmenu('geo', '/postal', 'Codigos postais', "", ['class' => 'nav-link']);
}, -10)->doIgnore();
RouteCollection::group("/postal", function(){
RouteCollection::get ("/", "\App\Geo\Postal\PostalController@index");
RouteCollection::get ("/form", "\App\Geo\Postal\PostalController@create");
RouteCollection::post ("/", "\App\Geo\Postal\PostalController@store");
RouteCollection::get ("/search/[d:code]", "\App\Geo\Postal\PostalController@search");
RouteCollection::get ("/[i:id]", "\App\Geo\Postal\PostalController@show");
RouteCollection::get ("/[i:id]/edit", "\App\Geo\Postal\PostalController@edit");
RouteCollection::put ("/[i:id]/edit", "\App\Geo\Postal\PostalController@update");
RouteCollection::delete("/[i:id]", "\App\Geo\Postal\PostalController@destroy");
});
+42
View File
@@ -0,0 +1,42 @@
<?php
namespace App\Geo\Postal\Classes;
use ORM\Entity as Entity;
use App\Geo\City\Classes\City as City;
use App\Geo\Zone\Classes\Zone as Zone;
use App\Geo\State\Classes\State as State;
use App\Geo\Country\Classes\Country as Country;
class Postal extends Entity {
//const _idPolice = Array("type" => "", "min" => 0, "max" => 100000, "step" => 2);
const _tableName = "geo_postals";
/* const _properties = Array(
"id" => ['listable' => true, 'searcheble' => false, 'orderable' => false],
"name" => ['listable' => true, 'searcheble' => true]);
*/
//const _timestamps = true;
//const _softdelete = true;
//const _connectionName = "";
public function country() {
return $this->belongsTo(Country::class, 'country_id', 'id', $this);
}
public function state() {
return $this->belongsTo(State::class, 'state_id', 'id', $this);
}
public function city() {
return $this->belongsTo(City::class, 'city_id', 'id', $this);
}
public function zone() {
return $this->belongsTo(Zone::class, 'zone_id', 'id', $this);
}
}
+59
View File
@@ -0,0 +1,59 @@
<?php
use Schema\Wrapper as Wrapper;
use App\Core\Sanity\MigratorController as Migrator;
function geo_postal_upgrade($pluginversion) {
if ($pluginversion < "0.0.1") {
$table = Wrapper::get_table("geo_postals");
$table->addColumn("country_id", "integer", Array("null" => false));
$table->addColumn("state_id", "integer", Array("null" => false));
$table->addColumn("city_id", "integer", Array("null" => false));
$table->addColumn("zone_id", "integer", Array("null" => true));
$table->addColumn("code", "string", Array("null" => false));
$table->addColumn("road", "string", Array("null" => true));
$table->addColumn("description", "string", Array("null" => true));
$table->addTimestamps();
$table->addSoftDelete();
$table->addForeignKey('state_id', Wrapper::get_table('geo_states'));
$table->addForeignKey('country_id', Wrapper::get_table('geo_countries'));
$table->addForeignKey('city_id', Wrapper::get_table('geo_cities'));
$table->addForeignKey('zone_id', Wrapper::get_table('geo_zones'));
$table->create();
$table = Wrapper::get_table("geo_postal_caches");
$table->addColumn("code", "string", Array("null" => false));
$table->addColumn("json", "text", Array("null" => false));
$table->addTimestamps();
$table->create();
Migrator::getInstance()->update_plugin_version("geo_postal", "1.0.0");
return;
}
if ($pluginversion < "1.0.1") {
$table = Wrapper::get_table("geo_postal_caches");
$table->addColumn("code", "string", Array("null" => false));
$table->addColumn("json", "text", Array("null" => false));
$table->addTimestamps();
$table->create();
Migrator::getInstance()->update_plugin_version("geo_postal", "1.0.1");
return;
}
//if ($pluginversion < "0.0.2") {
//$table = Wrapper::get_table("geo_postal");
//Migrator::getInstance()->update_plugin_version("geo_postal", "1.0.1");
//return;
//}
}
function geo_postal_rollback($pluginversion) {
if($pluginversion > "0.0.1"){
$table = Wrapper::get_table("geo_postal");
$table->drop();
return;
}
}
+2
View File
@@ -0,0 +1,2 @@
<?php
$lang["postal"]["module_name"] = "Postal";
+2
View File
@@ -0,0 +1,2 @@
<?php
$lang["postal"]["module_name"] = "Postal";
+12
View File
@@ -0,0 +1,12 @@
<?php
$plugin->name = "geo_postal";
$plugin->version = "1.0.1";
$plugin->require = Array(
Array("name" => "geo_params", "version" => "1.0.0"),
Array("name" => "geo_country", "version" => "1.0.0"),
Array("name" => "geo_state", "version" => "1.0.0"),
Array("name" => "geo_city", "version" => "1.0.0"),
Array("name" => "geo_zone", "version" => "1.0.0")
);
+10
View File
@@ -0,0 +1,10 @@
{{@ if( {{id}} ): @}}
<form method="POST" action="/postal/{{id}}/edit">
<input type="hidden" name="id" value="{{id}}" />
<input type="hidden" name="_method" value="put" />
{{@ else: @}}
<form method="POST" action="/postal">
<input type="hidden" name="id" value="" />
{{@ endif; @}}
</form>
+4
View File
@@ -0,0 +1,4 @@
<a href='/postal/form' >Adicionar </a>
<div class="table-responsive">
</div>
+23
View File
@@ -0,0 +1,23 @@
<?php
use App\Core\Template\Output as Output;
use Routes\RouteCollection as RouteCollection;
//Menu itens
RouteCollection::get('*', function() {
//Output::addMenu('/state', 'state', "<i class='fa fa-fa-cubes'></i>", ['class' => 'nav-link']);
Output::addOnSubmenu('geo', '/state', 'Estados', "", ['class' => 'nav-link']);
}, -10)->doIgnore();
RouteCollection::group("/state", function(){
RouteCollection::get ("/", "\App\Geo\State\StateController@index");
RouteCollection::get ("/form", "\App\Geo\State\StateController@create");
RouteCollection::get ("/select", "\App\Geo\State\StateController@loadSelect");
RouteCollection::post ("/", "\App\Geo\State\StateController@store");
RouteCollection::get ("/search", "\App\Geo\State\StateController@search");
RouteCollection::post ("/search", "\App\Geo\State\StateController@search");
RouteCollection::get ("/[i:id]", "\App\Geo\State\StateController@show");
RouteCollection::get ("/[i:id]/edit", "\App\Geo\State\StateController@edit");
RouteCollection::put ("/[i:id]/edit", "\App\Geo\State\StateController@update");
RouteCollection::delete("/[i:id]", "\App\Geo\State\StateController@destroy");
});
+139
View File
@@ -0,0 +1,139 @@
<?php
namespace App\Geo\State;
use \App\Core\Template\Output as Output;
use \App\Geo\State\Classes\State as State;
class StateController
{
/**
* Index
* Show the main State list
*/
function index()
{
$list = array();
for ($i = 0; $i <= 10; $i++) {
$obj = array();
$obj['id'] = $i;
$obj['value'] = md5($i);
$obj['description'] = sha1($i);
$list[] = $obj;
}
Output::render('list', $list);
}
/**
* Create
*
* Render the main State formulary
*/
function create()
{
Output::setView('form', ['id' => 0]);
Output::render();
}
/**
* Store
*
* Store the param on the database
* @param State $state
*/
function store(State $state)
{
}
/**
* Search
*
* Store the param on the database
* @param State $state
*/
function search()
{
$states = State::findAll(['id', 'shortname']);
$return = "<option value='0'>Selecione</option>";
foreach ($states as $state) {
if ($state->id == $_GET['value']) {
$return .= "<option value='$state->id' selected>$state->shortname</option>";
} else {
$return .= "<option value='$state->id'>$state->shortname</option>";
}
}
echo $return;
}
/**
* Show
*
* Render one register
*
* @param State $state
*/
function show(State $state)
{
\RR\Response::json($state)->send();
}
/**
* Edit
*
* Render the formular for a database State
*
* @param State $state
*/
function edit(State $state)
{
Output::setView('form', $state);
Output::render();
}
/**
* Update
* Store the changes of the param on the database
*
* @param State $state
*/
function update(State $state)
{
}
/**
* Destroy
* If the object has soft delete.
*
* @param State $state
*/
function destroy(State $state)
{
}
/**
* Purge
* Remove object even with soft delete.
*
* @param State $state
*/
function purge(State $state)
{
}
function loadSelect()
{
//ddd(State::findMany(['country_id' => ['=', '25']])->get());
Output::render(
'select',
[
'states' => State::findMany(['country_id' => ['=', '25']])->get(),
//'selected' => $_GET['value']
]
);
}
}
+25
View File
@@ -0,0 +1,25 @@
<?php
namespace App\Geo\State\Classes;
use ORM\Entity as Entity;
use App\Geo\Country\Classes\Country as Country;
class State extends Entity {
const _tableName = "geo_states";
//const _timestamps = true;
//const _softdelete = true;
//const _connectionName = "";
function country(){
return $this->belongsTo(Country::class, 'country_id');
}
}
@@ -0,0 +1,27 @@
insert into {geo_states} (name, code, shortname, country_id) VALUES('Are' ,12 ,'AC', (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'));
insert into {geo_states} (name, code, shortname, country_id) VALUES('Alagoas' ,27 ,'AL', (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'));
insert into {geo_states} (name, code, shortname, country_id) VALUES('Amapá' ,16 ,'AP', (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'));
insert into {geo_states} (name, code, shortname, country_id) VALUES('Amazonas' ,13 ,'AM', (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'));
insert into {geo_states} (name, code, shortname, country_id) VALUES('Bahia' ,29 ,'BA', (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'));
insert into {geo_states} (name, code, shortname, country_id) VALUES('Ceará' ,23 ,'CE', (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'));
insert into {geo_states} (name, code, shortname, country_id) VALUES('Distrito Federal' ,53 ,'DF', (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'));
insert into {geo_states} (name, code, shortname, country_id) VALUES('Espírito Santo' ,32 ,'ES', (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'));
insert into {geo_states} (name, code, shortname, country_id) VALUES('Goiás' ,52 ,'GO', (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'));
insert into {geo_states} (name, code, shortname, country_id) VALUES('Maranhão' ,21 ,'MA', (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'));
insert into {geo_states} (name, code, shortname, country_id) VALUES('Mato Grosso' ,51 ,'MT', (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'));
insert into {geo_states} (name, code, shortname, country_id) VALUES('Mato Grosso do Sul' ,50 ,'MS', (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'));
insert into {geo_states} (name, code, shortname, country_id) VALUES('Minas Gerais' ,31 ,'MG', (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'));
insert into {geo_states} (name, code, shortname, country_id) VALUES('Pará' ,15 ,'PA', (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'));
insert into {geo_states} (name, code, shortname, country_id) VALUES('Paraíba' ,25 ,'PB', (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'));
insert into {geo_states} (name, code, shortname, country_id) VALUES('Paraná' ,41 ,'PR', (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'));
insert into {geo_states} (name, code, shortname, country_id) VALUES('Pernambuco' ,26 ,'PE', (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'));
insert into {geo_states} (name, code, shortname, country_id) VALUES('Piauí' ,22 ,'PI', (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'));
insert into {geo_states} (name, code, shortname, country_id) VALUES('Rio Grande do Norte' ,24 ,'RN', (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'));
insert into {geo_states} (name, code, shortname, country_id) VALUES('Rio Grande do Sul' ,43 ,'RS', (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'));
insert into {geo_states} (name, code, shortname, country_id) VALUES('Rio de Janeiro' ,33 ,'RJ', (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'));
insert into {geo_states} (name, code, shortname, country_id) VALUES('Rondônia' ,11 ,'RO', (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'));
insert into {geo_states} (name, code, shortname, country_id) VALUES('Roraima' ,14 ,'RR', (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'));
insert into {geo_states} (name, code, shortname, country_id) VALUES('Santa Catarina' ,42 ,'SC', (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'));
insert into {geo_states} (name, code, shortname, country_id) VALUES('São Paulo' ,35 ,'SP', (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'));
insert into {geo_states} (name, code, shortname, country_id) VALUES('Sergipe' ,28 ,'SE', (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'));
insert into {geo_states} (name, code, shortname, country_id) VALUES('Tocantins' ,17 ,'TO', (SELECT id FROM {geo_countries} WHERE iso3 = 'BRA'));
+36
View File
@@ -0,0 +1,36 @@
<?php
use Schema\Wrapper as Wrapper;
use App\Core\Sanity\MigratorController as Migrator;
function geo_state_upgrade($pluginversion) {
if ($pluginversion < "0.0.1") {
$table = Wrapper::get_table("geo_states");
$table->addColumn("country_id", "integer", Array("null" => false));
$table->addColumn("name", "string", Array("null" => false));
$table->addColumn("code", "integer", Array("null" => true));
$table->addColumn("shortname", "string", Array("null" => false, 'limit' => 5));
$table->addColumn("description", "string", Array("null" => true));
$table->addForeignKey('country_id', Wrapper::get_table('geo_countries'));
$table->create();
Wrapper::exec(file_get_contents(__DIR__.'/001_brazil_states_seeding.sql') );
Migrator::getInstance()->update_plugin_version("geo_state", "1.0.0");
return;
}
//if ($pluginversion < "0.0.2") {
//$table = Wrapper::get_table("geo_state");
//Migrator::getInstance()->update_plugin_version("geo_states", "1.0.1");
//return;
//}
}
function geo_state_rollback($pluginversion) {
if($pluginversion > "0.0.1"){
$table = Wrapper::get_table("geo_states");
$table->drop();
return;
}
}
+2
View File
@@ -0,0 +1,2 @@
<?php
$lang["state"]["module_name"] = "State";
+2
View File
@@ -0,0 +1,2 @@
<?php
$lang["state"]["module_name"] = "State";
+9
View File
@@ -0,0 +1,9 @@
<?php
$plugin->name = "geo_state";
$plugin->version = "1.0.0";
$plugin->require = Array(
Array("name" => "geo_params", "version" => "1.0.0"),
Array("name" => "geo_country", "version" => "1.0.0")
);
+10
View File
@@ -0,0 +1,10 @@
{{@ if( {{id}} ): @}}
<form method="POST" action="/state/{{id}}/edit">
<input type="hidden" name="id" value="{{id}}" />
<input type="hidden" name="_method" value="put" />
{{@ else: @}}
<form method="POST" action="/state">
<input type="hidden" name="id" value="" />
{{@ endif; @}}
</form>
+4
View File
@@ -0,0 +1,4 @@
<a href='/state/form' >Adicionar </a>
<div class="table-responsive">
</div>
+4
View File
@@ -0,0 +1,4 @@
<option id='0'>Selecione</option>
{{#states}}
<option id='{{id}}' value="{{id}}">{{shortname}}</option>
{{/states}}
+20
View File
@@ -0,0 +1,20 @@
<?php
use App\Core\Template\Output as Output;
use Routes\RouteCollection as RouteCollection;
//Menu itens
RouteCollection::get('*', function() {
Output::addOnSubmenu('geo', '/zone', "Localidades", "", ['class' => 'nav-link']);
}, -10)->doIgnore();
RouteCollection::group("/zone", function(){
RouteCollection::get ("/", "\App\Geo\Zone\ZoneController@index");
RouteCollection::get ("/form", "\App\Geo\Zone\ZoneController@create");
RouteCollection::post ("/", "\App\Geo\Zone\ZoneController@store");
RouteCollection::post ("/search", "\App\Geo\Zone\ZoneController@search");
RouteCollection::get ("/[i:id]", "\App\Geo\Zone\ZoneController@show");
RouteCollection::get ("/[i:id]/edit", "\App\Geo\Zone\ZoneController@edit");
RouteCollection::put ("/[i:id]/edit", "\App\Geo\Zone\ZoneController@update");
RouteCollection::delete("/[i:id]", "\App\Geo\Zone\ZoneController@destroy");
});
+107
View File
@@ -0,0 +1,107 @@
<?php
namespace App\Geo\Zone;
use \App\Core\Template\Output as Output;
use \App\Geo\Zone\Classes\Zone as Zone;
class ZoneController {
/**
* Index
* Show the main Zone list
*/
function index(){
$list = Array();
for($i = 0; $i <= 10; $i++){
$obj = Array();
$obj['id'] = $i;
$obj['value'] = md5($i);
$obj['description'] = sha1($i);
$list[] = $obj;
}
Output::render('index', $list);
}
/**
* Create
*
* Render the main Zone formulary
*/
function create(){
Output::render('form', ['id' => 0]);
}
/**
* Store
*
* Store the param on the database
* @param Zone $zone
*/
function store(Zone $zone){
}
/**
* Search
*
* Store the param on the database
* @param Zone $zone
*/
function search(){
}
/**
* Show
*
* Render one register
*
* @param Zone $zone
*/
function show(Zone $zone){
}
/**
* Edit
*
* Render the formular for a database Zone
*
* @param Zone $zone
*/
function edit(Zone $zone){
Output::render('form', $zone);
}
/**
* Update
* Store the changes of the param on the database
*
* @param Zone $zone
*/
function update(Zone $zone){
}
/**
* Destroy
* If the object has soft delete.
*
* @param Zone $zone
*/
function destroy(Zone $zone){
}
/**
* Purge
* Remove object even with soft delete.
*
* @param Zone $zone
*/
function purge(Zone $zone){
}
}
+21
View File
@@ -0,0 +1,21 @@
<?php
namespace App\Geo\Zone\Classes;
use ORM\Entity as Entity;
class Zone extends Entity {
//const _idPolice = Array("type" => "", "min" => 0, "max" => 100000, "step" => 2);
const _tableName = "geo_zones";
/*const _properties = Array(
"id" => ['listable' => true, 'searcheble' => false, 'orderable' => false],
"name" => ['listable' => true, 'searcheble' => true]);
*/
//const _timestamps = true;
//const _softdelete = true;
//const _connectionName = "";
}
+32
View File
@@ -0,0 +1,32 @@
<?php
use Schema\Wrapper as Wrapper;
use App\Core\Sanity\MigratorController as Migrator;
function geo_zone_upgrade($pluginversion) {
if ($pluginversion < "0.0.1") {
$table = Wrapper::get_table("geo_zones");
$table->addColumn("name", "string", Array("null" => false));
$table->addColumn("city_id", "integer", Array("null" => false));
$table->addSoftDelete();
$table->addForeignKey('city_id', Wrapper::get_table('geo_cities'));
$table->create();
Migrator::getInstance()->update_plugin_version("geo_zone", "1.0.0");
return;
}
//if ($pluginversion < "0.0.2") {
//$table = Wrapper::get_table("geo_zones");
//Migrator::getInstance()->update_plugin_version("geo_zone", "1.0.1");
//return;
//}
}
function geo_zone_rollback($pluginversion) {
if($pluginversion > "0.0.1"){
$table = Wrapper::get_table("geo_zones");
$table->drop();
return;
}
}
+2
View File
@@ -0,0 +1,2 @@
<?php
$lang["zone"]["module_name"] = "Zone";
+2
View File
@@ -0,0 +1,2 @@
<?php
$lang["zone"]["module_name"] = "Zone";
+11
View File
@@ -0,0 +1,11 @@
<?php
$plugin->name = "geo_zone";
$plugin->version = "1.0.0";
$plugin->require = Array(
Array("name" => "geo_params", "version" => "1.0.0"),
Array("name" => "geo_country", "version" => "1.0.0"),
Array("name" => "geo_state", "version" => "1.0.0"),
Array("name" => "geo_city", "version" => "1.0.0")
);
+10
View File
@@ -0,0 +1,10 @@
{{@ if( {{id}} ): @}}
<form method="POST" action="/zone/{{id}}/edit">
<input type="hidden" name="id" value="{{id}}" />
<input type="hidden" name="_method" value="put" />
{{@ else: @}}
<form method="POST" action="/zone">
<input type="hidden" name="id" value="" />
{{@ endif; @}}
</form>
+4
View File
@@ -0,0 +1,4 @@
<a href='/zone/form' >Adicionar </a>
<div class="table-responsive">
</div>