/// <summary>
        /// 判断是否有地图匹配
        /// </summary>
        /// <param name="styleID"></param>
        /// <returns></returns>
        public bool GetMapReleationByStyle(string styleID)
        {
            var list = _IMapReleationRepository.GetAll().Where(q => q.DataStyleID == styleID).ToList();

            if (list.Count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#2
0
        public async Task <bool> UpdateMapBBox(string mapID)
        {
            try
            {
                var list = _IMapReleationRepository.GetAll().Where(q => q.MapID == mapID).ToList();
                var map  = _IMapRepository.Get(mapID);
                if (map != null && list != null && list.Count > 0)
                {
                    Dictionary <string, decimal?> bbox = new Dictionary <string, decimal?>();
                    for (int i = 0; i < list.Count; i++)
                    {
                        var layer = _ILayerContentRepository.Get(list[i].DataConfigID);

                        if (i == 0)
                        {
                            bbox.Add("MaxX", layer.MaxX);
                            bbox.Add("MinX", layer.MinX);
                            bbox.Add("MaxY", layer.MaxY);
                            bbox.Add("MinY", layer.MinY);
                        }
                        else
                        {
                            if (layer.MaxX > bbox["MaxX"])
                            {
                                bbox["MaxX"] = layer.MaxX;
                            }
                            if (layer.MaxY > bbox["MaxY"])
                            {
                                bbox["MaxY"] = layer.MaxY;
                            }
                            if (layer.MinX < bbox["MinX"])
                            {
                                bbox["MinX"] = layer.MinX;
                            }
                            if (layer.MinY < bbox["MinY"])
                            {
                                bbox["MinY"] = layer.MinY;
                            }
                        }
                    }
                    map.MaxX = bbox["MaxX"];
                    map.MinX = bbox["MinX"];
                    map.MaxY = bbox["MaxY"];
                    map.MinY = bbox["MinY"];

                    await _IMapRepository.UpdateAsync(map);


                    GeoServerHelper geoHelp     = new GeoServerHelper();
                    string          isAutoCache = ConfigurationManager.AppSettings.Get("IsAutoCache");
                    if (!string.IsNullOrEmpty(isAutoCache) && isAutoCache == "1")
                    {
                        geoHelp.TerminatingTask(map.MapEnName);
                        geoHelp.TileMap(map.MapEnName);
                    }

                    string strBBox = map.MinX.ToString() + "," + map.MinY.ToString() + "," + map.MaxX.ToString() + "," + map.MaxY.ToString();
                    #region [生成缩略图]

                    ThumbnailHelper tbh       = new ThumbnailHelper();
                    string          imagePath = tbh.CreateThumbnail(map.MapEnName, "map", strBBox);

                    if (string.IsNullOrEmpty(imagePath))
                    {
                        return(false);
                    }
                    else
                    {
                        return(true);
                    }

                    #endregion
                }
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }