Search in sources :

Example 1 with Distance

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;
}
Also used : ResultImpl(ddf.catalog.data.impl.ResultImpl) Distance(ddf.measure.Distance)

Aggregations

ResultImpl (ddf.catalog.data.impl.ResultImpl)1 Distance (ddf.measure.Distance)1