Exemple #1
0
        private List <TracedVertex> IntersectWithRectangle(MapRectangle mapWindow)
        {
            RenderDebug renderDebug = IntersectWithRectangleDebug(mapWindow);

            return(renderDebug.FinalClipRegion);
        }
Exemple #2
0
        public RenderDebug IntersectWithRectangleDebug(MapRectangle mapWindow)
        {
            RenderDebug renderDebug = new RenderDebug();

            renderDebug.IntersectedVertexList = new List <TracedVertex>();
            List <TracedVertex> list = new List <TracedVertex>();
            int num = 0;

            foreach (LatLon current in vertexList)
            {
                list.Add(new TracedVertex(num, current));
                num++;
            }

            TracedVertex tracedVertex = list[list.Count - 1];

            foreach (TracedVertex current2 in list)
            {
                ParametricLine parametricLine            = new ParametricLine(tracedVertex.position, current2.position);
                List <ParametricLine.Intersection> list2 = new List <ParametricLine.Intersection>();
                list2.Add(parametricLine.LatitudeIntersection(mapWindow.lat0));
                list2.Add(parametricLine.LatitudeIntersection(mapWindow.lat1));
                list2.Add(parametricLine.LongitudeIntersection(mapWindow.lon0));
                list2.Add(parametricLine.LongitudeIntersection(mapWindow.lon1));
                list2.Sort();
                foreach (ParametricLine.Intersection current3 in list2)
                {
                    if (!current3.IsParallel && current3.t > 0.0 && current3.t < 1.0)
                    {
                        LatLon position = parametricLine.t(current3.t);
                        renderDebug.IntersectedVertexList.Add(new TracedVertex(tracedVertex.originalIndex, position));
                    }
                }

                renderDebug.IntersectedVertexList.Add(current2);
                tracedVertex = current2;
            }

            double val;
            double val2;

            if (mapWindow.lat1 > mapWindow.lat0)
            {
                val  = mapWindow.lat0;
                val2 = mapWindow.lat1;
            }
            else
            {
                val  = mapWindow.lat1;
                val2 = mapWindow.lat0;
            }

            double val3;
            double val4;

            if (mapWindow.lon1 > mapWindow.lon0)
            {
                val3 = mapWindow.lon0;
                val4 = mapWindow.lon1;
            }
            else
            {
                val3 = mapWindow.lon1;
                val4 = mapWindow.lon0;
            }

            renderDebug.FinalClipRegion = new List <TracedVertex>();
            tracedVertex = null;
            foreach (TracedVertex current4 in renderDebug.IntersectedVertexList)
            {
                LatLon position2 = current4.position;
                LatLon position3 = new LatLon(Math.Max(val, Math.Min(position2.lat, val2)),
                                              Math.Max(val3, Math.Min(position2.lon, val4)));
                TracedVertex tracedVertex2 = new TracedVertex(current4.originalIndex, position3);
                if (tracedVertex == null || tracedVertex.position.lat != tracedVertex2.position.lat ||
                    tracedVertex.position.lon != tracedVertex2.position.lon)
                {
                    renderDebug.FinalClipRegion.Add(tracedVertex2);
                }

                tracedVertex = tracedVertex2;
            }

            return(renderDebug);
        }
		public RenderDebug IntersectWithRectangleDebug(MapRectangle mapWindow)
		{
			RenderDebug renderDebug = new RenderDebug();
			renderDebug.IntersectedVertexList = new List<TracedVertex>();
			List<TracedVertex> list = new List<TracedVertex>();
			int num = 0;
			foreach (LatLon current in this.vertexList)
			{
				list.Add(new TracedVertex(num, current));
				num++;
			}
			TracedVertex tracedVertex = list[list.Count - 1];
			foreach (TracedVertex current2 in list)
			{
				ParametricLine parametricLine = new ParametricLine(tracedVertex.position, current2.position);
				List<ParametricLine.Intersection> list2 = new List<ParametricLine.Intersection>();
				list2.Add(parametricLine.LatitudeIntersection(mapWindow.lat0));
				list2.Add(parametricLine.LatitudeIntersection(mapWindow.lat1));
				list2.Add(parametricLine.LongitudeIntersection(mapWindow.lon0));
				list2.Add(parametricLine.LongitudeIntersection(mapWindow.lon1));
				list2.Sort();
				foreach (ParametricLine.Intersection current3 in list2)
				{
					if (!current3.IsParallel && current3.t > 0.0 && current3.t < 1.0)
					{
						LatLon position = parametricLine.t(current3.t);
						renderDebug.IntersectedVertexList.Add(new TracedVertex(tracedVertex.originalIndex, position));
					}
				}
				renderDebug.IntersectedVertexList.Add(current2);
				tracedVertex = current2;
			}
			double val;
			double val2;
			if (mapWindow.lat1 > mapWindow.lat0)
			{
				val = mapWindow.lat0;
				val2 = mapWindow.lat1;
			}
			else
			{
				val = mapWindow.lat1;
				val2 = mapWindow.lat0;
			}
			double val3;
			double val4;
			if (mapWindow.lon1 > mapWindow.lon0)
			{
				val3 = mapWindow.lon0;
				val4 = mapWindow.lon1;
			}
			else
			{
				val3 = mapWindow.lon1;
				val4 = mapWindow.lon0;
			}
			renderDebug.FinalClipRegion = new List<TracedVertex>();
			tracedVertex = null;
			foreach (TracedVertex current4 in renderDebug.IntersectedVertexList)
			{
				LatLon position2 = current4.position;
				LatLon position3 = new LatLon(Math.Max(val, Math.Min(position2.lat, val2)), Math.Max(val3, Math.Min(position2.lon, val4)));
				TracedVertex tracedVertex2 = new TracedVertex(current4.originalIndex, position3);
				if (tracedVertex == null || tracedVertex.position.lat != tracedVertex2.position.lat || tracedVertex.position.lon != tracedVertex2.position.lon)
				{
					renderDebug.FinalClipRegion.Add(tracedVertex2);
				}
				tracedVertex = tracedVertex2;
			}
			return renderDebug;
		}