...
|
...
|
@@ -4,10 +4,15 @@ import com.alibaba.fastjson.JSONObject; |
|
|
import com.yoho.search.dal.StoreMapper;
|
|
|
import com.yoho.search.dal.model.Store;
|
|
|
import com.yohomars.search.index.builder.IIndexBuilder;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.*;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.LinkedHashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* Created by wangnan on 2016/8/25.
|
...
|
...
|
@@ -15,6 +20,8 @@ import java.util.*; |
|
|
@Component
|
|
|
public class StoreIndexBuilder extends IIndexBuilder {
|
|
|
|
|
|
private static Logger logger = LoggerFactory.getLogger(StoreIndexBuilder.class);
|
|
|
|
|
|
@Autowired
|
|
|
private StoreMapper storeMapper;
|
|
|
|
...
|
...
|
@@ -71,8 +78,19 @@ public class StoreIndexBuilder extends IIndexBuilder { |
|
|
|
|
|
//拼装地理位置信息
|
|
|
List<Double> locationList = new ArrayList<>();
|
|
|
locationList.add(Double.valueOf(store.getLongitude()));
|
|
|
locationList.add(Double.valueOf(store.getLatitude()));
|
|
|
//经纬度值校验,不合法的店铺经纬度赋默认值
|
|
|
if(store.getLongitude()>180||store.getLongitude()<-180){
|
|
|
locationList.add(new Double(0));
|
|
|
logger.warn("Illegal Longitude with store,[id={}]",store.getId());
|
|
|
}else{
|
|
|
locationList.add(Double.valueOf(store.getLongitude()));
|
|
|
}
|
|
|
if(store.getLatitude()>90||store.getLatitude()<-90){
|
|
|
locationList.add(new Double(0));
|
|
|
logger.warn("Illegal Latitude with store,[id={}]",store.getId());
|
|
|
}else{
|
|
|
locationList.add(Double.valueOf(store.getLatitude()));
|
|
|
}
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("location", locationList);
|
|
|
map.put("pin", jsonObject);
|
...
|
...
|
|