/// <summary> /// 以地址/地標取得 google map 地理編碼資訊 /// </summary> /// <param name="parameter">GeoLocationParameter</param> /// <returns>GoogleResponse</returns> public Infrastructure.ClassLibsProxy.Models.GoogleResponse GetGeocoding(GeoLocationParameterDto parameter) { var result = new Infrastructure.ClassLibsProxy.Models.GoogleResponse(); using (var googleGeoCoding = new uGIS.GoogleGeocoder(parameter.GeoKey)) { uGIS.GoogleResponse responseColletions = googleGeoCoding.Geocoding(parameter.Address); var mapConfig = new AutoMapper.MapperConfiguration(cfg => { cfg.CreateMap<uGIS.GoogleResponse.LocateStatus, Enums.GoogleLocateStatus>(); cfg.CreateMap<uGIS.GoogleLocate, Infrastructure.ClassLibsProxy.Models.GoogleLocate>(); cfg.CreateMap<uGIS.GoogleResponse, Infrastructure.ClassLibsProxy.Models.GoogleResponse>(); }); var mapper = mapConfig.CreateMapper(); result = mapper.Map<uGIS.GoogleResponse, Infrastructure.ClassLibsProxy.Models.GoogleResponse>(responseColletions); } return result; }
/// <summary> /// 以地址/地標取得 google map 地理編碼資訊 /// </summary> /// <param name="parameter">地理位置參數Dto</param> /// <returns>GoogleGeoDataDto</returns> public GoogleGeoDataDto GetGeocoding(GeoLocationParameterDto parameter) { var result = new GoogleGeoDataDto(); var responseColletions = this.GisProxy.GetGeocoding(parameter); if (responseColletions.Status.Equals(GoogleLocateStatus.Success)) { var mapConfig = new AutoMapper.MapperConfiguration(cfg => { cfg.CreateMap<Infrastructure.ClassLibsProxy.Models.GoogleLocate, GoogleLocateDto>() .ForMember(d => d.County, o => o.MapFrom(s => s.City)) .ForMember(d => d.District, o => o.MapFrom(s => s.Area)) .ForMember(d => d.IsPrecise, o => o.MapFrom(s => s.PreciseLevel)); cfg.CreateMap<Infrastructure.ClassLibsProxy.Models.GoogleResponse, GoogleGeoDataDto>(); }); var mapper = mapConfig.CreateMapper(); result = mapper.Map<Infrastructure.ClassLibsProxy.Models.GoogleResponse, GoogleGeoDataDto>(responseColletions); } return result; }