|
- String ksql = "select DE_ServiceDealer.* from DE_ServiceDealer DE_ServiceDealer where 1=1 " + typeFilter + gradeFilter + cityFilter + keywordsFilter + selectFilter;
- Table table = KSQL.select(ksql, null, "/dealer/dealer/data", null);
- //table增加一列“距离”
- table.addColumn("fRange", "Decimal");
- if (table.size() > 0) {
- Iterator<Row> iter = table.iterator();
- while (iter.hasNext()) {
- Row row = iter.next();
- //获取当前行的经度
- BigDecimal fLocation = row.getDecimal("fLongitude");
- //获取当前行的纬度
- BigDecimal fLatitude = row.getDecimal("fLatitude");
-
- if(fLocation != null && fLatitude != null && currentLon != null && currentLat != null){
- // 通过两点的经纬度计算距离
- BigDecimal ra=BigDecimal.valueOf(getDistance(fLocation.doubleValue(),fLatitude.doubleValue(),currentLon.doubleValue(),currentLat.doubleValue()));
- row.setDecimal("fRange", ra.setScale(1, BigDecimal.ROUND_HALF_UP));
- }
- }
- }
复制代码
我先用ksql查出数据到table,然后在table加了一列fRange,然后加入数据,现在想把table根据fRange排序,这个怎么做? |
|