def addWayPoint(self, event):
        x = event.pos().x()
        y = event.pos().y()
        point = (x, y)
        self.wayPoints.append(point)

        if (event.button() == QtCore.Qt.LeftButton):
            lonMin, latMin, lonMax, latMax = self.imageMetadata['bbox']
            sizeX, sizeY = self.imageMetadata['size']
            lat, lon = ImageUtils.posImage2Coords(x, y, sizeX, sizeY, latMin,
                                                  lonMin, latMax, lonMax)
            point_ll = (lat, lon)
            self.wayPoints_lat_lon.append(point)
            currentRowCount = self.table.rowCount()
            item = QTableWidgetItem()
            alt = QTableWidgetItem()
            if self.toffButton.isChecked():
                if self.toffButton.text() == 'Take off':
                    item.setText("TAKE OFF to " + str(lat) + ' ' + str(lon))
                    self.toffButton.setChecked(False)
                    self.toffButton.setText('Land')
                else:
                    item.setText("LAND in " + str(lat) + ' ' + str(lon))
                    self.toffButton.setChecked(False)
                    self.toffButton.setText('Take off')
            else:
                item.setText("lat: " + str(lat) + ' lon: ' + str(lon))
            alt.setText(self.altitudeText.text())
            self.table.insertRow(currentRowCount)
            self.table.setItem(currentRowCount, 0, item)
            self.table.setItem(currentRowCount, 1, alt)
    def update_waypoints(self):
        self.wayPoints = []
        bbox = self.imageMetadata["bbox"]
        print(bbox)
        imagesize = self.imageMetadata["size"]
        list_wp = []
        for i in range(len(self.wayPoints_lat_lon)):
            geo_point = self.wayPoints_lat_lon[i]
            point = ImageUtils.posCoords2Image(bbox[0], bbox[1], bbox[2],
                                               bbox[3], geo_point[0],
                                               geo_point[1], imagesize[0],
                                               imagesize[1])

            self.wayPoints.append(point)
Exemplo n.º 3
0
def retrieve_new_map(lat, lon, radius, width, heigth):

    bbox = getBoundingBox(lat, lon, radius)

    wms = WebMapService('http://www.ign.es/wms-inspire/pnoa-ma', version='1.3.0')
    bbox = getBoundingBox(lat, lon, radius)
    print(bbox)
    img = wms.getmap(layers=['OI.OrthoimageCoverage'],
                     styles=['default'],
                     srs='EPSG:4326',
                     bbox=(bbox),
                     size=(width, heigth),
                     format='image/png',
                     transparent=True)

    with open('images/tmp.png', 'wb') as f:
        f.write(img.read())

    ImageUtils.prepareInitialImage(img.read(), width, heigth)
    opencv_image = cv2.imread("images/imageWithDisclaimer.png", 1)

    image = {'bytes': opencv_image, 'bbox': bbox, 'size': (width, heigth)}
    return image
    def getPos(self, event):
        '''
        function who reference the mouse position in the image over coordinades
        :param event: event executed
        :return: None
        '''
        x = event.pos().x()
        y = event.pos().y()
        lonMin, latMin, lonMax, latMax = self.imageMetadata['bbox']

        sizeX, sizeY = self.imageMetadata['size']

        lat, lon = ImageUtils.posImage2Coords(x, y, sizeX, sizeY, latMin,
                                              lonMin, latMax, lonMax)
        self.labelGP.setText("lat: " + str(lat) + ' lon: ' + str(lon) +
                             " X: " + str(x) + " Y: " + str(y))
    def update_position(self):

        if self.pose != None:
            pose = self.getPose3D().getPose3D()
            lat = pose.x
            lon = pose.y
            bbox = self.imageMetadata["bbox"]
            self.limit_warning = GeoUtils.is_position_close_border(
                lat, lon, bbox)
            if self.limit_warning:
                self.download_zoomed_map()
            else:
                bbox = self.imageMetadata["bbox"]
                imagesize = self.imageMetadata["size"]
                x, y = ImageUtils.posCoords2Image(bbox[0], bbox[1], bbox[2],
                                                  bbox[3], lat, lon,
                                                  imagesize[0], imagesize[1])
                angle = self.sensorsWidget.quatToYaw(pose.q0, pose.q1, pose.q2,
                                                     pose.q3)
                self.setPosition(x, y, angle)
    def updateImage(self):

        img = self.imageMetadata.get("numpy")
        if img is not None:
            image = QImage(img.data, img.shape[1], img.shape[0],
                           img.shape[1] * img.shape[2], QImage.Format_RGB888)
            if img.shape[1] == self.IMAGE_COLS_MAX:
                x = 20
            else:
                x = (self.IMAGE_COLS_MAX + 20) / 2 - (img.shape[1] / 2)
            if img.shape[0] == self.IMAGE_ROWS_MAX:
                y = 40
            else:
                y = (self.IMAGE_ROWS_MAX + 40) / 2 - (img.shape[0] / 2)
            img_to_show = ImageUtils.refreshPosition(self.image2show,
                                                     40.4153774, -3.708283)
            size = QSize(img.shape[1], img.shape[0])
            self.imageLabel.move(x, y)
            self.imageLabel.resize(size)
            self.imageLabel.setPixmap(QPixmap.fromImage(image))
Exemplo n.º 7
0
signal.signal(signal.SIGINT, signal.SIG_DFL)

lat = 40.333285
lon = -3.797859
'''
lat =-35.363261
lon =149.165230


lat = 40.333090
lon = -3.798212
'''

H = 0.5  # radius in kilometers
'''
bbox = GeoUtils.getBoundingBox(lat,lon, h)
im = GeoUtils.retrieve_new_google_map(lat, lon, IMAGE_WIDTH, IMAGE_HEIGTH)
corners = getCorners((lat,lon),10,IMAGE_WIDTH,IMAGE_HEIGTH)

with open('images/tmp.png', 'wb') as f:
    f.write(im.read())


im = open('images/tmp.png','rb')
ImageUtils.prepareInitialImage(im.read(),IMAGE_WIDTH,IMAGE_HEIGTH)

#opencv_image = cv2.imread('images/imageWithDisclaimer.png',1);

opencv_image = cv2.imread('images/tmp.png',1)
image = {'bytes': opencv_image, 'bbox': corners, 'size': (IMAGE_WIDTH,IMAGE_HEIGTH)}