@willcgage/module-schematic 0.62.0 → 0.63.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1241,6 +1241,24 @@ var BUILT_IN_TRACK_PARTS = [...ATLAS_CODE55_N];
1241
1241
  function trackPart(id, library = BUILT_IN_TRACK_PARTS) {
1242
1242
  return library.find((p) => p.id === id) ?? null;
1243
1243
  }
1244
+ var TIE_HALF_LENGTH_INCHES = 0.319;
1245
+ function partExtent(part) {
1246
+ const pts = part?.pointsOffset;
1247
+ const overall = part?.overallLength;
1248
+ if (!pts || !overall) return null;
1249
+ if (pts.source !== "measured" || overall.source !== "measured") return null;
1250
+ const frog = part?.frogOffset;
1251
+ const aheadOfPoints = overall.inches - pts.inches;
1252
+ return {
1253
+ behindPoints: pts.inches,
1254
+ aheadOfPoints,
1255
+ pastFrog: frog && frog.source === "measured" ? overall.inches - frog.inches : aheadOfPoints
1256
+ };
1257
+ }
1258
+ function partExtentForSize(size, library = BUILT_IN_TRACK_PARTS) {
1259
+ const part = turnoutPartForSize(size, library);
1260
+ return part && part.frogNumber === size ? partExtent(part) : null;
1261
+ }
1244
1262
  function turnoutPartForSize(size, library = BUILT_IN_TRACK_PARTS) {
1245
1263
  const turnouts = library.filter((p) => p.kind === "turnout" && p.frogNumber != null);
1246
1264
  if (!turnouts.length) return null;
@@ -2073,6 +2091,7 @@ exports.MAIN_TRACK_ID = MAIN_TRACK_ID;
2073
2091
  exports.N_CAR_LENGTH_INCHES = N_CAR_LENGTH_INCHES;
2074
2092
  exports.N_SCALE_RATIO = N_SCALE_RATIO;
2075
2093
  exports.RAIL_GAUGE_INCHES = RAIL_GAUGE_INCHES;
2094
+ exports.TIE_HALF_LENGTH_INCHES = TIE_HALF_LENGTH_INCHES;
2076
2095
  exports.TURNOUT_LEAD_INCHES_PER_FROG = TURNOUT_LEAD_INCHES_PER_FROG;
2077
2096
  exports.WHOLE_MODULE_SECTION_ID = WHOLE_MODULE_SECTION_ID;
2078
2097
  exports.asModuleSchematic = asModuleSchematic;
@@ -2109,6 +2128,8 @@ exports.moduleLengthFromSections = moduleLengthFromSections;
2109
2128
  exports.moduleSections = moduleSections;
2110
2129
  exports.nextId = nextId;
2111
2130
  exports.parseXtpLibrary = parseXtpLibrary;
2131
+ exports.partExtent = partExtent;
2132
+ exports.partExtentForSize = partExtentForSize;
2112
2133
  exports.partOutlineAtFrog = partOutlineAtFrog;
2113
2134
  exports.pathLengthInches = pathLengthInches;
2114
2135
  exports.poseNeedsManual = poseNeedsManual;