On 21 déc. 2011, at 15:19, Hardy Ferentschik wrote:
>
> On Dec 21, 2011, at 2:59 PM, Emmanuel Bernard wrote:
>
>> Which one do you prefer (line in bold for each sample)?
>>
>> builder
>> .spatial()
>> .onCoordinates( "location" ) or
>> .forCoordinates("location") or .forLocation("location") or something else
>> .within( 500, Unit.KM )
>>
>> .of().latitude(48.858333d).longitude(2.294444d)
>> .createQuery();
>
> builder
> .spatial()
> .forLocation("location")
> .within( 500, Unit.KM )
>
> .of().latitude(48.858333d).longitude(2.294444d)
> .createQuery();
>
> On a side node, do we really need 'of()'. Sure it makes it sounds a little
> more like real English, but then why is there no 'and()' between lat and long.
> The whole DSL part only carries so far when directly hosted in Java. If there
> is no compelling reason for 'of()' i would argue one can drop it.
There is a reason for the of(). An overloaded form used when the user passes a
Coordinates object is like this
builder
.spatial()
.forLocation("location")
.within(500, Unit.KM)
.of(coordinates)
.createQuery();
So you can see there is a symmetry to it.
But we can reduce the number of methods called by doing something like this
builder
.spatial()
.forLocation("location")
.within(500, Unit.KM)
.ofLatitude(48.8d).andLongitude(2.29d)
.createQuery();
Would you like it better?
>
> what's about 'proximity' instead of 'spatial'?
I am somewhat neutral, but I think the industry term is spatial queries.
Thoughts?
>
>
>> builder
>> .spatial()
>> .onLatitudeField( "latitude"
>> ).onLongitudeField( "longitude" ) or .forLatitudeField( "latitude"
>> ).forLongitudeField( "longitude" ) or something else
>> .within( 51, Unit.KM )
>> .of().latitude( 24d
>> ).longitude( 31.5d )
>> .createQuery();
>
> builder
> .spatial()
> .onFields(long, lat)
> .within( 51, Unit.KM )
> .of().latitude( 24d
> ).longitude( 31.5d )
> .createQuery();
As Karel pointed out, a major bug in spatial queries is people using latitude
instead of longitude and vice versa. onFields does leave this can of worms open
_______________________________________________
hibernate-dev mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/hibernate-dev