void AddLocation(DaggerfallTerrain daggerTerrain, TerrainData terrainData) { //Destroy old locations by going through all the child objects, but //don't delete the billboard batch (The surrounding vegettion) foreach (Transform child in daggerTerrain.gameObject.transform) { if (!child.GetComponent <DaggerfallBillboardBatch>()) { Destroy(child.gameObject); } } foreach (LocationInstance loc in locationInstance) { if (daggerTerrain.MapPixelX != loc.worldX || daggerTerrain.MapPixelY != loc.worldY) { continue; } if (loc.terrainX <= 0 || loc.terrainY <= 0 || (loc.terrainX > 128 || loc.terrainY > 128)) { Debug.LogWarning("Invalid Location at " + daggerTerrain.MapPixelX + " : " + daggerTerrain.MapPixelY + " : The location pixelX + or/and pixelY must be higher than 0 and lower than 128"); continue; } //Now that we ensured that it is a valid location, then load the locationpreset LocationPrefab locationPrefab = LocationHelper.LoadLocationPrefab(Application.dataPath + LocationHelper.locationPrefabFolder + loc.prefab + ".txt"); if (locationPrefab == null) { Debug.LogWarning("Can't find location Preset: " + loc.prefab); continue; } if ((loc.terrainX + locationPrefab.height > 128 || loc.terrainY + locationPrefab.width > 128)) { Debug.LogWarning("Invalid Location at " + daggerTerrain.MapPixelX + " : " + daggerTerrain.MapPixelY + " : The locationpreset exist outside the terrain"); continue; } if ((loc.terrainX + locationPrefab.height > 127 || loc.terrainY + locationPrefab.width > 127)) { Debug.LogWarning("Invalid Location at " + daggerTerrain.MapPixelX + " : " + daggerTerrain.MapPixelY + " : The locationpreset must be 1 pixel away (both X and Y) from the terrainBorder"); continue; } //Smooth the terrain if (loc.type == 0) { daggerTerrain.MapData.hasLocation = true; //daggerTerrain.MapData.locationName = loc.name; daggerTerrain.MapData.locationRect = new Rect(loc.terrainX, loc.terrainY, locationPrefab.width, locationPrefab.height); int count = 0; float tmpAverageHeight = 0; for (int x = loc.terrainX; x <= loc.terrainX + locationPrefab.width; x++) { for (int y = loc.terrainY; y <= loc.terrainY + locationPrefab.height; y++) { tmpAverageHeight += daggerTerrain.MapData.heightmapSamples[y, x]; count++; } } daggerTerrain.MapData.averageHeight = tmpAverageHeight /= count; //TerrainHelper.BlendLocationTerrain(ref daggerTerrain.MapData); //orginal alternative for (int x = 1; x <= 127; x++) { for (int y = 1; y <= 127; y++) { daggerTerrain.MapData.heightmapSamples[y, x] = Mathf.Lerp(daggerTerrain.MapData.heightmapSamples[y, x], daggerTerrain.MapData.averageHeight, 1 / (GetDistanceFromRect(daggerTerrain.MapData.locationRect, new Vector2(x, y)) + 1)); } } terrainData.SetHeights(0, 0, daggerTerrain.MapData.heightmapSamples); } foreach (LocationPrefab.LocationObject obj in locationPrefab.obj) { if (!LocationHelper.ValidateValue(obj.type, obj.name)) { continue; } GameObject go = LocationHelper.LoadObject(obj.type, obj.name, daggerTerrain.gameObject.transform, new Vector3((loc.terrainX * TERRAIN_SIZE_MULTI) + obj.pos.x, (daggerTerrain.MapData.averageHeight * TERRAIN_HEIGHT_MAX) + obj.pos.y, (loc.terrainY * TERRAIN_SIZE_MULTI) + obj.pos.z), obj.rot, new Vector3(obj.scale.x, obj.scale.y, obj.scale.z), loc.locationID, obj.objectID ); if (go.GetComponent <DaggerfallBillboard>()) { float tempY = go.transform.position.y; go.GetComponent <DaggerfallBillboard>().AlignToBase(); go.transform.position = new Vector3(go.transform.position.x, tempY + ((go.transform.position.y - tempY) * go.transform.localScale.y), go.transform.position.z); } if (!go.GetComponent <DaggerfallLoot>()) { go.isStatic = true; } } continue; } }
private IEnumerable <Location> TestLocations() { return(LocationHelper.GetMany()); }
/// <summary> /// Search routes to selected destination/waypoints /// </summary> private async void GetRouteDirections() { if (RouteDatas == null) { return; } if (RouteDatas.Count > 0) { RouteDatas.Clear(); } if (RouteWaypoints.Count < 2) { return; } List <BasicGeoposition> pts = RouteWaypoints.Select(loc => loc.Position).ToList(); DateTime dateTime = DateTime.Now.AddMinutes(1); if ((leaveatButton.IsChecked.Value) || (arrivebyButton.IsChecked.Value)) { var dts = calendarView.SelectedDates.ToList(); dateTime = dts[0].DateTime.Date.AddMinutes(timePicker.SelectedTime.Value.TotalMinutes); } var avoids = GetAvoids(); var language = (LanguageComboBox.SelectedItem as ComboBoxItem).Tag.ToString(); RouteDirectionsResponse results = new RouteDirectionsResponse(); if (leaveatButton.IsChecked.Value || leaveatButton.IsChecked.Value) { results = await LocationHelper.GetRouteDirections(pts, language, travelMode, avoids, routeType, RouteOptionsCountComboBox.SelectedIndex, dateTime, null); } else { results = await LocationHelper.GetRouteDirections(pts, language, travelMode, avoids, routeType, RouteOptionsCountComboBox.SelectedIndex, null, dateTime); } if (results == null) { return; } foreach (var route in results.routes) { var routedata = new RouteData() { Route = route, IsLeaveNow = leaveNowButton.IsChecked.Value, IsArriveBy = arrivebyButton.IsChecked.Value, IsLeaveAt = leaveatButton.IsChecked.Value, IsShowed = false, StartLocationLable = RouteWaypoints[0].Name, EndLocationLabel = RouteWaypoints[RouteWaypoints.Count - 1].Name }; RouteDatas.Add(routedata); } }
public List <Location> GetLocations() { return(LocationHelper.GetLocations()); }
private async void FetchPlaces() { UserDialogs.Instance.Loading(title: "Processing Get Information...").Show(); var client = new HttpClient() { Timeout = TimeSpan.FromSeconds(20) }; JObject jsonDataObject = new JObject { { "auth", "H6V$36A*!?L^G2NXX7U%=GY@" } }; JObject jsonData = new JObject { { "params", jsonDataObject } }; var data = jsonData.ToString(); var content = new StringContent(data, Encoding.UTF8, "application/json"); Debug.WriteLine("REQUEST-FetchPlaces: " + data); try { HttpResponseMessage response = await client.PostAsync(ApiUri.BASE_URL + ApiUri.FETCH_PLACES, content); string responseContent = await response.Content.ReadAsStringAsync(); if (response.StatusCode == HttpStatusCode.OK) { UserDialogs.Instance.Loading().Hide(); Debug.WriteLine("RESPONSE-FetchPlaces: " + responseContent); ListPlacesResponse listPlacesResponse = JsonConvert.DeserializeObject <ListPlacesResponse>(responseContent, App.DefaultSerializerSettings); ListPlacesResult listPlacesResult = listPlacesResponse.Result; listPlaces = listPlacesResult.places.ToList(); var location = await LocationHelper.GetCurrentPosition(50); maps.MoveToRegion(MapSpan.FromCenterAndRadius(new Xamarin.Forms.GoogleMaps.Position(location.Latitude, location.Longitude), Distance.FromMeters(1000))); foreach (var place in listPlaces) { place.distance = location.CalculateDistance(new Plugin.Geolocator.Abstractions.Position(place.latitude, place.longitude), GeolocatorUtils.DistanceUnits.Kilometers); place.distance_display = place.distance > 1 ? place.distance.ToString("N0") + " km" : (place.distance / 1000).ToString("N0") + " m"; } //listPlaceOfInterest.ItemsSource = listPlaces .Where(x => x.longitude != 0 && x.latitude != 0).OrderByDescending(x => x.id).ToList(); await FetchPlaceTypes(); await GetNearestPlaces(); } } catch (TaskCanceledException ex) { UserDialogs.Instance.Loading().Hide(); UserDialogs.Instance.Toast(new ToastConfig("Bad Connection Error. Try Again")); Debug.WriteLine(ex.Message); } catch (Exception exx) { Debug.WriteLine(exx.Message); UserDialogs.Instance.Loading().Hide(); Notifications.Internal.ServerError(); } }
public void GetDistance() { // Values used for comparison comes from lines plotted into Google Maps. Google uses a varying number // decimals depending on the distance, so we loose a bit precision when rounding. But the results of this // unit test still shows that the method works (eg. the test will fail if using the mean radius rather than // the equatorial radius). var samples = new[] { new { From = new EssentialsLocation(55.6946159, 10.0366974), To = new EssentialsLocation(55.6477614, 10.1589203), Expected = "9.28", Decimals = 2 }, new { From = new EssentialsLocation(54.8671242, 7.7124023), To = new EssentialsLocation(56.8159142, 12.2113037), Expected = "355", Decimals = 0 }, new { From = new EssentialsLocation(49.2104204, -6.1083984), To = new EssentialsLocation(59.578851, 22.9833984), Expected = "2184", Decimals = 0 }, new { From = new EssentialsLocation(12.3829283, -71.3671875), To = new EssentialsLocation(71.2443555, 25.4882813), Expected = "8958", Decimals = 0 } }; foreach (var sample in samples) { string format = "{0:0." + ("".PadLeft(sample.Decimals, '0')) + "}"; Assert.AreEqual(sample.Expected, string.Format(CultureInfo.InvariantCulture, format, LocationHelper.GetDistance(sample.From, sample.To) / 1000), "#1"); Assert.AreEqual(sample.Expected, string.Format(CultureInfo.InvariantCulture, format, LocationUtils.GetDistance(sample.From, sample.To) / 1000), "#2"); } }
public IPLocation GetUserIPAddress() { return(LocationHelper.GetIpAndLocation(_httpContextAccessor)); }
public void InvalidateCacheForLocation(GameLocation location) { if (_connectedChestsCache != null && location != null && _connectedChestsCache.ContainsKey(LocationHelper.GetName(location))) { _connectedChestsCache.Remove(LocationHelper.GetName(location)); } }
private void BuildCacheForLocation(GameLocation gameLocation) { if (gameLocation != null) { var cacheToAdd = new Dictionary <Vector2, Chest>(); _monitor.Log($"Starting search for connected locations at {LocationHelper.GetName(gameLocation)}"); var items = ItemFinder.FindObjectsWithName(gameLocation, (from x in _machineConfigs select x.Name).ToList()); foreach (var valuePair in items) { var location = valuePair.Key; if (cacheToAdd.ContainsKey(location)) { // already found in another search continue; } var processedLocations = new List <ConnectedTile> { new ConnectedTile { Location = location, Object = valuePair.Value } }; ItemFinder.FindConnectedLocations(gameLocation, location, processedLocations, _allowDiagonalConnectionsForAllItems); var chest = processedLocations.FirstOrDefault(c => c.Chest != null)?.Chest; foreach (var connectedLocation in processedLocations) { cacheToAdd.Add(connectedLocation.Location, chest); } } lock (_connectedChestsCache) { if (_connectedChestsCache.ContainsKey(LocationHelper.GetName(gameLocation))) { // already ran? _connectedChestsCache.Remove(LocationHelper.GetName(gameLocation)); } _connectedChestsCache.Add(LocationHelper.GetName(gameLocation), new Dictionary <Vector2, Chest>()); foreach (var cache in cacheToAdd) { _connectedChestsCache[LocationHelper.GetName(gameLocation)].Add(cache.Key, cache.Value); } } _monitor.Log($"Searched your {LocationHelper.GetName(gameLocation)} for machines to collect from and found a total of {_connectedChestsCache[LocationHelper.GetName(gameLocation)].Count} locations to look for"); } }
void OnGUI() { if (GUI.Button(Rect_NewFile, "New File")) { locationInstance = new List <LocationInstance>(); locationInstaneNames = new List <string>(); locationPrefab = new List <LocationPrefab>(); } if (GUI.Button(Rect_SaveFile, "Save File")) { string path = EditorUtility.SaveFilePanel("Save as", LocationHelper.locationInstanceFolder, "new location", "txt"); if (path.Length != 0) { LocationHelper.SaveLocationInstance(locationInstance.ToArray(), path); } } if (GUI.Button(Rect_LoadFile, "Load File")) { string path = EditorUtility.OpenFilePanel("Open", LocationHelper.locationInstanceFolder, "txt"); if (path.Length == 0) { return; } locationInstance = LocationHelper.LoadLocationInstance(path); if (locationInstance == null) { return; } locationInstaneNames = new List <string>(); locationPrefab = new List <LocationPrefab>(); foreach (LocationInstance loc in locationInstance) { locationInstaneNames.Add(loc.name); if (loc.prefab != null) { LocationPrefab tmplocpref = LocationHelper.LoadLocationPrefab(Application.dataPath + LocationHelper.locationPrefabFolder + loc.prefab + ".txt"); if (tmplocpref != null) { locationPrefab.Add(tmplocpref); } else { locationPrefab.Add(new LocationPrefab()); } } else { locationPrefab.Add(new LocationPrefab()); } } } if (locationInstance != null) { ShowLocationList(); } }
void ShowLocationList() { scrollPosition = GUI.BeginScrollView(new Rect(32, 64, 256, 472), scrollPosition, new Rect(0, 0, 236, 20 + (locationInstaneNames.Count * 24)), false, true); listSelector = GUI.SelectionGrid(new Rect(10, 10, 216, locationInstaneNames.Count * 24), listSelector, locationInstaneNames.ToArray(), 1); GUI.EndScrollView(); if (locationInstance.Count > listSelector) { GUI.Label(new Rect(312, 64, 96, 16), "Location ID: "); GUI.TextField(new Rect(388, 64, 96, 16), "#" + locationInstance[listSelector].locationID.ToString("00000000")); if (GUI.Button(new Rect(506, 64, 128, 16), "Generate New ID")) { locationInstance[listSelector].UpdateLocationID(); } GUI.Label(new Rect(312, 96, 64, 16), "Name: "); locationInstance[listSelector].name = GUI.TextField(new Rect(372, 96, 128, 16), locationInstance[listSelector].name); if (GUI.changed) { locationInstaneNames[listSelector] = locationInstance[listSelector].name; } GUI.Label(new Rect(312, 128, 64, 16), "Prefab: "); GUI.TextField(new Rect(372, 128, 128, 16), locationInstance[listSelector].prefab); if (GUI.Button(new Rect(506, 128, 96, 16), "Select Prefab")) { string path = EditorUtility.OpenFilePanel("Open", LocationHelper.locationPrefabFolder, "txt"); if (path.Length == 0) { return; } LocationPrefab tmplocpref = LocationHelper.LoadLocationPrefab(path); if (tmplocpref != null) { locationInstance[listSelector].prefab = Path.GetFileNameWithoutExtension(path); locationPrefab[listSelector] = tmplocpref; } } if (locationInstance[listSelector].prefab != "" && !File.Exists(Application.dataPath + LocationHelper.locationPrefabFolder + locationInstance[listSelector].prefab + ".txt")) { GUI.contentColor = Color.red; GUI.Label(new Rect(614, 128, 128, 16), "Prefab not found!"); GUI.contentColor = Color.white; } GUI.Label(new Rect(312, 160, 64, 16), "Type: "); locationInstance[listSelector].type = EditorGUI.Popup(new Rect(372, 160, 128, 16), locationInstance[listSelector].type, locationTypes); GUI.Label(new Rect(312, 192, 64, 16), "World X: "); locationInstance[listSelector].worldX = EditorGUI.IntSlider(new Rect(372, 192, 256, 16), locationInstance[listSelector].worldX, 3, 998); GUI.Label(new Rect(312, 224, 64, 16), "World Y: "); locationInstance[listSelector].worldY = EditorGUI.IntSlider(new Rect(372, 224, 256, 16), locationInstance[listSelector].worldY, 3, 498); GUI.Label(new Rect(312, 256, 64, 16), "Terrain X: "); locationInstance[listSelector].terrainX = EditorGUI.IntSlider(new Rect(372, 256, 256, 16), locationInstance[listSelector].terrainX, 1, 127 - locationPrefab[listSelector].width); GUI.Label(new Rect(312, 288, 64, 16), "Terrain Y: "); locationInstance[listSelector].terrainY = EditorGUI.IntSlider(new Rect(372, 288, 256, 16), locationInstance[listSelector].terrainY, 1, 127 - locationPrefab[listSelector].height); GUI.Label(new Rect(454, 320, 64, 16), "- N -"); GUI.Box(new Rect(336, 336, 256, 256), "", blackBG); GUI.Box(new Rect((336 + (locationInstance[listSelector].terrainX * 2)), (592 - (locationInstance[listSelector].terrainY * 2)) - locationPrefab[listSelector].height * 2, locationPrefab[listSelector].width * 2, locationPrefab[listSelector].height * 2), "", lightGreenBG); GUI.Label(new Rect(454, 592, 64, 16), "- S -"); } if (GUI.Button(new Rect(32, 562, 96, 20), "Add Location")) { locationInstance.Add(new LocationInstance("new Location", 0, "", 0, 0, 0, 0)); locationInstance[locationInstance.Count - 1].UpdateLocationID(); locationInstaneNames.Add("new location"); locationPrefab.Add(new LocationPrefab()); } if (GUI.Button(new Rect(160, 562, 128, 20), "Remove Location")) { locationInstance.RemoveAt(listSelector); locationInstaneNames.RemoveAt(listSelector); } }
protected override void OnViewModelSet() { base.OnViewModelSet(); _locationHelper = new LocationHelper <MainView>(this); _listItemHelper = new ListItemHelper(this); }
/// <summary> /// FindEntriesByLocation. /// </summary> /// <param name="location">En sträng<see cref="string"/> med namnet på rummet eller lägenheten som söks.</param> /// <returns>En DataTable<see cref="DataTable"/> med sökresultat.</returns> public static DataTable FindEntriesByLocation(string location) { return(LocationHelper.FindEntriesByLocation(location, MaxEntries)); }
public Distance ComputeDistanceAway(LatLongPoint from) { LatLongPoint stationPoint = new LatLongPoint(Place.Lattitude, Place.Longitude); return(LocationHelper.ComputeDistance(stationPoint, from, DistanceUnit.Kilometers)); }
public static List <lo.Location> GetLocations() { return(LocationHelper.GetLocations()); }
/// <summary> /// 获取列表 /// </summary> /// <param name="pagination">分页</param> /// <param name="queryJson">查询参数</param> /// <returns>返回分页列表</returns> public IEnumerable <Ku_CompanyEntity> GetPageList(Pagination pagination, string queryJson) { var expression = LinqExtensions.True <Ku_CompanyEntity>(); var queryParam = queryJson.ToJObject(); string des = OperatorProvider.Provider.Current().Description; string locationSql = LocationHelper.GetLocationSql(des); string strSql = $"select c.* from Ku_Company c LEFT JOIN {locationSql} l ON l.Id=c.LocationId where ManageState=1 AND LocationId>0 AND c.District!='' ";//在营公海显示被获取公司 ObtainState=0 //坐标位置商圈ID存在的话,不以输入的商圈文字搜索 if (!queryParam["LocationId"].IsEmpty()) { string LocationId = queryParam["LocationId"].ToString(); strSql += " and LocationId = " + LocationId; } else if (!queryParam["RegeoName"].IsEmpty()) { string RegeoName = queryParam["RegeoName"].ToString(); strSql += " and c.RegeoName like '%" + RegeoName + "%' "; } //位置ID if (!queryParam["LocationIds"].IsEmpty()) { string LocationIds = queryParam["LocationIds"].ToString(); strSql += " and LocationId in (" + LocationIds + ")"; } //单据日期 if (!queryParam["StartTime"].IsEmpty() && !queryParam["EndTime"].IsEmpty()) { DateTime startTime = queryParam["StartTime"].ToDate(); DateTime endTime = queryParam["EndTime"].ToDate().AddDays(1); strSql += " and BuildTime >= '" + startTime + "' and BuildTime < '" + endTime + "'"; } //公司名 if (!queryParam["CompanyName"].IsEmpty()) { string CompanyName = queryParam["CompanyName"].ToString(); strSql += " and c.CompanyName like '%" + CompanyName + "%' "; } //经营范围 if (!queryParam["Scope"].IsEmpty()) { string Scope = queryParam["Scope"].ToString(); strSql += " and c.Scope like '%" + Scope + "%' "; } //行业 if (!queryParam["Sector"].IsEmpty()) { string Sector = queryParam["Sector"].ToString(); Sector = Sector.Replace("[", "").Replace("]", "").Replace("\"", "'"); strSql += " and c.Sector in(" + Sector + ")"; } //区域 if (!queryParam["District"].IsEmpty()) { string District = queryParam["District"].ToString(); District = District.Replace("[", "").Replace("]", "").Replace("\"", "'"); strSql += " and c.District in(" + District + ")"; } //POI分布 if (!queryParam["TypeName"].IsEmpty()) { string TypeName = queryParam["TypeName"].ToString(); TypeName = TypeName.Replace("[", "").Replace("]", "").Replace("\"", "'"); strSql += " and l.TypeName in(" + TypeName + ")"; } //销售人 if (!queryParam["ObtainUserId"].IsEmpty()) { string ObtainUserId = queryParam["ObtainUserId"].ToString(); strSql += " and c.ObtainUserId = '" + ObtainUserId + "'"; } //状态 if (!queryParam["FollowState"].IsEmpty()) { string FollowState = queryParam["FollowState"].ToString(); strSql += " and c.FollowState = '" + FollowState + "'"; } //排序楼层,房间 if (pagination.sidx == "Floor") { pagination.sidx = "Floor " + pagination.sord + ",Room " + pagination.sord; } return(this.BaseRepository().FindList(strSql.ToString(), pagination)); }
public static bool SetLocation(lo.Location location, pdm.Address address) { return(LocationHelper.SetLocation(location, address)); }
public void CalculateDistance() { double value = LocationHelper.DistanceFromMeToLocation(AppMobileService.Locaion.CurrentLocation.Latitude, AppMobileService.Locaion.CurrentLocation.Longitude, Latitude, Longitude); Distance = value.ToString("0.##"); }
public kmlDocumentPlacemark LocateWaypointOnRoute(WaypointDetectionMethod method, List <kmlDocumentPlacemark> route, List <GPSLocation> history, double heading, int waypointIndex = 0) { kmlDocumentPlacemark nearestMAPPlacemark = null; var location = history.Last(); var sortedMAPPoints = GLOSAHelper.SortMAPKMLDataByDistanceFromCurrentLocation(route, location.Latitude, location.Longitude).ToList(); if (sortedMAPPoints != null && sortedMAPPoints.Count > 0) { if (method == WaypointDetectionMethod.ShortestDistance) { nearestMAPPlacemark = sortedMAPPoints.First(); } else if (method == WaypointDetectionMethod.DeviceHeading) { // No valid method chosen throw new Exception("Waypoint Detection Method not implemented."); } else if (method == WaypointDetectionMethod.GPSHistoryDirection) { List <TrafficNode> listOfWaypoints = new List <TrafficNode>(); GPSLocation from = history[history.Count - 2]; GPSLocation to = history[history.Count - 1]; double?vehicleBearing = LocationHelper.HeadingBetweenTwoGPSLocations(from, to); foreach (var mapPoint in sortedMAPPoints) { listOfWaypoints.Add(new TrafficNode() { GPSLocation = KMLHelper.XMLCoordinateStringToGPSLocation(mapPoint.Point.coordinates), ID = mapPoint.name, angleDiff = 0, }); } foreach (var waypoint in listOfWaypoints) { double?bearingLocationToWaypoint = LocationHelper.HeadingBetweenTwoGPSLocations(to, waypoint.GPSLocation); double delta = LocationHelper.DeltaOfVehicleToLaneDirection(vehicleBearing, bearingLocationToWaypoint); waypoint.angleDiff = Math.Abs(delta);//Make positive waypoint.distance = Distance.CalculateDistanceBetween2PointsKMs(to.Latitude, to.Longitude, waypoint.GPSLocation.Latitude, waypoint.GPSLocation.Longitude); } var sortedByBearingAndDistance = listOfWaypoints.OrderBy(wp => wp.distance) .ThenBy(wp => wp.angleDiff) .Where(wp => wp.angleDiff >= -50 && wp.angleDiff <= 50 && wp.distance <= 1.0); if (sortedByBearingAndDistance != null && sortedByBearingAndDistance.Count() > waypointIndex) { var tn = sortedByBearingAndDistance.ToList()[waypointIndex]; var pm = sortedMAPPoints.Find(mp => mp.name == tn.ID); nearestMAPPlacemark = pm; } } else { // No valid method chosen throw new Exception("Waypoint Detection Method not properly set."); } } return(nearestMAPPlacemark); }
private async void SubmitPlace() { try { UserDialogs.Instance.Loading(title: "Add place...").Show(); var client = new HttpClient() { Timeout = TimeSpan.FromSeconds(30) }; var AuthService = DependencyService.Get <IAuthService>(); JObject jsonAuth = new JObject { { "login", AuthService.UserName }, { "password", AuthService.Password }, { "db", ServerAuth.DB } }; string imageBase64 = ""; if (imagefile != null) { byte[] imageBytes = await StorageHelper.LoadImage(imagefile.Path); imageBase64 = Convert.ToBase64String(imageBytes); } JObject jsonReview = new JObject { { "title", txtName.Text?.Trim() ?? "" }, { "text", txtContent.Text?.Trim() ?? "" }, { "image", imageBase64 }, { "rating", rating.Rating } }; var location = await LocationHelper.GetCurrentPosition(50); JObject jsonPlace = new JObject { { "name", txtName.Text?.Trim() ?? "" }, { "place_id", typePlace == null? "" : typePlace.id + "" }, { "latitude", location == null? 0 : location.Latitude }, { "longitude", location == null? 0 : location.Longitude } }; JObject jsonDataObject = new JObject { { "auth", jsonAuth }, { "review", jsonReview }, { "place", jsonPlace } }; JObject jsonData = new JObject { { "params", jsonDataObject } }; var data = jsonData.ToString(); var content = new StringContent(data, Encoding.UTF8, "application/json"); var response = await client.PostAsync(ApiUri.BASE_URL + ApiUri.CREATE_PLACE, content); string responseContent = await response.Content.ReadAsStringAsync(); if (response.StatusCode == HttpStatusCode.OK) { SuccessResponse successResponse = JsonConvert.DeserializeObject <SuccessResponse>(responseContent, App.DefaultSerializerSettings); if (successResponse != null && successResponse.Result != null) { if (successResponse.Result.Success) { DependencyService.Get <IToast>().LongAlert("Add new place success!"); await Navigation.PopAsync(true); if (this._updateResultListener != null) { this._updateResultListener.OnUpdate(true); } } else if (!string.IsNullOrWhiteSpace(successResponse.Result.Message)) { UserDialogs.Instance.Toast(new ToastConfig(successResponse.Result.Message)); } } else { Internal.ServerError(); } } else { Internal.ServerError(); } } catch (TaskCanceledException e) { UserDialogs.Instance.Toast(new ToastConfig("Bad Connection Error. Try Again")); } catch (Exception e) { Internal.ServerError(); } finally { UserDialogs.Instance.Loading().Hide(); } }
public void ShouldNotBeIdentitiedAsPostcode(string postcode) { Assert.IsFalse(LocationHelper.IsPostcode(postcode)); }
private Location TestLocation() { return(LocationHelper.Get()); }
//Get all model Zone2fifo qty from DB public static List <FGDailyReplenishment> GetAllModelsZoneQty(int zoneCode) { var query = (from model in db.ModelZoneMaps orderby model.Model descending select model); var updateModelZone1 = new List <ModelZoneMap>(); var result = new List <FGDailyReplenishment>(); Dictionary <string, int> duplicatedModel = new Dictionary <string, int>(); Dictionary <string, int> hashtable = new Dictionary <string, int>(); foreach (ModelZoneMap i in query) { if (duplicatedModel.ContainsKey(i.Model)) { continue; } else { duplicatedModel.Add(i.Model, 1); } var inventoryQty = (from inventory in db.InventoryIns where inventory.ModelNo.Equals(i.Model) group inventory by new { inventory.SN, inventory.Location } into g orderby g.FirstOrDefault().SN let item = (from ig in g orderby ig.SN select ig).FirstOrDefault() select item) ; foreach (var inventory in inventoryQty) { if (LocationHelper.MapZoneCode(inventory.Location) != zoneCode) { continue; } var daily = new FGDailyReplenishment(); daily.ModelNo = i.Model; daily.Description = i.FG; daily.Location = inventory.Location; daily.Qty += 1; if (daily.Location != null) { if (!hashtable.ContainsKey(daily.ModelNo + daily.Location)) { hashtable.Add(daily.ModelNo + daily.Location, daily.Qty); } else { daily.Qty = (int)hashtable[daily.ModelNo + daily.Location] + (int)daily.Qty; hashtable[daily.ModelNo + daily.Location] = daily.Qty; } } } } Dictionary <string, string> duplicated = new Dictionary <string, string>(); foreach (KeyValuePair <string, int> entry in hashtable) { var daily = new FGDailyReplenishment(); var key = (string)entry.Key; if (duplicated.ContainsKey(key.Substring(0, 6))) { continue; } duplicated.Add(key.Substring(0, 6), key.Substring(6)); daily.ModelNo = key.Substring(0, 6); daily.Location = key.Substring(6); daily.Qty = (int)entry.Value; result.Add(daily); } return(result); }
void Start() { InitComponents(); SendBirdClient.ChannelHandler channelHandler = new SendBirdClient.ChannelHandler(); channelHandler.OnMessageReceived = (BaseChannel channel, BaseMessage message) => { // Draw new messages if user is on the channel. if (currentChannel.Url == channel.Url) { if (message is UserMessage) { string text; text = UserMessageRichText((UserMessage)message); if (text.Contains("3dObject")) { string[] values = text.Split(','); Message1 obj = XMLSerializer.Deserialize(values[1]); Console.WriteLine("Text: " + values[1] + " Received obj World Position: x " + obj.transformX + " y: " + obj.transformY + " z: " + obj.transformZ); txtOpenChannelContent.text = txtOpenChannelContent.text + ("Text: " + values[1] + " Received obj Position: x " + obj.transformX + " y: " + obj.transformY + " z: " + obj.transformZ + "\n"); Vector3 targetPos; targetPos.x = obj.transformX; targetPos.y = obj.transformY; targetPos.z = obj.transformZ; Vector3 recObjPos = LocationHelper.calculatePosition(locationManager.getOrigWorldPosition(), targetPos); Console.WriteLine("\n\nReceived obj calculated Position: x " + recObjPos.x + " y: " + recObjPos.y + " z: " + recObjPos.z); GameObject clone = Instantiate(prefabObject, recObjPos, Quaternion.identity); } if (channel.IsOpenChannel()) { txtOpenChannelContent.text = txtOpenChannelContent.text + (UserMessageRichText((UserMessage)message) + "\n"); } else { txtGroupChannelContent.text = txtGroupChannelContent.text + (UserMessageRichText((UserMessage)message) + "\n"); Console.WriteLine(message.ToString()); } } else if (message is FileMessage) { if (channel.IsOpenChannel()) { txtOpenChannelContent.text = txtOpenChannelContent.text + (FileMessageRichText((FileMessage)message) + "\n"); } else { txtGroupChannelContent.text = txtGroupChannelContent.text + (FileMessageRichText((FileMessage)message) + "\n"); } } else if (message is AdminMessage) { if (channel.IsOpenChannel()) { txtOpenChannelContent.text = txtOpenChannelContent.text + (AdminMessageRichText((AdminMessage)message) + "\n"); } else { txtGroupChannelContent.text = txtGroupChannelContent.text + (AdminMessageRichText((AdminMessage)message) + "\n"); } } ScrollToBottom(); } }; SendBirdClient.AddChannelHandler("default", channelHandler); }