use of ddf.measure.Distance in project ddf by codice.
the class SolrMetacardClientImpl method createResult.
private ResultImpl createResult(SolrDocument doc) throws MetacardCreationException {
ResultImpl result = new ResultImpl(createMetacard(doc));
if (doc.get(RELEVANCE_SORT_FIELD) != null) {
result.setRelevanceScore(((Float) (doc.get(RELEVANCE_SORT_FIELD))).doubleValue());
}
if (doc.get(DISTANCE_SORT_FIELD) != null) {
Object distance = doc.getFieldValue(DISTANCE_SORT_FIELD);
if (distance != null) {
LOGGER.debug("Distance returned from Solr [{}]", distance);
double convertedDistance = new Distance(Double.valueOf(distance.toString()), Distance.LinearUnit.KILOMETER).getAs(Distance.LinearUnit.METER);
result.setDistanceInMeters(convertedDistance);
}
}
return result;
}
Aggregations