//通过aoi获得位置信息表(2,4) public Ku_LocationEntity GetLocationByAOI(IRepository db, Ku_LocationEntity locationData, GeocodesItem geo, Regeocode regeo, Aois aoi, int isRegeo) { locationData = db.FindList <Ku_LocationEntity>(t => t.RegeoId == aoi.id).FirstOrDefault(); if (locationData != null) { //有此坐标,个数+1 locationData.Count += 1; locationData.Modify(locationData.Id); db.Update <Ku_LocationEntity>(locationData); } else { AddressComponent addressComponent = regeo.addressComponent; double wxLon = 0, wxLat = 0, bdLon = 0, bdLat = 0; GDAPI.getCoordinate(aoi.location, out wxLat, out wxLon, out bdLat, out bdLon); string typeCode, typeName; GetTypeNameByCode(aoi.type, out typeCode, out typeName); //无此坐标,插入pos_location表 locationData = new Ku_LocationEntity() { Address = regeo.formatted_address, Province = addressComponent.province, City = addressComponent.city, CityCode = addressComponent.citycode, District = addressComponent.district, AdCode = addressComponent.adcode, Township = addressComponent.township, Location = aoi.location, wxLon = Convert.ToDecimal(wxLon), wxLat = Convert.ToDecimal(wxLat), bdLon = Convert.ToDecimal(bdLon), bdLat = Convert.ToDecimal(bdLat), _Level = geo.level, IsRegeo = isRegeo, RegeoId = aoi.id, RegeoName = aoi.name, Area = aoi.area,//存在字母转换失败decimal“山东省临沂市平邑县地方镇九间棚” TypeCode = typeCode, TypeName = typeName, Count = 1 }; locationData.Create(); db.Update <Ku_LocationEntity>(locationData); } return(locationData); }
//通过geo获得位置信息表(5) public Ku_LocationEntity GetLocationByGeo(IRepository db, Ku_LocationEntity locationData, GeocodesItem geo, int isRegeo) { //如果aoi取消 locationData = db.FindList <Ku_LocationEntity>(t => t.Location == geo.location).FirstOrDefault(); if (locationData != null) { locationData.Count += 1; locationData.Modify(locationData.Id); db.Update <Ku_LocationEntity>(locationData); } else { //添加POI double wxLon = 0, wxLat = 0, bdLon = 0, bdLat = 0; GDAPI.getCoordinate(geo.location, out wxLat, out wxLon, out bdLat, out bdLon); //无此坐标,插入pos_location表 locationData = new Ku_LocationEntity() { RegeoName = geo.formatted_address.Replace(geo.province, "").Replace(geo.city, "").Replace(geo.district, ""), Address = geo.formatted_address, Province = geo.province, City = geo.city, CityCode = geo.citycode, District = geo.district, AdCode = geo.adcode, Township = geo.township, Location = geo.location, wxLon = Convert.ToDecimal(wxLon), wxLat = Convert.ToDecimal(wxLat), bdLon = Convert.ToDecimal(bdLon), bdLat = Convert.ToDecimal(bdLat), _Level = geo.level, IsRegeo = 0, Count = 1 }; locationData.Create(); db.Insert <Ku_LocationEntity>(locationData); } return(locationData); }