public void GeoAddAsync(string key, params GeoItem[] items) { var list = new List <string>(); list.Add(key); list.AddRange(GeoItem.ToParams(items)); var cmd = _redisCode.Coder(RequestType.GEOADD, list.ToArray()); _batchData.Add(new BatchItem(RequestType.GEOADD, cmd)); }
/// <summary> /// 将给定的空间元素(纬度、经度、名字)添加到指定的键里面 /// </summary> /// <param name="key"></param> /// <param name="items"></param> /// <returns></returns> public int GeoAdd(string key, params GeoItem[] items) { var result = -1; if (items == null || !items.Any()) { throw new Exception("params must not allow null"); } var list = new List <string>(); list.Add(key); list.AddRange(GeoItem.ToParams(items)); int.TryParse(RedisConnection.DoWithMutiParams(RequestType.GEOADD, list.ToArray()).Data, out result); return(result); }
/// <summary> /// 将给定的空间元素(纬度、经度、名字)添加到指定的键里面 /// </summary> /// <param name="timeSpan"></param> /// <param name="key"></param> /// <param name="items"></param> /// <returns></returns> public async Task <int> GeoAddAsync(TimeSpan timeSpan, string key, params GeoItem[] items) { var result = -1; if (items == null || !items.Any()) { throw new Exception("params must not allow null"); } var list = new List <string>(); list.Add(key); list.AddRange(GeoItem.ToParams(items)); var data = await _cnn.DoWithMutiParamsAsync(RequestType.GEOADD, timeSpan, list.ToArray()); int.TryParse(data.Data, out result); return(result); }
public void AddUndonePosition(GeoItem add) { if (GeoItems == null) GeoItems = new HashSet<GeoItem>(); GeoItems.Add(add); }
/// <summary> /// 递归所有支流 /// </summary> /// <param name="sourcePoint"></param> /// <param name="geoList"></param> /// <param name="dic"></param> private void GetLineByPoint(Point2d sourcePoint, List <Geometry> geoList, ref List <Dictionary <Point2d, Geometry> > dic) { Geometry geo = null; Dictionary <Point2d, Geometry> temp = null; if (dic != null && dic.Count > 0) { foreach (var dicItem in dic) { foreach (var dicGeo in dicItem) { if (dicGeo.Key.X == sourcePoint.X && dicGeo.Key.Y == sourcePoint.Y) { geo = dicGeo.Value; temp = dicItem; break; } } } } if (temp == null) { temp = new Dictionary <Point2d, Geometry>(); dic.Add(temp); } Dictionary <Point2d, Geometry> temp1 = CopyDicGeometry(temp); int index = 0; List <Geometry> copyGeoList = new List <Geometry>(); copyGeoList.AddRange(geoList); foreach (var GeoItem in copyGeoList) { Point2d findOutPoint = new Point2d(0, 0); Point2d startp = new Point2d(GeoItem.GetX(0), GeoItem.GetY(0)); Point2d endp = new Point2d(GeoItem.GetX(GeoItem.GetPointCount() - 1), GeoItem.GetY(GeoItem.GetPointCount() - 1)); if (GeometryIsContainPoint(sourcePoint, GeoItem)) { if (startp == sourcePoint && ((geo != null && !GeometryIsContainPoint(endp, geo)) || geo == null)) { findOutPoint = endp; index++; } else if (sourcePoint == endp && ((geo != null && !GeometryIsContainPoint(startp, geo)) || geo == null)) { findOutPoint = startp; index++; } if (findOutPoint != new Point2d(0, 0) && !temp.ContainsKey(findOutPoint)) { Dictionary <Point2d, Geometry> copyTemp = CopyDicGeometry(temp1); copyTemp.Add(findOutPoint, GeoItem); geoList.Remove(GeoItem); if (dic.Contains(temp)) { dic.Remove(temp); } dic.Add(copyTemp); GetLineByPoint(findOutPoint, geoList, ref dic); } } } }