Skip to content

Instantly share code, notes, and snippets.

@wrenoud
Last active September 10, 2015 18:37
Show Gist options
  • Save wrenoud/af4f44c1713bf2cfea7b to your computer and use it in GitHub Desktop.
Save wrenoud/af4f44c1713bf2cfea7b to your computer and use it in GitHub Desktop.
Pretties a WKT string
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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