class TypeCoordinateService implements GeocoderService {

	@Override
	public GetLocationResult[] getLocation(List<String> location, int maxAlternatives, Locale locale) {
		if (null == locale) {
			locale = Locale.US;
		}
		GetLocationResult result = new GetLocationResult();
		if (location.size() > 0) {
			String[] parts = location.get(0).split("\\s+");
			if (parts.length >= 2) {
				NumberFormat format = NumberFormat.getInstance(locale);
				try {
					Double x = format.parse(parts[0]).doubleValue();
					Double y = format.parse(parts[1]).doubleValue();
					Coordinate coordinate = new Coordinate(x, y);

					String canonicalCrs = "";
					if (parts.length > 2) {
						String crsPart = parts[2];
						if (crsPart.startsWith(CRS_PREFIX)) {
							crsPart = crsPart.substring(CRS_PREFIX.length());
							try {
								coordinate = geoService.transform(coordinate, crsPart, defaultCrs);
								canonicalCrs = " " + CRS_PREFIX + crsPart;
							} catch (GeomajasException le) {
								log.debug("Crs conversion from " + crsPart + " tot " + defaultCrs + " failed, " +
										le.getMessage());
							}
						}
					}
					result.setCoordinate(coordinate);
					List<String> canonical = new ArrayList<String>();
					canonical.add(parts[0] + " " + parts[1] + canonicalCrs);
					result.setCanonicalStrings(canonical);
					return new GetLocationResult[] { result };
				} catch (ParseException pe) {
					log.debug("Could not parse " + location.get(0) + ", " + pe.getMessage());
				}
			}
		}
		return new GetLocationResult[0];
	}

}