示例#1
0
        public IEnumerator LanguageEnglish()
        {
            MapMatchingResource resource = new MapMatchingResource();

            resource.Coordinates = new Vector2d[]
            {
                new Vector2d(48.1974721043879, 16.36202484369278),
                new Vector2d(48.197922645046546, 16.36285901069641)
            };
            //set Steps to true to get turn-by-turn-instructions
            resource.Steps = true;
            //no language parameter needed: English is default

            MapMatcher          mapMatcher       = new MapMatcher(_fs, _timeout);
            MapMatchingResponse matchingResponse = null;

            mapMatcher.Match(
                resource,
                (MapMatchingResponse response) =>
            {
                matchingResponse = response;
            }
                );

            IEnumerator enumerator = _fs.WaitForAllRequests();

            while (enumerator.MoveNext())
            {
                yield return(null);
            }

            commonBasicResponseAsserts(matchingResponse);

            Directions.Step step0 = matchingResponse.Matchings[0].Legs[0].Steps[0];
            Directions.Step step1 = matchingResponse.Matchings[0].Legs[0].Steps[1];
            Assert.AreEqual("Head northeast on Rechte Wienzeile (B1)", step0.Maneuver.Instruction, "Step[0]:Instruction not as expected");
            Assert.AreEqual("You have arrived at your destination", step1.Maneuver.Instruction, "Step[1]:Instruction not as expected");
        }
示例#2
0
        public IEnumerator NoSegment()
        {
            MapMatchingResource resource = new MapMatchingResource();

            resource.Coordinates = new Vector2d[]
            {
                new Vector2d(48.28585, 16.55267),
                new Vector2d(48.28933, 16.55211)
            };

            MapMatcher          mapMatcher       = new MapMatcher(_fs, _timeout);
            MapMatchingResponse matchingResponse = null;

            mapMatcher.Match(
                resource,
                (MapMatchingResponse response) =>
            {
                matchingResponse = response;
            }
                );

            IEnumerator enumerator = _fs.WaitForAllRequests();

            while (enumerator.MoveNext())
            {
                yield return(null);
            }

            Assert.IsNotNull(matchingResponse, "Matching response is NULL");
            Assert.IsFalse(matchingResponse.HasRequestError, "Error during web request");
            Assert.AreEqual("NoSegment", matchingResponse.Code, "Matching code != 'NoSegment'");
            Assert.AreEqual("Could not find a matching segment for input coordinates", matchingResponse.Message, "Message not as expected");

            Assert.IsNull(matchingResponse.Tracepoints, "Tracepoints are not NULL");

            Assert.IsNotNull(matchingResponse.Matchings, "Matchings are NULL");
            Assert.AreEqual(0, matchingResponse.Matchings.Length, "Wrong number of matchings");
        }
