地址标准化城市解析以地址为准,匹配接口城市以输入为准
This commit is contained in:
+4
-3
@@ -167,7 +167,7 @@ public class AddressParserServiceImpl implements AddressParserService {
|
|||||||
Building matchedBuilding;
|
Building matchedBuilding;
|
||||||
//keywords使用aliyun接口返回的poi
|
//keywords使用aliyun接口返回的poi
|
||||||
AliyunBo aliyunBo = null;
|
AliyunBo aliyunBo = null;
|
||||||
if(params.isUseAliyunApi()){
|
if(params.isUseAliyunApi() && AddressParserGoal.Match.equals(addr.getAddressParserGoal())){
|
||||||
aliyunBo = aliyunService.addressStand(params.getAddress(), params.getCity());
|
aliyunBo = aliyunService.addressStand(params.getAddress(), params.getCity());
|
||||||
if(aliyunBo != null){
|
if(aliyunBo != null){
|
||||||
String poi = ((aliyunBo.getPoi() == null ? "":aliyunBo.getPoi()) + (aliyunBo.getSubpoi() == null ? "":aliyunBo.getSubpoi())).replaceAll("\\s*", "");
|
String poi = ((aliyunBo.getPoi() == null ? "":aliyunBo.getPoi()) + (aliyunBo.getSubpoi() == null ? "":aliyunBo.getSubpoi())).replaceAll("\\s*", "");
|
||||||
@@ -201,11 +201,11 @@ public class AddressParserServiceImpl implements AddressParserService {
|
|||||||
matchedBuilding.setSearchAddress(addr);
|
matchedBuilding.setSearchAddress(addr);
|
||||||
matchedBuilding.setSuggestName(getSuggestName(matchedBuilding));
|
matchedBuilding.setSuggestName(getSuggestName(matchedBuilding));
|
||||||
matchedBuilding.setSuggestAddress(getSuggestAddress(matchedBuilding));
|
matchedBuilding.setSuggestAddress(getSuggestAddress(matchedBuilding));
|
||||||
if(params.isUseAliyunApi() && aliyunBo != null){
|
if(params.isUseAliyunApi() && aliyunBo != null && AddressParserGoal.Match.equals(addr.getAddressParserGoal())){
|
||||||
completBuildingField(matchedBuilding, aliyunBo, params);
|
completBuildingField(matchedBuilding, aliyunBo, params);
|
||||||
}
|
}
|
||||||
Address tempAddr = matchedBuilding.getSearchAddress();
|
Address tempAddr = matchedBuilding.getSearchAddress();
|
||||||
if(StringUtils.isBlank(tempAddr.getProvince()) || StringUtils.isBlank(tempAddr.getCity()) || StringUtils.isBlank(tempAddr.getDistrict())|| StringUtils.isBlank(tempAddr.getStreet())){
|
if((StringUtils.isBlank(tempAddr.getProvince()) || StringUtils.isBlank(tempAddr.getCity()) || StringUtils.isBlank(tempAddr.getDistrict())|| StringUtils.isBlank(tempAddr.getStreet())) && AddressParserGoal.Match.equals(addr.getAddressParserGoal())){
|
||||||
// List<AddressMatchMetaData> metaDatas = addressRepoService.findAllByKeyword(null, params.getBuildingType(), new ArrayList<String>() {{add(tempAddr.getOrgAddress());}}, tempAddr.getLng(), tempAddr.getLat(), 100, false);
|
// List<AddressMatchMetaData> metaDatas = addressRepoService.findAllByKeyword(null, params.getBuildingType(), new ArrayList<String>() {{add(tempAddr.getOrgAddress());}}, tempAddr.getLng(), tempAddr.getLat(), 100, false);
|
||||||
tempAddr.addKeyword(tempAddr.getOrgAddress());
|
tempAddr.addKeyword(tempAddr.getOrgAddress());
|
||||||
List<AddressMatchMetaData> metaDatas = findMatchMetaData(tempAddr, params.getBuildingType(), MetaDataType.MAP, false);
|
List<AddressMatchMetaData> metaDatas = findMatchMetaData(tempAddr, params.getBuildingType(), MetaDataType.MAP, false);
|
||||||
@@ -385,6 +385,7 @@ public class AddressParserServiceImpl implements AddressParserService {
|
|||||||
addr.setSuggestDistrict(params.getSuggestDistrict());
|
addr.setSuggestDistrict(params.getSuggestDistrict());
|
||||||
addr.setSuggestName(params.getSuggestName());
|
addr.setSuggestName(params.getSuggestName());
|
||||||
addr.setPreciseLevel(params.getPreciseLevel());
|
addr.setPreciseLevel(params.getPreciseLevel());
|
||||||
|
addr.setAddressParserGoal(params.getAddressParserGoal());
|
||||||
addr.setProvince(params.getProvince());
|
addr.setProvince(params.getProvince());
|
||||||
addr.setDebugName(params.getDebugName());
|
addr.setDebugName(params.getDebugName());
|
||||||
return AddressProcessors.process(addr);
|
return AddressProcessors.process(addr);
|
||||||
|
|||||||
@@ -78,6 +78,16 @@ public class Address {
|
|||||||
|
|
||||||
private AliyunBo aliyunBo;
|
private AliyunBo aliyunBo;
|
||||||
|
|
||||||
|
public AddressParserGoal getAddressParserGoal() {
|
||||||
|
return addressParserGoal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAddressParserGoal(AddressParserGoal addressParserGoal) {
|
||||||
|
this.addressParserGoal = addressParserGoal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**地址解析目的*/
|
||||||
|
private AddressParserGoal addressParserGoal;
|
||||||
public AliyunBo getAliyunBo() {
|
public AliyunBo getAliyunBo() {
|
||||||
return aliyunBo;
|
return aliyunBo;
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -52,8 +52,8 @@ public class CityProcessor extends AbstractAddressProcessor {
|
|||||||
}
|
}
|
||||||
if(StringUtils.isNotBlank(city) && CityStatus.SURE != address.getCityStatus() ){
|
if(StringUtils.isNotBlank(city) && CityStatus.SURE != address.getCityStatus() ){
|
||||||
String formatCity = RegionData.formatCity(city);
|
String formatCity = RegionData.formatCity(city);
|
||||||
String possibleCity = parseCityFromAddress(orgAddress, address);
|
String possibleCity = AddressParserGoal.Match.equals(address.getAddressParserGoal()) ? parseCityFromAddress(orgAddress, address) : null;
|
||||||
String confirmCity = null;
|
String confirmCity = AddressParserGoal.Match.equals(address.getAddressParserGoal()) ? null : formatCity;
|
||||||
/**如果省份和城市信息相互矛盾 则用区域推断城市*/
|
/**如果省份和城市信息相互矛盾 则用区域推断城市*/
|
||||||
if(StringUtils.isNotBlank(address.getProvince()) && !ProvinceData.belongTo(formatCity, address.getProvince())){
|
if(StringUtils.isNotBlank(address.getProvince()) && !ProvinceData.belongTo(formatCity, address.getProvince())){
|
||||||
List<String> possibleCities = speculateCityNameByRegion(address, city);
|
List<String> possibleCities = speculateCityNameByRegion(address, city);
|
||||||
@@ -62,7 +62,7 @@ public class CityProcessor extends AbstractAddressProcessor {
|
|||||||
confirmCity = formatCity;
|
confirmCity = formatCity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(formatCity == null || !formatCity.equals(possibleCity)){
|
if(AddressParserGoal.Match.equals(address.getAddressParserGoal()) && (formatCity == null || (possibleCity!=null && !formatCity.equals(possibleCity)))){
|
||||||
confirmCity = possibleCity;
|
confirmCity = possibleCity;
|
||||||
}
|
}
|
||||||
if(null != confirmCity){
|
if(null != confirmCity){
|
||||||
|
|||||||
+3
-2
@@ -2,6 +2,7 @@ package com.fangjia.service.address.processor;
|
|||||||
|
|
||||||
import com.fangjia.core.RegionData;
|
import com.fangjia.core.RegionData;
|
||||||
import com.fangjia.service.address.mode.Address;
|
import com.fangjia.service.address.mode.Address;
|
||||||
|
import com.fangjia.service.address.mode.AddressParserGoal;
|
||||||
import com.fangjia.service.address.mode.CityStatus;
|
import com.fangjia.service.address.mode.CityStatus;
|
||||||
import com.fangjia.service.address.mode.ProvinceData;
|
import com.fangjia.service.address.mode.ProvinceData;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
@@ -24,9 +25,9 @@ public class ProvinceProcessor extends AbstractAddressProcessor {
|
|||||||
|
|
||||||
String orgAddress = address.getAddress();
|
String orgAddress = address.getAddress();
|
||||||
String[] provinceInfo = getProvince(orgAddress);
|
String[] provinceInfo = getProvince(orgAddress);
|
||||||
/*if(provinceInfo == null && address.getCity() != null){
|
if(provinceInfo == null && address.getCity() != null && !AddressParserGoal.Match.equals(address.getAddressParserGoal())){
|
||||||
provinceInfo = getProvince(address.getCity());
|
provinceInfo = getProvince(address.getCity());
|
||||||
}*/
|
}
|
||||||
if (null != provinceInfo) {
|
if (null != provinceInfo) {
|
||||||
String province = provinceInfo[NAME_IDX];
|
String province = provinceInfo[NAME_IDX];
|
||||||
if (provinceInfo[FULL_NAME_IDX] != null) {//全称匹配
|
if (provinceInfo[FULL_NAME_IDX] != null) {//全称匹配
|
||||||
|
|||||||
Reference in New Issue
Block a user