Thanks to visit codestin.com
Credit goes to github.com

Skip to content

The output point of GEOSGeomGetEndPoint loses the 'm' dimension #1191

@hsieyuan

Description

@hsieyuan

bug demo:

#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <geos_c.h>

static void
geos_message_handler(const char* fmt, ...)
{
    va_list ap;
    va_start(ap, fmt);
    vprintf (fmt, ap);
    va_end(ap);
}

int main()
{
    /* Send notice and error messages to our stdout handler */
    initGEOS(geos_message_handler, geos_message_handler);

    /* One concave polygon */
    const char* wkt = "linestring m (10.05 10.28 5.84, 20.95 31.98 9.01, 21.98 29.80 12.84)";

    /* Read the WKT into geometry objects */
    GEOSWKTReader* reader = GEOSWKTReader_create();
    GEOSGeometry* geom = GEOSWKTReader_read(reader, wkt);
    GEOSGeometry* ret_geo = NULL;
    GEOSWKTReader_destroy(reader);

    /* Check for parse success */
    if (!geom) {
        finishGEOS();
        return 1;
    }

    ret_geo = GEOSGeomGetEndPoint(geom);

    GEOSWKTWriter *writer = GEOSWKTWriter_create();
    const char *wkt_output = GEOSWKTWriter_write(writer, ret_geo);

    // 4. print output WKT string
    printf("WKT: %s\n", wkt_output);

    /* Clean up the global context */
    finishGEOS();

    /* Done */
    return 0;
}

expected: POINT M (21.98 29.8 12.84)
print: POINT (21.98 29.8)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions