Skip to content
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

Fixes and new raw files parser #4

Closed
wants to merge 1 commit into from
Closed

Fixes and new raw files parser #4

wants to merge 1 commit into from

Conversation

sergej-singer
Copy link

@sergej-singer sergej-singer commented Jun 3, 2024

KML Parser:

jinja Handler:

  • Fixed: COLOR: appearing on the previous line instead of on the next line while rendering Buffer for text
  • Fixed: TEXT: appearing on the previous line instead of on the next line
  • Fixed: COORDPOLY: not appearing after every polygon while rendering Polygons for TopSky Maps, resolves Wrong generation of Polygons for TopSky Maps #2

New raw file parser:

  • Added: the ability to load not only one raw file, but the whole directory

KML Parser:
- Added MultiGeometry Support
- Added Check for existance of <Document> Tag
jinja Handler:
- Fixed: "COLOR:" appearing on the previous line instead of on the next line while rendering Buffer for text
- Fixed: "TEXT:" appearing on the previous line instead of on the next line
- Fixed: "COORDPOLY:" not appearing after every polygon while rendering Polygons for TopSky Maps

New raw file parser:
- Added the ability to load not only one raw file, but the whole directory
@fpletz
Copy link
Member

fpletz commented Jun 6, 2024

For contributions in the future, please separate each logical change by commit so it can be reviewed and merged individually. At least one PR per topic would be excellent.

Copy link
Member

@fpletz fpletz left a comment

Choose a reason for hiding this comment

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

This PR in itself is very hard to review and test because it touches lots of different places and there is no good test cases. We should add unit tests at some point to mapbuilder. I would love to see smaller changes that are easier to merge individually.

Do you have a repo where you are using your changes? I'm wondering if you are in fact using the mapbuilder correctly. Since there is no documentation at the moment, I do understand that some of our design choices might be confusing.

else:
parser = RAWParser(source_dir / config["data"][data_source]["source"])
self.data[data_source] = parser.parse()
#logging.debug(self.data[data_source])
Copy link
Member

Choose a reason for hiding this comment

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

Either remove debugging statements or leave them in if they provide any benefit.

result[Path(*filepath.parts[1:]).as_posix()] = f.read()
elif os.path.isdir(root / dirname):
#logging.debug(f"2: {dirname}")
self.parse_recursively(root / dirname, result)
Copy link
Member

Choose a reason for hiding this comment

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

What is the use case for this? Why is a single file und thus raw string per data item not enough?

Copy link
Author

Choose a reason for hiding this comment

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

well, in FIR Langen they used an own script, to paste some data into maps. It worked simply by finding .import and replacing it with txt files in the path. I know mapbuilder can import plain txt files, but I would need to get every single of these 100 txt files into mapbuilder.toml. I found it would be simpler if I could make the mapbuilder to search for the needed txt files by itself by parsing the whole directory with all these txt files and then in jinja provide a path to the file inside given directory. I couldn't just paste the data into maps, because I it was actually reused in completely separate maps for separate profiles.

@@ -97,6 +98,9 @@ def to_text_buffer(geometry, label: str, color: str, adapt_to_length=True):

_render_polygon(lines, [buffer], color)

for i in range(len(lines)):
lines[i] = lines[i].replace("COLOR", "\nCOLOR")
Copy link
Member

Choose a reason for hiding this comment

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

This looks like the wrong position to fix this. Are you sure you are using the Jinja templating language correctly?

@@ -107,7 +111,7 @@ def to_text(geometry, label: str):
return ""

labeltext, _, _ = label.partition("#")
return f"TEXT:{coord2es(point.coords[0])}:{labeltext}"
return f"TEXT:{coord2es(point.coords[0])}:{labeltext}\n"
Copy link
Member

Choose a reason for hiding this comment

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

Same here. Newlines should be handled by Jinja templates.

Copy link
Author

Choose a reason for hiding this comment

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

Okay, I will try to replicate the issues with newlines one more time and will send a result.

@sergej-singer
Copy link
Author

Do you have a repo where you are using your changes? I'm wondering if you are in fact using the mapbuilder correctly. Since there is no documentation at the moment, I do understand that some of our design choices might be confusing.

Do you mean the repo with already made maps? I do have it here: https://github.com/sergej-singer/edgg-package

@sergej-singer
Copy link
Author

sergej-singer commented Jun 6, 2024

For contributions in the future, please separate each logical change by commit so it can be reviewed and merged individually. At least one PR per topic would be excellent.

I'm really sorry for that, I am quite new to this and not an actual programmer. Should I close then this PR and open new ones with smaller changes per issue?

@a3li a3li self-assigned this Jul 14, 2024
@a3li
Copy link
Collaborator

a3li commented Jul 14, 2024

Thanks for the contribution, but with multiple issues mangled into one commit, and not all of the fixes being correct, this cannot be merged like this.

@a3li a3li closed this Jul 14, 2024
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.

KML File with 'MultiGeometry' No Tag <Document> in KML File Wrong generation of Polygons for TopSky Maps
3 participants