Пример #1
0
    def kml(self, path, kml, kml_doc):
        """
        Appends kml nodes describing the given user's flight as described
        by the log array given. No nodes are added if less than two log
        entries are given.

        Args:
            path: A list of UasTelemetry elements.
            kml: A simpleKML Container to which the flight data will be added
            kml_doc: The simpleKML Document to which schemas will be added
        Returns:
            None
        """
        # KML Compliant Datetime Formatter
        kml_datetime_format = "%Y-%m-%dT%H:%M:%S.%fZ"
        icon = 'http://maps.google.com/mapfiles/kml/shapes/airports.png'
        kml_output_resolution = 100  # milliseconds

        coords = []
        when = []
        ranges = []

        if len(path) < 2:
            return

        dt = timedelta(milliseconds=kml_output_resolution)
        for pos, uav, time in self.times(path, dt):
            # Spatial Coordinates (longitude, latitude, altitude)
            coord = (pos[1], pos[0], units.feet_to_meters(pos[2]))
            coords.append(coord)

            # Time Elements
            when.append(time.strftime(kml_datetime_format))

            # Distance Elements
            uas_range = distance.distance_to(*uav + pos)
            ranges.append(uas_range)

        # Create a new track in the folder
        trk = kml.newgxtrack(name='Obstacle Path {}'.format(self.id))
        trk.altitudemode = AltitudeMode.absolute

        # Create a schema for extended data: proximity
        schema = kml_doc.newschema()
        schema.newgxsimplearrayfield(name='proximity',
                                     type=Types.float,
                                     displayname='UAS Proximity [ft]')
        trk.extendeddata.schemadata.schemaurl = schema.id

        # Append flight data
        trk.newwhen(when)
        trk.newgxcoord(coords)
        trk.extendeddata.schemadata.newgxsimplearraydata('proximity', ranges)

        # Set styling
        trk.extrude = 1  # Extend path to ground
        trk.style.linestyle.width = 2
        trk.style.linestyle.color = Color.red
        trk.iconstyle.icon.href = icon
Пример #2
0
    def kml(self, path, kml, kml_doc):
        """
        Appends kml nodes describing the given user's flight as described
        by the log array given. No nodes are added if less than two log
        entries are given.

        Args:
            path: A list of UasTelemetry elements.
            kml: A simpleKML Container to which the flight data will be added
            kml_doc: The simpleKML Document to which schemas will be added
        Returns:
            None
        """
        # KML Compliant Datetime Formatter
        kml_datetime_format = "%Y-%m-%dT%H:%M:%S.%fZ"
        icon = 'http://maps.google.com/mapfiles/kml/shapes/airports.png'
        kml_output_resolution = 100  # milliseconds

        coords = []
        when = []
        ranges = []

        if len(path) < 2:
            return

        dt = timedelta(milliseconds=kml_output_resolution)
        for pos, uav, time in self.times(path, dt):
            # Spatial Coordinates (longitude, latitude, altitude)
            coord = (pos[1], pos[0], pos[2])
            coords.append(coord)

            # Time Elements
            when.append(time.strftime(kml_datetime_format))

            # Distance Elements
            uas_range = distance.distance_to(*uav + pos)
            ranges.append(uas_range)

        # Create a new track in the folder
        trk = kml.newgxtrack(name='Obstacle Path {}'.format(self.id))
        trk.altitudemode = AltitudeMode.absolute

        # Create a schema for extended data: proximity
        schema = kml_doc.newschema()
        schema.newgxsimplearrayfield(name='proximity',
                                     type=Types.float,
                                     displayname='UAS Proximity [ft]')
        trk.extendeddata.schemadata.schemaurl = schema.id

        # Append flight data
        trk.newwhen(when)
        trk.newgxcoord(coords)
        trk.extendeddata.schemadata.newgxsimplearraydata('proximity', ranges)

        # Set styling
        trk.extrude = 1  # Extend path to ground
        trk.style.linestyle.width = 2
        trk.style.linestyle.color = Color.red
        trk.iconstyle.icon.href = icon
Пример #3
0
    def distance_to(self, other):
        """Computes distance to another position.

        Args:
          other: The other position.
        Returns:
          Distance in feet.
        """
        return distance.distance_to(self.latitude, self.longitude, 0, other.latitude, other.longitude, 0)
Пример #4
0
    def distance_to(self, other):
        """Computes distance to another position.

        Args:
          other: The other position.
        Returns:
          Distance in feet.
        """
        return distance.distance_to(self.latitude, self.longitude, 0,
                                    other.latitude, other.longitude, 0)
Пример #5
0
    def contains_pos(self, obst_lat, obst_lon, obst_alt, aerial_pos):
        """Whether the pos is contained within the obstacle's pos.

        Args:
            obst_lat: The latitude of the obstacle.
            obst_lon: The longitude of the obstacle.
            obst_alt: The altitude of the obstacle.
            aerial_pos: The position to test.
        Returns:
            Whether the given position is inside the obstacle.
        """
        dist_to_center = distance.distance_to(
            obst_lat, obst_lon, obst_alt, aerial_pos.gps_position.latitude,
            aerial_pos.gps_position.longitude, aerial_pos.altitude_msl)
        return dist_to_center <= self.sphere_radius
Пример #6
0
    def contains_pos(self, obst_lat, obst_lon, obst_alt, aerial_pos):
        """Whether the pos is contained within the obstacle's pos.

        Args:
            obst_lat: The latitude of the obstacle.
            obst_lon: The longitude of the obstacle.
            obst_alt: The altitude of the obstacle.
            aerial_pos: The position to test.
        Returns:
            Whether the given position is inside the obstacle.
        """
        dist_to_center = distance.distance_to(
            obst_lat, obst_lon, obst_alt, aerial_pos.gps_position.latitude,
            aerial_pos.gps_position.longitude, aerial_pos.altitude_msl)
        return dist_to_center <= self.sphere_radius