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

Change of structure, would you guys be interested to evaluate #22

Open
milovanderlinden opened this issue Jul 13, 2013 · 6 comments
Open

Comments

@milovanderlinden
Copy link

Hi all,

I have been working with basemaps to generate a particular style that we wanted for the Netherlands. It is a style derived from the "Basisregistratie topografie".

At first I started working from generate_style.py, but the large structure and the big amount of overrides made searching and replacing harder and harder.

So I drank some beer, put my feet on the table and tought; "Wouldn't it be better to use separate style files?"

So I moved all the dicts from generate_style.py to yaml files with a default directory for defaults and a style directory for all the custom styles.

Then I implemented the yaml reading in pyMapFile.py, pretty soon I had everything working.

I also enhanced the -g flag; it now creates/replaces all the .msinc file in one run. I did this because I discovered that running with the -l switch was way slower then generate_style.py

In the process I also added some variables I required, such as ANGLE on a couple of labels, OUTLINE on a couple of labels and I added cycleways and grass to the process as they where missing.

I would like to ask you guys if you would be interested in evaluating my effort. If you think it ain't what you want, let me know. I will isolate my fork.

The branch I am working on is https://github.com/opengeogroep/basemaps/tree/openbasiskaart-6-2 feel free to give it a spin.

If you have any comments or questions, do ask!

Cheers!

Milo

qgis-screenshot

@tbonfort
Copy link
Member

Hi Milo,
Seems interesting, and the yaml syntax is indeed more user friendly than the python dictionaries.

  • Currently your setup requires the yaml python module which isn't installed by default and is thus less easy to run, at least on basic unix systems. However, I know that getting "make" and "sed" installed on windows systems can be a pain, so if you managed to get those two out of the loop and do everything through the python file that would be a compensation.
  • yaml noob question: I'm extensively using this kind of syntax:
default_font = '"sans,arialuni,arabic'"
default_bold_font = "'sansb,arialuni,arabicbold'"

water_font:default_font
cities_font: {
  0:default_font,
  12:default_bold_font
}

would this also be supported by the yaml files ?

cheers,
thomas

@milovanderlinden
Copy link
Author

Hello Thomas,

  • I am aware of the fact that yaml introduces a dependency, but my idea is
    indeed what you say, to eliminate the requirement for make.
  • the only thing that is holding me back is that I cannot find a python
    alternative for the #IF #END structures (for SED alternatives are available
    in python) that are now in effect in the mapfile templates. But I will do
    my research and see if I can come up with a solution.

Regarding the reusage of declarations (as in your default_font) example, I
will test this, but I got the feeling it will work allready.

Op 15 jul. 2013 17:14 schreef "Thomas Bonfort" [email protected]
het volgende:

Hi Milo,
Seems interesting, and the yaml syntax is indeed more user friendly than
the python dictionaries.

  • Currently your setup requires the yaml python module which isn't
    installed by default and is thus less easy to run, at least on basic unix
    systems. However, I know that getting "make" and "sed" installed on windows
    systems can be a pain, so if you managed to get those two out of the loop
    and do everything through the python file that would be a compensation.
  • yaml noob question: I'm extensively using this kind of syntax: ```
    default_font = '"sans,arialuni,arabic'" default_bold_font =
    "'sansb,arialuni,arabicbold'"

water_font:default_font
cities_font: {
0:default_font,
12:default_bold_font
}
would this also be supported by the yaml files ?

cheers,
thomas


Reply to this email directly or view it on GitHubhttps://github.com//issues/22#issuecomment-20976272
.

@tbonfort
Copy link
Member

Milo,
I don't understand what you mean by the #IF #END structures. The sed processing in the makefile only does some simple string replacements, and removes comments and empty lines (those can be skipped). The sed script works directly on the final mapfile, so there should be no #xxx preprocessor directives left.

@tbonfort
Copy link
Member

Milo,
any update on this one ?

cheers,
thomas

@milovanderlinden
Copy link
Author

No, I am currently just using my syntax to update two styles that I created, but since last week I am enjoying a small vacation. I will get back in touch later.

@tacatac
Copy link
Contributor

tacatac commented May 4, 2019

Hope you had a nice vacation ;)

I went another way and split out the styles as Python modules to be reimported with importlib.import_module(). I tried various forms of exec and eval but this one works with Python 2.7 and upwards: tacatac@b328299

Each style file has a dictionary called after the style, which is used to update the current style, and any other bits required.

Regards,

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

No branches or pull requests

3 participants