From d29c825299c33cfa0019dcad83788cbcb3098503 Mon Sep 17 00:00:00 2001 From: Dave Date: Mon, 21 Jan 2008 03:47:52 +0000 Subject: [PATCH] Add a test for Character placement within a string. Currently the characters on bends end up on ugly angles. --- demo/data/test/charplacement.dbf | Bin 0 -> 487 bytes demo/data/test/charplacement.shp | Bin 0 -> 2108 bytes demo/data/test/charplacement.shx | Bin 0 -> 204 bytes demo/data/test/raw/charplacement.gfs | 25 +++++++ demo/data/test/raw/charplacement.gml | 99 +++++++++++++++++++++++++++ demo/data/test/raw/charplacement.xsd | 36 ++++++++++ demo/data/test/regenerate.sh | 5 ++ demo/test/charplacement.py | 82 ++++++++++++++++++++++ 8 files changed, 247 insertions(+) create mode 100644 demo/data/test/charplacement.dbf create mode 100644 demo/data/test/charplacement.shp create mode 100644 demo/data/test/charplacement.shx create mode 100644 demo/data/test/raw/charplacement.gfs create mode 100644 demo/data/test/raw/charplacement.gml create mode 100644 demo/data/test/raw/charplacement.xsd create mode 100644 demo/test/charplacement.py diff --git a/demo/data/test/charplacement.dbf b/demo/data/test/charplacement.dbf new file mode 100644 index 0000000000000000000000000000000000000000..c143baa9559bba0dbcd5f9485cfc026aa59ac497 GIT binary patch literal 487 zcmZRMXP4q-U|>jOkOPvKz|Yaw6)NfsqD9e^IQuvT2Sdcb@*HULyb3}2i75(xiMgo? zNFXH0)6vh}$CVt};E*6kPj`x>m6;xun2xX|%F{i{(Op3S0P=`m1^@s6 literal 0 HcmV?d00001 diff --git a/demo/data/test/charplacement.shp b/demo/data/test/charplacement.shp new file mode 100644 index 0000000000000000000000000000000000000000..ccdfcf4bc66b98c261a7cda3c5446eb31ca60ec1 GIT binary patch literal 2108 zcmaJ?ZERCz6uui}8)M9_)KO~f*7n}r-c3|sZvId?Fk--ovA^%e z`UjYgy?lFhO(V|Hv2j)9az*GxbEISA>||sC&T-}5749uNe601v@}q8?`ligAwMqdCVOJ72<{E1dP|9-O0~)v@AOj+ZsH6%6(_ z8}R;|<1OD*cv$!4k*@P+4bX}%%{^M{p1=)fn2OgSb03169~K_G`rFEPOXSQttg8)$ zIu(UKUk=2XCidY^#>74X@Kx{CQ+h;UVjn8h#>Z}5)3ce_hXymw>|L{|-p0f}%AkGU zx3NThE))CE6%@_(zQd03h)xoN8`YP zCyV{y7})S&Y*=Ge+Zwu04;v7>VDmOULwy4}bK$y|1cK zWudU6$2Ss4=3WZEc>5!#2H(wh*TvpZ*@a0f2Yt; zecus{HBVmm_5LZrB$pFSeWBf617^+}stoP4xOF|>uB`o@fA^>19BZxj3cah53pWQ~ z9L>+?FuxR*5!NrUWAgV8dB#oqTl#+1zSFcU5V;h$N#D=Jefk|!*<5Z@lX1bNQ2LZ_ KPm2>*mHh)x!1RFt literal 0 HcmV?d00001 diff --git a/demo/data/test/charplacement.shx b/demo/data/test/charplacement.shx new file mode 100644 index 0000000000000000000000000000000000000000..65b8dab8fc967cc8d686b6f56f21fc38d720ef2b GIT binary patch literal 204 zcmZQzQ0HR64$@vQGcW)V6nwCUFtiRpX$J`XVLyb%OBw-X4S+ZeO3wn)8bEvuh#eRh q7(s3T$}`$Q=^`k-3`*Yu(g_Ry$DFJ0J_c(!e`zDq%#0I01uG> literal 0 HcmV?d00001 diff --git a/demo/data/test/raw/charplacement.gfs b/demo/data/test/raw/charplacement.gfs new file mode 100644 index 000000000..b05ad940b --- /dev/null +++ b/demo/data/test/raw/charplacement.gfs @@ -0,0 +1,25 @@ + + + charplacement + charplacement + + 1 + 1.00000 + 2.00000 + 1.00000 + 5.00000 + + + NAME + NAME + String + 0 + + + CLASS + CLASS + String + 0 + + + diff --git a/demo/data/test/raw/charplacement.gml b/demo/data/test/raw/charplacement.gml new file mode 100644 index 000000000..8de776840 --- /dev/null +++ b/demo/data/test/raw/charplacement.gml @@ -0,0 +1,99 @@ + + + + + 00 + 13-13 + + + + + + 2,-1 1,-3 2,-5 + Road Name + TRIANGLE + + + 3,-1 4,-3 3,-5 + Road Name + TRIANGLE + + + + + 1,-12 13,-12 + + Road Name + STRAIGHT + + + + 1,-13 2,-13 5,-13 10,-13 13,-13 + + Road Name + STRAIGHT + + + + 6,-1 5,-3 5,-5 + Road Name + BEND + + + 7,-1 8,-3 8,-5 + Road Name + BEND + + + 5,-6 5,-8 6,-10 + Road Name + BEND + + + 8,-6 8,-8 7,-10 + Road Name + BEND + + + + 10.055915,-1.00031738281 10.6649858,-1.077712483 11.274056,-1.26950068 11.77921,-1.55298308 12.191993,-1.92815928 12.51529,-2.369132 12.746218,-2.8329032 12.884774,-3.2968745 12.930959,-3.875339 + Road Name + CURVE + + + 10.0555,-8.875339 10.6645708,-8.7979439 11.273641,-8.6061557 11.778795,-8.3226733 12.191578,-7.9474971 12.514875,-7.5065244 12.745803,-7.0427532 12.884359,-6.5787819 12.930544,-6.0003174 + Road Name + CURVE + + + + +9.055915,-2.00031738281 9.6649858,-2.077712483 10.274056,-2.26950068 10.77921,-2.55298308 11.191993,-2.92815928 11.51529,-3.369132 11.746218,-3.8329032 11.884774,-4.2968745 11.930959,-4.875339 +11.930544,-5.0003174 11.884359,-5.5787819 11.745803,-6.0427532 11.514875,-6.5065244 11.191578,-6.9474971 10.778795,-7.3226733 10.273641,-7.6061557 9.6645708,-7.7979439 9.0555,-7.875339 + + Road Name + CURVE + + + + +9.0435048,-10.5550195 9.480786,-10.2191668 9.963148,-10.0731439 10.540222,-10.2495527 10.968444,-10.525815 11.419238,-10.8336443 12.01882,-10.9565825 12.559787,-10.7996079 12.956495,-10.4089966 + + Road Name + SQUIGGLE + + + + + 1,-9 1.4,-10 1.8,-9 2.2,-10 2.6,-9 3.0,-10 3.4,-9 3.8,-10 4.2,-9 4.6,-10 + + Long ZigZag Road Name + ZIGZAG + + + + diff --git a/demo/data/test/raw/charplacement.xsd b/demo/data/test/raw/charplacement.xsd new file mode 100644 index 000000000..345905d06 --- /dev/null +++ b/demo/data/test/raw/charplacement.xsd @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/demo/data/test/regenerate.sh b/demo/data/test/regenerate.sh index 57e5de0ca..de1b5babe 100755 --- a/demo/data/test/regenerate.sh +++ b/demo/data/test/regenerate.sh @@ -13,3 +13,8 @@ rm -f displacement.shp displacement.shx displacement.dbf ogr2ogr -f "ESRI Shapefile" displacement raw/displacement.gml mv displacement/* ./ rmdir displacement + +rm -f charplacement.shp charplacement.shx charplacement.dbf +ogr2ogr -f "ESRI Shapefile" charplacement raw/charplacement.gml +mv charplacement/* ./ +rmdir charplacement diff --git a/demo/test/charplacement.py b/demo/test/charplacement.py new file mode 100644 index 000000000..3a137658d --- /dev/null +++ b/demo/test/charplacement.py @@ -0,0 +1,82 @@ +# $Id: rundemo.py 577 2008-01-03 11:39:10Z artem $ +# +# This file is part of Mapnik (c++ mapping toolkit) +# Copyright (C) 2005 Jean-Francois Doyon +# +# Mapnik is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Import everything. In this case this is safe, in more complex systems, you +# will want to be more selective. + +try: + from mapnik import * +except: + print '\n\nThe mapnik library and python bindings must have been compiled and \ +installed successfully before running this script.\n\n' + raise + +m = Map(690,690,"+proj=latlong +ellps=WGS84") + +m.background = Color(255,100,100,255) + +road_style = Style() + +#Road +road_rule = Rule() +road_stroke = Stroke(Color('white'), 1) +road_stroke.opacity = 0.7 +#road_rule.filter = Filter("[CLASS] = 'BENDUNDER' or [CLASS] = 'BENDOVER'") +road_rule.symbols.append(LineSymbolizer(road_stroke)) +road_style.rules.append(road_rule); + +#Road text +text_symbolizer = TextSymbolizer('NAME', 'DejaVu Sans Book', 20, Color('black')) +text_symbolizer.label_placement=label_placement.LINE_PLACEMENT +text_symbolizer.minimum_distance = 0 +#text_symbolizer.max_char_angle_delta = 40 +#text_symbolizer.force_odd_labels = 1 +text_symbolizer.label_spacing = 20 +text_symbolizer.label_position_tolerance = 50 +text_symbolizer.minimum_distance = 5 +text_symbolizer.avoid_edges = 0 +text_symbolizer.halo_fill = Color('yellow') +text_symbolizer.halo_radius = 1 +road_rule = Rule() +#road_rule.filter = Filter("[CLASS] = 'BENDUNDER' or [CLASS] = 'BENDOVER'") +road_rule.symbols.append(text_symbolizer) +road_style.rules.append(road_rule) + + +road_layer = Layer('road') +road_layer.datasource = Shapefile(file='../data/test/charplacement') + +m.append_style('road', road_style) +road_layer.styles.append('road') +m.layers.append(road_layer) + +# Draw map + +# Set the initial extent of the map. +m.zoom_to_box(Envelope(0,0,14,-14)) + + +# Render +im = Image(m.width,m.height) +render(m, im) + +# Save image to file +save_to_file('output.png', 'png',im) # true-colour RGBA + +print "Done\n"