# sis-commits mailing list archives

##### Site index · List index
Message view
Top
From "Peter Karich (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (SIS-45) Performance improvement of queryByPointRadius
Date Sun, 01 Jul 2012 11:29:18 GMT
```
[ https://issues.apache.org/jira/browse/SIS-45?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13404715#comment-13404715
]

Peter Karich commented on SIS-45:
---------------------------------

I've improved the query speed by additional 30% ! Now the distance is only an approximation
(but a good one for 'shorter' distances) based on the spherical projection:

http://en.wikipedia.org/wiki/Geographical_distance#Spherical_Earth_projected_to_a_plane

Here is the java code:

https://github.com/karussell/GraphHopper/blob/master/core/src/main/java/de/jetsli/graph/util/ApproxCalcDistance.java

http://stackoverflow.com/a/11261385/194609

> ---------------------------------------------
>
>                 Key: SIS-45
>                 URL: https://issues.apache.org/jira/browse/SIS-45
>             Project: Spatial Information Systems
>          Issue Type: Improvement
>          Components: distance functions
>            Reporter: Peter Karich
>            Assignee: Chris A. Mattmann
>             Fix For: 0.3-incubating
>
>
> If I didn't make a mistake a search with the normal distance method took ~2.4s and with
this distance method it takes only about 0.7s:
> {code}
>   public static double getHaversineDistance(double fromLat, double fromLon, double toLat,
double toLon) {
>     double dLat = Math.toRadians(toLat - fromLat);
>         double dLon = Math.toRadians(toLon - fromLon);
>         double a = Math.sin(dLat / 2) * Math.sin(dLat / 2)
* Math.sin(dLon / 2) * Math.sin(dLon / 2);
>         return EARTH_RADIUS * 2 * Math.asin(Math.sqrt(a));
>   }
> {code}
> Also one should think about normalizing the distance before the search so that one does
not need the whole last line which should give further speed improvements.
> I'm still unsure why it takes roughly the same time in my example for 10km, 20km and
40kmm where at every step a lot more nodes are involved. Normally I would say the mode nodes
- the more comparisons it'll take and the slower it should get. But it doesn't. Probably I'm
measuring wrong?

--
This message is automatically generated by JIRA.