bugGNU Octave - Bugs: bug #57669, [octave forge] (io) Corrupt output...

 
 

bug #57669: [octave forge] (io) Corrupt output when a single row of data is written with dbfwrite

Submitter:  Matthew Parkan <mparkan>
Submitted:  Sun 26 Jan 2020 06:08:41 PM UTC
   
 
Category:  Octave Package Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  philipnienhuis
Originator Name:  Matt Parkan Open/Closed:  * Closed
Release:  * other Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Thu 06 Feb 2020 09:05:43 PM UTC, comment #7: 

Fixed & pushed here:
http://hg.code.sf.net/p/octave/io/rev/690640234834
(I forgot to report back on this bug)

Philip Nienhuis <philipnienhuis>
Group Member
Mon 27 Jan 2020 08:48:40 PM UTC, comment #6: 

Thanks for testing.
So it was a sort of off-by-one error.

I'll push a fix later this week; my local repos got a bit out of sync due to hardware failures on my main dev box so I have to sort that out first.
Once done an io-2.6.0 release is within sight.

Philip Nienhuis <philipnienhuis>
Group Member
Mon 27 Jan 2020 08:05:10 PM UTC, comment #5: 

Looks like it's working correctly now, thanks!

Matthew Parkan <mparkan>
Mon 27 Jan 2020 07:30:12 PM UTC, comment #4: 

Please try with attached dbfwrite.m and report back.

(file #48291)

Philip Nienhuis <philipnienhuis>
Group Member
Mon 27 Jan 2020 07:25:56 PM UTC, comment #3: 

Just checked the last modified dbfwrite version I had submitted here:

https://savannah.gnu.org/bugs/?53899

It seems to produce a correct DBF output with a single record, so the problem probably appeared in later revisions (in the chunking or the unwind protection blocks).

Matthew Parkan <mparkan>
Mon 27 Jan 2020 03:44:01 PM UTC, comment #2: 

Bug is in dbfwrite, L.203 and further, where for your first case nrecs = 1 but the for loop starts at 2.
Intriguing that it works for nrecs = 2. I'll pick it up, this is s/th for the io package.

BTW wasn't this code that you once wrote? (I could have it wrong)

Philip Nienhuis <philipnienhuis>
Group Member
Sun 26 Jan 2020 08:02:54 PM UTC, comment #1: 

Could you also test the latest dbfwrite.m in the on-line repo? I fixed it a few weeks ago.

BTW mapping-1.4.0 is in the package release tracker. Depending on the admin's work load there may be some time for a last-minute fix.

Philip Nienhuis <philipnienhuis>
Group Member
Sun 26 Jan 2020 06:08:41 PM UTC, original submission:  

Hi,

There seems to be an issue with the output of the shapewrite function in the mapping package (latest snapshot files from Jan 26, 2020): when a single record is written to a shapefile, the result does not contain any of the attributes.

Example:


s = struct;
j = 1;
s(j).Geometry = 'Point';
s(j).X = 597600;
s(j).Y = 172250;
s(j).BoundingBox = [min(s(j).X), min(s(j).Y); max(s(j).X), max(s(j).Y)];
s(j).Attribute1 = 'abc';
s(j).Attribute2 = 42;

shapewrite(s, 'point.shp');
s2 = shaperead('point.shp');


This will return:

Geometry = Point
X =  597600
Y =  172250
Custom1 = [](0x0)
Custom2 = [](0x0)


This only seems to happen when the structure contains a single record. For example, the following code will produce the expected result:


s = struct;
j = 1;
s(j).Geometry = 'Point';
s(j).X = 597600;
s(j).Y = 172250;
s(j).BoundingBox = [min(s(j).X), min(s(j).Y); max(s(j).X), max(s(j).Y)];
s(j).Attribute1 = 'abc';
s(j).Attribute2 = 42;

j = 2;
s(j).Geometry = 'Point';
s(j).X = 598600;
s(j).Y = 170250;
s(j).BoundingBox = [min(s(j).X), min(s(j).Y); max(s(j).X), max(s(j).Y)];
s(j).Attribute1 = 'efg';
s(j).Attribute2 = 43;

shapewrite(s, 'point.shp');


It is likely that the issue is in the dbwrite() function used by shapewrite to create the dBase file.

Matthew Parkan <mparkan>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #48291:  dbfwrite.m added by philipnienhuis (8KiB - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by siko1056 (Updated the item)
  • -email is unavailable- added by mparkan (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 10 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-04-28 siko1056 Summary[octave forge](io) Corrupt output when a single row of data is written with dbfwrite [octave forge] (io) Corrupt output when a single row of data is written with dbfwrite
    2020-02-06 philipnienhuis StatusIn Progress Fixed
        Open/ClosedOpen Closed
    2020-01-27 philipnienhuis StatusNeed Info In Progress
    2020-01-27 philipnienhuis Attached File- Added dbfwrite.m, #48291
        StatusNone Need Info
    2020-01-27 philipnienhuis Assigned toNone philipnienhuis
        Release5.1.90 other
        Operating SystemMicrosoft Windows Any
        Summary[octave forge](mapping/io) Corrupt output when a single record is written with shapewrite [octave forge](io) Corrupt output when a single row of data is written with dbfwrite

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code