Sven Geggus <[EMAIL PROTECTED]> wrote: > Langer Rede kurzer Sinn! Ich hab trotzdem für orp einen patch gebaut, > der die Breite von Flüssen berücksichtig, wenn ein with=X Tag an den > Weg angehängt ist. X ist die Breite des Flusses in Meter.
OK Leute, nachdem Raphael zurecht darauf hingewiesen hat, dass das Teil stinklangsam geworden ist hab ich nochmal drüber geschaut und das Problem zusammen mit Matthias Merz, der deutlich besser perl kann als ich gelöst! Hier also die Version 0.2 des Flußbreiten-Patch ich denke ihr könnt schon mal eure Laser Entfernungmesser kaufen gehn! http://home.geggus.net/osm/orp-river-width.diff Apropos Laser Entfernungmesser. Kennt jemand die Geräte Bosch DLE 50 und/oder PLR 30? PLR 30 ist Bosch grün DLE 50 ist blau also die Profi Serie. 50m ist schon cool. Billiger als GPS das Zeug :) Gruss Sven --schnipp-- Index: orp-drawing.pm =================================================================== --- orp-drawing.pm (Revision 8793) +++ orp-drawing.pm (Arbeitskopie) @@ -15,6 +15,7 @@ require "orp-bbox-area-center.pm"; our ($writer, $projection, $symbolScale, $textAttenuation, $debug); +our %widthconfig; # ------------------------------------------------------------------- @@ -78,15 +79,53 @@ { my ($linenode, $layer, $way, $class) = @_; + # explicit way specific style + my $style=""; + # convenience variables my $id = $way->{"id"}; my $nodes = $way->{"nodes"}; return unless(scalar(@$nodes)); + # this is a special case for ways (rivers) where we honor a + # width=something tag. + # It is used to generate rivers of different width. + # This is done by an explicit specification of a + # style="stroke-width:..px" tag in the generated SVG output + + if (defined($way->{"tags"}->{"width"})) { + + # check whether width shall be honored for this way + my $cname=""; + foreach my $c (split(/ /,$class)){ + if($widthconfig{'honorWidth'}{$c}) { + $cname=$c; + last; + } + } + if ($cname ne "") { + my $width = $way->{"tags"}->{"width"}; + $width =~ s/m$//; + my $f = $widthconfig{'meter2px'}; + my $w; + # make sure, that width is a numeric value + { no warnings; $w = $f*$width if 0+$width;} + + if (defined($w)) { + # make sure that width is inside the desired range + my $maxw = $f* $widthconfig{'maxLineWidth'}; + my $minw = $f* $widthconfig{'minLineWidth'}; + if ($w > $maxw) {$w = $maxw;} + if ($w < $minw) {$w = $minw;} + $style = "stroke-width:${w}px"; + } + } + } + # first draw middle segment if we have more than 2 nodes draw_path($linenode, "way_mid_$id", - "osmarender-stroke-linecap-butt osmarender-no-marker-start osmarender-no-marker-end") + "osmarender-stroke-linecap-butt osmarender-no-marker-start osmarender-no-marker-end", $style) if (scalar(@$nodes)>2); # count connectors on first and last node @@ -116,32 +155,32 @@ if ($first_node_connection_count == 1) { - draw_path($linenode, "way_start_$id", "osmarender-no-marker-end"); + draw_path($linenode, "way_start_$id", "osmarender-no-marker-end", $style); } elsif ($first_node_lower_layer_connection_count > 0) { draw_path($linenode, "way_start_$id", - "osmarender-stroke-linecap-butt osmarender-no-marker-end"); + "osmarender-stroke-linecap-butt osmarender-no-marker-end", $style); } else { draw_path($linenode, "way_start_$id", - "osmarender-stroke-linecap-round osmarender-no-marker-end"); + "osmarender-stroke-linecap-round osmarender-no-marker-end", $style); } if ($last_node_connection_count == 1) { - draw_path($linenode, "way_end_$id", "osmarender-no-marker-start"); + draw_path($linenode, "way_end_$id", "osmarender-no-marker-start", $style); } elsif ($last_node_lower_layer_connection_count > 0) { draw_path($linenode, "way_end_$id", - "osmarender-stroke-linecap-butt osmarender-no-marker-start"); + "osmarender-stroke-linecap-butt osmarender-no-marker-start", $style); } else { draw_path($linenode, "way_end_$id", - "osmarender-stroke-linecap-round osmarender-no-marker-start"); + "osmarender-stroke-linecap-round osmarender-no-marker-start", $style); } } @@ -719,17 +758,18 @@ } # ------------------------------------------------------------------- -# sub draw_path($rulenode, $path_id, $class) +# sub draw_path($rulenode, $path_id, $class, $style) # # draws an SVG path with the given path reference and style. # ------------------------------------------------------------------- sub draw_path { - my ($rulenode, $path_id, $addclass) = @_; + my ($rulenode, $path_id, $addclass, $style) = @_; my $mask_class = $rulenode->getAttribute("mask-class"); my $class = $rulenode->getAttribute("class"); my $extra_attr = []; + if ($mask_class ne "") { my $mask_id = "mask_".$path_id; @@ -752,11 +792,17 @@ $writer->endTag("mask"); $extra_attr = [ "mask" => "url(#".$mask_id.")" ]; } - - $writer->emptyTag("use", - "xlink:href" => "#$path_id", - @$extra_attr, - "class" => defined($addclass) ? "$class $addclass" : $class); + if (defined($style) and $style ne "") { + $writer->emptyTag("use", + "xlink:href" => "#$path_id", "style" => "$style", + @$extra_attr, + "class" => defined($addclass) ? "$class $addclass" : $class); + } else { + $writer->emptyTag("use", + "xlink:href" => "#$path_id", + @$extra_attr, + "class" => defined($addclass) ? "$class $addclass" : $class); + } } 1; Index: orp.pl =================================================================== --- orp.pl (Revision 8793) +++ orp.pl (Arbeitskopie) @@ -140,6 +140,8 @@ our $relation_storage = {}; our $text_index = {}; +our %widthconfig = (); + my $handler = SAXOsmHandler->new($node_storage, $way_storage, $relation_storage); my $parser = XML::Parser::PerlSAX->new(Handler => $handler); my $rule_file = "rule.xml"; @@ -263,6 +265,14 @@ my $showLicense = get_variable("showLicense", "no"); our $textAttenuation = get_variable("textAttenuation"); +# the following stuff is needed for the width-tag support in rivers +# the default values can be altered by rule file variables +$widthconfig{'maxLineWidth'} = get_variable("maxLineWidth", "100"); +$widthconfig{'minLineWidth'} = get_variable("minLineWidth", "1"); +$widthconfig{'meter2px'} = get_variable("meter2px", "0.1375"); +my @honorWidthList = split(/ /, get_variable("honorWidth","waterway-river-core waterway-river-casing")); +$widthconfig{'honorWidth'} = { map { $_ => 1 } @honorWidthList }; + # extra height for marginalia my $marginaliaTopHeight = ($title ne "") ? 40 : ($showBorder eq "yes") ? 1.5 : 0; --schnapp-- -- /* Fuck me gently with a chainsaw... */ (David S. Miller in /usr/src/linux/arch/sparc/kernel/ptrace.c) /me is [EMAIL PROTECTED], http://sven.gegg.us/ on the Web _______________________________________________ Talk-de mailing list [email protected] http://lists.openstreetmap.org/cgi-bin/mailman/listinfo/talk-de

