[hibernate-dev] [HSEARCH] Geospatial indexing and queries
Sanne Grinovero
sanne at hibernate.org
Wed Dec 21 10:29:07 EST 2011
Inline to both these, and some thoughts about subsequent mails:
On 21 December 2011 15:03, Nicolas Helleringer
<nicolas.helleringer at gmail.com> wrote:
> My two cents :
>
> - .onLocation("position")
>
> - .onLatitude("lat").onLongitude("lng")
I'm confused on what the String represents. I'm going to assume index
fields? So I'm preferring the "onLocation*Field* [..]" versions.
Moreover, assuming we have some @Spatial annotation on the entity,
can't we figure out the fields automatically, or at least have to
point only the the property getter of component object which provides
both latitude and longitude?
More:
> 2011/12/21 Emmanuel Bernard <emmanuel at hibernate.org>
>
>> 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()
>> .onLatitudeField( "latitude"
>> ).onLongitudeField( "longitude" ) or .forLatitudeField( "latitude"
>> ).forLongitudeField( "longitude" ) or something else
>> .within( 51, Unit.KM )
>> .of().latitude( 24d
>> ).longitude( 31.5d )
>> .createQuery();
As mentioned above I prefer the second batch of options, but it's
scary. I do like fluent APIs, but (on Eclipse at least) they don't
provide much help on autocompletion so I'm having a hard time when I
have to use one. IMHO they are cool only as long as the depth of
methods is not abused, also since they require hand-crafted formatting
to read properly.
I wouldn't avoid using more than one parameter for those cases in
which the follow up option is mandatory:
onLongitudeLatitude(long , long );
Also, isn't this use case easier to grasp with some helper type like
spatial().spatialFieldInRegion( "fieldName", AreaBuilder.createRadius(
... ) ).createQuery();
? Just a thought, could evolve to support the different distance
scoring options:
spatial().spatialFieldCloseTo( "fieldName", PointBuilder.createPoint(
... ), distanceBoost f ).createQuery();
Cheers,
Sanne
More information about the hibernate-dev
mailing list