From 16d688567775062a50ef9b3cc4a335e35f21b022 Mon Sep 17 00:00:00 2001 From: mloenow Date: Fri, 21 Jan 2022 22:12:31 +0100 Subject: [PATCH] Add support for DBF file encoding --- src/map.view.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/map.view.ts b/src/map.view.ts index ee63d1e..63c5fca 100644 --- a/src/map.view.ts +++ b/src/map.view.ts @@ -417,9 +417,13 @@ export class MapView { await fileUtils.readDataFile(dataUrl.replace('.shp', '.prj'), 'utf8'); const dbfData = await fileUtils.readDataFile(dataUrl.replace('.shp', '.dbf'), null); + const cpgFilePath = dataUrl.replace('.shp', '.cpg'); + const encoding = fs.existsSync(cpgFilePath) + ? await fileUtils.readDataFile(cpgFilePath, 'utf8') + : undefined; this._mapData = shapefile.combine([ shapefile.parseShp(shapefileData, prjData), - shapefile.parseDbf(dbfData) + shapefile.parseDbf(dbfData, encoding) ]); this.createGeoJsonFile(this._mapData); this.refreshMapView();