Ticket #2690: MultipolygonClosing.diff

File MultipolygonClosing.diff, 3.4 KB (added by Irrfahrt, 9 years ago)

patch to fetch all the required data to close open multipolygons

  • layers.conf

     
    3030# lowzoom and default/maplint Layers depending on job from t@h server
    3131LayersCapability = captionless,tile,caption
    3232
     33# MultiPolygonClosingPredicates defines a list of xapi style predicates to
     34# close areas defined by advanced multipolygons which may have stayed open
     35# after fetching the tile's bboxed data.
     36MultiPolygonClosingPredicates = relation[landuse|natural=*],relation[area=yes],relation[waterway=riverbank]
    3337
    3438
    3539# Details for "default" layer
  • lib/Tileset.pm

     
    812812
    813813    my @OSMServers = (@predicates) ? split(/,/, $Config->get("XAPIServers")) : split(/,/, $Config->get("APIServers"));
    814814
     815    my @multipolygon_closing_predicates = ();
     816    if ($req->Z >= 12) {
     817        my $mpc_predicates = $Config->get("MultiPolygonClosingPredicates");
     818        if ($mpc_predicates) {
     819            $mpc_predicates =~ s/\s+//g;
     820            push(@multipolygon_closing_predicates, split(/,/, $mpc_predicates));
     821        }
     822    }
     823
    815824    my $Server = Server->new();
    816825    my $res;
    817826    my $reason;
     
    833842        my @URLS;
    834843        my @title;
    835844        if (@predicates) {
    836             foreach my $predicate (@predicates) {
    837                 my $URL = $Config->get("XAPI_$OSMServer");
    838                 $URL =~ s/%p/${predicate}/g;                # substitute %p place holder with predicate
    839                 $URL =~ s/%v/$Config->get('OSMVersion')/ge; # substitute %v place holder with API version
    840                 push(@URLS, $URL);
    841                 push(@title, $predicate);
    842             }
     845            $self->substitutePredicates($OSMServer,
     846                    \$Config->get(@predicates),
     847                    \@URLS,
     848                    \@title);
    843849        }
    844850        else {
     851            if (@multipolygon_closing_predicates) {
     852                my @XAPIServers = split(/,/, $Config->get("XAPIServers"));
     853
     854                foreach my $xapiServer (@XAPIServers) {
     855                    $self->substitutePredicates($xapiServer,
     856                           \@multipolygon_closing_predicates,
     857                           \@URLS,
     858                           \@title);
     859                }
     860                undef @multipolygon_closing_predicates;
     861            }
     862
    845863            my $URL = $Config->get("API_$OSMServer");
    846864            $URL =~ s/%v/$Config->get('OSMVersion')/ge; # substitute %v place holder with API version
    847865            push(@URLS, $URL);
     
    944962    return $DataFile;
    945963}
    946964
     965sub substitutePredicates {
     966    #
     967    my $self = shift;
    947968
     969    my ($xapiServer, $predicates, $URLS, $title) = @_;
     970
     971    my $Config = $self->{Config};
     972    my $servers = $Config->get("XAPI_$xapiServer");
     973    my $osm_version = $Config->get('OSMVersion');
     974
     975    foreach my $predicate (@$predicates) {
     976         my $URL = $servers;
     977
     978         $URL =~ s/%p/${predicate}/g; # substitute %p place holder with predicate
     979         $URL =~ s/%v/$osm_version/ge; # substitute %v place holder with API version
     980         push(@$URLS, $URL);
     981         push(@$title, $predicate);
     982    }
     983}
     984
     985
    948986#------------------------------------------------------
    949987# Go through preprocessing steps for the current layer
    950988# expects $self->{JobDir}/data.osm as input and produces