ThinkGeo.com    |     Documentation    |     Premium Support

Smoothing jagged lines

I noticed that lines look jagged when looking closely like they are drawn without anti-aliasing. Is this normal or is there a way to “smooth” lines out?

Hi Dan,

Could you please show us the code or let us know how to reproduce it?

Generally I think if it’s vector data it will still render smooth enough after you zoom in.

Regards,

Ethan

Hi Ethan, I’m just loading normal shapefiles containing line features. Below is a screenshot I took, zoomed in to show some of the lines. See how they are jagged, and look like “steps”?

Here’s another one, but not zoomed in:

These lines have anywhere from ~400 to ~1500 vertices, with each vertex being very close to the next. Here’s how some of these vertices look just to show how close they are:

I noticed when drawing lines using the trackoverlay, I do not see any of the jaggedness.

Hi Dan,

I think that’s related with some property you set, could you please modify this sample:9608.zip (10.6 KB)

So we can see what’s the problem.

And your first screen shot is not a correct map, it should be a stretched image from higher level, which means your current hadn’t render complete.

Regards,

Ethan

For my LineStyles, I have a class that inherits from LineStyle. Here’s the class:

public class MyLineStyle : LineStyle
{
    public GeoColor PenColor
    {
        get;
        set;
    }

    public MyLineStyle(Color? penColor, int penWidth)
    {
        PenColor = GeoColor.FromArgb(penColor.Value.A, penColor.Value.R, penColor.Value.G, penColor.Value.B);
        CenterPen = new GeoPen(PenColor, penWidth);
        CenterPen.DashStyle = LineDashStyle.Solid;
        CenterPen.SetLineCap(DrawingLineCap.Flat, DrawingLineCap.Flat, GeoDashCap.Flat);
    }
}

The layers containing these line features are InMemoryFeatureLayers. For these layers, here are the properties I’m setting:

inMemoryFeatureLayer.DrawingQuality = DrawingQuality.HighSpeed;
inMemoryFeatureLayer.ZoomLevelSet.ZoomLevel101.DefaultLineStyle = myLineStyle;

Here are the properties I set for the Overlay containing these layers:

overlay.TileType = TileType.SingleTile;
overlay.DrawingQuality = DrawingQuality.HighSpeed;
overlay.TransitionEffect = TransitionEffect.None;

That’s all I’m doing.

Hi Dan,

I still hadn’t reproduced it after change the code.

You can keep zoom into the deepest level its scale nearly equal 1, and see the line still render clearly.

I think you still missed some code about it.

You can try to modify the high speed to high quality to see whether it render correct in your project.

And I wish you can reproduce that in the sample project, so we can help find the reason.

9608.zip (10.9 KB)

Regards,

Ethan