@@ -18,8 +18,6 @@ async function convertShpToGeo(filename) {
18
18
const outputFilePath = `${ outputDirGeojson } /${ filename } .geojson` ;
19
19
const commands = [ inputFilePath , `-proj wgs84` , `-o format=geojson ${ outputFilePath } ` ] . join ( ' ' ) ;
20
20
await mapshaper . runCommands ( commands ) ;
21
-
22
- console . log ( `GeoJSON saved to ${ outputFilePath } ` ) ;
23
21
}
24
22
25
23
function getJsonFile ( filename ) {
@@ -32,7 +30,6 @@ function getJsonFile(filename) {
32
30
}
33
31
34
32
async function createCountriesLayer ( { bounds, filter, name, resolution, source } ) {
35
- console . log ( `Building ${ resolution } m countries layer for '${ name } '` ) ;
36
33
const inputFilePath = `${ outputDirGeojson } /${ unFilename } _${ resolution } m/${ source } .geojson` ;
37
34
const outputFilePath = `${ outputDirGeojson } /${ name } _${ resolution } m/countries.geojson` ;
38
35
const commands = [
@@ -43,7 +40,6 @@ async function createCountriesLayer({ bounds, filter, name, resolution, source }
43
40
] . join ( ' ' ) ;
44
41
await mapshaper . runCommands ( commands ) ;
45
42
addCentroidsToGeojson ( outputFilePath ) ;
46
- // TODO: Add simplification command if on 110m resolution? Or take care of somewhere else?
47
43
}
48
44
49
45
function addCentroidsToGeojson ( geojsonPath ) {
@@ -62,7 +58,6 @@ function addCentroidsToGeojson(geojsonPath) {
62
58
63
59
async function createLandLayer ( { bounds, name, resolution, source } ) {
64
60
// TODO: Figure out way to only include North and Central America via filter, dissolve
65
- console . log ( `Building ${ resolution } m land layer for '${ name } '` ) ;
66
61
const inputFilePath = `${ outputDirGeojson } /${ unFilename } _${ resolution } m/${ source } .geojson` ;
67
62
const outputFilePath = `${ outputDirGeojson } /${ name } _${ resolution } m/land.geojson` ;
68
63
const commands = [
@@ -75,7 +70,6 @@ async function createLandLayer({ bounds, name, resolution, source }) {
75
70
}
76
71
77
72
async function createCoastlinesLayer ( { bounds, name, resolution, source } ) {
78
- console . log ( `Building ${ resolution } m coastlines layer for '${ name } '` ) ;
79
73
// TODO: Update source to be a path?
80
74
const inputFilePath = `${ outputDirGeojson } /${ unFilename } _${ resolution } m/${ source } .geojson` ;
81
75
const outputFilePath = `${ outputDirGeojson } /${ name } _${ resolution } m/coastlines.geojson` ;
@@ -90,7 +84,6 @@ async function createCoastlinesLayer({ bounds, name, resolution, source }) {
90
84
}
91
85
92
86
async function createOceanLayer ( { bounds, name, resolution, source } ) {
93
- console . log ( `Building ${ resolution } m ocean layer for '${ name } '` ) ;
94
87
const inputFilePath = `./tasks/topojson/world_rectangle.geojson` ;
95
88
const outputFilePath = `${ outputDirGeojson } /${ name } _${ resolution } m/ocean.geojson` ;
96
89
const eraseFilePath = `${ outputDirGeojson } /${ unFilename } _${ resolution } m/${ source } .geojson` ;
@@ -104,7 +97,6 @@ async function createOceanLayer({ bounds, name, resolution, source }) {
104
97
}
105
98
106
99
async function createRiversLayer ( { name, resolution, source } ) {
107
- console . log ( `Building ${ resolution } m rivers layer for '${ name } '` ) ;
108
100
const inputFilePath = `${ outputDirGeojson } /${ getNEFilename ( { resolution, source } ) } .geojson` ;
109
101
const outputFilePath = `${ outputDirGeojson } /${ name } _${ resolution } m/rivers.geojson` ;
110
102
const commands = [
@@ -116,7 +108,6 @@ async function createRiversLayer({ name, resolution, source }) {
116
108
}
117
109
118
110
async function createLakesLayer ( { name, resolution, source } ) {
119
- console . log ( `Building ${ resolution } m lakes layer for '${ name } '` ) ;
120
111
const inputFilePath = `${ outputDirGeojson } /${ getNEFilename ( { resolution, source } ) } .geojson` ;
121
112
const outputFilePath = `${ outputDirGeojson } /${ name } _${ resolution } m/lakes.geojson` ;
122
113
const commands = [
@@ -128,7 +119,6 @@ async function createLakesLayer({ name, resolution, source }) {
128
119
}
129
120
130
121
async function createSubunitsLayer ( { name, resolution, source } ) {
131
- console . log ( `Building ${ resolution } m subunits layer for '${ name } '` ) ;
132
122
const filter = [ 'AUS' , 'BRA' , 'CAN' , 'USA' ] . map ( ( id ) => `adm0_a3 === "${ id } "` ) . join ( ' || ' ) ;
133
123
const inputFilePath = `${ outputDirGeojson } /${ getNEFilename ( { resolution, source } ) } .geojson` ;
134
124
const outputFilePath = `${ outputDirGeojson } /${ name } _${ resolution } m/subunits.geojson` ;
@@ -211,10 +201,7 @@ function getCentroid(feature) {
211
201
212
202
async function convertLayersToTopojson ( { name, resolution } ) {
213
203
const regionDir = path . join ( outputDirGeojson , `${ name } _${ resolution } m` ) ;
214
- if ( ! fs . existsSync ( regionDir ) ) {
215
- console . log ( `Couldn't find ${ regionDir } ` ) ;
216
- return ;
217
- }
204
+ if ( ! fs . existsSync ( regionDir ) ) return ;
218
205
219
206
const outputFile = `${ outputDirTopojson } /${ name } _${ resolution } m.json` ;
220
207
// Layer names default to file names
@@ -225,8 +212,6 @@ async function convertLayersToTopojson({ name, resolution }) {
225
212
const topojson = getJsonFile ( outputFile ) ;
226
213
const prunedTopojson = pruneProperties ( topojson ) ;
227
214
fs . writeFileSync ( outputFile , JSON . stringify ( prunedTopojson ) ) ;
228
-
229
- console . log ( `Topojson saved to: ${ outputFile } ` ) ;
230
215
}
231
216
232
217
// Get polygon features from UN GeoJSON
0 commit comments