NetTopologySuite / NetTopologySuite.IO.ShapeFile

The ShapeFile IO module for NTS.
33 stars 25 forks source link

DateTime value with Time in ShapeFile #40

Closed SzeNowy closed 1 month ago

SzeNowy commented 4 years ago

Hi,

I'm trying to create ShapeFile which contains time-specific values.

At first, I tried to just add DateTime fields to Attributes table just using: attributesTable.Add("DateTime", myObject.MyDateTimeField));,

but according to ShapeFileDataWriter: else if (type == typeof(DateTime)) header.AddColumn(name, 'D', DateLength, DateDecimals); and DbFileWriter:

else if (columnValue is DateTime)
  {
          Write((DateTime)columnValue);
    }
...
/// <summary>
        /// </summary>
        /// <param name="date"></param>
        private void Write(DateTime date)
        {
            foreach (char c in date.Year.ToString(NumberFormatInfo.InvariantInfo))
                _writer.Write(c);

            if (date.Month < 10)
                _writer.Write('0');
            foreach (char c in date.Month.ToString(NumberFormatInfo.InvariantInfo))
                _writer.Write(c);

            if (date.Day < 10)
                _writer.Write('0');
            foreach (char c in date.Day.ToString(NumberFormatInfo.InvariantInfo))
                _writer.Write(c);
        }

DateTime is always converted to Date format.

So I started to search how to place Time in dbf file, and found in documentation that there is a Timestamp field which has @ symbol. I tried to change symbol in shape file header, but I See that there are a few places that should be fixed to use Timestamp field.

My question is: In actual code is there a way to place in .shp/.dbf files not only date but also a time and mark it as @ timestamp? Is there a reason why it's not supported? Is my documentation wrong or is there any other reason?

If there just never be any need to use timestamp before could I contribute and add that functionality? :)

mromer-jca commented 8 months ago

Any solution for it? I have the same problem

FObermaier commented 8 months ago

This package is deprecated. Use NetTopologySuite.IO.Esri

KubaSzostak commented 1 month ago

Support for DateTime type has been added in the successor library.