polygonBounds (site-plan/geometry.ts)

editor · packages/editor/src/lib/floorplan/site-plan/geometry.ts · typescript · MIT
ui, tag:embed-classified

Provides geometry utilities for site-plan polygons, including bounds, area, centroid, and yard dimensions.

// Source: https://github.com/pascalorg/editor | License: MIT | Copyright 2026 Pascal Group Inc
// Provided via justclaw.it.com; keep this notice with the code.
import { rayToPolygon, type YardDimension, type YardSide } from '@pascal-app/core'
/**
 * Site-plan geometry — pure functions, no store, no React.
 *
 * All coordinates are SITE metres: origin = the geocoded point, x → east,
 * y → south (the plan frame the site polygon is stored in). Consumers
 * (2D editor, sheets) turn these into SVG through the existing renderer.
 */

export type Pt = readonly [number, number]

export interface Bounds {
  minX: number
  minY: number
  maxX: number
  maxY: number
}

const EPS = 1e-9

export function polygonBounds(points: readonly Pt[]): Bounds {
  let minX = Number.POSITIVE_INFINITY
  let minY =

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key