<commit_before>package Geo::Vector::Layer;
# @brief A subclass of Gtk2::Ex::Geo::Layer

=pod

=head1 NAME

Geo::Vector::Layer - A geospatial vector layer class for Gtk2::Ex::Geo

=cut

use strict;
use warnings;
use UNIVERSAL qw(isa);
use POSIX;
POSIX::setlocale( &POSIX::LC_NUMERIC, "C" ); # http://www.remotesensing.org/gdal/faq.html nr. 11
use Carp;
use Encode;
use File::Spec;
use Gtk2::Ex::Geo::Layer qw/:all/;
use Geo::OGC::Geometry;
use Geo::Vector::Layer::Dialogs;
use Glib;
use Gtk2;

BEGIN {
    if ($^O eq 'MSWin32') {
	require Win32::OLE;
	import Win32::OLE qw(in);
    }
}

use vars qw/%RENDER_AS2INDEX %INDEX2RENDER_AS $oneself $dialog_folder
            $BORDER_COLOR/;

require Exporter;
our @ISA = qw(Exporter Geo::Vector Gtk2::Ex::Geo::Layer);
our @EXPORT = qw();
our %EXPORT_TAGS = ( 'all' => [ qw( ) ] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our $VERSION = 0.03;

%RENDER_AS2INDEX = (Native => 0, Points => 1, Lines => 2, Polygons => 3);
for (keys %RENDER_AS2INDEX) {
    $INDEX2RENDER_AS{$RENDER_AS2INDEX{$_}} = $_;
}
$oneself = {};

# default values for new objects:

$BORDER_COLOR = [255, 255, 255];

sub registration {
    my $dialogs = Geo::Vector::Layer::Dialogs->new();
    my $commands = {
	open => {
	    nr => 1,
	    text => 'Open vector',
	    tip => 'Add a new vector layer.',
	    pos => 0,
	    sub => sub {
		my(undef, $gui) = @_;
		$gui->{history}->enter(''); # open_vector dialog uses the same history
		open_open_vector_dialog($gui);
	    }
	}
    };
    return { dialogs => $dialogs, commands => $commands };
}

## @cmethod $upgrade($object)
#
# @brief Upgrade (strictly) Geo::Vector objects to Geo::Vector::Layers
sub upgrade {
    my($object) = @_;
    if (ref($object) eq 'Geo::Vector') {
	bless($object, 'Geo::Vector::Layer');
	$object->defaults();
    }
    return $object;
}

sub new {
    my($package, %params) = @_;
    my $self = Geo::Vector::new($package, %params);
    Gtk2::Ex::Geo::Layer::new($package, self => $self, %params);
    return $self;
}

## @ignore
sub DESTROY {
}

sub defaults {<commit_msg>upgrade does not return the object any more, it returns boolean telling whether the object really was upgraded<commit_after>package Geo::Vector::Layer;
# @brief A subclass of Gtk2::Ex::Geo::Layer

=pod

=head1 NAME

Geo::Vector::Layer - A geospatial vector layer class for Gtk2::Ex::Geo

=cut

use strict;
use warnings;
use UNIVERSAL qw(isa);
use POSIX;
POSIX::setlocale( &POSIX::LC_NUMERIC, "C" ); # http://www.remotesensing.org/gdal/faq.html nr. 11
use Carp;
use Encode;
use File::Spec;
use Gtk2::Ex::Geo::Layer qw/:all/;
use Geo::OGC::Geometry;
use Geo::Vector::Layer::Dialogs;
use Glib;
use Gtk2;

BEGIN {
    if ($^O eq 'MSWin32') {
	require Win32::OLE;
	import Win32::OLE qw(in);
    }
}

use vars qw/%RENDER_AS2INDEX %INDEX2RENDER_AS $oneself $dialog_folder
            $BORDER_COLOR/;

require Exporter;
our @ISA = qw(Exporter Geo::Vector Gtk2::Ex::Geo::Layer);
our @EXPORT = qw();
our %EXPORT_TAGS = ( 'all' => [ qw( ) ] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our $VERSION = 0.03;

%RENDER_AS2INDEX = (Native => 0, Points => 1, Lines => 2, Polygons => 3);
for (keys %RENDER_AS2INDEX) {
    $INDEX2RENDER_AS{$RENDER_AS2INDEX{$_}} = $_;
}
$oneself = {};

# default values for new objects:

$BORDER_COLOR = [255, 255, 255];

sub registration {
    my $dialogs = Geo::Vector::Layer::Dialogs->new();
    my $commands = {
	open => {
	    nr => 1,
	    text => 'Open vector',
	    tip => 'Add a new vector layer.',
	    pos => 0,
	    sub => sub {
		my(undef, $gui) = @_;
		$gui->{history}->enter(''); # open_vector dialog uses the same history
		open_open_vector_dialog($gui);
	    }
	}
    };
    return { dialogs => $dialogs, commands => $commands };
}

## @cmethod $upgrade($object)
#
# @brief Upgrade (strictly) Geo::Vector objects to Geo::Vector::Layers
sub upgrade {
    my($object) = @_;
    if (ref($object) eq 'Geo::Vector') {
	bless($object, 'Geo::Vector::Layer');
	$object->defaults();
	return 1;
    }
    return 0;
}

sub new {
    my($package, %params) = @_;
    my $self = Geo::Vector::new($package, %params);
    Gtk2::Ex::Geo::Layer::new($package, self => $self, %params);
    return $self;
}

## @ignore
sub DESTROY {
}

sub defaults {
{'fraction_non_alphanumeric': 0.18312854442344045, 'fraction_numerical': 0.01890359168241966, 'mean_word_length': 3.9741480611045827, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2752075', 'n_tokens_mistral': 1729, 'n_tokens_neox': 1616, 'n_words': 397}