[jira] [Commented] (JENA-1915) spatial:greatCircle appears to be returning wrong answers

2020-06-14 Thread Bryon Jacob (Jira)


[ 
https://issues.apache.org/jira/browse/JENA-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17135249#comment-17135249
 ] 

Bryon Jacob commented on JENA-1915:
---

Great - glad the tests were useful!

I'd imagine the differences are because I calculated using Haversine and the 
implementation in jena is Vincenty - both are measures of distance, but 
different algorithms that produce slightly different results...

> spatial:greatCircle appears to be returning wrong answers
> -
>
> Key: JENA-1915
> URL: https://issues.apache.org/jira/browse/JENA-1915
> Project: Apache Jena
>  Issue Type: Bug
>  Components: Spatial
>Affects Versions: Jena 3.13.1
>Reporter: Bryon Jacob
>Priority: Major
>  Time Spent: 20m
>  Remaining Estimate: 0h
>
> the `spatial:greatCircle` function appears broken - sometimes returning 
> negative numbers.  returning negative numbers can never be correct from a 
> distance function - but I've tried to produce something more useful than that 
> as a defect report and repro...
> I was trying to "port" some SPARQL queries where I'd written the great circle 
> function (Haversine formula) to use the spatial:greatCircle function - which 
> means I had a pretty good test case to see where the issue arises.  I 
> simplified my query down to a repeatable test that demonstrates the issue:
> note that in my original query, I was using a custom jena function to compute 
> `radians` - since that function won't be available to you in stock jena to 
> try this out, I've precomputed the radians values and put them in the VALUES 
> block next to lat/lon pairs.  This should be runnable on any stock Jena 
> instance with the jena-geosparql functions loaded.  Note that for most of the 
> distances computed, the two distances agree quite closely - but for the last 
> two, the jena function returns a negative number, where the hand-computed 
> value is a correct distance between those points 
> {code:java}
> PREFIX m: 
> PREFIX spatial: 
> # this is a namespace of custom functions, which won't be available in stock 
> Jena - to reproduce
> # this, I've pre-computed the radian values and included them in a VALUES 
> block below...
> # PREFIX f: 
> SELECT ?lat1 ?lon1 ?lat2 ?lon2 ?φ1 ?φ2 ?Δφ ?Δλ ?d1 ?d2
>  WHERE {
>  VALUES (?lat1 ?lon1 ?lat2 ?lon2 ?φ1 ?φ2 ?Δφ ?Δλ) {
>  # in my original query, I was computing radians using a custom 
> radians function, which won't be available 
>  # in stock Jena, so to make this reproducible I precomputed the 
> radians values needed for the Haversine
> (41.2572  -95.965641.2592 -95.93390.7201  0.7201  
> 0.  0.0006)
> (41.2572  -95.965641.2482 -96.072 0.7201  0.7199  
> -0.0002 -0.0019)
> (41.2572  -95.965641.5871 -93.626 0.7201  0.7258  
> 0.0058  0.0408)
> (41.2572  -95.965651.0472 -113.9998   0.7201  0.8909  
> 0.1709  -0.3148)
> (41.2572  -95.965640.7528 -73.98760.7201  0.7113  
> -0.0088 0.3836)
> (41.2572  -95.965649.7237 13.3422 0.7201  0.8678  
> 0.1478  1.9078)
> (41.2572  -95.9656-33.906518.4175 0.7201  
> -0.5918 -1.3119 1.9964)
> (41.2572  -95.9656-33.8646151.20990.7201  
> -0.5910 -1.3111 4.3140)
>  }
> 
> # calculate the "great circle" distance between the two (lat φ, long λ) 
> points, in kilometers.
> # these are the function calls in my original query, commented out and 
> replaced with VALUES above
> # BIND (f:radians(?lat1) AS ?φ1)
> # BIND (f:radians(?lat2) AS ?φ2)
> # BIND (f:radians(?lat2 - ?lat1) AS ?Δφ)
> # BIND (f:radians(?lon2 - ?lon1) AS ?Δλ)
> BIND (m:sin(?Δφ / 2) * m:sin(?Δφ / 2) + m:cos(?φ1) * m:cos(?φ2) * 
> m:sin(?Δλ / 2) * m:sin(?Δλ / 2) AS ?a)
> BIND (2 * m:atan2(m:sqrt(?a), m:sqrt(1 - ?a)) AS ?c)
> BIND (6371 AS ?RadiusOfEarthInKm)
> BIND (?RadiusOfEarthInKm * ?c AS ?d1)
> # call the Jena function for comparison
> BIND(spatial:greatCircle(?lat1, ?lon1, ?lat2, ?lon2, 
> ) AS ?d2)
> }
> {code}
>  
>  
>  
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (JENA-1915) spatial:greatCircle appears to be returning wrong answers

