Planar rings in drawing units: parse and emit M/L/Z path text with the source's decimal scale kept, shoelace area with the closing edge and holes, bounding box, centroid, edge lengths, and the isometric projection a plan is drawn with. Policy-free and database-free.
| Tier | foundation |
| Role | value_object |
| Path | crates/foundation/planar-geometry |
| Edition | 2021 |
| Targets | foundation_planar_geometry |
| Public items | 28 across 1 module |
| Tests | 13 |
What it is for
Planar rings in drawing units.
A drawing arrives as path text: M6.00,472.67L6.02,6.00 ... Z, repeated once per ring. This crate turns that text into rings of decimal points and back, keeping the decimal scale the source wrote (6.00 stays 6.00, 266.6 stays 266.6), so a ring that was not edited emits the text it was read from. Everything computed from a ring -- area, bounding box, centroid, edge lengths, an isometric projection -- is a pure function over those points.
No policy lives here: what a ring means (a lot, a road, a building) and what is acceptable for it belong to the crate that knows the domain.
Capabilities
crate root
Planar rings in drawing units.
| Item |
|---|
fn parse_path(d : & str) -> Result <Vec <Ring>, PathError> |
fn iso_project(u : f64, v : f64, z : f64) ->(f64, f64) |
BBox
Planar rings in drawing units.
| Item |
|---|
pub struct BBox |
BBox :: fn width(& self) -> f64 |
BBox :: fn height(& self) -> f64 |
fn bbox(rings : & Ring) -> Option <BBox> |
PathError
Planar rings in drawing units.
| Item |
|---|
pub enum PathError |
Point
Planar rings in drawing units.
| Item |
|---|
pub struct Point |
Point :: fn new(x : Decimal, y : Decimal) -> Self |
Ring
Planar rings in drawing units.
| Item |
|---|
pub struct Ring |
fn emit_path(rings : & Ring, closed_repeat : bool) -> String |
fn signed_area(ring : & Ring) -> f64 |
fn area(rings : & Ring) -> f64 |
fn centroid(ring : & Ring) ->(f64, f64) |
fn edge_lengths(ring : & Ring) -> Vec <f64> |
fn perimeter(ring : & Ring) -> f64 |
fn rounding_bound(ring : & Ring) -> f64 |
Region
A region of the plane made of polygons, and the set arithmetic between regions.
| Item |
|---|
pub struct Region |
Region :: fn empty() -> Self |
Region :: fn from_ring(ring : & (f64, f64)) -> Self |
Region :: fn from_rings(rings : & Vec <(f64, f64)>) -> Self |
Region :: fn union(& self, other : & Region) -> Region |
Region :: fn difference(& self, other : & Region) -> Region |
Region :: fn intersection(& self, other : & Region) -> Region |
Region :: fn is_empty(& self) -> bool |
Region :: fn area(& self) -> f64 |
Region :: fn polygon_count(& self) -> usize |
Region :: fn rings(& self) -> Vec <Vec <(f64, f64)>> |
How to use it
No examples/ target and no doctest in this crate's rustdoc. The tests listed under Verification are the closest executable usage.
Module structure
foundation_planar_geometry
region
Public surface
`crate root`
| Item | What it is |
|---|---|
pub struct Point | One vertex, in the drawing's units, with the decimal scale the source wrote. |
Point :: fn new(x : Decimal, y : Decimal) -> Self | — |
pub struct Ring | A closed ring of vertices |
pub struct BBox | The axis-aligned box around a set of rings. |
BBox :: fn width(& self) -> f64 | — |
BBox :: fn height(& self) -> f64 | — |
pub enum PathError | — |
fn parse_path(d : & str) -> Result <Vec <Ring>, PathError> | Parse path text made of M x,y, L x,y and Z into rings |
fn emit_path(rings : & Ring, closed_repeat : bool) -> String | Emit rings as `M x,y L x,y .. |
fn signed_area(ring : & Ring) -> f64 | Signed shoelace area of one ring, including the closing edge |
fn area(rings : & Ring) -> f64 | Area of a figure made of rings: rings wound like the largest ring add, rings wound the other way are holes and subtract, and a ring of no area adds nothing |
fn bbox(rings : & Ring) -> Option <BBox> | Bounding box over every vertex of every ring |
fn centroid(ring : & Ring) ->(f64, f64) | Area-weighted centroid of one ring |
fn edge_lengths(ring : & Ring) -> Vec <f64> | Length of each edge, in vertex order, closing edge last. |
fn perimeter(ring : & Ring) -> f64 | Perimeter of one ring, closing edge included. |
fn rounding_bound(ring : & Ring) -> f64 | The most the area of a ring can differ from the area of the exact figure it was rounded from: half a unit of the coarsest decimal scale among its vertices, times the perimeter |
fn iso_project(u : f64, v : f64, z : f64) ->(f64, f64) | The 30-degree isometric projection: (u, v, z) in plan becomes ((u - v) cos 30°, (u + v) / 2 - z). |
`region`
| Item | What it is |
|---|---|
pub struct Region | A set of polygons, possibly with holes, in drawing units. |
Region :: fn empty() -> Self | The empty region. |
Region :: fn from_ring(ring : & (f64, f64)) -> Self | One simple polygon from a closed ring (the closing edge implied). |
Region :: fn from_rings(rings : & Vec <(f64, f64)>) -> Self | The union of every ring: overlapping rings merge, disjoint rings stay apart. |
Region :: fn union(& self, other : & Region) -> Region | — |
Region :: fn difference(& self, other : & Region) -> Region | What is in self and not in other. |
Region :: fn intersection(& self, other : & Region) -> Region | — |
Region :: fn is_empty(& self) -> bool | — |
Region :: fn area(& self) -> f64 | Unsigned area, holes subtracted. |
Region :: fn polygon_count(& self) -> usize | — |
Region :: fn rings(& self) -> Vec <Vec <(f64, f64)>> | Every ring as points: each polygon's exterior followed by its holes. |
Re-exports. Exported here, defined elsewhere.
| Export | Defined in |
|---|---|
Region | region::Region |
Boundary
Depends on no other workspace tier.
Shares tier foundation with 28 other crates: foundation-audit-log, foundation-basemodels, foundation-bounded-io, foundation-conversation-closure, foundation-crypto-sign, foundation-decisioning, foundation-encounter-vocabulary, foundation-fs-metadata, … (28 total).
_What this crate deliberately does NOT own is a judgment. No committed registry records one for it, so none is stated here._
Where it sits
| Tier (ontology) | foundation |
| Architectural role (taxonomy) | value_object |
| Location | crates/foundation/planar-geometry |
| Vocabulary in force (lexicon) | current |
Dependencies
Runtime, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
geo | ^0.33 | — | no | always |
rust_decimal | ^1 | serde | no | always |
thiserror | ^2 | — | no | always |
Development, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
rust_decimal_macros | ^1 | — | no | always |
Build. None.
Depended on by. 1 workspace crate.
Signal flow — what reaches this crate, and what it reaches.
flowchart LR n_domain_subdivision_plan["domain-subdivision-plan"] -->|uses| SELF SELF["foundation-planar-geometry"] classDef self fill:#1f883d,stroke:#1f883d,color:#fff; class SELF self;
Feature flags
No Cargo features are defined: every capability is unconditional, so no consumer can receive a half-wired crate.
Targets
| Kind | Name | Source |
|---|---|---|
| lib | foundation_planar_geometry | `src/lib.rs` |
Error model
| Error type | Named by |
|---|---|
PathError | parse_path |
Operational characteristics
| Property | Evidence |
|---|---|
| async public surface | none detected |
| async runtime | none detected |
| database access | none detected |
| network I/O | none detected |
| unsafe code | none detected |
| environment variables | none detected |
No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.
Configuration
No environment variable is read with a literal name anywhere in this crate. A variable whose key is computed at run time cannot be listed here, and is not claimed to be absent.
Related capabilities
1 workspace crate depends on this one: domain-subdivision-plan.
Verification
| Kind | Count |
|---|---|
| Unit tests | 13 |
| Integration tests | 0 |
| Examples | 0 |
| Doctests | 0 |
Evidence by module. How often each public module is named by something executable.
| Module | Tests | Examples | Consumers |
|---|---|---|---|
crate root | 14 | 0 | 10 |
region | 1 | 0 | 1 |
What the tests establish, by name:
a_lot_of_ten_by_fifteen_has_those_edges_and_that_area—src/lib.rsa_multi_ring_path_yields_one_ring_per_subpath—src/lib.rsa_path_parses_to_rings_and_keeps_the_scale_it_was_written_with—src/lib.rsa_path_without_a_move_or_with_a_curve_is_refused—src/lib.rsan_unedited_ring_emits_the_text_it_was_read_from—src/lib.rsbbox_and_centroid_are_computed_over_every_ring—src/lib.rsshoelace_closes_the_ring_and_subtracts_holes—src/lib.rsthe_isometric_projection_is_the_one_the_plan_draws_with—src/lib.rsthe_predio_ring_measures_what_the_plan_declares_within_its_rounding_bound—src/lib.rsthe_rounding_bound_follows_the_coarsest_scale—src/lib.rsa_hole_is_a_ring_and_counts_against_the_area—src/region.rslayers_taken_in_order_tile_the_site_without_overlap—src/region.rsunion_merges_overlaps_and_difference_removes_them—src/region.rs
Documentation coverage
| Measure | Documented | Total |
|---|---|---|
| Public items with rustdoc | 20 | 28 |
Public modules with a //! block | 1 | 1 |
pie showData
title Public items with rustdoc
"Documented" : 20
"No rustdoc detected" : 8
Metrics
| Metric | Value |
|---|---|
| Rust source files | 2 |
| Source lines | 563 |
| Code lines | 456 |
| Public API items | 28 |
| Public modules | 1 |
| Tests | 13 |
| Examples | 0 |
| Cargo features | 0 |
| Direct runtime dependencies | 3 |
| Workspace reverse dependencies | 1 |
pie showData
title Public API by kind
"enum" : 1
"function" : 10
"method" : 13
"struct" : 4
pie showData
title Rust source composition
"Code" : 456
"Blank or comment" : 107
Generation
Rendered by tools-corpus corpus readme from repository evidence alone, renderer schema 2, lexicon current. No model, network service or database was consulted. Regenerate with tools-corpus corpus readme --write; verify with --check.