/// <summary> /// Adds an edge to the vertex /// </summary> /// <returns>The edge.</returns> /// <param name="edge">The object to serialize</param> /// <param name="direction">The step specifiying the vertex to connect to</param> public EdgeQuery <From> AddEdge(IEdgeObject edge, DirectionStep direction) { var properties = JObject.FromObject(edge).ToObject <Dictionary <string, object> >(); properties.Remove(nameof(edge.EdgeLabel)); return(AddEdge(edge.EdgeLabel, direction).AddProperties(properties.Where(p => p.Value != null).ToDictionary(p => p.Key, p => p.Value))); }
private DirectionStep inputToDirection(Vector2 input) { inputAngle = (float)Math.Atan2(input.x, input.y); octant = (int)Math.Round(8 * inputAngle / (2 * Math.PI) + 8) % 8; tempDir = (DirectionStep)(Mathf.Pow(2f, octant)); return(tempDir); }
private void Setup_Test_Database(TestDatabase client) { client.Execute(VertexQuery.Create("one")).Wait(); client.Execute(VertexQuery.Create("two")).Wait(); client.Execute(VertexQuery.Create("three")).Wait(); client.Execute(VertexQuery.All().HasLabel("one").AddEdge("one_to_two", DirectionStep.To(VertexQuery.Find("two")))).Wait(); client.Execute(VertexQuery.All().HasLabel("two").AddEdge("two_to_three", DirectionStep.To(VertexQuery.Find("three")))).Wait(); }
public void Steps_SimplePath() { using (var client = TestDatabase.GetClient("simple_path")) { client.Execute(VertexQuery.Create("one")).Wait(); client.Execute(VertexQuery.Create("two")).Wait(); client.Execute(VertexQuery.Create("three")).Wait(); client.Execute(VertexQuery.All().HasLabel("one").AddEdge("to", DirectionStep.To(VertexQuery.Find("two")))).Wait(); client.Execute(VertexQuery.All().HasLabel("two").AddEdge("to", DirectionStep.To(VertexQuery.Find("three")))).Wait(); Assert.AreEqual(client.Execute(VertexQuery.All().HasLabel("one").Both().Both().Count()).Result.First(), 2L); Assert.AreEqual(client.Execute(VertexQuery.All().HasLabel("one").Both().Both().SimplePath().Count()).Result.First(), 1L); } }
public void Steps_Optional() { using (var client = TestDatabase.GetClient("optional")) { client.Execute(VertexQuery.Create("one")).Wait(); var subQuery = VertexQuery.All().CreateSubQuery().Out(); Assert.AreEqual(client.Execute(VertexQuery.All().Optional(subQuery)).Result.First().label, "one"); client.Execute(VertexQuery.Create("two")).Wait(); client.Execute(VertexQuery.All().HasLabel("one").AddEdge("to", DirectionStep.To(VertexQuery.Find("two")))).Wait(); Assert.AreEqual(client.Execute(VertexQuery.All().Optional(subQuery)).Result.First().label, "two"); } }
public void Steps_AddE() { using (var client = TestDatabase.GetClient("addE")) { // Setup var vertex1 = client.Execute(VertexQuery.Create("vertex1")).Result; var vertex2 = client.Execute(VertexQuery.Create("vertex2")).Result; // Test var query = VertexQuery.All().HasLabel("vertex1").AddEdge("edge1", DirectionStep.To(vertex2.First().id)); client.Execute(query).Wait(); // Verify Assert.AreEqual(client.Execute(VertexQuery.All().HasLabel("vertex1").Out()).Result.First().id, vertex2.First().id); } }
public void Steps_Where() { using (var client = TestDatabase.GetClient("where")) { client.Execute(VertexQuery.Create("one")).Wait(); client.Execute(VertexQuery.Create("two")).Wait(); client.Execute(VertexQuery.Create("three")).Wait(); client.Execute(VertexQuery.All().HasLabel("one").AddEdge("to", DirectionStep.To(VertexQuery.Find("two")))).Wait(); client.Execute(VertexQuery.All().HasLabel("two").AddEdge("to", DirectionStep.To(VertexQuery.Find("three")))).Wait(); var query = VertexQuery.All().HasLabel("one").As("a").Both().Both().Where(GraphPredicate.NotEqualTo("a")); var result = client.Execute(query).Result; Assert.AreEqual(result.Count(), 1); Assert.AreEqual(result.First().label, "three"); } }
public void Steps_Select() { using (var client = TestDatabase.GetClient("select")) { client.Execute(VertexQuery.Create("one")).Wait(); client.Execute(VertexQuery.Create("two")).Wait(); client.Execute(VertexQuery.All().HasLabel("one").AddEdge("to", DirectionStep.To(VertexQuery.Find("two")))).Wait(); var query = VertexQuery.All().As("a").Out().As("b").Select("a", "b"); var result = client.Execute(query).Result; Assert.IsTrue(result.First().ContainsKey("a")); Assert.IsTrue(result.First().ContainsKey("b")); } }
//Changing audioinfos list to a spread out one private void Awake() { fsis.footStep += EvaluateEvent; foreach (AudioInfo n in audioInfos) { DirectionStep tempTag = n.tag; if (tempTag == 0) { tempTag = (DirectionStep) ~0; } //If no tag has been given it will be used in all if (tempTag.HasFlag(DirectionStep.E)) { dirAudio[DirectionStep.E].Add(n); } if (tempTag.HasFlag(DirectionStep.N)) { dirAudio[DirectionStep.E].Add(n); } if (tempTag.HasFlag(DirectionStep.NE)) { dirAudio[DirectionStep.E].Add(n); } if (tempTag.HasFlag(DirectionStep.NW)) { dirAudio[DirectionStep.E].Add(n); } if (tempTag.HasFlag(DirectionStep.SE)) { dirAudio[DirectionStep.E].Add(n); } if (tempTag.HasFlag(DirectionStep.S)) { dirAudio[DirectionStep.E].Add(n); } if (tempTag.HasFlag(DirectionStep.SW)) { dirAudio[DirectionStep.E].Add(n); } } }
private static List<DirectionSteps> ParseDirectionResults(string result) { var directionStepsList = new List<DirectionSteps>(); var xmlDoc = new XmlDocument { InnerXml = result }; if (xmlDoc.HasChildNodes) { var directionsResponseNode = xmlDoc.SelectSingleNode("DirectionsResponse"); if (directionsResponseNode != null) { var statusNode = directionsResponseNode.SelectSingleNode("status"); if (statusNode != null && statusNode.InnerText.Equals("OK")) { var legs = directionsResponseNode.SelectNodes("route/leg"); foreach (XmlNode leg in legs) { int stepCount = 1; var stepNodes = leg.SelectNodes("step"); var steps = new List<DirectionStep>(); foreach (XmlNode stepNode in stepNodes) { var directionStep = new DirectionStep(); directionStep.Index = stepCount++; directionStep.Distance = stepNode.SelectSingleNode("distance/text").InnerText; directionStep.Duration = stepNode.SelectSingleNode("duration/text").InnerText; directionStep.Description = Regex.Replace(stepNode.SelectSingleNode("html_instructions").InnerText, "<[^<]+?>", ""); steps.Add(directionStep); } var directionSteps = new DirectionSteps(); directionSteps.OriginAddress = leg.SelectSingleNode("start_address").InnerText; directionSteps.DestinationAddress = leg.SelectSingleNode("end_address").InnerText; directionSteps.TotalDistance = leg.SelectSingleNode("distance/text").InnerText; directionSteps.TotalDuration = leg.SelectSingleNode("duration/text").InnerText; directionSteps.Steps = steps; directionStepsList.Add(directionSteps); } } } } return directionStepsList; }
public ActionResult GetDirections(string startPostCode, string endPostCode) { var xx = _googleDirectionsServiceClient.GetDirectionsBetweenPostcodesAsXml("AL6", "lu7"); IList <DirectionStep> steps = new List <DirectionStep>(); foreach (var route in xx.Routes) { foreach (var leg in route.Legs) { foreach (var step in leg.Steps) { var directionStep = new DirectionStep(); directionStep.Distance = step.Distance.Text; directionStep.Duration = step.Duration.Text; directionStep.HtmlText = step.HtmlDirections; steps.Add(directionStep); } } } return(View(steps)); }
public void Steps_ValueMap() { using (var client = TestDatabase.GetClient("valueMap")) { client.Execute(VertexQuery.Create("foo").AddProperty("age", 30)).Wait(); var vertexQuery = VertexQuery.All().ValueMap(); var vertexResult = client.Execute(vertexQuery).Result; Assert.AreEqual(vertexResult.Count(), 1); Assert.IsTrue(vertexResult.First().ContainsKey("age")); Assert.AreEqual(vertexResult.First()["age"].First(), 30L); client.Execute(VertexQuery.Create("bar")).Wait(); client.Execute(VertexQuery.All().HasLabel("foo").AddEdge("to", DirectionStep.To(VertexQuery.Find("bar"))).AddProperty("key", "value")).Wait(); var edgeQuery = VertexQuery.All().OutE().ValueMap(); var edgeResult = client.Execute(edgeQuery).Result; Assert.AreEqual(edgeResult.Count(), 1); Assert.IsTrue(edgeResult.First().ContainsKey("key")); Assert.AreEqual(edgeResult.First()["key"], "value"); } }
private void EvaluateEvent(DirectionStep direction, float strengh) { throw new NotImplementedException(); }
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..."; }
/// <summary> /// Adds an edge to the vertex /// </summary> /// <param name="label">The label of the new edge</param> /// <param name="direction">The step specifiying the vertex to connect to</param> /// <param name="properties">The properties to add to the new edge</param> public EdgeQuery <From> AddEdge(string label, DirectionStep direction, Dictionary <string, object> properties) { return(AddEdge(label, direction).AddProperties(properties)); }
/// <summary> /// Adds an edge to the vertex /// </summary> /// <param name="label">The label of the new edge</param> /// <param name="direction">The step specifiying the vertex to connect to</param> public EdgeQuery <From> AddEdge(string label, DirectionStep direction) { Steps.Add("addE('" + Sanitize(label) + "')"); Steps.Add(direction.ToString()); return(new EdgeQuery <From>(this)); }