spatial query

4 messages Options
Embed this post
Permalink
冉兵

spatial query

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)
Hi,
 
I'm new to HibernateSpatial but with great interests.
 
Can I do spatial query directly in the hql, something like find all restaurants within 5 km distance? The more general questions is if there is an abstraction in HQL that can do the usual geometry computation?
 
Thanks!
 
Bing
 

_______________________________________________
hibernatespatial-users mailing list
[hidden email]
http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users
Karel Maesen

Re: spatial query

Reply Threaded More More options
Print post
Permalink

Yes you can use postgis (or Oracle spatial) functions in HQL. Check  
the unit tests in the Hibernate Spatial project for examples. They  
generally follow the OGC names (which is the same as the pre-1.3  
Postgis names - those not starting with ST_).

Regards,
Karel


On 07 Jan 2009, at 05:46, Bing Ran wrote:

> Hi,
>
> I'm new to HibernateSpatial but with great interests.
>
> Can I do spatial query directly in the hql, something like find all  
> restaurants within 5 km distance? The more general questions is if  
> there is an abstraction in HQL that can do the usual geometry  
> computation?
>
> Thanks!
>
> Bing
>
> _______________________________________________
> hibernatespatial-users mailing list
> [hidden email]
> http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/ 
> hibernatespatial-users

_______________________________________________
hibernatespatial-users mailing list
[hidden email]
http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users
冉兵

Re: spatial query

Reply Threaded More More options
Print post
Permalink
Thanks for the answers. I have looked at the source of PostgisDialect and
seen all the registered functions. Sorry for my little knowledge of postgis,
but what's the difference of those function starting with st_ and those with
matching names but without the prefix?

Another question: why does this HQL

 "from SocialEvent where contains(area, ?)"

results in:

org.springframework.orm.hibernate3.HibernateQueryException: unexpected AST
node: ( near line 1, column 60 [from bran.tries.hibernatespatial.SocialEvent
where contains(area, ?) ];

while

 "from SocialEvent where contains(area, ?) = true"

works?

Help is appreciated.

Bing


--------------------------------------------------
From: "Karel Maesen" <[hidden email]>
Sent: Thursday, January 08, 2009 6:10 AM
To: "Hibernate Spatial Users Discussion"
<[hidden email]>
Subject: Re: [hibernatespatial-users] spatial query

>
> Yes you can use postgis (or Oracle spatial) functions in HQL. Check
> the unit tests in the Hibernate Spatial project for examples. They
> generally follow the OGC names (which is the same as the pre-1.3
> Postgis names - those not starting with ST_).
>
> Regards,
> Karel
>
>
> On 07 Jan 2009, at 05:46, Bing Ran wrote:
>
>> Hi,
>>
>> I'm new to HibernateSpatial but with great interests.
>>
>> Can I do spatial query directly in the hql, something like find all
>> restaurants within 5 km distance? The more general questions is if
>> there is an abstraction in HQL that can do the usual geometry
>> computation?
>>
>> Thanks!
>>
>> Bing
>>
>> _______________________________________________
>> hibernatespatial-users mailing list
>> [hidden email]
>> http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/
>> hibernatespatial-users
>
> _______________________________________________
> hibernatespatial-users mailing list
> [hidden email]
> http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users
>
_______________________________________________
hibernatespatial-users mailing list
[hidden email]
http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users
Karel Maesen

Re: spatial query

Reply Threaded More More options
Print post
Permalink
Hi,

On 08 Jan 2009, at 04:33, Bing Ran wrote:

> Thanks for the answers. I have looked at the source of  
> PostgisDialect and
> seen all the registered functions. Sorry for my little knowledge of  
> postgis,
> but what's the difference of those function starting with st_ and  
> those with
> matching names but without the prefix?

Since release 1.3, the postgis team decided to adopt the naming of  
the SQL-MM convention. Most of these function names are just synonyms  
for the (older) ones. Hibernate Spatial doesn't yet support them. I  
plan to do that later when creating a new dialect specifically for  
the 1.3 and later postgis.

>
> Another question: why does this HQL
>
>  "from SocialEvent where contains(area, ?)"
>
> results in:
>
> org.springframework.orm.hibernate3.HibernateQueryException:  
> unexpected AST
> node: ( near line 1, column 60 [from  
> bran.tries.hibernatespatial.SocialEvent
> where contains(area, ?) ];
>
> while
>
>  "from SocialEvent where contains(area, ?) = true"
>
> works?
>
> Help is appreciated.

If you get "unexpected AST node" it means that the HQL statement is  
syntactically incorrect. So it looks like the HQL requires a  
relational expression and is not satisfied just with a boolean-valued  
function.

Karel
_______________________________________________
hibernatespatial-users mailing list
[hidden email]
http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users