MapServer / basemaps

Scripts to generate MapServer mapfiles based on OpenStreetMap data. Please submit pull requests to the 'main' branch.
61 stars 46 forks source link

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

Open milovanderlinden opened 11 years ago

milovanderlinden commented 11 years ago

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 commented 11 years ago

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

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 commented 11 years ago

Hello Thomas,

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" notifications@github.com 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/mapserver/basemaps/issues/22#issuecomment-20976272 .

tbonfort commented 11 years ago

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 commented 11 years ago

Milo, any update on this one ?

cheers, thomas

milovanderlinden commented 11 years ago

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 commented 5 years ago

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: https://github.com/tacatac/basemaps/commit/b3282994459aa3b5689bb82c81ccbaf75149ccf7

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

Regards,