JPA Geospatial Support

How to map points and polygons to java types. If this is not possible, what is a workaround?

I would like to use geospatial support in mysql or postgres via JPA.

+6
java mysql jpa geospatial postgis
source share
4 answers

DataNucleus supports storing / polling the vast majority of common geospatial types in JPA (and JDO). See this link for a list of supported types http://www.datanucleus.org/products/accessplatform_3_0/rdbms/spatial_types.html

+3
source share

I used Hibernate Spatial as mentioned in PostGIS and JPA 2.0

+2
source share

Displaying a map and a polygon in java is not very natural. (the logic of abstraction will be rather cumbersome). I would suggest using a graphical model (e.g. rdf). But it can take a good degree of training. Check out the GVSig . This is an open source Java based project.

I evaluated them before moving on to a more complete geospatial analysis using Allegrograph and RDF.

0
source share

I also tried - you can get the data if you declare your field in JPA as Byte[] , and it will look like blob, but in the MySQL spatial internal format - so no matter what, you will always get an unreadable internal format - the best way in JPA, use your own SQL query to output data as text.

 SELECT AsText(columnName) FROM tableName; 

For instace:

 String sql = "SELECT AsText(LOCATION) FROM ENTITY where id=?1"; return (String) em.createNativeQuery(sql) .setParameter(1, id) .getSingleResult(); 

returns in my case: POINT(40.01999 -75.147171) .

0
source share

All Articles