SWMMVis  6.0.0-alpha.4
Qt6/C++ GIS-based graphical user interface for the SWMMVis engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
CRSReproject Namespace Reference

Classes

struct  Stats
 

Functions

bool reprojectModel (SWMM_Engine engine, const SpatialReferenceSystem &oldSRS, const SpatialReferenceSystem &newSRS, Stats *stats=nullptr, QString *errorOut=nullptr)
 Transform every coordinate in the model from oldSRS to newSRS.
 
void transformPointsInPlace (OGRCoordinateTransformation *ct, double *xs, double *ys, int n)
 Transform n interleaved scene points in place, in chunks.
 

Variables

constexpr int kTransformChunk = 65536
 Number of points pushed through OGR per batched call.
 

Function Documentation

◆ reprojectModel()

bool CRSReproject::reprojectModel ( SWMM_Engine  engine,
const SpatialReferenceSystem oldSRS,
const SpatialReferenceSystem newSRS,
Stats stats = nullptr,
QString *  errorOut = nullptr 
)

Transform every coordinate in the model from oldSRS to newSRS.

Uses the bulk node API for performance; loops per-link and per-subcatch for variable-length chains. Best-effort: a per-object failure logs and continues so a partially-projectable model still gets the rest done.

Parameters
engineOpen SWMM engine handle (must outlive the call).
oldSRSSource CRS (e.g. layer's stored CRS).
newSRSTarget CRS (also written to the engine via swmm_spatial_set_crs).
statsOptional out-param with counts of objects touched.
errorOutOptional human-readable error if the transform itself fails.
Returns
true if the transform was built and applied to ≥ 1 object; false on hard failure (no transform, no nodes touched).
Here is the call graph for this function:

◆ transformPointsInPlace()

void CRSReproject::transformPointsInPlace ( OGRCoordinateTransformation *  ct,
double xs,
double ys,
int  n 
)

Transform n interleaved scene points in place, in chunks.

Replaces the Transform(1, &x, &y)-per-point pattern that made the geometry cache do ~1.5M individual PROJ calls on a 100k-node model. One call per kTransformChunk points instead.

Parameters
ctTransform to apply. Null is a valid no-op — a layer whose CRS already matches the canvas has no transform, and every caller relied on that.
xs,ysParallel arrays of n coordinates, rewritten in place.
Note
Per-point failure semantics are preserved deliberately. The per-point code left an unprojectable coordinate at its INPUT value, and real models carry such points (a projection failure left ten junctions ~4e7 units out in WW-2024). Silently changing where those land — under a performance banner — would move geometry. So this passes OGR the pabSuccess array and restores the original value for any point OGR rejects, rather than keeping whatever OGR wrote.
Here is the caller graph for this function:

Variable Documentation

◆ kTransformChunk

constexpr int CRSReproject::kTransformChunk = 65536
inlineconstexpr

Number of points pushed through OGR per batched call.

Big enough that PROJ's per-call overhead is amortised, small enough that the scratch buffers stay cache-resident and the peak allocation is bounded regardless of model size.