コード例 #1
0
        /// <summary>
        /// 以 google map 地理編碼資訊取得地址/地標
        /// </summary>
        /// <param name="parameter">GeoCodingParameterDto</param>
        /// <returns>GoogleResponse</returns>
        public Infrastructure.ClassLibsProxy.Models.GoogleResponse ReverseGeocoding(GeoCodingParameterDto parameter)
        {
            var result = new Infrastructure.ClassLibsProxy.Models.GoogleResponse();

            using (var googleGeoCoding = new uGIS.GoogleGeocoder(parameter.GeoKey))
            {
                uGIS.GoogleResponse responseColletions = googleGeoCoding.ReverseGeocoding(parameter.Latitude, parameter.Longitude);

                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;
        }
コード例 #2
0
        /// <summary>
        /// 以 google map 地理編碼資訊取得地址/地標
        /// </summary>
        /// <param name="parameter">地理編碼參數Dto</param>
        /// <returns>GoogleGeoDataDto</returns>
        public GoogleGeoDataDto ReverseGeocoding(GeoCodingParameterDto parameter)
        {
            var result = new GoogleGeoDataDto();

            var responseColletions = this.GisProxy.ReverseGeocoding(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;
        }