Skip to content

Commit

Permalink
MetaSearch: set 4326 as default CRS, use WKT to feed polygon geometry
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkralidis committed Apr 3, 2017
1 parent e462bfb commit d6433c5
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions python/plugins/MetaSearch/dialogs/maindialog.py
Expand Up @@ -392,7 +392,10 @@ def set_bbox_from_map(self):
"""set bounding box from map extent"""

crs = self.map.mapSettings().destinationCrs()
crsid = int(crs.authid().split(':')[1])
try:
crsid = int(crs.authid().split(':')[1])
except IndexError: # no projection
crsid = 4326

extent = self.map.extent()

Expand Down Expand Up @@ -570,7 +573,7 @@ def record_clicked(self):
if points is not None:
src = QgsCoordinateReferenceSystem(4326)
dst = self.map.mapSettings().destinationCrs()
geom = QgsGeometry.fromPolygon(points)
geom = QgsGeometry.fromWkt(points)
if src.postgisSrid() != dst.postgisSrid():
ctr = QgsCoordinateTransform(src, dst)
try:
Expand Down Expand Up @@ -953,11 +956,6 @@ def bbox_to_polygon(bbox):
maxx = float(bbox.maxx)
maxy = float(bbox.maxy)

return [[
QgsPoint(minx, miny),
QgsPoint(minx, maxy),
QgsPoint(maxx, maxy),
QgsPoint(maxx, miny)
]]
return 'POLYGON((%.2f %.2f, %.2f %.2f, %.2f %.2f, %.2f %.2f, %.2f %.2f))' % (minx, miny, minx, maxy, maxx, maxy, maxx, miny, minx, miny) # noqa
else:
return None

0 comments on commit d6433c5

Please sign in to comment.