Skip to content

Commit

Permalink
Merge pull request #340 from Maxxen/geoparquet
Browse files Browse the repository at this point in the history
Port changes from stable, add `ST_HasZ/M`, `ST_ZMFlags`, add `WKB_BLOB` specializations.
  • Loading branch information
Maxxen authored Jun 12, 2024
2 parents 011524f + 45d3750 commit dbb9971
Show file tree
Hide file tree
Showing 21 changed files with 775 additions and 50 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/StableDistributionPipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ name: Stable Extension Distribution Pipeline
on:
pull_request:
branches:
- v0.10.3
- v1.0.0
paths-ignore:
- '**/README.md'
- 'doc/**'
push:
branches:
- v0.10.3
- v1.0.0
paths-ignore:
- '**/README.md'
- 'doc/**'
Expand All @@ -24,17 +24,17 @@ concurrency:
jobs:
duckdb-stable-build:
name: Build extension binaries
uses: duckdb/extension-ci-tools/.github/workflows/_extension_distribution.yml@v0.10.3
uses: duckdb/extension-ci-tools/.github/workflows/_extension_distribution.yml@v1.0.0
with:
duckdb_version: v0.10.3
duckdb_version: v1.0.0
extension_name: spatial

duckdb-stable-deploy:
name: Deploy extension binaries
needs: duckdb-stable-build
uses: duckdb/extension-ci-tools/.github/workflows/_extension_deploy.yml@v0.10.3
uses: duckdb/extension-ci-tools/.github/workflows/_extension_deploy.yml@v1.0.0
secrets: inherit
with:
duckdb_version: v0.10.3
duckdb_version: v1.0.0
extension_name: spatial
deploy_latest: ${{ startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/v0.10.3' }}
deploy_latest: ${{ startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/v1.0.0' }}
1 change: 1 addition & 0 deletions deps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ ExternalProject_Add(
-DOGR_ENABLE_DRIVER_MVT=ON
-DOGR_ENABLE_DRIVER_PMTILES=ON
-DOGR_ENABLE_DRIVER_JSONFG=ON
-DOGR_ENABLE_DRIVER_GTFS=ON

# Drivers requiring network/curl
-DOGR_ENABLE_DRIVER_AMIGOCLOUD=${SPATIAL_USE_NETWORK}
Expand Down
170 changes: 166 additions & 4 deletions docs/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
| [ST_Distance](#st_distance) | Returns the distance between two geometries. |
| [ST_Distance_Sphere](#st_distance_sphere) | Returns the haversine distance between two geometries. |
| [ST_Distance_Spheroid](#st_distance_spheroid) | Returns the distance between two geometries in meters using a ellipsoidal model of the earths surface |
| [ST_Dump](#st_dump) | Dumps a geometry into a set of sub-geometries |
| [ST_Dump](#st_dump) | Dumps a geometry into a set of sub-geometries and their "path" in the original geometry. |
| [ST_EndPoint](#st_endpoint) | Returns the end point of a line. |
| [ST_Envelope](#st_envelope) | Returns the minimum bounding box for the input geometry as a polygon geometry. |
| [ST_Equals](#st_equals) | Compares two geometries for equality |
Expand All @@ -47,6 +47,8 @@
| [ST_GeomFromText](#st_geomfromtext) | Deserializes a GEOMETRY from a WKT string, optionally ignoring invalid geometries |
| [ST_GeomFromWKB](#st_geomfromwkb) | Deserializes a GEOMETRY from a WKB encoded blob |
| [ST_GeometryType](#st_geometrytype) | Returns a 'GEOMETRY_TYPE' enum identifying the input geometry type. |
| [ST_HasM](#st_hasm) | Check if the input geometry has M values. |
| [ST_HasZ](#st_hasz) | Check if the input geometry has Z values. |
| [ST_Hilbert](#st_hilbert) | Encodes the X and Y values as the hilbert curve index for a curve covering the given bounding box |
| [ST_Intersection](#st_intersection) | Returns the "intersection" of geom1 and geom2 |
| [ST_Intersects](#st_intersects) | Returns true if two geometries intersects |
Expand Down Expand Up @@ -82,6 +84,7 @@
| [ST_Point4D](#st_point4d) | Creates a POINT_4D |
| [ST_PointN](#st_pointn) | Returns the n'th vertex from the input geometry as a point geometry |
| [ST_PointOnSurface](#st_pointonsurface) | Returns a point that is guaranteed to be on the surface of the input geometry. Sometimes a useful alternative to ST_Centroid. |
| [ST_Points](#st_points) | Collects all the vertices in the geometry into a multipoint |
| [ST_QuadKey](#st_quadkey) | Computes a quadkey from a given lon/lat point. |
| [ST_ReducePrecision](#st_reduceprecision) | Returns the geometry with all vertices reduced to the target precision |
| [ST_RemoveRepeatedPoints](#st_removerepeatedpoints) | Returns a new geometry with repeated points removed, optionally within a target distance of eachother. |
Expand All @@ -101,15 +104,18 @@
| [ST_YMax](#st_ymax) | Returns the maximum Y value of a geometry |
| [ST_YMin](#st_ymin) | Returns the minimum Y value of a geometry |
| [ST_Z](#st_z) | Returns the Z value of a point geometry, or NULL if not a point or empty |
| [ST_ZMFlag](#st_zmflag) | Returns a flag indicating the presence of Z and M values in the input geometry. |
| [ST_ZMax](#st_zmax) | Returns the maximum Z value of a geometry |
| [ST_ZMin](#st_zmin) | Returns the minimum Z value of a geometry |

**[Aggregate Functions](#aggregate-functions)**

| Function | Summary |
| --- | --- |
| [ST_Envelope_Agg](#st_envelope_agg) | Computes a minimal-bounding-box polygon 'enveloping' the set of input geometries |
| [ST_Intersection_Agg](#st_intersection_agg) | Computes the intersection of a set of geometries |
| [ST_Union_Agg](#st_union_agg) | Computes the union of a set of input geometries |

**[Table Functions](#table-functions)**

| Function | Summary |
Expand All @@ -118,6 +124,7 @@
| [ST_Read](#st_read) | Read and import a variety of geospatial file formats using the GDAL library. |
| [ST_ReadOSM](#st_readosm) | The ST_ReadOsm() table function enables reading compressed OpenStreetMap data directly from a `.osm.pbf file.` |
| [ST_Read_Meta](#st_read_meta) | Read and the metadata from a variety of geospatial file formats using the GDAL library. |

----

## Scalar Functions
Expand Down Expand Up @@ -704,7 +711,7 @@ st_point(52.3130, 4.7725)

### ST_Dump

_Dumps a geometry into a set of sub-geometries_
_Dumps a geometry into a set of sub-geometries and their "path" in the original geometry._

#### Signature

Expand All @@ -714,8 +721,6 @@ STRUCT(geom GEOMETRY, path INTEGER[])[] ST_Dump (col0 GEOMETRY)

#### Description

Dumps a geometry into a set of sub-geometries

Dumps a geometry into a set of sub-geometries and their "path" in the original geometry.

#### Example
Expand Down Expand Up @@ -792,6 +797,7 @@ _Returns the minimal bounding box enclosing the input geometry_

```sql
BOX_2D ST_Extent (col0 GEOMETRY)
BOX_2D ST_Extent (col0 WKB_BLOB)
```

#### Description
Expand Down Expand Up @@ -1015,6 +1021,7 @@ ANY ST_GeometryType (col0 POINT_2D)
ANY ST_GeometryType (col0 LINESTRING_2D)
ANY ST_GeometryType (col0 POLYGON_2D)
ANY ST_GeometryType (col0 GEOMETRY)
ANY ST_GeometryType (col0 WKB_BLOB)
```

#### Description
Expand All @@ -1023,6 +1030,88 @@ Returns a 'GEOMETRY_TYPE' enum identifying the input geometry type.



### ST_HasM

_Check if the input geometry has M values._

#### Signature

```sql
BOOLEAN ST_HasM (col0 GEOMETRY)
BOOLEAN ST_HasM (col0 WKB_BLOB)
```

#### Description

Check if the input geometry has M values.

#### Example

```sql
-- HasM for a 2D geometry
SELECT ST_HasM(ST_GeomFromText('POINT(1 1)'));
----
false

-- HasM for a 3DZ geometry
SELECT ST_HasM(ST_GeomFromText('POINT Z(1 1 1)'));
----
false

-- HasM for a 3DM geometry
SELECT ST_HasM(ST_GeomFromText('POINT M(1 1 1)'));
----
true

-- HasM for a 4D geometry
SELECT ST_HasM(ST_GeomFromText('POINT ZM(1 1 1 1)'));
----
true
```



### ST_HasZ

_Check if the input geometry has Z values._

#### Signature

```sql
BOOLEAN ST_HasZ (col0 GEOMETRY)
BOOLEAN ST_HasZ (col0 WKB_BLOB)
```

#### Description

Check if the input geometry has Z values.

#### Example

```sql
-- HasZ for a 2D geometry
SELECT ST_HasZ(ST_GeomFromText('POINT(1 1)'));
----
false

-- HasZ for a 3DZ geometry
SELECT ST_HasZ(ST_GeomFromText('POINT Z(1 1 1)'));
----
true

-- HasZ for a 3DM geometry
SELECT ST_HasZ(ST_GeomFromText('POINT M(1 1 1)'));
----
false

-- HasZ for a 4D geometry
SELECT ST_HasZ(ST_GeomFromText('POINT ZM(1 1 1 1)'));
----
true
```



### ST_Hilbert

_Encodes the X and Y values as the hilbert curve index for a curve covering the given bounding box_
Expand Down Expand Up @@ -1615,6 +1704,34 @@ Returns a point that is guaranteed to be on the surface of the input geometry. S



### ST_Points

_Collects all the vertices in the geometry into a multipoint_

#### Signature

```sql
GEOMETRY ST_Points (col0 GEOMETRY)
```

#### Description

Collects all the vertices in the geometry into a multipoint

#### Example

```sql
select st_points('LINESTRING(1 1, 2 2)'::geometry);
----
MULTIPOINT (1 1, 2 2)

select st_points('MULTIPOLYGON Z EMPTY'::geometry);
----
MULTIPOINT Z EMPTY
```



### ST_QuadKey

_Computes a quadkey from a given lon/lat point._
Expand Down Expand Up @@ -2022,6 +2139,51 @@ Returns the Z value of a point geometry, or NULL if not a point or empty



### ST_ZMFlag

_Returns a flag indicating the presence of Z and M values in the input geometry._

#### Signature

```sql
UTINYINT ST_ZMFlag (col0 GEOMETRY)
UTINYINT ST_ZMFlag (col0 WKB_BLOB)
```

#### Description

Returns a flag indicating the presence of Z and M values in the input geometry.
0 = No Z or M values
1 = M values only
2 = Z values only
3 = Z and M values

#### Example

```sql
-- ZMFlag for a 2D geometry
SELECT ST_ZMFlag(ST_GeomFromText('POINT(1 1)'));
----
0

-- ZMFlag for a 3DZ geometry
SELECT ST_ZMFlag(ST_GeomFromText('POINT Z(1 1 1)'));
----
2

-- ZMFlag for a 3DM geometry
SELECT ST_ZMFlag(ST_GeomFromText('POINT M(1 1 1)'));
----
1

-- ZMFlag for a 4D geometry
SELECT ST_ZMFlag(ST_GeomFromText('POINT ZM(1 1 1 1)'));
----
3
```



### ST_ZMax

_Returns the maximum Z value of a geometry_
Expand Down
2 changes: 1 addition & 1 deletion duckdb
Submodule duckdb updated 134 files
12 changes: 7 additions & 5 deletions generate_function_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
json({
name: function_name,
signatures: signatures,
tags: tags,
tags: func_tags,
description: description,
example: example
})
Expand All @@ -18,13 +18,13 @@
return: return_type,
params: list_zip(parameters, parameter_types)::STRUCT(name VARCHAR, type VARCHAR)[]
}) as signatures,
any_value(try_cast(comment AS STRUCT(key VARCHAR, value VARCHAR)[])) as tags,
any_value(tags) AS func_tags,
any_value(description) AS description,
any_value(example) AS example
FROM duckdb_functions()
FROM duckdb_functions() as funcs
WHERE function_type = '$FUNCTION_TYPE$'
GROUP BY function_name, function_type
HAVING list_contains(tags, {key: 'ext', value: 'spatial'})
HAVING func_tags['ext'] = ['spatial']
ORDER BY function_name
);
"""
Expand Down Expand Up @@ -62,11 +62,13 @@ def main():
f.write("## Function Index \n")
f.write("**[Scalar Functions](#scalar-functions)**\n\n")
write_table_of_contents(f, scalar_functions)
f.write("\n")
f.write("**[Aggregate Functions](#aggregate-functions)**\n\n")
write_table_of_contents(f, aggregate_functions)
f.write("\n")
f.write("**[Table Functions](#table-functions)**\n\n")
write_table_of_contents(f, table_functions)

f.write("\n")
f.write("----\n\n")

# Write basic functions
Expand Down
8 changes: 8 additions & 0 deletions spatial/include/spatial/core/functions/scalar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ struct CoreScalarFunctions {
RegisterStGeomFromHEXWKB(db);
RegisterStGeomFromText(db);
RegisterStGeomFromWKB(db);
RegisterStHas(db);
RegisterStHaversine(db);
RegisterStHilbert(db);
RegisterStIntersects(db);
Expand All @@ -45,6 +46,7 @@ struct CoreScalarFunctions {
RegisterStPerimeter(db);
RegisterStPoint(db);
RegisterStPointN(db);
RegisterStPoints(db);
RegisterStQuadKey(db);
RegisterStRemoveRepeatedPoints(db);
RegisterStStartPoint(db);
Expand Down Expand Up @@ -126,6 +128,9 @@ struct CoreScalarFunctions {
// ST_GeomFromWKB
static void RegisterStGeomFromWKB(DatabaseInstance &db);

// ST_Has(M/Z) + ST_ZMFlag
static void RegisterStHas(DatabaseInstance &db);

// ST_Haversine
static void RegisterStHaversine(DatabaseInstance &db);

Expand Down Expand Up @@ -174,6 +179,9 @@ struct CoreScalarFunctions {
// ST_PointN
static void RegisterStPointN(DatabaseInstance &db);

// ST_Points
static void RegisterStPoints(DatabaseInstance &db);

// ST_RemoveRepeatedPoints
static void RegisterStRemoveRepeatedPoints(DatabaseInstance &db);

Expand Down
Loading

0 comments on commit dbb9971

Please sign in to comment.