index.ts 2.7 KB
/**
 * @hm/clean-core —— 出险数据清洗算法内核(可移植纯算法包)。
 *
 * 这个包不含任何 DOM / fetch / 全局状态 / 第三方依赖,因此同一个包既能跑在浏览器 Worker 里
 * (实时导入解析),也能跑在 Node CLI 里(离线批量清洗)。宿主(heatmap app)与 B 阶段的
 * `clean-adapters` / `clean-cli` 都从这里取算法。
 *
 * 包分层:
 *   - geo/*      : 坐标系互转、多边形几何、落水判定、海上合法走廊(全是纯函数)
 *   - cleanRules : 8 类处置规则的核心判据(FLAG 位掩码 + 各 classify/mark*)
 *   - cleanRows  : 编排入口(CleanRow[] → flags + classes + warnings),可移植套件的高层 API
 *   - dims       : 道路名解析(roadOfAddress / buildRoadIndex)
 *   - types      : 数据契约子集(CleanClassKey / CleanSample / CleanClass / UNRESOLVED_LABEL)
 */

/* 数据契约子集 */
export { UNRESOLVED_LABEL } from './types';
export type { CleanClassKey, CleanSample, CleanClass } from './types';

/* 坐标系互转 */
export { gcj02ToWgs84, wgs84ToGcj02, outOfChina } from './geo/coord';

/* 多边形几何 */
export {
  pointInRing,
  pointInPolygon,
  pointInPolygons,
  metersPerDegLng,
  distanceToBoundaryM,
  boundsOf,
} from './geo/polygon';
export type { LngLat, ShapePolygon, NamedPolys, ShapeBounds } from './geo/polygon';

/* 落水 / 域外几何 */
export {
  offshoreVerdict,
  parseDistrictGeometry,
  parseGeoFeatures,
  parseGeometryPolys,
} from './geo/offshoreVerdict';
export type { CorridorMatch } from './geo/corridors';

/* 海上合法走廊 */
export { parseCorridors, pointInLegalCorridor } from './geo/corridors';
export type { CorridorFeature } from './geo/corridors';

/* 道路解析 */
export { ROAD_UNRESOLVED, roadOfAddress, buildRoadIndex } from './dims';

/* 规则内核 */
export {
  FLAG,
  ISO_RADII,
  ISO_FLAGS,
  SPARSE_DEFAULT_THRESHOLD,
  SPARSE_STREET_DEFAULT_THRESHOLD,
  SPARSE_STREET_MIN,
  SPARSE_STREET_MAX,
  isStreetUnresolved,
  streetNameOf,
  SMALL_DEFAULT_RADIUS_M,
  SMALL_DEFAULT_THRESHOLD,
  SMALL_RADIUS_MAX,
  SMALL_THRESHOLD_MAX,
  OFFSHORE_FAR_DIST_M,
  flagOfMissing,
  missingDimLabels,
  presentDimLabels,
  classifyRegion,
  classifyOffshore,
  markIsolated,
  markSparseRoads,
  markSparseStreets,
  markSmallClusters,
  CLASS_DEFAULTS,
  CLASS_INFO,
} from './cleanRules';
export type {
  RegionVerdict,
  SparseRoadInput,
  SparseRoadResult,
  SparseStreetInput,
  SparseStreetResult,
  SmallClusterInput,
  SmallClusterResult,
} from './cleanRules';

/* 编排入口 */
export { cleanRows, loadLandMask, loadCorridors } from './cleanRows';
export type {
  CleanRow,
  CleanContext,
  CleanThresholds,
  CleanResult,
} from './cleanRows';