Skip to content

Commit

Permalink
separate house and street
Browse files Browse the repository at this point in the history
return field house not housenumber
  • Loading branch information
Natalia Kowalczyk committed Feb 11, 2024
1 parent c457e22 commit a7ab4dc
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 25 deletions.
2 changes: 1 addition & 1 deletion lib/service/geocodio/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function map(f) {
const place = {
ll: [location.lng, location.lat],
place: f.name,
housenumber: address.number,
house: address.number,
street: address.street,
town: address.city,
county: address.county,
Expand Down
2 changes: 1 addition & 1 deletion lib/service/graphhopper/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function map(f) {
const place = {
ll: [f.point.lng, f.point.lat],
type: f.osm_value,
housenumber: f.housenumber,
house: f.housenumber,
street: f.street,
town: f.city,
province: normalize.state(f.state),
Expand Down
4 changes: 1 addition & 3 deletions lib/service/locationiq/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,13 @@ function map(f) {

const place = {
ll: [parseFloat(f.lon), parseFloat(f.lat)],
house: a.house_number,
street: a.road || a.pedestrian,
town: a.city,
province: normalize.state(a.state),
country: normalize.country(a.country)
};

if (a.house_number && place.street) {
place.street = [a.house_number, place.street].join(' ');
}
place.address = util.address(place);
if (f.display_name) {
place.place = f.display_name.split(',')[0];
Expand Down
4 changes: 1 addition & 3 deletions lib/service/pelias/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,13 @@ function map(f) {
const place = {
ll: f.geometry.coordinates,
type: p.layer,
house: p.housenumber,
street: p.street,
town: p.locality,
county: p.county,
province: normalize.state(p.region),
country: normalize.country(p.country)
};
if (p.housenumber && place.street) {
place.street = [p.housenumber, place.street].join(' ');
}
if (place.type === 'venue') {
place.place = p.name;
if (query.type) {
Expand Down
2 changes: 1 addition & 1 deletion lib/service/positionstack/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function map(f) {
const place = {
ll: [f.longitude, f.latitude],
type: f.type,
housenumber: f.number,
house: f.number,
street: f.street,
town: guessCity(f),
province: f.region_code,
Expand Down
9 changes: 6 additions & 3 deletions lib/service/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ function defaults(obj, source) {
}

function address(place) {
return [place.street, place.town || place.county, place.province, place.country]
.filter(function (s) { return s; })
.join(', ');
return [
[place.house, place.street].filter(Boolean).join(' '),
place.town || place.county,
place.province,
place.country
].filter(Boolean).join(', ');
}

function removeEmpties(place) {
Expand Down
2 changes: 1 addition & 1 deletion test/service/geocodio/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('geocodio geocoding', function () {
result.places[0].should.deepEqual({
ll: [-111.400596, 45.284265],
address: '50 Big Sky Resort Rd, Big Sky, MT 59716',
housenumber: '50',
house: '50',
street: 'Big Sky Resort',
county: 'Madison County',
province: 'MT',
Expand Down
8 changes: 4 additions & 4 deletions test/service/graphhopper/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ describe('graphhopper geocoding', function () {
result.places[2].should.deepEqual({
ll: [-71.086670478147, 42.36274665],
type: 'construction',
housenumber: '325',
house: '325',
street: 'Main Street',
town: 'Cambridge',
province: 'MA',
country: 'USA',
place: '325 Main Street',
address: 'Main Street, Cambridge, MA, USA'
address: '325 Main Street, Cambridge, MA, USA'
});
result.places[3].should.deepEqual({
ll: [-71.6192199, 42.5524712],
Expand Down Expand Up @@ -141,13 +141,13 @@ describe('graphhopper geocoding', function () {
result.places[1].should.deepEqual({
ll: [-111.4011158, 45.2839783],
type: 'sports_centre',
housenumber: '50',
house: '50',
street: 'Big Sky Resort Road',
town: 'Big Sky',
province: 'MT',
country: 'USA',
place: 'Big Sky Resort',
address: 'Big Sky Resort Road, Big Sky, MT, USA'
address: '50 Big Sky Resort Road, Big Sky, MT, USA'
});
result.places[2].should.deepEqual({
ll: [-111.40110501870444, 45.284622],
Expand Down
12 changes: 8 additions & 4 deletions test/service/locationiq/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ describe('locationiq geocoding', function () {
type: 'restaurant',
ll: [-73.9904326, 40.7442736],
address: '30 West 26th Street, New York, NY, USA',
street: '30 West 26th Street',
house: '30',
street: 'West 26th Street',
town: 'New York',
province: 'NY',
country: 'USA'
Expand All @@ -77,7 +78,8 @@ describe('locationiq geocoding', function () {
type: 'disused',
ll: [-73.9903515, 40.7442363],
address: '30 West 26th Street, New York, NY, USA',
street: '30 West 26th Street',
house: '30',
street: 'West 26th Street',
town: 'New York',
province: 'NY',
country: 'USA'
Expand All @@ -87,7 +89,8 @@ describe('locationiq geocoding', function () {
type: 'company',
ll: [-73.9903727, 40.7442104],
address: '30 West 26th Street, New York, NY, USA',
street: '30 West 26th Street',
house: '30',
street: 'West 26th Street',
town: 'New York',
province: 'NY',
country: 'USA'
Expand Down Expand Up @@ -131,7 +134,8 @@ describe('locationiq geocoding', function () {
type: 'house_number',
ll: [-104.999354, 39.676536],
address: '2200 South Jason Street, Denver, CO, USA',
street: '2200 South Jason Street',
house: '2200',
street: 'South Jason Street',
town: 'Denver',
province: 'CO',
country: 'USA'
Expand Down
12 changes: 8 additions & 4 deletions test/service/pelias/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ describe('pelias geocoding', function () {
place: 'Quality Suites Moab Near Arches National Park',
url: 'https://www.openstreetmap.org/way/130513576',
type: 'venue',
street: '800 South Main Street',
house: '800',
street: 'South Main Street',
town: 'Moab',
county: 'Grand County',
province: 'UT',
Expand Down Expand Up @@ -142,7 +143,8 @@ describe('pelias geocoding', function () {
url: 'https://www.openstreetmap.org/node/10238187804',
type: 'restaurant',
address: '7221 West Ray Road, Chandler, AZ, USA',
street: '7221 West Ray Road',
house: '7221',
street: 'West Ray Road',
town: 'Chandler',
county: 'Maricopa County',
province: 'AZ',
Expand Down Expand Up @@ -200,7 +202,8 @@ describe('pelias geocoding', function () {
address: '3253 Meridian, Mammoth Lakes, CA, USA',
place: 'The Summit',
url: 'https://www.openstreetmap.org/way/42188373',
street: '3253 Meridian',
house: '3253',
street: 'Meridian',
town: 'Mammoth Lakes',
county: 'Mono County',
province: 'CA',
Expand All @@ -210,7 +213,8 @@ describe('pelias geocoding', function () {
ll: [-118.983976, 37.63619],
type: 'address',
address: '3253 Meridian, Mammoth Lakes, CA, USA',
street: '3253 Meridian',
house: '3253',
street: 'Meridian',
town: 'Mammoth Lakes',
county: 'Mono County',
province: 'CA',
Expand Down

0 comments on commit a7ab4dc

Please sign in to comment.