Thanks a ton! This is uber-helpful.<br>
<br>
Aaron<br><br><div><span class="gmail_quote">On 6/30/06, <b class="gmail_sendername">Mateusz Loskot</b> &lt;<a href="mailto:mateusz@loskot.net">mateusz@loskot.net</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Aaron Koning wrote:<br>&gt; Is there anyway of getting OGR to output Null values into a Date<br>&gt; field when there is a Null value present in the input Date field?<br><br>Hi,<br><br>Last days, I fixed this issue but due to my Internet connection was
<br>broken, I could not commit it.<br>So, now I can and I've committed my changes to CVS.<br><br>Changes:<br>- Fixed Shape driver - NULL/0 date value was converted to string without<br>zero fill for year, e.g. 0/00/00 instead of 0000/00/00.
<br><br>- Fixed NULL handling in PG driver - now, if date field stores year of<br>0000, the value is considered as NULL, because there is no ZERO year<br>(this follows PostgreSQL/MySQL dates handling behaviour, interesting
<br>reference:<br><a href="http://groups.google.pl/group/mailing.database.pgsql-sql/browse_frm/thread/1685953a3ebf48c1">http://groups.google.pl/group/mailing.database.pgsql-sql/browse_frm/thread/1685953a3ebf48c1</a><br><br>
So, I was able to import Aaron's shapefile to PostgreSQL 8.1.4.<br>Here are my commands:<br><br>ogr2ogr -f PostgreSQL PG:dbname=gdal_nulldate bugs/null_date/dates.shp<br><br>NOTE: I renamed Aaron's shapefile to dates.shp<br>
Here is what I got in my gdal_nulldate database:<br><br>gdal_nulldate=# \dt<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;List of relations<br> Schema | Name&nbsp;&nbsp;| Type&nbsp;&nbsp;|&nbsp;&nbsp;Owner<br>--------+-------+-------+---------<br> public | dates | table | mloskot<br>(1 row)
<br><br>gdal_nulldate=# \d dates<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Table
&quot;public.dates&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;Column&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;
Type&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Modifiers<br>--------------+---------------+---------------------------------------------------------<br> ogc_fid&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| integer&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | not null default<br>nextval('dates_ogc_fid_seq'::regclass)
<br> wkb_geometry | bytea&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<br> dstrbedate&nbsp;&nbsp; | date&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|<br> dstrbsdate&nbsp;&nbsp; | date&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|<br> licenceid&nbsp;&nbsp;&nbsp;&nbsp;| character(50) |<br> permitid&nbsp;&nbsp;&nbsp;&nbsp; | character(50) |<br> blknmbr&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| character(50) |<br>Indexes:
<br>&nbsp;&nbsp;&nbsp;&nbsp;&quot;dates_pk&quot; PRIMARY KEY, btree (ogc_fid)<br><br>gdal_nulldate=# select dstrbedate, dstrbsdate from dates;<br> dstrbedate | dstrbsdate<br>------------+------------<br> 2001-02-07 | 2001-02-07<br> 2001-02-08 | 2001-02-08
<br> 2002-02-01 | 2002-02-01<br> 2002-01-05 | 2002-01-05<br> 1999-01-06 | 1999-01-06<br> 1997-12-24 | 1997-12-24<br> 1999-03-03 | 1999-03-03<br> 2001-11-01 | 2001-11-01<br> 1998-12-21 | 1998-12-21<br> 1998-09-10 | 1998-09-10
<br> 1998-02-04 | 1998-02-04<br> 2001-01-08 | 2001-01-08<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|<br> 1996-12-23 | 1996-12-23<br> 1992-11-13 | 1992-11-13<br> 1996-01-05 | 1996-01-05<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|<br> 1990-01-01 | 1990-01-01<br>(18 rows)<br><br>
gdal_nulldate=#<br><br>NOTE: As you can see, two records store null dates, just as in the input<br>shapefile.<br><br>So, I assume this issue is fixed, but there are small things I'd like to<br>explain/learn (regarding OGR Shape driver and dates).
<br>Please, see my comment marked with 'XXX - mloskot' in the<br>ogr/ogrsf_frmts/shape/shape2ogr.cpp file.<br><br>Cheers<br>--<br>Mateusz Loskot<br><a href="http://mateusz.loskot.net">http://mateusz.loskot.net</a><br>_______________________________________________
<br>Gdal-dev mailing list<br><a href="mailto:Gdal-dev@lists.maptools.org">Gdal-dev@lists.maptools.org</a><br><a href="http://lists.maptools.org/mailman/listinfo/gdal-dev">http://lists.maptools.org/mailman/listinfo/gdal-dev
</a><br></blockquote></div><br><br clear="all"><br>-- <br>+--------------------------------------------<br>|&nbsp;&nbsp;Aaron Koning<br>|&nbsp;&nbsp;Information Technologist<br>|&nbsp;&nbsp;Prince George, BC, Canada.<br>+--------------------------------------------
<br>|&nbsp;&nbsp;<a href="http://datashare.gis.unbc.ca/fist/">http://datashare.gis.unbc.ca/fist/</a><br>|&nbsp;&nbsp;<a href="http://datashare.gis.unbc.ca/gctp-js/">http://datashare.gis.unbc.ca/gctp-js/</a><br>+--------------------------------------------