0
votes

I m trying to draw the stored polygon points on google map when user clicks on the map. I use postgres database. I successfully stored the polygons into DB. When i try to auto draw the polygon points i get an recursion error. Here is my code

class drawPolygon(Base):

    __tablename__ = "tbl_data_area"      

    id =  Column(Integer, nullable=False, primary_key=True)
    area = Column(Geometry('Polygon'))
    name = Column( Text )

    _poly  = None

    def getPoly(self):
        if not self._poly:
            self._poly = to_shape(self.area)//i get error here
        return self._poly

    def getAreaPoints(self):
        return self.getPoly().area
    area = property(getAreaPoints)          

I don't know whats wrong in self.area. when the line self._poly = to_shape(self.area) executes I get this error RuntimeError: maximum recursion depth exceeded while calling a Python object. I m struck with this. Can any one help please.

1
self.area calls getAreaPoints(self) which calls self.getPoly() which uses self.area which calls getAreaPoints(self) which calls self.getPoly() which uses self.area which calls getAreaPoints(self) which calls self.getPoly() which uses self.area...... - Martijn Pieters♦
In other words, self.area is not the column, it is the area = property(getAreaPoints) property you defined. Perhaps you wanted to rename that property? - Martijn Pieters♦
@Martijn Pieters: It worked by Changing the Property name. Thanks a lot - Nirmala Sudhir

1 Answers

1
votes

You have both a column and a property named area:

area = Column(Geometry('Polygon'))

# ...

def getAreaPoints(self):
    return self.getPoly().area
area = property(getAreaPoints)          

The latter replaced the former. As such, self.getPoly() uses the property when accessing self.area, and the property calls self.getPoly() again.

Rename either the column or the property if you wanted to use the column in the getPoly() method.