Beispiel #1
0
        protected override IStyleData Calculate(MarkupRegularLine line, ITrajectory trajectory, MarkupLOD lod)
        {
            var solidOffset  = CenterSolid ? 0 : Invert ? Offset : -Offset;
            var dashedOffset = (Invert ? -Offset : Offset) * (CenterSolid ? 2 : 1);
            var borders      = line.Borders;

            var dashes = new List <MarkupStylePart>();

            dashes.AddRange(StyleHelper.CalculateSolid(trajectory, lod, CalculateSolidDash));
            if (CheckDashedLod(lod, Width, DashLength))
            {
                dashes.AddRange(StyleHelper.CalculateDashed(trajectory, DashLength, SpaceLength, CalculateDashedDash));
            }

            return(new MarkupStyleParts(dashes));

            IEnumerable <MarkupStylePart> CalculateSolidDash(ITrajectory lineTrajectory)
            {
                if (StyleHelper.CalculateSolidPart(borders, lineTrajectory, solidOffset, Width, Color, out MarkupStylePart dash))
                {
                    yield return(dash);
                }
            }

            IEnumerable <MarkupStylePart> CalculateDashedDash(ITrajectory lineTrajectory, float startT, float endT)
            {
                if (StyleHelper.CalculateDashedParts(borders, lineTrajectory, startT, endT, DashLength, dashedOffset, Width, Color, out MarkupStylePart dash))
                {
                    yield return(dash);
                }
            }
        }
Beispiel #2
0
        public override IEnumerable <MarkupStylePart> Calculate(MarkupCrosswalk crosswalk, MarkupLOD lod)
        {
            var middleOffset = GetVisibleWidth(crosswalk) / 2 + OffsetBefore;
            var deltaOffset  = GetLengthCoef((Width + Offset) / 2, crosswalk);
            var firstOffset  = -crosswalk.NormalDir * (middleOffset - deltaOffset);
            var secondOffset = -crosswalk.NormalDir * (middleOffset + deltaOffset);

            var coef        = Mathf.Sin(crosswalk.CornerAndNormalAngle);
            var dashLength  = Parallel ? DashLength / coef : DashLength;
            var spaceLength = Parallel ? SpaceLength / coef : SpaceLength;
            var direction   = Parallel ? crosswalk.NormalDir : crosswalk.CornerDir.Turn90(true);
            var borders     = crosswalk.BorderTrajectories;

            var trajectoryFirst  = crosswalk.GetFullTrajectory(middleOffset - deltaOffset, direction);
            var trajectorySecond = crosswalk.GetFullTrajectory(middleOffset + deltaOffset, direction);

            foreach (var dash in StyleHelper.CalculateDashed(trajectoryFirst, dashLength, spaceLength, CalculateDashes))
            {
                yield return(dash);
            }

            foreach (var dash in StyleHelper.CalculateDashed(trajectorySecond, dashLength, spaceLength, CalculateDashes))
            {
                yield return(dash);
            }

            IEnumerable <MarkupStylePart> CalculateDashes(ITrajectory crosswalkTrajectory, float startT, float endT)
            => CalculateCroswalkPart(crosswalkTrajectory, startT, endT, direction, borders, Width, DashLength);
        }
