from django.contrib.gis.db.models.fields import LineStringField
from django.contrib.gis.db.models.manager import GeoManager
from django.db import models, models
from django.utils.translation import ugettext_lazy as _



class Trail(models.Model):
    '''
    Representation of a muni track.
    '''
    name = models.CharField(_('name'), max_length=100)
    created = models.DateTimeField(_('created'), auto_now_add=True, blank=True)
    edited = models.DateTimeField(_('last change'), auto_now=True, blank=True)
    description = models.CharField(_('description'), max_length=500, blank=True)
    waypoints = LineStringField(_('waypoints'), dim=3, null=True, blank=True) #include altitude as Z
    objects = GeoManager()
    # user
    # comments[]
    # country
    # unitours link
    # pictures[]
    
    def __unicode__(self):
        return u'%s' % self.name

@@ -859,8 +859,1368 @@
 lf.name%0A
+    %0A    def has_waypoints(self):%0A        return self.waypoints is not None%0A    %0A    def get_altitude_difference(self):%0A        '''%0A        Calculates the total altitude difference between start and end point.%0A        Ignores ups and downs in between.%0A        '''%0A        #TODO%0A        %0A    def get_max_slope(self):%0A        '''%0A        Calculates the slope in %25 for each pair of waypoints and returns%0A        the highest slope found.%0A        '''%0A        %0A    def get_avg_slope(self):%0A        '''%0A        Calculates the average slope by dividing total altitude difference%0A        through the length of the track.%0A        '''%0A        %0A    def get_length(self):%0A        '''%0A        Calculates the (flat) distance of the track.%0A        This does not take into account that the earth isn't flat, and that%0A        the distance should be longer due to the altitude difference.%0A        '''%0A        %0A    def get_exact_length(self):%0A        '''%0A        Calculates the length of the track and takes into account that%0A        the earth is not flat + altitude difference.%0A        '''%0A        %0A    def get_total_altitude_up(self):%0A        '''%0A        Calculates the total uphill meters (altitude)%0A        '''%0A        #TODO%0A        %0A    def get_total_altitude_down(self):%0A        '''%0A        Calculates the total downhill meters (altitude)%0A        '''%0A        #TODO%0A        %0A

add method signatures to trail model