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

Nik2Img: setting bbox and zoom level together doesn't work? #4

Closed
Andrey-VI opened this issue Dec 19, 2012 · 7 comments
Closed

Nik2Img: setting bbox and zoom level together doesn't work? #4

Andrey-VI opened this issue Dec 19, 2012 · 7 comments

Comments

@Andrey-VI
Copy link

Command used: nik2img.py style.xml image.png -b 37.598494 55.745767 37.621711 55.755182 -z 17 -v
Terminal output here: https://gist.github.com/4337623
Note the steps 11—14 and 18. Strange values there.
Resulting image.png not with bbox (37.598494,55.745767,37.621711,55.755182), but seems to be with bbox (5.0932890358,-0.000894408328134,5.09603561778,0.000936646328296).

@springmeyer
Copy link
Member

not sure it will fix by try -d 256 256 to pass a square image (default is 600x400)

@springmeyer
Copy link
Member

recall Mapnik's aspect_fix_ratio which will, by default, fix the aspect ratio of the map bounds to fit the image size (I think, can always mix this up)

@Andrey-VI
Copy link
Author

But I want to set bbox and zoom level only, and Nik2Img should calculate image dimensions according to this values…
Maybe this is missing feature not the bug?

@springmeyer
Copy link
Member

the default is GROW_BBOX (which means the bbox will be changed to fix the aspect ratio of the image): https://github.com/mapnik/mapnik/blob/master/src/map.cpp#L63

Sounds like you might want to do:

nik2img.py --aspect-fix-mode=GROW_CANVAS ...

https://github.com/mapnik/mapnik/blob/master/src/map.cpp#L431-L485

@Andrey-VI
Copy link
Author

My only problem is bbox. -b option in combination with -z option doesn't work.
With -b 37.598494 55.745767 37.621711 55.755182 -z 17 or -b 30 50 40 60 -z 17 I get

Step: 11 // --> Map extent: Box2d(5.0932890358,-0.00135217199224,5.09603561778,0.0013944099924)
Step: 12 // --> Map long/lat bbox: Box2d(5.0932890358,-0.00135217199224,5.09603561778,0.0013944099924)
Step: 13 // --> Map center: Coord(5.09466232679,2.11190000812e-05)
Step: 14 // --> Map long/lat center: Coord(5.09466232679,2.11190000812e-05)
Step: 15 // --> Map scale denominator: 4265.45909532
Step: 16 // --> Extent of all layers: Box2d(-180.000026,-89.000047438,190.189350653,89.000089676)
Step: 17 // --> Long/lat extent of all layers: Box2d(-180.000026,-89.000047438,190.189350653,89.000089676)
Step: 18 // --> Long/lat center of all layers: Coord(5.09466232679,2.11190000812e-05)

Why?

@springmeyer
Copy link
Member

I'm not sure. I recommend you try digging around in the nik2img.py code (its just python) or write a pure python script to try to get done what you are after (as a comparative testcase)

@springmeyer
Copy link
Member

I'm going to close this up. You've likely found a legitimate bug/oddity in nik2img, but its not a tool that I use/develop regularly.

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

2 participants