Skip to content

Commit

Permalink
very minor tweaks to the conflation algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
k-yle committed Feb 28, 2024
1 parent 5844222 commit 2bcb549
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/stage2-preprocess/preprocessNZGB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type TempObject = {

// these transformations must be kept to a bare minimum
const transformName = (_nzgbName: string, type: NameType) => {
let nzgbName = _nzgbName.replace(/ pa$/i, ' Pā');
let nzgbName = _nzgbName.trim().replace(/ pa$/i, ' Pā');

// for train stations, OSM doesn't include the suffix in the name
if (type === 'Railway Station') {
Expand All @@ -59,6 +59,9 @@ async function csvToTemp(): Promise<{ out: TempObject; ety: EtymologyReport }> {
if (!(index % 1000)) process.stdout.write('.');
index += 1;

// "Discontinued" don't exist or completely irrelevant
if (data.status.endsWith('Discontinued')) return;

/** cause of the BOM character at the start of the csv file we do this */
const ref = +(data.name_id || data['\uFEFFname_id' as 'name_id']);

Expand Down
4 changes: 3 additions & 1 deletion src/stage3-conflate/compareFeatures/compareFeatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ export function compareFeatures(
const threshold =
osm.osmId[0] === 'n'
? DISTANCE_APART_THRESHOLD_NODE
: DISTANCE_APART_THRESHOLD_AREA;
: osm.osmId[0] === 'w'
? DISTANCE_APART_THRESHOLD_AREA
: Infinity; // relations are not checked for distance
if (metresAway > threshold && !DONT_TRY_TO_MOVE.has(nzgb.type)) {
tagChanges.__action = 'move';
}
Expand Down
4 changes: 2 additions & 2 deletions src/stage3-conflate/getPresetTags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ export function getPresetTags(place: NZGBFeature): {
return {
all: preset.subseaTags,
match: preset.subseaTags,
acceptTags: preset.acceptTags,
acceptTags: [...(preset.acceptTags || []), preset.onLandTags],
};
}
return {
all: preset.onLandTags,
match: preset.onLandTags,
acceptTags: preset.acceptTags,
acceptTags: [...(preset.acceptTags || []), preset.subseaTags],
};
}

0 comments on commit 2bcb549

Please sign in to comment.