示例#3
0
        public IEnumerator LanguageGerman()
        {
            MapMatchingResource resource = new MapMatchingResource();

            resource.Coordinates = new Vector2d[]
            {
                new Vector2d(48.1974721043879, 16.36202484369278),
                new Vector2d(48.197922645046546, 16.36285901069641)
            };
            //set Steps to true to get turn-by-turn-instructions
            resource.Steps    = true;
            resource.Language = InstructionLanguages.German;

            MapMatcher          mapMatcher       = new MapMatcher(_fs, _timeout);
            MapMatchingResponse matchingResponse = null;

            mapMatcher.Match(
                resource,
                (MapMatchingResponse response) =>
            {
                matchingResponse = response;
            }
                );

            IEnumerator enumerator = _fs.WaitForAllRequests();

            while (enumerator.MoveNext())
            {
                yield return(null);
            }

            commonBasicResponseAsserts(matchingResponse);

            Directions.Step step0 = matchingResponse.Matchings[0].Legs[0].Steps[0];
            Directions.Step step1 = matchingResponse.Matchings[0].Legs[0].Steps[1];
            Assert.AreEqual("Fahren Sie Richtung Nordosten auf Rechte Wienzeile (B1)", step0.Maneuver.Instruction, "Step[0]:Instruction not as expected");
            Assert.AreEqual("Sie haben Ihr Ziel erreicht", step1.Maneuver.Instruction, "Step[1]:Instruction not as expected");
        }
		public IEnumerator Annotation()
		{

			MapMatchingResource resource = new MapMatchingResource();
			resource.Coordinates = new Vector2d[]
			{
				new Vector2d(48.1974721043879,16.36202484369278),
				new Vector2d(48.197922645046546,16.36285901069641)
			};
			//need to pass 'Overview.Full' to get 'Congestion'
			resource.Overview = Overview.Full;
			resource.Annotations = Annotations.Distance | Annotations.Duration | Annotations.Speed | Annotations.Congestion;

			MapMatcher mapMatcher = new MapMatcher(_fs, _timeout);
			MapMatchingResponse matchingResponse = null;
			mapMatcher.Match(
				resource,
				(MapMatchingResponse response) =>
				{
					matchingResponse = response;
				}
			);

			IEnumerator enumerator = _fs.WaitForAllRequests();
			while (enumerator.MoveNext()) { yield return null; }

			commonBasicResponseAsserts(matchingResponse);

			Directions.Leg leg = matchingResponse.Matchings[0].Legs[0];
			Assert.IsNotNull(leg.Annotation, "Annotation is NULL");
			Assert.IsNotNull(leg.Annotation.Distance, "Distance is NULL");
			Assert.IsNotNull(leg.Annotation.Duration, "Duration is NULL");
			Assert.IsNotNull(leg.Annotation.Speed, "Speed is NULL");
			Assert.IsNotNull(leg.Annotation.Congestion, "Congestion is NULL");

			Assert.GreaterOrEqual(leg.Annotation.Distance[1], 42, "Annotation has wrong distnce");
		}
		public IEnumerator CoordinatesNull()
		{

			MapMatchingResource resource = new MapMatchingResource();
			Assert.Throws(
				typeof(System.Exception)
				, () => resource.Coordinates = null
				, "MapMatchingResource did not throw when setting null coordinates"
			);

			yield return null;


			MapMatcher mapMatcher = new MapMatcher(_fs, _timeout);
			MapMatchingResponse matchingResponse = null;

			Assert.Throws(
				typeof(System.Exception)
				, () =>
				{
					mapMatcher.Match(
						resource,
						(MapMatchingResponse response) =>
						{
							matchingResponse = response;
						}
					);
				}
				, "MapMatcher.Match did not throw with null coordinates"
			);

			IEnumerator enumerator = _fs.WaitForAllRequests();
			while (enumerator.MoveNext()) { yield return null; }

			Assert.IsNull(matchingResponse, "Matching response was expected to be null");
		}
		public IEnumerator AlternativesWithSteps()
		{

			MapMatchingResource resource = new MapMatchingResource();
			resource.Coordinates = new Vector2d[]
			{
				new Vector2d(48.31331,16.49062),
				new Vector2d(48.31638,16.49243)
			};
			resource.Radiuses = new uint[] { 10, 30 };
			resource.Steps = true;

			MapMatcher mapMatcher = new MapMatcher(_fs, _timeout);
			MapMatchingResponse matchingResponse = null;
			mapMatcher.Match(
				resource,
				(MapMatchingResponse response) =>
				{
					matchingResponse = response;
				}
			);

			IEnumerator enumerator = _fs.WaitForAllRequests();
			while (enumerator.MoveNext()) { yield return null; }

			commonBasicResponseAsserts(matchingResponse);

			Assert.AreEqual(2, matchingResponse.Tracepoints.Length, "Wrong number of tracepoints");
			Assert.GreaterOrEqual(2, matchingResponse.Tracepoints[0].AlternativesCount, "Wrong 'AlternativesCount' for Tracepoint[0]");
			Assert.GreaterOrEqual(19, matchingResponse.Tracepoints[1].AlternativesCount, "Wrong 'AlternativesCount' for Tracepoint[1]");

			Assert.IsNotNull(matchingResponse.Matchings[0].Legs[0].Steps, "Steps are NULL");
			Assert.AreEqual(2, matchingResponse.Matchings[0].Legs[0].Steps.Count, "Wrong number of steps");
			Assert.IsNotNull(matchingResponse.Matchings[0].Legs[0].Steps[0].Intersections, "Intersections are NULL");
			Assert.AreEqual(3, matchingResponse.Matchings[0].Legs[0].Steps[0].Intersections.Count, "Wrong number of intersections");
		}