Github sponshorship


New geos release

The 5.0 version of the geos crate, the binding of the Geometry Engine Open Source C library was just released! The last version came out not so long ago, however it lacked quite a number of things, starting with functions available in the C library. This new release changes everything. Time to write about what happened in this new version!

A quick note before starting: when "geos" is written, I'm talking about the Rust crate, when "GEOS" is written, I'm talking about the C library. Now that it's clear, let's start!


To sum up changes:

Alongside those big changes, some smaller ones like the replacement of skeptic with doc-comment to test README file code examples now prevents cargo to rebuild the whole library everytime when it's being used as a dependency.

A renaming also happened:

More control

For this new release, control over errors has been greatly improved. Now, almost every function returns a GResult. It can seem a bit annoying at first, but when an error triggers, you can find where it comes from very easily, and that was the goal.

You can then get more information on the error through the ContextHandle type which provides the following two methods (amongst others):

Runpub fn get_last_error(&self) -> Option<String>;
pub fn get_last_notification(&self) -> Option<String>;

You can call them on any geos type through the ContextInteractions trait. But in case you want to be noticed when the error occurs directly without having to call this function, you can set a callback to be called:

Runpub fn set_error_message_handler(&self, ef: Option<Box<dyn Fn(&str) + Send + Sync + 'a>>);
pub fn set_notice_message_handler(&self, nf: Option<Box<dyn Fn(&str) + Send + Sync + 'a>>);


Another nice add is the add of the WBKWriter and WKTWriter types. Convenient methods over other types to generate outputs are still available (thinking about to_wkt and to_wkt_precision). Now it's possible to change how many decimals you want, the number of output dimensions, etc...

Word of the end

All these changes were made with a clear focus on giving more control to the users while making it easier to use (thanks to the documentation and the examples too!). Feedbacks are very welcome so don't hesitate to open issues on the repository.

Good hacking!

Posted on the 14/05/2019 at 11:30 by @GuillaumeGomez
Back to articles list
RSS feedRSS feed