Skip to content

Commit

Permalink
feat(geojson): display unit number in geojson properties (#1603)
Browse files Browse the repository at this point in the history
  • Loading branch information
missinglink authored Feb 11, 2022
1 parent de470ed commit 6aa997d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions helper/geojsonify_place_details.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const field = require('./fieldValue');
// If a property is identified as a single string, assume it should be presented as a string in response
// If something other than string is desired, use the following structure: { name: 'category', type: 'array' }
const DETAILS_PROPS = [
{ name: 'unit', type: 'string' },
{ name: 'housenumber', type: 'string' },
{ name: 'street', type: 'string' },
{ name: 'postalcode', type: 'string' },
Expand Down
1 change: 1 addition & 0 deletions middleware/renamePlacenames.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const _ = require('lodash');
const PARENT_PROPS = require('../helper/placeTypes');

const ADDRESS_PROPS = [
{ name: 'unit', newName: 'unit' },
{ name: 'number', newName: 'housenumber' },
{ name: 'zip', newName: 'postalcode', transform: (value) => { return [value]; } },
{ name: 'street', newName: 'street' }
Expand Down
7 changes: 7 additions & 0 deletions test/unit/helper/geojsonify_place_details.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module.exports.tests = {};
module.exports.tests.geojsonify_place_details = (test, common) => {
test('plain old string values should be copied verbatim, replacing old values', t => {
const source = {
unit: 'unit value',
housenumber: 'housenumber value',
street: 'street value',
postalcode: 'postalcode value',
Expand Down Expand Up @@ -53,6 +54,7 @@ module.exports.tests.geojsonify_place_details = (test, common) => {
};

const expected = {
unit: 'unit value',
housenumber: 'housenumber value',
street: 'street value',
postalcode: 'postalcode value',
Expand Down Expand Up @@ -110,6 +112,7 @@ module.exports.tests.geojsonify_place_details = (test, common) => {
test('\'empty\' string-type values should be output as \'\'', t => {
[ [], {}, '', true, null, undefined ].forEach(empty_value => {
const source = {
unit: empty_value,
housenumber: empty_value,
street: empty_value,
postalcode: empty_value,
Expand Down Expand Up @@ -170,6 +173,7 @@ module.exports.tests.geojsonify_place_details = (test, common) => {

test('source arrays should be copy first value', t => {
const source = {
unit: ['unit value 1', 'unit value 2'],
housenumber: ['housenumber value 1', 'housenumber value 2'],
street: ['street value 1', 'street value 2'],
postalcode: ['postalcode value 1', 'postalcode value 2'],
Expand Down Expand Up @@ -218,6 +222,7 @@ module.exports.tests.geojsonify_place_details = (test, common) => {
};

const expected = {
unit: 'unit value 1',
housenumber: 'housenumber value 1',
street: 'street value 1',
postalcode: 'postalcode value 1',
Expand Down Expand Up @@ -275,6 +280,7 @@ module.exports.tests.geojsonify_place_details = (test, common) => {
test('non-empty objects should be converted to strings', t => {
// THIS TEST SHOWS THAT THE CODE DOES NOT DO WHAT IT EXPECTED
const source = {
unit: { unit: 'unit value'},
housenumber: { housenumber: 'housenumber value'},
street: { street: 'street value'},
postalcode: { postalcode: 'postalcode value'},
Expand Down Expand Up @@ -323,6 +329,7 @@ module.exports.tests.geojsonify_place_details = (test, common) => {
};

const expected = {
unit: '[object Object]',
housenumber: '[object Object]',
street: '[object Object]',
postalcode: '[object Object]',
Expand Down

0 comments on commit 6aa997d

Please sign in to comment.