Talk:Mapgen.pl

From OpenStreetMap Wiki
Jump to navigation Jump to search

Wish / Wünsche

  • Rendern von Way-Relationen für Wanderkarten (done)
  • Einbindung von Grafiken statt Farben für Flächen (done)
  • weiteren Filter für die Routen um z.B. Fernwanderweg und Jakobsweg unterschiedlich darstellten zu können.

Not necessarily in scope

  • connecting parts of streets belonging to the same street (for labeling) (done)
  • map area selection by boundary polygons
  • map area selection by external polygons
  • map area selection by bounding box (done)
  • Projection? (done)
  • draw Bézier-Curve for a better look
  • export svg elements with id's dereived from name tags (each svg element should have an id? names are not unique... --Gary68 20:34, 3 March 2010 (UTC))
it would be great if there was some relation between id and tags, would be very useful for taking it into other programs like processing for example. one easy solution is to have the existing unique id's and append name to it only if its there --Planemad/Talk 10:31, 4 March 2010 (UTC)
just out of curiousity: what are you going to do with this information exactly? (what process, what program?) --Gary68 11:21, 4 March 2010 (UTC)
For creating visualizations using Processing, i could apply dynamic styling on the fly using a database if i could target elements through their id's. One thing i had in mind was a visual street search, as you type in the streetname, the matching streets gets highlighted, something like this :) --Planemad/Talk 14:00, 4 March 2010 (UTC)
I second PlaneMad's suggestions but would prefer the tag information to be on the class attribute. As in HTML this can have multiple values, incidentally. The OSM ID could, perhaps, be on the ID attribute. Alex McKee 01:16, 8 March 2010 (UTC)
ooh, yes :) --Planemad/Talk 16:28, 10 March 2010 (UTC)

download latest

i write a little script for windows by using wget. the request files will be download and save in the define folders

echo off
echo MAPGEN - download latest version

set folder_pm=C:\Perl\lib\osm
set folder_mapgen=%osmworkfolder%\mapgen
set url_svn="http://svn.openstreetmap.org/applications/utils/gary68"

echo delete old versions

del %folder_pm%\osm.pm
del %folder_pm%\mapgen.pm
del %folder_pm%\mapgenRules.pm
del %folder_pm%\QuadTree.pm

del %folder_mapgen%\mapgenRules.ods
del %folder_mapgen%\mapgenRules.csv
del %folder_mapgen%\mapgen.pl
del %folder_mapgen%\dir.pl
del %folder_mapgen%\mapgenManual.pdf
del %folder_mapgen%\icons.zip

wget "%url_svn%/OSM/osm.pm" -O "%folder_pm%\osm.pm"
wget "%url_svn%/OSM/mapgen.pm" -O "%folder_pm%\mapgen.pm"
wget "%url_svn%/OSM/mapgenRules.pm" -O "%folder_pm%\mapgenRules.pm"
wget "%url_svn%/OSM/QuadTree.pm" -O "%folder_pm%\QuadTree.pm"

wget "%url_svn%/mapgen.pl" -O "%folder_mapgen%\mapgen.pl"
wget "%url_svn%/dir.pl" -O "%folder_mapgen%\dir.pl"
wget "%url_svn%/mapgenRules.csv" -O "%folder_mapgen%\mapgenRules.csv"
wget "%url_svn%/mapgenRules.ods" -O "%folder_mapgen%\mapgenRules.ods"
wget "%url_svn%/mapgenManual.pdf" -O "%folder_mapgen%\mapgenManual.pdf"
wget "%url_svn%/icons.zip" -O "%folder_mapgen%\icons.zip"

set folder_pm=
set folder_mapgen=
set url_svn=

pause

you only had to modify the values for the parameters folder_pm and folder_mapgen. WGET for windows you can download here.

  • OR install and configure SVN and type "svn update"...

Label fallback

A really nice feature would be the ability to provide multiple values for the label argument. If a certain tag wasn't available then it would fallback to the other value. For example: name:cy, name meaning name in Welsh if available, otherwise name. Alex McKee 06:33, 11 February 2010 (UTC)

DONE
Fantastic implementation, you even anticipated what would have been my next request! Alex McKee 19:59, 25 February 2010 (UTC)

Can't locate Math/Polygon.pm

This morning, I used svn update on an Ubuntu Karmic (9.10) box and a Fedora 9 box to get the latest version of mapgen.pl

Now, when I run mapgen.pl I get the following error:

Can't locate Math/Polygon.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.10.0 /usr/local/share/perl/5.10.0 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.10 /usr/share/perl/5.10 /usr/local/lib/site_perl .) at mapgen.pl line 52. BEGIN failed--compilation aborted at mapgen.pl line 52.

