TravelMapping / DataProcessing

Data Processing Scripts and Programs for Travel Mapping Project
4 stars 6 forks source link

LABEL_TOO_LONG and malformed URLs #467

Closed yakra closed 3 years ago

yakra commented 3 years ago

The LABEL_TOO_LONG datacheck is performed in Route::read_wpt after the Waypoint ctor returns. Problem is, the Waypoint ctor performs the MALFORMED_URL, MALFORMED_LAT & MALFORMED_LON datachecks. If any of these 3 coexist with LABEL_TOO_LONG, they'll try to insert a label that's too long to fit into the DB.

yakra commented 3 years ago
yakra commented 3 years ago

Adding

/* DEBUG */
if (root == "me.i295")
{   std::ofstream dump295(Args::logfilepath+"/me.i295.dump");
    dump295.write(wptdata, wptdatasize);
    dump295.close();

    char lstr[2050];
    std::ofstream lines295(Args::logfilepath+"/me.i295.lines");
    for (char*l : lines)
    {   sprintf(lstr, "%X\n", int(l-wptdata));
        lines295 << lstr;
    }
    lines295.close();
}

to Route::read_wpt right before the // per-route datachecks reveals...


Adding

/* DEBUG */
if (route->root == "me.i295")
    std::cout << "DEBUG: me.i295 @ " << line << std::endl;

to the Waypoint ctor between route = rte; and // split line into fields yields...

yakra commented 3 years ago
// process lines
for (unsigned int l = lines[1] < wptdata+2; l < lines.size()-1; l++)
{   // strip whitespace from end...     // l == 8 | lines[l] == 1FA | lines[l+1] == 1FC
    char* endchar = lines[l+1]-2;       // endchar == 1FA
    while (*endchar == 0) endchar--;    // *endchar == '7'; no change to endchar
    if (endchar <= lines[l]) continue;  // endchar == lines[l]; continue; here's the problem

Time to review the git blame and see when this was introduced and why, and what can be changed. Was it the "blank line at the beginning" bug? Yes.

yakra commented 3 years ago

Hopefully changing (endchar <= lines[l]) to (endchar < lines[l]) will work. I'll have to test this out on noreaster per #443.

yakra commented 3 years ago

Now we get:

[yakra@noreaster ~/ytm/DataProcessing/siteupdate/cplusplus]$ ~/diff _master/logs/datacheck.log _debug2/logs/datacheck.log 
1c1
< Log file created at: Tue Oct  5 14:27:05 2021
---
> Log file created at: Tue Oct  5 14:36:17 2021
1221a1222
> ausvic.c156;;;;SINGLE_FIELD_LINE;

An extra line at the end of the file contains a single space.