Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(geoarrow-types): Minimal type specifications #50

Merged
merged 33 commits into from
Jun 13, 2024

Conversation

paleolimbot
Copy link
Contributor

@paleolimbot paleolimbot commented May 18, 2024

A paired down version of #48. The scope of this PR is just to get the constants and parameterization of the type solidified along with how various components are combined (which is the powerful and annoying to replicate part).

import geoarrow.types as gt

user_request = gt.geoarrow()
user_request
# > TypeSpec(Encoding.GEOARROW)

inferred_from_data = gt.type_spec(
    dimensions="xy", geometry_type="point", edge_type="planar", crs=gt.OGC_CRS84
)
inferred_from_data
#> TypeSpec(GeometryType.POINT, Dimensions.XY, EdgeType.PLANAR, ProjJsonCrs(OGC:CRS84))

# Will error if a user typed a conflicting request (e.g., gt.linestring())
all_specified = gt.TypeSpec.coalesce_unspecified(user_request, inferred_from_data)
all_specified
#> TypeSpec(Encoding.GEOARROW, GeometryType.POINT, Dimensions.XY, EdgeType.PLANAR, ProjJsonCrs(OGC:CRS84))

# GeoPandas (or something else) can fill in defaults for things that were not specified
# or inferred but are required to create the full type
geopandas_defaults = gt.type_spec(
    encoding="wkb", coord_type="interleaved", edge_type="planar"
)
all_specified.with_defaults(geopandas_defaults)
#> TypeSpec(Encoding.GEOARROW, GeometryType.POINT, Dimensions.XY, CoordType.INTERLEAVED, EdgeType.PLANAR, ProjJsonCrs(OGC:CRS84))

@paleolimbot paleolimbot marked this pull request as ready for review May 28, 2024 13:44
@paleolimbot paleolimbot merged commit 492176d into geoarrow:main Jun 13, 2024
8 checks passed
@paleolimbot paleolimbot deleted the python-type-pkg-constants branch June 13, 2024 00:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant