Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

CoordinateSequence: Raise error on invalid ordinateIndex #1245

Merged
merged 1 commit into from
Feb 26, 2025

Conversation

dbaston
Copy link
Member

@dbaston dbaston commented Feb 26, 2025

As discussed in #1244 (comment)

Mixed feelings about this, since the ability to set a Z value on an XY sequence without getting an error has existed since forever.

@dbaston dbaston requested a review from mwtoews February 26, 2025 03:48
@dr-jts
Copy link
Contributor

dr-jts commented Feb 26, 2025

This is the right thing to do, to prevent incorrect code.

@mwtoews
Copy link
Contributor

mwtoews commented Feb 26, 2025

Maybe also add a test for XYM?

template<>
template<>
void object::test<25>()
{
    set_test_name("setOrdinate on XYM coordinate");

    /* TODO: use GEOSCoordSeq_createWithDimensions() instead */
    double buffer[3];
    cs_ = GEOSCoordSeq_copyFromBuffer(buffer, 1, 0, 1);

    ensure("setX", GEOSCoordSeq_setOrdinate(cs_, 0, 0, 1));
    ensure("setY", GEOSCoordSeq_setOrdinate(cs_, 0, 1, 2));
    ensure("setZ", !GEOSCoordSeq_setOrdinate(cs_, 0, 2, 3));
    ensure("setM", GEOSCoordSeq_setOrdinate(cs_, 0, 3, 4));

    double x, y, m;
    ensure(GEOSCoordSeq_copyToArrays(cs_, &x, &y, nullptr, &m));

    ensure_equals("X", x, 1);
    ensure_equals("Y", y, 2);
    ensure_equals("M", m, 4);
}

@dbaston dbaston force-pushed the coordseq-setordinate-strict branch from a5ad89a to 5b2f551 Compare February 26, 2025 21:18
Co-authored-by: Mike Taves <mwtoews@gmail.com>
@dbaston dbaston force-pushed the coordseq-setordinate-strict branch from 5b2f551 to edf3a5b Compare February 26, 2025 21:20
@dbaston dbaston merged commit 472f417 into libgeos:main Feb 26, 2025
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants