Skip to content

Conversation

@strump
Copy link
Collaborator

@strump strump commented Sep 16, 2025

Working on splitting huge function komap_mapswithme into smaller parts for better testability and future refactorings.

@strump strump force-pushed the kothic-improvements branch from 780178d to bddb74c Compare September 17, 2025 07:34
for i in st.get('casing-dashes', st.get('dashes', [])):
dr_line.dashdot.dd.extend([float(i)])
addPattern(dr_line.dashdot.dd)
addPattern(patterns, dr_line.dashdot.dd)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appeared that dash patterns are loaded from patterns.txt and extended with patterns from *.mapcss files. After that patterns values are exported back to patterns.txt.

colors.add(int(colorLine.strip()))
return colors

def save_colors(colors:set[int], file_path:str):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: will code be cleaner with pathlib.Path instead of str?

def load_patterns(patterns_file_name:str) -> list[list[float]]:
patterns = []

if os.path.exists(patterns_file_name):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it throw on missing file?

Copy link
Collaborator Author

@strump strump Sep 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Funny thing: if you delete data/patterns.txt file from OrganicMaps repo then tools/unix/generate_drules.sh will regenerate the content from *.mapcss rules. And new file content matches 100%.

This happens here: libkomwm.py:763, libkomwm.py:791

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"patterns.txt" is the auto generated file like drules_proto_*.txt/bin

src/libkomwm.py Outdated
if int(row[5]) < cnt:
raise Exception('Wrong type id: {0}'.format(';'.join(row)))
while int(row[5]) > cnt:
types.append("mapswithme") # Placeholder
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change to organicmaps? ;-)

Copy link
Collaborator Author

@strump strump Sep 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is feasible )

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to "organicmaps". When we update kothic submodule in main repo let's not forget to chage C++ code and regenerate the files.

Comment on lines +333 to +335
# TODO: row[1] contains multiple tag=value combinations comma-separated.
# E.g. "[leisure=swimming_pool][access=private],[amenity=swimming_pool][access=private]"
# But only the first one "[leisure=swimming_pool][access=private]" is parsed here.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make a separate method to properly parse and extract these values? Maybe also write a small test for that method?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can it be merged without the implemented todo?

Copy link
Collaborator Author

@strump strump Sep 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put this TODO comment to indicate how parser of mapcss-mapping.csv works now. This behaviour was there for a long time. Let's keep it for now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vng how did it work before?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Values after comma are used for the classifier matching (generator).
For the styles definition (kothic) only the first (main) value is needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants