Skip to content

Bump vendored MEOS headers to 1.3 and adapt CGO call sites#1

Open
estebanzimanyi wants to merge 2 commits into
mainfrom
bump/meos-1.3
Open

Bump vendored MEOS headers to 1.3 and adapt CGO call sites#1
estebanzimanyi wants to merge 2 commits into
mainfrom
bump/meos-1.3

Conversation

@estebanzimanyi
Copy link
Copy Markdown
Member

Adopts the unified spatial nomenclature (tpoint_* renamed to tspatial_* / tgeo_* depending on signature), the meos_initialize() split that moves the timezone to a separate call, and the temporal_append_tinstant interpType parameter. cast.h gains stddef.h so size_t resolves on hosts that do not transitively include it via meos.h.

Adopts the unified spatial nomenclature (tpoint_* renamed to tspatial_*
/ tgeo_* depending on signature), the meos_initialize() split that
moves the timezone to a separate call, and the temporal_append_tinstant
interpType parameter.  cast.h gains stddef.h so size_t resolves on
hosts that do not transitively include it via meos.h.
Copy link
Copy Markdown
Member

@Davichet-e Davichet-e left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, only minor things

Comment thread main_tpoint.go Outdated
// TPointSTBoxes Return an array of spatiotemporal boxes from the segments of a temporal point
func TPointSTBoxes[TP TPoint](tp TP, max_count int) ([]*STBox, error) {
var count C.int
_ = max_count
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If max_count is not used anymore, we should remove it

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 895af5d. Removed the unused max_count parameter from TPointSTBoxes and updated the only caller (example_main_tpoint_test.go).

Comment thread geo.go Outdated
Comment on lines 57 to 71
func GeographyFromText(input string, srid int) *Geom {
c_geom_str := C.CString(input)
defer C.free(unsafe.Pointer(c_geom_str))
c_geom := C.geography_from_text(c_geom_str, C.int(srid))
c_geom := C.geo_from_text(c_geom_str, C.int(srid))
g := &Geom{_inner: c_geom}
return g
}

func GeometryFromText(input string, srid int) *Geom {
c_geom_str := C.CString(input)
defer C.free(unsafe.Pointer(c_geom_str))
c_geom := C.geometry_from_text(c_geom_str, C.int(srid))
c_geom := C.geo_from_text(c_geom_str, C.int(srid))
g := &Geom{_inner: c_geom}
return g
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This functions are now the same, we could collapse them into one single GeoFromText

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 895af5d. Collapsed into a single GeoFromText; the two were byte-identical since geo_from_text is a single function under the 1.3 unified nomenclature, and there were no other callers.

Comment thread main_tpoint.go
Comment on lines 207 to 211
func TPointExpandSpace[TP TPoint](tp TP, other float64) *STBox {
box := C.tspatial_to_stbox(tp.Inner())
return &STBox{
_inner: C.tpoint_expand_space(tp.Inner(), C.double(other)),
_inner: C.stbox_expand_space(box, C.double(other)),
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is leaking memory since tspatial_to_stbox doesn't touch the input, it creates another stbox

Recommended:

func TPointExpandSpace[TP TPoint](tp TP, other float64) *STBox {
    box := C.tspatial_to_stbox(tp.Inner())
    defer C.free(unsafe.Pointer(box))
    return &STBox{
        _inner: C.stbox_expand_space(box, C.double(other)),
    }
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 895af5d. Added defer C.free(unsafe.Pointer(box)). Verified against MEOS source: tspatial_to_stbox returns a fresh palloc'd STBox and stbox_expand_space(const STBox *) returns a separate stbox_copy, so freeing the intermediate is safe and does not touch _inner. This also matches the C.free(unsafe.Pointer(res)) convention already used elsewhere in the package.

…and-space box

Collapse the now-identical GeographyFromText and GeometryFromText into a
single GeoFromText, since geo_from_text is one function under the 1.3
unified spatial nomenclature. Remove the unused max_count parameter from
TPointSTBoxes and update its caller. Free the intermediate STBox from
tspatial_to_stbox in TPointExpandSpace; stbox_expand_space copies its
input rather than adopting it, so the box was leaked.
@Davichet-e
Copy link
Copy Markdown
Member

Did we also run the tests to make sure we didn't break anything? Also maybe worth at some point adding a CI job

@estebanzimanyi
Copy link
Copy Markdown
Member Author

Ran the suite. Against a MEOS 1.3 library (built from MobilityDB stable-1.3), the GoMEOS package tests are green: 115/115 example tests pass and go vet is clean, with the meos_initialize() split and the tspatial_*/tgeo_* renames in place.

One caveat worth flagging: this PR pins MEOS 1.3 on purpose, and 1.4 changed several spatial-relationship signatures (tdwithin_tgeo_tgeo, tintersects_tgeo_geo, tintersects_tgeo_tgeo, ttouches_tgeo_geo gained bool, bool parameters). So PR #1 builds and passes only against a 1.3 libmeos; against a current/1.4 libmeos it does not compile (signature mismatch) and a binary that links a 1.4 libmeos against the vendored 1.3 headers SIGSEGVs. The current-MEOS path is #3 ("Bump GoMEOS to MEOS 1.4"). Tests for this PR therefore have to run against a 1.3 libmeos.

On CI: agreed, and it directly prevents this class of drift. The shape that works (just added to MEOS.NET PR #3) is a workflow that builds libmeos from the matching MobilityDB ref and runs the suite, here stable-1.3 + go test. Happy to add that workflow to this PR if you want it in scope.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants