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

Map attributes parsing #9

Open
springmeyer opened this issue Nov 1, 2010 · 13 comments
Open

Map attributes parsing #9

springmeyer opened this issue Nov 1, 2010 · 13 comments

Comments

@springmeyer
Copy link
Member

We should respect map level attributes like 'min_version' when an mml parsed by python, and stuff like 'font_directory' which will be available in mapnik2.

I'll take this on, but it can happen after initial release.

@gravitystorm
Copy link

Making this issue easier to find: cascadenik support for "minimum_version"

@migurski
Copy link
Member

migurski commented May 2, 2012

Is this still a thing? Did "font_directory" get added?

@springmeyer
Copy link
Member Author

Yes, it did. And before the 2.0.0 release all parameters were made to use consistent dashes (instead of underscores), so its now font-directory, and it can be passed a directory or a single file:

https://github.com/mapnik/mapnik/blob/master/tests/data/good_maps/extra_known_map_attributes.xml

mojodna added a commit to mojodna/Cascadenik that referenced this issue May 24, 2014
Usage:

    Map {
      font-directory: url("fonts/");
    }

Fixes mapnik#9
@mojodna
Copy link
Member

mojodna commented May 24, 2014

So, I'm trying to fix this because I'm off in the weeds on a Friday evening...

I've gotten as far as getting font-directory to pass through as a URI: mojodna/Cascadenik@b4e1385

However, I'm having trouble associating it with a mapnik.Map here:

def to_mapnik(self, mmap, dirs=None):

It's an "extra param" (i.e. not directly part of the public API, along with minimum_version per extra_known_map_attributes.xml), so it should be attached to mmap.parameters, which is a mapnik._mapnik.Parameters instance and appears to be read-only, but I'm probably missing something.

Ideas?

@mojodna
Copy link
Member

mojodna commented Jun 5, 2014

mmap.parameters.append(mapnik._mapnik.Parameter("font-directory", "fonts/"))
mapnik.save_map(mmap, "style.xml")

outputs:

<?xml version="1.0" encoding="utf-8"?>
<Map srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs">
    <Parameters>
        <Parameter name="font-directory" type="string">fonts/</Parameter>
    </Parameters>
</Map>

This what I was expecting (https://github.com/mapnik/mapnik/blob/master/tests/data/good_maps/extra_known_map_attributes.xml, effectively):

<Map srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs" font-directory="fonts/" />

@springmeyer are these intended to be interchangeable? https://github.com/mapnik/mapnik/blob/49feda9b13e6db416647afad8204b8d7d6c22024/src/load_map.cpp#L263 makes me think that they're not (since it's reading font-directory from the <Map> node).

Is this a bug in the Python bindings?

@springmeyer
Copy link
Member Author

Yes, a bug in the bindings resulting from the oddity of this parameter. Basically, font-directory only matters at the time the xml is loaded so it did not make sense to add it as a new property. So, I think my reasoning was to push it into the extra attributes so that it would not get lost and could be serialized still. But it has gotten lost.

@springmeyer
Copy link
Member Author

hmm, forgot that I actually did away with this support (mapnik/mapnik@ea5a46f#diff-bc721da090a4fdd48972b8aad7f14ec8). So, font-directory is not able to be round tripped and there is no way to add it via python.

@mojodna
Copy link
Member

mojodna commented Jun 5, 2014

Well, crap. Thanks for looking into it.

@springmeyer
Copy link
Member Author

it this lack of round tripping a major problem?

@mojodna
Copy link
Member

mojodna commented Jun 5, 2014

No, I think I've got a better way of dealing with it that doesn't involve Cascadenik.

@springmeyer
Copy link
Member Author

great. so I'll close this. Ping back if you have reservations. I'm planning on reworking the behavior of font-directory in Mapnik master soon (consider making it apply fonts locally to map rather than to global cache) - in this case it would again be round-trippable.

@springmeyer
Copy link
Member Author

note: font-directory round tripping will work around at Mapnik 2.3.x

@mojodna
Copy link
Member

mojodna commented Jul 1, 2014

Awww.. That was very kind of you--thanks! Reopening since it's fixable now!

@mojodna mojodna reopened this Jul 1, 2014
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

4 participants