Opened 18 years ago

Last modified 17 years ago

#1036 closed defect (fixed)

XYMZ data in WKT leads to an error

Reported by: ari.jolma@… Owned by: Mateusz Łoskot
Priority: high Milestone:
Component: OGR_SF Version: unspecified
Severity: normal Keywords:
Cc: ari.jolma@…

Description

OGRWktReadPoints in ogrutils.cpp does not accept XYZM data, which one may get
for example from PostGIS.

Change History (5)

comment:1 by ari.jolma@…, 18 years ago

Please add this to ogrutils.cpp:374

        /* skip possible M coordinate for now */

	if( isdigit(szDelim[0]) || szDelim[0] == '-' || szDelim[0] == '.' )

	  pszInput = OGRWktReadToken( pszInput, szDelim );

comment:2 by warmerdam, 18 years ago

No rush on this Mateusz, though hopefully it can be addressed before the 
next release.  I think we should talk briefly about whether this approach is
ok before you apply it. 

comment:3 by warmerdam, 18 years ago

See also #1323.

comment:4 by Mateusz Łoskot, 17 years ago

Fixed handling XYZM coordinates in EWKT.
Here is simple test running without any crash or error message:

--------------------------------------------------------------------------------
#include <cassert>
#include <iostream>
#include <ogr_geometry.h>
#include <cpl_port.h>
using namespace std;

void test(int i, char* ewkt)
{
    cout << "--------------------\n"
         << "Test " << i
         << "\n--------------------\n"
         << "EWKT: " << ewkt << endl;

    char* wkt = NULL;
    OGRGeometry* g = NULL;
    OGRGeometryFactory::createFromWkt(&ewkt, NULL, &g);
    assert(NULL != g);

    OGRErr err = g->exportToWkt(&wkt);
    assert(OGRERR_NONE == err);

    OGRGeometryFactory::destroyGeometry(g);

    cout << "WKT : " << wkt << endl;
}

int main()
{
    char* data[] =
    {
        "POINT (10 20)",
        "POINT (10 20 1)",
        "POINT (10 20 5 5)",
        "MULTIPOINT (10 20,30 30)",
        "MULTIPOINT (10 20 5,30 30 7)",
        "MULTIPOINT (10 20 5 5,30 30 7 7)",
        "LINESTRING (10 10,20 20,30 30,40 40)",
        "LINESTRING (10 10 1,20 20 3,30 30 5,40 40 7)",
        "LINESTRING (10 10 1 2,20 20 3 4,30 30 5 6,40 40 7 8)",
        "MULTILINESTRING ((10 10,20 20),(30 30,40 40))",
        "MULTILINESTRING ((10 10 1,20 20 3),(30 30 5,40 40 7))",
        "MULTILINESTRING ((10 10 1 2,20 20 3 4),(30 30 5 6,40 40 7 8))",
        "POLYGON ((0 0,4 0,4 4,0 4,0 0),(1 1, 2 1, 2 2, 1 2,1 1))",
        "POLYGON ((0 0 0,4 0 0,4 4 0,0 4 0,0 0 0),(1 1 0, 2 1 0, 2 2 0, 1 2 0,1 1 0))",
        "POLYGON ((0 0 1 2,4 0 3 4,4 4 5 6,0 4 7 8,0 0 1 2))"
    };

    for (int i = 0; i < (sizeof(data)/sizeof(data[0])); i++)
    {
        test(i, data[i]);
    }

    return 0;
}
--------------------------------------------------------------------------------

comment:5 by Mateusz Łoskot, 17 years ago

Fix also submitted to branches/1.4
Note: See TracTickets for help on using tickets.