diff --git a/demo/data/test/charplacement.dbf b/demo/data/test/charplacement.dbf new file mode 100644 index 000000000..c143baa95 Binary files /dev/null and b/demo/data/test/charplacement.dbf differ diff --git a/demo/data/test/charplacement.shp b/demo/data/test/charplacement.shp new file mode 100644 index 000000000..ccdfcf4bc Binary files /dev/null and b/demo/data/test/charplacement.shp differ diff --git a/demo/data/test/charplacement.shx b/demo/data/test/charplacement.shx new file mode 100644 index 000000000..65b8dab8f Binary files /dev/null and b/demo/data/test/charplacement.shx differ 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"