Add newly made data and test for testing label overlap handling. Rename old test to textspacing.
This commit is contained in:
parent
e96e7b18fa
commit
a092425940
15 changed files with 285 additions and 44 deletions
BIN
demo/data/test/overlap.dbf
Normal file
BIN
demo/data/test/overlap.dbf
Normal file
Binary file not shown.
BIN
demo/data/test/overlap.shp
Normal file
BIN
demo/data/test/overlap.shp
Normal file
Binary file not shown.
BIN
demo/data/test/overlap.shx
Normal file
BIN
demo/data/test/overlap.shx
Normal file
Binary file not shown.
|
@ -1,7 +1,7 @@
|
|||
<GMLFeatureClassList>
|
||||
<GMLFeatureClass>
|
||||
<Name>roadsmall</Name>
|
||||
<ElementPath>roadsmall</ElementPath>
|
||||
<Name>overlap</Name>
|
||||
<ElementPath>overlap</ElementPath>
|
||||
<DatasetSpecificInfo>
|
||||
<FeatureCount>1</FeatureCount>
|
||||
<ExtentXMin>1.00000</ExtentXMin>
|
93
demo/data/test/raw/overlap.gml
Normal file
93
demo/data/test/raw/overlap.gml
Normal file
|
@ -0,0 +1,93 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<ogr:FeatureCollection
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="overlap.xsd"
|
||||
xmlns:ogr="http://ogr.maptools.org/"
|
||||
xmlns:gml="http://www.opengis.net/gml">
|
||||
<gml:boundedBy>
|
||||
<gml:Box>
|
||||
<gml:coord><gml:X>0</gml:X><gml:Y>0</gml:Y></gml:coord>
|
||||
<gml:coord><gml:X>13</gml:X><gml:Y>-13</gml:Y></gml:coord>
|
||||
</gml:Box>
|
||||
</gml:boundedBy>
|
||||
<gml:featureMember>
|
||||
|
||||
<ogr:overlap fid="F0">
|
||||
<ogr:geometryProperty><gml:LineString><gml:coordinates>1,-1 1,-10</gml:coordinates></gml:LineString></ogr:geometryProperty>
|
||||
<ogr:NAME>Road Name</ogr:NAME>
|
||||
<ogr:CLASS>NETWORK</ogr:CLASS>
|
||||
</ogr:overlap>
|
||||
<ogr:overlap fid="F0">
|
||||
<ogr:geometryProperty><gml:LineString><gml:coordinates>1,-3 7,-3</gml:coordinates></gml:LineString></ogr:geometryProperty>
|
||||
<ogr:NAME>Road Name</ogr:NAME>
|
||||
<ogr:CLASS>NETWORK</ogr:CLASS>
|
||||
</ogr:overlap>
|
||||
<ogr:overlap fid="F0">
|
||||
<ogr:geometryProperty><gml:LineString><gml:coordinates>7,-3 7,-7</gml:coordinates></gml:LineString></ogr:geometryProperty>
|
||||
<ogr:NAME>Road Name</ogr:NAME>
|
||||
<ogr:CLASS>NETWORK</ogr:CLASS>
|
||||
</ogr:overlap>
|
||||
<ogr:overlap fid="F0">
|
||||
<ogr:geometryProperty><gml:LineString><gml:coordinates>3,-2 3,-8</gml:coordinates></gml:LineString></ogr:geometryProperty>
|
||||
<ogr:NAME>Road Name</ogr:NAME>
|
||||
<ogr:CLASS>NETWORK</ogr:CLASS>
|
||||
</ogr:overlap>
|
||||
<ogr:overlap fid="F0">
|
||||
<ogr:geometryProperty><gml:LineString><gml:coordinates>7,-7 1,-7</gml:coordinates></gml:LineString></ogr:geometryProperty>
|
||||
<ogr:NAME>Road Name</ogr:NAME>
|
||||
<ogr:CLASS>NETWORK</ogr:CLASS>
|
||||
</ogr:overlap>
|
||||
<ogr:overlap fid="F0">
|
||||
<ogr:geometryProperty><gml:LineString><gml:coordinates>5,-2 5,-8</gml:coordinates></gml:LineString></ogr:geometryProperty>
|
||||
<ogr:NAME>Road Name</ogr:NAME>
|
||||
<ogr:CLASS>NETWORK</ogr:CLASS>
|
||||
</ogr:overlap>
|
||||
|
||||
<ogr:overlap fid="F0">
|
||||
<ogr:geometryProperty><gml:LineString><gml:coordinates>8,-3 12,-3</gml:coordinates></gml:LineString></ogr:geometryProperty>
|
||||
<ogr:NAME>Road Name</ogr:NAME>
|
||||
<ogr:CLASS>CROSS</ogr:CLASS>
|
||||
</ogr:overlap>
|
||||
<ogr:overlap fid="F0">
|
||||
<ogr:geometryProperty><gml:LineString><gml:coordinates>10,-1 10,-5</gml:coordinates></gml:LineString></ogr:geometryProperty>
|
||||
<ogr:NAME>Road Name</ogr:NAME>
|
||||
<ogr:CLASS>CROSS</ogr:CLASS>
|
||||
</ogr:overlap>
|
||||
|
||||
<ogr:overlap fid="F0">
|
||||
<ogr:geometryProperty><gml:LineString><gml:coordinates>
|
||||
10,-9 13,-9 13,-11 11,-11 11,-8
|
||||
</gml:coordinates></gml:LineString></ogr:geometryProperty>
|
||||
<ogr:NAME>Road Name</ogr:NAME>
|
||||
<ogr:CLASS>SELFOVERLAP</ogr:CLASS>
|
||||
</ogr:overlap>
|
||||
|
||||
<ogr:overlap fid="F0">
|
||||
<ogr:geometryProperty><gml:LineString><gml:coordinates>4,-9 4,-13</gml:coordinates></gml:LineString></ogr:geometryProperty>
|
||||
<ogr:NAME>Road Name</ogr:NAME>
|
||||
<ogr:CLASS>NETWORK2</ogr:CLASS>
|
||||
</ogr:overlap>
|
||||
<ogr:overlap fid="F0">
|
||||
<ogr:geometryProperty><gml:LineString><gml:coordinates>8,-9 8,-13</gml:coordinates></gml:LineString></ogr:geometryProperty>
|
||||
<ogr:NAME>Road Name</ogr:NAME>
|
||||
<ogr:CLASS>NETWORK2</ogr:CLASS>
|
||||
</ogr:overlap>
|
||||
<ogr:overlap fid="F0">
|
||||
<ogr:geometryProperty><gml:LineString><gml:coordinates>1,-11 9,-11</gml:coordinates></gml:LineString></ogr:geometryProperty>
|
||||
<ogr:NAME>Road Name</ogr:NAME>
|
||||
<ogr:CLASS>NETWORK2</ogr:CLASS>
|
||||
</ogr:overlap>
|
||||
<ogr:overlap fid="F0">
|
||||
<ogr:geometryProperty><gml:LineString><gml:coordinates>2,-9 2,-13</gml:coordinates></gml:LineString></ogr:geometryProperty>
|
||||
<ogr:NAME>Road Name</ogr:NAME>
|
||||
<ogr:CLASS>NETWORK2</ogr:CLASS>
|
||||
</ogr:overlap>
|
||||
<ogr:overlap fid="F0">
|
||||
<ogr:geometryProperty><gml:LineString><gml:coordinates>6,-9 6,-13</gml:coordinates></gml:LineString></ogr:geometryProperty>
|
||||
<ogr:NAME>Road Name</ogr:NAME>
|
||||
<ogr:CLASS>NETWORK2</ogr:CLASS>
|
||||
</ogr:overlap>
|
||||
|
||||
|
||||
</gml:featureMember>
|
||||
</ogr:FeatureCollection>
|
|
@ -9,8 +9,8 @@
|
|||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:element name="road" type="ogr:road_Type" substitutionGroup="gml:_Feature"/>
|
||||
<xs:complexType name="road_Type">
|
||||
<xs:element name="overlap" type="ogr:overlap_Type" substitutionGroup="gml:_Feature"/>
|
||||
<xs:complexType name="overlap_Type">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="gml:AbstractFeatureType">
|
||||
<xs:sequence>
|
25
demo/data/test/raw/textspacing.gfs
Normal file
25
demo/data/test/raw/textspacing.gfs
Normal file
|
@ -0,0 +1,25 @@
|
|||
<GMLFeatureClassList>
|
||||
<GMLFeatureClass>
|
||||
<Name>textspacing</Name>
|
||||
<ElementPath>textspacing</ElementPath>
|
||||
<DatasetSpecificInfo>
|
||||
<FeatureCount>1</FeatureCount>
|
||||
<ExtentXMin>1.00000</ExtentXMin>
|
||||
<ExtentXMax>2.00000</ExtentXMax>
|
||||
<ExtentYMin>1.00000</ExtentYMin>
|
||||
<ExtentYMax>5.00000</ExtentYMax>
|
||||
</DatasetSpecificInfo>
|
||||
<PropertyDefn>
|
||||
<Name>NAME</Name>
|
||||
<ElementPath>NAME</ElementPath>
|
||||
<Type>String</Type>
|
||||
<Width>0</Width>
|
||||
</PropertyDefn>
|
||||
<PropertyDefn>
|
||||
<Name>CLASS</Name>
|
||||
<ElementPath>CLASS</ElementPath>
|
||||
<Type>String</Type>
|
||||
<Width>0</Width>
|
||||
</PropertyDefn>
|
||||
</GMLFeatureClass>
|
||||
</GMLFeatureClassList>
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<ogr:FeatureCollection
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="road.xsd"
|
||||
xsi:schemaLocation="textspacing.xsd"
|
||||
xmlns:ogr="http://ogr.maptools.org/"
|
||||
xmlns:gml="http://www.opengis.net/gml">
|
||||
<gml:boundedBy>
|
||||
|
@ -12,106 +12,106 @@
|
|||
</gml:boundedBy>
|
||||
<gml:featureMember>
|
||||
|
||||
<ogr:road fid="F0">
|
||||
<ogr:textspacing fid="F0">
|
||||
<ogr:geometryProperty><gml:LineString><gml:coordinates>2,-1 1,-3 2,-5</gml:coordinates></gml:LineString></ogr:geometryProperty>
|
||||
<ogr:NAME>Road Name</ogr:NAME>
|
||||
<ogr:CLASS>TRIANGLE</ogr:CLASS>
|
||||
</ogr:road>
|
||||
<ogr:road fid="F1">
|
||||
</ogr:textspacing>
|
||||
<ogr:textspacing fid="F1">
|
||||
<ogr:geometryProperty><gml:LineString><gml:coordinates>3,-1 4,-3 3,-5</gml:coordinates></gml:LineString></ogr:geometryProperty>
|
||||
<ogr:NAME>Road Name</ogr:NAME>
|
||||
<ogr:CLASS>TRIANGLE</ogr:CLASS>
|
||||
</ogr:road>
|
||||
</ogr:textspacing>
|
||||
|
||||
<ogr:road fid="F2">
|
||||
<ogr:textspacing fid="F2">
|
||||
<ogr:geometryProperty><gml:LineString><gml:coordinates>1,-7 2,-7</gml:coordinates></gml:LineString></ogr:geometryProperty>
|
||||
<ogr:NAME>Road Name</ogr:NAME>
|
||||
<ogr:CLASS>STRAIGHT</ogr:CLASS>
|
||||
</ogr:road>
|
||||
<ogr:road fid="F3">
|
||||
</ogr:textspacing>
|
||||
<ogr:textspacing fid="F3">
|
||||
<ogr:geometryProperty><gml:LineString><gml:coordinates>1,-8 3,-8</gml:coordinates></gml:LineString></ogr:geometryProperty>
|
||||
<ogr:NAME>Road Name</ogr:NAME>
|
||||
<ogr:CLASS>STRAIGHT</ogr:CLASS>
|
||||
</ogr:road>
|
||||
<ogr:road fid="F4">
|
||||
</ogr:textspacing>
|
||||
<ogr:textspacing fid="F4">
|
||||
<ogr:geometryProperty><gml:LineString><gml:coordinates>1,-9 4,-9</gml:coordinates></gml:LineString></ogr:geometryProperty>
|
||||
<ogr:NAME>Road Name</ogr:NAME>
|
||||
<ogr:CLASS>STRAIGHT</ogr:CLASS>
|
||||
</ogr:road>
|
||||
<ogr:road fid="F5">
|
||||
</ogr:textspacing>
|
||||
<ogr:textspacing fid="F5">
|
||||
<ogr:geometryProperty><gml:LineString><gml:coordinates>1,-10 5,-10</gml:coordinates></gml:LineString></ogr:geometryProperty>
|
||||
<ogr:NAME>Road Name</ogr:NAME>
|
||||
<ogr:CLASS>STRAIGHT</ogr:CLASS>
|
||||
</ogr:road>
|
||||
</ogr:textspacing>
|
||||
|
||||
<ogr:road fid="F6">
|
||||
<ogr:textspacing fid="F6">
|
||||
<ogr:geometryProperty><gml:LineString><gml:coordinates>1,-11 7,-11</gml:coordinates></gml:LineString></ogr:geometryProperty>
|
||||
<ogr:NAME>Road Name</ogr:NAME>
|
||||
<ogr:CLASS>STRAIGHT</ogr:CLASS>
|
||||
</ogr:road>
|
||||
<ogr:road fid="F7">
|
||||
</ogr:textspacing>
|
||||
<ogr:textspacing fid="F7">
|
||||
<ogr:geometryProperty><gml:LineString><gml:coordinates>
|
||||
1,-12 13,-12
|
||||
</gml:coordinates></gml:LineString></ogr:geometryProperty>
|
||||
<ogr:NAME>Road Name</ogr:NAME>
|
||||
<ogr:CLASS>STRAIGHT</ogr:CLASS>
|
||||
</ogr:road>
|
||||
<ogr:road fid="F8">
|
||||
</ogr:textspacing>
|
||||
<ogr:textspacing fid="F8">
|
||||
<ogr:geometryProperty><gml:LineString><gml:coordinates>
|
||||
1,-13 2,-13 5,-13 10,-13 13,-13
|
||||
</gml:coordinates></gml:LineString></ogr:geometryProperty>
|
||||
<ogr:NAME>Road Name</ogr:NAME>
|
||||
<ogr:CLASS>STRAIGHT</ogr:CLASS>
|
||||
</ogr:road>
|
||||
</ogr:textspacing>
|
||||
|
||||
<ogr:road fid="F9">
|
||||
<ogr:textspacing fid="F9">
|
||||
<ogr:geometryProperty><gml:LineString><gml:coordinates>6,-1 5,-3 5,-5</gml:coordinates></gml:LineString></ogr:geometryProperty>
|
||||
<ogr:NAME>Road Name</ogr:NAME>
|
||||
<ogr:CLASS>BEND</ogr:CLASS>
|
||||
</ogr:road>
|
||||
<ogr:road fid="F10">
|
||||
</ogr:textspacing>
|
||||
<ogr:textspacing fid="F10">
|
||||
<ogr:geometryProperty><gml:LineString><gml:coordinates>7,-1 8,-3 8,-5</gml:coordinates></gml:LineString></ogr:geometryProperty>
|
||||
<ogr:NAME>Road Name</ogr:NAME>
|
||||
<ogr:CLASS>BEND</ogr:CLASS>
|
||||
</ogr:road>
|
||||
<ogr:road fid="F11">
|
||||
</ogr:textspacing>
|
||||
<ogr:textspacing fid="F11">
|
||||
<ogr:geometryProperty><gml:LineString><gml:coordinates>5,-6 5,-8 6,-10</gml:coordinates></gml:LineString></ogr:geometryProperty>
|
||||
<ogr:NAME>Road Name</ogr:NAME>
|
||||
<ogr:CLASS>BEND</ogr:CLASS>
|
||||
</ogr:road>
|
||||
<ogr:road fid="F12">
|
||||
</ogr:textspacing>
|
||||
<ogr:textspacing fid="F12">
|
||||
<ogr:geometryProperty><gml:LineString><gml:coordinates>8,-6 8,-8 7,-10</gml:coordinates></gml:LineString></ogr:geometryProperty>
|
||||
<ogr:NAME>Road Name</ogr:NAME>
|
||||
<ogr:CLASS>BEND</ogr:CLASS>
|
||||
</ogr:road>
|
||||
</ogr:textspacing>
|
||||
|
||||
<ogr:road fid="F13">
|
||||
<ogr:textspacing fid="F13">
|
||||
<ogr:geometryProperty><gml:LineString><gml:coordinates>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</gml:coordinates></gml:LineString></ogr:geometryProperty>
|
||||
<ogr:NAME>Road Name</ogr:NAME>
|
||||
<ogr:CLASS>CURVE</ogr:CLASS>
|
||||
</ogr:road>
|
||||
<ogr:road fid="F14">
|
||||
</ogr:textspacing>
|
||||
<ogr:textspacing fid="F14">
|
||||
<ogr:geometryProperty><gml:LineString><gml:coordinates>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</gml:coordinates></gml:LineString></ogr:geometryProperty>
|
||||
<ogr:NAME>Road Name</ogr:NAME>
|
||||
<ogr:CLASS>CURVE</ogr:CLASS>
|
||||
</ogr:road>
|
||||
</ogr:textspacing>
|
||||
|
||||
<ogr:road fid="F15">
|
||||
<ogr:textspacing fid="F15">
|
||||
<ogr:geometryProperty><gml:LineString><gml:coordinates>
|
||||
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
|
||||
</gml:coordinates></gml:LineString></ogr:geometryProperty>
|
||||
<ogr:NAME>Road Name</ogr:NAME>
|
||||
<ogr:CLASS>CURVE</ogr:CLASS>
|
||||
</ogr:road>
|
||||
</ogr:textspacing>
|
||||
|
||||
<ogr:road fid="F16">
|
||||
<ogr:textspacing fid="F16">
|
||||
<ogr:geometryProperty><gml:LineString><gml:coordinates>
|
||||
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
|
||||
</gml:coordinates></gml:LineString></ogr:geometryProperty>
|
||||
<ogr:NAME>Road Name</ogr:NAME>
|
||||
<ogr:CLASS>SQUIGGLE</ogr:CLASS>
|
||||
</ogr:road>
|
||||
</ogr:textspacing>
|
||||
|
||||
</gml:featureMember>
|
||||
</ogr:FeatureCollection>
|
36
demo/data/test/raw/textspacing.xsd
Normal file
36
demo/data/test/raw/textspacing.xsd
Normal file
|
@ -0,0 +1,36 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<xs:schema targetNamespace="http://ogr.maptools.org/" xmlns:ogr="http://ogr.maptools.org/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:gml="http://www.opengis.net/gml" elementFormDefault="qualified" version="1.0">
|
||||
<xs:import namespace="http://www.opengis.net/gml" schemaLocation="http://schemas.opengeospatial.net/gml/2.1.2/feature.xsd"/><xs:element name="FeatureCollection" type="ogr:FeatureCollectionType" substitutionGroup="gml:_FeatureCollection"/>
|
||||
<xs:complexType name="FeatureCollectionType">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="gml:AbstractFeatureCollectionType">
|
||||
<xs:attribute name="lockId" type="xs:string" use="optional"/>
|
||||
<xs:attribute name="scope" type="xs:string" use="optional"/>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:element name="textspacing" type="ogr:textspacing_Type" substitutionGroup="gml:_Feature"/>
|
||||
<xs:complexType name="textspacing_Type">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="gml:AbstractFeatureType">
|
||||
<xs:sequence>
|
||||
<xs:element name="geometryProperty" type="gml:GeometryPropertyType" nillable="true" minOccurs="1" maxOccurs="1"/>
|
||||
<xs:element name="NAME" nillable="true" minOccurs="0" maxOccurs="1">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:maxLength value="60"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:element>
|
||||
<xs:element name="CLASS" nillable="true" minOccurs="0" maxOccurs="1">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:maxLength value="60"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
</xs:schema>
|
|
@ -1,5 +1,10 @@
|
|||
#!/bin/sh
|
||||
rm -f road.shp road.shx road.dbf
|
||||
ogr2ogr -f "ESRI Shapefile" road raw/road.gml
|
||||
mv road/* ./
|
||||
rmdir road
|
||||
rm -f textspacing.shp textspacing.shx textspacing.dbf
|
||||
ogr2ogr -f "ESRI Shapefile" textspacing raw/textspacing.gml
|
||||
mv textspacing/* ./
|
||||
rmdir textspacing
|
||||
|
||||
rm -f overlap.shp overlap.shx overlap.dbf
|
||||
ogr2ogr -f "ESRI Shapefile" overlap raw/overlap.gml
|
||||
mv overlap/* ./
|
||||
rmdir overlap
|
||||
|
|
82
demo/test/overlap.py
Normal file
82
demo/test/overlap.py
Normal file
|
@ -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.line_cap = line_cap.ROUND_CAP
|
||||
road_stroke.line_join = line_join.ROUND_JOIN
|
||||
#road_rule.filter = Filter("[CLASS] = 'STRAIGHT'")
|
||||
road_rule.symbols.append(LineSymbolizer(road_stroke))
|
||||
road_style.rules.append(road_rule);
|
||||
|
||||
#Road text
|
||||
text_symbolizer = TextSymbolizer('NAME', 'DejaVu Sans Book', 10, 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 = 60
|
||||
text_symbolizer.label_position_tolerance = 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] = 'STRAIGHT'")
|
||||
road_rule.symbols.append(text_symbolizer)
|
||||
road_style.rules.append(road_rule)
|
||||
|
||||
|
||||
road_layer = Layer('road')
|
||||
road_layer.datasource = Shapefile(file='../data/test/overlap')
|
||||
|
||||
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"
|
|
@ -60,7 +60,7 @@ road_style.rules.append(road_rule)
|
|||
|
||||
|
||||
road_layer = Layer('road')
|
||||
road_layer.datasource = Shapefile(file='../data/test/road')
|
||||
road_layer.datasource = Shapefile(file='../data/test/textspacing')
|
||||
|
||||
m.append_style('road', road_style)
|
||||
road_layer.styles.append('road')
|
Loading…
Add table
Reference in a new issue