@@ -64,9 +64,9 @@ export const geoLocSearch = async (lat: number, long: number, bounds: IBounds) =
6464 const populationLimitClause = "city15000" ;
6565 // boundsClause is used if using citiesJSON service
6666 const boundsClause = `north=${ bounds . north } &south=${ bounds . south } &east=${ bounds . east } &west=${ bounds . west } ` ;
67- // const url = `${kGeolocCitiesService}?${[locClause, userClause, boundsClause, maxRowsClause].join("&")}`;
68- const url = `${ kGeolocService } ?${ [ locClause , userClause , maxRowsClause , radiusClause , populationLimitClause ]
69- . join ( "&" ) } `;
67+ const url = `${ kGeolocCitiesService } ?${ [ locClause , userClause , boundsClause , maxRowsClause ] . join ( "&" ) } ` ;
68+ // const url = `${kGeolocService}?${[locClause, userClause, maxRowsClause, radiusClause, populationLimitClause ]
69+ // .join("&") }`;
7070 try {
7171 const response = await fetch ( url ) ;
7272 if ( response . ok ) {
@@ -87,14 +87,14 @@ export const geoLocSearch = async (lat: number, long: number, bounds: IBounds) =
8787 console . log ( "sorted geonames" , JSON . parse ( JSON . stringify ( sortedGeonamesByPopulation ) ) ) ;
8888
8989 // find the nearest location nearest the lat/long. We use the commented out code if using the citiesJSON service
90- // const nearest = findNearestCity(lat, long, data.geonames);
91- const nearest = sortedGeonamesByPopulation [ 0 ] ;
90+ const nearest = findNearestCity ( lat , long , data . geonames ) ;
91+ // const nearest = sortedGeonamesByPopulation[0];
9292 console . log ( "nearest location" , JSON . parse ( JSON . stringify ( nearest ) ) ) ;
9393 return nearest
94- ? { success : true , values : { location :`${ nearest . name } , ${ nearest . adminCode1 } ` } }
94+ // ? {success: true, values: {location:`${nearest.name}, ${nearest.adminCode1}`}}
9595 // Return this value if using the citiesJSON service.
9696 // citiesJSON service does not have adminCode1 (state name), se we use countrycode
97- // ? {success: true, values: {location:`${nearest.name}, ${nearest.countrycode}`}}
97+ ? { success : true , values : { location :`${ nearest . name } , ${ nearest . countrycode } ` } }
9898 : { success : false , values : { location : "Unknown Location" } } ;
9999 } else {
100100 return Promise . reject ( response . statusText ) ;
0 commit comments