From 2ac4a2ead4ed1a06ce26c122400937aaf4edeeb2 Mon Sep 17 00:00:00 2001 From: Anton Akhatov Date: Tue, 26 Sep 2023 01:28:53 +0100 Subject: [PATCH] use new tile server + add house meta --- .eslintrc.json | 1 - components/Layers/Houses/houseBase.ts | 17 ++++++++++++++++- components/Map/Map.tsx | 2 +- public/house-meta.json | 1 - public/houses-meta.json | 1 - 5 files changed, 17 insertions(+), 5 deletions(-) delete mode 100644 public/house-meta.json delete mode 100644 public/houses-meta.json diff --git a/.eslintrc.json b/.eslintrc.json index acf0a4b3..d8ebbc05 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -5,7 +5,6 @@ }, "rules": { "indent": ["error", 4, { "SwitchCase": 1 }], - "no-console": ["error", { "allow": ["error"] }], "no-param-reassign": ["error", { "props": false }], "no-plusplus": "off", "implicit-arrow-linebreak": "off", diff --git a/components/Layers/Houses/houseBase.ts b/components/Layers/Houses/houseBase.ts index a8f3a6c7..96a55558 100644 --- a/components/Layers/Houses/houseBase.ts +++ b/components/Layers/Houses/houseBase.ts @@ -1,9 +1,24 @@ import { HistogramDataWithoutValues } from 'components/UI/RangeHistogram'; -import houseMeta from '../../../public/houses-meta.json'; import { HouseSourceType } from './Houses.constants'; +type Meta = Record; + +let cache: Meta = null; +async function getHouseMeta(): Promise { + return fetch('https://map-backend.netlify.app/house-meta.json') + .then((res) => res.json()) + .then((data) => ({ + years: data.years.map((item) => item.count || null), + levels: data.levels.map((item) => item.count || null), + health: data.health.map((item) => item.count || null), + })); +} + export const houseBase = { async getFilterValues(_: HistogramDataWithoutValues, filterName: HouseSourceType) { + const houseMeta = cache || (await getHouseMeta()); + cache = houseMeta; + switch (filterName) { case HouseSourceType.Year: return Promise.resolve(houseMeta.years); diff --git a/components/Map/Map.tsx b/components/Map/Map.tsx index 7d14d824..58debece 100644 --- a/components/Map/Map.tsx +++ b/components/Map/Map.tsx @@ -43,7 +43,7 @@ export function Map() { maxZoom={20} // hash style={{ width: '100vw', height: '100vh', color: 'black' }} - mapStyle="https://cartography-zeta.vercel.app/style.json" + mapStyle="https://map-backend.netlify.app/style.json" // @ts-ignore mapLib={maplibregl} antialias diff --git a/public/house-meta.json b/public/house-meta.json deleted file mode 100644 index c8ce3c31..00000000 --- a/public/house-meta.json +++ /dev/null @@ -1 +0,0 @@ -{"years":{"1723":2,"1725":1,"1726":3,"1749":1,"1800":9,"1806":1,"1810":1,"1820":14,"1824":1,"1826":5,"1827":1,"1829":1,"1830":8,"1833":1,"1835":3,"1836":1,"1837":2,"1838":2,"1840":12,"1845":1,"1847":3,"1849":1,"1850":67,"1852":3,"1854":1,"1859":1,"1860":1,"1863":1,"1865":2,"1868":1,"1870":14,"1873":1,"1874":1,"1876":1,"1877":1,"1878":1,"1880":68,"1881":3,"1882":1,"1884":2,"1885":1,"1886":5,"1888":4,"1889":2,"1890":34,"1891":3,"1892":5,"1893":2,"1894":6,"1896":9,"1897":2,"1899":3,"1900":42,"1901":8,"1902":2,"1903":1,"1904":1,"1905":2,"1906":2,"1908":2,"1909":5,"1910":20,"1912":4,"1913":2,"1914":7,"1915":3,"1917":304,"1919":2,"1920":13,"1921":2,"1922":5,"1923":3,"1924":9,"1925":15,"1926":21,"1927":40,"1928":46,"1929":47,"1930":100,"1931":38,"1932":125,"1933":38,"1934":58,"1935":34,"1936":72,"1937":70,"1938":73,"1939":116,"1940":164,"1941":119,"1942":34,"1943":43,"1944":36,"1945":72,"1946":104,"1947":106,"1948":209,"1949":206,"1950":308,"1951":197,"1952":390,"1953":355,"1954":339,"1955":324,"1956":372,"1957":564,"1958":872,"1959":928,"1960":1019,"1961":695,"1962":558,"1963":549,"1964":433,"1965":337,"1966":298,"1967":299,"1968":291,"1969":240,"1970":316,"1971":214,"1972":226,"1973":219,"1974":196,"1975":239,"1976":222,"1977":247,"1978":203,"1979":176,"1980":231,"1981":174,"1982":200,"1983":147,"1984":174,"1985":213,"1986":189,"1987":196,"1988":189,"1989":191,"1990":211,"1991":180,"1992":220,"1993":174,"1994":189,"1995":202,"1996":133,"1997":152,"1998":183,"1999":176,"2000":158,"2001":113,"2002":158,"2003":175,"2004":236,"2005":231,"2006":332,"2007":290,"2008":339,"2009":321,"2010":328,"2011":359,"2012":328,"2013":395,"2014":501,"2015":342,"2016":212,"2017":72,"2018":96,"2019":85,"2020":82,"2021":31,"2022":3,"unknown":57822},"health":{"1":59,"2":38,"3":54,"4":71,"5":126,"6":94,"7":93,"8":84,"9":85,"10":196,"11":105,"12":104,"13":69,"14":93,"15":116,"16":124,"17":108,"18":111,"19":143,"20":194,"21":135,"22":124,"23":109,"24":131,"25":201,"26":113,"27":109,"28":121,"29":102,"30":173,"31":85,"32":97,"33":82,"34":93,"35":131,"36":79,"37":63,"38":56,"39":71,"40":107,"41":68,"42":73,"43":61,"44":71,"45":87,"46":58,"47":43,"48":45,"49":50,"50":93,"51":48,"52":28,"53":30,"54":30,"55":32,"56":21,"57":15,"58":15,"59":14,"60":35,"61":13,"62":18,"63":15,"64":26,"65":25,"66":24,"67":22,"68":10,"69":15,"70":14,"71":7,"72":6,"73":7,"74":4,"75":1,"78":4,"79":1,"80":3,"82":2,"unknown":75601,"37.3":1,"7.3":2,"9.55":1,"2.7":2,"25.9":1,"3.25":3,"2.2":1,"15.5":1,"0.6":2,"7.2":4,"5.3":1,"2.6":1,"12.9":1,"4.6":2,"22.5":2,"8.2":1,"0.01":3,"35.3":1,"34.6":1,"8.55":2,"10.35":2,"2.5":6,"13.6":1,"21.7":1,"19.4":2,"26.4":1,"0.35":1,"6.5":2,"4.8":1,"5.6":2,"1.2":7,"3.3":1,"3.5":2,"1.6":1,"5.4":4,"8.8":2,"53.8":1,"3.6":4,"7.5":2,"0.5":2,"22.27":3,"6.3":2,"6.4":4,"3.2":2,"43.1":1,"4.5":6,"12.5":2,"0.2":5,"11.6":1,"25.63":3,"1.5":3,"11.4":1,"11.7":2,"21.5":1,"13.7":1,"13.2":1,"3.4":1,"0.1":1,"2.8":1,"15.2":1},"levels":{"0":4,"1":7986,"2":3674,"3":1431,"4":904,"5":3036,"6":184,"7":95,"8":71,"9":1496,"10":461,"11":50,"12":385,"13":49,"14":148,"15":62,"16":465,"17":83,"18":85,"19":53,"20":44,"21":14,"22":24,"23":24,"24":36,"25":115,"26":57,"27":22,"28":31,"29":8,"30":11,"31":4,"32":12,"33":5,"34":7,"35":3,"36":1,"37":3,"42":2,"52":2,"unknown":59953,"-1":3,"1;2":1}} \ No newline at end of file diff --git a/public/houses-meta.json b/public/houses-meta.json deleted file mode 100644 index 5ac28696..00000000 --- a/public/houses-meta.json +++ /dev/null @@ -1 +0,0 @@ -{"years":[146,275,507,724,2682,12152,3962,2834],"levels":[11660,2335,3386,2007,644,730,98,244,37],"health":[777,1185,1351,933,664,327,203,44,5,null]} \ No newline at end of file