Skip to content

Commit

Permalink
from PyQGIS2 to PyQGIS3 - Making envelope layer
Browse files Browse the repository at this point in the history
apply the new names of classes or methods
#191
  • Loading branch information
SimonSAMPERE committed Jun 18, 2019
1 parent 16fceb5 commit be4ad7c
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 19 deletions.
58 changes: 45 additions & 13 deletions _user/quicksearches.json
@@ -1,18 +1,50 @@
{
"_current": {
"contact": null,
"datatype": null,
"favorite": null,
"format": null,
"geofilter": null,
"inspire": null,
"license": null,
"ob": "relevance",
"od": "desc",
"operation": "intersects",
"owner": "owner:08b3054757544463abd06f3ab51ee491",
"srs": null,
"text": "",
"url": "https://api.isogeo.com/resources/search?q=owner:08b3054757544463abd06f3ab51ee491&ob=relevance&od=desc&_include=serviceLayers,layers&_limit=10&_offset=0&_lang=fr"
},
"_default": {
"contact": null,
"datatype": "type:dataset",
"favorite": null,
"format": null,
"geofilter": null,
"inspire": null,
"license": null,
"ob": "relevance",
"od": "desc",
"operation": "intersects",
"owner": null,
"srs": null,
"text": "",
"contact": null,
"datatype": "type:dataset",
"favorite": null,
"format": null,
"geofilter": null,
"inspire": null,
"license": null,
"ob": "relevance",
"od": "desc",
"operation": "intersects",
"owner": null,
"srs": null,
"text": "",
"url": "https://v1.api.isogeo.com/resources/search?_limit=0&_offset=0"
},
"debug_md_displayer": {
"contact": null,
"datatype": null,
"favorite": null,
"format": null,
"geofilter": null,
"inspire": null,
"license": null,
"ob": "relevance",
"od": "desc",
"operation": "intersects",
"owner": "owner:08b3054757544463abd06f3ab51ee491",
"srs": null,
"text": "",
"url": "https://api.isogeo.com/resources/search?q=owner:08b3054757544463abd06f3ab51ee491&_limit=0&_offset=0&_lang=fr"
}
}
12 changes: 6 additions & 6 deletions modules/metadata_display.py
Expand Up @@ -7,8 +7,8 @@
from datetime import datetime

# PyQGIS
from qgis.core import (QgsProject, QgsMessageLog, QgsVectorLayer, QgsPoint,
QgsRectangle, QgsFeature, QgsGeometry, QgsRasterLayer)
from qgis.core import (QgsProject, QgsMessageLog, QgsVectorLayer, QgsPointXY,
QgsRectangle, QgsFeature, QgsGeometry, QgsRasterLayer, QgsRenderContext)


# PyQT
Expand Down Expand Up @@ -390,20 +390,20 @@ def envelope2layer(self, envelope):
md_lyr = QgsVectorLayer("Polygon?crs=epsg:4326",
"Metadata envelope",
"memory")
md_lyr.setLayerTransparency(75)
symbols = md_lyr.rendererV2().symbols()
symbols = md_lyr.renderer().symbols(QgsRenderContext())
symbol = symbols[0]
symbol.setColor(QColor.fromRgb(255,20,147))
symbol.setOpacity(0.25)

if envelope.get("type") == "Polygon":
# parse coordinates
coords = envelope.get("coordinates")[0]
poly_pts = [QgsPoint(round(i[0], 3),
poly_pts = [QgsPointXY(round(i[0], 3),
round(i[1], 3))
for i in coords]
# add geometry to layer
poly = QgsFeature()
poly.setGeometry(QgsGeometry.fromPolygon([poly_pts]))
poly.setGeometry(QgsGeometry.fromPolygonXY([poly_pts]))
md_lyr.dataProvider().addFeatures([poly])
md_lyr.updateExtents()
elif envelope.get("type") == "MultiPolygon":
Expand Down

0 comments on commit be4ad7c

Please sign in to comment.