Ejemplo n.º 1
0
        private float[] GetPointOnMap(Coordinate location)
        {
            float topY = 1 / horizontalRes * verticalRes;

            Coordinate botLeft  = new Coordinate(Constants.MAP_MIN_LATITUDE, Constants.MAP_MIN_LONGITUDE);
            Coordinate botRight = new Coordinate(Constants.MAP_MIN_LATITUDE, Constants.MAP_MAX_LONGITUDE);
            Coordinate topLeft  = new Coordinate(Constants.MAP_MAX_LATITUDE, Constants.MAP_MIN_LONGITUDE);

            float sizeX = (float)Coordinate.CalcDist(botLeft, botRight);
            float sizeY = (float)Coordinate.CalcDist(botLeft, topLeft);

            float scaleX = 1f / sizeX;
            float scaleY = topY / sizeY;

            float distX = (float)Coordinate.CalcDist(botLeft, new Coordinate(botLeft.Latitude, location.Longitude)) * scaleX;
            float distY = (float)Coordinate.CalcDist(botLeft, new Coordinate(location.Latitude, botLeft.Longitude)) * scaleY;

            return(new float[] { distX, distY });
        }
Ejemplo n.º 2
0
        private List <vtkActor> DrawDirection(SortedSet <Coordinate> coordinates, float yOffset, Coordinate start, Coordinate end)
        {
            DateTime endDate = this.startDate.AddMinutes(this.step);
            SortedSet <Coordinate> subset = coordinates.GetViewBetween(new Coordinate(this.startDate), new Coordinate(endDate));

            SortedSet <Coordinate> noDuplicates = new SortedSet <Coordinate>(new ByDist(start));

            foreach (Coordinate coord in subset)
            {
                bool insert = true;
                foreach (Coordinate coord2 in noDuplicates)
                {
                    if (coord.VehicleID.Equals(coord2.VehicleID))
                    {
                        insert = false;
                        break;
                    }
                }

                if (insert)
                {
                    noDuplicates.Add(coord);
                }
            }

            double routeLength = Coordinate.CalcDist(start, end);
            double scale       = Constants.TUBE_SIZE / routeLength;
            float  curX        = Constants.TUBE_START_X;


            float averageDist         = Constants.TUBE_SIZE / noDuplicates.Count;
            float maxAcceptableDist   = averageDist * (1 + Constants.ACCEPTABLE_DIST_SKEW);
            float minAcceptableDist   = averageDist * (1 - Constants.ACCEPTABLE_DIST_SKEW);
            float maxUnreasonableDist = averageDist * (1 + Constants.GRAVE_DIST_SKEW);
            float minUnreasonableDist = averageDist * (1 - Constants.GRAVE_DIST_SKEW);

            List <vtkActor> actors = new List <vtkActor>();

            bool first = true;

            foreach (Coordinate coord in noDuplicates)
            {
                double distToOrigin = Coordinate.CalcDist(start, coord) * scale;
                double size         = Math.Abs(curX - (Constants.TUBE_START_X + distToOrigin));

                size = Math.Min(Constants.TUBE_START_X + Constants.TUBE_SIZE - curX, size);
                double deltaY = (size - averageDist);

                //Bounds deltaY to upper and lower limits
                deltaY = Math.Min(deltaY, Constants.TUBE_MAX_DELTA_Y);
                deltaY = Math.Max(deltaY, -Constants.TUBE_MAX_DELTA_Y);

                Color color;

                color = Color.GetColorFromPalette((float)size, minUnreasonableDist, maxUnreasonableDist);
                if (size > averageDist)
                {
                    color = Color.GetColorFromPalette((float)size, averageDist, maxUnreasonableDist);
                }
                else
                {
                    color = Color.GetColorFromPalette(-(float)size, -averageDist, -minUnreasonableDist);
                }

                if (first)
                {
                    first  = false;
                    color  = Color.GRAY;
                    deltaY = 0;
                }
                //else
                //{
                //				if (size > maxUnreasonableDist || size < minUnreasonableDist)
                //								color = Color.colorPalette[0];
                //				else if (size > maxAcceptableDist || size < minAcceptableDist)
                //								color = Color.colorPalette[3];
                //				else
                //								color = Color.colorPalette[6];
                //}

                actors.Add(this.DrawLineSector(curX, yOffset, (float)size, color, (float)deltaY));
                actors.Add(this.DrawIndicatorLine(curX, yOffset));
                curX = Constants.TUBE_START_X + (float)distToOrigin;
            }
            {
                double size = (Constants.TUBE_START_X + Constants.TUBE_SIZE) - curX;

                actors.Add(this.DrawLineSector(curX, yOffset, (float)size, Color.GRAY, 0f));
                actors.Add(this.DrawIndicatorLine(curX, yOffset));

                curX = (Constants.TUBE_START_X + Constants.TUBE_SIZE);
                actors.Add(this.DrawIndicatorLine(curX, yOffset));
            }

            return(actors);
        }