+ hebrew rtl patch from JonB
This commit is contained in:
parent
df8cfcab03
commit
dce49f4a75
4 changed files with 46 additions and 11 deletions
|
@ -30,7 +30,7 @@ installed successfully before running this script.\n\n'
|
|||
# Instanciate a map, giving it a width and height. Remember: the word "map" is
|
||||
# reserved in Python! :)
|
||||
|
||||
m = Map(800,600,"+proj=latlong +ellps=WGS84")
|
||||
m = Map(800,600,"+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs")
|
||||
|
||||
# Set its background colour. More on colours later ...
|
||||
|
||||
|
@ -56,6 +56,7 @@ m.background = Color('white')
|
|||
# table= TODO
|
||||
|
||||
provpoly_lyr = Layer('Provinces')
|
||||
provpoly_lyr.srs = "+proj=lcc +ellps=GRS80 +lat_0=49 +lon_0=-95 +lat+1=49 +lat_2=77 +datum=NAD83 +units=m +no_defs"
|
||||
provpoly_lyr.datasource = Shapefile(file='../data/boundaries', encoding='latin1')
|
||||
|
||||
# We then define a style for the layer. A layer can have one or many styles.
|
||||
|
@ -120,7 +121,7 @@ m.layers.append(provpoly_lyr)
|
|||
# A simple example ...
|
||||
|
||||
qcdrain_lyr = Layer('Quebec Hydrography')
|
||||
|
||||
qcdrain_lyr.srs = "+proj=lcc +ellps=GRS80 +lat_0=49 +lon_0=-95 +lat+1=49 +lat_2=77 +datum=NAD83 +units=m +no_defs"
|
||||
qcdrain_lyr.datasource = Shapefile(file='../data/qcdrainage')
|
||||
|
||||
qcdrain_style = Style()
|
||||
|
@ -138,6 +139,7 @@ m.layers.append(qcdrain_lyr)
|
|||
# re-use the style defined in the above layer for the next one.
|
||||
|
||||
ondrain_lyr = Layer('Ontario Hydrography')
|
||||
ondrain_lyr.srs = "+proj=lcc +ellps=GRS80 +lat_0=49 +lon_0=-95 +lat+1=49 +lat_2=77 +datum=NAD83 +units=m +no_defs"
|
||||
ondrain_lyr.datasource = Shapefile(file='../data/ontdrainage')
|
||||
|
||||
ondrain_lyr.styles.append('drainage')
|
||||
|
@ -146,6 +148,7 @@ m.layers.append(ondrain_lyr)
|
|||
# Provincial boundaries
|
||||
|
||||
provlines_lyr = Layer('Provincial borders')
|
||||
provlines_lyr.srs = "+proj=lcc +ellps=GRS80 +lat_0=49 +lon_0=-95 +lat+1=49 +lat_2=77 +datum=NAD83 +units=m +no_defs"
|
||||
provlines_lyr.datasource = Shapefile(file='../data/boundaries_l')
|
||||
|
||||
# Here we define a "dash dot dot dash" pattern for the provincial boundaries.
|
||||
|
@ -169,6 +172,7 @@ m.layers.append(provlines_lyr)
|
|||
# Roads 3 and 4 (The "grey" roads)
|
||||
|
||||
roads34_lyr = Layer('Roads')
|
||||
roads34_lyr.srs = "+proj=lcc +ellps=GRS80 +lat_0=49 +lon_0=-95 +lat+1=49 +lat_2=77 +datum=NAD83 +units=m +no_defs"
|
||||
# create roads datasource (we're going to re-use it later)
|
||||
|
||||
roads34_lyr.datasource = Shapefile(file='../data/roads')
|
||||
|
@ -202,7 +206,7 @@ m.layers.append(roads34_lyr)
|
|||
# Roads 2 (The thin yellow ones)
|
||||
|
||||
roads2_lyr = Layer('Roads')
|
||||
|
||||
roads2_lyr.srs = "+proj=lcc +ellps=GRS80 +lat_0=49 +lon_0=-95 +lat+1=49 +lat_2=77 +datum=NAD83 +units=m +no_defs"
|
||||
# Just get a copy from roads34_lyr
|
||||
roads2_lyr.datasource = roads34_lyr.datasource
|
||||
|
||||
|
@ -238,6 +242,7 @@ m.layers.append(roads2_lyr)
|
|||
# Roads 1 (The big orange ones, the highways)
|
||||
|
||||
roads1_lyr = Layer('Roads')
|
||||
roads1_lyr.srs = "+proj=lcc +ellps=GRS80 +lat_0=49 +lon_0=-95 +lat+1=49 +lat_2=77 +datum=NAD83 +units=m +no_defs"
|
||||
roads1_lyr.datasource = roads34_lyr.datasource
|
||||
|
||||
roads1_style_1 = Style()
|
||||
|
@ -271,6 +276,7 @@ m.layers.append(roads1_lyr)
|
|||
# Populated Places
|
||||
|
||||
popplaces_lyr = Layer('Populated Places')
|
||||
popplaces_lyr.srs = "+proj=lcc +ellps=GRS80 +lat_0=49 +lon_0=-95 +lat+1=49 +lat_2=77 +datum=NAD83 +units=m +no_defs"
|
||||
popplaces_lyr.datasource = Shapefile(file='../data/popplaces',encoding='latin1')
|
||||
|
||||
popplaces_style = Style()
|
||||
|
@ -301,8 +307,9 @@ m.layers.append(popplaces_lyr)
|
|||
# Draw map
|
||||
|
||||
# Set the initial extent of the map.
|
||||
|
||||
m.zoom_to_box(Envelope(1405120.04127408,-247003.813399447,1706357.31328276,-25098.593149577))
|
||||
print m.envelope()
|
||||
m.zoom_all()
|
||||
#m.zoom_to_box(Envelope(1405120.04127408,-247003.813399447,1706357.31328276,-25098.593149577))
|
||||
|
||||
# Render two maps, two PNGs, one JPEG.
|
||||
im = Image(m.width,m.height)
|
||||
|
@ -333,3 +340,5 @@ print "\n\n", len(images), "maps have been rendered in the current directory:"
|
|||
for image in images:
|
||||
print "-", image
|
||||
print "\n\nHave a look!\n\n"
|
||||
|
||||
save_map(m,"map.xml")
|
||||
|
|
|
@ -32,11 +32,28 @@ int main( int argc, char **argv )
|
|||
|
||||
datasource_cache::instance()->register_datasources("/opt/mapnik/lib/mapnik/input");
|
||||
|
||||
freetype_engine::register_font("/opt/mapnik/lib/mapnik/fonts/DejaVuSans.ttf");
|
||||
freetype_engine::register_font("/opt/mapnik/lib/mapnik/fonts/DejaVuSans-Bold.ttf");
|
||||
freetype_engine::register_font("/opt/mapnik/lib/mapnik/fonts/DejaVuSans-BoldOblique.ttf");
|
||||
freetype_engine::register_font("/opt/mapnik/lib/mapnik/fonts/DejaVuSans-ExtraLight.ttf");
|
||||
freetype_engine::register_font("/opt/mapnik/lib/mapnik/fonts/DejaVuSans-Oblique.ttf");
|
||||
freetype_engine::register_font("/opt/mapnik/lib/mapnik/fonts/DejaVuSans.ttf");
|
||||
freetype_engine::register_font("/opt/mapnik/lib/mapnik/fonts/DejaVuSansCondensed-Bold.ttf");
|
||||
freetype_engine::register_font("/opt/mapnik/lib/mapnik/fonts/DejaVuSansCondensed-BoldOblique.ttf");
|
||||
freetype_engine::register_font("/opt/mapnik/lib/mapnik/fonts/DejaVuSansCondensed-Oblique.ttf");
|
||||
freetype_engine::register_font("/opt/mapnik/lib/mapnik/fonts/DejaVuSansCondensed.ttf");
|
||||
freetype_engine::register_font("/opt/mapnik/lib/mapnik/fonts/DejaVuSansMono-Bold.ttf");
|
||||
freetype_engine::register_font("/opt/mapnik/lib/mapnik/fonts/DejaVuSansMono-BoldOblique.ttf");
|
||||
freetype_engine::register_font("/opt/mapnik/lib/mapnik/fonts/DejaVuSansMono-Oblique.ttf");
|
||||
freetype_engine::register_font("/opt/mapnik/lib/mapnik/fonts/DejaVuSansMono.ttf");
|
||||
|
||||
|
||||
freetype_engine::register_font("/opt/mapnik/lib/mapnik/fonts/DejaVuSerif-Bold.ttf");
|
||||
freetype_engine::register_font("/opt/mapnik/lib/mapnik/fonts/DejaVuSerif-BoldOblique.ttf");
|
||||
freetype_engine::register_font("/opt/mapnik/lib/mapnik/fonts/DejaVuSerif-Oblique.ttf");
|
||||
freetype_engine::register_font("/opt/mapnik/lib/mapnik/fonts/DejaVuSerif.ttf");
|
||||
freetype_engine::register_font("/opt/mapnik/lib/mapnik/fonts/DejaVuSerifCondensed-Bold.ttf");
|
||||
freetype_engine::register_font("/opt/mapnik/lib/mapnik/fonts/DejaVuSerifCondensed-BoldOblique.ttf");
|
||||
freetype_engine::register_font("/opt/mapnik/lib/mapnik/fonts/DejaVuSerifCondensed-Oblique.ttf");
|
||||
freetype_engine::register_font("/opt/mapnik/lib/mapnik/fonts/DejaVuSerifCondensed.ttf");
|
||||
|
||||
QApplication app( argc, argv );
|
||||
MainWindow window;
|
||||
window.show();
|
||||
|
|
|
@ -5,12 +5,12 @@ CC = g++
|
|||
TEMPLATE = app
|
||||
|
||||
INCLUDEPATH += /opt/mapnik/include
|
||||
INCLUDEPATH += /opt/boost/include/boost-1_34_1
|
||||
INCLUDEPATH += /usr/local/include/freetype2
|
||||
INCLUDEPATH += /usr/local/include/boost-1_35
|
||||
INCLUDEPATH += /usr/X11/include/
|
||||
INCLUDEPATH += .
|
||||
|
||||
QMAKE_CXXFLAGS +=' -DDARWIN'
|
||||
unix:LIBS = -L/opt/mapnik/lib -lmapnik -lfreetype
|
||||
unix:LIBS = -L/opt/mapnik/lib -L/usr/X11/lib -lmapnik -lfreetype
|
||||
|
||||
# Input
|
||||
|
||||
|
|
|
@ -274,6 +274,15 @@ namespace mapnik
|
|||
height = char_dim.second > height ? char_dim.second : height;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Non-Arabic RTL
|
||||
for (int j=0;j<arabic.length();++j)
|
||||
{
|
||||
dimension_t char_dim = character_dimensions(arabic[j]);
|
||||
info.add_info(arabic[j], char_dim.first, char_dim.second);
|
||||
width += char_dim.first;
|
||||
height = char_dim.second > height ? char_dim.second : height;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue