当前位置: 首页>>代码示例>>Python>>正文


Python QgsPoint.wellKnownText方法代码示例

本文整理汇总了Python中qgis.core.QgsPoint.wellKnownText方法的典型用法代码示例。如果您正苦于以下问题:Python QgsPoint.wellKnownText方法的具体用法?Python QgsPoint.wellKnownText怎么用?Python QgsPoint.wellKnownText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在qgis.core.QgsPoint的用法示例。


在下文中一共展示了QgsPoint.wellKnownText方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: CoordinatesWidget

# 需要导入模块: from qgis.core import QgsPoint [as 别名]
# 或者: from qgis.core.QgsPoint import wellKnownText [as 别名]
class CoordinatesWidget(QWidget):
    """
    Custom widget for entering an X,Y coordinate pair.
    """
    def __init__(self,parent = None,x=0,y=0):
        QWidget.__init__(self,parent)
        self.resize(270, 130)
        
        self._gridLayout = QGridLayout(self)
        self._sbYCoord = QDoubleSpinBox(self)
        self._sbYCoord.setMinimumSize(QSize(0, 30))
        self._sbYCoord.setDecimals(5)
        self._sbYCoord.setMinimum(-180.0)
        self._sbYCoord.setMaximum(180.0)
        self._gridLayout.addWidget(self._sbYCoord, 2, 1, 1, 1)
        self._label_2 = QLabel(self)
        self._label_2.setText(QApplication.translate("CoordinatesWidget","Y-Coordinate"))
        self._gridLayout.addWidget(self._label_2, 2, 0, 1, 1)
        self._label = QLabel(self)
        self._label.setMaximumSize(QSize(80, 16777215))
        self._label.setText(QApplication.translate("CoordinatesWidget","X-Coordinate"))
        self._gridLayout.addWidget(self._label, 1, 0, 1, 1)
        self._sbXCoord = QDoubleSpinBox(self)
        self._sbXCoord.setMinimumSize(QSize(0, 30))
        self._sbXCoord.setDecimals(5)
        self._sbXCoord.setMinimum(-180.0)
        self._sbXCoord.setMaximum(180.0)
        self._gridLayout.addWidget(self._sbXCoord, 1, 1, 1, 1)
        self.vlNotification = QVBoxLayout()
        self._gridLayout.addLayout(self.vlNotification, 0, 0, 1, 2)
        
        #Set X and Y values
        self._sbXCoord.setValue(float(x))
        self._sbYCoord.setValue(float(y))
        
        self._geomPoint = QgsPoint(x,y)
        
        #Use default SRID
        self._srid = 4326
        
        #Connect signals
        self._sbXCoord.valueChanged.connect(self.onXCoordValueChanged)
        self._sbYCoord.valueChanged.connect(self.onYCoordValueChanged)
        
    def onXCoordValueChanged(self,value):
        """
        Slot raised when the value of the X-Coordinate spinbox changes
        """
        self._geomPoint.setX(value)
        
    def onYCoordValueChanged(self,value):
        """
        Slot raised when the value of the Y-Coordinate spinbox changes
        """
        self._geomPoint.setY(value)
        
    def xCoord(self):
        return self._geomPoint.x()
    
    def yCoord(self):
        return self._geomPoint.y()
    
    def XY(self):
        return (self.xCoord(),self.yCoord())
    
    def setX(self,xCoord):
        self._sbXCoord.setValue(xCoord)
        
    def setY(self,yCoord):
        self._sbYCoord.setValue(yCoord)
        
    def setXY(self,x,y):
        """
        Set both X and Y coordinate values.
        """
        self.setX(x)
        self.setY(y)
    
    def geomPoint(self):
        """
        Returns the coordinate representation as a QgsPoint.
        """
        return self._geomPoint
    
    def setSRID(self,geoModel):
        """
        Set the SRID using the SRID by using that one specified in the geometry column of 
        an sqlalchemy object.
        """
        if hasattr(geoModel,"SRID"):
            self._srid = geoModel.SRID()
        
    def toEWKT(self):
        """
        Returns the specified X,Y point as an extended well-known text representation.
        PostGIS 2.0 requires geometry to be in EWKT specification.
        """
        return "SRID={0};{1}".format(str(self._srid),self._geomPoint.wellKnownText())
    
    
#.........这里部分代码省略.........
开发者ID:7o9,项目名称:stdm-plugin,代码行数:103,代码来源:coordinates_editor.py


注:本文中的qgis.core.QgsPoint.wellKnownText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。