class GeonamesGeocoderService implements GeocoderService {

	public GetLocationResult[] getLocation(List<String> location, int maxAlternatives, Locale ignore) {
		GetLocationResult[] result;
		try {
			/* code for using the geonames library, does not support fuzzy or isNameRequired
			ToponymSearchCriteria criteria = new ToponymSearchCriteria();
			criteria.setQ(splitCommaReverseService.combine(location));
			criteria.setMaxRows(MAX_ROWS + 1);
			//criteria.setNameRequired(true);
			//criteria.setFuzzy(FUZZY_VALUE);
			GetLocationResult result = null;
			List<Toponym> toponyms = search(splitCommaReverseService.combine(location), MAX_ROWS + 1, false);
			List<Toponym> toponyms = tsr.getToponyms();
			*/
			List<Toponym> toponyms = search(splitCommaReverseService.combine(location), maxAlternatives, false);
			int resCount = toponyms.size();
			/*
			- original plan was to search one more than maximum and don't return results is too many as too ambiguous
			- but that doesn't work from straightforward queries like "london"
			if (resCount > MAX_ROWS) {
				// too many results, treat as not found
				return null;
			}
			*/

			if (0 == resCount) {
				// try fuzzy search when no results
				toponyms = search(splitCommaReverseService.combine(location), maxAlternatives, true);
			}

			// remove duplicates from the results (eg because featureClass is different)
			removeDuplicates(toponyms);
			resCount = toponyms.size();

			result = new GetLocationResult[resCount];
			for (int i = 0; i < resCount; i++) {
				Toponym toponym = toponyms.get(i);
				GetLocationResult one = new GetLocationResult();
				List<String> prefResult = new ArrayList<String>();
				prefResult.add(toponym.getCountryCode());
				prefResult.add(toponym.getName());
				one.setCanonicalStrings(prefResult);
				Coordinate coordinate = new Coordinate();
				coordinate.x = toponym.getLongitude();
				coordinate.y = toponym.getLatitude();
				one.setCoordinate(coordinate);
				result[i] = one;
			}
			return result;
		} catch (Exception ex) { // NOSONAR
			log.error("Search failed", ex);
			return null;
		}
	}

}