Martin, it would be really nice if the WKBWriter
(a) had a constructor that simply takes an "includeSRID" parameter
(b) worked out the 2d/3d thing for itself.

On 2013-08-20 03:16, Martin Davis wrote:
Sigh, yes, the JTS handling of Z values is a bit weak right now. Hoping to improve this in redesign of the API - but it will break lots of things unfortunately.

In absence of better metadata about the coordinate dimension the method of checking for Z = NaN is about all that can be done right now, . Be aware however that Geometry.getCoordinates() is a bit inefficient for complex geometries, since it has to create one big array to hold all Coordinate values, and then traverse the geometry copying the references. Using a CoordinateFilter would be more efficient.

On Monday, August 19, 2013 5:16:59 AM UTC-7, Nicolas Fortin (OrbisGIS) wrote:

    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)


--
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