Created
January 7, 2014 15:07
-
-
Save chriswk/8300648 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private ImmutableList<IPoi> convertResultToPoisG(final String searchKey, final SearchServiceResult result) { | |
return FluentIterable | |
.from(result.getSearchResults().getResultItems()) | |
.transform(new SearchResultToPoiBean(searchKey)) | |
.filter(new MercatorFilter()) | |
.transform(new Function<IadPoiBean, IPoi>() { | |
@Nullable | |
@Override | |
public IPoi apply(@Nullable IadPoiBean input) { | |
return input; | |
} | |
}) | |
.toImmutableList(); | |
} | |
private class SearchResultToPoiBean implements Function<ResultItem, IadPoiBean> { | |
private String searchKey; | |
private SearchResultToPoiBean(String key) { | |
this.searchKey = key; | |
} | |
public IadPoiBean apply(ResultItem resultItem) { | |
PoiType localType = poiConfig.getPoiTypeForSearchKey(searchKey); | |
if (resultItem.getFields().containsKey(PROJECT_FIELD_KEY)) { | |
localType = poiConfig.getPoiType(POI_TYPE_IAD_GROUP); | |
} | |
return new IadPoiBean(resultItem.getFields(), searchKey, Integer.valueOf(localType.getId()), localType); | |
} | |
} | |
private class MercatorFilter implements Predicate<IadPoiBean> { | |
@Override | |
public boolean apply(@Nullable IadPoiBean iPoi) { | |
return !(!iPoi.hasMercatorCoordinates() || Double.valueOf(0.0).equals(iPoi.getLat()) || Double.valueOf(0.0).equals(iPoi.getLng())); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment