Draft patch attached.
Let me know if it needs tweaking.
Regards,
Shawn.
On Wed Jul 30 03:43:49 2014, LIOSHA wrote:
Show quoted text> Hi!
>
> The project lives at google-code:
http://code.google.com/p/geo-
> shapefile-writer/
>
> It would be very nice if you sent me a patch.
>
>
> Втр Июл 29 22:42:54 2014, SLAFFAN писал:
> > Thanks for this very useful module.
> >
> > given/when has been marked as experimental under Perl 5.20 so loading
> > Geo::Shapefile::Writer raises experimental warnings.
> >
> > This is pretty easy to fix, and I'm happy to do so. Just let me know
> > if there is a code repository somewhere to work from.
> >
> > Regards,
> > Shawn.
Index: lib/Geo/Shapefile/Writer.pm
===================================================================
--- lib/Geo/Shapefile/Writer.pm (revision 15)
+++ lib/Geo/Shapefile/Writer.pm (working copy)
@@ -170,39 +170,38 @@
my ($xmin, $ymin, $xmax, $ymax);
my $rdata;
- given ( $self->{TYPE} ) {
- when ( $shape_type{NULL} ) {
- $rdata = pack( 'L', $self->{TYPE} );
- }
+ my $type = $self->{TYPE};
- when ( $shape_type{POINT} ) {
- $rdata = pack( 'Ldd', $self->{TYPE}, @$data );
- ($xmin, $ymin, $xmax, $ymax) = ( @$data, @$data );
- }
+ if ($type == $shape_type{NULL} ) {
+ $rdata = pack( 'L', $self->{TYPE} );
+ }
+ elsif ($type == $shape_type{POINT} ) {
+ $rdata = pack( 'Ldd', $self->{TYPE}, @$data );
+ ($xmin, $ymin, $xmax, $ymax) = ( @$data, @$data );
+ }
+ elsif ($type == $shape_type{POLYLINE} || $type == $shape_type{POLYGON} ) {
+ my $rpart = q{};
+ my $rpoint = q{};
+ my $ipoint = 0;
- when ( [ @shape_type{'POLYLINE','POLYGON'} ] ) {
- my $rpart = q{};
- my $rpoint = q{};
- my $ipoint = 0;
-
- for my $line ( @$data ) {
- $rpart .= pack 'L', $ipoint;
- for my $point ( @$line ) {
- my ($x, $y) = @$point;
- $rpoint .= pack 'dd', $x, $y;
- $ipoint ++;
- }
+ for my $line ( @$data ) {
+ $rpart .= pack 'L', $ipoint;
+ for my $point ( @$line ) {
+ my ($x, $y) = @$point;
+ $rpoint .= pack 'dd', $x, $y;
+ $ipoint ++;
}
+ }
- $xmin = min map {$_->[0]} map {@$_} @$data;
- $ymin = min map {$_->[1]} map {@$_} @$data;
- $xmax = max map {$_->[0]} map {@$_} @$data;
- $ymax = max map {$_->[1]} map {@$_} @$data;
+ $xmin = min map {$_->[0]} map {@$_} @$data;
+ $ymin = min map {$_->[1]} map {@$_} @$data;
+ $xmax = max map {$_->[0]} map {@$_} @$data;
+ $ymax = max map {$_->[1]} map {@$_} @$data;
- $rdata = pack 'LddddLL', $self->{TYPE}, $xmin, $ymin, $xmax, $ymax, scalar @$data, $ipoint;
- $rdata .= $rpart . $rpoint;
- }
+ $rdata = pack 'LddddLL', $self->{TYPE}, $xmin, $ymin, $xmax, $ymax, scalar @$data, $ipoint;
+ $rdata .= $rpart . $rpoint;
}
+
my $attr0 = $attributes[0];
if ( ref $attr0 eq 'HASH' ) {