public object ToPolygon(CoordinateInfo[][] coordinates)
		{
			if (coordinates.Length == 0)
				return Polygon.Empty;
			return _geometryFactory.CreatePolygon(
				_geometryFactory.CreateLinearRing(coordinates.First().Select(MakeCoordinate).ToArray()),
				coordinates.Skip(1).Select(x => _geometryFactory.CreateLinearRing(x.Select(MakeCoordinate).ToArray())).ToArray()
				);
		}
		public object ToPolygon(CoordinateInfo[][] coordinates)
		{
			if (coordinates.Length == 0)
				return Polygon.Empty;
			return new Polygon(
				new LinearRing(coordinates.First().Select(MakeCoordinate)),
				coordinates.Skip(1).Select(x => new LinearRing(x.Select(MakeCoordinate)))
				);
		}
		private Coordinate MakeCoordinate(CoordinateInfo coordinate)
		{
			if (coordinate.Z.HasValue && coordinate.M.HasValue)
				return new CoordinateZM(coordinate.Y, coordinate.X, coordinate.Z.Value, coordinate.M.Value);
			if (coordinate.Z.HasValue)
				return new CoordinateZ(coordinate.Y, coordinate.X, coordinate.Z.Value);
			if (coordinate.M.HasValue)
				return new CoordinateM(coordinate.Y, coordinate.X, coordinate.M.Value);
			return new Coordinate(coordinate.Y, coordinate.X);
		}
Exemplo n.º 4
0
        /// <summary>
        ///  已知A点 和距离差,求 B点经度
        /// </summary>
        /// <param name="coordinate1">经纬度 A</param>
        /// <param name="km">距离</param>
        /// <returns></returns>
        public static CoordinateInfo GetLngDistance(CoordinateInfo coordinate1, double km)
        {
            if (coordinate1 == null)
            {
                return(null);
            }

            //纬度90度
            if (coordinate1.Latitude > 90 || coordinate1.Latitude < 90)
            {
                var lng2 = coordinate1.Longitude * 100000 - km * 1000 / Math.Cos(coordinate1.Latitude);

                return(new CoordinateInfo(lng2 / 100000, coordinate1.Latitude));
            }

            return(new CoordinateInfo(0, coordinate1.Latitude));
        }
Exemplo n.º 5
0
        /// <summary>
        /// 获取所有的坐标系信息表集合
        /// </summary>
        /// <returns>所有信息</returns>
        public ObservableCollection <CoordinateInfo> SelectAllCollection()
        {
            ObservableCollection <CoordinateInfo> datas = new ObservableCollection <CoordinateInfo>();
            SqlStatement stmt = _session.CreateSqlStatement();

            stmt.AppendString("select * from CoordinateInfo");
            stmt.StatementType = SqlStatementType.Select;
            GenDataReader reader = _session.ExcecuteReader(stmt);

            while (reader.Read())
            {
                CoordinateInfo dao = new CoordinateInfo();
                DataReaderToEntity(reader, dao);
                datas.Add(dao);
            }
            reader.Close();
            return(datas);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 新增坐标系信息表
        /// </summary>
        /// <param name="dao">数据对象</param>
        /// <returns>成功/失败</returns>
        public bool Insert(CoordinateInfo dao)
        {
            bool ret = false;

            try
            {
                Session.Open();
                Session.BeginTransaction();
                ret = _dal.Insert(dao);
                Session.CommitTransaction();
            }
            catch (Exception err)
            {
                ret = false;
                Log.Error(dao, err);
                Session.RollBackTransaction();
            }
            finally
            {
                Session.Close();
            }
            return(ret);
        }
Exemplo n.º 7
0
    public void ParseDocument(string filename)
    {
        XDocument xml      = XDocument.Load(filename);
        var       cInfoXml = xml.Descendants(DNS("coordinateInfo"))
                             .First();

        var info = new CoordinateInfo
        {
            PageSize = new Coordinates((int)cInfoXml.Element(DNS("pageSize")).Attribute("x"),
                                       (int)cInfoXml.Element(DNS("pageSize")).Attribute("y")),
            FwbScaling = new Coordinates((int)cInfoXml.Element(DNS("fbd")).Element(DNS("scaling")).Attribute("x"),
                                         (int)cInfoXml.Element(DNS("fbd")).Element(DNS("scaling")).Attribute("y")),
            LdScaling = new Coordinates((int)cInfoXml.Element(DNS("ld")).Element(DNS("scaling")).Attribute("x"),
                                        (int)cInfoXml.Element(DNS("ld")).Element(DNS("scaling")).Attribute("y")),
            SfcScaling = new Coordinates((int)cInfoXml.Element(DNS("sfc")).Element(DNS("scaling")).Attribute("x"),
                                         (int)cInfoXml.Element(DNS("sfc")).Element(DNS("scaling")).Attribute("y"))
        };

        var htmlParagraph = xml.Descendants().Where(e => e.Name == HtmlNS("p")).First();

        Console.WriteLine(htmlParagraph);
        File.WriteAllText("output.txt", htmlParagraph.ToString());
    }
		public object ToMultiLineString(CoordinateInfo[][] coordinates)
		{
			if (coordinates.Length == 0)
				return MultiLineString.Empty;
			return new MultiLineString(coordinates.Select(ToLineString).Cast<LineString>());
		}
		public object ToMultiPoint(CoordinateInfo[] coordinates)
		{
			if (coordinates.Length == 0)
				return MultiPoint.Empty;
			return new MultiPoint(coordinates.Select(ToPoint).Cast<Point>());
		}
Exemplo n.º 10
0
 /// <summary>
 /// 设置地层由Chunk进行调用
 /// </summary>
 /// <param name="coordinateInfo"></param>
 internal abstract void SetStratum(CoordinateInfo coordinateInfo);
		public object ToEnvelope(CoordinateInfo[] coordinates)
		{
			if (coordinates == null || coordinates.Length != 2)
				return null;

			return new Envelope(MakeCoordinate(coordinates[0]), MakeCoordinate(coordinates[1]));
		}
		public object ToPoint(CoordinateInfo coordinates)
		{
			if (coordinates == null)
				return Point.Empty;
			return _geometryFactory.CreatePoint(MakeCoordinate(coordinates));
		}
Exemplo n.º 13
0
 public List <PromotionEntity> GetPagedList(PagerRequest pagerRequest, out int totalCount,
                                            PromotionSortOrder sortOrder,
                                            DateTimeRangeInfo dateTimeRangeInfo, CoordinateInfo coordinateInfo,
                                            Timestamp timestamp, int?recommendUser)
 {
     return(GetPagedList(pagerRequest, out totalCount, sortOrder, dateTimeRangeInfo, coordinateInfo, timestamp,
                         recommendUser, PromotionFilterMode.Default));
 }
Exemplo n.º 14
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="skipCount"></param>
        /// <param name="pagerRequest"></param>
        /// <param name="totalCount"></param>
        /// <param name="sortOrder"></param>
        /// <param name="dateTimeRangeInfo"></param>
        /// <param name="coordinateInfo"></param>
        /// <param name="timestamp"></param>
        /// <param name="recommendUser"></param>
        /// <returns></returns>
        private List <PromotionEntity> GetPagedListByBeStart(int?skipCount, PagerRequest pagerRequest, out int totalCount, PromotionSortOrder sortOrder,
                                                             DateTimeRangeInfo dateTimeRangeInfo, CoordinateInfo coordinateInfo, Timestamp timestamp, int?recommendUser)
        {
            /*查询逻辑
             * 1.今天开始的活动
             * 2.以前开始,今天还自进行的活动
             * 3.即将开始的活动,时间升序 24小时内的
             *
             * logic 例 size40
             */
            var f3 = Filter3(DataStatus.Normal, new DateTimeRangeInfo()
            {
                EndDateTime = DateTime.Now
            }, timestamp, recommendUser);


            if (skipCount == null)
            {
                return
                    (base.Get(f3, out totalCount, pagerRequest.PageIndex, pagerRequest.PageSize,
                              OrderBy(PromotionSortOrder.StartAsc)).ToList());
            }
            else
            {
                return
                    (base.Get(f3, out totalCount, pagerRequest.PageIndex, pagerRequest.PageSize,
                              OrderBy(PromotionSortOrder.StartAsc), skipCount.Value).ToList());
            }
        }
		public object ToMultiPolygon(CoordinateInfo[][][] coordinates)
		{
			if (coordinates.Length == 0)
				return MultiPolygon.Empty;
			return new MultiPolygon(coordinates.Select(ToPolygon).Cast<Polygon>());
		}
Exemplo n.º 16
0
        private FavoriteCollectionResponse Get(float version, int userId, PagerRequest pagerRequest, CoordinateInfo coordinate, FavoriteSortOrder sortOrder, SourceType sourceType)
        {
            FavoriteCollectionResponse response;
            int totalCount;

            if (version >= 2.1)
            {
                var entitys = _favoriteRepository.Get(userId, pagerRequest, out totalCount, sortOrder, sourceType);

                var list = MappingManager.FavoriteCollectionResponseMapping(entitys, coordinate);

                response = new FavoriteCollectionResponse(pagerRequest, totalCount)
                {
                    Favorites = list
                };
            }
            else
            {
                var entitys = _favoriteRepository.GetPagedList(userId, pagerRequest, out totalCount, sortOrder, sourceType);

                response            = MappingManager.FavoriteCollectionResponseMapping(entitys, coordinate);
                response.Index      = pagerRequest.PageIndex;
                response.Size       = pagerRequest.PageSize;
                response.TotalCount = totalCount;
            }

            return(response);
        }
		public object ToMultiPolygon(CoordinateInfo[][][] coordinates)
		{
			if (coordinates.Length == 0)
				return MultiPolygon.Empty;
			return _geometryFactory.CreateMultiPolygon(coordinates.Select(ToPolygon).Cast<IPolygon>().ToArray());
		}
		public object ToMultiLineString(CoordinateInfo[][] coordinates)
		{
			if (coordinates.Length == 0)
				return MultiLineString.Empty;
			return _geometryFactory.CreateMultiLineString(coordinates.Select(ToLineString).Cast<IBasicLineString>().ToArray());
		}
Exemplo n.º 19
0
        private List <PromotionEntity> Get(PagerRequest pageRequest, Timestamp timestamp, PromotionSortOrder sortOrder, CoordinateInfo coordinateInfo, out int totalCount)
        {
            List <PromotionEntity> entitys;

            switch (sortOrder)
            {
            case PromotionSortOrder.Near:
                //先找 店铺地理位置,找到并且有促销的店铺
                //根据店铺筛出商品
                entitys = _promotionRepository.GetPagedList(pageRequest.PageIndex, pageRequest.PageSize, out totalCount,
                                                            (int)sortOrder, coordinateInfo.Longitude, coordinateInfo.Latitude, timestamp);
                break;

            case PromotionSortOrder.New:
                /*查询逻辑
                 * 1.今天开始的活动
                 * 2.以前开始,今天还自进行的活动
                 * 3.即将开始的活动,时间升序 24小时内的
                 *
                 * logic 例 size40
                 */

                //1
                entitys = _promotionRepository.GetPagedList(pageRequest, out totalCount, PromotionSortOrder.New, new DateTimeRangeInfo
                {
                    StartDateTime = DateTime.Now,
                    EndDateTime   = DateTime.Now
                }, coordinateInfo, timestamp, null, PromotionFilterMode.New);

                var t = pageRequest.PageIndex * pageRequest.PageSize;

                var e2Size  = 0;
                var e2Index = 1;
                List <PromotionEntity> e2;
                var e2Count   = 0;
                var c         = t - totalCount;
                int?skipCount = null;
                if (c <= 0)
                {
                    e2Index = 1;
                    e2Size  = 0;
                }
                else if (c > 0 && c < pageRequest.PageSize)
                {
                    //1
                    e2Index = 1;
                    e2Size  = c;
                }
                else
                {
                    e2Index = (int)Math.Ceiling(c / (double)pageRequest.PageSize);
                    e2Size  = pageRequest.PageSize;

                    if (e2Index > 1)
                    {
                        skipCount = c - (e2Index - 1) * e2Size + (pageRequest.PageSize * (e2Index - 2));
                    }
                }

                var p2 = new PagerRequest(e2Index, e2Size);

                e2 = _promotionRepository.GetPagedList(p2, out e2Count, PromotionSortOrder.New, new DateTimeRangeInfo
                {
                    StartDateTime = DateTime.Now,
                    EndDateTime   = DateTime.Now
                }, coordinateInfo, timestamp, null, PromotionFilterMode.BeginStart, skipCount);

                if (e2.Count != 0 && e2Size != 0)
                {
                    entitys.AddRange(e2);
                }

                //总记录数
                totalCount = totalCount + e2Count;
                //entitys = _promotionRepository.GetPagedList(pageRequest.PageIndex, pageRequest.PageSize,
                //                    out totalCount, (int)request.SortOrder, timestamp);
                break;

            default:
                entitys = _promotionRepository.GetPagedList(pageRequest.PageIndex, pageRequest.PageSize,
                                                            out totalCount, (int)sortOrder, timestamp);
                break;
            }

            return(entitys);
        }
		public object ToLinearRing(CoordinateInfo[] coordinates)
		{
			if (coordinates.Length == 0)
				return LinearRing.Empty;
			return _geometryFactory.CreateLinearRing(coordinates.Select(MakeCoordinate).ToArray());
		}
		public object ToEnvelope(CoordinateInfo[] coordinates)
		{
			if (coordinates == null || coordinates.Length != 2)
				return null;
			return new Envelope(coordinates[0].Y, coordinates[0].X, coordinates[1].Y, coordinates[1].X);
		}
Exemplo n.º 22
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pagerRequest"></param>
        /// <param name="totalCount"></param>
        /// <param name="sortOrder"></param>
        /// <param name="dateTimeRangeInfo"></param>
        /// <param name="coordinateInfo"></param>
        /// <param name="timestamp"></param>
        /// <param name="recommendUser"></param>
        /// <returns></returns>
        private List <PromotionEntity> GetPagedListByNew(PagerRequest pagerRequest, out int totalCount, PromotionSortOrder sortOrder,
                                                         DateTimeRangeInfo dateTimeRangeInfo, CoordinateInfo coordinateInfo, Timestamp timestamp, int?recommendUser)
        {
            /*查询逻辑
             * 1.今天开始的活动
             * 2.以前开始,今天还自进行的活动
             * 3.即将开始的活动,时间升序 24小时内的
             *
             * logic 例 size40
             */

            var r = new DateTimeRangeInfo
            {
                EndDateTime = DateTime.Now
            };

            var f1 = Filter1(DataStatus.Normal, r, timestamp, recommendUser);

            var f2 = Filter2(DataStatus.Normal, r, timestamp, recommendUser);

            var skip = (pagerRequest.PageIndex - 1) * pagerRequest.PageSize;

            var t = base.Get(f1)
                    .Union(
                base.Get(f2));

            totalCount = t.Count();

            if (pagerRequest.PageSize == 1)
            {
                return(t.OrderByDescending(s => s.IsTop).ThenByDescending(v => v.StartDate).Take(pagerRequest.PageSize).ToList());
            }

            return(t.OrderByDescending(s => s.IsTop).ThenByDescending(v => v.StartDate).Skip(skip).Take(pagerRequest.PageSize).ToList());
        }
Exemplo n.º 23
0
        public List <PromotionEntity> GetPagedList(PagerRequest pagerRequest, out int totalCount, PromotionSortOrder sortOrder,
                                                   DateTimeRangeInfo dateTimeRangeInfo, CoordinateInfo coordinateInfo, Timestamp timestamp, int?recommendUser, PromotionFilterMode filterMode)
        {
            if (filterMode == PromotionFilterMode.New)
            {
                return(GetPagedListByNew(pagerRequest, out totalCount, sortOrder, dateTimeRangeInfo, coordinateInfo,
                                         timestamp, recommendUser));
            }

            if (filterMode == PromotionFilterMode.BeginStart)
            {
                return(GetPagedListByBeStart(null, pagerRequest, out totalCount, sortOrder, dateTimeRangeInfo, coordinateInfo,
                                             timestamp, recommendUser));
            }


            if (coordinateInfo != null)
            {
                //存储
                return(GetPagedList(pagerRequest.PageIndex, pagerRequest.PageSize, out totalCount, (int)sortOrder,
                                    coordinateInfo.Longitude, coordinateInfo.Latitude, timestamp));
            }

            return
                (base.Get(Filter(DataStatus.Normal, dateTimeRangeInfo, timestamp, recommendUser), out totalCount, pagerRequest.PageIndex,
                          pagerRequest.PageSize, OrderBy(sortOrder)).ToList());
        }
Exemplo n.º 24
0
        public List <PromotionEntity> GetPagedList(PagerRequest pagerRequest, out int totalCount, PromotionSortOrder sortOrder,
                                                   DateTimeRangeInfo dateTimeRangeInfo, CoordinateInfo coordinateInfo, Timestamp timestamp,
                                                   int?recommendUser, PromotionFilterMode filterMode, int?specialSkipCount)
        {
            if (specialSkipCount == null || specialSkipCount.Value == 0 || filterMode != PromotionFilterMode.BeginStart)
            {
                return(GetPagedList(pagerRequest, out totalCount, sortOrder, dateTimeRangeInfo, coordinateInfo,
                                    timestamp, recommendUser, filterMode));
            }

            var skipCount = specialSkipCount.Value;

            return(GetPagedListByBeStart(skipCount,
                                         pagerRequest, out totalCount, sortOrder, dateTimeRangeInfo, coordinateInfo,
                                         timestamp, recommendUser));
        }
Exemplo n.º 25
0
 /// <summary>
 /// 获取指定的数据行DataRow转换成CoordinateInfo
 /// </summary>
 /// <param name="dr">DataRow数据</param>
 /// <param name="dao">CoordinateInfo实体类</param>
 public void DataRowToEntity(DataRow dr, CoordinateInfo dao)
 {
     if (dr["ID"] == null || dr["ID"] == DBNull.Value)
     {
         dao.ID = int.MinValue;
     }
     else
     {
         dao.ID = int.Parse(dr["ID"].ToString());
     }
     if (dr["GroupID"] == null || dr["GroupID"] == DBNull.Value)
     {
         dao.GroupID = Guid.NewGuid();
     }
     else
     {
         dao.GroupID = Guid.Parse(dr["GroupID"].ToString());
     }
     if (dr["Category"] == null || dr["Category"] == DBNull.Value)
     {
         dao.Category = int.MinValue;
     }
     else
     {
         dao.Category = int.Parse(dr["Category"].ToString());
     }
     if (dr["CoordinateID"] == null || dr["CoordinateID"] == DBNull.Value)
     {
         dao.CoordinateID = null;
     }
     else
     {
         dao.CoordinateID = dr["CoordinateID"].ToString();
     }
     if (dr["CoordinateName"] == null || dr["CoordinateName"] == DBNull.Value)
     {
         dao.CoordinateName = null;
     }
     else
     {
         dao.CoordinateName = dr["CoordinateName"].ToString();
     }
     if (dr["Length"] == null || dr["Length"] == DBNull.Value)
     {
         dao.Length = null;
     }
     else
     {
         dao.Length = dr["Length"].ToString();
     }
     if (dr["Remark"] == null || dr["Remark"] == DBNull.Value)
     {
         dao.Remark = null;
     }
     else
     {
         dao.Remark = dr["Remark"].ToString();
     }
     if (dr["IsReversed"] == null || dr["IsReversed"] == DBNull.Value)
     {
         dao.IsReversed = null;
     }
     else
     {
         dao.IsReversed = dr["IsReversed"].ToString();
     }
     if (dr["CurrentMileage"] == null || dr["CurrentMileage"] == DBNull.Value)
     {
         dao.CurrentMileage = null;
     }
     else
     {
         dao.CurrentMileage = dr["CurrentMileage"].ToString();
     }
     if (dr["EdgeMileage"] == null || dr["EdgeMileage"] == DBNull.Value)
     {
         dao.EdgeMileage = null;
     }
     else
     {
         dao.EdgeMileage = dr["EdgeMileage"].ToString();
     }
 }
Exemplo n.º 26
0
        public List <PromotionEntity> GetPagedListForSearch(PagerRequest pagerRequest, out int totalCount, PromotionSortOrder sortOrder,
                                                            DateTimeRangeInfo dateTimeRangeInfo, CoordinateInfo coordinateInfo, Timestamp timestamp,
                                                            int?recommendUser, PromotionFilterMode?filterMode, string promotionName, List <int> tagids,
                                                            int?brandId)
        {
            var filter = Filter(DataStatus.Normal, null, timestamp, recommendUser, tagids);

            if (!String.IsNullOrWhiteSpace(promotionName))
            {
                filter = filter.And(v => v.Name.StartsWith(promotionName));
            }

            return(base.Get(filter, out totalCount, pagerRequest.PageIndex,
                            pagerRequest.PageSize, OrderBy(sortOrder)).ToList());
        }
		private Coordinate MakeCoordinate(CoordinateInfo coordinate)
		{
			if (coordinate.Z.HasValue)
				return new Coordinate(coordinate.X, coordinate.Y, coordinate.Z.Value);
			return new Coordinate(coordinate.X, coordinate.Y);
		}
		public object ToPoint(CoordinateInfo coordinates)
		{
			if (coordinates == null)
				return Point.Empty;
			return new Point(MakeCoordinate(coordinates));
		}
		public object ToLinearRing(CoordinateInfo[] coordinates)
		{
			if (coordinates.Length == 0)
				return LinearRing.Empty;
			return new LinearRing(coordinates.Select(MakeCoordinate));
		}
Exemplo n.º 30
0
        /// <summary>
        /// 获取指定的IDataReader中的CoordinateInfo
        /// </summary>
        /// <param name="reader">IDataReader对象</param>
        /// <param name="dao">CoordinateInfo实体类</param>
        public void DataReaderToEntity(IDataReader reader, CoordinateInfo dao)
        {
            object data;

            data = reader["ID"];
            if (data == null || data == DBNull.Value)
            {
                dao.ID = int.MinValue;
            }
            else
            {
                dao.ID = int.Parse(data.ToString());
            }
            data = reader["GroupID"];
            if (data == null || data == DBNull.Value)
            {
                dao.GroupID = Guid.NewGuid();
            }
            else
            {
                dao.GroupID = Guid.Parse(data.ToString());
            }
            data = reader["Category"];
            if (data == null || data == DBNull.Value)
            {
                dao.Category = int.MinValue;
            }
            else
            {
                dao.Category = int.Parse(data.ToString());
            }
            data = reader["CoordinateID"];
            if (data == null || data == DBNull.Value)
            {
                dao.CoordinateID = null;
            }
            else
            {
                dao.CoordinateID = data.ToString();
            }
            data = reader["CoordinateName"];
            if (data == null || data == DBNull.Value)
            {
                dao.CoordinateName = null;
            }
            else
            {
                dao.CoordinateName = data.ToString();
            }
            data = reader["Length"];
            if (data == null || data == DBNull.Value)
            {
                dao.Length = null;
            }
            else
            {
                dao.Length = data.ToString();
            }
            data = reader["Remark"];
            if (data == null || data == DBNull.Value)
            {
                dao.Remark = null;
            }
            else
            {
                dao.Remark = data.ToString();
            }
            data = reader["IsReversed"];
            if (data == null || data == DBNull.Value)
            {
                dao.IsReversed = null;
            }
            else
            {
                dao.IsReversed = data.ToString();
            }
            data = reader["CurrentMileage"];
            if (data == null || data == DBNull.Value)
            {
                dao.CurrentMileage = null;
            }
            else
            {
                dao.CurrentMileage = data.ToString();
            }
            data = reader["EdgeMileage"];
            if (data == null || data == DBNull.Value)
            {
                dao.EdgeMileage = null;
            }
            else
            {
                dao.EdgeMileage = data.ToString();
            }
        }
Exemplo n.º 31
0
        private PromotionCollectionResponse GetList(PagerRequest pagerRequest, Timestamp timestamp, PromotionSortOrder sortOrder, CoordinateInfo coordinateInfo)
        {
            int totalCount;
            var entitys = Get(pagerRequest, timestamp, sortOrder, coordinateInfo, out totalCount);

            var response = new PromotionCollectionResponse(pagerRequest, totalCount)
            {
                Promotions = MappingManager.PromotionResponseMapping(entitys, coordinateInfo)
            };


            return(response);
        }