Beispiel #1
0
        /// <summary>
        /// 将全景图按照由近及远排序
        /// </summary>
        /// <param name="lat">定位位置的纬度</param>
        /// <param name="lng">定位位置的经度</param>
        /// <returns></returns>
        public IEnumerable <PanoramaScene> GetAllPanoramaScenesOrderByDistance(double lat = 28.9721214555, double lng = 118.8898357316, int pageSize = 15, int index = 0)
        {
            var query = from ps in _sceneRepository.TableNoTracking
                        where !ps.Deleted
                        select ps;

            var panoramaScenes = query.ToList();

            var panoramaScenesOrderedResult = panoramaScenes
                                              .OrderBy(ps => GeographyHelper.GetDistance(ps.PanoramaLocation.Lat, ps.PanoramaLocation.Lng, lat, lng))
                                              .ThenByDescending(ps => ps.ProductionDate);

            var locationNameList = new List <string>();
            var resultPanomarScenesFilterResult = new List <PanoramaScene>();

            foreach (var scene in panoramaScenesOrderedResult)
            {
                if (locationNameList.Contains(scene.PanoramaLocation.Name))
                {
                    continue;
                }
                else
                {
                    resultPanomarScenesFilterResult.Add(scene);
                    locationNameList.Add(scene.PanoramaLocation.Name);
                }
            }

            var resultPanomarScenesResult = resultPanomarScenesFilterResult.Skip(index * pageSize).Take(pageSize);

            return(resultPanomarScenesResult);
        }
        public IHttpActionResult GetPreviewList(double lat = 28.9721214555, double lng = 118.8898357316, int pageSize = 15, int index = 0)
        {
            var coord  = _sceneService.GetAllPanoramaScenesOrderByDistance(lat, lng, pageSize, index);
            var scenes = coord.ToList().Select(ps =>
            {
                var previewModel        = ps.ToPreviewModel();
                previewModel.Produce    = "衢州市地理信息中心";
                previewModel.ImgPath   += ps.ProductionDate.ToString("yyyyMMdd") + ".tiles";
                previewModel.LocationId = ps.PanoramaLocation.Id;
                previewModel.Lng        = ps.PanoramaLocation.Lng;
                previewModel.Lat        = ps.PanoramaLocation.Lat;
                previewModel.Dist       = Math.Floor(GeographyHelper.GetDistance(ps.PanoramaLocation.Lat, ps.PanoramaLocation.Lng, lat, lng));
                if (previewModel.Dist > 5000)
                {
                    previewModel.Dist = 5000;
                }
                return(previewModel);
            });

            return(Ok(scenes));
        }