Problems while creating PolylineZ-Shapefile from scratch

Nov 24, 2014 at 11:50 AM
Hello group,

first thanks for the nice library to the developers!

I want to use Dotspatial to create PointZ and PolylineZ shapefiles from scratch. Whereas the creation of the Pointfile works like a charm, I have had some troubles to create PolylineZ-Files. I got all this stuff up to tell that it has Z-Values in it, e.g.:
_newSet = new FeatureSet(global::DotSpatial.Topology.FeatureType.Line);
_newSet.CoordinateType = CoordinateType.Z;
Next, I get the vertices for each Line and create the shapes, add them to the FeatureSet, and fill the Businesstablefields (DBF) like this:
var shape = new Shape(FeatureType.Line);
shape.AddPart(vertices, CoordinateType.Z);
_newF = new Feature(shape);
_newF = _newSet.AddFeature(_newF);
_newF.DataRow.BeginEdit();
foreach (DataColumn _c in Table.Columns)
_newF.DataRow[_c.ColumnName] = _r[_c];
_newF.DataRow.EndEdit();
Finally, I save the Shapefile by calling:
_newSet.SaveAs(Filename, false);
The problem here is, that I have ShapeFiles with an empty Z-Envelope. ESRI ArcGIS Desktop is showing in ArcCatalog that the Shapes are Polyline ZM, but if I check the Shapes in ArcGIS Engine, the Z-Values of the Shapes (Points in ESRI-PointCollection what are the Polylines) are "n.def."
The Z-Extend can't even re-calculated in ArcCatalog.

I looked a little bit into the sources of DotSpatial and found, that, when it comes to calculate the Envelope of a LineString, the Z-Dimension is never taken into account, means, MinZ/MaxZ of the Extent of a Linestring is always NaN.

When I add some code to the LineString.cs like this:

protected override IEnvelope ComputeEnvelopeInternal()
{
....
        if (!double.IsNaN(_points[0].Z))
        {
            double minz = _points[0].Z;
            double maxz = _points[0].Z;
            for (int i = 1; i < _points.Count; i++)
            {
                minz = minz < _points[i].Z ? minz : _points[i].Z;
                maxz = maxz > _points[i].Z ? maxz : _points[i].Z;
            }
            return new Envelope(minx, maxx, miny, maxy, minz, maxz);
        }
        else
            return new Envelope(minx, maxx, miny, maxy);
}

all works perfectly.

But I also found something like ExtentMZ-Classes and such, so I guess I'm doing something totally wrong while creating the files.

Question:
Is there another way to create PolylineZ-Shapes (and save them to a shapefile)?
Am I missing something?

Can somebody point me into the right direction?

Many thanks,
Volker