Skip to content

Commit ebd37e7

Browse files
committed
Filters out locations with 0 population
Increases maxRows and radius in queries BUG: still does not filter out neighborhoods when what we want is the city name (Southside, and Northside, instead of Chicago)
1 parent f75cd36 commit ebd37e7

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/utils/location-utils.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ export const geoLocSearch = async (lat: number, long: number, bounds: IBounds) =
5858
const userClause = `username=${kGeonamesUser}`;
5959
const locClause = `lat=${lat}&lng=${long}`;
6060
const boundsClause = `north=${bounds.north}&south=${bounds.south}&east=${bounds.east}&west=${bounds.west}`;
61-
const maxRowsClause = `maxRows=20`;
62-
const radiusClause = `radius=10`;
61+
const maxRowsClause = `maxRows=50`;
62+
const radiusClause = `radius=25`;
6363
const populationLimitClause = "city15000";
6464
// const url = `${kGeolocCitiesService}?${[locClause, userClause, boundsClause, maxRowsClause].join("&")}`;
6565
const url = `${kGeolocService}?${[locClause, userClause, maxRowsClause, radiusClause, populationLimitClause ]
@@ -68,7 +68,10 @@ export const geoLocSearch = async (lat: number, long: number, bounds: IBounds) =
6868
const response = await fetch(url);
6969
if (response.ok) {
7070
const data = await response.json();
71-
const geonames = data.geonames;
71+
// filter out geonames where population is 0
72+
const geonames = data.geonames.filter((geoname: any) => {
73+
return geoname.population > 0;
74+
});
7275
console.log("GeoLocSearch geonames", JSON.parse(JSON.stringify(geonames)));
7376
console.log("data size", geonames.length);
7477
const sortedGeonamesByPopulation = geonames.sort((a: any, b: any) => {

0 commit comments

Comments
 (0)