| 1 | package Wikibase::Datatype::Value::Globecoordinate; | ||||||||||
| 2 | |||||||||||
| 3 | 10 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 10 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 10 | ▶ | use Error::Pure qw(err); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 10 | ▶ | use Mo qw(build is); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 10 | ▶ | use Wikibase::Datatype::Utils qw(check_entity); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 10 | our $VERSION = 0.40; | |||||||||
| 11 | |||||||||||
| 12 | 10 | extends 'Wikibase::Datatype::Value'; | |||||||||
| 13 | |||||||||||
| 14 | 10 | has altitude => ( | |||||||||
| 15 | 'is' => 'ro', | ||||||||||
| 16 | ); | ||||||||||
| 17 | |||||||||||
| 18 | 10 | has globe => ( | |||||||||
| 19 | 'is' => 'ro', | ||||||||||
| 20 | ); | ||||||||||
| 21 | |||||||||||
| 22 | 1 | ▶ | sub latitude { | ||||||||
|
Subroutine
latitude: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 23 | 1 | my $self = shift; | |||||||||
| 24 | |||||||||||
| 25 | 1 | return $self->{'value'}->[0]; | |||||||||
| 26 | } | ||||||||||
| 27 | |||||||||||
| 28 | 1 | ▶ | sub longitude { | ||||||||
|
Subroutine
longitude: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 29 | 1 | my $self = shift; | |||||||||
| 30 | |||||||||||
| 31 | 1 | return $self->{'value'}->[1]; | |||||||||
| 32 | } | ||||||||||
| 33 | |||||||||||
| 34 | 10 | has precision => ( | |||||||||
| 35 | 'is' => 'ro', | ||||||||||
| 36 | ); | ||||||||||
| 37 | |||||||||||
| 38 | 1 | ▶ | sub type { | ||||||||
|
Subroutine
type: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 39 | 1 | return 'globecoordinate'; | |||||||||
| 40 | } | ||||||||||
| 41 | |||||||||||
| 42 | 15 | ▶ | sub BUILD { | ||||||||
|
Subroutine
BUILD: called CC=7 SCAR=19.5
Pod
undocumented
| |||||||||||
| 43 | 15 | my $self = shift; | |||||||||
| 44 | |||||||||||
| 45 | 15 | ▶ | if (ref $self->{'value'} ne 'ARRAY') { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 46 | 1 | err "Parameter 'value' must be a array."; | |||||||||
| 47 | } | ||||||||||
| 48 | 14 | ▶ | if (@{$self->{'value'}} != 2) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 49 | 1 | err "Parameter 'value' array must have two fields ". | |||||||||
| 50 | "(latitude and longitude)."; | ||||||||||
| 51 | } | ||||||||||
| 52 | 13 | my ($lat, $lon) = @{$self->{'value'}}; | |||||||||
| 53 | 13 | ▶ | if ($lat !~ m/^\-?\d+\.?\d*$/ms) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 54 | 1 | err "Parameter 'value' has bad first parameter (latitude)."; | |||||||||
| 55 | } | ||||||||||
| 56 | 12 | ▶ | if ($lon !~ m/^\-?\d+\.?\d*$/ms) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 57 | 1 | err "Parameter 'value' has bad first parameter (longitude)."; | |||||||||
| 58 | } | ||||||||||
| 59 | |||||||||||
| 60 | 11 | ▶ | if (! defined $self->{'globe'}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 61 | 10 | $self->{'globe'} = 'Q2', | |||||||||
| 62 | } | ||||||||||
| 63 | 11 | check_entity($self, 'globe'); | |||||||||
| 64 | |||||||||||
| 65 | 11 | ▶ | if (! defined $self->{'precision'}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 66 | 10 | $self->{'precision'} = '1e-07', | |||||||||
| 67 | } | ||||||||||
| 68 | |||||||||||
| 69 | 11 | return; | |||||||||
| 70 | } | ||||||||||
| 71 | |||||||||||
| 72 | 10 | 1; | |||||||||
| 73 | |||||||||||
| 74 | __END__ | ||||||||||