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: 28 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
python-version: [ "3.10", "3.11", "3.12", "3.13" ]
os: [ ubuntu-latest, macos-13, macos-14 ]
include:
- ld_path: "/usr/local/lib"
- ld_prefix: "/usr/local"
- os: macos-14
ld_path: "/opt/homebrew/lib"
ld_prefix: "/opt/homebrew"

steps:
- name: Checkout
Expand All @@ -38,7 +38,7 @@ jobs:
uses: awalsh128/cache-apt-pkgs-action@latest
if: runner.os == 'Linux'
with:
packages: build-essential cmake postgresql-server-dev-14 libproj-dev libjson-c-dev libgsl-dev libgeos-dev
packages: build-essential cmake postgresql-server-dev-16 libproj-dev libjson-c-dev libgsl-dev libgeos-dev
version: 1.0

- name: Get dependencies from homebrew (cache)
Expand All @@ -56,17 +56,32 @@ jobs:
brew reinstall python@3.11 || brew link --overwrite python@3.11
brew update

- name: Derive MEOS branch from package version
id: meos_branch
shell: bash
run: |
pymeos_version=$(sed -nE 's/^__version__ = "([^"]+)".*/\1/p' pymeos/__init__.py)
major_minor=$(echo "$pymeos_version" | sed -nE 's/^([0-9]+\.[0-9]+).*/\1/p')
candidate="stable-${major_minor}"
if git ls-remote --exit-code https://github.com/MobilityDB/MobilityDB "$candidate" >/dev/null 2>&1; then
meos_branch=$candidate
else
meos_branch="master"
fi
echo "Package version $pymeos_version => MEOS branch $meos_branch"
echo "meos_branch=$meos_branch" >> "$GITHUB_OUTPUT"

- name: Fetch MEOS sources
env:
BRANCH_NAME: ${{ github.base_ref || github.ref_name }}
run: |
git clone --branch ${{ env.BRANCH_NAME }} --depth 1 https://github.com/MobilityDB/MobilityDB
git clone --branch ${{ steps.meos_branch.outputs.meos_branch }} --depth 1 https://github.com/MobilityDB/MobilityDB

- name: Install MEOS
run: |
mkdir MobilityDB/build
cd MobilityDB/build
cmake .. -DMEOS=on
cmake .. -DMEOS=ON -DCBUFFER=ON -DPOSE=ON \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${{ matrix.ld_prefix }}
make -j
sudo make install

Expand All @@ -78,9 +93,10 @@ jobs:

- name: Fetch PyMEOS CFFI sources
env:
BRANCH_NAME: ${{ github.base_ref || github.ref_name }}
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
run: |
git clone --branch ${{ env.BRANCH_NAME }} --depth 1 https://github.com/MobilityDB/PyMEOS-CFFI
git clone --branch ${{ env.BRANCH_NAME }} --depth 1 https://github.com/MobilityDB/PyMEOS-CFFI \
|| git clone --branch ${{ github.base_ref || 'master' }} --depth 1 https://github.com/MobilityDB/PyMEOS-CFFI

- name: Install python dependencies
run: |
Expand All @@ -97,6 +113,6 @@ jobs:

- name: Test PyMEOS with pytest
run: |
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${{ matrix.ld_path }}
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:${{ matrix.ld_path }}
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${{ matrix.ld_prefix }}/lib
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:${{ matrix.ld_prefix }}/lib
pytest
25 changes: 24 additions & 1 deletion pymeos/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
MeosGeoJsonOutputError,
)

__version__ = "1.3.0-alpha-1"
__version__ = "1.4.0-alpha-1"
__all__ = [
# initialization
"pymeos_initialize",
Expand Down Expand Up @@ -66,6 +66,22 @@
"TGeogPointInst",
"TGeogPointSeq",
"TGeogPointSeqSet",
"TNpoint",
"TNpointInst",
"TNpointSeq",
"TNpointSeqSet",
"TCbuffer",
"TCbufferInst",
"TCbufferSeq",
"TCbufferSeqSet",
"TPose",
"TPoseInst",
"TPoseSeq",
"TPoseSeqSet",
"TRgeometry",
"TRgeometryInst",
"TRgeometrySeq",
"TRgeometrySeqSet",
# temporal
"Temporal",
"TInstant",
Expand All @@ -86,6 +102,13 @@
"GeoSet",
"GeometrySet",
"GeographySet",
"Npoint",
"NpointSet",
"Nsegment",
"Cbuffer",
"CbufferSet",
"Pose",
"PoseSet",
# extras
"TInterpolation",
# aggregators
Expand Down
4 changes: 2 additions & 2 deletions pymeos/aggregators/point_aggregators.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ class TemporalPointExtentAggregator(BaseAggregator[TPoint, STBox]):
includes all aggregated temporal numbers.

MEOS Functions:
tpoint_extent_transfn, temporal_tagg_finalfn
tspatial_extent_transfn, temporal_tagg_finalfn
"""

_add_function = tpoint_extent_transfn
_add_function = tspatial_extent_transfn

@classmethod
def _finish(cls, state) -> STBox:
Expand Down
25 changes: 13 additions & 12 deletions pymeos/boxes/stbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def _get_box(
elif isinstance(other, STBox):
other_box = other._inner
elif isinstance(other, TPoint):
other_box = tpoint_to_stbox(other._inner)
other_box = tspatial_to_stbox(other._inner)
elif allow_time_only and isinstance(other, Temporal):
other_box = tstzspan_to_stbox(temporal_to_tstzspan(other._inner))
elif allow_time_only and isinstance(other, datetime):
Expand Down Expand Up @@ -190,7 +190,7 @@ def from_geometry(geom: shp.BaseGeometry, geodetic: bool = False) -> STBox:
A new :class:`STBox` instance.

MEOS Functions:
pgis_geometry_in, geo_to_stbox
geom_in, geo_to_stbox
"""
gs = geo_to_gserialized(geom, geodetic)
return STBox(_inner=geo_to_stbox(gs))
Expand Down Expand Up @@ -266,9 +266,9 @@ def from_tpoint(temporal: TPoint) -> STBox:
A new :class:`STBox` instance.

MEOS Functions:
tpoint_to_stbox
tspatial_to_stbox
"""
return STBox(_inner=tpoint_to_stbox(temporal._inner))
return STBox(_inner=tspatial_to_stbox(temporal._inner))

@staticmethod
def from_expanding_bounding_box(
Expand All @@ -290,17 +290,18 @@ def from_expanding_bounding_box(
A new :class:`STBox` instance.

MEOS Functions:
geo_expand_space, tpoint_expand_space, stbox_expand_space
geo_to_stbox, tspatial_to_stbox, stbox_expand_space
"""
if isinstance(value, shp.BaseGeometry):
gs = geo_to_gserialized(value, geodetic)
result = geo_expand_space(gs, expansion)
box = geo_to_stbox(gs)
elif isinstance(value, TPoint):
result = tpoint_expand_space(value._inner, expansion)
box = tspatial_to_stbox(value._inner)
elif isinstance(value, STBox):
result = stbox_expand_space(value._inner, expansion)
box = value._inner
else:
raise TypeError(f"Operation not supported with type {value.__class__}")
result = stbox_expand_space(box, expansion)
return STBox(_inner=result)

# ------------------------- Output ----------------------------------------
Expand Down Expand Up @@ -939,7 +940,7 @@ def is_over_or_left(self, other: Union[shp.BaseGeometry, STBox, TPoint]) -> bool
overlap, ``False`` otherwise.

MEOS Functions:
overleft_stbox_stbox, tpoint_to_stbox
overleft_stbox_stbox, tspatial_to_stbox
"""
return overleft_stbox_stbox(self._inner, self._get_box(other))

Expand Down Expand Up @@ -1198,7 +1199,7 @@ def nearest_approach_distance(
elif isinstance(other, STBox):
return nad_stbox_stbox(self._inner, other._inner)
elif isinstance(other, TPoint):
return nad_tpoint_stbox(other._inner, self._inner)
return nad_tgeo_stbox(other._inner, self._inner)
else:
raise TypeError(f"Operation not supported with type {other.__class__}")

Expand Down Expand Up @@ -1331,9 +1332,9 @@ def tile(
geo_to_gserialized(origin, self.geodetic())
if origin is not None
else (
pgis_geography_in("Point(0 0 0)", -1)
geog_in("Point(0 0 0)", -1)
if self.geodetic()
else pgis_geometry_in("Point(0 0 0)", -1)
else geom_in("Point(0 0 0)", -1)
)
)
tiles, count = stbox_space_time_tiles(self._inner, sz, sz, sz, dt, gs, st)
Expand Down
10 changes: 10 additions & 0 deletions pymeos/collections/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
from .time import *
from .text import *
from .geo import *
from .npoint import *
from .cbuffer import *
from .pose import *

__all__ = [
"Set",
Expand All @@ -30,4 +33,11 @@
"FloatSet",
"FloatSpan",
"FloatSpanSet",
"Npoint",
"NpointSet",
"Nsegment",
"Cbuffer",
"CbufferSet",
"Pose",
"PoseSet",
]
2 changes: 1 addition & 1 deletion pymeos/collections/base/spanset.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def __init__(
self._inner = self.__class__._parse_function(string)
else:
spans = [self.__class__._parse_value_function(p) for p in span_list]
self._inner = spanset_make(spans, normalize, True)
self._inner = spanset_make(spans)

def __copy__(self: Self) -> Self:
"""
Expand Down
4 changes: 4 additions & 0 deletions pymeos/collections/cbuffer/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from .cbuffer import Cbuffer
from .cbufferset import CbufferSet

__all__ = ["Cbuffer", "CbufferSet"]
Loading