我现在也有丑陋的 SPARQL 代码来完成带宽到xsd:double
. 这是基于频率指示符出现在编码带宽的前 6 个字符中的假设。该标准将整个带宽字段限制为 4 个字符,包括指示符。但是,我已经看到示例扩展到最多 6 个字符(例如,100H00
上面显示的也可以被合规编码为100H
)
这是 SPARQL 代码自包含示例:
SELECT DISTINCT *
WHERE
{
BIND("5M75C3F"^^xsd:string AS ?emissionDesignator) .
BIND(strlen(?emissionDesignator) AS ?edLength) .
BIND(substr(?emissionDesignator, ?edLength - 2, 3) AS ?useCodes) .
BIND(strbefore(?emissionDesignator, ?useCodes) AS ?encodedBandwidth) .
# case of indicator in character position 1
{
BIND(substr(?encodedBandwidth, 1, 1) AS ?indicator) .
FILTER ((?indicator = "H") || (?indicator = "K") || (?indicator = "M") || (?indicator = "G")) .
}
UNION
# case of indicator in character position 2
{
BIND(substr(?encodedBandwidth, 2, 1) AS ?indicator) .
FILTER ((?indicator = "H") || (?indicator = "K") || (?indicator = "M") || (?indicator = "G")) .
}
UNION
# case of indicator in character position 3
{
BIND(substr(?encodedBandwidth, 3, 1) AS ?indicator) .
FILTER ((?indicator = "H") || (?indicator = "K") || (?indicator = "M") || (?indicator = "G")) .
}
UNION
# case of indicator in character position 4
{
BIND(substr(?encodedBandwidth, 4, 1) AS ?indicator) .
FILTER ((?indicator = "H") || (?indicator = "K") || (?indicator = "M") || (?indicator = "G")) .
}
UNION
# case of indicator in character position 5
{
BIND(substr(?encodedBandwidth, 5, 1) AS ?indicator) .
FILTER ((?indicator = "H") || (?indicator = "K") || (?indicator = "M") || (?indicator = "G")) .
}
UNION
# case of indicator in character position 6
{
BIND(substr(?encodedBandwidth, 6, 1) AS ?indicator) .
FILTER ((?indicator = "H") || (?indicator = "K") || (?indicator = "M") || (?indicator = "G")) .
}
VALUES (?freqIndicator ?multiplier) {
("H"^^xsd:string 1.0e0)
("K"^^xsd:string 1.0e3)
("M"^^xsd:string 1.0e6)
("G"^^xsd:string 1.0e9)
} .
FILTER (?indicator = ?freqIndicator) .
BIND (xsd:double(replace(?encodedBandwidth, ?freqIndicator, ".")) AS ?bandwidthDecimalPart) .
BIND ((?bandwidthDecimalPart * ?multiplier) AS ?bandwidthDouble ) .
}
上面给出了如下所示的结果......带宽的双精度值?bandwidthDouble
以Hz为单位,便于后续推理。现在开始处理排放指示符的其余部分。最终,此代码将在 SPIN 构造函数中结束,以便在实例化时进行自动翻译。
![在此处输入图像描述](https://i.stack.imgur.com/l78mM.png)