2020-06-14 Thread Greg Albiston (Jira)


[ 
https://issues.apache.org/jira/browse/JENA-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17135217#comment-17135217
 ] 

Greg Albiston commented on JENA-1915:
-

Hi Bryon,

Thanks for reporting this and the test cases. This has now been fixed on 
`master` branch with the test values you provided now being used as unit tests. 
There are still the minor discrepancies (less than 300m) which are likely due 
to rounding differences.

Thanks again,

Greg

> spatial:greatCircle appears to be returning wrong answers
> -
>
> Key: JENA-1915
> URL: https://issues.apache.org/jira/browse/JENA-1915
> Project: Apache Jena
>  Issue Type: Bug
>  Components: Spatial
>Affects Versions: Jena 3.13.1
>Reporter: Bryon Jacob
>Priority: Major
>  Time Spent: 20m
>  Remaining Estimate: 0h
>
> the `spatial:greatCircle` function appears broken - sometimes returning 
> negative numbers.  returning negative numbers can never be correct from a 
> distance function - but I've tried to produce something more useful than that 
> as a defect report and repro...
> I was trying to "port" some SPARQL queries where I'd written the great circle 
> function (Haversine formula) to use the spatial:greatCircle function - which 
> means I had a pretty good test case to see where the issue arises.  I 
> simplified my query down to a repeatable test that demonstrates the issue:
> note that in my original query, I was using a custom jena function to compute 
> `radians` - since that function won't be available to you in stock jena to 
> try this out, I've precomputed the radians values and put them in the VALUES 
> block next to lat/lon pairs.  This should be runnable on any stock Jena 
> instance with the jena-geosparql functions loaded.  Note that for most of the 
> distances computed, the two distances agree quite closely - but for the last 
> two, the jena function returns a negative number, where the hand-computed 
> value is a correct distance between those points 
> {code:java}
> PREFIX m: 
> PREFIX spatial: 
> # this is a namespace of custom functions, which won't be available in stock 
> Jena - to reproduce
> # this, I've pre-computed the radian values and included them in a VALUES 
> block below...
> # PREFIX f: 
> SELECT ?lat1 ?lon1 ?lat2 ?lon2 ?φ1 ?φ2 ?Δφ ?Δλ ?d1 ?d2
>  WHERE {
>  VALUES (?lat1 ?lon1 ?lat2 ?lon2 ?φ1 ?φ2 ?Δφ ?Δλ) {
>  # in my original query, I was computing radians using a custom 
> radians function, which won't be available 
>  # in stock Jena, so to make this reproducible I precomputed the 
> radians values needed for the Haversine
> (41.2572  -95.965641.2592 -95.93390.7201  0.7201  
> 0.  0.0006)
> (41.2572  -95.965641.2482 -96.072 0.7201  0.7199  
> -0.0002 -0.0019)
> (41.2572  -95.965641.5871 -93.626 0.7201  0.7258  
> 0.0058  0.0408)
> (41.2572  -95.965651.0472 -113.9998   0.7201  0.8909  
> 0.1709  -0.3148)
> (41.2572  -95.965640.7528 -73.98760.7201  0.7113  
> -0.0088 0.3836)
> (41.2572  -95.965649.7237 13.3422 0.7201  0.8678  
> 0.1478  1.9078)
> (41.2572  -95.9656-33.906518.4175 0.7201  
> -0.5918 -1.3119 1.9964)
> (41.2572  -95.9656-33.8646151.20990.7201  
> -0.5910 -1.3111 4.3140)
>  }
> 
> # calculate the "great circle" distance between the two (lat φ, long λ) 
> points, in kilometers.
> # these are the function calls in my original query, commented out and 
> replaced with VALUES above
> # BIND (f:radians(?lat1) AS ?φ1)
> # BIND (f:radians(?lat2) AS ?φ2)
> # BIND (f:radians(?lat2 - ?lat1) AS ?Δφ)
> # BIND (f:radians(?lon2 - ?lon1) AS ?Δλ)
> BIND (m:sin(?Δφ / 2) * m:sin(?Δφ / 2) + m:cos(?φ1) * m:cos(?φ2) * 
> m:sin(?Δλ / 2) * m:sin(?Δλ / 2) AS ?a)
> BIND (2 * m:atan2(m:sqrt(?a), m:sqrt(1 - ?a)) AS ?c)
> BIND (6371 AS ?RadiusOfEarthInKm)
> BIND (?RadiusOfEarthInKm * ?c AS ?d1)
> # call the Jena function for comparison
> BIND(spatial:greatCircle(?lat1, ?lon1, ?lat2, ?lon2, 
> ) AS ?d2)
> }
> {code}
>  
>  
>  
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (JENA-1915) spatial:greatCircle appears to be returning wrong answers

