F1 — a tolerancia de simplificacao e os digitos de quantizacao viraram politica em unidades de solo em scripts/lib/topology.mjs, consumida pelos dois scripts de geometria. Os quantis 0.35 copiados cortavam as 19 ZE de Salvador a ~0.6 m2 e os 417 municipios a ~1.78 km2; com tolerancia absoluta e a grade de ~103 m do estado, a malha das zonas caiu de 480 para 30.2 pontos/feature. bahia-municipalities segue byte-identico e o tripwire de bytes deu lugar a pontos/feature. F2 — featureMapKey passou a ser asserido sobre features reais das tres malhas comprometidas (417 codarea, 27 code, 19 slug), e o comentario de MAP_KEY_PROPERTIES agora diz o que o codigo faz: as propriedades sao mutuamente exclusivas, nao ordenadas por especificidade. F3 — a malha das zonas e um detalhe sobre o mapa, nao o mapa: se o chunk falha, Salvador cai no poligono municipal que ja esta desenhado embaixo e o resto da Bahia continua funcionando, com o motivo logado. A ressalva de aproximacao saiu do gate de comparacao e passou a depender de bundle.hasZoneMunicipalities, derivado no servidor de municipality.kind. F4 — orfaos deletados: os dois acessores sem chamador, isZoneMapKey (o servidor ja sabe a regra), o wrapper simplifyTopology e o helper polygonCount com um branch inalcancavel. MunicipalityMapNavigation colapsou em string | undefined e MunicipalitiesByMapKey em Record<string, string>.
72 lines
2.2 KiB
TypeScript
72 lines
2.2 KiB
TypeScript
import type { Feature, MultiPolygon, Polygon } from 'geojson'
|
||
import type { GeometryCollection, Topology } from 'topojson-specification'
|
||
|
||
/** Every committed mesh is polygonal; only the properties differ. */
|
||
type BahiaFeature<Properties> = Feature<Polygon | MultiPolygon, Properties>
|
||
|
||
type BahiaMunicipalityProperties = {
|
||
codarea: string
|
||
name: string
|
||
}
|
||
|
||
type BahiaTerritoryProperties = {
|
||
code: string
|
||
name: string
|
||
}
|
||
|
||
/**
|
||
* Zone municipalities (Salvador ZE 1–19): keyed by the catalog slug, because a
|
||
* zone has no IBGE code of its own — the whole city shares `ibgeCode`.
|
||
*/
|
||
type MunicipalityZoneProperties = {
|
||
municipalitySlug: string
|
||
name: string
|
||
ibgeCode: string
|
||
}
|
||
|
||
export type BahiaMunicipalityFeature = BahiaFeature<BahiaMunicipalityProperties>
|
||
|
||
export type BahiaTerritoryFeature = BahiaFeature<BahiaTerritoryProperties>
|
||
|
||
export type MunicipalityZoneFeature = BahiaFeature<MunicipalityZoneProperties>
|
||
|
||
/** Any feature of the committed meshes, as the map layer receives them. */
|
||
export type BahiaMeshFeature =
|
||
| BahiaMunicipalityFeature
|
||
| BahiaTerritoryFeature
|
||
| MunicipalityZoneFeature
|
||
|
||
/**
|
||
* What the geometry helpers actually need — a polygonal geometry, nothing else.
|
||
* Declaring the requirement instead of a feature union keeps `GeoJsonProperties`
|
||
* (which is `any`) out of the signature of a helper that only reads coordinates.
|
||
*/
|
||
export type PolygonalFeature = { geometry: Polygon | MultiPolygon }
|
||
|
||
export type MunicipalityTopology = Topology<{
|
||
municipalities: GeometryCollection<BahiaMunicipalityProperties>
|
||
}>
|
||
|
||
export type TerritoryTopology = Topology<{
|
||
territories: GeometryCollection<BahiaTerritoryProperties>
|
||
}>
|
||
|
||
export type MunicipalityZoneTopology = Topology<{
|
||
municipalityZones: GeometryCollection<MunicipalityZoneProperties>
|
||
}>
|
||
|
||
export type MunicipalityGeometryModule = {
|
||
topology: MunicipalityTopology
|
||
features: readonly BahiaMunicipalityFeature[]
|
||
getMunicipalityFeature: (codarea: string) => BahiaMunicipalityFeature | undefined
|
||
}
|
||
|
||
export type TerritoryGeometryModule = {
|
||
topology: TerritoryTopology
|
||
features: readonly BahiaTerritoryFeature[]
|
||
}
|
||
|
||
export type MunicipalityZoneGeometryModule = {
|
||
topology: MunicipalityZoneTopology
|
||
features: readonly MunicipalityZoneFeature[]
|
||
}
|