Last active
September 10, 2015 18:37
-
-
Save wrenoud/af4f44c1713bf2cfea7b to your computer and use it in GitHub Desktop.
Pretties a WKT string
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def formatWKT(text, strIndent = " ", maxIndent = 3): | |
curIndent = 0 | |
formated = "" | |
newline = lambda: "\n" + strIndent * curIndent if curIndent < maxIndent else "" | |
for char in text: | |
if char == "[": | |
curIndent += 1 | |
formated += char + newline() | |
elif char == "]": | |
formated += newline() + char | |
curIndent -= 1 | |
elif char == ",": | |
formated += char + newline() | |
else: | |
formated += char | |
return formated |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment