scalestyle.rb is a ruby script that performs the scaling operations outside mapnik. It modifies the line widths and font sizes directly in the stylesheet before it is passed to mapnik for rendering.
The following images were created with nik2img.py, all with a scale factor of 1.0.
Text
Labels are scaled correctly.
Thursday 8 July 2010
Test Results
I wanted to post these results in redmine, but the wiki doesn't support resizing of images.
Here are the results of some tests with scale factors. The tests are organized according to the element they test. For each element tested (lines, dashes or fonts), I created a style based on osm.xml, removing the symbolizers I didn't need with the purpose of emphasizing the element. The images were created using nik2img.py.
Text
The three images appear scaled and very similar. The second image has twice the size of the first one, with a scale factor of 2 to fix the size of the labels. The third image has three times the size of the first and a scale factor of 2.
Here are the results of some tests with scale factors. The tests are organized according to the element they test. For each element tested (lines, dashes or fonts), I created a style based on osm.xml, removing the symbolizers I didn't need with the purpose of emphasizing the element. The images were created using nik2img.py.
Text
The three images appear scaled and very similar. The second image has twice the size of the first one, with a scale factor of 2 to fix the size of the labels. The third image has three times the size of the first and a scale factor of 2.
Although the size of the labels seems to be correct, some of them move from one image to the other.
Dashes
The following images were created with a style that contained only line symbolizers with dashes.
Dashes
The following images were created with a style that contained only line symbolizers with dashes.
Friday 25 June 2010
June 25
The last change I made has some things I don't like:
I tried to reflect the changes in the python bindings. I added a third parameter to mapnik.Image's constructor and the code compiled correctly. However, townguide's code doesn't produce the images. I tried to disable the code that determines the resolution, but these values are used in other parts of the code that may be ...
- First, to achieve the change in size in the image and the map elements, I applied the scale factor directly in the constructors of image_32 and agg_renderer. For example, I multiplied the scale factor by the width and height of the image before setting these values. I also changed the values of the bboxes that are passed to CoordTransform and label_collision_detector in agg_renderer's constructor. There are maybe other better places than these to apply the scale factor. However, it is convenient to apply it before all these dimension values (image's width and height, label collision area, etc.) are used further.
- Agg_renderer holds a reference to a template type (T & pixmap) instead of a explicit reference to image_32. I assume there might be other image objects that could be used as well, but I haven't seen them in code yet. mapnik_python uses only the image_32 object in the render methods. If there are such other objects, I would have to make the changes I made in image_32 in all these classes.
I tried to reflect the changes in the python bindings. I added a third parameter to mapnik.Image's constructor and the code compiled correctly. However, townguide's code doesn't produce the images. I tried to disable the code that determines the resolution, but these values are used in other parts of the code that may be ...
Thursday 24 June 2010
June 24
Yesterday, I took advantage of the installation I did of townguide-py, Waldemar's project, to test changes in the branch more quickly and to have a variety of different maps to render (using osm's viewer).
Before that, I merged the branch with trunk to have it up to date and take a look at the changes in agg_renderer with respect to scaling. I based the last commit on these changes but also added the scale factor to image_32. It makes sense to me to have it there, because I also need to change the size of the image, not only of the map elements.
Before that, I merged the branch with trunk to have it up to date and take a look at the changes in agg_renderer with respect to scaling. I based the last commit on these changes but also added the scale factor to image_32. It makes sense to me to have it there, because I also need to change the size of the image, not only of the map elements.
Tuesday 22 June 2010
XML Upgrade Problem
I faced a problem when rendering OSM data, that made some elements of the map not to be displayed; the cities appeared in gray and the streets were just thin black lines. The following map of Hartlepool, England, shows how the maps were displayed:
The problem seemed weird to me, because I was following the instructions in Townguide's manual [1] and they produced good results to Waldemar. Besides, Waldemar tried it yesterday in his computer and the maps were rendered correctly, both with mapnik and mapnik2. I thought that the problem was something I changed in the code of AGG renderer, but I went back to the previous revision and the problem was still there.
The problem turned out to be in osm.xml, which I got from: http://svn.openstreetmap.org/applications/rendering/mapnik. Dane Springmeyer had already told me that mapnik2 introduced some changes in the stylesheet, so my stylesheet was outdated. I was also getting deprecation warnings when running mapnik's demos, generate_image.py and nik2img.py:
My first attempt to eliminate these warnings was to use the upgrade_map_xml utility, as Dane Springmeyer told me. However, it didn't seem to work, because the stylesheet was still the same. So what I did was to replace manually what the warnings were telling me, but I guess I made some mistakes (replacing, for example, in sql queries too).
Searching the web, I found that the output of upgrade_map_xml needed to be printed to a file, as it is displayed in the terminal by default. So the correct usage is:
And indeed it was empty after issuing the command.
[1] http://code.google.com/p/townguide/wiki/InstallationInstructions
The problem seemed weird to me, because I was following the instructions in Townguide's manual [1] and they produced good results to Waldemar. Besides, Waldemar tried it yesterday in his computer and the maps were rendered correctly, both with mapnik and mapnik2. I thought that the problem was something I changed in the code of AGG renderer, but I went back to the previous revision and the problem was still there.
The problem turned out to be in osm.xml, which I got from: http://svn.openstreetmap.org/applications/rendering/mapnik. Dane Springmeyer had already told me that mapnik2 introduced some changes in the stylesheet, so my stylesheet was outdated. I was also getting deprecation warnings when running mapnik's demos, generate_image.py and nik2img.py:
Deprecation Warning: symbolizer value now an expression, please wrap properly in brackets like "[name]".
My first attempt to eliminate these warnings was to use the upgrade_map_xml utility, as Dane Springmeyer told me. However, it didn't seem to work, because the stylesheet was still the same. So what I did was to replace manually what the warnings were telling me, but I guess I made some mistakes (replacing, for example, in sql queries too).
Searching the web, I found that the output of upgrade_map_xml needed to be printed to a file, as it is displayed in the terminal by default. So the correct usage is:
$ python upgrade_map_xml.py osm.xml > osm.xml
But what I really did was to print the output in a second file, because python generated the following error:lxml.etree.XMLSyntaxError: Document is empty, line 1, column 1
And indeed it was empty after issuing the command.
[1] http://code.google.com/p/townguide/wiki/InstallationInstructions
June 22
It's been a while since I last updated the blog and I feel that my communication with the community and my mentor has been poor and scarce. I really need to improve in this aspect, because many people are interested in the project and expect a lot from it.
Talking about the progress of the project, my mentor gave me some directions last week, which I haven't had the chance to put in practice, because of some technical difficulties I've found. The problem is starting to frustrate me, because I'm falling behind my schedule and I still have to deal with units and the second part of the project.
I felt that I needed to test the code with images with more elements or detail, so I began to investigate how to work with OSM data in mapnik. Townguide's installation manual was very helpful in this respect. After solving some issues with the postgis database (the nodes table wasn't created when I imported the data using osm2pgsql) I finally manged to create an map. However, this map looks like the following:
When it should look like this:
The second image was produced with townguide-py, Waldemar's project, with mapnik 1 behind and the first one with the new branch, mapnik_resolution. The problem may be caused by some code I introduced lately because Waldemar rendered the map using my branch (latest committed changes) and it looked fine. I'll go back to the previous revision and make the changes one by one to detect the problem.
My next move was to merge trunk with my branch. To incorporate the changes in trunk, I issued the following command:
Revision 1796 is the snapshot of the repository from which the branch was created. While the merging was being executed, conflicts arose; I accepted the changes completely because I wanted mine to be overwritten. However, the changes from trunk were applied, but my changes were still there, which caused a failure when I built the code.
Then I decided to copy it, like this:
But this only created a directory for trunk inside the branch. I need to get help to do it.
Talking about the progress of the project, my mentor gave me some directions last week, which I haven't had the chance to put in practice, because of some technical difficulties I've found. The problem is starting to frustrate me, because I'm falling behind my schedule and I still have to deal with units and the second part of the project.
I felt that I needed to test the code with images with more elements or detail, so I began to investigate how to work with OSM data in mapnik. Townguide's installation manual was very helpful in this respect. After solving some issues with the postgis database (the nodes table wasn't created when I imported the data using osm2pgsql) I finally manged to create an map. However, this map looks like the following:
When it should look like this:
The second image was produced with townguide-py, Waldemar's project, with mapnik 1 behind and the first one with the new branch, mapnik_resolution. The problem may be caused by some code I introduced lately because Waldemar rendered the map using my branch (latest committed changes) and it looked fine. I'll go back to the previous revision and make the changes one by one to detect the problem.
My next move was to merge trunk with my branch. To incorporate the changes in trunk, I issued the following command:
svn merge -r 1796:HEAD svn+ssh://svn@svn.mapnik.org/trunk
Revision 1796 is the snapshot of the repository from which the branch was created. While the merging was being executed, conflicts arose; I accepted the changes completely because I wanted mine to be overwritten. However, the changes from trunk were applied, but my changes were still there, which caused a failure when I built the code.
Then I decided to copy it, like this:
svn copy svn+ssh://svn@svn.mapnik.org/trunk svn+ssh://svn@svn.mapnik.org/branches/mapnik_resolution
But this only created a directory for trunk inside the branch. I need to get help to do it.
Saturday 29 May 2010
May 29
Mapnik Installation (r1796)
I checked out the project's branch from SVN. I want to manage the project locally with Git, so I'll be committing to the server using git-svn.
The installation caused me some trouble:
I checked out the project's branch from SVN. I want to manage the project locally with Git, so I'll be committing to the server using git-svn.
The installation caused me some trouble:
- After installing version 1_43 of boost in /usr/local and building boost.regex, libboost_regex was still linked to libicu version 42. I had libicu 44 in both /usr/local/lib and /usr/lib, but libicu 42 stil in /usr/lib. Even when I included -sICU_PATH=/usr/local when building with bjam it was still linked to the older version. I solved it removing libicu 42 from /usr/lib and leaving only version 44, but I'm sure this is not the correct way to solve this problem.
- The revision I checked out (1796) includes new code that implements some SVG features that are still in development. This revision had two bugs, which where solved by Herm (http://trac.mapnik.org/ticket/557), in files include/mapnik/svg/agg_svg_path_renderer.h (declaration of function 'arc_to' had parameter 'rx' twice | the second 'rx' should be 'ry') and agg/include/agg_rasterizer_scanline_aa.h (function 'abs' should be preceded with 'std::').
- When configuring the build with scons (python scons/scons.py configure) the following problem was solved by removing 'config.py' which (I think) acts as a cache where scons saves the options chosen (i.e. BOOST_LIBS, DEMO) of previous ran configurations:
Note: will build without these OPTIONAL dependencies:
- ociei (Oracle database library | configure with OCCI_LIBS & OCCI_INCLUDES | more info: http://trac.mapnik.org/wiki/OCCI)
- rasterlite
Problem encountered parsing mapnik version, falling back to [0, 8, 0]
- ociei (Oracle database library | configure with OCCI_LIBS & OCCI_INCLUDES | more info: http://trac.mapnik.org/wiki/OCCI)
- rasterlite
Problem encountered parsing mapnik version, falling back to [0, 8, 0]
- Finally, when I finished the installation, importing mapnik2 in python produced the following error, which I solved removing the input file plugins from /usr/local/lib/mapnik2/input [UPDATE: Running the build again installed correctly the input files and python doesn't show errors anymore when importing mapnik2 (it may have something to do with what's referred to here http://trac.mapnik.org/wiki/InstallationTroubleshooting under 'Input/Plugin 'file not found' output')]:
Problem loading plugin library: /usr/local/lib/mapnik2/input/ogr.input (libtool error: file not found)
Problem loading plugin library: /usr/local/lib/mapnik2/input/gdal.input (libtool error: file not found)
Problem loading plugin library: /usr/local/lib/mapnik2/input/gdal.input (libtool error: file not found)
Subscribe to:
Posts (Atom)