Hi,

Recently I ran into an issue with the plplot 5.11.1 on Windows. The plmap code seems to omit lines entirely when a part of the line is not visible. This only occurs when the line is not visible on the left hand side of the plot. When a part is not visible on the right hand side it is properly shown.

At my Debian Stable system I use the system's 5.10.0 version. There the issue doesn't occur. (I noticed the plmap code has been rewritten between 5.10.0 and 5.11.0.) I also tested the bug on Debian Stable with 5.11.1 and a recent master [d71e48], both have the issue.

Attached a modified example 19 where the bug is shown. The first plot shows the entire coast of Ireland. The second plot should only omit a small part of the coast, but instead the entire coast has been removed. Only the internal border of Ireland remains visible. This seems to happen with all coast lines; I picked Ireland since it shows the bug nicely.


Regards,
Mark de Wever

PS: It seems the old deprecated plmap code no longer shows a map (at least on Windows). I didn't investigate further, I just installed the shapelib library.

PPS: There also seems to be another issue with a filled polygon map, but I'm still investigating. If it really is an issue, I'll report it.
//--------------------------------------------------------------------------
// $Id: x19.cc 12532 2013-09-26 15:18:37Z andrewross $
//--------------------------------------------------------------------------
//
//--------------------------------------------------------------------------
// Copyright (C) 2004  Andrew Ross
// Copyright (C) 2004  Alan W. Irwin
//
// This file is part of PLplot.
//
// PLplot is free software; you can redistribute it and/or modify
// it under the terms of the GNU Library General Public License as published by
// the Free Software Foundation; version 2 of the License.
//
// PLplot 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 Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public License
// along with PLplot; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
//--------------------------------------------------------------------------
//
//--------------------------------------------------------------------------
// Implementation of PLplot example 19 in C++.
//--------------------------------------------------------------------------

#include "plc++demos.h"

#ifdef PL_USE_NAMESPACE
using namespace std;
#endif

class x19 {
public:
    x19( int, char ** );

private:
    // Class data
    plstream *pls;
};

void
map_transform( PLFLT x, PLFLT y, PLFLT *xt, PLFLT *yt, PLPointer /* data */ )
{
    PLFLT radius;

    radius = 90.0 - y;
    *xt    = radius * cos( x * M_PI / 180.0 );
    *yt    = radius * sin( x * M_PI / 180.0 );
}

//--------------------------------------------------------------------------
// mapform19
//
// Defines specific coordinate transformation for example 19.
// Not to be confused with mapform in src/plmap.c.
// x[], y[] are the coordinates to be plotted.
//--------------------------------------------------------------------------

void
mapform19( PLINT n, PLFLT *x, PLFLT *y )
{
    int   i;
    PLFLT xp, yp, radius;
    for ( i = 0; i < n; i++ )
    {
        radius = 90.0 - y[i];
        xp     = radius * cos( x[i] * M_PI / 180.0 );
        yp     = radius * sin( x[i] * M_PI / 180.0 );
        x[i]   = xp;
        y[i]   = yp;
    }
}

// "Normalize" longitude values so that they always fall between -180.0 and
// 180.0
PLFLT
normalize_longitude( PLFLT lon )
{
    PLFLT times;
    if ( lon >= -180.0 && lon <= 180.0 )
    {
        return ( lon );
    }
    else
    {
        times = floor( ( fabs( lon ) + 180.0 ) / 360.0 );
        if ( lon < 0.0 )
        {
            return ( lon + 360.0 * times );
        }
        else
        {
            return ( lon - 360.0 * times );
        }
    }
}

// A custom axis labeling function for longitudes and latitudes.
void
geolocation_labeler( PLINT axis, PLFLT value, char *label, PLINT length, 
PLPointer /* data */ )
{
    const char *direction_label = "";
    PLFLT      label_val        = 0.0;

    if ( axis == PL_Y_AXIS )
    {
        label_val = value;
        if ( label_val > 0.0 )
        {
            direction_label = " N";
        }
        else if ( label_val < 0.0 )
        {
            direction_label = " S";
        }
        else
        {
            direction_label = "Eq";
        }
    }
    else if ( axis == PL_X_AXIS )
    {
        label_val = normalize_longitude( value );
        if ( label_val > 0.0 )
        {
            direction_label = " E";
        }
        else if ( label_val < 0.0 )
        {
            direction_label = " W";
        }
        else
        {
            direction_label = "";
        }
    }
    if ( axis == PL_Y_AXIS && value == 0.0 )
    {
        // A special case for the equator
        snprintf( label, length, "%s", direction_label );
    }
    else
    {
        snprintf( label, length, "%.0f%s", fabs( label_val ), direction_label );
    }
}


x19::x19( int argc, char ** argv )
{
    PLFLT minx, maxx, miny, maxy;

    pls = new plstream();

    pls->parseopts( &argc, argv, PL_PARSE_FULL );

    pls->init();
    pls->col0( 1 );
    pls->slabelfunc( geolocation_labeler, NULL );

        // Ireland is entirely visible
    miny = 48;
    maxy = 62;

    minx = -10.5;
    maxx = 6.5;

    pls->env( minx, maxx, miny, maxy, 1, 70 );
    pls->map( NULL, "cglobe", minx, maxx, miny, maxy );

        // Shift: now only the internal border is visible
    minx += 0.5;
    maxx += 0.5;

    pls->env( minx, maxx, miny, maxy, 1, 70 );
    pls->map( NULL, "cglobe", minx, maxx, miny, maxy );


    delete pls;
}

int main( int argc, char ** argv )
{
    x19 *x = new x19( argc, argv );

    delete x;
}


//--------------------------------------------------------------------------
//                              End of x19.cc
//--------------------------------------------------------------------------
------------------------------------------------------------------------------
_______________________________________________
Plplot-devel mailing list
Plplot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plplot-devel

Reply via email to