diff --git a/assets/roads_p3.qml b/assets/roads_p3.qml new file mode 100644 index 0000000..0fe07f4 --- /dev/null +++ b/assets/roads_p3.qml @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + 0 + 0 + 1 + diff --git a/generic_functions.py b/generic_functions.py index bc6cc89..e28f5b8 100755 --- a/generic_functions.py +++ b/generic_functions.py @@ -4,11 +4,11 @@ # from qgis.PyQt.QtCore import QVariant from qgis import processing from processing.tools import dataobjects -from qgis.core import QgsCoordinateReferenceSystem, QgsVectorLayer, QgsProject, edit, QgsGeometry, QgsProperty, QgsField, QgsFeature, QgsRasterLayer, QgsSpatialIndex, QgsFeatureRequest, QgsGeometryUtils, QgsVector, QgsCoordinateTransform, QgsMultiPoint, QgsPoint, QgsPointXY, QgsProperty, QgsApplication +from qgis.core import QgsCoordinateReferenceSystem, QgsVectorLayer, QgsProject, edit, QgsGeometry, QgsProperty, QgsField, QgsFeature, QgsRasterLayer, QgsSpatialIndex, QgsFeatureRequest, QgsGeometryUtils, QgsVector, QgsCoordinateTransform, QgsMultiPoint, QgsPoint, QgsPointXY, QgsProperty, QgsApplication #, QgsRendererCategory, QgsSymbol, QgsLineSymbol, QgsCategorizedSymbolRenderer from processing.gui.AlgorithmExecutor import execute_in_place -import os, json +import os, json #, random from math import isclose,pi @@ -1347,4 +1347,46 @@ def remove_unconnected_lines_v2(inputlayer): break if not_intersecting: - inputlayer.deleteFeature(feat_id) \ No newline at end of file + inputlayer.deleteFeature(feat_id) + +# def generate_bounded_color(vmin=100,vmax=200): +# """Generate a random color with each channel limited to max_brightness.""" +# r = random.randint(vmin,vmax) +# g = random.randint(vmin,vmax) +# b = random.randint(vmin,vmax) + +# # returning as hex: +# return f'#{r:02x}{g:02x}{b:02x}' + + +# def style_line_random_colors(layer, field_name,previous_dict=None): + +# # renderer = layer.renderer() +# # symbol = renderer.symbol() + +# # if symbol.type() == QgsSymbol.Line: +# categories = {} +# colors = {} + +# fields = layer.fields() +# field_index = fields.indexFromName(field_name) +# unique_values = layer.uniqueValues(field_index) + +# for value in unique_values: +# if previous_dict: +# if value in previous_dict: +# categories[value] = QgsRendererCategory(str(value), QgsLineSymbol.createSimple({'color': previous_dict[value], 'width': .5}),str(value)) + +# else: +# color = generate_bounded_color() + +# categories[value] = QgsRendererCategory(value, QgsLineSymbol.createSimple({'color': color, 'width': .5}),f'{value}') +# colors[value] = color + +# renderer = QgsCategorizedSymbolRenderer(field_name, list(categories.values())) +# layer.setRenderer(renderer) + +# layer.triggerRepaint() + +# return colors + diff --git a/metadata.txt b/metadata.txt index 83d4223..80a409a 100644 --- a/metadata.txt +++ b/metadata.txt @@ -4,9 +4,9 @@ [general] name=OSM SidewalKreator -qgisMinimumVersion=3.22.2 +qgisMinimumVersion=3.28 description=Plugin designated to create the Geometries of Sidewalks (separated from streets) based on OpenStreetMap Streets, given a bounding polygon, outputting to a .geojson to be imported on JOSM. It is mostly intended for accessibility Mapping. -version=1.1 +version=1.2 author=Kaue de Moraes Vestena email=kauemv2@gmail.com diff --git a/osm_sidewalkreator.py b/osm_sidewalkreator.py index 4c5e4ac..2dc6073 100755 --- a/osm_sidewalkreator.py +++ b/osm_sidewalkreator.py @@ -472,7 +472,7 @@ def change_all_labels_bylang(self): (self.dlg.opt_perp_crossings,'perpen-\ndicularly','perpendi-\ncularmente'), (self.dlg.label_inward_d,'distance\ninward','distância\nadentro'), (self.dlg.voronoi_checkbox,'Use Voronoi Polygons Rule','Usar Polígonos de Voronoi'), - (self.dlg.alongside_vor_checkbox,'Alongside with another option','Junto à Outra Opção'), + (self.dlg.alongside_vor_checkbox,'Alongside another option','Junto à Outra Opção'), (self.dlg.maxlensplit_checkbox,'Max Len.','Larg. Máx.'), (self.dlg.segsbynum_checkbox,'In x\nsegments','Em x\nsegmentos'), (self.dlg.onlyfacades_checkbox,'Only Facades',' Faces Q.'), @@ -631,7 +631,9 @@ def data_clean(self): for i in range(self.dlg.dead_end_iters_box.value()): # without second input, the function will work just as before remove_lines_from_no_block(self.splitted_lines) - + + # adding same style again: + # style_line_random_colors(self.clipped_reproj_datalayer,highway_tag,self.streets_styledict) ##### creating points of intersection: intersection_points = get_intersections(self.splitted_lines,self.splitted_lines,'TEMPORARY_OUTPUT') @@ -920,10 +922,12 @@ def sidewalks_splitting(self): # print(QgsProject.instance().mapLayers()) self.add_layer_canvas(self.whole_sidewalks) - self.whole_sidewalks.loadNamedStyle(self.sidewalk_stylefile_path) + # self.whole_sidewalks.loadNamedStyle(self.sidewalk_stylefile_path) + apply_style(self.whole_sidewalks,sidewalks_stylefilename) self.add_layer_canvas(self.crossings_layer) - self.crossings_layer.loadNamedStyle(self.crossings_stylefile_path) + # self.crossings_layer.loadNamedStyle(self.crossings_stylefile_path) + apply_style(self.crossings_layer,crossings_stylefilename) # kerbs: @@ -2564,6 +2568,9 @@ def call_get_osm_data(self): self.set_text_based_on_language(self.dlg.input_status_of_data,'data acquired!','Dados Obtidos!!') self.dlg.datafetch_progressbar.setValue(100) + # setting style on roads: + # self.streets_styledict = style_line_random_colors(self.clipped_reproj_datalayer,highway_tag) + def set_text_based_on_language(self,qt_object,en_txt,ptbr_txt,extra_control_bool=True): if extra_control_bool: diff --git a/osm_sidewalkreator_dialog_base.ui b/osm_sidewalkreator_dialog_base.ui index b71f5b5..cf58312 100644 --- a/osm_sidewalkreator_dialog_base.ui +++ b/osm_sidewalkreator_dialog_base.ui @@ -906,7 +906,7 @@ dead-end-streets false - Alongside with another option + Alongside another option