Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Synchronize Stripe phase #171

Open
WJSchakel opened this issue Nov 23, 2024 · 2 comments
Open

Synchronize Stripe phase #171

WJSchakel opened this issue Nov 23, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@WJSchakel
Copy link
Collaborator

By synchronizing Stripe phase, i.e. making sure that a dashed stripe neatly continues on the next link, it is prevented that short links cause confusing disruptions in the dash pattern.

In order to also synchronize the phase of adjacent stripes, the dash and gap lengths can be based on the link center line. The fractions along the link center line, would then be applied on the Stripe center line. This all needs to occur on flattened lines, as that is the information that the animation has.

On some links stripes can be far from the link center line, considering the curvature. The option needs to be maintained that the dashes apply to the stripe center line. A utility can be used to adjust dashes on individual stripes, to at least synchronize the dash phase at the end of the link.

Another utility can set the offset such that phase is synchronized with a stripe on the previous link.

@WJSchakel
Copy link
Collaborator Author

Each Stripe now has:

  • Length dashOffset: the offset at the start of the stripe.
  • StripeLateralSync lateralSync: determines whether the dashes are applied to the stripe line (NONE), or a line in the middle of the area bounded by all stripes on the link (LINK), optionally with full phases added/removed to stay close to original dash lengths while adhering to the phase at the end-points (SNAP).
  • StripePhaseSync phaseSync: whether to synchronize the phase upstream (UPSTREAM), downstream (DOWNSTREAM) or not at all (NONE).
  • List<StripeElement> elements: individual lines and gaps between them that together make up the whole stripe.

Furthermore, permeability (or lack thereof) can be set on the whole stripe, or for specific GTU types.

Each StripeElement has:

  • Length width: applicable for continuous lines, dashed lines, and gaps between them.
  • Color color: which is null when the element is a gap.
  • LengthVector dashes: which is only not-null for a dashed line.

This allows a rich tapestry for common stripe road markings.

@WJSchakel
Copy link
Collaborator Author

WJSchakel commented Nov 29, 2024

Class StripeSynchronization has been added. It receives a map of all stripes to work with. It synchronizes the phase of stripes one by one, recursing through them as required. This process stops when an upstream/downstream stripe has StripePhaseSync.NONE, or when a previously encountered stripe is encountered (i.e. a circular dependency). In the latter case, the stipe is not synchronized, but takes as reference (anchor).

When a stripe is synchronized, other stripes in the same link might also be immediately synchronized. This happens when:

  • Both synchronize either upstream (StripePhaseSync.UPSTREAM), or both synchronize downstream (StripePhaseSync.DOWNSTREAM).
  • They have the same period within their total dash pattern, i.e. based on all StripeElement within a Stripe.
  • Both synchronize at, and draw based on, the link level (StripeLateralSync.LINK or StripeLateralSync.SNAP).

The period is based on the greatest common divisor, which is calculated using long values, which are equal to the double lengths times 10000 (i.e. by 1/10th of a millimeter). Whole numbers are required to calculate the greatest common divisor, but this also makes sure that 3m+9m and 4m+8m are equal regardless of floating point issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants