Skip to content
Draft
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
2 changes: 1 addition & 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
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
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
41 changes: 20 additions & 21 deletions pymeos/collections/geo/geoset.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,17 @@
intersection_set_geo,
minus_set_geo,
union_set_geo,
geoset_as_ewkt,
geoset_as_text,
geoset_out,
spatialset_as_ewkt,
spatialset_as_text,
geoset_make,
geoset_srid,
geoset_round,
spatialset_srid,
set_round,
minus_geo_set,
geomset_in,
geogset_in,
pgis_geometry_in,
geom_in,
geometry_to_gserialized,
pgis_geography_in,
geog_in,
geography_to_gserialized,
intersection_set_set,
minus_set_set,
Expand Down Expand Up @@ -53,9 +52,9 @@ def __str__(self, max_decimals: int = 15):
A new :class:`str` instance

MEOS Functions:
geoset_out
spatialset_as_text
"""
return geoset_out(self._inner, max_decimals)
return spatialset_as_text(self._inner, max_decimals)

def as_ewkt(self, max_decimals: int = 15) -> str:
"""
Expand All @@ -68,9 +67,9 @@ def as_ewkt(self, max_decimals: int = 15) -> str:
A :class:`str` instance.

MEOS Functions:
geoset_as_ewkt
spatialset_as_ewkt
"""
return geoset_as_ewkt(self._inner, max_decimals)
return spatialset_as_ewkt(self._inner, max_decimals)

def as_wkt(self, max_decimals: int = 15):
"""
Expand All @@ -83,9 +82,9 @@ def as_wkt(self, max_decimals: int = 15):
A :class:`str` instance.

MEOS Functions:
geoset_as_text
spatialset_as_text
"""
return geoset_as_text(self._inner, max_decimals)
return spatialset_as_text(self._inner, max_decimals)

def as_text(self, max_decimals: int = 15):
"""
Expand All @@ -98,9 +97,9 @@ def as_text(self, max_decimals: int = 15):
A :class:`str` instance.

MEOS Functions:
geoset_as_text
spatialset_as_text
"""
return geoset_as_text(self._inner, max_decimals)
return spatialset_as_text(self._inner, max_decimals)

# ------------------------- Conversions -----------------------------------

Expand Down Expand Up @@ -176,9 +175,9 @@ def srid(self) -> int:
An integer

MEOS Functions:
geoset_srid
spatialset_srid
"""
return geoset_srid(self._inner)
return spatialset_srid(self._inner)

# ------------------------- Topological Operations --------------------------------

Expand Down Expand Up @@ -306,17 +305,17 @@ def round(self: Self, max_decimals: int) -> Self:
A new :class:`GeoSet` object of the same subtype of ``self``.

MEOS Functions:
tpoint_roundgeoset_round
set_round
"""
return self.__class__(_inner=geoset_round(self._inner, max_decimals))
return self.__class__(_inner=set_round(self._inner, max_decimals))


class GeometrySet(GeoSet):
_mobilitydb_name = "geomset"

_parse_function = geomset_in
_parse_value_function = lambda x: (
pgis_geometry_in(x, -1) if isinstance(x, str) else geometry_to_gserialized(x)
geom_in(x, -1) if isinstance(x, str) else geometry_to_gserialized(x)
)


Expand All @@ -325,5 +324,5 @@ class GeographySet(GeoSet):

_parse_function = geogset_in
_parse_value_function = lambda x: (
pgis_geography_in(x, -1) if isinstance(x, str) else geography_to_gserialized(x)
geog_in(x, -1) if isinstance(x, str) else geography_to_gserialized(x)
)
8 changes: 4 additions & 4 deletions pymeos/main/tfloat.py
Original file line number Diff line number Diff line change
Expand Up @@ -877,9 +877,9 @@ def derivative(self) -> TFloat:
A new :class:`TFloat` instance.

MEOS Functions:
tfloat_derivative
temporal_derivative
"""
return Temporal._factory(tfloat_derivative(self._inner))
return Temporal._factory(temporal_derivative(self._inner))

# ------------------------- Transformations ----------------------------------
def to_degrees(self, normalize: bool = True) -> TFloat:
Expand Down Expand Up @@ -921,9 +921,9 @@ def round(self, max_decimals: int = 0) -> TFloat:
A new :class:`TFloat` instance.

MEOS Functions:
tfloat_round
temporal_round
"""
return Temporal._factory(tfloat_round(self._inner, max_decimals))
return Temporal._factory(temporal_round(self._inner, max_decimals))

# ------------------------- Split Operations ------------------------------
def value_split(self, size: float, start: Optional[float] = 0) -> List[Temporal]:
Expand Down
Loading
Loading