Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
Added levels of acces to renderer symbol type
Added secondary test for simple symbol renderer
Added false label for raster_renderer in case it's false
  • Loading branch information
bogind committed Oct 10, 2021
1 parent 9d43c5e commit a910163
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
5 changes: 4 additions & 1 deletion metadata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
name=qlyrx
qgisMinimumVersion=3.0
description=Apply Arcgis Pro .lyrx style
version=0.3.1
version=0.3.2
author=Netta Beninson, Dror Bogin
[email protected]

Expand All @@ -23,6 +23,9 @@ repository=https://github.com/arc2qgis/qlyrx
# Recommended items:

changelog=
2021-10-10 Version 0.3.2
* Bug Fix version

2021-06-18 Version 0.3.1
* Rewrote layer loading using pyqgis instaed of base ui elements.

Expand Down
28 changes: 20 additions & 8 deletions qlyrx.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from qgis.utils import *
import json
import re
import qgis.utils


# Initialize Qt resources from file resources.py
from .resources import *
Expand Down Expand Up @@ -1263,10 +1263,11 @@ def apply_lyrx_symbols(self, layer, lyrx_data, geometry_general_type_str):
for p in layerDef :
#print(p)
if 'type' in p:
print(p['type'])
if p['type'] == 'CIMRasterLayer':
raster_symbol = True
raster_data = p
else:
raster_symbol = False
## Check for renderers
temp_renderer = p['renderer'] if 'renderer' in p else ''
renderers.append(temp_renderer)
Expand All @@ -1282,7 +1283,17 @@ def apply_lyrx_symbols(self, layer, lyrx_data, geometry_general_type_str):
label_expessions.append('')
## Get lyrx shape type and original names
if not temp_renderer == '' and not raster_symbol:
rend_type = temp_renderer['symbol']['type'] if 'symbol' in temp_renderer else temp_renderer['defaultSymbol']['symbol']['type']
if 'symbol' in temp_renderer:
rend_type = temp_renderer['symbol']['type']
elif 'defaultSymbol' in temp_renderer:
rend_type = temp_renderer['defaultSymbol']['symbol']['type']
elif 'groups' in temp_renderer:
group0 = temp_renderer['groups'][0]
if 'classes' in group0:
symbol0 = group0['classes'][0]
rend_type = symbol0['symbol']['symbol']['type']

#rend_type = temp_renderer['symbol']['type'] if 'symbol' in temp_renderer else temp_renderer['defaultSymbol']['symbol']['type']
renderers_symb_type.append(rend_type.lower())
dataset = p['featureTable']['dataConnection']['dataset']
dataset_names.append(dataset)
Expand All @@ -1293,9 +1304,8 @@ def apply_lyrx_symbols(self, layer, lyrx_data, geometry_general_type_str):

# Find a renderer with the active layer field attribute
rend_to_check = []
x = 0
x = 0
for r in renderers_symb_type:
#print(r)
if geometry_general_type_str in r:
rend_to_check.append(x)
x = x + 1
Expand All @@ -1318,12 +1328,14 @@ def apply_lyrx_symbols(self, layer, lyrx_data, geometry_general_type_str):
#for u in range(0,len(self.used_fields)):
# self.add_field_layout(layer,self.used_fields[u],u)


# Check simple symbol
if rend_idx < 0 and not raster_symbol:
active_name = layer.sourceName()
rend_idx = dataset_names.index(active_name)
simple_symbol = True
rend_idx = dataset_names.index(active_name) if layer.sourceName() in dataset_names else 0
if renderers[0]['type'] != "CIMSimpleRenderer":
simple_symbol = False
else:
simple_symbol = True

if rend_idx > -1 and not simple_symbol:
## Create data arrays for symbols, labels, symbolLayers, halo options
Expand Down

0 comments on commit a910163

Please sign in to comment.