mirror of
https://github.com/exyte/Macaw.git
synced 2024-09-11 05:05:23 +03:00
Merge pull request #687 from aapng/scientific-notation-parsing
Fix polyline and polygon points parsing
This commit is contained in:
commit
c7c78266fc
@ -986,15 +986,14 @@ open class SVGParser {
|
|||||||
|
|
||||||
fileprivate func parsePoints(_ pointsString: String) -> [Double] {
|
fileprivate func parsePoints(_ pointsString: String) -> [Double] {
|
||||||
var resultPoints: [Double] = []
|
var resultPoints: [Double] = []
|
||||||
let pointPairs = pointsString.replacingOccurrences(of: "-", with: " -").components(separatedBy: " ")
|
|
||||||
|
|
||||||
pointPairs.forEach { pointPair in
|
let scanner = Scanner(string: pointsString)
|
||||||
let points = pointPair.components(separatedBy: ",")
|
while !scanner.isAtEnd {
|
||||||
points.forEach { point in
|
var resultPoint: Double = 0
|
||||||
if let resultPoint = Double(point) {
|
if scanner.scanDouble(&resultPoint) {
|
||||||
resultPoints.append(resultPoint)
|
resultPoints.append(resultPoint)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
_ = scanner.scanCharacters(from: [","], into: nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
if resultPoints.count % 2 == 1 {
|
if resultPoints.count % 2 == 1 {
|
||||||
|
Loading…
Reference in New Issue
Block a user