% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/weights.R
\name{build_distance_context}
\alias{build_distance_context}
\title{Build a distance context object}
\usage{
build_distance_context(coords, ids, longlat = FALSE, cache = TRUE)
}
\arguments{
\item{coords}{A numeric matrix with columns `X` and `Y`.}

\item{ids}{Character or numeric vector of unit IDs (length = nrow(coords)).}

\item{longlat}{Logical.  Passed to `compute_distance()`.}

\item{cache}{Logical.  If `TRUE` (default), pre-computes and caches the
full n x n distance matrix.  Set `FALSE` for very large datasets to avoid
memory pressure; `get_local_distances()` will then compute rows on demand.}
}
\value{
A list with class `"gwpr_distance_context"` containing:
* `ids` — character vector of unit IDs.
* `distance_matrix` — n x n matrix (or `NULL` if `cache = FALSE`).
* `coords` — the original coordinate matrix.
* `longlat` — logical flag.
}
\description{
Wraps a distance matrix together with unit IDs into a list suitable for
passing to `get_local_distances()`.  Optionally pre-computes the full
distance matrix (recommended for small data) or stores only the coordinate
matrix for on-the-fly computation (recommended for large data).
}
\keyword{internal}
