Skip to content

Commit

Permalink
stroke_opacity option
Browse files Browse the repository at this point in the history
  • Loading branch information
iamtekson committed Mar 16, 2022
1 parent b6f2e9d commit 80a6414
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
19 changes: 12 additions & 7 deletions pysld/categorizedStyle.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def __init__(self,
fill_color='#ffffff',
stroke_color="#333333",
stroke_width=1,
stroke_opacity=1,
opacity=1,

point_size=6,
Expand All @@ -40,6 +41,7 @@ def __init__(self,
fill_color=fill_color,
stroke_color=stroke_color,
stroke_width=stroke_width,
stroke_opacity=stroke_opacity,
opacity=opacity,

point_size=point_size,
Expand Down Expand Up @@ -74,12 +76,12 @@ def get_number_of_class(self):
if self.values is None:
raise ValueError('The values should be list of catagory')

elif self.number_of_class != len(self.values):
if self.number_of_class is None:
self.number_of_class = len(self.values)

else:
raise ValueError(
'There is a problem during get_number_of_class method.')
# else:
# raise ValueError(
# 'There is a problem during get_number_of_class method.')

def point_symbolizer_generator(self, fill_color):
symbolizer = '''
Expand All @@ -94,13 +96,14 @@ def point_symbolizer_generator(self, fill_color):
<Stroke>
<CssParameter name="stroke">{3}</CssParameter>
<CssParameter name="stroke-width">{4}</CssParameter>
<CssParameter name="stroke-opacity">{7}</CssParameter>
</Stroke>
</Mark>
<Size>{5}</Size>
<Rotation>{6}</Rotation>
</Graphic>
</PointSymbolizer>
'''.format(self.well_known_name, fill_color, self.opacity, self.stroke_color, self.stroke_width, self.point_size, self.point_rotation)
'''.format(self.well_known_name, fill_color, self.opacity, self.stroke_color, self.stroke_width, self.point_size, self.point_rotation, self.stroke_opacity)

return symbolizer

Expand All @@ -121,11 +124,12 @@ def line_symbolizer_generator(self, stroke_color):
<CssParameter name="stroke">{0}</CssParameter>
<CssParameter name="stroke-width">{1}</CssParameter>
<CssParameter name="stroke-linecap">{2}</CssParameter>
<CssParameter name="stroke-opacity">{5}</CssParameter>
{3}
</Stroke>
{4}
</LineSymbolizer>
'''.format(stroke_color, self.stroke_linecap, dasharray, perpendicular_offset)
'''.format(stroke_color, self.stroke_width, self.stroke_linecap, dasharray, perpendicular_offset, self.stroke_opacity)

return symbolizer

Expand All @@ -139,9 +143,10 @@ def polygon_symbolizer_generator(self, fill_color):
<Stroke>
<CssParameter name="stroke">{2}</CssParameter>
<CssParameter name="stroke-width">{3}</CssParameter>
<CssParameter name="stroke-opacity">{4}</CssParameter>
</Stroke>
</PolygonSymbolizer>
'''.format(fill_color, self.opacity, self.stroke_color, self.stroke_width)
'''.format(fill_color, self.opacity, self.stroke_color, self.stroke_width, self.stroke_opacity)

return symbolizer

Expand Down
2 changes: 2 additions & 0 deletions pysld/classifiedStyle.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def __init__(self,
fill_color='#ffffff',
stroke_color="#333333",
stroke_width=1,
stroke_opacity=1,
opacity=1,

point_size=6,
Expand Down Expand Up @@ -50,6 +51,7 @@ def __init__(self,
fill_color=fill_color,
stroke_color=stroke_color,
stroke_width=stroke_width,
stroke_opacity=stroke_opacity,
opacity=opacity,

point_size=point_size,
Expand Down
2 changes: 2 additions & 0 deletions pysld/simpleStyle.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def __init__(
fill_color='#ffffff',
stroke_color="#333333",
stroke_width=1,
stroke_opacity=1,
opacity=1,

point_size=6,
Expand Down Expand Up @@ -39,6 +40,7 @@ def __init__(
self.fill_color = fill_color
self.stroke_color = stroke_color
self.stroke_width = stroke_width
self.stroke_opacity = stroke_opacity,
self.opacity = opacity
self.feature_label = feature_label

Expand Down
8 changes: 6 additions & 2 deletions pysld/style.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ def __init__(
fill_color='#ffffff',
stroke_color="#333333",
stroke_width=1,
stroke_opacity=1,
opacity=1,

dbname=None,
Expand Down Expand Up @@ -179,6 +180,7 @@ def __init__(
fill_color=fill_color,
stroke_color=stroke_color,
stroke_width=stroke_width,
stroke_opacity=stroke_opacity,
opacity=opacity,

point_size=point_size,
Expand Down Expand Up @@ -270,11 +272,13 @@ def get_values_from_pg(self, sql_query=None):
if self.conn is None:
self.connect()

if self.attribute_name is None:
self.attribute_name = self.get_attribute_name()

if sql_query is not None:
self.values = self.get_values_from_sql(sql_query)

if self.attribute_name is None:
self.attribute_name = self.get_attribute_name()
else:
self.values = self.get_values_from_column(
column=self.attribute_name, table=self.pg_table_name, schema=self.schema)

Expand Down

0 comments on commit 80a6414

Please sign in to comment.