mrsnospam wrote:
RobJellinghaus wrote:
I'm not clear on what you want. You want to do a query for businesses within a given distance of a certain latitude/longitude?
Yes I want to do exactly this. Currently I get the resultset then calculate the great circle distance on each item. Great circle distance is a a complex calc but just a calc given two points nontheless.
So right now you are calculating great-circle distance
outside the database?
mrsnospam wrote:
RobJellinghaus wrote:
Perhaps the question to ask yourself is, how would you do this without Hibernate?
This does have to do with hibernate because what I really want is a resultset (from the database) containing Businesses within this distance./quote]
You seem to have missed my point. Right now you are calculating distances outside the database. You say that you want the database to do it (so you can do geoqueries based on distance to a point).
That is
not Hibernate's problem! Hibernate knows nothing about spatial queries or spatial indexing. You have to configure the
database itself to store your geopoints and handle your spatial queries.
For instance, from
this page on MySQL geoqueries:
Code:
SELECT
c.cab_driver,
ROUND(GLength(LineStringFromWKB(LineString(AsBinary(c.cab_loc),
AsBinary(a.address_loc)))))
AS distance
FROM cab c, address a
WHERE a.address = 'Foobar street 110'
ORDER BY distance ASC LIMIT 1;
If your database can't do something like that, then Hibernate's not going to be able to either.
Even if your database
does support geoqueries, I'm not sure HQL does! You can probably do some magic with UserTypes, though.
Cheers,
Rob