[Georuby-devel] as_hex_wkb vs as_hex_binary

Guilhem Vellut guilhem.vellut at gmail.com
Thu May 4 10:06:09 EDT 2006

I actually changed the names of the ewkb export methods and their behavior.
Before, you had to explicitly tell the export method (called as_hex_binary
then) the dimension you wanted to export and if you did not want the SRID.
The default was 2D and with SRID. So if you were working with 3D geometries
and no SRID (ie default -1 SRID), you always had to add the arguments. Now,
in the same case, as_hex_ewkb will by default export the geometry by keeping
in the export all the information intact (here the 3D) and leave out the
information it does not have (here the SRID). In most cases, this is what
you would like I think. In any case, you can restrict what information to
export by passing arguments. 

Another binary export method is provided for convenience, as_hex_wkb, which
always restricts the output to 2D and no SRID, no matter what information is
contained in the geometry to export (like for example 3D and with SRID).
Since as_hex_wkb and as_hex_ewkb are both binary export methods, I removed
the as_hex_binary so that there would be no confusion.

In your specific case, if you use 2D and no SRID (ie default -1 SRID)
directly in the geometries, as_hex_ewkb will actually by default export a
strict WKB string (2D and no SRID, since this is all the information
contained in the geometry). You can make it clearer that you are exporting
strict WKB by using as_hex_wkb. This is what is done in the mysql adapter.

I thought that maybe I should leave the former methods in for compatiblity,
but since GeoRuby is still a very young library, I changed all the way by
suppressing as_hex_binary and as_binary, which are now incorrect to use with
the last GeoRuby version.

Sorry for not having it made clearer in the release notes. I hope this
cleared all the confusion.


Quick question to clear up some confusion on my end... just pulled  
in the latest GeoRuby gem update and latest rev from the  
mysql_spatial_adapter repo (which was probably my first mistake... it  
wasn't really broken, so I probably shouldn't have been fixing it :).

	My tests started failing raising an exception from line 77 of  
mysql_spatial_adapter.rb, which looks like:


	Changing it to "value.as_hex_wkb" instead of "value.as_hex_binary 
(2,false)" cleared it right up, but which one is "correct"?  Is  
as_hex_binary going/gone, or is that line still technically correct  
within the scope of the next version?

More information about the Georuby-devel mailing list