Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Port to mojo v0.6, begin implementing traits.
Browse files Browse the repository at this point in the history
  • Loading branch information
guidorice committed Dec 16, 2023
1 parent 1d83dea commit 02651ba
Show file tree
Hide file tree
Showing 24 changed files with 657 additions and 652 deletions.
17 changes: 14 additions & 3 deletions geo_features/geom/envelope.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@ from geo_features.geom.point import Point
from geo_features.geom.enums import CoordDims
from geo_features.geom.layout import Layout
from geo_features.geom.traits import Geometric, Emptyable
from geo_features.serialization.traits import JSONable, WKTable, Geoarrowable
from geo_features.serialization import (
WKTParser,
WKTable,
JSONParser,
JSONable,
Geoarrowable,
)


@value
@register_passable("trivial")
struct Envelope[dtype: DType](
Expand Down Expand Up @@ -146,6 +145,7 @@ struct Envelope[dtype: DType](

fn __str__(self) -> String:
return self.__repr__()

#
# Getters
#
Expand Down Expand Up @@ -200,6 +200,17 @@ struct Envelope[dtype: DType](
fn dims(self) -> Int:
return len(self.ogc_dims)

fn set_ogc_dims(inout self, ogc_dims: CoordDims):
"""
Setter for ogc_dims enum. May be only be useful if the Point constructor with variadic list of coordinate values.
(ex: when Point Z vs Point M is ambiguous.
"""
debug_assert(
len(self.ogc_dims) == 3 and len(ogc_dims) == 3,
"Unsafe change of dimension number",
)
self.ogc_dims = ogc_dims

fn has_height(self) -> Bool:
return (self.ogc_dims == CoordDims.PointZ) or (
self.ogc_dims == CoordDims.PointZM
Expand Down
10 changes: 10 additions & 0 deletions geo_features/geom/layout.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,13 @@ struct Layout[dtype: DType = DType.float64, offset_dtype: DType = DType.uint32](

fn has_measure(self) -> Bool:
return self.ogc_dims == CoordDims.PointM or self.ogc_dims == CoordDims.PointZM

fn set_ogc_dims(inout self, ogc_dims: CoordDims):
"""
Setter for ogc_dims enum. May be only be useful if the Point constructor with variadic list of coordinate values.
(ex: when Point Z vs Point M is ambiguous.
"""
debug_assert(
len(self.ogc_dims) == len(ogc_dims), "Unsafe change of dimension number"
)
self.ogc_dims = ogc_dims
Loading

0 comments on commit 02651ba

Please sign in to comment.