Example #1
0
 def GetNeiborhoodPoints(self, temporaryLayer, centralPoint, pointsDB):
     assert isinstance(centralPoint, mstaPoint)
     assert isinstance(temporaryLayer, QgsVectorLayer)
     retValue = list()
     # Construct an ellipse geometry or circle when semiMajor = semiMinor
     ellipse = QgsEllipse(centralPoint,
                          self.getSearch().getMajor(),
                          self.getSearch().getMinor(),
                          self.getSearch().getDirection())
     if ellipse.area() == 0.0:  # If ellipse have 0 area
         return retValue  # return an empty list
     # Select in the bounding box of the ellipse/circle geometry to restrict the list of points to look at
     request = QgsFeatureRequest()
     request.setFilterRect(ellipse.boundingBox()).setFlags(
         QgsFeatureRequest.ExactIntersect)
     # Loop over the select points inside the box if any
     for f in temporaryLayer.getFeatures(request):
         if QgsGeometry(ellipse.toPolygon()).contains(
                 f.geometry()) and f.id() != centralPoint.getID():
             retValue.append(pointsDB[
                 f.id() -
                 1])  # Construction of the list of neighbor mstaPoints
     return retValue
Example #2
0
 def testQgsEllipseRepr(self):
     e = QgsEllipse(QgsPoint(1, 2), 2.0, 3.0)
     self.assertEqual(
         e.__repr__(),
         '<QgsEllipse: Ellipse (Center: Point (1 2), Semi-Major Axis: 3, Semi-Minor Axis: 2, Azimuth: 180)>'
     )
Example #3
0
 def testQgsEllipseRepr(self):
     e = QgsEllipse(QgsPoint(1, 2), 2.0, 3.0)
     self.assertEqual(e.__repr__(), '<QgsEllipse: Ellipse (Center: Point (1 2), Semi-Major Axis: 3, Semi-Minor Axis: 2, Azimuth: 180)>')