def get_plottable_lattice(self, color_string):
     slices_physical_x_coords = [eachSlice.get_physical_x_coords()
                                 for eachSlice in self.slices]
     slices_physical_y_coords = [eachSlice.get_physical_y_coords()
                                 for eachSlice in self.slices]
     physical_x_coords = util.fast_concat(slices_physical_x_coords)
     physical_y_coords = util.fast_concat(slices_physical_y_coords)
     physical_x_coords_array = np.array(physical_x_coords)
     physical_y_coords_array = np.array(physical_y_coords)
     lattice_points = [physical_x_coords_array, physical_y_coords_array]
     plottable_lattice = [lattice_points, color_string]
     return plottable_lattice
 def select_paths(self, paths_sets):
     paths_lists = [paths_set.paths for paths_set in paths_sets]
     paths = util.fast_concat(paths_lists)
     print "num paths 3d: " + str(len(paths))
     paths_times_and_costs = [path.fetch_min_time_and_total_cost()
                              for path in paths]
     front = paretofront.ParetoFront(paths_times_and_costs)
     optimal_paths_indices = front.front_indices
     optimal_paths = [paths[i] for i in optimal_paths_indices]
     sorted_paths = sorted(optimal_paths, key=lambda p: p.total_cost)
     print "num paths 3d selected: " + str(len(sorted_paths))
     return sorted_paths
Exemple #3
0
    def get_land_elevations_srtm(self):

        global lastBoundingLatLng 
        global lastSRTMTile 

        bounding_latlngs = [srtm.SRTMTile.get_bounding_coords(latlng)
                            for latlng in self.latlngs]
        bounding_latlngs_unchanged = [bounding_latlng == lastBoundingLatLng 
                                      for bounding_latlng in bounding_latlngs]
        if all(bounding_latlngs_unchanged):
            tiles = [lastSRTMTile]            
            land_elevations = [tile.getAltitudeFromLatLon(latlng[0], latlng[1])
                               for latlng in self.latlngs]
        else:
            bounding_latlngs_lists = [[]]
            last_bounding_latlng = bounding_latlngs[0]
            for bounding_latlng in bounding_latlngs:    
                if bounding_latlng != last_bounding_latlng:
                    bounding_latlngs_lists.append([])
                    bounding_latlngs_lists[-1].append(bounding_latlng)
                    last_bounding_latlng = bounding_latlng
                else:
                    bounding_latlngs_lists[-1].append(bounding_latlng)
            tile_latlngs = [latlngs_list[0] for latlngs_list 
                            in bounding_latlngs_lists]
            tiles = [elevationDownloader.getTile(tile_latlng[0], tile_latlng[1]) 
                     for tile_latlng in tile_latlngs]
            bounding_latlngs_lists_lengths = [len(latlngs_list) for latlngs_list
                                              in bounding_latlngs_lists]
            last_index = 0
            latlngs_lists = []
            for list_length in bounding_latlngs_lists_lengths:
                latlngs_list = self.latlngs[last_index:last_index + list_length]
                latlngs_lists.append(latlngs_list)
                last_index += list_length

            land_elevations_lists = []
            for i in range(len(latlngs_lists)):
                tile = tiles[i]
                latlngs_list = latlngs_lists[i]
                land_elevations_list = [tile.getAltitudeFromLatLon(latlng[0], 
                                                                   latlng[1])
                                        for latlng in latlngs_list]
                land_elevations_lists.append(land_elevations_list)
            land_elevations = util.fast_concat(land_elevations_lists)

        lastBoundingLatlng = bounding_latlngs[-1]
        lastSRTMTile = tiles[-1]
        land_elevations = np.array(land_elevations)
        return land_elevations
 def select_paths(self, paths_sets):
     paths_lists = [paths_set.paths for paths_set in paths_sets]
     selected_paths = util.fast_concat(paths_lists)
     """"
     paths_times_and_costs = [path.get_time_and_cost() for path in paths]
     minimize_time = True
     minimize_cost = True
     front = paretofront.ParetoFront(paths_times_and_costs, minimize_time,
                                                            minimize_cost)
     selected_paths_indices = front.fronts_indices[-1]
     self.selected_paths = [paths[i] for i in selected_paths_indices]
     selected_times_and_costs = [path.get_time_and_cost() for path
                                 in self.selected_paths]
     """
     return selected_paths
Exemple #5
0
def get_elevations(latlngs):
    latlngs_partitions = partition_latlngs(latlngs)
    partitions_elevations = [get_partition_elevations(latlngs_partition)
                             for latlngs_partition in latlngs_partitions]
    elevations = util.fast_concat(partitions_elevations)
    return elevations