pub struct WKTWriter<'a> { /* private fields */ }
Expand description

The WKTWriter type is used to generate WKT formatted output from Geometry.

Example

use geos::{Geometry, WKTWriter};

let point_geom = Geometry::new_from_wkt("POINT (2.5 2.5)").expect("Invalid geometry");
let mut writer = WKTWriter::new().expect("Failed to create WKTWriter");

assert_eq!(writer.write(&point_geom).unwrap(), "POINT (2.5000000000000000 2.5000000000000000)");

Implementations

Creates a new WKTWriter instance.

Example
use geos::{Geometry, WKTWriter};

let point_geom = Geometry::new_from_wkt("POINT (2.5 2.5)").expect("Invalid geometry");
let mut writer = WKTWriter::new().expect("Failed to create WKTWriter");

assert_eq!(writer.write(&point_geom).unwrap(), "POINT (2.5000000000000000 2.5000000000000000)");

Creates a new WKTWriter instance with a given context.

Example
use geos::{ContextHandling, Geometry, WKTWriter};

let point_geom = Geometry::new_from_wkt("POINT (2.5 2.5)").expect("Invalid geometry");
let mut writer = WKTWriter::new_with_context(point_geom.clone_context())
                           .expect("Failed to create WKTWriter");

assert_eq!(writer.write(&point_geom).unwrap(), "POINT (2.5000000000000000 2.5000000000000000)");

Writes out the given geometry as WKT format.

Example
use geos::{Geometry, WKTWriter};

let point_geom = Geometry::new_from_wkt("POINT (2.5 2.5)").expect("Invalid geometry");
let mut writer = WKTWriter::new().expect("Failed to create WKTWriter");

assert_eq!(writer.write(&point_geom).unwrap(), "POINT (2.5000000000000000 2.5000000000000000)");

Sets the precision to be used when calling WKTWriter::write. Often, what users actually want is the WKTWriter::set_trim method instead.

Example
use geos::{Geometry, WKTWriter};

let point_geom = Geometry::new_from_wkt("POINT (2.5 2.5)").expect("Invalid geometry");
let mut writer = WKTWriter::new().expect("Failed to create WKTWriter");

writer.set_rounding_precision(2);
assert_eq!(writer.write(&point_geom).unwrap(), "POINT (2.50 2.50)");

writer.set_rounding_precision(4);
assert_eq!(writer.write(&point_geom).unwrap(), "POINT (2.5000 2.5000)");

Sets the number of dimensions to be used when calling WKTWriter::write. By default, it is 2.

Example
use geos::{Geometry, OutputDimension, WKTWriter};

let point_geom = Geometry::new_from_wkt("POINT (1.1 2.2 3.3)").expect("Invalid geometry");
let mut writer = WKTWriter::new().expect("Failed to create WKTWriter");
writer.set_trim(true);

assert_eq!(writer.write(&point_geom).unwrap(), "POINT (1.1 2.2)");

writer.set_output_dimension(OutputDimension::ThreeD);
assert_eq!(writer.write(&point_geom).unwrap(), "POINT Z (1.1 2.2 3.3)");

Returns the number of dimensions to be used when calling WKTWriter::write. By default, it is 2.

Example
use geos::{OutputDimension, WKTWriter};

let mut writer = WKTWriter::new().expect("Failed to create WKTWriter");

assert_eq!(writer.get_out_dimension(), Ok(OutputDimension::TwoD));
writer.set_output_dimension(OutputDimension::ThreeD);
assert_eq!(writer.get_out_dimension(), Ok(OutputDimension::ThreeD));

Enables/disables trimming of unnecessary decimals.

Example
use geos::{Geometry, WKTWriter};

let point_geom = Geometry::new_from_wkt("POINT (2.5 2.5)").expect("Invalid geometry");
let mut writer = WKTWriter::new().expect("Failed to create WKTWriter");

assert_eq!(writer.write(&point_geom).unwrap(), "POINT (2.5000000000000000 2.5000000000000000)");

writer.set_trim(true);
assert_eq!(writer.write(&point_geom).unwrap(), "POINT (2.5 2.5)");

Enables/disables old 3D/4D WKT style generation.

Example
use geos::{Geometry, OutputDimension, WKTWriter};

let point_geom = Geometry::new_from_wkt("POINT (2.5 2.5 2.5)").expect("Invalid geometry");
let mut writer = WKTWriter::new().expect("Failed to create WKTWriter");

writer.set_output_dimension(OutputDimension::ThreeD);
writer.set_trim(true);

assert_eq!(writer.write(&point_geom).unwrap(), "POINT Z (2.5 2.5 2.5)");

writer.set_old_3D(true);
assert_eq!(writer.write(&point_geom).unwrap(), "POINT (2.5 2.5 2.5)");

Trait Implementations

Set the context handle to the WKTWriter.

use geos::{ContextInteractions, ContextHandle, WKTWriter};

let context_handle = ContextHandle::init().expect("invalid init");
let mut writer = WKTWriter::new().expect("failed to create WKT writer");
context_handle.set_notice_message_handler(Some(Box::new(|s| println!("new message: {}", s))));
writer.set_context_handle(context_handle);

Get the context handle of the WKTWriter.

use geos::{ContextInteractions, WKTWriter};

let mut writer = WKTWriter::new().expect("failed to create WKT writer");
let context = writer.get_context_handle();
context.set_notice_message_handler(Some(Box::new(|s| println!("new message: {}", s))));

Gets the last error (if any) from the ContextHandle held by this object. Read more

Gets the last notification (if any) from the ContextHandle held by this object. Read more

Executes the destructor for this type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.