Q:

How to open a DXF referenced file with SharpMap?

I'm working in a viewer map with Sharpmap in C#. I use FWTools, too.
I need attach a dxf file in my viewer as a reference.
Actually i can attach shapes (shp) files, raster images (ecw, tif) but i can do this with sharpmap, i can't find the way.
Someone can help me.
Thanks

A:

Looking at the documentation for SharpMap, it looks like you can add simple geometry like lines and if you don't mind a shameless plug, I wrote a library that can read DXF files (source) (NuGet package) so you should be able to do something like the following:
DxfFile dxf;
using (var stream = new FileStream(@"path\to\file.dxf", FileMode.Open))
{
    dxf = DxfFile.Load(stream);
}

foreach (var entity in dxf.Entities)
{
    switch (entity.EntityType)
    {
        case DxfEntityType.Line:
            var line = (DxfLine)entity;
            // insert code here to add the line to SharpMap using
            // line.P1 and line.P2 as end points
            break;
    }
}

