Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
5dd2dc9
Adds a first version of st_simplify which is the identity
ncordon Oct 6, 2025
b787a47
This does not work :____
ncordon Oct 7, 2025
4413503
Adds first working version, but only for foldable geometries
ncordon Oct 7, 2025
805ab89
Adds implementation for non foldable geometry
ncordon Oct 7, 2025
ed96b60
Adds tests
ncordon Oct 8, 2025
e5e3d44
Checkpoint
ncordon Oct 9, 2025
ac2e0be
Adds more tests
ncordon Oct 9, 2025
0e6e1e2
Update docs/changelog/136309.yaml
ncordon Oct 9, 2025
908632b
Updates changelog
ncordon Oct 9, 2025
dd2933e
Update docs/changelog/136309.yaml
ncordon Oct 9, 2025
6ab6bdc
Reshapes the code a bit
ncordon Oct 10, 2025
cec7793
Merge branch 'main' into st_simplify
ncordon Oct 10, 2025
4b164d0
Adds auto-generated tests for st_simplify
ncordon Oct 20, 2025
8bc10f8
checkpoint
ncordon Oct 20, 2025
7cc3afe
[CI] Auto commit changes from spotless
Oct 20, 2025
c117a19
Makes integers be a valid input for the tolerance
ncordon Oct 20, 2025
6fcfeb4
Merge remote-tracking branch 'upstream/main' into st_simplify
ncordon Oct 20, 2025
a88ba3c
Merge remote-tracking branch 'origin/main' into st_simplify
craigtaverner Oct 27, 2025
f216fb9
Fix merge conflicts
ncordon Oct 27, 2025
a199465
Merge remote-tracking branch 'origin/main' into st_simplify
craigtaverner Oct 27, 2025
dfabf12
temp
ncordon Nov 17, 2025
1aed14a
Goes through some pr feedback
ncordon Nov 18, 2025
253619e
[CI] Auto commit changes from spotless
Nov 18, 2025
9465cb0
Addresses more pr feedback
ncordon Nov 19, 2025
2b273fa
Merge remote-tracking branch 'upstream/main' into st_simplify
ncordon Nov 19, 2025
90b075d
Bumps jts version and addresses more pr feedback
ncordon Nov 20, 2025
5d9f936
Update docs/changelog/136309.yaml
ncordon Nov 26, 2025
6c8ed7d
Merge branch 'main' into st_simplify
ncordon Nov 26, 2025
a1e9d29
Bumps jts version to 1.20.0 (#138351)
ncordon Nov 25, 2025
ed20dd9
Adds PostGIS tests and tweaks the tolerance description
ncordon Nov 26, 2025
465cbec
Fixes automatic tests
ncordon Dec 1, 2025
06f0d74
Adds more unit tests
ncordon Dec 1, 2025
9c25ce0
Updates docs
ncordon Dec 1, 2025
5829ea8
Merge branch 'main' into st_simplify
ncordon Dec 1, 2025
f056837
Merge branch 'main' into st_simplify
ncordon Dec 2, 2025
6b5a8fe
Corrects bug when generating documentation
ncordon Dec 2, 2025
9bffd1a
Merge branch 'main' into st_simplify
ncordon Dec 2, 2025
51dc578
Merge branch 'main' into st_simplify
ncordon Dec 3, 2025
a251b62
Merge branch 'main' into st_simplify
ncordon Dec 5, 2025
a64229f
Merge remote-tracking branch 'origin/main' into st_simplify
craigtaverner Dec 9, 2025
283f546
Split spatial-jts tests out to separate file
craigtaverner Dec 9, 2025
c14f942
Support any number type for tolerance
craigtaverner Dec 9, 2025
47e211f
Some fixes (added more literal tests, support all number types for to…
craigtaverner Dec 9, 2025
89ac8cc
Addresses more pr feedback
ncordon Dec 10, 2025
bbfa066
[CI] Auto commit changes from spotless
Dec 10, 2025
5d4531f
Added support for multi-valued fields and initial doc-values evaluators
craigtaverner Dec 10, 2025
6a99b89
Merge branch 'st_simplify' of github.com:ncordon/elasticsearch into s…
craigtaverner Dec 10, 2025
c9408b4
Support doc-values for points in StSimplify
craigtaverner Dec 10, 2025
4c957b0
Merge branch 'st_simplify' of github.com:ncordon/elasticsearch into s…
craigtaverner Dec 10, 2025
15c06d3
Add st_simplify to the docs
craigtaverner Dec 10, 2025
5e443a3
Last nits
ncordon Dec 14, 2025
cc55c03
Fixes flaky test
ncordon Dec 15, 2025
44bf3ba
Merge remote-tracking branch 'upstream/main' into st_simplify
ncordon Dec 15, 2025
b57daa7
Merge remote-tracking branch 'upstream/main' into st_simplify
ncordon Dec 15, 2025
844b5f8
[CI] Auto commit changes from spotless
Dec 15, 2025
d838ace
Adds test for St Simplify and doc values
ncordon Dec 16, 2025
2fd8acb
Tweaks comment on test
ncordon Dec 16, 2025
dc7f70f
Merge branch 'main' into st_simplify
craigtaverner Dec 16, 2025
556dbca
Adds harcoded test cases so we always have typed data to test
ncordon Dec 16, 2025
90d17a7
Have StSimplify.fold() combine geometries, as we do for multi-value f…
craigtaverner Dec 17, 2025
82bcbec
Changes to the test
ncordon Dec 18, 2025
facd1ee
Merge branch 'main' into st_simplify
craigtaverner Dec 18, 2025
cd6e24f
Unflakes test
ncordon Dec 18, 2025
a1c27fe
Adds back version to docs
ncordon Dec 18, 2025
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
6 changes: 6 additions & 0 deletions docs/changelog/136309.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 136309
summary: Adds ST_SIMPLIFY geospatial function
area: ES|QL
type: enhancement
issues:
- 44747

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@
* [`ST_GEOTILE`](../../functions-operators/spatial-functions.md#esql-st_geotile) {applies_to}`stack: preview` {applies_to}`serverless: preview`
* [`ST_GEOHEX`](../../functions-operators/spatial-functions.md#esql-st_geohex) {applies_to}`stack: preview` {applies_to}`serverless: preview`
* [`ST_GEOHASH`](../../functions-operators/spatial-functions.md#esql-st_geohash) {applies_to}`stack: preview` {applies_to}`serverless: preview`
* [`ST_SIMPLIFY`](../../functions-operators/spatial-functions.md#esql-st_simplify) {applies_to}`stack: preview` {applies_to}`serverless: preview`
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,6 @@ mapped_pages:

:::{include} ../_snippets/functions/layout/st_geohash.md
:::

:::{include} ../_snippets/functions/layout/st_simplify.md
:::
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions x-pack/plugin/esql-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ base {

dependencies {
api project(path: xpackModule('mapper-version'))
api "org.locationtech.jts:jts-core:${versions.jts}"
testImplementation project(':test:framework')
testImplementation(testArtifact(project(xpackModule('core'))))
}
31 changes: 31 additions & 0 deletions x-pack/plugin/esql-core/licenses/jts-core-LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Eclipse Distribution License - v 1.0

Copyright (c) 2007, Eclipse Foundation, Inc. and its licensors.

All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

Neither the name of the Eclipse Foundation, Inc. nor the names of its
contributors may be used to endorse or promote products derived from this
software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

1 change: 1 addition & 0 deletions x-pack/plugin/esql-core/licenses/jts-core-NOTICE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,19 @@
import org.apache.lucene.util.BytesRef;
import org.elasticsearch.geometry.Geometry;
import org.elasticsearch.geometry.Point;
import org.elasticsearch.geometry.Rectangle;
import org.elasticsearch.geometry.utils.GeographyValidator;
import org.elasticsearch.geometry.utils.GeometryValidator;
import org.elasticsearch.geometry.utils.WellKnownBinary;
import org.elasticsearch.geometry.utils.WellKnownText;
import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.GeometryFactory;
import org.locationtech.jts.geom.LinearRing;
import org.locationtech.jts.geom.Polygon;
import org.locationtech.jts.geom.impl.CoordinateArraySequence;
import org.locationtech.jts.io.ParseException;
import org.locationtech.jts.io.WKTReader;
import org.locationtech.jts.io.WKTWriter;

import java.nio.ByteOrder;

Expand Down Expand Up @@ -125,4 +134,31 @@ public String wkbToWkt(BytesRef wkb) {
public Geometry wkbToGeometry(BytesRef wkb) {
return WellKnownBinary.fromWKB(validator(), false, wkb.bytes, wkb.offset, wkb.length);
}

public org.locationtech.jts.geom.Geometry wkbToJtsGeometry(BytesRef wkb) throws ParseException, IllegalArgumentException {
String wkt = wkbToWkt(wkb);
if (wkt.startsWith("BBOX")) {
Geometry geometry = WellKnownBinary.fromWKB(GeometryValidator.NOOP, true, wkb.bytes, wkb.offset, wkb.length);
if (geometry instanceof Rectangle rect) {
var bottomLeft = new Coordinate(rect.getMinX(), rect.getMinY());
var bottomRight = new Coordinate(rect.getMaxX(), rect.getMinY());
var topRight = new Coordinate(rect.getMaxX(), rect.getMaxY());
var topLeft = new Coordinate(rect.getMinX(), rect.getMaxY());

var coordinates = new Coordinate[] { bottomLeft, bottomRight, topRight, topLeft, bottomLeft };
var geomFactory = new GeometryFactory();
var linearRing = new LinearRing(new CoordinateArraySequence(coordinates), geomFactory);
return new Polygon(linearRing, null, geomFactory);
}
}
WKTReader reader = new WKTReader();
return reader.read(wkt);
}

public BytesRef jtsGeometryToWkb(org.locationtech.jts.geom.Geometry jtsGeometry) {
WKTWriter writer = new WKTWriter();
String wkt = writer.write(jtsGeometry);
return wktToWkb(wkt);
}

}
Loading
Loading