Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/portable-parity.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: portable-aliases parity

# Gates the portable bare-name dialect (RFC #920; MEOS-API cross-repo
# handoff PR #9): GoMEOS's exposed CGO symbol set — the hand-written root
# package plus the IDL-driven generated surface (tools/_preview, emitted
# by tools/codegen.py from tools/meos-idl.json, the MEOS-API parser's
# JSON output) — must remain a superset of portableAliases.bareNames:
# 29/29, 0 unbacked, and every one of the six in-scope user-facing type
# families (temporal, geo, cbuffer, npoint, pose, rgeo) covered.
# cbuffer/npoint/pose/rgeo are full temporal types and are never excluded
# from the parity headline.
#
# Neither job needs libmeos/CGO: both audit the source statically, so the
# gate is self-contained and cannot be flaked by the C toolchain.

on:
push:
pull_request:

jobs:
parity:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Parity gate (script — exposed symbol set ⊇ bareNames)
run: python3 tools/portable_parity.py --check

- uses: actions/setup-go@v5
with:
go-version: '1.23'

- name: Parity gate (Go test — language-independent mirror)
env:
CGO_ENABLED: '0'
run: go test ./tools/parity/ -v
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# GoMEOS

[MEOS (Mobility Engine, Open Source)](https://www.libmeos.org/) is a C library which enables the manipulation of
temporal and spatio-temporal data based on [MobilityDB](https://mobilitydb.com/)'s data types and functions.
temporal and spatio-temporal data based on [MobilityDB](https://github.com/MobilityDB/MobilityDB)'s data types and functions.

GoMEOS is a Go library that wraps the MEOS C library using [CGO](https://pkg.go.dev/cmd/cgo), providing a set of Go functions that allows to use MEOS functionality by directly accessing C structs and C functions.
GoMEOS is a Go library that wraps the MEOS C library using [CGO](https://pkg.go.dev/cmd/cgo), providing a set of Go functions that allows to use MEOS functionality by directly accessing C structs and C functions. It tracks MEOS 1.4.

GoMEOS exposes the functionality of MEOS and is meant to be used directly by the user.

The wrappers are generated from the [MEOS-API](https://github.com/MobilityDB/MEOS-API) `meos-idl.json` catalog rather than written by hand. To regenerate them against a given MEOS version, see [`tools/README.md`](tools/README.md).

# Usage

## Installation
Expand Down
2 changes: 2 additions & 0 deletions cast.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
#define gunion_spanset_spanset union_spanset_spanset


#include <stddef.h>
#include "meos.h"
#include "meos_geo.h"
#include <stdio.h>
#include <stdlib.h>

Expand Down
14 changes: 7 additions & 7 deletions geo.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,55 +17,55 @@ type Geom struct {
func NewGeom(geom_str string, typemod int) Geom {
c_geom_str := C.CString(geom_str)
defer C.free(unsafe.Pointer(c_geom_str))
c_geom := C.pgis_geometry_in(c_geom_str, C.int(typemod))
c_geom := C.geom_in(c_geom_str, C.int(typemod))
g := Geom{_inner: c_geom}
return g
}

func PgisGeometryIn(input string, typemod int) *Geom {
c_geom_str := C.CString(input)
defer C.free(unsafe.Pointer(c_geom_str))
c_geom := C.pgis_geometry_in(c_geom_str, C.int(typemod))
c_geom := C.geom_in(c_geom_str, C.int(typemod))
g := &Geom{_inner: c_geom}
return g
}

func PgisGeographyIn(input string, typemod int) *Geom {
c_geom_str := C.CString(input)
defer C.free(unsafe.Pointer(c_geom_str))
c_geom := C.pgis_geography_in(c_geom_str, C.int(typemod))
c_geom := C.geog_in(c_geom_str, C.int(typemod))
g := &Geom{_inner: c_geom}
return g
}

func GeographyFromHexEwkb(input string) *Geom {
c_geom_str := C.CString(input)
defer C.free(unsafe.Pointer(c_geom_str))
c_geom := C.geography_from_hexewkb(c_geom_str)
c_geom := C.geog_from_hexewkb(c_geom_str)
g := &Geom{_inner: c_geom}
return g
}

func GeometryFromHexEwkb(input string) *Geom {
c_geom_str := C.CString(input)
defer C.free(unsafe.Pointer(c_geom_str))
c_geom := C.geometry_from_hexewkb(c_geom_str)
c_geom := C.geom_from_hexewkb(c_geom_str)
g := &Geom{_inner: c_geom}
return g
}

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
}
Expand Down
2 changes: 1 addition & 1 deletion main_temporal.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ func TemporalTPrecision[T Temporal](temp T, duration timeutil.Timedelta, start t
// TemporalAppendTInstant Append an instant to a temporal value
func TemporalAppendTInstant[T Temporal, TI TInstant](temp T, inst TI, max_dist float64, max_time timeutil.Timedelta, expand bool) Temporal {
m := TimeDeltaToInterval(max_time)
res := C.temporal_append_tinstant(temp.Inner(), C.cast_temporal_to_tinstant(inst.Inner()), C.double(max_dist), &m, C.bool(expand))
res := C.temporal_append_tinstant(temp.Inner(), C.cast_temporal_to_tinstant(inst.Inner()), C.interpType(C.INTERP_NONE), C.double(max_dist), &m, C.bool(expand))
return CreateTemporal(res)
}

Expand Down
6 changes: 3 additions & 3 deletions main_tfloat.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ func TFloatValueAtTimestamp[TF TFloat](tf TF, ts time.Time) float64 {

// TFloatDerivative Return the derivative of a temporal number
func TFloatDerivative[TF TFloat](tf TF) Temporal {
return CreateTemporal(C.tfloat_derivative(tf.Inner()))
return CreateTemporal(C.temporal_derivative(tf.Inner()))
}

// TFloatToDegrees Return a temporal number transformed from radians to degrees
Expand All @@ -391,7 +391,7 @@ func TFloatToRadians[TF TFloat](tf TF) Temporal {

// TFloatRound Return a temporal float with the precision of the values set to a number of decimal places
func TFloatRound[TF TFloat](tf TF, max_decimals int) Temporal {
return CreateTemporal(C.tfloat_round(tf.Inner(), C.int(max_decimals)))
return CreateTemporal(C.temporal_round(tf.Inner(), C.int(max_decimals)))
}

// TFloatShiftValue Return a temporal integer whose value dimension is shifted by a value
Expand Down Expand Up @@ -465,7 +465,7 @@ func DivFloatTFloat[TF TFloat](value float64, tf TF) Temporal {

// DistanceTFloatFloat returns the temporal distance between a temporal float and a constant float.
func DistanceTFloatFloat[TF TFloat](tf TF, value float64) Temporal {
c_temp := C.distance_tfloat_float(tf.Inner(), C.double(value))
c_temp := C.tdistance_tfloat_float(tf.Inner(), C.double(value))
return CreateTemporal(c_temp)
}

Expand Down
6 changes: 3 additions & 3 deletions main_tgeogpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func NewTGeogPointInst(tgmpi_in string) *TGeogPointInst {
}

func (tgmpi *TGeogPointInst) TPointOut(maxdd int) string {
c_tgmpi_out := C.tpoint_as_text(tgmpi._inner, C.int(maxdd))
c_tgmpi_out := C.tspatial_as_text(tgmpi._inner, C.int(maxdd))
defer C.free(unsafe.Pointer(c_tgmpi_out))
tgmpi_out := C.GoString(c_tgmpi_out)
return tgmpi_out
Expand Down Expand Up @@ -82,7 +82,7 @@ func NewTGeogPointSeq(tgmpi_in string) TGeogPointSeq {
}

func (tgmpi *TGeogPointSeq) TPointOut(maxdd int) string {
c_tgmpi_out := C.tpoint_as_text(tgmpi._inner, C.int(maxdd))
c_tgmpi_out := C.tspatial_as_text(tgmpi._inner, C.int(maxdd))
defer C.free(unsafe.Pointer(c_tgmpi_out))
tgmpi_out := C.GoString(c_tgmpi_out)
return tgmpi_out
Expand Down Expand Up @@ -129,7 +129,7 @@ func NewTGeogPointSeqSet(tgmpi_in string) *TGeogPointSeqSet {
}

func (tgmpi *TGeogPointSeqSet) TPointOut(maxdd int) string {
c_tgmpi_out := C.tpoint_as_text(tgmpi._inner, C.int(maxdd))
c_tgmpi_out := C.tspatial_as_text(tgmpi._inner, C.int(maxdd))
defer C.free(unsafe.Pointer(c_tgmpi_out))
tgmpi_out := C.GoString(c_tgmpi_out)
return tgmpi_out
Expand Down
8 changes: 4 additions & 4 deletions main_tgeompoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ func NewEmptyTGeomPointInst() TGeomPointInst {
}

func (tgmpi *TGeomPointInst) TPointOut(maxdd int) string {
c_tgmpi_out := C.tpoint_as_text(tgmpi._inner, C.int(maxdd))
c_tgmpi_out := C.tspatial_as_text(tgmpi._inner, C.int(maxdd))
defer C.free(unsafe.Pointer(c_tgmpi_out))
tgmpi_out := C.GoString(c_tgmpi_out)
return tgmpi_out
}

func (tgmpi *TGeomPointInst) TInstantOut(maxdd int) string {
c_tgmpi_out := C.tpoint_as_text(tgmpi._inner, C.int(maxdd))
c_tgmpi_out := C.tspatial_as_text(tgmpi._inner, C.int(maxdd))
defer C.free(unsafe.Pointer(c_tgmpi_out))
tgmpi_out := C.GoString(c_tgmpi_out)
return tgmpi_out
Expand Down Expand Up @@ -93,7 +93,7 @@ func NewTGeomPointSeqFromWKB(tgmpi_in string) *TGeomPointSeq {
}

func (tgmpi *TGeomPointSeq) TPointOut(maxdd int) string {
c_tgmpi_out := C.tpoint_as_text(tgmpi._inner, C.int(maxdd))
c_tgmpi_out := C.tspatial_as_text(tgmpi._inner, C.int(maxdd))
defer C.free(unsafe.Pointer(c_tgmpi_out))
tgmpi_out := C.GoString(c_tgmpi_out)
return tgmpi_out
Expand Down Expand Up @@ -144,7 +144,7 @@ func NewTGeomPointSeqSet(tgmpi_in string) *TGeomPointSeqSet {
}

func (tgmpi *TGeomPointSeqSet) TPointOut(maxdd int) string {
c_tgmpi_out := C.tpoint_as_text(tgmpi._inner, C.int(maxdd))
c_tgmpi_out := C.tspatial_as_text(tgmpi._inner, C.int(maxdd))
defer C.free(unsafe.Pointer(c_tgmpi_out))
tgmpi_out := C.GoString(c_tgmpi_out)
return tgmpi_out
Expand Down
2 changes: 1 addition & 1 deletion main_tnumber.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func TNumberDeltaValue[TN TNumber](tn TN) Temporal {

// DistanceTNumberTNumber returns the temporal distance between two temporal numbers.
func DistanceTNumberTNumber[TN1 TNumber, TN2 TNumber](tn1 TN1, tn2 TN2) Temporal {
c_temp := C.distance_tnumber_tnumber(tn1.Inner(), tn2.Inner())
c_temp := C.tdistance_tnumber_tnumber(tn1.Inner(), tn2.Inner())
return CreateTemporal(c_temp)
}

Expand Down
Loading
Loading