public void BuildWalkables(GamePlay.GWorld world, GeoBox curBox, int curDepth, ref int maxDepth) {//这里要递归改回溯算法,否则堆栈吃不消 if (curDepth > maxDepth) { maxDepth = curDepth; } curBox.Walk = true; curBox.CanWalk = true; foreach (var i in curBox.LinkedBox) { if (i == null) { continue;//边缘 } if (i.Walk) { continue;//已经走过了 } if (i.CanWalk == false) { continue;//一个阻塞了 } if (CheckBoxInPhy(world, ref i.Box, ref CurrentPosition, ref CurrentRotation)) { i.CanWalk = false; } else { BuildWalkables(world, i, curDepth + 1, ref maxDepth); } } }
public static GeoBox GetGeoBox(this MapSpan _span) { if (_span != null) { var center = _span.Center; var halfheightDegrees = _span.LatitudeDegrees / 2; var halfwidthDegrees = _span.LongitudeDegrees / 2; var left = center.Longitude - halfwidthDegrees; var right = center.Longitude + halfwidthDegrees; var top = center.Latitude + halfheightDegrees; var bottom = center.Latitude - halfheightDegrees; GeoBox box = new GeoBox { MinLatitude = left, MaxLatitude = right, MinLongitude = bottom, MaxLongitude = top }; return(box); } return(null); }
public async Task <IActionResult> DownloadUpdates([FromQuery] decimal lat, [FromQuery] decimal lng, [FromQuery] DateTime lastUpdatedTime) { if (!ModelState.IsValid) { return(Json(new { WasSuccessful = false, Message = "Invalid model state for DownloadUpdates." })); } // Download all events where the event was updated after the last client's updated time GeoBox gb = CalculateBoundingGeoBox(lat, lng, Policy.SURROUNDING_GEOBOX_SIDE_LENGTH); var @events = await _context.Event.Where(e => ( e.Latitude <gb.MaxLatitude && e.Latitude> gb.MinLatitude && e.Longitude <gb.MaxLongitude && e.Longitude> gb.MinLongitude && e.TimeLastUpdated > lastUpdatedTime )).ToListAsync(); // Determine if any of these events need to be deleted... var eventsToDelete = @events.Where(Policy.ShouldMarkEventForDeletion); foreach (Event e in eventsToDelete) { e.Deleted = true; e.TimeLastUpdated = DateTime.UtcNow; } _context.UpdateRange(eventsToDelete); await _context.SaveChangesAsync(); return(Json(new { WasSuccessful = true, Events = @events, CurrentServerTime = DateTime.UtcNow })); }
/// <summary> /// /// </summary> /// <param name="_center"></param> /// <param name="_distance">In feet</param> /// <returns></returns> public List <Hydrant> GetHydrants(GeoPoint _center, double _distance) { GeoDistance distance = new GeoDistance(DistanceUnits.Feet, _distance); GeoBox gb = new GeoBox(_center, distance, distance); return(GetHydrants(gb)); }
public void CreateGoBox() { var point = new GeoPoint(39.461538f, -0.4098373f); var geobox = GeoBox.From(point); Assert.NotNull(geobox); }
/// <summary> /// /// </summary> /// <param name="_tagPosition"></param> /// <param name="_distance">Feet</param> /// <returns></returns> public List <NearbyHydrant> GetNearbyHydrants(GeoPoint _tagPosition, double _distance) { GeoDistance distance = new GeoDistance(DistanceUnits.Feet, _distance); GeoBox gb = new GeoBox(_tagPosition, distance, distance); List <Hydrant> hydrants = GetHydrants(gb); List <NearbyHydrant> output = new List <NearbyHydrant>(); foreach (Hydrant hydrant in hydrants) { NearbyHydrant nbh = new NearbyHydrant { Position = hydrant.Position, Location = string.Format("Latitude: {0}<br>Longitude: {1}", hydrant.Position.Y.ToString("###.######"), hydrant.Position.X.ToString("###.######")), HydrantGuid = hydrant.Guid, DistanceInFeet = PositionHelper.GetDistance(_tagPosition, hydrant.Position).ToFeet().ToString("###.#"), Thumbnail = string.Format("<img src=\"{0}\" class=\"tagimg\" onclick=\"ShowImage('{1}');\">", hydrant.GetUrl(true), hydrant.GetUrl(false)), MatchButton = string.Format("<button type=\"button\" class=\"btn btn-info\" onclick=\"MatchHydrant('{0}')\">Match</button>", hydrant.Guid) }; output.Add(nbh); } return(output); }
public void BuildWalkables2(GamePlay.GWorld world, Stack <GeoBox> stack) { while (stack.Count > 0) { GeoBox curBox = stack.Pop(); foreach (var i in curBox.LinkedBox) { if (i == null) { continue;//边缘 } if (i.Walk) { continue;//已经走过了 } if (i.CanWalk == false) { continue;//一个阻塞了 } if (CheckBoxInPhy(world, ref i.Box, ref CurrentPosition, ref CurrentRotation)) { i.CanWalk = false; } else { i.Walk = true; i.CanWalk = true; stack.Push(i); } } } }
public static WhereAreFiresResponse [] GetFirePoints(GeoPoint currentPosition, string user) { var args = new WhereAreFires(GeoBox.From(currentPosition, 100)); var firesDetected = WebApiHelper.GetNasaWebApiResponse <WhereAreFiresResponse []> (args); return(firesDetected); }
private void UpdateCurrentView() { GeoBox box = m_Map.VisibleRegion.GetGeoBox(); if (box != null) { List <Hydrant> hydrants = GetHydrants(box); Device.BeginInvokeOnMainThread(() => { if (hydrants != null) { m_Map.Pins.Clear(); foreach (var item in hydrants) { if (item.Position != null) { var pin = new Pin() { Label = "Hydrant" }; pin.Position = new Position(item.Position.Latitude, item.Position.Longitude); m_Map.Pins.Add(pin); } } } }); } }
public List <Hydrant> GetHydrants(GeoBox _geoBox) { IMongoQuery query = Query.WithinRectangle("Position", _geoBox.MinLongitude(), _geoBox.MinLatitude(), _geoBox.MaxLongitude(), _geoBox.MaxLatitude()); return(GetList(query)); }
public CheckFireExistence(GeoBox geoBox) : this() { //this.date1 = int.Parse (date1.ToString ("")); //this.date2 = int.Parse (date2.ToString ("")); ulx = geoBox.UpperLeft.Longitude; uly = geoBox.UpperLeft.Latitude; lrx = geoBox.LowerRight.Longitude; lry = geoBox.LowerRight.Latitude; }
public List <Hydrant> GetHydrants(GeoBox _geoBox, int _quantity) { IMongoQuery query = Query.WithinRectangle("Position", _geoBox.MinLongitude(), _geoBox.MinLatitude(), _geoBox.MaxLongitude(), _geoBox.MaxLatitude()); MongoCursor cursor = GetCursor(query).SetLimit(_quantity); return(GetList(cursor)); }
SofiaEnvirontment() { nasaFirePoints = new List <NasaFirePoint> (); firePoints = new List <FirePoint> (); weatherService = new WeatherService(); var args = new WhereAreFires(GeoBox.From(defaultPoint, DefaultZoom)); var firesDetected = WebApiHelper.GetNasaWebApiResponse <WhereAreFiresResponse []> (args); AddItems(firesDetected); }
public static GeoPoint SouthWest(this GeoBox _box) { if (_box != null) { GeoPoint output = new GeoPoint(); output.Latitude = _box.MinLatitude; output.Longitude = _box.MinLongitude; return(output); } return(null); }
public static GeoPoint Center(this GeoBox _box) { if (_box != null) { GeoPoint output = new GeoPoint(); output.Latitude = (_box.MaxLatitude - _box.MinLatitude) / 2; output.Longitude = (_box.MaxLongitude - _box.MinLongitude) / 2; return(output); } return(null); }
public static GeoPoint NorthEast(this GeoBox _box) { if (_box != null) { GeoPoint output = new GeoPoint(); output.Latitude = _box.MaxLatitude; output.Longitude = _box.MaxLongitude; return(output); } return(null); }
public string GetGeoboxCSVData(DynamicDictionary _parameters) { HydrantWikiManager hwm = new HydrantWikiManager(); double east = Convert.ToDouble((string)_parameters["east"]); double west = Convert.ToDouble((string)_parameters["west"]); double north = Convert.ToDouble((string)_parameters["north"]); double south = Convert.ToDouble((string)_parameters["south"]); GeoBox geobox = new GeoBox(east, west, north, south); List <Hydrant> hydrants = hwm.GetHydrants(geobox); return(HydrantCSVHelper.GetHydrantCSV(hydrants)); }
private List <Hydrant> GetHydrants(GeoBox box) { if (box != null) { var response = HWManager.GetInstance().ApiManager.GetHydrantsInBox( HydrantWikiApp.User, box.MinLatitude, box.MaxLatitude, box.MinLongitude, box.MaxLongitude); return(response.Hydrants); } return(null); }
public BaseResponse HangleGetHydrantsByGeobox(DynamicDictionary _parameters) { var response = new BaseResponse { Success = false }; User user; if (AuthHelper.IsAuthorized(Request, out user)) { HydrantWikiManager hwm = new HydrantWikiManager(); double east = Convert.ToDouble((string)_parameters["east"]); double west = Convert.ToDouble((string)_parameters["west"]); double north = Convert.ToDouble((string)_parameters["north"]); double south = Convert.ToDouble((string)_parameters["south"]); int quantity = 250; if (_parameters.ContainsKey("quantity")) { quantity = Convert.ToInt32((string)_parameters["quantity"]); } if (quantity > 500) { quantity = 500; } GeoBox geobox = new GeoBox(east, west, north, south); List <Hydrant> hydrants = hwm.GetHydrants(geobox, quantity); List <HydrantHeader> headers = ProcessHydrants(hydrants); response = new HydrantQueryResponse { Success = true, Hydrants = headers }; hwm.LogInfo(user.Guid, "Retrieved Hydrants by Geobox"); return(response); } else { LogUnauthorized(Request); } return(response); }
public void BuildGeoBoxs(Vector3 pos, Vector3 scale, Quaternion rotation) { int sizex = (int)(scale.X / AgentGridSize); int sizez = (int)(scale.Z / AgentGridSize); int sizey = (int)(scale.Y / AgentGridSize); float startx = scale.X * -0.5f; float starty = scale.Y * -0.5f; float startz = scale.Z * -0.5f; CurrentScale = scale; CurrentPosition = pos; CurrentRotation = rotation; Matrix mat = Matrix.Transformation(Vector3.UnitXYZ, rotation, pos); GeoBoxs = new GeoBox[sizex, sizey, sizez]; //Vector4 outv4 = new Vector4(); for (int i = 0; i < sizex; i++) { for (int j = 0; j < sizey; j++) { for (int k = 0; k < sizez; k++) { GeoBoxs[i, j, k] = new GeoBox(); //Vector3 min = new Vector3(startx + i * AgentGridSize, starty + j * AgentGridSize, startz + k * AgentGridSize) GeoBoxs[i, j, k].Box.Minimum = new Vector3(startx + i * AgentGridSize, starty + j * AgentGridSize, startz + k * AgentGridSize); GeoBoxs[i, j, k].Box.Maximum = new Vector3(startx + (i + 1) * AgentGridSize, starty + (j + 1) * AgentGridSize, startz + (k + 1) * AgentGridSize); //Vector3.Transform(ref GeoBoxs[i, j, k].OrigBox.Minimum, ref mat, out outv4); //GeoBoxs[i, j, k].Box.Minimum = new Vector3(outv4.X, outv4.Y, outv4.Z); //Vector3.Transform(ref GeoBoxs[i, j, k].OrigBox.Maximum, ref mat, out outv4); //GeoBoxs[i, j, k].Box.Maximum = new Vector3(outv4.X, outv4.Y, outv4.Z); GeoBoxs[i, j, k].FaceType = 0; GeoBoxs[i, j, k].Index = -1; GeoBoxs[i, j, k].X = i; GeoBoxs[i, j, k].Y = j; GeoBoxs[i, j, k].Z = k; } } } BuildBoxLinker(); }
public async Task <IEnumerable <MediaGeoLocation> > FindMediaInGeoBoxAsync( GeoBox box, int limit, CancellationToken cancellation) { FilterDefinition <Media> filter = Builders <Media> .Filter.GeoWithinBox(x => x.GeoLocation.Point, box.SouthWest.Longitude, box.SouthWest.Latitude, box.NorthEast.Longitude, box.NorthEast.Latitude); var medias = await _mediaStoreContext.Medias.Find(filter) .Limit(limit) .Project(p => new { p.Id, p.GeoLocation !.Point.Coordinates, p.GeoLocation !.GeoHash })
public async Task <IActionResult> DownloadAllEventsInArea([FromQuery] decimal lat, [FromQuery] decimal lng) { if (!ModelState.IsValid) { return(Json(new { WasSuccessful = false, Message = "Model state was invalid for downloading all events..." })); } // Within 30 miles GeoBox gb = CalculateBoundingGeoBox(lat, lng, Policy.SURROUNDING_GEOBOX_SIDE_LENGTH); var @events = await _context.Event.Where(e => ( e.Latitude <gb.MaxLatitude && e.Latitude> gb.MinLatitude && e.Longitude <gb.MaxLongitude && e.Longitude> gb.MinLongitude )).ToListAsync(); // Determine if any of these events need to be deleted... var eventsToDelete = events.Where(Policy.ShouldMarkEventForDeletion); return(Json(new { WasSuccessful = true, Events = @events, CurrentServerTime = DateTime.UtcNow })); }
static int GetFiresAroundYou(GeoPoint point) => WebApiHelper.GetNasaWebApiResponse <HowManyFiresExistResponse> (new HowManyFiresExist(GeoBox.From(point))).number;
public List <Hydrant> GetHydrants(GeoBox _geoBox) { HydrantDAO dao = new HydrantDAO(MongoDB); return(dao.GetHydrants(_geoBox)); }
public List <Hydrant> GetHydrants(GeoBox _geoBox, int _quantity) { HydrantDAO dao = new HydrantDAO(MongoDB); return(dao.GetHydrants(_geoBox, _quantity)); }