Skip to content

geometry

qgis_render::geometry

The geometry vocabulary used across the library: the Geometry type plus the supporting value types.

use qgis_render::geometry::*;

Contents

ItemDescription
GeometryVector geometry with GEOS-backed operations.
GeometryTypePoint, LineString, Polygon, multi- variants, GeometryCollection, CircularString.
PointA single x, y, optional z and m.
ExtentAxis-aligned bounding box.
VertexIterator over the vertices of a geometry.

Extent

Extent is the bounding box that appears in project, layer, feature, and render APIs.

let extent = Extent::new(14.0, 50.0, 15.0, 51.0); // minx, miny, maxx, maxy
extent.width() // 1.0
extent.height() // 1.0
extent.center() // Point
extent.contains(&point) // bool
extent.intersects(&other) // bool
extent.combine_with(&other) // union of two boxes
extent.scale(1.1) // grow around the center

Parse one from the minx,miny,maxx,maxy form used by the CLI:

let extent = Extent::from_str("14,50,15,51")?;

Point

let p = Point::new(14.0, 50.0);
let p3d = Point::new_z(14.0, 50.0, 320.0);
p.x(); p.y(); p.z(); // z() -> Option<f64>

Iterating vertices

for vertex in geom.vertices() {
println!("{} {}", vertex.x, vertex.y);
}

Conversions

FunctionDescription
Geometry::from_wkt / to_wktWell-known text.
Geometry::from_wkb / to_wkbWell-known binary.
Geometry::from_geojson / to_geojsonGeoJSON via serde_json::Value.

See also

  • Geometry — the geometry type in detail
  • Crs — units and reprojection
  • features — bounding_box and intersects filters