On Sat, 5 Jul 2008 17:56:18 +0000 (UTC)
Sven Geggus <[EMAIL PROTECTED]> wrote:

> Hallo zusammen,
> 
> so, jetzt kann ich endlich teilweise das anbieten, was ich eigentlich
> schon länger haben wollte aber bisher mangels xslt Kenntnisse nicht
> realisieren konnte.
> 
> Prinzipiell bin ich zwar auch kein Perl Hacker sondern meine
> Scriptsprachen sind eher Python und Tcl, aber trotzdem liegt
> mir die prozedurale Welt wohl doch besser als xslt.
> 
> 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.

Wir muessen zwei Breitenangaben beruecksichtigen 'width' und
'est_width' und ich empfehle die Verwendung von
'est_width' bei geschaetzter Breite.

Ich hab dein Patch etwas modifiziert (Anhang 'orp-river-width.diff').

> Ich möchte das ganze jedoch erst ins svn einchecken wenn es jemand
> ausprobiert und für funktioniell befunden hat.
> 

Fuer's Erste sollte es tun (ich werde mal noch 'ne Landschaft rendern
in der ich mehr Breitenangaben habe).

Grusz
    Christian
Index: orp-drawing.pm
===================================================================
--- orp-drawing.pm	(revision 8751)
+++ orp-drawing.pm	(working copy)
@@ -78,15 +78,54 @@
 {
     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
+    # with=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
+
+    my($way_width) = grep { defined } 
+                     map $way->{'tags'}->{$_} => qw( width est_width );
+
+    if( defined($way_width) and $way_width =~ /^ \d+\.?\d* m?  $/x)
+    {  # width an integer number w/ optional unit (meters)
+
+        $way_width =~ s/m$//;
+
+        # get all classes where width should be honored
+        my @honorWidth = split ' ' => get_variable("honorWidth","waterway-river-core waterway-river-casing");
+        
+        # check if the list of honored classes contains the current class
+        my %currentClass = map { $_ => 1 } split(/ /,$class);
+
+        if(grep $currentClass{$_} => @honorWidth)
+        {
+            my $meter2PixelFactor = get_variable("meter2px","0.1375");
+
+            $way_width *= $meter2PixelFactor;
+
+            my $minLineWidth = get_variable("minLineWidth", "1");
+            my $maxLineWidth = get_variable("maxLineWidth", "100");
+
+            $way_width = $minLineWidth if $way_width < $minLineWidth;
+            $way_width = $maxLineWidth if $way_width > $maxLineWidth;
+
+            $style = "stroke-width:${way_width}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;

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Talk-de mailing list
Talk-de@openstreetmap.org
http://lists.openstreetmap.org/cgi-bin/mailman/listinfo/talk-de

Antwort per Email an