how to compare fields with two List?

Viewed 40

"For example, I have multiple latitude and longitude. I got Multiple cities From API. I need the same City for the same latitude and longitude. but I don't understand how to achieve it?

// Converting KML document into List Java object List // Skip the filling city in GTPointsUploadResponseBean.fields.city List result = parseKml(kml);

    // Create  List<SingleNearestCityBean> SingleNearestCityDTOList  from List<GTPointsUploadResponseBean> result
    // Call List<SingleNearestCityBean> batchSingleCities = getSingleNearestCity(String username,List<SingleNearestCityBean> SingleNearestCityDTOList);
    // 
    // Fill GTPointsUploadResponseBean.fields.city from batchSingleCities
    // Said : You require a function/logic to find out the city by lat/lng
    //
    
    List<SingleNearestCityBean> SingleNearestCityBeanList = new ArrayList<SingleNearestCityBean>();

    SingleNearestCityBean singleNearestCityBean = null;
    for (GTPointsUploadResponseBean singleResult:result) {
        singleNearestCityBean = new SingleNearestCityBean();
        //Converted String value of latitude and longitude To Double Value
        double latitudeDoubleValue = Double.valueOf(singleResult.getFields().getLatitude().getValue());
        double longitudeDoubleValue = Double.valueOf(singleResult.getFields().getLongitude().getValue());

        singleNearestCityBean.setLatitude(latitudeDoubleValue);
        singleNearestCityBean.setLongitude(longitudeDoubleValue);
        SingleNearestCityBeanList.add(singleNearestCityBean);
    }
    if (logger.isTraceEnabled()) logger.trace("build() SingleNearestCityBeanList size: {}", SingleNearestCityBeanList.size());

    NearestCityService nearestCityService = SpringContext.getBean(NearestCityServiceImpl.class);
    if (logger.isDebugEnabled()) logger.debug("SpringContext called with nearestCityService: {}", nearestCityService);
    
    List<SingleNearestCityBean> batchSingleCities = nearestCityService.getSingleNearestCity(
            username, 
            SingleNearestCityBeanList);
    if (logger.isTraceEnabled()) logger.trace("build() SingleNearestCityBeanList size: {}", SingleNearestCityBeanList.size());
    
// i need to get city with result how to get guys
    
    if (logger.isDebugEnabled()) logger.debug("build() returning result size: {}", result.size());
    return result;
}

"

0 Answers
Related