[ 
https://issues.apache.org/jira/browse/SEDONA-178?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17618877#comment-17618877
 ] 

Martin Andersson commented on SEDONA-178:
-----------------------------------------

I agree. I think option 3 is the way forward at least in the short term.

 

I did a version of option 3 here: 
[https://github.com/apache/incubator-sedona/compare/master...umartin:incubator-sedona:sedona178_2]

 

I wanted to avoid ST_Buffer. I my opinion correctness should never be 
compromised on. So the only valid solution with ST_Buffer is to execute the 
original predicate after the join (like st_intersects(st_buffer(a, x + margin), 
b) and st_distance(a, b) <= x).
 # Margin is hard to calculate.
 # ST_Buffer makes simple geometries a lot more complex so ST_Intersects might 
be expensive to calculate. In postgis: select 
st_npoints(st_buffer(st_geometryfromtext('POINT (1 1)'), 1)) = 33

My tweak is that I expanded the envelope instead of using st_buffer on the 
actual geometry. That way the buffered geometry is always a simple square and 
there is no need for a margin.

 

> Correctness issue in distance join queries
> ------------------------------------------
>
>                 Key: SEDONA-178
>                 URL: https://issues.apache.org/jira/browse/SEDONA-178
>             Project: Apache Sedona
>          Issue Type: Bug
>            Reporter: Martin Andersson
>            Priority: Major
>
> Hi,
> We are seeing erroneous results for some distance join queries.
>  
> Case 1:
> The following query gives no output even though the distance between the 
> geometries is 1.
> {{select *}}
> {{from (select ST_LineFromText('Linestring(1 1, 1 4)') as geom) a}}
> {{join (select st_point(1.0,5.0) as geom) b}}
> {{on st_distance(a.geom, b.geom) < 1.4}}
> I think the issue boils down to a misuse of/error in Circle class. 
> DistanceJoinExec.scala:60 will create a Circle from the linestring and a 
> radius of 1.4.
> Circle will compute the center point (1 2.5) and radius (1.5) for the 
> linestring. The actual radius used is max(radius(linestring), 1.4). See 
> Circle.java:80 
> For the query to work the Circle needs a radius 1.4 _larger_ than the 
> linestring. Like this:
> circle = new Circle(geom, 0.0);
> circle.setRadius(circle.getRadius() + 1.4)
>  
> Case 2:
> The following query matches the geometries even though the distance is not 
> less than 0.1. Actual distance is 1.
> {{select *}}
> {{from (select ST_LineFromText('Linestring(1 1, 1 3, 3 3)') as geom) a}}
> {{join (select st_point(2.0,2.0) as geom) b}}
> {{on st_distance(a.geom, b.geom) < 0.1}}
> Pseudo code for the join condition:
> new Circle(a.geom, 0.1).covers(b.geom)
> The circle does cover the point but the linestring is further away from the 
> point than 0.1
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to