# Path: prometapi/compat.py
# def zlib_encode(data):
# 
# Path: prometapi/encoders.py
# def encrypt(e, t):
#     r = str_to_longs(e)
#     a = str_to_longs(t)
#     if len(r) <= 1:
#         r = [r[0], 0]
#     
#     l = len(r)
#     g = r[l - 1]
#     s = r[0]
#     i = 2654435769
#     c = math.floor(6 + 52 / l)
#     u = 0
#     
#     while c > 0:
#         u += i
#         n = rshift(u, 2) & 3
#         
#         p = 0
#         while l > p:
#             s = r[(p + 1) % l]
#             o = (rshift(g, 5) ^ ((s << 2) & 0xffffffff) ) + (rshift(s, 3) ^ ((g << 4) & 0xffffffff)) ^ (u ^ s) + (a[3 & p ^ n] ^ g)
#             g = r[p] = (r[p] + o) & 0xffffffff
#             
#             p += 1
#         c -= 1
#     f = longs_to_str(r)
#     return f
# 
# Path: prometapi/geoprocessing.py
# def get_coordtransform():
# 	from django.contrib.gis.gdal.srs import SpatialReference, CoordTransform
# 	sl = SpatialReference('EPSG:3787')
# 	sl.import_wkt(sl_wkt)
# 	wgs = SpatialReference('EPSG:4326')
# 	trans = CoordTransform(sl, wgs)
# 	return trans
# 
# def find_coordtransform(srid):
# 	if srid == u'EPSG:3787':
# 		return get_coordtransform()
# 	elif srid == u'EPSG:3912':
# 		from django.contrib.gis.gdal.srs import SpatialReference, CoordTransform
# 		sl = SpatialReference('EPSG:3912')
# 		wgs = SpatialReference('EPSG:4326')
# 		trans = CoordTransform(sl, wgs)
# 		return trans
# 	else:
# 		raise ValueError("Couldn't find transform: %r" % srid)


import datetime
import re
import os
import uuid
import simplejson
import time
import urllib
import requests
import subprocess
import xml.etree.ElementTree as ET
from prometapi.compat import urlopen, unicode_type, unichr_cast
from calendar import timegm
from django.db import models
from django.contrib.gis.geos import GEOSGeometry
from django.utils._os import safe_join
from django.utils.timezone import make_aware, utc
from django.conf import settings
from prometapi.encoders import encrypt
from prometapi.geoprocessing import get_coordtransform, find_coordtransform
    from django.db import connection
    The encoding consists of reordering and translating.

    Reordering:

    Step 1: take evenly positioned characters, this is the first part of result
    Step 2: take oddly positioned characters
    Step 3: reverse oddly positioned characters
    Step 4: add them to the string from step 1

    Example:

    s = '123456789'

    Step 1: resultstr = '13579'
    Step 2: oddly = '2468'
    Step 3: oddly = '8642'
    Step 4: resultstr = '135798642'

    Translating characters is done via a self-inverse function:

        f(x) = unichr((255 - ord(x)) % 65536)

    """
    assert isinstance(s, unicode_type), 'Parameter is not unicode.'
    s2 = s[::2] + s[1::2][::-1]
    return ''.join((unichr_cast((255 - ord(c)) % 65536) for c in s2))


def _decode(s):
    # decode

# Path: prometapi/compat.py
# def zlib_encode(data):
# 
# Path: prometapi/encoders.py
# def encrypt(e, t):
#     r = str_to_longs(e)
#     a = str_to_longs(t)
#     if len(r) <= 1:
#         r = [r[0], 0]
#     
#     l = len(r)
#     g = r[l - 1]
#     s = r[0]
#     i = 2654435769
#     c = math.floor(6 + 52 / l)
#     u = 0
#     
#     while c > 0:
#         u += i
#         n = rshift(u, 2) & 3
#         
#         p = 0
#         while l > p:
#             s = r[(p + 1) % l]
#             o = (rshift(g, 5) ^ ((s << 2) & 0xffffffff) ) + (rshift(s, 3) ^ ((g << 4) & 0xffffffff)) ^ (u ^ s) + (a[3 & p ^ n] ^ g)
#             g = r[p] = (r[p] + o) & 0xffffffff
#             
#             p += 1
#         c -= 1
#     f = longs_to_str(r)
#     return f
# 
# Path: prometapi/geoprocessing.py
# def get_coordtransform():
# 	from django.contrib.gis.gdal.srs import SpatialReference, CoordTransform
# 	sl = SpatialReference('EPSG:3787')
# 	sl.import_wkt(sl_wkt)
# 	wgs = SpatialReference('EPSG:4326')
# 	trans = CoordTransform(sl, wgs)
# 	return trans
# 
# def find_coordtransform(srid):
# 	if srid == u'EPSG:3787':
# 		return get_coordtransform()
# 	elif srid == u'EPSG:3912':
# 		from django.contrib.gis.gdal.srs import SpatialReference, CoordTransform
# 		sl = SpatialReference('EPSG:3912')
# 		wgs = SpatialReference('EPSG:4326')
# 		trans = CoordTransform(sl, wgs)
# 		return trans
# 	else:
# 		raise ValueError("Couldn't find transform: %r" % srid)


# Path: prometapi/models.py
import datetime
import re
import os
import uuid
import simplejson
import time
import urllib
import requests
import subprocess
import xml.etree.ElementTree as ET
from prometapi.compat import urlopen, unicode_type, unichr_cast
from calendar import timegm
from django.db import models
from django.contrib.gis.geos import GEOSGeometry
from django.utils._os import safe_join
from django.utils.timezone import make_aware, utc
from django.conf import settings
from prometapi.encoders import encrypt
from prometapi.geoprocessing import get_coordtransform, find_coordtransform
    from django.db import connection

    The encoding consists of reordering and translating.

    Reordering:

    Step 1: take evenly positioned characters, this is the first part of result
    Step 2: take oddly positioned characters
    Step 3: reverse oddly positioned characters
    Step 4: add them to the string from step 1

    Example:

    s = '123456789'

    Step 1: resultstr = '13579'
    Step 2: oddly = '2468'
    Step 3: oddly = '8642'
    Step 4: resultstr = '135798642'

    Translating characters is done via a self-inverse function:

        f(x) = unichr((255 - ord(x)) % 65536)

    """
    assert isinstance(s, unicode_type), 'Parameter is not unicode.'
    s2 = s[::2] + s[1::2][::-1]
    return ''.join((unichr_cast((255 - ord(c)) % 65536) for c in s2))


def _decode(s):
    # decode

    if not isinstance(s, unicode_type):