# Path: prometapi/models.py
# class EnEvents(models.Model):
#     timestamp = models.DateTimeField(auto_now_add=True, db_index=True)
#     json_data = models.TextField(null=True, blank=True)
#     original_data = models.TextField()
# 
# class Events(models.Model):
#     timestamp = models.DateTimeField(auto_now_add=True, db_index=True)
#     json_data = models.TextField(null=True, blank=True)
#     original_data = models.TextField()
# 
# class Cameras(models.Model):
#     timestamp = models.DateTimeField(auto_now_add=True, db_index=True)
#     json_data = models.TextField(null=True, blank=True)
#     original_data = models.TextField()
# 
# class Burja(models.Model):
#     timestamp = models.DateTimeField(auto_now_add=True, db_index=True)
#     json_data = models.TextField(null=True, blank=True)
#     original_data = models.TextField()
# 
# class BurjaZnaki(models.Model):
#     timestamp = models.DateTimeField(auto_now_add=True, db_index=True)
#     json_data = models.TextField(null=True, blank=True)
#     original_data = models.TextField()
# 
# class Counters(models.Model):
#     timestamp = models.DateTimeField(auto_now_add=True, db_index=True)
#     json_data = models.TextField(null=True, blank=True)
#     original_data = models.TextField()
# 
# class ParkiriscaLPT(models.Model):
#     timestamp = models.DateTimeField(auto_now_add=True, db_index=True)
#     json_data = models.TextField(null=True, blank=True)
#     original_data = models.TextField()
# 
# def _loads(s):
#     return simplejson.loads(s, use_decimal=True)
# 
# def promet_to_2016_11(jsondata):
#     v201611 = {
#         u'Expires': jsondata[u'Expires'],
#         u'ModelVersion': jsondata[u'ModelVersion'],
#         u'ModifiedTime': jsondata[u'ModifiedTime'],
#         u'RoutingVersion': jsondata[u'RoutingVersion'],
#     }
#     v201611[u'Contents'] = contents = []
# 
#     ctransforms = {
#         u'dogodki': events_to_2016_11,
#         u'stevci': counters_to_2016_11,
#         u'burja': burja_to_2016_11,
#         u'kamere': cameras_to_2016_11,
#     }
# 
#     for c in jsondata[u'Contents']:
#         typ = c[u'ContentName']
#         try:
#             transformed = ctransforms[typ](c)
#         except KeyError as e:
#             print(e)
#             pass
#         else:
#             contents.append(transformed)
# 
#     return v201611
# 
# Path: prometapi/bicikeljproxy/models.py
# class BicikeljData(models.Model):
# 	timestamp = models.DateTimeField(auto_now_add=True, db_index=True)
# 	json_data = models.TextField()
# 
# Path: prometapi/sos112/models.py
# class SOS112(models.Model):
#     timestamp = models.DateTimeField(auto_now_add=True)
#     original_data = models.TextField()
#     json_data = models.TextField()


import urllib
import simplejson
import dicttoxml
    import json
    import json
from django.http import HttpResponse
from django.shortcuts import render_to_response
from prometapi.models import EnEvents, Events, Cameras, Burja, BurjaZnaki, Counters, ParkiriscaLPT, _loads, \
    promet_to_2016_11
from prometapi.bicikeljproxy.models import BicikeljData
from prometapi.sos112.models import SOS112
from geoprocessing import get_coordtransform
from django.contrib.gis.geos import GEOSGeometry
    from prometapi.encoders import decrypt
    from prometapi.models import PROMET_KEY
        return {
            'status': 'fail',
            'error': 'Coordinates should be floats.'
        }

    xl, xh, yl, yh = 372543, 631496, 34152, 197602
    if not (xl <= coords[0] <= xh and yl <= coords[1] <= yh):
        return {
            'status': 'fail',
            'error': 'Coordinates (%s, %s) out of bounds: %d <= x <= %d and %d <= y <= %d.' % (coords[0], coords[1], xl, xh, yl, yh)
        }

    geotransform = get_coordtransform()
    point = GEOSGeometry('SRID=3787;POINT (%s %s)' % tuple(coords))
    point.transform(geotransform)
    transformed = (point.x, point.y)

    return {
        'status': 'ok',
        'gk': coords,
        'wgs84': transformed,
        'kml': point.kml,
    }


def debug_promet(request):

    context = {}
    if request.method == 'POST':
        encrypted_raw = request.POST.get('encrypted')

# Path: prometapi/models.py
# class EnEvents(models.Model):
#     timestamp = models.DateTimeField(auto_now_add=True, db_index=True)
#     json_data = models.TextField(null=True, blank=True)
#     original_data = models.TextField()
# 
# class Events(models.Model):
#     timestamp = models.DateTimeField(auto_now_add=True, db_index=True)
#     json_data = models.TextField(null=True, blank=True)
#     original_data = models.TextField()
# 
# class Cameras(models.Model):
#     timestamp = models.DateTimeField(auto_now_add=True, db_index=True)
#     json_data = models.TextField(null=True, blank=True)
#     original_data = models.TextField()
# 
# class Burja(models.Model):
#     timestamp = models.DateTimeField(auto_now_add=True, db_index=True)
#     json_data = models.TextField(null=True, blank=True)
#     original_data = models.TextField()
# 
# class BurjaZnaki(models.Model):
#     timestamp = models.DateTimeField(auto_now_add=True, db_index=True)
#     json_data = models.TextField(null=True, blank=True)
#     original_data = models.TextField()
# 
# class Counters(models.Model):
#     timestamp = models.DateTimeField(auto_now_add=True, db_index=True)
#     json_data = models.TextField(null=True, blank=True)
#     original_data = models.TextField()
# 
# class ParkiriscaLPT(models.Model):
#     timestamp = models.DateTimeField(auto_now_add=True, db_index=True)
#     json_data = models.TextField(null=True, blank=True)
#     original_data = models.TextField()
# 
# def _loads(s):
#     return simplejson.loads(s, use_decimal=True)
# 
# def promet_to_2016_11(jsondata):
#     v201611 = {
#         u'Expires': jsondata[u'Expires'],
#         u'ModelVersion': jsondata[u'ModelVersion'],
#         u'ModifiedTime': jsondata[u'ModifiedTime'],
#         u'RoutingVersion': jsondata[u'RoutingVersion'],
#     }
#     v201611[u'Contents'] = contents = []
# 
#     ctransforms = {
#         u'dogodki': events_to_2016_11,
#         u'stevci': counters_to_2016_11,
#         u'burja': burja_to_2016_11,
#         u'kamere': cameras_to_2016_11,
#     }
# 
#     for c in jsondata[u'Contents']:
#         typ = c[u'ContentName']
#         try:
#             transformed = ctransforms[typ](c)
#         except KeyError as e:
#             print(e)
#             pass
#         else:
#             contents.append(transformed)
# 
#     return v201611
# 
# Path: prometapi/bicikeljproxy/models.py
# class BicikeljData(models.Model):
# 	timestamp = models.DateTimeField(auto_now_add=True, db_index=True)
# 	json_data = models.TextField()
# 
# Path: prometapi/sos112/models.py
# class SOS112(models.Model):
#     timestamp = models.DateTimeField(auto_now_add=True)
#     original_data = models.TextField()
#     json_data = models.TextField()


# Path: prometapi/views.py
import urllib
import simplejson
import dicttoxml
    import json
    import json
from django.http import HttpResponse
from django.shortcuts import render_to_response
from prometapi.models import EnEvents, Events, Cameras, Burja, BurjaZnaki, Counters, ParkiriscaLPT, _loads, \
    promet_to_2016_11
from prometapi.bicikeljproxy.models import BicikeljData
from prometapi.sos112.models import SOS112
from geoprocessing import get_coordtransform
from django.contrib.gis.geos import GEOSGeometry
    from prometapi.encoders import decrypt
    from prometapi.models import PROMET_KEY

        return {
            'status': 'fail',
            'error': 'Coordinates should be floats.'
        }

    xl, xh, yl, yh = 372543, 631496, 34152, 197602
    if not (xl <= coords[0] <= xh and yl <= coords[1] <= yh):
        return {
            'status': 'fail',
            'error': 'Coordinates (%s, %s) out of bounds: %d <= x <= %d and %d <= y <= %d.' % (coords[0], coords[1], xl, xh, yl, yh)
        }

    geotransform = get_coordtransform()
    point = GEOSGeometry('SRID=3787;POINT (%s %s)' % tuple(coords))
    point.transform(geotransform)
    transformed = (point.x, point.y)

    return {
        'status': 'ok',
        'gk': coords,
        'wgs84': transformed,
        'kml': point.kml,
    }


def debug_promet(request):

    context = {}
    if request.method == 'POST':
        encrypted_raw = request.POST.get('encrypted')

        encrypted = encrypted_raw.strip()