Skip to content

Commit

Permalink
Reformat code with prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
russellporter committed Aug 1, 2024
1 parent fb01cf8 commit 6276ad2
Show file tree
Hide file tree
Showing 54 changed files with 528 additions and 515 deletions.
2 changes: 1 addition & 1 deletion src/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function configFromEnvironment(): Config {
assert(
Array.isArray(bbox) &&
bbox.length === 4 &&
bbox.every((value) => typeof value === "number")
bbox.every((value) => typeof value === "number"),
);
}
const geocodingCacheTTL = process.env.GEOCODING_SERVER_URL_TTL;
Expand Down
26 changes: 13 additions & 13 deletions src/PrepareGeoJSON.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ it("produces empty output for empty input", async () => {
lifts: [],
runs: [],
},
paths.input
paths.input,
);

await prepare(paths, config);
Expand Down Expand Up @@ -134,7 +134,7 @@ it("produces output for simple input", async () => {
},
],
},
paths.input
paths.input,
);

await prepare(paths, config);
Expand Down Expand Up @@ -411,17 +411,17 @@ it("shortens ski area names for Mapbox GL output", async () => {
lifts: [],
runs: [],
},
paths.input
paths.input,
);

await prepare(paths, config);

expect(
TestHelpers.fileContents(paths.output.mapboxGL.skiAreas).features[0]
.properties.name
.properties.name,
).toBe("Ski Welt");
expect(
TestHelpers.fileContents(paths.output.skiAreas).features[0].properties.name
TestHelpers.fileContents(paths.output.skiAreas).features[0].properties.name,
).toBe(longName);
});

Expand Down Expand Up @@ -457,7 +457,7 @@ it("processes OpenStreetMap ski areas", async () => {
lifts: [],
runs: [],
},
paths.input
paths.input,
);

await prepare(paths, config);
Expand Down Expand Up @@ -569,15 +569,15 @@ it("processes OpenStreetMap ski area sites", async () => {
},
],
},
paths.input
paths.input,
);

await prepare(paths, config);

expect(
TestHelpers.fileContents(paths.output.skiAreas).features.map(
simplifiedSkiAreaFeature
)
simplifiedSkiAreaFeature,
),
).toMatchInlineSnapshot(`
[
{
Expand All @@ -590,8 +590,8 @@ it("processes OpenStreetMap ski area sites", async () => {

expect(
TestHelpers.fileContents(paths.output.lifts).features.map(
simplifiedLiftFeature
)
simplifiedLiftFeature,
),
).toMatchInlineSnapshot(`
[
{
Expand All @@ -606,8 +606,8 @@ it("processes OpenStreetMap ski area sites", async () => {

expect(
TestHelpers.fileContents(paths.output.runs).features.map(
simplifiedRunFeature
)
simplifiedRunFeature,
),
).toMatchInlineSnapshot(`
[
{
Expand Down
36 changes: 18 additions & 18 deletions src/PrepareGeoJSON.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,21 @@ export default async function prepare(paths: DataPaths, config: Config) {
await StreamToPromise(
merge([
readGeoJSONFeatures(paths.input.geoJSON.skiAreas).pipe(
flatMap(formatSkiArea(InputSkiAreaType.OPENSTREETMAP_LANDUSE))
flatMap(formatSkiArea(InputSkiAreaType.OPENSTREETMAP_LANDUSE)),
),
Readable.from(siteProvider.getGeoJSONSites()),
readGeoJSONFeatures(paths.input.geoJSON.skiMapSkiAreas).pipe(
flatMap(formatSkiArea(InputSkiAreaType.SKIMAP_ORG))
flatMap(formatSkiArea(InputSkiAreaType.SKIMAP_ORG)),
),
])
.pipe(toFeatureCollection())
.pipe(
createWriteStream(
config.arangoDBURLForClustering
? paths.intermediate.skiAreas
: paths.output.skiAreas
)
)
: paths.output.skiAreas,
),
),
);

console.log("Processing runs...");
Expand All @@ -67,17 +67,17 @@ export default async function prepare(paths: DataPaths, config: Config) {
config.elevationServerURL
? addElevation(config.elevationServerURL)
: null,
10
)
10,
),
)
.pipe(toFeatureCollection())
.pipe(
createWriteStream(
config.arangoDBURLForClustering
? paths.intermediate.runs
: paths.output.runs
)
)
: paths.output.runs,
),
),
);

console.log("Processing lifts...");
Expand All @@ -91,17 +91,17 @@ export default async function prepare(paths: DataPaths, config: Config) {
config.elevationServerURL
? addElevation(config.elevationServerURL)
: null,
10
)
10,
),
)
.pipe(toFeatureCollection())
.pipe(
createWriteStream(
config.arangoDBURLForClustering
? paths.intermediate.lifts
: paths.output.lifts
)
)
: paths.output.lifts,
),
),
);

if (config.arangoDBURLForClustering) {
Expand All @@ -110,7 +110,7 @@ export default async function prepare(paths: DataPaths, config: Config) {
paths.intermediate,
paths.output,
config.arangoDBURLForClustering,
config.geocodingServer
config.geocodingServer,
);
}

Expand All @@ -122,9 +122,9 @@ export default async function prepare(paths: DataPaths, config: Config) {
readGeoJSONFeatures(getPath(paths.output, type))
.pipe(flatMap(MapboxGLFormatter.formatter(type)))
.pipe(toFeatureCollection())
.pipe(createWriteStream(getPath(paths.output.mapboxGL, type)))
.pipe(createWriteStream(getPath(paths.output.mapboxGL, type))),
);
})
}),
);

console.log("Done preparing");
Expand Down
8 changes: 4 additions & 4 deletions src/PrepareGeoJSONWithElevation.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ it("adds elevations to lift geometry", async () => {
],
runs: [],
},
paths.input
paths.input,
);

await prepare(paths, config);
Expand Down Expand Up @@ -148,7 +148,7 @@ it("adds elevations to run geometry & elevation profile", async () => {
},
],
},
paths.input
paths.input,
);

await prepare(paths, config);
Expand Down Expand Up @@ -231,7 +231,7 @@ it("completes without adding elevations when elevation server fails", async () =
],
runs: [],
},
paths.input
paths.input,
);

await prepare(paths, config);
Expand Down Expand Up @@ -328,7 +328,7 @@ it("adds elevations to run polygons", async () => {
},
],
},
paths.input
paths.input,
);

await prepare(paths, config);
Expand Down
26 changes: 13 additions & 13 deletions src/TestHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,70 +55,70 @@ export function mockInputFiles(
lifts: InputLiftFeature[];
runs: InputRunFeature[];
},
inputPaths: InputDataPaths
inputPaths: InputDataPaths,
) {
fs.writeFileSync(
inputPaths.geoJSON.skiMapSkiAreas,
JSON.stringify({
type: "FeatureCollection",
features: input.skiMapSkiAreas,
})
}),
);
fs.writeFileSync(
inputPaths.geoJSON.skiAreas,
JSON.stringify({
type: "FeatureCollection",
features: input.openStreetMapSkiAreas,
})
}),
);
fs.writeFileSync(
inputPaths.osmJSON.skiAreaSites,
JSON.stringify({
elements: input.openStreetMapSkiAreaSites,
})
}),
);
fs.writeFileSync(
inputPaths.geoJSON.lifts,
JSON.stringify({
type: "FeatureCollection",
features: input.lifts,
})
}),
);
fs.writeFileSync(
inputPaths.geoJSON.runs,
JSON.stringify({
type: "FeatureCollection",
features: input.runs,
})
}),
);
}

export function mockFeatureFiles(
skiAreas: SkiAreaFeature[],
lifts: LiftFeature[],
runs: RunFeature[],
intermedatePaths: GeoJSONIntermediatePaths
intermedatePaths: GeoJSONIntermediatePaths,
) {
fs.writeFileSync(
intermedatePaths.skiAreas,
JSON.stringify({
type: "FeatureCollection",
features: skiAreas,
})
}),
);
fs.writeFileSync(
intermedatePaths.lifts,
JSON.stringify({
type: "FeatureCollection",
features: lifts,
})
}),
);
fs.writeFileSync(
intermedatePaths.runs,
JSON.stringify({
type: "FeatureCollection",
features: runs,
})
}),
);
}

Expand Down Expand Up @@ -264,7 +264,7 @@ export function simplifiedLiftFeature(feature: LiftFeature) {
id: feature.properties.id,
name: feature.properties.name,
skiAreas: feature.properties.skiAreas.map(
(skiArea) => skiArea.properties.id
(skiArea) => skiArea.properties.id,
),
};
}
Expand All @@ -274,7 +274,7 @@ export function simplifiedRunFeature(feature: RunFeature) {
id: feature.properties.id,
name: feature.properties.name,
skiAreas: feature.properties.skiAreas.map(
(skiArea) => skiArea.properties.id
(skiArea) => skiArea.properties.id,
),
};
}
Expand All @@ -288,7 +288,7 @@ export function simplifiedSkiAreaFeature(feature: SkiAreaFeature) {
}

export function simplifiedSkiAreaFeatureWithStatistics(
feature: SkiAreaFeature
feature: SkiAreaFeature,
) {
return {
...simplifiedSkiAreaFeature(feature),
Expand Down
Loading

0 comments on commit 6276ad2

Please sign in to comment.