void OnTriggerEnter(Collider other) { DirectionInfo directionInfo = other.GetComponent <DirectionInfo>(); if (directionInfo != null) { directionToGo = directionInfo.direction; } }
private DirectionInfo getDirection(LocationInfo from, LocationInfo to) { DirectionInfo direction = new DirectionInfo(); string origin = from.address, destination = to.address; if (origin == "" || origin == null) { origin = from.lat + "," + from.lng; } if (destination == "" || destination == null) { destination = to.lat + "," + to.lng; } var request = WebRequest.Create("https://maps.googleapis.com/maps/api/directions/json?origin=" + origin + "&destination=" + destination + "&key=" + API_Key); request.ContentType = "application/json; charset=utf-8"; string text; var response = (HttpWebResponse)request.GetResponse(); using (var sr = new StreamReader(response.GetResponseStream())) { text = sr.ReadToEnd(); JavaScriptSerializer js = new JavaScriptSerializer(); JsonDirectionInfo jsoninfo = new JsonDirectionInfo(text); if (jsoninfo.status != "OK") { ViewBag.Error = "Error " + jsoninfo.status; return(null); } if (jsoninfo.routes.Length == 0) { ViewBag.Error = "No direction."; return(null); } //string userID = Session["username"].ToString(); dynamic d = JObject.Parse(text); var directions_legs = d.routes[0].legs; direction.distance_text = directions_legs[0].distance.text; direction.distance_value = directions_legs[0].distance.value; direction.start.address = directions_legs[0].start_address; direction.start.lat = directions_legs[0].start_location.lat; direction.start.lng = directions_legs[0].start_location.lng; direction.end.lat = directions_legs[0].end_location.lat; direction.end.lng = directions_legs[0].end_location.lng; direction.end.address = directions_legs[0].end_address; } return(direction); }
private static TemplateInfo GetTemplateInfo(string templateName, DirectionInfo directionInfo) { foreach (TemplateInfo templateInfo in directionInfo.extraInfo.templates) { if (templateName == templateInfo.template) { return(templateInfo); } } return(null); }
public async Task <Guid> CreateDirection(DirectionInfo directionInfo) { var direction = new Direction() { Id = Guid.NewGuid(), DirectionCode = directionInfo.DirectionCode, Name = directionInfo.Name }; await _dbContext.Directions.AddAsync(direction); await _dbContext.SaveChangesAsync(); return(direction.Id); }
private void OnRefreshUserMenu(object data) { int num = (int)(1 + allowedDirection) % directionInfos.Length; DirectionInfo directionInfo = directionInfos[num]; UserMenu userMenu = Game.Instance.userMenu; GameObject gameObject = base.gameObject; string iconName = directionInfo.iconName; string name = directionInfo.name; System.Action on_click = OnChangeWorkableDirection; string tooltip = directionInfo.tooltip; userMenu.AddButton(gameObject, new KIconButtonMenu.ButtonInfo(iconName, name, on_click, Action.NumActions, null, null, null, tooltip, true), 0f); }
public JsonResult GetDirection() { LocationInfo from = new LocationInfo(); from.address = Session["From"].ToString(); LocationInfo to = new LocationInfo(); to.address = Session["To"].ToString(); DirectionInfo v = getDirection(from, to); Session["direction"] = v; return(new JsonResult { Data = v, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
/// <summary> /// コンストラクタ /// </summary> public MouseGesture() { isActive = false; EnableDragGesture = true; AllowHoldClick = true; stroke = ""; directionInfo = new DirectionInfo[4]; for (int i = 0; i < 4; i++) { directionInfo[i] = new DirectionInfo(); } Range = 15; // フックプロシージャ hookCallback += HookProc; }
//private readonly string _webservicePath; //private readonly string _userName; //private readonly string _password; //public SoftissimoTranslation(string webservicePath, string userName, string password) //{ // _webservicePath = webservicePath; // _userName = userName; // _password = password; //} #region Implementation of IAutomaticTranslation public string TranslateText(string toTranslate, string sourceLang, string destinationLang, string profileId, TranslationUserAccount translationUserAccount, bool isHtml) { string toTranslateOriginal = toTranslate; try { sourceLang = ConvertLanguageCode2LettersTo3Letters(sourceLang); destinationLang = ConvertLanguageCode2LettersTo3Letters(destinationLang); if (string.IsNullOrEmpty(profileId)) { profileId = "General"; } using (Translator webService = GetWebService(translationUserAccount.Login, translationUserAccount.Password, translationUserAccount.Url)) { DirectionInfo directionInfo = GetDirectionInfo(webService, sourceLang, destinationLang); bool truncated; long wordsLeft; if (isHtml) { byte[] encbuff = Encoding.UTF8.GetBytes(toTranslate); toTranslate = Convert.ToBase64String(encbuff); string result = webService.TranslateHTML(toTranslate, directionInfo, GetTemplateInfo(profileId, directionInfo), string.Empty, false, null, "utf-8", out truncated, out wordsLeft); byte[] decodedBytes = Convert.FromBase64String(result); result = Encoding.UTF8.GetString(decodedBytes); return(result); } else { return(webService.TranslateText(toTranslate, directionInfo, GetTemplateInfo(profileId, directionInfo), null, out truncated, out wordsLeft)); } } } catch (Exception e) { Utilities.LogException("TranslateText", e, EventLogEntryType.Warning); return(toTranslateOriginal); } }
private void LoadDirectionInfoFromFile() { try { string FileName; FileName = direction_file; FileStream fs = new FileStream(FileName, FileMode.Open, FileAccess.Read); XmlSerializer serializer = new XmlSerializer(typeof(DirectionInfo)); m_DirectionInfo = (DirectionInfo)serializer.Deserialize(fs); fs.Close(); DrawNewLocation(); } catch (Exception) { this.lblDirectionStatus.Text = "selected file can not be loaded!!"; direction_file = null; } }
public List <string> GetTemplates(string source3LettersLang, string destination3LettersLang, string url, string login, string password) { var templates = new List <string>(); using (Translator webService = GetWebService(login, password, url))//(this._userName, this._password, this._webservicePath)) { DirectionInfo directionInfo = GetDirectionInfo(webService, source3LettersLang, destination3LettersLang); if (directionInfo != null) { foreach (TemplateInfo templateInfo in directionInfo.extraInfo.templates) { templates.Add(templateInfo.template); } } } return(templates); }
private void SetAllowedDirection(WorkableReactable.AllowedDirection new_direction) { KBatchedAnimController component = GetComponent <KBatchedAnimController>(); DirectionInfo directionInfo = directionInfos[(int)new_direction]; bool flag = directionInfo.allowLeft && directionInfo.allowRight; bool is_visible = !flag && directionInfo.allowLeft; bool is_visible2 = !flag && directionInfo.allowRight; component.SetSymbolVisiblity("arrow2", flag); component.SetSymbolVisiblity("arrow_left", is_visible); component.SetSymbolVisiblity("arrow_right", is_visible2); if (new_direction != allowedDirection) { allowedDirection = new_direction; if (onDirectionChanged != null) { onDirectionChanged(allowedDirection); } } }
public static Vector3 TotalDirection(List <DriverAssistant> assists) { Vector3 sumDir = Vector3.zero; float sumWeight = 0f; foreach (DriverAssistant assist in assists) { DirectionInfo info = assist.CurTargetDir(); info.weight -= Mathf.Max(0f, sumWeight + info.weight - 1f); sumDir += info.dir * info.weight; sumWeight += info.weight; if (sumWeight > 0.99f) { break; } } return(sumDir.normalized); }
public ActionResult findDriver(Trip model) { if (Session["username"] == null) { return(RedirectToAction("Login", "Account")); } ListDriverNearLocation = new List <DriverInfomation>(); //From = getLocationFromAddress(model.tripFrom); //To = getLocationFromAddress(model.tripTo); LocationInfo from = new LocationInfo(), to = new LocationInfo(); from.address = model.tripFrom; to.address = model.tripTo; Session["From"] = model.tripFrom; Session["To"] = model.tripTo; DirectionInfo direction = getDirection(from, to); return(View()); }
public DirectionInfo calcTargetDir() { Car car = driver.car; List <Circle> obstacles = driver.Obstacles; DirectionInfo info = obstacles .Where(c => { c.CachedDist = Vector3.Distance(car.Pos, c.Center) - c.Radius; return(c.CachedDist < outOfRangeThreshold); }) .Aggregate(new DirectionInfo(Vector3.zero, 0f), (d, c) => { Vector3 relPos = car.Pos - c.Center; Vector3 tgtDir = relPos.normalized; float dot = Mathf.Max(0f, dotOffset - Vector3.Dot(tgtDir, car.Dir)); float weight = dot * coefPriorityWeight / c.CachedDist; return(new DirectionInfo(d.dir + tgtDir, d.weight + weight)); }); info.dir = info.dir.normalized; return(info.weight > 0.01f ? info : DefaultTargetDir()); }
private List <DriverInfomation> getNearDiver() { LocationInfo from = new LocationInfo(); from.address = Session["From"].ToString(); ListDriverNearLocation = new List <DriverInfomation>(); List <DriverInfomation> lstAllDriver = getAllDriver(); foreach (DriverInfomation driver in lstAllDriver) { LocationInfo lc_diver = new LocationInfo(); lc_diver.lat = driver.latitude; lc_diver.lng = driver.longtitude; DirectionInfo direc = getDirection(lc_diver, from); if (direc.distance_value <= 5000) { ListDriverNearLocation.Add(driver); } } return(ListDriverNearLocation); }
/// <summary> /// Returns a very basic read based on the abstract alignment. We don't yet /// </summary> /// <returns></returns> public Read ToRead() { var cigar = new CigarAlignment(Cigar); const byte qualityForAll = 30; var readLength = (int)cigar.GetReadSpan(); var alignment = new BamAlignment { CigarData = cigar, Position = Position - 1, RefID = 1, Bases = Directions.EndsWith("F") ? new string('A', readLength) : new string('T', readLength), Qualities = Enumerable.Repeat(qualityForAll, readLength).ToArray() }; alignment.MapQuality = 30; var read = new Read("chr1", alignment); var di = new DirectionInfo(Directions); read.SequencedBaseDirectionMap = di.ToDirectionMap(); return(read); }
public string GetFareEstimateDisplay(DirectionInfo direction) { var fareEstimate = _localize[_appSettings.Data.DestinationIsRequired ? "NoFareTextIfDestinationIsRequired" : "NoFareText"]; if (direction.ValidationResult != null && direction.ValidationResult.HasError) { fareEstimate = direction.ValidationResult.Message; } else if (direction.Distance.HasValue) { var willShowFare = direction.Price.HasValue && direction.Price.Value > 0; if (willShowFare) { var isOverMaxFare = direction.Price.Value > _appSettings.Data.MaxFareEstimate; var formattedCurrency = CultureProvider.FormatCurrency(direction.Price.Value); fareEstimate = String.Format( CultureProvider.CultureInfo, _localize[isOverMaxFare ? "EstimatePriceOver100" : "EstimatePriceFormat"], formattedCurrency, direction.FormattedDistance); } else { fareEstimate = _localize["EstimatedFareNotAvailable"]; } } return(fareEstimate); }
public object Get(DirectionsRequest request) { if (!request.OriginLat.HasValue || !request.OriginLng.HasValue) { throw new HttpError(HttpStatusCode.BadRequest, "MissingPosition", "An original longitude and latitude is required"); } var marketTariff = GetMarketTariff(request.OriginLat.Value, request.OriginLng.Value); double originLat = request.OriginLat.HasValue ? request.OriginLat.Value : 0.0; double originLng = request.OriginLng.HasValue ? request.OriginLng.Value : 0.0; double destLat = request.DestinationLat.HasValue ? request.DestinationLat.Value : 0.0; double destLng = request.DestinationLng.HasValue ? request.DestinationLng.Value : 0.0; var result = _client.GetDirection(originLat, originLng, destLat, destLng, request.VehicleTypeId, request.Date, false, marketTariff); var directionInfo = new DirectionInfo { Distance = result.Distance, FormattedDistance = result.FormattedDistance, Price = result.Price, FormattedPrice = result.FormattedPrice, TripDurationInSeconds = (int?)result.Duration }; if (_serverSettings.ServerData.ShowEta && request.OriginLat.HasValue && request.OriginLng.HasValue) { try { // Get available vehicles var availableVehicles = _vehicleService.Post(new AvailableVehicles { Latitude = request.OriginLat.Value, Longitude = request.OriginLng.Value, VehicleTypeId = null }).ToArray(); // Get nearest available vehicle var nearestAvailableVehicle = GetNearestAvailableVehicle(request.OriginLat.Value, request.OriginLng.Value, availableVehicles); if (nearestAvailableVehicle != null) { // Get eta var etaDirectionInfo = _client.GetEta(nearestAvailableVehicle.Latitude, nearestAvailableVehicle.Longitude, request.OriginLat.Value, request.OriginLng.Value); directionInfo.EtaFormattedDistance = etaDirectionInfo.FormattedDistance; directionInfo.EtaDuration = (int?)etaDirectionInfo.Duration; } } catch (Exception ex) { _logger.LogMessage("Direction Service: Error trying to get ETA: " + ex.Message, ex); } } return(directionInfo); }
private void btExtractDirectionInfo_Click(object sender, EventArgs e) { HtmlElement DirectionsSteps = webBrowser1.Document.GetElementById("tDirections"); if (DirectionsSteps == null) { MessageBox.Show("oops direction is not populated yet!!"); return; } label2.Text = "Loading... will take a while.."; Application.DoEvents(); SerializableList <DirectionStep> Steps = new SerializableList <DirectionStep>(); string description = ""; double lat = 0; double lng = 0; int PolyLineIndex = 0; foreach (HtmlElement InnerElement in DirectionsSteps.All) { if (InnerElement.GetAttribute("className") == "dStepDesc") { description = InnerElement.InnerText; } if (InnerElement.GetAttribute("className") == "dLat") { lat = double.Parse(InnerElement.InnerText); } if (InnerElement.GetAttribute("className") == "dLag") { lng = double.Parse(InnerElement.InnerText); } if (InnerElement.GetAttribute("className") == "dPolyLineIndex") { PolyLineIndex = int.Parse(InnerElement.InnerText); DirectionStep ds = new DirectionStep(new LatLng(lat, lng), description, PolyLineIndex); Steps.Add(ds); } } SerializableList <LatLng> Points = new SerializableList <LatLng>(); HtmlElement PathPoints = webBrowser1.Document.GetElementById("Points"); if (PathPoints == null) { MessageBox.Show("oops direction is not populated yet!!"); return; } foreach (HtmlElement InnerElement in PathPoints.All) { if (InnerElement.GetAttribute("className") == "pLat") { lat = double.Parse(InnerElement.InnerText); } if (InnerElement.GetAttribute("className") == "pLng") { lng = double.Parse(InnerElement.InnerText); Points.Add(new LatLng(lat, lng)); } } m_DirectionInfo = new DirectionInfo(key, Points, Steps); //m_DirectionInfo. label2.Text = "direction info loaded..."; }
public SpecialtiesAndCount GetSpecialtiesByDirection([FromBody] DirectionInfo directionInfo) => this.specialtyProvider.GetSpecialtiesByDirection(directionInfo);
public async Task <Guid> AddDirection([FromBody] DirectionInfo directionInfo) { return(await _directionsService.CreateDirection(directionInfo)); }
public async Task UpdateDirection([FromBody] DirectionInfo directionInfo, Guid directionGuid) { await _directionsService.UpdateDirection(directionInfo, directionGuid); }