Beispiel #3
0
        public override IEnumerable <MarkupStylePart> Calculate(MarkupCrosswalk crosswalk, MarkupLOD lod)
        {
            var offset = GetVisibleWidth(crosswalk) / 2 + OffsetBefore;

            var coef       = Mathf.Sin(crosswalk.CornerAndNormalAngle);
            var borders    = crosswalk.BorderTrajectories;
            var index      = 0;
            var direction  = Parallel ? crosswalk.NormalDir : crosswalk.CornerDir.Turn90(true);
            var trajectory = crosswalk.GetFullTrajectory(offset, direction);

            if (!UseGap)
            {
                var dashLength  = Parallel ? DashLength / coef : DashLength;
                var spaceLength = Parallel ? SpaceLength / coef : SpaceLength;

                return(StyleHelper.CalculateDashed(trajectory, dashLength, spaceLength, CalculateDashes));

                IEnumerable <MarkupStylePart> CalculateDashes(ITrajectory crosswalkTrajectory, float startT, float endT)
                {
                    index += 1;
                    foreach (var part in CalculateCroswalkPart(crosswalkTrajectory, startT, endT, direction, borders, Width, DashLength, GetColor(index)))
                    {
                        yield return(part);
                    }
                }
            }
            else
            {
                var groupLength = (DashLength * GapPeriod + SpaceLength * (GapPeriod - 1));
                var dashT       = DashLength / groupLength;
                var spaceT      = SpaceLength / groupLength;

                groupLength /= (Parallel ? coef : 1f);
                var gapLength = GapLength / (Parallel ? coef : 1f);

                return(StyleHelper.CalculateDashed(trajectory, groupLength, gapLength, CalculateDashes));

                IEnumerable <MarkupStylePart> CalculateDashes(ITrajectory crosswalkTrajectory, float startT, float endT)
                {
                    index += 1;
                    for (var i = 0; i < GapPeriod; i += 1)
                    {
                        var partStartT = startT + (endT - startT) * (dashT + spaceT) * i;
                        var partEndT   = partStartT + (endT - startT) * dashT;
                        foreach (var part in CalculateCroswalkPart(crosswalkTrajectory, partStartT, partEndT, direction, borders, Width, DashLength, GetColor(index)))
                        {
                            yield return(part);
                        }
                    }
                }
            }
        }
Beispiel #4
0
        protected override IStyleData Calculate(MarkupRegularLine line, ITrajectory trajectory, MarkupLOD lod)
        {
            if (!CheckDashedLod(lod, Width, DashLength))
            {
                return(new MarkupStyleParts());
            }

            var borders = line.Borders;

            return(new MarkupStyleParts(StyleHelper.CalculateDashed(trajectory, DashLength, SpaceLength, GetDashes)));

            IEnumerable <MarkupStylePart> GetDashes(ITrajectory trajectory, float startT, float endT)
            => CalculateDashes(trajectory, startT, endT, borders);
        }
Beispiel #5
0
        protected override IStyleData Calculate(MarkupStopLine stopLine, ITrajectory trajectory, MarkupLOD lod)
        {
            if (!CheckDashedLod(lod, Base, Height))
            {
                return(new MarkupStyleParts());
            }

            var styleData = new MarkupStyleParts(StyleHelper.CalculateDashed(trajectory, Base, Space, CalculateDashes));

            foreach (var dash in styleData)
            {
                dash.MaterialType = MaterialType.Triangle;
            }

            return(styleData);
        }
Beispiel #6
0
        protected override IStyleData Calculate(MarkupStopLine stopLine, ITrajectory trajectory, MarkupLOD lod)
        {
            if (!CheckDashedLod(lod, Width, DashLength))
            {
                return(new MarkupStyleParts());
            }

            var offset = ((stopLine.Start.Direction + stopLine.End.Direction) / -2).normalized * (Width / 2);

            return(new MarkupStyleParts(StyleHelper.CalculateDashed(trajectory, DashLength, SpaceLength, CalculateDashes)));

            IEnumerable <MarkupStylePart> CalculateDashes(ITrajectory dashTrajectory, float startT, float endT)
            {
                yield return(StyleHelper.CalculateDashedPart(dashTrajectory, startT, endT, DashLength, offset, offset, Width, Color));
            }
        }
Beispiel #7
0
        public override IEnumerable <MarkupStylePart> Calculate(MarkupCrosswalk crosswalk, MarkupLOD lod)
        {
            var offset = GetVisibleWidth(crosswalk) / 2 + OffsetBefore;

            var coef        = Mathf.Sin(crosswalk.CornerAndNormalAngle);
            var dashLength  = Parallel ? DashLength / coef : DashLength;
            var spaceLength = Parallel ? SpaceLength / coef : SpaceLength;
            var direction   = Parallel ? crosswalk.NormalDir : crosswalk.CornerDir.Turn90(true);
            var borders     = crosswalk.BorderTrajectories;

            var trajectory = crosswalk.GetFullTrajectory(offset, direction);

            return(StyleHelper.CalculateDashed(trajectory, dashLength, spaceLength, CalculateDashes));

            IEnumerable <MarkupStylePart> CalculateDashes(ITrajectory crosswalkTrajectory, float startT, float endT)
            => CalculateCroswalkPart(crosswalkTrajectory, startT, endT, direction, borders, Width, DashLength);
        }
Beispiel #8
0
        public override IEnumerable <MarkupStylePart> Calculate(MarkupCrosswalk crosswalk, MarkupLOD lod)
        {
            var middleOffset     = GetVisibleWidth(crosswalk) / 2 + OffsetBefore;
            var deltaOffset      = (Width - LineWidth) / 2 / Mathf.Sin(crosswalk.CornerAndNormalAngle);
            var firstTrajectory  = crosswalk.GetTrajectory(middleOffset - deltaOffset);
            var secondTrajectory = crosswalk.GetTrajectory(middleOffset + deltaOffset);

            foreach (var dash in StyleHelper.CalculateDashed(firstTrajectory, DashLength, SpaceLength, CalculateDashes))
            {
                yield return(dash);
            }

            foreach (var dash in StyleHelper.CalculateDashed(secondTrajectory, DashLength, SpaceLength, CalculateDashes))
            {
                yield return(dash);
            }

            IEnumerable <MarkupStylePart> CalculateDashes(ITrajectory dashTrajectory, float startT, float endT)
            {
                yield return(StyleHelper.CalculateDashedPart(dashTrajectory, startT, endT, DashLength, 0, LineWidth, Color));
            }
        }
Beispiel #9
0
        public override IEnumerable <MarkupStylePart> Calculate(MarkupCrosswalk crosswalk, MarkupLOD lod)
        {
            foreach (var dash in base.Calculate(crosswalk, lod))
            {
                yield return(dash);
            }

            var offset = GetVisibleWidth(crosswalk) / 2 + OffsetBefore;

            var direction = crosswalk.CornerDir.Turn90(true);
            var borders   = crosswalk.BorderTrajectories;
            var width     = Width - 2 * LineWidth;

            var trajectory = crosswalk.GetFullTrajectory(offset, direction);

            foreach (var dash in StyleHelper.CalculateDashed(trajectory, DashLength, SpaceLength, CalculateDashes))
            {
                yield return(dash);
            }

            IEnumerable <MarkupStylePart> CalculateDashes(ITrajectory crosswalkTrajectory, float startT, float endT)
            => CalculateCroswalkPart(crosswalkTrajectory, startT, endT, direction, borders, Width, DashLength, Color);
        }
Beispiel #10
0
        protected override IStyleData Calculate(MarkupStopLine stopLine, ITrajectory trajectory, MarkupLOD lod)
        {
            var offsetNormal = ((stopLine.Start.Direction + stopLine.End.Direction) / -2).normalized;
            var solidOffset  = offsetNormal * (Width / 2);
            var dashedOffset = offsetNormal * (Width / 2 + 2 * Offset);

            var dashes = new List <MarkupStylePart>();

            dashes.AddRange(StyleHelper.CalculateSolid(trajectory, lod, CalculateSolidDash));
            if (CheckDashedLod(lod, Width, DashLength))
            {
                dashes.AddRange(StyleHelper.CalculateDashed(trajectory, DashLength, SpaceLength, CalculateDashedDash));
            }

            return(new MarkupStyleParts(dashes));

            MarkupStylePart CalculateSolidDash(ITrajectory lineTrajectory) => StyleHelper.CalculateSolidPart(lineTrajectory, solidOffset, solidOffset, Width, Color);

            IEnumerable <MarkupStylePart> CalculateDashedDash(ITrajectory lineTrajectory, float startT, float endT)
            {
                yield return(StyleHelper.CalculateDashedPart(lineTrajectory, startT, endT, DashLength, dashedOffset, dashedOffset, Width, Color));
            }
        }