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

render bounding box question #8

Closed
africanrhino opened this issue Mar 6, 2017 · 7 comments
Closed

render bounding box question #8

africanrhino opened this issue Mar 6, 2017 · 7 comments

Comments

@africanrhino
Copy link
Contributor

is there any way we can get the bbox and scale of what is to be rendered by the map? the zoomToBox zooms the image to fit the bounds of map, but if say you produce a 800X600 image based on a zoomToBox that's 16:9 then the rendered bounding box will be significantly different to the original 16:9. I'm trying to manipulate the data layer to exclude any label on the edge of the map but without knowing what the true bounding box is and without knowing the scale will be makes this difficult. any ideas here?

@garrettrayj
Copy link
Owner

Mapnik has functionality to get a map's extent and scale, but it is not implemented in the extension yet. I also suspect that being able to change the aspect fix mode (https://github.com/mapnik/mapnik/wiki/Aspect-Fix-Mode) would be helpful.

Relevant Mapnik methods:

Let me know if you want to tackle implementation. Otherwise I'll work up something over the next week or two.

@africanrhino
Copy link
Contributor Author

I wish I could. not very handy with c. I am at "hello world" level. I think those mapnik methods would be very handy. am trying to implement it via the !bbox! intersect thing but its not very flexible nor particularly useful. perusing the map.hpp, remove_style might also be very useful in the long run. I suspect this project will mostly be used to generate static maps, at least that's how i'm using it and managing layers and styles is big one for that. the way i am doing it is loading the xml file and altering the style and layer then send it via loadXmlString().

great project, very useful to have this available native in php7+ thank you very much for the effort so far!

@garrettrayj
Copy link
Owner

garrettrayj commented Mar 18, 2017

The discussed methods are now available in the develop branch. There is some house keeping and documentation work I want to get in, so a tagged release is still a couple weeks out. Until then, the map class tests offer the best look into what's available.

@africanrhino
Copy link
Contributor Author

great enhancements , good to see you pulled though a lot more than i thought you were. I've tried to compile it but it to be failing on

make test
@ FAIL \Mapnik\Image [tests/image.phpt]

i didn't get any compile errors. could it be a libgd version thing? the master branch still compiles and passes the tests.

@garrettrayj
Copy link
Owner

Paths for test images were missing a directory separator. 🤦‍♂️

I got Travis (Ubuntu Trusty) back to building successfully so you might pull and try again. Thanks!

@africanrhino
Copy link
Contributor Author

ok , all is working , new functions are sweet! :)

$class_methods = get_class_methods($map);
echo print_r($class_methods,true);
gives ->

Array
(
[0] => __construct
[1] => loadXmlFile
[2] => loadXmlString
[3] => zoom
[4] => zoomAll
[5] => pan
[6] => panAndZoom
[7] => zoomToBox
[8] => registerFonts
[9] => getBasePath
[10] => setBasePath
[11] => getWidth
[12] => setWidth
[13] => getHeight
[14] => setHeight
[15] => resize
[16] => getSrs
[17] => setSrs
[18] => getBackgroundImage
[19] => setBackgroundImage
[20] => getBackgroundImageOpacity
[21] => setBackgroundImageOpacity
[22] => getMaximumExtent
[23] => setMaximumExtent
[24] => resetMaximumExtent
[25] => getCurrentExtent
[26] => getBufferSize
[27] => setBufferSize
[28] => getBufferedExtent
[29] => getScale
[30] => getScaleDenominator
[31] => countLayers
[32] => removeStyle
[33] => removeAll
[34] => getAspectFixMode
[35] => setAspectFixMode
)

@garrettrayj
Copy link
Owner

New functionality has been merged into master and released with 1.2.0. Make sure and checkout the new API docs too. Thank you for creating the issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants