Thanks for your answer, I think it's a good solution.

But, I still have two problems:

1. I found GeometryFactory could be constructed with a PrecisionModel.
However, in my situation, the geometry is read from a shape file which is
attach with a default PrecisionModel (FLOATING). I want to know how could I
change the PrecisionModel of them? And I also transform the geometry, how
to ensure the PrecisionModel of the transformed geometry is the same?

2. Dose this solution means the lose of the computation precision?


On Wed, Feb 15, 2012 at 3:48 PM, Ben Caradoc-Davies
<[email protected]> wrote:

> On 15/02/12 15:16, Zheng Xudong wrote:
>
>> Because I use multiline string to compute hashcode, so it may affect my
>> final result observably.
>>
>
> The use of hashCodes on floats or doubles (or types based on them) will
> likely be nonportable (as I don't think JTS uses strictfp everywhere).
> Because of the effect of platform-specific rounding, float and double types
> (and geometries based on them) should be regarded as fuzzy and thus having
> unpredictable hashCode.
>
> The good news is that this is a well-known problem with a solution that is
> implemented in JTS. Please read the javadoc for JTS PrecisionModel. You
> should be able to convert your geometries (with a GeometryFactory?) to a
> grid with (for example) a 0.001 precision. These will then likely behave as
> discrete values (not the continuous values of the underlying doubles) and
> will have much more stable hashCodes.
>
> Jody knows more. Any time anyone want to introduce a new geometry
> implementation, Jody asks "does it have a precision model?" so I think Jody
> knows rather a lot about this issue.
>
> Kind regards,
>
>
> --
> Ben Caradoc-Davies <[email protected]>
> Software Engineer
> CSIRO Earth Science and Resource Engineering
> Australian Resources Research Centre
>

-- 
Zheng Xudong
State Key Laboratory of Software Development Environment
School of Computer Science and Engineer, BeiHang University
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
GeoTools-GT2-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to