-
Notifications
You must be signed in to change notification settings - Fork 5
Small refactoring #32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
780178d to
bddb74c
Compare
| 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) |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to organicmaps? ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This value needs to be changed here too:
https://github.com/organicmaps/organicmaps/blob/master/libs/indexer/classificator.cpp#L362
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is feasible )
There was a problem hiding this comment.
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.
| # 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. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
…ated files with organicmaps original files.
Working on splitting huge function
komap_mapswithmeinto smaller parts for better testability and future refactorings.