Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Closed
hsieyuan opened this issue Nov 15, 2024 · 0 comments
Closed

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

hsieyuan opened this issue Nov 15, 2024 · 0 comments

Comments

@hsieyuan
Copy link

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)

hsieyuan added a commit to hsieyuan/geos that referenced this issue Nov 15, 2024
Fix the bug in LineString::getPointN, which causes the output point of GEOSGeomGetEndPoint loses the 'm' dimension
@pramsey pramsey closed this as completed Nov 16, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants