# Path: routing/mathfunctions.py
# def haversine(lon1, lat1, lon2, lat2):
#     """
#     Calculate the great circle distance between two points
#     on the earth (specified in decimal degrees)
#     """
#     # convert decimal degrees to radians
#     lon1, lat1, lon2, lat2 = map(radians, [lon1, lat1, lon2, lat2])
#     # haversine formula
#     dlon = lon2 - lon1
#     dlat = lat2 - lat1
#     a = sin(dlat/2)**2 + cos(lat1) * cos(lat2) * sin(dlon/2)**2
#     c = 2 * asin(sqrt(a))
#     km = 6378.137 * c
#     return km


from copy import deepcopy
from random import randint
from transmeta import TransMeta
from django.db import models
from django.contrib.gis.db import models as geomodels
from django.contrib.gis.geos import *
from django.utils.translation import ugettext_lazy as _
from routing.mathfunctions import haversine
import simplejson as json
import logging
# -*- coding: utf-8 -*-

# Global imports

# Django imports

# Local imports

WEIGHTS = [1, 2, 3, 6, 12]
MAX_WEIGHT = max(WEIGHTS)
MIN_WEIGHT = min(WEIGHTS)
THRESHOLD = 2*max(WEIGHTS)

logger = logging.getLogger(__name__)


class Way(geomodels.Model):
    class_id = models.BigIntegerField(null=True, blank=True)
    length = models.FloatField(null=True, blank=True)
    name = models.CharField(max_length=200, default='', blank=True)

# Path: routing/mathfunctions.py
# def haversine(lon1, lat1, lon2, lat2):
#     """
#     Calculate the great circle distance between two points
#     on the earth (specified in decimal degrees)
#     """
#     # convert decimal degrees to radians
#     lon1, lat1, lon2, lat2 = map(radians, [lon1, lat1, lon2, lat2])
#     # haversine formula
#     dlon = lon2 - lon1
#     dlat = lat2 - lat1
#     a = sin(dlat/2)**2 + cos(lat1) * cos(lat2) * sin(dlon/2)**2
#     c = 2 * asin(sqrt(a))
#     km = 6378.137 * c
#     return km


# Path: routing/models.py
from copy import deepcopy
from random import randint
from transmeta import TransMeta
from django.db import models
from django.contrib.gis.db import models as geomodels
from django.contrib.gis.geos import *
from django.utils.translation import ugettext_lazy as _
from routing.mathfunctions import haversine
import simplejson as json
import logging

# -*- coding: utf-8 -*-

# Global imports

# Django imports

# Local imports

WEIGHTS = [1, 2, 3, 6, 12]
MAX_WEIGHT = max(WEIGHTS)
MIN_WEIGHT = min(WEIGHTS)
THRESHOLD = 2*max(WEIGHTS)

logger = logging.getLogger(__name__)


class Way(geomodels.Model):
    class_id = models.BigIntegerField(null=True, blank=True)
    length = models.FloatField(null=True, blank=True)
    name = models.CharField(max_length=200, default='', blank=True)

    x1 = models.FloatField()