I'm sorry, it's my mistake, Geometry.getDimension does not return 2 or 3. 
It is related to geometry type, not coordinates. The only way I found to 
test if a Geometry contain a Z coordinate somewhere is through the 
following function:

    /**
     * @param coordinates Coordinate array
     * @return True if the array is empty or contain only 2d coordinates.
     */
    private static boolean is2d(Coordinate[] coordinates) {
        if(coordinates==null) {
            return true;
        }
        for(Coordinate coordinate : coordinates) {
            if(!Double.isNaN(coordinate.z)) {
                return false;
            }
        }
        return true;
    }

Then the constructor become this

new WKBWriter(is2d(geometry.getCoordinates()) ? 2 : 3, geom3d.getSRID() != 
0)

Le lundi 19 août 2013 13:43:42 UTC+2, Noel Grandin a écrit :
>
>  
> On 2013-08-19 11:49, Nicolas Fortin (OrbisGIS) wrote:
>  
>
> > The first fix, isGeometry function, a mix was done on Geometry 
>> > object/class: 
>> > 
>> > 
>> https://github.com/nicolas-f/h2database/commit/ac5fab9fffbf5cfd63f7e67e8ce4fa90da727dbc
>>  
>> > 
>> This commit makes no sense at all. 
>> - you have created a unnecessary recursive call in DataType#isGeometry 
>> - you have broken the case where the geometry stuff is not on the 
>> classpath 
>> - you have removed a test case from TestSpatial for no reason that I can 
>> see. 
>>
>>  
> This is not recursive, it uses the other function that test class, not 
> object.
> the second function test if static geometry constant is null.
> The random test case is covered by Thomas MVMap unit test in a cleaner way 
> (without random, and way more faster)
>  
> Ah, now that's more useful as a commit message. 
> OK, applied.
>
>   
>
>> > Second fix, WKB export, SRID and Z was missing: 
>> > 
>> > 
>> https://github.com/nicolas-f/h2database/commit/f8df369622defb0413aa15b8e78ee35b0d461ca8
>>  
>>
>> This fix assumes that Geometry will always be 3D, which means that we 
>> will no longer support 2D geometry, which does not seem like a good idea 
>> to me. 
>>
>>  
> You are right, we can replace the constructor by this:
> new WKBWriter(geometry.getDimension(), geometry.getSRID() != 0)
>  
> Applied.
>
>   
>
>> > 
>> > Third fix, ValueGeometry.equals, GeometryCollection throws an error 
>> > when equals is used, using a work around through binary comparison: 
>> > 
>> > 
>> https://github.com/nicolas-f/h2database/commit/57d141acb4a97b960f704860994a283b33e69d40
>>  
>>
>> This commit also makes no sense. Why is the Geometry class throwing an 
>> IllegalArgumentException? We need more explanation here. 
>>
>
> Geometry compute the intersection matrix (more robust to rounding errors), 
> this cannot be done with GeometryCollection, then it throws an exception. 
> Test all geometries inside the collection separatly may be another solution.
>  
>
> Hmm, this looks like it actually needs a fix to be applied in the JTS 
> library. 
> I think you should liase with the JTS people and get them to fix their 
> equals method.
>
>   
>
>>
>> > 
>> > Fourth fix, update OSGi bundle manifest in order to optionally import 
>> > JTS and export some other package of h2 to be able to write a table 
>> > engine in a remote OSGi bundle. 
>> > 
>> > 
>> https://github.com/nicolas-f/h2database/commit/0042bf99cc677515cee6b91d4b8723e3330507bd
>>  
>>
>> I'm going to leave this for Thomas to comment on. 
>> Historically we have been very loathe to expose more of H2's internals 
>> because we have no intention of making all of this stuff part of our 
>> "supported API". 
>>
>>  
> There is the TableEngine in the api package, however it has dependency on 
> other (hidden) packages.
>  
>
> This patch exports a huge chunk of our internal stuff,  way more than the 
> basic TableEngine API, so I'm going to leave it up to Thomas to make the 
> call.
>
>
>
>
> 

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to