The error is the same on both machines (though the "@INC contains:" varies)

I can't find any relevant packages for either Ubuntu or Fedora to install the Polygon.pm module.

--Avantman42 09:15, 11 February 2010 (UTC)

Rationale for not using a xml library

Hi, is there a reason you are not using a xml parser library and do all the xml extraction by regexes? Maybe I'll sometime do some programming on OSM files, so i just want to ask if there is some reason as to not use a xml lib with osm. Thanks, --Gormo 14:12, 18 February 2010 (UTC)

I somehow started this way 2 years ago and got stuck with the regexes. As far as I remember someone wrote this was faster... Gary68

POI icons

I've been playing with this and received very impressive results already (after some manual preprocessing of osm data and a lot of experimental changes especially with font sizes).

A few questions still:

Could you perhaps provide the png images referenced in the svg file or does everyone rather create his own?

just grabbed a few icons from the wiki. please look there. -- Gary68
will publish some soon --Gary68 17:58, 1 March 2010 (UTC)

Would it be possible to define the icons as svg? I found it a little of a pitty that the script creates lovely fully scalable maps but uses pixel images as icons. I would happily provide the svg files as I think my knowledge of Inkscape is slightly better than my Perl scripting skills.

i suppose that svg files do also work... or don't they? didn't try yet. -- Gary68
I'll check on that. My suspicion was that you can't link svg files they same way as images, but the better if it works. -- g0ldfish
No, it does not seem to work this way, you can't embed another svg file they way you would do with pixel images. However, if the svg file contains the icon as a single path (first point in path on the baseline of the icon and first point set to 0,0 as in these examples ->[1]), it seems possible to extract the path from the file and insert it into the map svg file instead of the image. Would that be an improvement you might think about, or is this beyond scope? -- g0ldfish
for my icons it works somehow. i will shortly publish a zip of all icon and tile files. i recently put them all in one directory so it shouldn't be a problem. --Gary68 17:58, 1 March 2010 (UTC)
i once had the problem that my pdf viewer didn't show correct results although the svg files were correct. try png or another viewer! --Gary68 18:11, 1 March 2010 (UTC)
I think I found the reason now: I used to generate the SVG map on Linux , but used Inkscape /Firefox on Windows to edit/view it, and the both seem to have unclosed bugs reported about not showing links SVG files: https://bugs.launchpad.net/inkscape/+bug/168244 -- g0ldfish

Oh, and there is a hint that modern Acrobat Readers would allow to print enlarged pdf files spanning over several pages. I somehow cannot seem to find this feature in the print dialogs, where do I access it? G0ldfish 16:24, 19 February 2010 (UTC)

it's right in the print dialog. it's in the drop box where you usually select "fit page" and the like. then a new dialog item appears where a parameter can be given how to enlarge the map. -- Gary68
No luck there :( May it be printer-specific? -- g0ldfish
it's in adobe acrobat 9 STANDARD, version 9.1.3 - no matter what printer i choose. -Gary68

OSX 10.6 (Leopard) install

$ cpan Compress::Bzip2
$ cpan Math::Polygon
$ cpan GD::Graph3d
if not, try: $ cpan sudo <whatever>
may need also: $ cpan YAML


Then create folder /mapgen and download mapgen.pl and rest of files into it.
Also create folder /mapgen/OSM and download mapgen.pm and rest of *.pm files into it.
Get a map.osm or download it and put map.osm in folder /mapgen
e.g.> http://api.openstreetmap.org/api/0.6/map?bbox=-0.489,51.28,0.236,51.686
The bbox (bounding box) goes in this order: minlongitude, minlatitude, maxlongitude, maxlatitude (left, bottom, right, top).
The numbers can be taken from export tab in openstretmap.org

run the perl script to get the mapgen.svg
$ ./mapgen.pl -in=map.osm -style=mapgenRules.csv

check mapgenManual.pdf for other arguments --Sergionaranja 12:25, 30 March 2010 (UTC)

Geo::Proj4 on Windows

Having difficulty getting Geo::Proj4 to install on Windows. I have the windows binary of Proj4 installed but Geo::Proj4 is failing to install giving "Error: proj library version not known". Any help and advice would be appreciated. Alex McKee 10:44, 21 July 2010 (UTC)

I should add that I read this thread on talk-de but couldn't follow the meaning well enough Alex McKee 10:53, 21 July 2010 (UTC)
Forget it. Geo::Proj4 is a Perl adaption for the original Proj library written in C. It uses a dynaloader.pm-Modul which may or may not work with Windows Versions of Perl. In our case, it may not.

You could use cygwin under Windows to emulate a linux shell, or Virtual box. Or find someone who might reprogram the C-routines in native perl. Ajoessen 28.10.2010