ThinkGeo.com    |     Documentation    |     Premium Support

Difference between pens in line styles?

Looking at line styles, I see inner pen, center pen, and outer pen. What is the difference between these? I am attempting to set the LineDashStyle, but regardless of which pen’s DashStyle I set, it always seems to be a solid line. Setting the line caps work fine though.

Hi @Dan_Weaver,

Thanks for your inquiry. What version of WPF are you on? I just did a lot of tests in v13 and everything is working as I expect. I tried multiple LineDashStyle properties on both innerPen and outerPen. Below is one version of the code I’ve tested with - this came from the WPF ‘HowDoI’ samples:

                var lineStyle = new LineStyle(
                outerPen: new GeoPen(GeoColors.Black, 12),
                innerPen: new GeoPen(GeoColors.White, 6)
                {
                    DashStyle = LineDashStyle.Custom,
                    DashPattern = { 3f, 3f },
                    StartCap = DrawingLineCap.Flat,
                    EndCap = DrawingLineCap.Flat
                }
            );

Does your code look similar? If not, can you share a quick snippet from your code and we’ll investigate further.

Thanks,
John

Thanks for the reply. I am also using v13. Is it required to set both inner and outer pens? I’m only worried about showing one “line”, not an inner, outer, and center part. I noticed if I set the outer pen’s color to transparent, I then get the single “line” (and dashes when set) when using InnerPen.

What is the “GeoDashCap”? I thought it might be the end caps of the dashes themselves, but they stay as a square for me. For example:

myLinestyle.OuterPen = new GeoPen(GeoColors.Transparent, 6);
myLinestyle.InnerPen = new GeoPen(PenColor, 6);
myLinestyle.InnerPen.DashStyle = LineDashStyle.Dash;
myLinestyle.InnerPen.SetLineCap(DrawingLineCap.Triangle, DrawingLineCap.DiamondAnchor, GeoDashCap.Triangle);

In the above, everything works except GeoDashCap which is set in that .SetLineCap function.

Also, what is “LineDashStyle.Custom” for? Is that strictly for when you define your own dash pattern?

Edit: One more question. It seems that whenever the start and end cap are set to DrawingLineCap.Square, the dash pattern is ignored and a solid line is shown.

Example: I have a linestyle with the following properties:

Looks like this:image

However, if I change one of the caps to something other than square, it shows the gaps (although very small):


image

Hi @Dan_Weaver,

Thanks for the code samples and screenshots. You’re correct in assuming that you really only need the OuterPen, if you look at the LineStyle constructors you’ll see the CenterPen and InnerPen are optional.

I’ve tried your exact code with my own line data and it works just fine (see the screenshot below from the HowDoI railroad data using your exact code:

As you can see, both the dash pattern and end caps look as expected.

I wonder if your data is already smaller lines and a combination of your specific data and the transparent OuterPen may be causing issues. It’s like your line data is already dashed into individual small lines? You may want to play around with one of the shapefiles like the Railroads in the HowDoI samples and I think this will clarify what’s going on. Or, you can send me your line data and I’ll look into it here.

Regarding your question on the LineDashStyle.Custom, yes, it allows you to define your own pattern. Check out Kyle’s reply (post #3) from this thread. It will give you some more insight on how the LineDashStyle.Custom works.

Let me know if this clears things up. Or, go ahead and send your line data to support@thinkgeo.com and we’ll take a closer look.

Thanks,
John

Appreciate the response! I’ll dig into this a bit more on my end and look at that railroads example.

Good luck Dan. Let us know how it goes.

Hello again. In the CreateLineStyle sample you listed earlier from the HowDoI solution, if you change the rbDashedLineType_Checked function to this:

private async void rbDashedLineType_Checked(object sender, RoutedEventArgs e)
{
    if (mapView.Overlays.Count > 0)
    {
        LayerOverlay layerOverlay = (LayerOverlay)mapView.Overlays["overlay"];
        ShapeFileFeatureLayer friscoRailroad = (ShapeFileFeatureLayer)layerOverlay.Layers["Railroad"];

        var lineStyle = new LineStyle(
            outerPen: new GeoPen(GeoColors.White, 3)
            {
                DashStyle = LineDashStyle.Dash,
                StartCap = DrawingLineCap.Square,
                EndCap = DrawingLineCap.Square
            }
        );

        // Add the line style to the collection of custom styles for ZoomLevel 1.
        friscoRailroad.ZoomLevelSet.ZoomLevel01.CustomStyles.Clear();
        friscoRailroad.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(lineStyle);

        // Apply the styles for ZoomLevel 1 down to ZoomLevel 20. This effectively applies the line style on every zoom level on the map. 
        friscoRailroad.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

        // Refresh the layerOverlay to show the new style
        await layerOverlay.RefreshAsync();
    }
}

you will see the issue I am seeing. It is a solid white line even though the LineDashStyle is set to Dash. This happens with various combinations of the DrawingLineCap value for the StartCap and EndCap. Some work, some turn the line into a solid line.

Hi @Dan_Weaver,

That’s very interesting. When I use your code and run the sample, I see dashed lines. I bet there’s something non-standard in your setup with your screen scaling, etc. that our code is not handling correctly. The screenshot below is what I see when running your rbDashedLineType_Checked. Can you confirm that you’re seeing something different?

Thanks,
John

Hi John, yup I’m seeing it different. Here’s what I see:

The size and color is correct, but the dashes do not appear. And again, if I change the start/end caps to ArrowAnchor (some of the others work as well), I do see the dashes.

// the below does not work
var lineStyle = new LineStyle(
    outerPen: new GeoPen(GeoColors.White, 3)
    {
        DashStyle = LineDashStyle.Dash,
        StartCap = DrawingLineCap.Square,
        EndCap = DrawingLineCap.Square
    }
); 

Is there a specific environment setting you want me to check?

Hi Dan,

I suspect your display scale in windows is 100%? I think you’ve found a bug in our LineStyle that doesn’t occur at other scales like 125% or 150%. I’ve talked to the product team and they will add this to their bug list to fix in a future release.

In the mean-time, using the LineDashStyle.Custom with explicit DashPattern should work on any screen. Can you try code like below and see if it works for now?

var lineStyle = new LineStyle(
      outerPen: new GeoPen(GeoColors.White, 3)
      {
          DashStyle = LineDashStyle.Custom,
          DashPattern = { 3f, 3f },
          StartCap = DrawingLineCap.Square,
          EndCap = DrawingLineCap.Square
      }
  );

Thanks for identifying this bug!!

Thanks,
John

Thanks! If you could please let me know whenever the bug gets fixed and the build it gets fixed in that would be great.

For the custom style you mentioned as an alternative, is that just for dashes? what about dots and dash-dot ? Is it typically 1f for a dot?

Hi @Dan_Weaver,

The DashPattern property can be used to customize any imaginable combination of dashes/dots, etc.

You set the DashPattern to an array of float values. The first value is a dash length, then the 2nd a space length, the third a dash length, and the fourth a space length, etc. You can have any length of array you choose and the style will repeat after that.

The pattern below would be one way to do a dash-dot:
DashPattern = { 3f, 3f, 1f, 3f }

The first 3f would be the dash, and the 3rd parameter - the 1f would be for the dot. The 2nd and fourth parameters would be the space after the dash and dot.

Thanks,
John

1 Like