refactor: draw state labels start

This commit is contained in:
Azgaar 2022-09-13 00:13:13 +03:00
parent e35cc2e9cb
commit e07bf91cd7
4 changed files with 131 additions and 18 deletions

View file

@ -69,8 +69,8 @@ async function generate(options?: IGenerationOptions) {
// renderLayer("biomes");
renderLayer("burgs");
renderLayer("routes");
// renderLayer("states");
renderLayer("provinces");
renderLayer("states");
renderLayer("labels");
// pack.cells.route.forEach((route, index) => {
// if (route === 2) drawPoint(pack.cells.p[index], {color: "black"});

View file

@ -14,10 +14,12 @@ interface IGetPolesProps {
export function getPolesOfInaccessibility(props: IGetPolesProps) {
TIME && console.time("getPolesOfInaccessibility");
const multiPolygons = getMultiPolygons(props);
const sortByLength = (a: unknown[], b: unknown[]) => b.length - a.length;
console.log(multiPolygons);
const poles: Dict<TPoint> = Object.fromEntries(
Object.entries(multiPolygons).map(([id, multiPolygon]) => {
const [x, y] = polylabel(multiPolygon, 20);
const [x, y] = polylabel(multiPolygon.sort(sortByLength), 20);
return [id, [rn(x), rn(y)]];
})
);