mirror of
https://github.com/exyte/Macaw.git
synced 2024-09-11 05:05:23 +03:00
Fix polyline and polygon points parsing
Handling of numbers in scientific notation in `parsePoints` used to be incorrect, because a number could be broken by an exponent minus sign, resulting in incorrect values. E.g. '2.5e-1' -> '2.5e', '-1'.
This commit is contained in:
parent
b3b8f321bf
commit
bd5e868dac
@ -986,15 +986,14 @@ open class SVGParser {
|
||||
|
||||
fileprivate func parsePoints(_ pointsString: String) -> [Double] {
|
||||
var resultPoints: [Double] = []
|
||||
let pointPairs = pointsString.replacingOccurrences(of: "-", with: " -").components(separatedBy: " ")
|
||||
|
||||
pointPairs.forEach { pointPair in
|
||||
let points = pointPair.components(separatedBy: ",")
|
||||
points.forEach { point in
|
||||
if let resultPoint = Double(point) {
|
||||
resultPoints.append(resultPoint)
|
||||
}
|
||||
let scanner = Scanner(string: pointsString)
|
||||
while !scanner.isAtEnd {
|
||||
var resultPoint: Double = 0
|
||||
if scanner.scanDouble(&resultPoint) {
|
||||
resultPoints.append(resultPoint)
|
||||
}
|
||||
_ = scanner.scanCharacters(from: [","], into: nil)
|
||||
}
|
||||
|
||||
if resultPoints.count % 2 == 1 {
|
||||
|
Loading…
Reference in New Issue
Block a user