municipios-br 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +121 -0
- package/README.md +335 -0
- package/database/municipios-by-uf.json +167029 -0
- package/database/municipios.json +166975 -0
- package/database/stats.json +230 -0
- package/lib/constants.d.ts +15 -0
- package/lib/constants.d.ts.map +1 -0
- package/lib/constants.js +87 -0
- package/lib/constants.js.map +1 -0
- package/lib/data.d.ts +8 -0
- package/lib/data.d.ts.map +1 -0
- package/lib/data.js +16 -0
- package/lib/data.js.map +1 -0
- package/lib/flags.d.ts +53 -0
- package/lib/flags.d.ts.map +1 -0
- package/lib/flags.js +93 -0
- package/lib/flags.js.map +1 -0
- package/lib/index.d.ts +6 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +28 -0
- package/lib/index.js.map +1 -0
- package/lib/municipios.d.ts +43 -0
- package/lib/municipios.d.ts.map +1 -0
- package/lib/municipios.js +72 -0
- package/lib/municipios.js.map +1 -0
- package/lib/types.d.ts +74 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +3 -0
- package/lib/types.js.map +1 -0
- package/package.json +45 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
Creative Commons Legal Code
|
|
2
|
+
|
|
3
|
+
CC0 1.0 Universal
|
|
4
|
+
|
|
5
|
+
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
|
|
6
|
+
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
|
|
7
|
+
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
|
|
8
|
+
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
|
|
9
|
+
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
|
|
10
|
+
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
|
|
11
|
+
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
|
|
12
|
+
HEREUNDER.
|
|
13
|
+
|
|
14
|
+
Statement of Purpose
|
|
15
|
+
|
|
16
|
+
The laws of most jurisdictions throughout the world automatically confer
|
|
17
|
+
exclusive Copyright and Related Rights (defined below) upon the creator
|
|
18
|
+
and subsequent owner(s) (each and all, an "owner") of an original work of
|
|
19
|
+
authorship and/or a database (each, a "Work").
|
|
20
|
+
|
|
21
|
+
Certain owners wish to permanently relinquish those rights to a Work for
|
|
22
|
+
the purpose of contributing to a commons of creative, cultural and
|
|
23
|
+
scientific works ("Commons") that the public can reliably and without fear
|
|
24
|
+
of later claims of infringement build upon, modify, incorporate in other
|
|
25
|
+
works, reuse and redistribute as freely as possible in any form whatsoever
|
|
26
|
+
and for any purposes, including without limitation commercial purposes.
|
|
27
|
+
These owners may contribute to the Commons to promote the ideal of a free
|
|
28
|
+
culture and the further production of creative, cultural and scientific
|
|
29
|
+
works, or to gain reputation or greater distribution for their Work in
|
|
30
|
+
part through the use and efforts of others.
|
|
31
|
+
|
|
32
|
+
For these and/or other purposes and motivations, and without any
|
|
33
|
+
expectation of additional consideration or compensation, the person
|
|
34
|
+
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
|
|
35
|
+
is an owner of Copyright and Related Rights in the Work, voluntarily
|
|
36
|
+
elects to apply CC0 to the Work and publicly distribute the Work under its
|
|
37
|
+
terms, with knowledge of his or her Copyright and Related Rights in the
|
|
38
|
+
Work and the meaning and intended legal effect of CC0 on those rights.
|
|
39
|
+
|
|
40
|
+
1. Copyright and Related Rights. A Work made available under CC0 may be
|
|
41
|
+
protected by copyright and related or neighboring rights ("Copyright and
|
|
42
|
+
Related Rights"). Copyright and Related Rights include, but are not
|
|
43
|
+
limited to, the following:
|
|
44
|
+
|
|
45
|
+
i. the right to reproduce, adapt, distribute, perform, display,
|
|
46
|
+
communicate, and translate a Work;
|
|
47
|
+
ii. moral rights retained by the original author(s) and/or performer(s);
|
|
48
|
+
iii. publicity and privacy rights pertaining to a person's image or
|
|
49
|
+
likeness depicted in a Work;
|
|
50
|
+
iv. rights protecting against unfair competition in regards to a Work,
|
|
51
|
+
subject to the limitations in paragraph 4(a), below;
|
|
52
|
+
v. rights protecting the extraction, dissemination, use and reuse of data
|
|
53
|
+
in a Work;
|
|
54
|
+
vi. database rights (such as those arising under Directive 96/9/EC of the
|
|
55
|
+
European Parliament and of the Council of 11 March 1996 on the legal
|
|
56
|
+
protection of databases, and under any national implementation
|
|
57
|
+
thereof, including any amended or successor version of such
|
|
58
|
+
directive); and
|
|
59
|
+
vii. other similar, equivalent or corresponding rights throughout the
|
|
60
|
+
world based on applicable law or treaty, and any national
|
|
61
|
+
implementations thereof.
|
|
62
|
+
|
|
63
|
+
2. Waiver. To the greatest extent permitted by, but not in contravention
|
|
64
|
+
of, applicable law, Affirmer hereby overtly, fully, permanently,
|
|
65
|
+
irrevocably and unconditionally waives, abandons, and surrenders all of
|
|
66
|
+
Affirmer's Copyright and Related Rights and associated claims and causes
|
|
67
|
+
of action, whether now known or unknown (including existing as well as
|
|
68
|
+
future claims and causes of action), in the Work (i) in all territories
|
|
69
|
+
worldwide, (ii) for the maximum duration provided by applicable law or
|
|
70
|
+
treaty (including future time extensions), (iii) in any current or future
|
|
71
|
+
medium and for any number of copies, and (iv) for any purpose whatsoever,
|
|
72
|
+
including without limitation commercial, advertising or promotional
|
|
73
|
+
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
|
|
74
|
+
member of the public at large and to the detriment of Affirmer's heirs and
|
|
75
|
+
successors, fully intending that such Waiver shall not be subject to
|
|
76
|
+
revocation, rescission, cancellation, termination, or any other legal or
|
|
77
|
+
equitable action to disrupt the quiet enjoyment of the Work by the public
|
|
78
|
+
as contemplated by Affirmer's express Statement of Purpose.
|
|
79
|
+
|
|
80
|
+
3. Public License Fallback. Should any part of the Waiver for any reason
|
|
81
|
+
be judged legally invalid or ineffective under applicable law, then the
|
|
82
|
+
Waiver shall be preserved to the maximum extent permitted taking into
|
|
83
|
+
account Affirmer's express Statement of Purpose. In addition, to the
|
|
84
|
+
extent the Waiver is so judged Affirmer hereby grants to each affected
|
|
85
|
+
person a royalty-free, non transferable, non sublicensable, non exclusive,
|
|
86
|
+
irrevocable and unconditional license to exercise Affirmer's Copyright and
|
|
87
|
+
Related Rights in the Work (i) in all territories worldwide, (ii) for the
|
|
88
|
+
maximum duration provided by applicable law or treaty (including future
|
|
89
|
+
time extensions), (iii) in any current or future medium and for any number
|
|
90
|
+
of copies, and (iv) for any purpose whatsoever, including without
|
|
91
|
+
limitation commercial, advertising or promotional purposes (the
|
|
92
|
+
"License"). The License shall be deemed effective as of the date CC0 was
|
|
93
|
+
applied by Affirmer to the Work. Should any part of the License for any
|
|
94
|
+
reason be judged legally invalid or ineffective under applicable law, such
|
|
95
|
+
partial invalidity or ineffectiveness shall not invalidate the remainder
|
|
96
|
+
of the License, and in such case Affirmer hereby affirms that he or she
|
|
97
|
+
will not (i) exercise any of his or her remaining Copyright and Related
|
|
98
|
+
Rights in the Work or (ii) assert any associated claims and causes of
|
|
99
|
+
action with respect to the Work, in either case contrary to Affirmer's
|
|
100
|
+
express Statement of Purpose.
|
|
101
|
+
|
|
102
|
+
4. Limitations and Disclaimers.
|
|
103
|
+
|
|
104
|
+
a. No trademark or patent rights held by Affirmer are waived, abandoned,
|
|
105
|
+
surrendered, licensed or otherwise affected by this document.
|
|
106
|
+
b. Affirmer offers the Work as-is and makes no representations or
|
|
107
|
+
warranties of any kind concerning the Work, express, implied,
|
|
108
|
+
statutory or otherwise, including without limitation warranties of
|
|
109
|
+
title, merchantability, fitness for a particular purpose, non
|
|
110
|
+
infringement, or the absence of latent or other defects, accuracy, or
|
|
111
|
+
the present or absence of errors, whether or not discoverable, all to
|
|
112
|
+
the greatest extent permissible under applicable law.
|
|
113
|
+
c. Affirmer disclaims responsibility for clearing rights of other persons
|
|
114
|
+
that may apply to the Work or any use thereof, including without
|
|
115
|
+
limitation any person's Copyright and Related Rights in the Work.
|
|
116
|
+
Further, Affirmer disclaims responsibility for obtaining any necessary
|
|
117
|
+
consents, permissions or other rights required for any use of the
|
|
118
|
+
Work.
|
|
119
|
+
d. Affirmer understands and acknowledges that Creative Commons is not a
|
|
120
|
+
party to this document and has no duty or obligation with respect to
|
|
121
|
+
this CC0 or use of the Work.
|
package/README.md
ADDED
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
# Bandeiras do Brasil: Estados + Municípios
|
|
2
|
+
|
|
3
|
+
Pacote de ícones com bandeiras dos **27 Estados** + **4.366 Municípios** brasileiros em 4 estilos SVG + 8 variantes PNG, com API TypeScript para busca programática.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Capitais
|
|
8
|
+
|
|
9
|
+
| | | | |
|
|
10
|
+
|:---:|:---:|:---:|:---:|
|
|
11
|
+
|  |  |  |  |
|
|
12
|
+
| **AC** Rio Branco | **AL** Maceió | **AM** Manaus | **AP** Macapá |
|
|
13
|
+
|  |  |  |  |
|
|
14
|
+
| **BA** Salvador | **CE** Fortaleza | **DF** Brasília | **ES** Vitória |
|
|
15
|
+
|  |  |  |  |
|
|
16
|
+
| **GO** Goiânia | **MA** São Luís | **MG** Belo Horizonte | **MS** Campo Grande |
|
|
17
|
+
|  |  |  |  |
|
|
18
|
+
| **MT** Cuiabá | **PA** Belém | **PB** João Pessoa | **PE** Recife |
|
|
19
|
+
|  |  |  |  |
|
|
20
|
+
| **PI** Teresina | **PR** Curitiba | **RJ** Rio de Janeiro | **RN** Natal |
|
|
21
|
+
|  |  |  |  |
|
|
22
|
+
| **RO** Porto Velho | **RR** Boa Vista | **RS** Porto Alegre | **SC** Florianópolis |
|
|
23
|
+
|  |  |  | |
|
|
24
|
+
| **SE** Aracaju | **SP** São Paulo | **TO** Palmas | |
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Instalação
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm install municipios-br
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Ou clone o repositório para acesso direto aos arquivos:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
git clone https://github.com/nataliasm23/icones-bandeiras-br-uf.git
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Uso Rápido
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
import {
|
|
46
|
+
getMunicipio,
|
|
47
|
+
getFlagPath,
|
|
48
|
+
searchMunicipios,
|
|
49
|
+
getMunicipiosWithFlags,
|
|
50
|
+
stats,
|
|
51
|
+
} from "municipios-br";
|
|
52
|
+
|
|
53
|
+
// Buscar por código IBGE
|
|
54
|
+
const sp = getMunicipio(3550308);
|
|
55
|
+
console.log(sp?.name); // "São Paulo"
|
|
56
|
+
|
|
57
|
+
// Obter caminho do arquivo de ícone
|
|
58
|
+
const path = getFlagPath(3550308, "circle", "svg");
|
|
59
|
+
// "circle/svg/SP/3550308-sao-paulo-circle.svg"
|
|
60
|
+
|
|
61
|
+
// Obter URL completa via jsDelivr (CDN gratuito do GitHub)
|
|
62
|
+
import { getFlagUrl } from "municipios-br";
|
|
63
|
+
const url = getFlagUrl(3550308, "circle", "png-200", "https://cdn.jsdelivr.net/gh/nataliasm23/icones-bandeiras-br-uf@master/dist");
|
|
64
|
+
// "https://cdn.jsdelivr.net/gh/nataliasm23/icones-bandeiras-br-uf@master/dist/circle/png-200/SP/3550308-sao-paulo-circle.png"
|
|
65
|
+
|
|
66
|
+
// Buscar por nome
|
|
67
|
+
const results = searchMunicipios("curitiba");
|
|
68
|
+
console.log(results[0]?.ibge_code); // 4106902
|
|
69
|
+
|
|
70
|
+
// Listar municípios com bandeiras por estado
|
|
71
|
+
const rjFlags = getMunicipiosWithFlags("RJ");
|
|
72
|
+
console.log(rjFlags.length); // 92
|
|
73
|
+
|
|
74
|
+
// Estatísticas do banco de dados
|
|
75
|
+
console.log(stats.total_municipios); // 5571
|
|
76
|
+
console.log(stats.total_with_icons); // 4366
|
|
77
|
+
console.log(stats.icon_coverage_pct); // 78.4
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Estilos
|
|
83
|
+
|
|
84
|
+
4 estilos disponíveis:
|
|
85
|
+
|
|
86
|
+
| Estilo | Dimensões | Descrição |
|
|
87
|
+
|--------|-----------|-----------|
|
|
88
|
+
| **full** | 300×200 | Proporção 3:2, sem recorte |
|
|
89
|
+
| **rounded** | 300×200 | Proporção 3:2, cantos arredondados (r=20) |
|
|
90
|
+
| **circle** | 200×200 | 1:1, recorte circular |
|
|
91
|
+
| **square-rounded** | 200×200 | 1:1, quadrado arredondado (r=20) |
|
|
92
|
+
|
|
93
|
+

|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## Cobertura por Estado
|
|
98
|
+
|
|
99
|
+
| UF | Estado | Total | Bandeiras | Cobertura |
|
|
100
|
+
|----|--------|------:|------:|---------:|
|
|
101
|
+
| AC | Acre | 22 | 14 | 63.6% |
|
|
102
|
+
| AL | Alagoas | 102 | 65 | 63.7% |
|
|
103
|
+
| AM | Amazonas | 62 | 47 | 75.8% |
|
|
104
|
+
| AP | Amapá | 16 | 11 | 68.8% |
|
|
105
|
+
| BA | Bahia | 417 | 350 | 83.9% |
|
|
106
|
+
| CE | Ceará | 184 | 165 | 89.7% |
|
|
107
|
+
| DF | Distrito Federal | 1 | 1 | 100.0% |
|
|
108
|
+
| ES | Espírito Santo | 78 | 65 | 83.3% |
|
|
109
|
+
| GO | Goiás | 246 | 182 | 74.0% |
|
|
110
|
+
| MA | Maranhão | 217 | 135 | 62.2% |
|
|
111
|
+
| MG | Minas Gerais | 853 | 602 | 70.6% |
|
|
112
|
+
| MS | Mato Grosso do Sul | 79 | 75 | 94.9% |
|
|
113
|
+
| MT | Mato Grosso | 142 | 86 | 60.6% |
|
|
114
|
+
| PA | Pará | 144 | 105 | 72.9% |
|
|
115
|
+
| PB | Paraíba | 223 | 201 | 90.1% |
|
|
116
|
+
| PE | Pernambuco | 185 | 135 | 73.0% |
|
|
117
|
+
| PI | Piauí | 224 | 93 | 41.5% |
|
|
118
|
+
| PR | Paraná | 399 | 275 | 68.9% |
|
|
119
|
+
| RJ | Rio de Janeiro | 92 | 92 | 100.0% |
|
|
120
|
+
| RN | Rio Grande do Norte | 167 | 127 | 76.0% |
|
|
121
|
+
| RO | Rondônia | 52 | 46 | 88.5% |
|
|
122
|
+
| RR | Roraima | 15 | 15 | 100.0% |
|
|
123
|
+
| RS | Rio Grande do Sul | 497 | 470 | 94.6% |
|
|
124
|
+
| SC | Santa Catarina | 295 | 278 | 94.2% |
|
|
125
|
+
| SE | Sergipe | 75 | 61 | 81.3% |
|
|
126
|
+
| SP | São Paulo | 645 | 631 | 97.8% |
|
|
127
|
+
| TO | Tocantins | 139 | 39 | 28.1% |
|
|
128
|
+
| | **Total** | **5,571** | **4,366** | **78.4%** |
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## Referência da API
|
|
133
|
+
|
|
134
|
+
### Tipos
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
type UF = "AC" | "AL" | "AM" | ... | "TO" // 27 UF codes
|
|
138
|
+
type Region = "N" | "NE" | "CO" | "SE" | "S" // Macro-regions
|
|
139
|
+
type FlagStyle = "full" | "rounded" | "circle" | "square-rounded"
|
|
140
|
+
type PngSize = "png-200" | "png-800"
|
|
141
|
+
type FlagFormat = "svg" | PngSize
|
|
142
|
+
|
|
143
|
+
interface Municipio {
|
|
144
|
+
ibge_code: number
|
|
145
|
+
name: string
|
|
146
|
+
slug: string
|
|
147
|
+
uf: UF
|
|
148
|
+
uf_name: string
|
|
149
|
+
region: Region
|
|
150
|
+
region_name: string
|
|
151
|
+
has_flag: boolean
|
|
152
|
+
has_icons: boolean
|
|
153
|
+
flag_source: string | null
|
|
154
|
+
icons?: MunicipioIcons
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
interface MunicipioIcons {
|
|
158
|
+
full_svg: string
|
|
159
|
+
"full_png-200": string
|
|
160
|
+
"full_png-800": string
|
|
161
|
+
rounded_svg: string
|
|
162
|
+
"rounded_png-200": string
|
|
163
|
+
"rounded_png-800": string
|
|
164
|
+
circle_svg: string
|
|
165
|
+
"circle_png-200": string
|
|
166
|
+
"circle_png-800": string
|
|
167
|
+
"square-rounded_svg": string
|
|
168
|
+
"square-rounded_png-200": string
|
|
169
|
+
"square-rounded_png-800": string
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Funções
|
|
174
|
+
|
|
175
|
+
| Função | Descrição |
|
|
176
|
+
|--------|-----------|
|
|
177
|
+
| `getMunicipio(ibgeCode)` | Busca município pelo código IBGE |
|
|
178
|
+
| `getMunicipiosByUf(uf)` | Retorna todos os municípios de uma UF |
|
|
179
|
+
| `getMunicipiosWithFlags(uf?)` | Retorna municípios com ícones gerados |
|
|
180
|
+
| `searchMunicipios(query)` | Busca por nome ou slug |
|
|
181
|
+
| `getFlagPath(ibgeCode, style, format)` | Retorna caminho relativo do ícone |
|
|
182
|
+
| `getFlagUrl(ibgeCode, style, format, baseUrl)` | Retorna URL completa com base |
|
|
183
|
+
| `getAllFlagPaths(ibgeCode)` | Retorna os 12 caminhos de ícone do município |
|
|
184
|
+
| `buildFlagPath(uf, ibgeCode, slug, style, format)` | Monta caminho a partir dos componentes |
|
|
185
|
+
|
|
186
|
+
### Constantes
|
|
187
|
+
|
|
188
|
+
| Constante | Tipo | Descrição |
|
|
189
|
+
|-----------|------|-----------|
|
|
190
|
+
| `UF_NAMES` | `Record<UF, string>` | Nomes completos dos estados |
|
|
191
|
+
| `UF_CAPITALS` | `Record<UF, { name, ibgeCode }>` | Capital de cada UF |
|
|
192
|
+
| `REGIONS` | `Record<Region, UF[]>` | UFs por macrorregião |
|
|
193
|
+
| `REGION_NAMES` | `Record<Region, string>` | Nomes das macrorregiões |
|
|
194
|
+
| `ALL_UFS` | `UF[]` | Lista ordenada dos 27 códigos UF |
|
|
195
|
+
|
|
196
|
+
### Dados
|
|
197
|
+
|
|
198
|
+
| Export | Tipo | Descrição |
|
|
199
|
+
|--------|------|-----------|
|
|
200
|
+
| `municipios` | `Municipio[]` | Todos os 5.571 municípios |
|
|
201
|
+
| `municipiosByUf` | `Record<UF, Municipio[]>` | Agrupados por estado |
|
|
202
|
+
| `stats` | `DatabaseStats` | Estatísticas de cobertura |
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
## Estrutura de Arquivos
|
|
207
|
+
|
|
208
|
+
```
|
|
209
|
+
dist/
|
|
210
|
+
├── full/
|
|
211
|
+
│ ├── svg/{UF}/{ibge_code}-{slug}-full.svg # 300×200
|
|
212
|
+
│ ├── png-200/{UF}/{ibge_code}-{slug}-full.png # 300×200
|
|
213
|
+
│ └── png-800/{UF}/{ibge_code}-{slug}-full.png # 1200×800
|
|
214
|
+
├── rounded/
|
|
215
|
+
│ ├── svg/{UF}/{ibge_code}-{slug}-rounded.svg # 300×200, r=20
|
|
216
|
+
│ ├── png-200/{UF}/{ibge_code}-{slug}-rounded.png # 300×200
|
|
217
|
+
│ └── png-800/{UF}/{ibge_code}-{slug}-rounded.png # 1200×800
|
|
218
|
+
├── circle/
|
|
219
|
+
│ ├── svg/{UF}/{ibge_code}-{slug}-circle.svg # 200×200
|
|
220
|
+
│ ├── png-200/{UF}/{ibge_code}-{slug}-circle.png # 200×200
|
|
221
|
+
│ └── png-800/{UF}/{ibge_code}-{slug}-circle.png # 800×800
|
|
222
|
+
└── square-rounded/
|
|
223
|
+
├── svg/{UF}/{ibge_code}-{slug}-sq.svg # 200×200, r=20
|
|
224
|
+
├── png-200/{UF}/{ibge_code}-{slug}-sq.png # 200×200
|
|
225
|
+
└── png-800/{UF}/{ibge_code}-{slug}-sq.png # 800×800
|
|
226
|
+
|
|
227
|
+
database/
|
|
228
|
+
├── municipios.json # Todos os 5.571 municípios com caminhos dos ícones
|
|
229
|
+
├── municipios-by-uf.json # Agrupados por estado
|
|
230
|
+
└── stats.json # Estatísticas de cobertura
|
|
231
|
+
|
|
232
|
+
src/ # Código-fonte TypeScript
|
|
233
|
+
├── index.ts # Barrel export
|
|
234
|
+
├── types.ts # Definições de tipos
|
|
235
|
+
├── constants.ts # Nomes das UFs, capitais, regiões
|
|
236
|
+
├── data.ts # Carregamento do banco JSON
|
|
237
|
+
├── municipios.ts # Funções de busca
|
|
238
|
+
└── flags.ts # Resolução de caminhos de bandeiras
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
### Convenção de Nomes
|
|
242
|
+
|
|
243
|
+
Arquivos seguem o padrão: `{ibge_code}-{slug}-{style}.{ext}`
|
|
244
|
+
|
|
245
|
+
- **ibge_code**: Código oficial IBGE do município (7 dígitos)
|
|
246
|
+
- **slug**: Nome do município em formato URL (minúsculas, hifenizado)
|
|
247
|
+
- **style**: `full`, `rounded`, `circle` ou `sq`
|
|
248
|
+
|
|
249
|
+
Exemplo: `3550308-sao-paulo-circle.svg` (Cidade de São Paulo, estilo circle)
|
|
250
|
+
|
|
251
|
+
---
|
|
252
|
+
|
|
253
|
+
## Acesso Direto aos Arquivos
|
|
254
|
+
|
|
255
|
+
```html
|
|
256
|
+
<!-- SVG (recomendado para web) -->
|
|
257
|
+
<img src="dist/circle/svg/SP/3550308-sao-paulo-circle.svg" alt="São Paulo" />
|
|
258
|
+
|
|
259
|
+
<!-- PNG 200px -->
|
|
260
|
+
<img src="dist/full/png-200/SP/3550308-sao-paulo-full.png" alt="São Paulo" />
|
|
261
|
+
|
|
262
|
+
<!-- PNG 800px (alta resolução) -->
|
|
263
|
+
<img src="dist/rounded/png-800/SP/3550308-sao-paulo-rounded.png" alt="São Paulo" />
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### Consulta ao Banco de Dados (Python)
|
|
267
|
+
|
|
268
|
+
```python
|
|
269
|
+
import json
|
|
270
|
+
|
|
271
|
+
with open("database/municipios.json") as f:
|
|
272
|
+
municipios = json.load(f)
|
|
273
|
+
|
|
274
|
+
sp = next(m for m in municipios if m["ibge_code"] == 3550308)
|
|
275
|
+
if sp["has_icons"]:
|
|
276
|
+
print(f'dist/{sp["icons"]["circle_svg"]}')
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
---
|
|
280
|
+
|
|
281
|
+
## Geração
|
|
282
|
+
|
|
283
|
+
### Pré-requisitos
|
|
284
|
+
|
|
285
|
+
- Python 3.8+
|
|
286
|
+
- Pillow (`pip install Pillow`)
|
|
287
|
+
- tqdm (`pip install tqdm`)
|
|
288
|
+
- rsvg-convert (`brew install librsvg` no macOS)
|
|
289
|
+
|
|
290
|
+
### Gerar ícones
|
|
291
|
+
|
|
292
|
+
```bash
|
|
293
|
+
# Todas as bandeiras, todos os formatos (4 SVG + 8 PNG por bandeira)
|
|
294
|
+
python3 scripts/generate-icons.py
|
|
295
|
+
|
|
296
|
+
# Apenas SVG (mais rápido)
|
|
297
|
+
python3 scripts/generate-icons.py --skip-png
|
|
298
|
+
|
|
299
|
+
# Um único estado
|
|
300
|
+
python3 scripts/generate-icons.py --uf SP
|
|
301
|
+
|
|
302
|
+
# Mais paralelismo
|
|
303
|
+
python3 scripts/generate-icons.py --workers 8
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
### Construir banco de dados
|
|
307
|
+
|
|
308
|
+
```bash
|
|
309
|
+
python3 scripts/build-database.py
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
|
|
314
|
+
## Fontes de Dados
|
|
315
|
+
|
|
316
|
+
- **Wikidata** — Dados estruturados de bandeiras via consultas SPARQL
|
|
317
|
+
- **Wikimedia Commons** — Descoberta por categoria e busca
|
|
318
|
+
- **Wikipedia** — Scraping de páginas de municípios
|
|
319
|
+
- **Sites de prefeituras** — Fontes municipais oficiais
|
|
320
|
+
|
|
321
|
+
Todas as bandeiras são de domínio público ou licença livre.
|
|
322
|
+
|
|
323
|
+
---
|
|
324
|
+
|
|
325
|
+
## Créditos
|
|
326
|
+
|
|
327
|
+
- Ícones originais das bandeiras estaduais por [Pierre Lapalu](https://github.com/pierrelapalu/icones-bandeiras-br-uf)
|
|
328
|
+
- Bandeiras municipais coletadas do Wikimedia/Wikidata (domínio público)
|
|
329
|
+
- Códigos IBGE dos municípios do [IBGE](https://www.ibge.gov.br/)
|
|
330
|
+
|
|
331
|
+
---
|
|
332
|
+
|
|
333
|
+
## Licença
|
|
334
|
+
|
|
335
|
+
MIT
|