2020-06-14 Thread ASF subversion and git services (Jira)


[ 
https://issues.apache.org/jira/browse/JENA-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17135214#comment-17135214
 ] 

ASF subversion and git services commented on JENA-1915:
---

Commit bb90563d978b72c6ea378d22f51dc44bb7ea8f01 in jena's branch 
refs/heads/master from Greg Albiston
[ https://gitbox.apache.org/repos/asf?p=jena.git;h=bb90563 ]

Fixed JENA-1915 and added additional test values.

> spatial:greatCircle appears to be returning wrong answers
> -
>
> Key: JENA-1915
> URL: https://issues.apache.org/jira/browse/JENA-1915
> Project: Apache Jena
>  Issue Type: Bug
>  Components: Spatial
>Affects Versions: Jena 3.13.1
>Reporter: Bryon Jacob
>Priority: Major
>  Time Spent: 10m
>  Remaining Estimate: 0h
>
> the `spatial:greatCircle` function appears broken - sometimes returning 
> negative numbers.  returning negative numbers can never be correct from a 
> distance function - but I've tried to produce something more useful than that 
> as a defect report and repro...
> I was trying to "port" some SPARQL queries where I'd written the great circle 
> function (Haversine formula) to use the spatial:greatCircle function - which 
> means I had a pretty good test case to see where the issue arises.  I 
> simplified my query down to a repeatable test that demonstrates the issue:
> note that in my original query, I was using a custom jena function to compute 
> `radians` - since that function won't be available to you in stock jena to 
> try this out, I've precomputed the radians values and put them in the VALUES 
> block next to lat/lon pairs.  This should be runnable on any stock Jena 
> instance with the jena-geosparql functions loaded.  Note that for most of the 
> distances computed, the two distances agree quite closely - but for the last 
> two, the jena function returns a negative number, where the hand-computed 
> value is a correct distance between those points 
> {code:java}
> PREFIX m: 
> PREFIX spatial: 
> # this is a namespace of custom functions, which won't be available in stock 
> Jena - to reproduce
> # this, I've pre-computed the radian values and included them in a VALUES 
> block below...
> # PREFIX f: 
> SELECT ?lat1 ?lon1 ?lat2 ?lon2 ?φ1 ?φ2 ?Δφ ?Δλ ?d1 ?d2
>  WHERE {
>  VALUES (?lat1 ?lon1 ?lat2 ?lon2 ?φ1 ?φ2 ?Δφ ?Δλ) {
>  # in my original query, I was computing radians using a custom 
> radians function, which won't be available 
>  # in stock Jena, so to make this reproducible I precomputed the 
> radians values needed for the Haversine
> (41.2572  -95.965641.2592 -95.93390.7201  0.7201  
> 0.  0.0006)
> (41.2572  -95.965641.2482 -96.072 0.7201  0.7199  
> -0.0002 -0.0019)
> (41.2572  -95.965641.5871 -93.626 0.7201  0.7258  
> 0.0058  0.0408)
> (41.2572  -95.965651.0472 -113.9998   0.7201  0.8909  
> 0.1709  -0.3148)
> (41.2572  -95.965640.7528 -73.98760.7201  0.7113  
> -0.0088 0.3836)
> (41.2572  -95.965649.7237 13.3422 0.7201  0.8678  
> 0.1478  1.9078)
> (41.2572  -95.9656-33.906518.4175 0.7201  
> -0.5918 -1.3119 1.9964)
> (41.2572  -95.9656-33.8646151.20990.7201  
> -0.5910 -1.3111 4.3140)
>  }
> 
> # calculate the "great circle" distance between the two (lat φ, long λ) 
> points, in kilometers.
> # these are the function calls in my original query, commented out and 
> replaced with VALUES above
> # BIND (f:radians(?lat1) AS ?φ1)
> # BIND (f:radians(?lat2) AS ?φ2)
> # BIND (f:radians(?lat2 - ?lat1) AS ?Δφ)
> # BIND (f:radians(?lon2 - ?lon1) AS ?Δλ)
> BIND (m:sin(?Δφ / 2) * m:sin(?Δφ / 2) + m:cos(?φ1) * m:cos(?φ2) * 
> m:sin(?Δλ / 2) * m:sin(?Δλ / 2) AS ?a)
> BIND (2 * m:atan2(m:sqrt(?a), m:sqrt(1 - ?a)) AS ?c)
> BIND (6371 AS ?RadiusOfEarthInKm)
> BIND (?RadiusOfEarthInKm * ?c AS ?d1)
> # call the Jena function for comparison
> BIND(spatial:greatCircle(?lat1, ?lon1, ?lat2, ?lon2, 
> ) AS ?d2)
> }
> {code}
>  
>  
>  
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (JENA-1915) spatial:greatCircle appears to be returning wrong answers

2020-06-14 Thread ASF subversion and git services (Jira)


[ 
https://issues.apache.org/jira/browse/JENA-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17135215#comment-17135215
 ] 

ASF subversion and git services commented on JENA-1915:
---

Commit f7ec31cfda27b1e736e0fccbb2b75c506be6e335 in jena's branch 
refs/heads/master from GregAlbo
[ https://gitbox.apache.org/repos/asf?p=jena.git;h=f7ec31c ]

Merge pull request #756 from galbiston/great_circle_formula_fix

Fixed [JENA-1915] and added additional test values.

> spatial:greatCircle appears to be returning wrong answers
> -
>
> Key: JENA-1915
> URL: https://issues.apache.org/jira/browse/JENA-1915
> Project: Apache Jena
>  Issue Type: Bug
>  Components: Spatial
>Affects Versions: Jena 3.13.1
>Reporter: Bryon Jacob
>Priority: Major
>  Time Spent: 20m
>  Remaining Estimate: 0h
>
> the `spatial:greatCircle` function appears broken - sometimes returning 
> negative numbers.  returning negative numbers can never be correct from a 
> distance function - but I've tried to produce something more useful than that 
> as a defect report and repro...
> I was trying to "port" some SPARQL queries where I'd written the great circle 
> function (Haversine formula) to use the spatial:greatCircle function - which 
> means I had a pretty good test case to see where the issue arises.  I 
> simplified my query down to a repeatable test that demonstrates the issue:
> note that in my original query, I was using a custom jena function to compute 
> `radians` - since that function won't be available to you in stock jena to 
> try this out, I've precomputed the radians values and put them in the VALUES 
> block next to lat/lon pairs.  This should be runnable on any stock Jena 
> instance with the jena-geosparql functions loaded.  Note that for most of the 
> distances computed, the two distances agree quite closely - but for the last 
> two, the jena function returns a negative number, where the hand-computed 
> value is a correct distance between those points 
> {code:java}
> PREFIX m: 
> PREFIX spatial: 
> # this is a namespace of custom functions, which won't be available in stock 
> Jena - to reproduce
> # this, I've pre-computed the radian values and included them in a VALUES 
> block below...
> # PREFIX f: 
> SELECT ?lat1 ?lon1 ?lat2 ?lon2 ?φ1 ?φ2 ?Δφ ?Δλ ?d1 ?d2
>  WHERE {
>  VALUES (?lat1 ?lon1 ?lat2 ?lon2 ?φ1 ?φ2 ?Δφ ?Δλ) {
>  # in my original query, I was computing radians using a custom 
> radians function, which won't be available 
>  # in stock Jena, so to make this reproducible I precomputed the 
> radians values needed for the Haversine
> (41.2572  -95.965641.2592 -95.93390.7201  0.7201  
> 0.  0.0006)
> (41.2572  -95.965641.2482 -96.072 0.7201  0.7199  
> -0.0002 -0.0019)
> (41.2572  -95.965641.5871 -93.626 0.7201  0.7258  
> 0.0058  0.0408)
> (41.2572  -95.965651.0472 -113.9998   0.7201  0.8909  
> 0.1709  -0.3148)
> (41.2572  -95.965640.7528 -73.98760.7201  0.7113  
> -0.0088 0.3836)
> (41.2572  -95.965649.7237 13.3422 0.7201  0.8678  
> 0.1478  1.9078)
> (41.2572  -95.9656-33.906518.4175 0.7201  
> -0.5918 -1.3119 1.9964)
> (41.2572  -95.9656-33.8646151.20990.7201  
> -0.5910 -1.3111 4.3140)
>  }
> 
> # calculate the "great circle" distance between the two (lat φ, long λ) 
> points, in kilometers.
> # these are the function calls in my original query, commented out and 
> replaced with VALUES above
> # BIND (f:radians(?lat1) AS ?φ1)
> # BIND (f:radians(?lat2) AS ?φ2)
> # BIND (f:radians(?lat2 - ?lat1) AS ?Δφ)
> # BIND (f:radians(?lon2 - ?lon1) AS ?Δλ)
> BIND (m:sin(?Δφ / 2) * m:sin(?Δφ / 2) + m:cos(?φ1) * m:cos(?φ2) * 
> m:sin(?Δλ / 2) * m:sin(?Δλ / 2) AS ?a)
> BIND (2 * m:atan2(m:sqrt(?a), m:sqrt(1 - ?a)) AS ?c)
> BIND (6371 AS ?RadiusOfEarthInKm)
> BIND (?RadiusOfEarthInKm * ?c AS ?d1)
> # call the Jena function for comparison
> BIND(spatial:greatCircle(?lat1, ?lon1, ?lat2, ?lon2, 
> ) AS ?d2)
> }
> {code}
>  
>  
>  
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (JENA-1915) spatial:greatCircle appears to be returning wrong answers

2020-06-12 Thread Bryon Jacob (Jira)


[ 
https://issues.apache.org/jira/browse/JENA-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17134327#comment-17134327
 ] 

Bryon Jacob commented on JENA-1915:
---

also, in case it's useful - the results of the above query:


||lat1||lon1||lat2||lon2||φ1||φ2||Δφ||Δλ||d1||d2||
|41.2572|-95.9656|41.2592|-95.9339|0.7201|0.7201|0.|0.0006|2.8736|2.6591|
|41.2572|-95.9656|41.2482|-96.072|0.7201|0.7199|-0.0002|-0.0019|9.1893|8.9509|
|41.2572|-95.9656|41.5871|-93.626|0.7201|0.7258|0.0058|0.0408|198.3806|198.4888|
|41.2572|-95.9656|51.0472|-113.9998|0.7201|0.8909|0.1709|-0.3148|1757.1519|1756.8603|
|41.2572|-95.9656|40.7528|-73.9876|0.7201|0.7113|-0.0088|0.3836|1840.1915|1840.1844|
|41.2572|-95.9656|49.7237|13.3422|0.7201|0.8678|0.1478|1.9078|7781.1365|7780.9378|
|41.2572|-95.9656|-33.9065|18.4175|0.7201|-0.5918|-1.3119|1.9964|14312.6630|-5702.7114|
|41.2572|-95.9656|-33.8646|151.2099|0.7201|-0.5910|-1.3111|4.3140|14184.1430|-5830.9657|



> spatial:greatCircle appears to be returning wrong answers
> -
>
> Key: JENA-1915
> URL: https://issues.apache.org/jira/browse/JENA-1915
> Project: Apache Jena
>  Issue Type: Bug
>  Components: Spatial
>Affects Versions: Jena 3.13.1
>Reporter: Bryon Jacob
>Priority: Major
>
> the `spatial:greatCircle` function appears broken - sometimes returning 
> negative numbers.  returning negative numbers can never be correct from a 
> distance function - but I've tried to produce something more useful than that 
> as a defect report and repro...
> I was trying to "port" some SPARQL queries where I'd written the great circle 
> function (Haversine formula) to use the spatial:greatCircle function - which 
> means I had a pretty good test case to see where the issue arises.  I 
> simplified my query down to a repeatable test that demonstrates the issue:
> note that in my original query, I was using a custom jena function to compute 
> `radians` - since that function won't be available to you in stock jena to 
> try this out, I've precomputed the radians values and put them in the VALUES 
> block next to lat/lon pairs.  This should be runnable on any stock Jena 
> instance with the jena-geosparql functions loaded.  Note that for most of the 
> distances computed, the two distances agree quite closely - but for the last 
> two, the jena function returns a negative number, where the hand-computed 
> value is a correct distance between those points 
> {code:java}
> PREFIX m: 
> PREFIX spatial: 
> # this is a namespace of custom functions, which won't be available in stock 
> Jena - to reproduce
> # this, I've pre-computed the radian values and included them in a VALUES 
> block below...
> # PREFIX f: 
> SELECT ?lat1 ?lon1 ?lat2 ?lon2 ?φ1 ?φ2 ?Δφ ?Δλ ?d1 ?d2
>  WHERE {
>  VALUES (?lat1 ?lon1 ?lat2 ?lon2 ?φ1 ?φ2 ?Δφ ?Δλ) {
>  # in my original query, I was computing radians using a custom 
> radians function, which won't be available 
>  # in stock Jena, so to make this reproducible I precomputed the 
> radians values needed for the Haversine
> (41.2572  -95.965641.2592 -95.93390.7201  0.7201  
> 0.  0.0006)
> (41.2572  -95.965641.2482 -96.072 0.7201  0.7199  
> -0.0002 -0.0019)
> (41.2572  -95.965641.5871 -93.626 0.7201  0.7258  
> 0.0058  0.0408)
> (41.2572  -95.965651.0472 -113.9998   0.7201  0.8909  
> 0.1709  -0.3148)
> (41.2572  -95.965640.7528 -73.98760.7201  0.7113  
> -0.0088 0.3836)
> (41.2572  -95.965649.7237 13.3422 0.7201  0.8678  
> 0.1478  1.9078)
> (41.2572  -95.9656-33.906518.4175 0.7201  
> -0.5918 -1.3119 1.9964)
> (41.2572  -95.9656-33.8646151.20990.7201  
> -0.5910 -1.3111 4.3140)
>  }
> 
> # calculate the "great circle" distance between the two (lat φ, long λ) 
> points, in kilometers.
> # these are the function calls in my original query, commented out and 
> replaced with VALUES above
> # BIND (f:radians(?lat1) AS ?φ1)
> # BIND (f:radians(?lat2) AS ?φ2)
> # BIND (f:radians(?lat2 - ?lat1) AS ?Δφ)
> # BIND (f:radians(?lon2 - ?lon1) AS ?Δλ)
> BIND (m:sin(?Δφ / 2) * m:sin(?Δφ / 2) + m:cos(?φ1) * m:cos(?φ2) * 
> m:sin(?Δλ / 2) * m:sin(?Δλ / 2) AS ?a)
> BIND (2 * m:atan2(m:sqrt(?a), m:sqrt(1 - ?a)) AS ?c)
> BIND (6371 AS ?RadiusOfEarthInKm)
> BIND (?RadiusOfEarthInKm * ?c AS ?d1)
> # call the Jena function for comparison
>