Double latitude = requestDTO.getLatitude();
Double longitude = requestDTO.getLongitude();
String countryId = requestDTO.getCountryId();
String status = requestDTO.getStatusOfILM();
Point point = new Point(longitude, latitude);
String geoSpatialQueryForLine = "{countryId:'" + countryId + "'},{ilmState:'" + status + "'}";
Query query = new BasicQuery(geoSpatialQueryForLine);
List<AggregationOperation> list = new ArrayList<>();
NearQuery nearQuery = NearQuery.near(point).query(query).maxDistance(distance).minDistance(0).spherical(true);
list.add(Aggregation.geoNear(nearQuery, RestServiceConfig.SITE_TO_LINE_DISTANCE));
list.add(Aggregation.project(RestServiceConfig.ID_KEY, RestServiceConfig.SITE_TO_LINE_DISTANCE));
TypedAggregation<TariffLineDocument> agg = new TypedAggregation<>(TariffLineDocument.class, list);
List<TariffLineDocument> result = mongoOperations.aggregate(agg, TariffLineDocument.class).getMappedResults();
for (TariffLineDocument document : result) {
TariffDocument tariffDocument = TariffDocument.builder()
.tariffLayerId(document.getId())
.layerType(RestServiceConfig.LINE)
.siteToLineDistance(document.getSiteToLineDistance())
.build();
documentList.add(tariffDocument);
}
logger.info(RestServiceConfig.NUMBER_OF_LINE_SHAPES, documentList.size());
} catch (Exception exception) {
logger.info(RestServiceConfig.ERROR_IN_METHOD, exception.getMessage());
}
return documentList;
This is my Java code. Here, sitetoline is returning as "siteToLineDistance": 0.004334109519106326, so all the documents have sitetoline within this range. As maxdistance is 200, every document is fetched. I want to only fetch documents which is in maxdistance range, i.e. 200 and I don't know what sitetolinedistance is in km/meters.
In what measures it is returning the sitetolinedistance like meters, km, miles, etc?
Output:
