Пример #1
0
        private List <SaveRoad.DictCross> findCrossesF(SaveRoad.DictCross[] cross, SaveRoad.RoadInfo current, MapGo.nyrqPosition p1, MapGo.nyrqPosition p2, double ascendingValue, getRoadCodeParameter codeF, getRoadOrderParameter orderF, getPercentParameter percentF)
        {
            var findCrosses = (from item in cross
                               where item.CrossState == 1 &&
                               codeF(item) == current.RoadCode &&
                               (orderF(item) + percentF(item)) * ascendingValue > (p1.roadOrder + p1.percent) * ascendingValue &&
                               (orderF(item) + percentF(item)) * ascendingValue < (p2.roadOrder + p2.percent) * ascendingValue
                               orderby(orderF(item) + percentF(item)) * ascendingValue ascending
                               select item).ToList();

            return(findCrosses);
        }
Пример #2
0
        private static double[] getRoadRectangle(SaveRoad.RoadInfo value, Dictionary <int, SaveRoad.RoadInfo> result)
        {
            double KofPointStretchFirstAndSecond = 1;
            double KofPointStretchThirdAndFourth = 1;

            if (value.CarInOpposeDirection == 0)
            {
                KofPointStretchFirstAndSecond = 0.1;
                KofPointStretchThirdAndFourth = 1.5;
            }

            double[] point1, point2, point3, point4;
            var      vec = new double[] { value.endLongitude - value.startLongitude, value.endLatitude - value.startLatitude };

            vec = setToOne(vec);
            System.Numerics.Complex c = new System.Numerics.Complex(vec[0], vec[1]);
            if (!result.ContainsKey(value.RoadOrder - 1))
            {
                var c2 = new System.Numerics.Complex(0, 1);
                var c3 = c * c2;

                point1 = new double[] {
                    value.startLongitude + c3.Real * value.MaxSpeed * roadZoomValue * KofPointStretchFirstAndSecond,
                    value.startLatitude + c3.Imaginary * value.MaxSpeed * roadZoomValue * KofPointStretchFirstAndSecond
                };
                var c5 = c / c2;
                point2 = new double[] {
                    value.startLongitude + c5.Real * value.MaxSpeed * roadZoomValue * KofPointStretchFirstAndSecond,
                    value.startLatitude + c5.Imaginary * value.MaxSpeed * roadZoomValue * KofPointStretchFirstAndSecond
                };
            }
            else
            {
                var valueP = result[value.RoadOrder - 1];//previows
                var vecP   = new double[] { valueP.endLongitude - valueP.startLongitude, valueP.endLatitude - valueP.startLatitude };
                vecP = setToOne(vecP);
                System.Numerics.Complex cP = new System.Numerics.Complex(-vecP[0], -vecP[1]);
                var vecDiv2 = c + cP;
                {
                    if (Math.Abs((vecDiv2 / c).Imaginary) < 1e-6)
                    {
                        var c2 = new System.Numerics.Complex(0, 1);
                        var c3 = c * c2;
                        point1 = new double[] {
                            value.startLongitude + c3.Real * value.MaxSpeed * roadZoomValue * KofPointStretchFirstAndSecond,
                            value.startLatitude + c3.Imaginary * value.MaxSpeed * roadZoomValue * KofPointStretchFirstAndSecond
                        };
                        var c5 = c / c2;
                        point2 = new double[] {
                            value.startLongitude + c5.Real * value.MaxSpeed * roadZoomValue * KofPointStretchFirstAndSecond,
                            value.startLatitude + c5.Imaginary * value.MaxSpeed * roadZoomValue * KofPointStretchFirstAndSecond
                        };
                    }
                    else
                    {
                        var k = 1 / (vecDiv2 / c).Imaginary;
                        var s = Math.Sqrt(k * k + 1 / k / k);

                        {
                            var vecDivOperate = s / k * setToOne(vecDiv2);
                            point1 = new double[] {
                                value.startLongitude + vecDivOperate.Real * value.MaxSpeed * roadZoomValue * KofPointStretchFirstAndSecond,
                                value.startLatitude + vecDivOperate.Imaginary * value.MaxSpeed * roadZoomValue * KofPointStretchFirstAndSecond
                            };
                        }
                        {
                            var vecDiv2_opp_diretion = -1 * (vecDiv2);
                            var vecDivOperate        = s / k * setToOne(vecDiv2_opp_diretion);
                            point2 = new double[] {
                                value.startLongitude + vecDivOperate.Real * value.MaxSpeed * roadZoomValue * KofPointStretchFirstAndSecond,
                                value.startLatitude + vecDivOperate.Imaginary * value.MaxSpeed * roadZoomValue * KofPointStretchFirstAndSecond
                            };
                        }
                    }
                }
            }
            c = new System.Numerics.Complex(-vec[0], -vec[1]);
            if (!result.ContainsKey(value.RoadOrder + 1))
            {
                var c2 = new System.Numerics.Complex(0, 1);
                var c3 = c * c2;
                point3 = new double[] {
                    value.endLongitude + c3.Real * value.MaxSpeed * roadZoomValue * KofPointStretchThirdAndFourth,
                    value.endLatitude + c3.Imaginary * value.MaxSpeed * roadZoomValue * KofPointStretchThirdAndFourth
                };
                var c5 = c / c2;
                point4 = new double[] {
                    value.endLongitude + c5.Real * value.MaxSpeed * roadZoomValue * KofPointStretchThirdAndFourth,
                    value.endLatitude + c5.Imaginary * value.MaxSpeed * roadZoomValue * KofPointStretchThirdAndFourth
                };
            }
            else
            {
                var valueN = result[value.RoadOrder + 1];//next
                var vecN   = new double[] {
                    valueN.endLongitude - valueN.startLongitude,
                    valueN.endLatitude - valueN.startLatitude
                };
                vecN = setToOne(vecN);
                System.Numerics.Complex cP = new System.Numerics.Complex(vecN[0], vecN[1]);
                var vecDiv2 = c + cP;
                if (Math.Abs((vecDiv2 / c).Imaginary) < 1e-6)
                {
                    var c2 = new System.Numerics.Complex(0, 1);
                    var c3 = c * c2;
                    point3 = new double[] {
                        value.endLongitude + c3.Real * value.MaxSpeed * roadZoomValue * KofPointStretchThirdAndFourth,
                        value.endLatitude + c3.Imaginary * value.MaxSpeed * roadZoomValue * KofPointStretchThirdAndFourth
                    };
                    var c5 = c / c2;
                    point4 = new double[] {
                        value.endLongitude + c5.Real * value.MaxSpeed * roadZoomValue * KofPointStretchThirdAndFourth,
                        value.endLatitude + c5.Imaginary * value.MaxSpeed * roadZoomValue * KofPointStretchThirdAndFourth
                    };
                }
                else
                {
                    var k = 1 / (vecDiv2 / c).Imaginary;
                    var s = Math.Sqrt(k * k + 1 / k / k);
                    {
                        var vecDivOperate = s / k * setToOne(vecDiv2);
                        point3 = new double[] {
                            value.endLongitude + vecDivOperate.Real * value.MaxSpeed * roadZoomValue * KofPointStretchThirdAndFourth,
                            value.endLatitude + vecDivOperate.Imaginary * value.MaxSpeed * roadZoomValue * KofPointStretchThirdAndFourth
                        };
                    }
                    {
                        var vecDiv2_opp_diretion = -1 * vecDiv2;
                        var vecDivOperate        = s / k * setToOne(vecDiv2_opp_diretion);
                        point4 = new double[] {
                            value.endLongitude + vecDivOperate.Real * value.MaxSpeed * roadZoomValue * KofPointStretchThirdAndFourth,
                            value.endLatitude + vecDivOperate.Imaginary * value.MaxSpeed * roadZoomValue * KofPointStretchThirdAndFourth
                        };
                    }
                }
            }
            return(new double[]
            {
                Math.Round(point1[0], 9), Math.Round(point1[1], 9),
                Math.Round(point2[0], 9), Math.Round(point2[1], 9),
                Math.Round(point3[0], 9), Math.Round(point3[1], 9),
                Math.Round(point4[0], 9), Math.Round(point4[1], 9)
            });
        }
Пример #3
0
 private static object getCrossPoints(SaveRoad.RoadInfo value, Dictionary <string, Dictionary <int, SaveRoad.RoadInfo> > result)
 {
     //List<string>
     throw new NotImplementedException();
 }