Repository Public BSD-3-Clause
1// =============================================================================2// SP BOUCHER | SOFTWARE & RESEARCH3// ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// PROJECT METADATA7// -----------------------------------------------------------------------------8// Project : ORIX Maps9// File : Infrastructure/ingestion/ORIXOSM/Sources/osm-stat/main.swift10// Module : osm-stat11// Repository : https://git.spboucher.ai/orix-maps12// Created : 2026-11-2513// Last Modified : 2026-11-2514//15// =============================================================================16// AUTHOR & PROFESSIONAL AFFILIATION17// =============================================================================18//19// Author : Simon-Pierre Boucher20// Position : Professor of Finance21// Institution : Université du Québec en Outaouais (UQO)22// Department : Département des sciences administratives23// Organization : SP Boucher24//25// Website : https://spboucher.ai26// Git : https://git.spboucher.ai27//28// =============================================================================29// OFFICIAL CONTACT DIRECTORY30// =============================================================================31//32// General : info@spboucher.ai33// Professional : contact@spboucher.ai34// Direct : simon@spboucher.ai35// Research : research@spboucher.ai36// Development : dev@spboucher.ai37// Support : support@spboucher.ai38// Security/Admin : admin@spboucher.ai39// Notifications : notifications@spboucher.ai40//41// Preferred Contact: support@spboucher.ai42//43// =============================================================================44// COPYRIGHT & INTELLECTUAL PROPERTY45// =============================================================================46//47// Copyright (c) 202648// Simon-Pierre Boucher49//50// All rights reserved where applicable.51//52// This file is governed by the applicable project license,53// copyright notices, institutional agreements and relevant law.54//55// Unless expressly authorized by the applicable license or56// rights holder, copying, redistribution, sublicensing,57// publication and commercial exploitation are not permitted.58//59// Existing third-party rights and notices remain unaffected.60//61// =============================================================================62// CONFIDENTIALITY & SECURITY63// =============================================================================64//65// Classification : Public66// Distribution : Public repository; use is governed by the project license67// Security Contact : admin@spboucher.ai68//69// Access to this source does not independently grant permission70// to redistribute or disclose confidential materials.71//72// Do not embed credentials, private keys, access tokens,73// certificates or confidential personal information.74//75// =============================================================================76// LICENSE & MAINTENANCE77// =============================================================================78//79// License : Proprietary, all rights reserved (see license file)80// License File : LICENSE81// Maintainer : Simon-Pierre Boucher82// Technical Contact: dev@spboucher.ai83//84// =============================================================================85// END OF SP BOUCHER SOURCE HEADER86// =============================================================================8788import Foundation89import ORIXOSM9091// Usage: osm-stat <file.osm.pbf> — counts entities; a quick integrity and throughput check for an extract.92guard CommandLine.arguments.count == 2 else { FileHandle.standardError.write(Data("usage: osm-stat <file.osm.pbf>\n".utf8)); exit(2) }93do {94 let start = Date()95 let reader = try OSMPBFReader(url: URL(fileURLWithPath: CommandLine.arguments[1]))96 let header = try reader.header()97 var nodes = 0, ways = 0, relations = 0, highways = 0, named = 0, addresses = 098 try reader.read { block in99 nodes += block.nodes.count; ways += block.ways.count; relations += block.relations.count100 for n in block.nodes where !n.tags.isEmpty { if n.tags["name"] != nil { named += 1 }; if n.tags["addr:housenumber"] != nil { addresses += 1 } }101 for w in block.ways { if w.tags["highway"] != nil { highways += 1 }; if w.tags["name"] != nil { named += 1 }; if w.tags["addr:housenumber"] != nil { addresses += 1 } }102 }103 let ts = header.replicationTimestamp.map { ISO8601DateFormatter().string(from: Date(timeIntervalSince1970: TimeInterval($0))) } ?? "unknown"104 print("blocks \(reader.blockCount) nodes \(nodes) ways \(ways) relations \(relations) highways \(highways) named \(named) addresses \(addresses)")105 print("data timestamp \(ts) writer \(header.writingProgram ?? "?") seconds \(String(format: "%.1f", Date().timeIntervalSince(start)))")106} catch { FileHandle.standardError.write(Data("error: \(error)\n".utf8)); exit(1) }107