Skip to content

Commit

Permalink
Several changes, mostly for lyrx->geostyler conversion (#55)
Browse files Browse the repository at this point in the history
* Install submodules in setup.py

* Create worflow to notify camptocamp/lyrx2sld on updates

* Add custom event type

* added support for HSV colors in arcgis format

* added library version

* some changes to style2style

* add version to SLD output

* added mapping for esri fonts markers

* Delete notify.yaml

* Add GitHub Action to notify lyrx2sld on updates

* Update notify.yaml

* Update notify.yaml

* fix for hatch fill from arcgis format

* Update mapping of ESRI symbols

* fixed case of no color value in arcgis format

* handle case of possible missing fieldValues in arcgis format

* fixed case of missing halo symbol in arcgis format

* correctly handle case of CIMUniqueValueRenderer with no groups

* support for CIMPictureMarker

* handle icons on style2style.py

This changes the return from togeostyler and fromgestyler methods for all formts

* handle case of missing label property in arcgis format

* show error on empty geostyler result

* added support for CIMClassBreaksRenderer

* prevent exception if rgb values are float in arcgis format

* round dash definition values when float values are used in arcgis format

* fixed issue with when arcgis style has no else rule

* fied cmyk2rgb conversion and usage of scale dependency for labels

* minor fixes for lyrx2geostyler conversion

* invert order of symbolizers when converting from lyrx into geostyler

* Reverse symbol order

* Typo

* reverted support for z-ordering

* removed unused method

* LYRX: don't convert outline of polygons to line symbolizer

* fixed dashed outlines and hatched fills in lyrx2geostyler conversion

* added support for concatenated strings from lyrx format

* removed unused code

* fixed concatenation of strings in labels in arcgis format

* added support for rotation in lyrx to geostyler conversion

Also, this commit fixes the handling of min/max scale denominators

* Fix rotation sign

* Add support for symbol transparency (#10)

* support whereClause in conversion of labels from lyrx (#11)

* Improve symbol support (#13)

* Use symbol fill color, refine opacity support

* Use stroke width, default to 0

* Default symbol fill color to white

* Add support for null value comparison (#14)

GEO-4833

* do not add polygon fill if not present in lyrx source

* added support for CIMGrayColor in lyrx

* added partial support for CIMVectorMarker

* correctly add 'group' vendor option in sld output

* fixed halos and class breaks in lyrx->geostyler conversion

* removed workflows

Co-authored-by: Cécile Vuilleumier <[email protected]>
  • Loading branch information
volaya and vuilleumierc authored Dec 8, 2021
1 parent 73236a5 commit 3836958
Show file tree
Hide file tree
Showing 13 changed files with 396 additions and 159 deletions.
1 change: 1 addition & 0 deletions bridgestyle/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .version import __version__
7 changes: 3 additions & 4 deletions bridgestyle/arcgis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@


def toGeostyler(style, options=None):
geostyler, _, _ = togeostyler.convert(json.loads(style), options)
return geostyler
return togeostyler.convert(json.loads(style), options)


def fromGeostyler(style, options=None):
arcgisjson, warnings = fromgeostyler.convert(style, options)
return arcgisjson
return fromgeostyler.convert(style, options)

62 changes: 62 additions & 0 deletions bridgestyle/arcgis/expressions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# For now, this is limited to compound labels using the python or VB syntax
def convertExpression(expression, tolowercase):
if tolowercase:
expression = expression.lower()
if "+" in expression or "&" in expression:
if "+" in expression:
tokens = expression.split("+")[::-1]
else:
tokens = expression.split("&")[::-1]
addends = []
for token in tokens:
if "[" in token:
addends.append(["PropertyName", token.replace("[", "").replace("]", "").strip()])
else:
addends.append(token.replace('"', ''))
allOps = addends[0]
for attr in addends[1:]:
allOps = ["Concatenate", attr, allOps]
expression = allOps
else:
expression = ["PropertyName", expression.replace("[", "").replace("]", "")]
return expression


def stringToParameter(s, tolowercase):
s = s.strip()
if "'" in s or '"' in s:
return s.strip("'\"")
else:
s = s.lower() if tolowercase else s
return ["PropertyName", s]


# For now, limited to = or IN statements
# There is no formal parsing, just a naive conversion
def convertWhereClause(clause, tolowercase):
if "=" in clause:
tokens = clause.split("=")
expression = ["PropertyIsEqualTo",
stringToParameter(tokens[0], tolowercase),
stringToParameter(tokens[1], tolowercase)]
return expression
elif " in " in clause.lower():
clause = clause.replace(" IN ", " in ")
tokens = clause.split(" in ")
attribute = tokens[0]
values = tokens[1].strip("() ").split(",")
subexpressions = []
for v in values:
subexpressions.append(["PropertyIsEqualTo",
stringToParameter(attribute, tolowercase),
stringToParameter(v, tolowercase)])
expression = []
if len(values) == 1:
return subexpressions[0]
else:
accum = ["Or", subexpressions[0], subexpressions[1]]
for subexpression in subexpressions[2:]:
accum = ["Or", accum, subexpression]
return accum

return clause
Loading

0 comments on commit 3836958

Please sign in to comment.