Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Two questions about geospatial data and OGM
PostPosted: Tue Oct 31, 2017 10:40 am 
Newbie

Joined: Mon Mar 20, 2017 7:40 am
Posts: 5
Hello,

I have two questions:

First question:

Is there a way to define a geospatial index (https://docs.mongodb.com/manual/geospat ... al-indexes) as it is done with full text indices (https://docs.jboss.org/hibernate/stable ... xt_indexes)?

Second questions:

Geospatial queries need coordinates to be persisted in a defined order.

MongoDB Docs (https://docs.mongodb.com/manual/geospat ... atial-data):

Quote:
Specify via an embedded document:
[...]
If specifying latitude and longitude coordinates, the first field, regardless of the field name, must contains the longitude value and the second field, the latitude value ; i.e.

<field>: { <field1>: <longitude>, <field2>: <latitude> }


I use the the following:
Code:
@Embeddable
public class LngLat implements Serializable {

    private Double lng;

    private Double lat;

    public LngLat() {
    }

    public LngLat(Double lng, Double lat) {
        this.lng = lng;
        this.lat = lat;
    }

    public Double getLng() {
        return lng;
    }

    public void setLng(Double lng) {
        this.lng = lng;
    }

    public Double getLat() {
        return lat;
    }

    public void setLat(Double lat) {
        this.lat = lat;
    }
}


...but it gets persisted like this:

Code:
{ ..., "location" : { "lat" : 48.2088284029927, "lng" : 16.359914169215926 }, ...}


...the other way round.

Is there a way to define the order?

Thanks,

Paul


Top
 Profile  
 
 Post subject: Re: Two questions about geospatial data and OGM
PostPosted: Fri Nov 03, 2017 5:43 am 
Hibernate Team
Hibernate Team

Joined: Fri Sep 09, 2011 3:18 am
Posts: 295
I don't think there is an easy way to solve this issue.
You probably need to create a new type descriptor, and use it via the org.hibernate.boot.model.TypeContributor

I'll try to write an example over the week-end.
In the meanwhile you can try have a look at the Hibernate OGM source code: https://github.com/hibernate/hibernate- ... butor.java

Thanks,
Daivde


Top
 Profile  
 
 Post subject: Re: Two questions about geospatial data and OGM
PostPosted: Fri Nov 03, 2017 5:50 am 
Hibernate Team
Hibernate Team

Joined: Fri Sep 09, 2011 3:18 am
Posts: 295
By the way, Thanks for the feedback.
I've created a JIRA: https://hibernate.atlassian.net/browse/OGM-1339


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.