Precision Model

2 messages Options
Embed this post
Permalink
Pablo José Cabrera Muñoz

Precision Model

Reply Threaded More More options
Print post
Permalink
Hello everyone,

I've been using hibernate spatial for a while and it's been a great
experience so far.

Although, I'm stuck with an application requirement that has to validate
if a given polygon is within another polygon. The thing is that there is
some reprojection made both in the server-side (Java) and the
client-side (Javascript / OpenLayers) and when the user draws the exact
same polygon (using the OpenLayers API with Snapping activated on the
validated polygon) there is a small difference between those two
polygons and when I use "pol1.contains(pol2)" or even
"pol2.contains(pol1)" they both says "false", so I noticed that they are
not quite equal and the difference is really small. I think that I could
use a fixed precision model as said in this thread
(http://n2.nabble.com/hibernate-spatial.cfg.xml-td1482530.html) to avoid
this small difference.

And the question is:

Will hibernate-spatial use this precision when using spatial operations
and functions? (I guess not, because it only builds the java objects
using that give precision model).

If not, given that I save my geometries with a specific precision model,
will they be preserved within the database? (I guess Yes, but it does't
really matter, since my objects will be returned with that given precision).

I think that's the way it would work, but I can't be sure of that... Any
thoughts?

--
Pablo Cabrera
Analista Implementador
Softplan/Poligraph
Fone: (048) 3027.8000
http://www.softplan.com.br
Sistema da Qualidade Certificado ISO 9001:2000

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

Re: Precision Model

Reply Threaded More More options
Print post
Permalink
Hi,

You can configure the precision model used by Hibernate Spatial. To  
do that, create a file "hibernate-spatial.cfg.xml" and put it on the  
classpath.

You can configure the precision model like so:

<?xml version="1.0" encoding="UTF-8"?>
<hibernate-spatial>
         <precision_model>FIXED</precision_model>
         <precision_model_scale>5</precision_model_scale>
</hibernate-spatial>


This precision model is used then for all geometries that are loaded  
from the database. Hopefully, this will help you resolve the issue.

Regards,

Karel

On 13 Aug 2009, at 17:34, Pablo José Cabrera Muñoz wrote:

> Hello everyone,
>
> I've been using hibernate spatial for a while and it's been a great
> experience so far.
>
> Although, I'm stuck with an application requirement that has to  
> validate
> if a given polygon is within another polygon. The thing is that  
> there is
> some reprojection made both in the server-side (Java) and the
> client-side (Javascript / OpenLayers) and when the user draws the  
> exact
> same polygon (using the OpenLayers API with Snapping activated on the
> validated polygon) there is a small difference between those two
> polygons and when I use "pol1.contains(pol2)" or even
> "pol2.contains(pol1)" they both says "false", so I noticed that  
> they are
> not quite equal and the difference is really small. I think that I  
> could
> use a fixed precision model as said in this thread
> (http://n2.nabble.com/hibernate-spatial.cfg.xml-td1482530.html) to  
> avoid
> this small difference.
>
> And the question is:
>
> Will hibernate-spatial use this precision when using spatial  
> operations
> and functions? (I guess not, because it only builds the java objects
> using that give precision model).
>
> If not, given that I save my geometries with a specific precision  
> model,
> will they be preserved within the database? (I guess Yes, but it  
> does't
> really matter, since my objects will be returned with that given  
> precision).
>
> I think that's the way it would work, but I can't be sure of  
> that... Any
> thoughts?
>
> --
> Pablo Cabrera
> Analista Implementador
> Softplan/Poligraph
> Fone: (048) 3027.8000
> http://www.softplan.com.br
> Sistema da Qualidade Certificado ISO 9001:2000
>
> _______________________________________________
> 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