mapnik / mapnik Goto Github PK
View Code? Open in Web Editor NEWMapnik is an open source toolkit for developing mapping applications
Home Page: http://mapnik.org
License: GNU Lesser General Public License v2.1
Mapnik is an open source toolkit for developing mapping applications
Home Page: http://mapnik.org
License: GNU Lesser General Public License v2.1
Starting in r485, e.g.
datasource_bmpolygons = PostGIS(host=conf.db_host,
dbname=conf.db_name,
user=conf.db_user,
password=conf.db_password,
table='bmpolygon_joined_current')
where conf.db_host and conf.db_password are both None, fails with
connection [host= dbname=cycling user=cycling password= connect_timeout=4] failed
could not translate host name "dbname=cycling" to address: Name or service not known
I'm trying to open a connection to a PostGIS database using Mapnik from my Python script. It's not working, but Mapnik gives no feedback on why -- it just creates blank tiles. Mapnik should raise an exception or at the very least put something on stderr.
At the moment only int, double and wstring types are supported by Filter parser.
A workaround to this is use Filter("[FIELDNAME]=1")
The current WMS server implementation does not support GetFeatureInfo().
This will be added as soon as the underlying C++ core and Python bindings allow it.
Depends on ticket:1.
The mapnik build system doesn't check for the python lib directory. Attached is a patch to ask python which is the lib directory (lib64 under x86_64).
Version: 0.4.0 (same for trunk)
label_placement should be a property of text_symbolizer.
It would be good to be able to output the raw data of a map image to a given output stream in the same way that you can output to file. For example:
Image32 buf(m.getWidth(),m.getHeight());
agg_renderer r(m,buf);
r.apply();
save_to_file(pngfile,"png",buf.data());
As well as save_to_file, have an output_to_stream function such as:
output_to_stream (std::cout, "png", buf.data());
Use alls set of parameters to calculate connection id.
When combining SRTM contours and OpenStreetMap points of interest, many of the labels on the later disappear. This is because the SRTM labels and osm points share label cache and SRTM labels take all available placements.
Would thus be good to have a flag to empty label cache at the beginning of processing a particular layer.
FreeBSD builds and installs boost libraries with posix threads but without the -mt suffix.
The following changes were necessary for mapnik components to build on FreeBSD. I'm just signalling the breakage: a real check or some added logic that needs to be put into the SConstruct files (by someone more well-versed than I in scons). This is just a hackish change.
svn diff
{{{
--- bindings/python/SConscript (revision 479)
+++ bindings/python/SConscript (working copy)
@@ -28,7 +28,7 @@
linkflags = ''
if env['THREADING'] == 'multi':
--- SConstruct (revision 479)
+++ SConstruct (working copy)
@@ -64,6 +64,9 @@
print "Building on %s ..." % env['PLATFORM']
Help(opts.GenerateHelpText(env))
+if env['PLATFORM'] == 'FreeBSD' :
env.Append(LIBS = 'pthread')
conf = Configure(env)
@@ -145,7 +148,7 @@
for count, libinfo in enumerate(BOOST_LIBSHEADERS):
if env['THREADING'] == 'multi' :
if not conf.CheckLibWithHeader('boost_%s%s-mt' % (libinfo[0],env['BOOST_APPEND']), libinfo[1], 'C++') and libinfo[2] :
if not conf.CheckLibWithHeader('boost_%s%s' % (libinfo[0],env['BOOST_APPEND']), libinfo[1], 'C++') and libinfo[2] :
print 'Could not find header or shared library for boost %s, exiting!' % libinfo[0]
Exit(1)
elif not conf.CheckLibWithHeader('boost_%s%s' % (libinfo[0], env['BOOST_APPEND']), libinfo[1], 'C++') :
@@ -169,9 +172,9 @@
-if 'boost_program_options%s-mt' % env['BOOST_APPEND'] in env['LIBS']:
+if 'boost_program_options%s' % env['BOOST_APPEND'] in env['LIBS']:
SConscript('utils/shapeindex/SConscript')
}}}
THREADING=multi is the default. mapnik r469 fails to build with:
{{{
136 [reid@magnify mapnik-svn]$ python scons/scons.py
scons: Reading SConscript files ...
Building on Linux ...
Checking for main() in C library m... yes
Checking for main() in C library ltdl... yes
Checking for main() in C library png... yes
Checking for main() in C library tiff... yes
Checking for main() in C library z... yes
Checking for main() in C library jpeg... yes
Checking for main() in C library proj... yes
Checking for main() in C library pq... no
Checking for main() in C++ library boost_thread-mt... no
Could not find header or shared library for boost thread, exiting!
}}}
Attempting to create a PostGIS connection using UNIX sockets e.g.:
{{{
datasource_byways = PostGIS(host=None,
dbname=conf.db_name,
user=conf.db_user,
password=conf.db_password,
table='byway_joined_current')
}}}
results in the error message
{{{
connection to host= dbname=cycling user=cycling password= connect_timeout=4 failed
could not translate host name "dbname=cycling" to address: Name or service not known
}}}
Setting host to the empty string or leaving it out altogether give the same result.
In comparison, psycopg (a Python DB API 2.0 adapter) uses UNIX sockets to connect to the database when host is specified in this way.
This is with r432.
to be removed
Empty envelopes are causing infinite recursive splitting in quad_tree.
Hi, I'm trying for 3 days now to install Mapnik on my Suse Server.
But I'm always getting errors. Now I don't know what to do.
myuser:/usr/install/mapnik-0.4.0 # /usr/bin/python2.4 scons/scons.pyscons: Reading SConscript files ...
Checking for main() in C library m... no
I also have the file /usr/include/math.h
and this also looks ok:
ldconfig -p | grep libm.
libmysqlclient_r.so.14 (libc6) => /usr/lib/libmysqlclient_r.so.14
libmysqlclient.so.14 (libc6) => /usr/lib/libmysqlclient.so.14
libmusclecard.so.1 (libc6) => /usr/lib/libmusclecard.so.1
libmusclecard.so (libc6) => /usr/lib/libmusclecard.so
libmp.so.3 (libc6) => /usr/lib/libmp.so.3
libmp.so (libc6) => /usr/lib/libmp.so
libmng.so.1 (libc6) => /usr/lib/libmng.so.1
libmhash.so.2 (libc6) => /usr/lib/libmhash.so.2
libmenuw.so.5 (libc6) => /usr/lib/libmenuw.so.5
libmenu.so.5 (libc6) => /usr/lib/libmenu.so.5
libmemusage.so (libc6, OS ABI: Linux 2.2.5) => /lib/libmemusage.so
libmcrypt.so.4 (libc6) => /usr/lib/libmcrypt.so.4
libmcal.so.0.7 (libc6) => /usr/lib/libmcal.so.0.7
libmcal.so (libc6) => /usr/lib/libmcal.so
libmagic.so.1 (libc6) => /usr/lib/libmagic.so.1
libm.so.6 (libc6, hwcap: 0x8000000000000000, OS ABI: Linux 2.6.4) => /lib/tls/libm.so.6
libm.so.6 (libc6, hwcap: 0x8000000000000, OS ABI: Linux 2.4.1) => /lib/i686/libm.so.6
libm.so.6 (libc6, OS ABI: Linux 2.2.5) => /lib/libm.so.6
can anybody tell me what to do?
Thanx in advance
When using Mapnik and the PostGIS input driver, if you don't have the postgis driver installed mapnik simply assumes no data exists for the layer and continues on, when instead it should throw an error of some kind.
Steps to reproduce:
Expected behaviour:
Actual behaviour:
Mapnik uses combination of iconv and fribidi to support unicode and BIDI. There is no support for 'shaping'. It looks like ICU library has got all features we need, it's c++
and some boost libraries (e.g boost_regex) can be built with ICU support already.
I'm planning to investigate using ICU as a replacement for iconv, fribidi.
This ticket describes problems installing in a non-standard location as a non-root user; /tmp/mapnik fills in for the real installation location.
The desired installation would be as follows, and it should obtainable by specifying a single parameter (preferably "prefix" since that is what other build systems use).
{{{
xx [reid@magnify mapnik-src]$ find /tmp/mapnik -xtype d
/tmp/mapnik
/tmp/mapnik/bin
/tmp/mapnik/include
/tmp/mapnik/include/mapnik
/tmp/mapnik/lib
/tmp/mapnik/lib/mapnik
/tmp/mapnik/lib/mapnik/input
/tmp/mapnik/lib/mapnik/fonts
/tmp/mapnik/lib/python2.4
/tmp/mapnik/lib/python2.4/site-packages
/tmp/mapnik/lib/python2.4/site-packages/mapnik
/tmp/mapnik/lib/python2.4/site-packages/mapnik/ogcserver
}}}
(a) With ''python scons/scons.py PREFIX=/tmp/mapnik install'', the build fails. (Note also that the error message is misleading: a missing file is only a symptom; the real reason the build failed is that I don't have permission to write to the directory it's trying to install into.)
{{{
63 [reid@magnify mapnik-src]$ python scons/scons.py PREFIX=/tmp/mapnik install
scons: Reading SConscript files ...
Checking for main() in C library m... yes
Checking for main() in C library ltdl... yes
Checking for main() in C library png... yes
Checking for main() in C library tiff... yes
Checking for main() in C library z... yes
Checking for main() in C library jpeg... yes
Checking for main() in C library proj... yes
Checking for main() in C library pq... no
Checking for main() in C++ library boost_thread... yes
Checking for main() in C++ library boost_filesystem... yes
Checking for main() in C++ library boost_regex... yes
Checking for main() in C++ library boost_program_options... yes
Bindings Python version... 2.4
Python 2.4 prefix... /usr
scons: done reading SConscript files.
scons: Building targets ...
Install file: "bindings/python/mapnik/paths.py" as "/usr/lib/python2.4/site-packages/mapnik/paths.py"
scons: *** [/usr/lib/python2.4/site-packages/mapnik/paths.py] Exception
Traceback (most recent call last):
File "/tmp/mapnik-src/scons/scons-local-0.96.1/SCons/Taskmaster.py", line 101, in execute
self.targets[0].build()
File "/tmp/mapnik-src/scons/scons-local-0.96.1/SCons/Node/init.py", line 201, in build
apply(executor, (self, errfunc), kw)
File "/tmp/mapnik-src/scons/scons-local-0.96.1/SCons/Executor.py", line 115, in call
apply(action, (self.targets, self.sources, env, errfunc), kw)
File "/tmp/mapnik-src/scons/scons-local-0.96.1/SCons/Action.py", line 243, in call
stat = self.execute(target, source, env)
File "/tmp/mapnik-src/scons/scons-local-0.96.1/SCons/Action.py", line 512, in execute
return self.execfunction(target=target, source=rsources, env=env)
File "/tmp/mapnik-src/scons/scons-local-0.96.1/SCons/Environment.py", line 82, in installFunc
return install(target[0].path, source[0].path, env)
File "/tmp/mapnik-src/scons/scons-local-0.96.1/SCons/Defaults.py", line 219, in copyFunc
shutil.copy2(source, dest)
File "/usr/lib/python2.4/shutil.py", line 92, in copy2
copyfile(src, dst)
File "/usr/lib/python2.4/shutil.py", line 48, in copyfile
fdst = open(dst, 'wb')
IOError: [Errno 2] No such file or directory: '/usr/lib/python2.4/site-packages/mapnik/paths.py'
scons: building terminated because of errors.
}}}
(c) With ''python scons/scons.py DESTDIR=/tmp/mapnik install'', the build succeeds, but the installation has extra ''/usr'' and ''/usr/local'' subpaths:
{{{
67 [reid@magnify mapnik-src]$ find /tmp/mapnik -xtype d
/tmp/mapnik
/tmp/mapnik/usr
/tmp/mapnik/usr/lib
/tmp/mapnik/usr/lib/python2.4
/tmp/mapnik/usr/lib/python2.4/site-packages
/tmp/mapnik/usr/lib/python2.4/site-packages/mapnik
/tmp/mapnik/usr/lib/python2.4/site-packages/mapnik/ogcserver
/tmp/mapnik/usr/local
/tmp/mapnik/usr/local/bin
/tmp/mapnik/usr/local/lib
/tmp/mapnik/usr/local/lib/mapnik
/tmp/mapnik/usr/local/lib/mapnik/input
/tmp/mapnik/usr/local/lib/mapnik/fonts
/tmp/mapnik/usr/local/include
/tmp/mapnik/usr/local/include/mapnik
}}}
(c) With ''python scons/scons.py PREFIX=/tmp/mapnik DESTDIR=/ install'', the build fails in the same way as (a).
(d) With ''python scons/scons.py PREFIX=/ DESTDIR=/tmp/mapnik install'', the build succeeds, but the extra ''/usr'' subpaths are still present:
{{{
72 [reid@magnify mapnik-src]$ find /tmp/mapnik -xtype d
/tmp/mapnik
/tmp/mapnik/usr
/tmp/mapnik/usr/lib
/tmp/mapnik/usr/lib/python2.4
/tmp/mapnik/usr/lib/python2.4/site-packages
/tmp/mapnik/usr/lib/python2.4/site-packages/mapnik
/tmp/mapnik/usr/lib/python2.4/site-packages/mapnik/ogcserver
/tmp/mapnik/bin
/tmp/mapnik/lib
/tmp/mapnik/lib/mapnik
/tmp/mapnik/lib/mapnik/input
/tmp/mapnik/lib/mapnik/fonts
/tmp/mapnik/include
/tmp/mapnik/include/mapnik
}}}
Some methods e.g:
{{{
style = m.find_style('My Style')
}}}
returns a copy of an object while others might reference existing object.
We need to provide doc strings to clearly state 'return value policy'
Change 'query_point' method to accept (x,y) in Map coordinate system ( was lat/long )
It would be nice to be able to write text along a line with a "vertical" displacement, so that a streetname could be rendered alongside the street. Similar to that for the dy attribute to point textsymbolizer.
{{{ }}}
The displacement would probably refer to the distance between the line and text path at right angles to the line, rather than a vertical displacement on the final render. The latter wouldn't work for north-south streets!
Consideration would need to be given to corners in lines, e.g. the displacement given would indicate the gap between the two paths, and would have to be maintained around the corners.
Color mapped raster is not handled in gdal.input
Data containing anything beyond standard 7-bit ascii characters gets improperly handled. For example, french accented characters in the demo data come out missing on maps generated by the demo, or corrupted when output through WMS' GetFeatureInfo.
This has only been tested and observed with shapefile data, I can't speak as to whether this might also be a problem with PostGIS.
My memory is fuzzy, but I'm pretty sure this worked at some point?
if we try to make filter with a '''unicode''' string;
arule = Rule()[[BR]]
arule.filter = Filter("[road_type] = 'işlek'")[[BR]]
arule = Rule()[[BR]]
arule.filter = Filter("[road_type] = 'i\351lek'")[[BR]]
arule = Rule()[[BR]]
arule.filter = Filter("[road_type] = 'i\x15flek'")[[BR]]
'''problem''' : failed at := 'i\x15flek'[[BR]]
DejaVu fonts are derived from Bitstream Vera and offer better Unicode support.
'Interlaced' images are not loaded properly by png_reader.
Currently polygons are only labeled at their centroid. I'm interested in having polygons labeled even when the polygon's center is not in the image.
for f in ds.features_at_point(merc):
print f
<mapnik._mapnik.Feature object at 0xb7f163ac>
on that, I'd expect to be able to call:
for (k,v) in f.properties:
but I can't. Also, if I do:
f.properties['type']
I get back a mapnik._mapnik.Value object, and not a native python object as I'd expect
Also, if I do
for prop in f.properties:
you have to call key() and value(), it'd be good if there were python attributes for them
Nick
At the moment data source loader iterates through all files in directory. We can safely
only consider files with *.input ext.
See [https://lists.berlios.de/pipermail/mapnik-users/2007-October/000439.html thread on Mapnik users mailing list].
And http://support.mapbox.com/discussions/tilemill/7787-postgis-layer-loads-but-features-are-empty
The PostGIS plugin/WKB reader assumes that geometries are in 2D. Though not standard OGC, PostGIS supports 3D/4D. There are two ways to fix this in Mapnik :
Comparing Mapnik to other maps such as A-Z (on a completely mapped area, of course), Mapnik isn't too good at rendering the names of small ways. I'd guess it's because Mapnik only writes names along the way in a single line, rather than having text above and below the way as well. It could also shorten "road" to "rd", "place" to "pl", and so on. Two examples:
Here, 'Besant Place' is rendered at zoom level 18 but no others, although there is plenty of space at level 17 and possibly space at 16: http://www.openstreetmap.org/?lat=51.461921004143846&lon=-0.07821224290394427&zoom=18
In this example, 'Jarvis Road' isn't rendered at all (it's the fatter residential road coming off Melbourne Grove). Given that there's nothing to the left until you reach the (unrendered) hospital, there is plenty of space to squeeze this name in: http://www.openstreetmap.org/?lat=51.46022479727068&lon=-0.07955871153778353&zoom=18
A related problem occurs with long ways, where the name only seems to get rendered once and in the middle at all zoom levels, rather than repeating the name at higher zoom levels so one doesn't have to drag the map around to find it. In this example most of the primary and secondary suffer from this problem, just zoom in to the top of Lordship Lane to see what I mean. With the junction of Barry Road & Peckham Rye (the two secondary ways) it's not even clear which road continues to the North, causing a bit of a navigational problem as well: http://www.openstreetmap.org/?lat=51.45448897859278&lon=-0.0686260299610329&zoom=15
When installing mapnik into a user directory (without superuser privileges), the build fails because the Scons can not install Python modules in the main Python tree.
In order to force Scons to install Python modules into the specified prefix, I changed line 26 of bindings/python/SConscript from :
{{{
prefix = env['PYTHON_PREFIX'] + '/' + env['LIBDIR_SCHEMA'] + '/python' + env['PYTHON_VERSION'] + '/site-packages/'
}}}
to:
{{{
prefix = env['PREFIX'] + '/' + env['LIBDIR_SCHEMA'] + '/python' + env['PYTHON_VERSION'] + '/site-packages/'
}}}
I do not know if this solution could be recommended but it would be great to respect the PREFIX build option anyway.
At the moment Features store text attributes in std::string (in client encoding) and only transcoded to wide-strings (UCS-2) during rendering. This causes a problem with Python bindings exposing Features text properties in other then ASCII e.g.:
{{{
from mapnik import *
ds = Shapefile(file='./demo/data/boundaries')
pt = ds.envelope().center()
fs = ds.features_at_point(pt)
f = fs.next()
name = str(f.properties['NOM_FR'])
name
'Qu\xe9bec'
print name
Qu�ec
name_unicode = unicode(name,'Latin1') # we know it's in Latin1
name_unicode
u'Qu\xe9bec'
print name_unicode
Québec
}}}
One way to address this is to convert to and store text attributes as Unicode (UCS-2). In Python bindings we can provide 'unicode' method to access std::wstring as a Python Unicode.
{{{
name = f.properties['NOM_FR'].unicode() # name is Python Unicode
name
u'Qu\xe9bec'
print name
Québec
}}}
At the moment there is no way to get list of available faces in a font.
There's a ticket raised against OpenStreetMap (http://trac.openstreetmap.org/ticket/569) reporting some streets whose names are being rendered upside down by mapnik. The streets in question can be seen at http://openstreetmap.org/?lat=61.48511&lon=23.82427&zoom=15&layers=B0F - note that if you zoom in one more notch the names are the right way up.
Hi,
In r484,
{{{
sym = TextSymbolizer('name', 'DejaVu Sans Book', int(point_size), Color('black'))
}}}
works fine, while
{{{
sym = TextSymbolizer('name', 'Bitstream Vera Sans Roman', int(point_size), Color('black'))
}}}
fails silently, i.e. no labels are drawn.
There should be some error indication, not silent failure.
Subversion revision 438 fails to build on Ubuntu Dapper:
{{{
scons: Reading SConscript files ...
Checking for main() in C library m... yes
Checking for main() in C library ltdl... yes
Checking for main() in C library png... yes
Checking for main() in C library tiff... yes
Checking for main() in C library z... yes
Checking for main() in C library jpeg... yes
Checking for main() in C library proj... yes
Checking for main() in C library pq... yes
Checking for main() in C++ library boost_thread-gcc-mt... no
Checking for main() in C++ library boost_thread-gcc... no
Could not find header or shared library for boost thread, exiting!
}}}
{{{
11 [reid@magnify ~]$ ls -l /usr/lib/libboost_thread*
lrwxrwxrwx 1 root root 39 2006-11-06 10:49 /usr/lib/libboost_thread-gcc-mt-1_33_1.so -> libboost_thread-gcc-mt-1_33_1.so.1.33.1
-rw-r--r-- 1 root root 40928 2006-01-11 21:13 /usr/lib/libboost_thread-gcc-mt-1_33_1.so.1.33.1
lrwxrwxrwx 1 root root 32 2006-11-06 10:49 /usr/lib/libboost_thread.so -> libboost_thread-gcc-mt-1_33_1.so
}}}
r432 worked fine for me. I suspect this is related to the Boost changes in r433?
render_to_tile() prints timing information on standard out; I'd like to be able to suppress this in order to build a mapnik script that runs quietly.
IMO, no output should be the default.
Add missing doc strings to core objects e.g Style,Rule,Filter,Datasource etc.
When a name is rendered on an area with TextSymbolizer it looks like the top line of the text is placed in the centre of the area vertically, rather than centring the whole block of text. See Sheredes School in the middle of http://www.openstreetmap.org/?lat=51.75335969615901&lon=-0.019260559503621932&zoom=16 for an example
to be removed
While migrating to new hosting, two original tutorials got lost. We need to revive them or create new ones.
NUMERIC type is ignored at the moment.
When I run scons it will eventually error saying that mapnik.so cannot be linked. So when I defer the python bindings and the plugins and build src/ it will all work. It appears that scons build alphabetically by directory name than by precedence?
These options are needed to enhance label and shield placements. Buffer would specify the distance around labels where other labels will not be placed. Min_distance would specify the minimum distance between duplicate labels.
See patch which enables the max_char_angle_delta attribute in the element of a mapnik XML file.
I installed Mapnik with:
{{{
prefix=/export/scratch/reid/python
site_packages=lib/python2.4/site-packages
set -e
python scons/scons.py THREADING=single PGSQL_INCLUDES=/usr/include/postgresql PREFIX= DESTDIR=$prefix install
cd $prefix
rm -fv $site_packages/mapnik
ln -v -s ../../../usr/$site_packages/mapnik $site_packages/mapnik
sudo rm -fv /lib/mapnik
sudo ln -v -s $prefix/lib/mapnik /lib/mapnik
}}}
... and the input plugins were not found without the last two lines, which require superuser priviledges, i.e. AFAICT it is no longer possible to install Mapnik without root access.
This is r469.
Build fails on OS X 10.4.9 with libiconv 1.11. The attached patch compiles past this point.
{{{
include/mapnik/unicode.hpp: In member function 'std::wstring mapnik::transcoder::transcode(const std::string&) const':
include/mapnik/unicode.hpp:177: error: invalid conversion from 'char**' to 'const char**'
include/mapnik/unicode.hpp:177: error: initializing argument 2 of 'size_t libiconv(void_, const char__, size_t_, char*, size_t)'
scons: *** [bindings/python/mapnik_datasource.os] Error 1
scons: building terminated because of errors.
}}}
We are building tiles where the point size of line labels can exceed the width of the line. In these case, labels are applied very sparsely (see example tiles).
I don't have a complete example to share, since it would require access to our database, but let me know if you can't reproduce it. I can try to get something out of rundemo.py.
Please feel free to contact me if you need more information or testing.
Add support for building Mapnik on Mac OS X using native gcc_4.0.1 compiler
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.