Last active
August 29, 2015 14:05
-
-
Save bmoregeo/e44abbc5ddeb8c462462 to your computer and use it in GitHub Desktop.
This file contains 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 ExtractInt(string, start_position): | |
""" | |
Loop through string till the next + or - sign and convert the stuff in between from 32-> integer | |
""" | |
result = [] | |
stop = False | |
position = start_position | |
while not stop: | |
char = string[position] | |
if not position == start_position and (char in ('-','+')): | |
stop = True | |
break | |
else: | |
result.append(char) | |
position+=1 | |
if position == len(string): | |
stop = True | |
if len(result) >0: | |
iResult = stringToInt32(''.join(result)) | |
final_position = position | |
return (iResult, final_position) | |
else: | |
ValueError(string) | |
def stringToInt32(string): | |
""" | |
Convert binary string to integer | |
""" | |
i = int(string[1:],32) | |
if string[0] == '-': | |
return -i | |
elif not string[0] in ('-','+'): | |
ValueError('Invalid String: %s' % string) | |
else: | |
return i | |
def parseBinaryGeo(string): | |
difX = 0 | |
difY = 0 | |
i = 0 | |
while i < len(string): | |
nDiffX, i = ExtractInt(string, i) | |
print nDiffX, i | |
nDifYX, i = ExtractInt(string, i) | |
nX = nDiffX + nLastDiffX | |
nY = nDiffY + nLastDiff | |
print nX, nY | |
x = parseBinaryGeo(string) | |
print x | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://resources.esri.com/help/9.3/arcgisengine/ArcObjects/esrinetworkanalyst/INACompactStreetDirection_CompressedGeometry.htm