OGR precision vs Scale and DateTime values not set

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

OGR precision vs Scale and DateTime values not set

Clay, Bruce

There seems to be a difference in the way ESRI uses precision and scale to that of OGR.  I don’t know which is right.  I am using the c# libraries include in the FWTools.2.0.3.

 

OGR does not appear to have a data type of Double when displayed in ArcMap.  The stored attribute value appear correct but the parameters are different

I defined the double field as:

 

fieldDef = new FieldDefn(“LATITUDE”, FieldType.OFTReal);

fieldDef.SetWidth(8);

fieldDef.SetPrecision(38);

 

and ArcMap shows Type = Float, Length = 8, Precision = 7, and Scale = 38

 

Also the DateTime fields are not getting set.  If I use the DisplayFeature method in the c# createData.cs example, the date time fields appear to be set properly (2006/10/10 9:00:00) but is I use ogrinfo –al the the date fields are not set.

 

I have defined them as follows:

 

fieldDef = new FieldDefn(“DATE_TIME”, FieldType.OFTDateTime);

fieldDef.SetWidth(36);

fieldDef.SetPrecision(0);

 

ArcMap shows Type = Date Length = 8, Precision = 0; scale = 0

 

And I set the value with:

 

fieldIndex = featureDef.GetFieldIndex(shapeFieldList[3].fieldName);

if (fieldIndex >= 0)

{

feature.SetField(fieldIndex, minDate.Year, minDate.Month, minDate.Day,

minDate.Hour, minDate.Minute, minDate.Second, 0);

}

 

I also tried:

feature.SetField(fieldIndex, minDate.ToString("yyyy-MM-dd HH:mm:ss"));

 

but it didn’t work either

 

 

Any thoughts as to what I am doing wrong would be greatly appreciated.

 

Bruce


This message and any enclosures are intended only for the addressee.  Please  
notify the sender by email if you are not the intended recipient.  If you are  
not the intended recipient, you may not use, copy, disclose, or distribute this  
message or its contents or enclosures to any other person and any such actions  
may be unlawful.  Ball reserves the right to monitor and review all messages  
and enclosures sent to or from this email address.

_______________________________________________
gdal-dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: OGR precision vs Scale and DateTime values not set

Frank Warmerdam
Clay, Bruce wrote:

> There seems to be a difference in the way ESRI uses precision and scale
> to that of OGR.  I don’t know which is right.  I am using the c#
> libraries include in the FWTools.2.0.3.
>
> OGR does not appear to have a data type of Double when displayed in
> ArcMap.  The stored attribute value appear correct but the parameters
> are different
>
> I defined the double field as:
>
>  
>
> fieldDef = new FieldDefn(“LATITUDE”, FieldType.OFTReal);
>
> fieldDef.SetWidth(8);
>
> fieldDef.SetPrecision(38);
 >
> and ArcMap shows Type = Float, Length = 8, Precision = 7, and Scale = 38

Bruce,

I'm not sure what ESRI means by Scale. But for OGR precision should be
less than width.  That is width specifies the full width of the field
and precision indicates how many characters of the field are used for
the decimal places.  So "123.456" would have a width of seven and a
precision of three.

> Also the DateTime fields are not getting set.  If I use the
> DisplayFeature method in the c# createData.cs example, the date time
> fields appear to be set properly (2006/10/10 9:00:00) but is I use
> ogrinfo –al the the date fields are not set.

Are you working with Shapefiles?  I think the shapefile driver only
supports date fields, not datetime or time.  But I would expect that
at least the date would be handled.  If you can file a bug demonstrating
broken OFTDate field support, I would appreciate that.

PS. OFTDateTime is *supposed* to be automatically treated as
OFTDate internally.

Best regards,
--
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, [hidden email]
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | President OSGeo, http://osgeo.org

_______________________________________________
gdal-dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: OGR precision vs Scale and DateTime values not set

Markus Neteler
On Dec 29, 2007 9:19 PM, Frank Warmerdam <[hidden email]> wrote:
> Clay, Bruce wrote:
...
> > Also the DateTime fields are not getting set.  If I use the
> > DisplayFeature method in the c# createData.cs example, the date time
> > fields appear to be set properly (2006/10/10 9:00:00) but is I use
> > ogrinfo –al the the date fields are not set.
>
> Are you working with Shapefiles?  I think the shapefile driver only
> supports date fields, not datetime or time.  But I would expect that
> at least the date would be handled.  If you can file a bug demonstrating
> broken OFTDate field support, I would appreciate that.

It would be a nice-to-have also for GRASS:

cd grass63/db/drivers/dbf
[neteler@localhost dbf]$ grep -i date *
...
dbfexe.c:       case (SQLP_DATE):  /* DATE treated as string unless
SHAPELIB/DBFLIB supports date type */

This is a working but ugly approach...

Markus
_______________________________________________
gdal-dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/gdal-dev