| 1234567891011121314151617181920212223242526272829303132333435363738 |
- /** Source material semantics shared by map and detail renderers; unknown codes are never guessed. */
- const SURFACES = Object.freeze({
- steel: { kind: 'steel', label: '钢管', metalness: 0.82, roughness: 0.32 },
- iron: { kind: 'iron', label: '铸铁', metalness: 0.65, roughness: 0.7 },
- pe: { kind: 'pe', label: 'PE塑料', metalness: 0, roughness: 0.5 },
- pvc: { kind: 'pvc', label: 'PVC塑料', metalness: 0, roughness: 0.28 },
- frp: { kind: 'frp', label: '玻璃钢复合材料', metalness: 0, roughness: 0.4 },
- concrete: { kind: 'concrete', label: '混凝土', metalness: 0, roughness: 0.96 },
- copper: { kind: 'copper', label: '铜管', metalness: 0.92, roughness: 0.26 },
- unknown: { kind: 'unknown', label: '材质未识别', metalness: 0, roughness: 0.8 },
- })
- export function pipeSurface(material) {
- const text = typeof material === 'string' ? material.trim().toUpperCase() : ''
- let kind = 'unknown'
- if (/玻璃钢|^(FRP|GRP|GFRP)$/.test(text)) kind = 'frp'
- else if (/不锈钢|钢管|碳钢|镀锌|无缝钢|^(钢|STEEL|STAINLESS STEEL|SS|Q235|Q345)$/.test(text)) kind = 'steel'
- else if (/铸铁|球墨|^(DI|CI|DUCTILE IRON|CAST IRON)$/.test(text)) kind = 'iron'
- else if (/聚乙烯|^(HDPE|MDPE|PE)([-\s]?\d+)?$/.test(text)) kind = 'pe'
- else if (/聚氯乙烯|^(U?PVC|PVC[- ]?U)$/.test(text)) kind = 'pvc'
- else if (/混凝土|水泥|^(CONCRETE|RCP|RC)$/.test(text)) kind = 'concrete'
- else if (/铜管|^(COPPER|CU)$/.test(text)) kind = 'copper'
- return { ...SURFACES[kind], source: typeof material === 'string' ? material : '' }
- }
- export function sourceDiameterM(value) {
- return typeof value === 'number' && Number.isFinite(value) && value > 0 ? value / 1000 : null
- }
- /** Same local tangent-plane metric as the detail projection. Source paths are never stretched. */
- export function geographicPipeLength(path) {
- if (!Array.isArray(path) || path.length < 2) return 0
- const cosLat = Math.cos(path[0][1] * Math.PI / 180)
- let length = 0
- for (let i = 1; i < path.length; i += 1) {
- length += Math.hypot((path[i][0] - path[i - 1][0]) * 111320 * cosLat, (path[i][1] - path[i - 1][1]) * 111320)
- }
- return length
- }
|