Return a properly quoted string for use in PostgreSQL/PostGIS.
(self)
| 49 | return poly |
| 50 | |
| 51 | def getquoted(self): |
| 52 | """ |
| 53 | Return a properly quoted string for use in PostgreSQL/PostGIS. |
| 54 | """ |
| 55 | if self.is_geometry: |
| 56 | # Psycopg will figure out whether to use E'\\000' or '\000'. |
| 57 | return b"%s(%s)" % ( |
| 58 | b"ST_GeogFromWKB" if self.geography else b"ST_GeomFromEWKB", |
| 59 | sql.quote(self.ewkb).encode(), |
| 60 | ) |
| 61 | else: |
| 62 | # For rasters, add explicit type cast to WKB string. |
| 63 | return b"'%s'::raster" % self.ewkb.hex().encode() |
no test coverage detected