Skip to content

Commit b7b41a6

Browse files
authored
Merge pull request #493 from HSLdevcom/osm-preprocessing-changes
AB#235 Remove downloads related to OSM preprocessing
2 parents 2612f5a + 7821e59 commit b7b41a6

4 files changed

Lines changed: 16 additions & 42 deletions

File tree

config.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,6 @@ const osm = {
6868
...extraOSM,
6969
};
7070

71-
const osmPreprocessingURLs = {
72-
hsl: 'https://geocoding.blob.core.windows.net/vrk/osm-preprocessing-hsl.txt',
73-
};
74-
7571
const dem = {
7672
waltti:
7773
'https://elevdata.blob.core.windows.net/elevation/waltti/waltti-10m-elevation-model_20190927.tif',
@@ -88,14 +84,6 @@ module.exports = {
8884
osm: router.osm.map(id => {
8985
return { id, url: osm[id] };
9086
}), // array of id, url (OSM data) pairs
91-
osmPreprocessingInstructions: router.osm
92-
.filter(id => {
93-
return osmPreprocessingURLs[id];
94-
})
95-
.map(id => {
96-
return { id, url: osmPreprocessingURLs[id] };
97-
}), // array of id, url (OSM preprocessing instruction data) pairs
98-
osmPreprocessingURLs,
9987
dem: router.dem ? [{ id: router.dem, url: dem[router.dem] }] : null, // currently only one DEM file is used
10088
dataToolImage: `hsldevcom/otp-data-tools:${process.env.TOOLS_TAG || 'v3'}`,
10189
dataDir: `${process.cwd()}/data`,

gulpfile.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ const storageCleanup = require('./task/StorageCleanup');
3030
const seedSourceDir = `${config.dataDir}/router-${config.router.id}`; // e.g. data/router-hsl
3131

3232
const osmDlDir = `${config.dataDir}/downloads/osm`;
33-
const osmPreprocessingDlDir = `${config.dataDir}/downloads/osm-preprocessing`;
3433
const demDlDir = `${config.dataDir}/downloads/dem`;
3534
const gtfsDlDir = `${config.dataDir}/downloads/gtfs`;
3635

@@ -60,10 +59,6 @@ gulp.task('osm:download', async cb => {
6059
createDir(osmDlDir);
6160
createDir(osmDir);
6261
await dl(config.osm, osmDlDir);
63-
if (config.osmPreprocessingInstructions) {
64-
createDir(osmPreprocessingDlDir);
65-
await dl(config.osmPreprocessingInstructions, osmPreprocessingDlDir);
66-
}
6762
cb();
6863
});
6964

@@ -75,7 +70,7 @@ gulp.task(
7570
gulp
7671
.src(`${osmDlDir}/*`, noBuf)
7772
.pipe(validateBlobSize())
78-
.pipe(runOSMPreprocessing(osmPreprocessingDlDir))
73+
.pipe(runOSMPreprocessing(`${config.router.id}/osm-preprocessing`))
7974
.pipe(testOTPFile())
8075
.pipe(gulp.dest(osmDir)),
8176
() => del(tmpDir),

hsl/osm-preprocessing/hsl.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
osmconvert hsl.pbf -o=hsl.o5m
2+
osmfilter hsl.o5m --modify-tags="ref=H0071 to ref=no ref=H0091 to ref=no ref=H0072 to ref=no" -o=hsl2.o5m
3+
osmconvert hsl2.o5m -o=hsl.pbf

task/OSMPreprocessing.js

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,7 @@ const readline = require('readline');
44
const fse = require('fs-extra');
55
const exec = require('child_process').exec;
66
const through = require('through2');
7-
const {
8-
dataDir,
9-
constants,
10-
dataToolImage,
11-
osmPreprocessingURLs,
12-
} = require('../config');
7+
const { dataDir, constants, dataToolImage } = require('../config');
138
const { postSlackMessage, createDir } = require('../util');
149

1510
async function readPreprocessingInstructions(preprocessingInstructionsFile) {
@@ -45,19 +40,23 @@ async function readPreprocessingInstructions(preprocessingInstructionsFile) {
4540
function preprocessWithFile(
4641
osmFile,
4742
quiet = false,
48-
osmPreprocessingDlDir,
43+
osmPreprocessingDir,
4944
osmId,
5045
osmFileName,
5146
) {
5247
const lastLog = [];
5348

5449
return new Promise((resolve, reject) => {
55-
const preprocessingInstructionsFile = `${osmPreprocessingDlDir}/${osmId}.txt`;
50+
const preprocessingInstructionsFile = `${osmPreprocessingDir}/${osmId}.txt`;
5651

5752
if (!fs.existsSync(osmFile)) {
5853
reject(new Error(`${osmFile} does not exist!\n`));
5954
} else if (!fs.existsSync(preprocessingInstructionsFile)) {
60-
reject(new Error(`${preprocessingInstructionsFile} does not exist!\n`));
55+
reject(
56+
new Error(
57+
`No OSM preprocessing instructions for ${osmId}. ${preprocessingInstructionsFile} does not exist!\n`,
58+
),
59+
);
6160
} else {
6261
createDir(`${dataDir}/tmp`);
6362
fs.mkdtemp(`${dataDir}/tmp/osm-preprocessing`, (err, folder) => {
@@ -138,7 +137,7 @@ function preprocessWithFile(
138137
}
139138

140139
module.exports = {
141-
runOSMPreprocessing: osmPreprocessingDlDir => {
140+
runOSMPreprocessing: osmPreprocessingDir => {
142141
return through.obj(function (file, encoding, callback) {
143142
const osmFile = file.history[file.history.length - 1];
144143
if (process.env.SKIP_OSM_PREPROCESSING) {
@@ -150,19 +149,7 @@ module.exports = {
150149
const osmFileName = osmFile.split('/').pop();
151150
// This can be, for example, hsl, finland, or southFinland.
152151
const osmId = osmFileName.split('.')[0];
153-
if (!osmPreprocessingURLs[osmId]) {
154-
process.stdout.write(
155-
'No OSM preprocessing instructions for ' + osmId + '\n',
156-
);
157-
return callback(null, file);
158-
}
159-
preprocessWithFile(
160-
osmFile,
161-
true,
162-
osmPreprocessingDlDir,
163-
osmId,
164-
osmFileName,
165-
)
152+
preprocessWithFile(osmFile, true, osmPreprocessingDir, osmId, osmFileName)
166153
.then(outputContents => {
167154
if (outputContents) {
168155
file.contents = outputContents;
@@ -171,7 +158,8 @@ module.exports = {
171158
callback(null, null);
172159
}
173160
})
174-
.catch(() => {
161+
.catch(err => {
162+
process.stdout.write(err.message);
175163
callback(null, null);
176164
});
177165
});

0 commit comments

Comments
 (0)