Ejemplo n.º 1
0
    def calc_total_line(self, points="all"):
        """
        returns the distance between each point in the route
        """

        rbs = self.routebase_set.order_by('sequence')

        if points == "land":
            rbs = rbs.exclude(land=False)

        # convert to [(lat,lng), ...] while maintaining the same order
        # skipping any routebase that has no location
        points = [(rb.location.location.x, rb.location.location.y)
                  for rb in rbs if rb.location and rb.location.location]

        dist = []
        from utils import coord_dist
        for i, po in enumerate(points):
            try:
                next = points[1 + i]
            except IndexError:
                pass
            else:
                from django.contrib.gis.geos import Point
                dist.append(coord_dist(Point(po), Point(next)))

        return sum(dist)
Ejemplo n.º 2
0
 def calc_total_line(self, points="all"):
     """
     returns the distance between each point in the route
     """
     
     rbs = self.routebase_set.order_by('sequence')          
         
     if points == "land":
         rbs = rbs.exclude(land=False)
     
     # convert to [(lat,lng), ...] while maintaining the same order
     # skipping any routebase that has no location
     points = [(rb.location.location.x, rb.location.location.y)
                     for rb in rbs if rb.location and rb.location.location]
     
     dist = []
     from utils import coord_dist
     for i,po in enumerate(points):
         try:
             next = points[1+i]
         except IndexError:
             pass
         else:
             from django.contrib.gis.geos import Point
             dist.append(coord_dist(Point(po), Point(next)))
      
     return sum(dist)
Ejemplo n.º 3
0
 def calc_max_start(self, a=None):
     """
     Returns the max distance between any point in the route and the
     starting point. Used for ATP XC distance.
     """
     
     if not a:
         a = self._get_AllPoints()
     
     mp = a.collect()
     start = a[0].location
     
     dist = []
     from utils import coord_dist
     for i,po in enumerate(mp):
         dist.append(coord_dist(po, start))
      
     return max(dist)
Ejemplo n.º 4
0
    def calc_max_start(self, a=None):
        """
        Returns the max distance between any point in the route and the
        starting point. Used for ATP XC distance.
        """

        if not a:
            a = self._get_AllPoints()

        mp = a.collect()
        start = a[0].location

        dist = []
        from utils import coord_dist
        for i, po in enumerate(mp):
            dist.append(coord_dist(po, start))

        return max(dist)
Ejemplo n.º 5
0
 def calc_max_width(self, a=None):
     """
     Returns the max distance between any two points in the route
     """
     
     if not a:
         a = self._get_AllPoints()
     
     mp = a.collect()
     
     dist = []
     from utils import coord_dist
     for i,point1 in enumerate(mp):
         for j,point2 in enumerate(mp):
             dist.append(coord_dist(point1, point2))
     
     diameter = max(dist)
     
     return diameter
Ejemplo n.º 6
0
    def calc_max_width(self, a=None):
        """
        Returns the max distance between any two points in the route
        """

        if not a:
            a = self._get_AllPoints()

        mp = a.collect()

        dist = []
        from utils import coord_dist
        for i, point1 in enumerate(mp):
            for j, point2 in enumerate(mp):
                dist.append(coord_dist(point1, point2))

        diameter = max(dist)

        return diameter
Ejemplo n.º 7
0
 def calc_max_width(self, a=None):
     """
     Returns the max distance between any two points in the route
     """
     
     if not a:
         a = self._get_AllPoints()
     
     mp = a.collect()
     centroid = mp.envelope.centroid
     
     dist = []
     from utils import coord_dist
     for i,point in enumerate(mp):
         dist.append(coord_dist(point, centroid))
     
     #since we're measuring from the center, multiply by 2    
     diameter = max(dist) * 2
     
     return diameter