NAME
Wikibase::Datatype::Struct::Value::Globecoordinate - Wikibase globe coordinate value structure serialization.
SYNOPSIS
my
$struct_hr
= obj2struct(
$obj
,
$base_uri
);
my
$obj
= struct2obj(
$struct_hr
);
DESCRIPTION
This conversion is between objects defined in Wikibase::Datatype and structures serialized via JSON to MediaWiki.
SUBROUTINES
obj2struct
my
$struct_hr
= obj2struct(
$obj
,
$base_uri
);
Convert Wikibase::Datatype::Value::Globecoordinate instance to structure. $base_uri
is base URI of Wikibase system (e.g. http://test.wikidata.org/entity/).
Returns reference to hash with structure.
struct2obj
my
$obj
= struct2obj(
$struct_hr
);
Convert structure of globe coordinate to object.
Returns Wikibase::Datatype::Value::Globecoordinate instance.
ERRORS
obj2struct():
Base URI is required.
Object doesn't exist.
Object isn
't '
Wikibase::Datatype::Value::Globecoordinate'.
struct2obj():
Structure isn
't for '
globecoordinate' datatype.
EXAMPLE1
use
strict;
use
warnings;
use
Data::Printer;
# Object.
my
$obj
= Wikibase::Datatype::Value::Globecoordinate->new(
'value'
=> [49.6398383, 18.1484031],
);
# Get structure.
# Dump to output.
p
$struct_hr
;
# Output:
# \ {
# type "globecoordinate",
# value {
# altitude "null",
# globe "http://test.wikidata.org/entity/Q2",
# latitude 49.6398383,
# longitude 18.1484031,
# precision 1e-07
# }
# }
EXAMPLE2
use
strict;
use
warnings;
# Globe coordinate structure.
my
$struct_hr
= {
'type'
=>
'globecoordinate'
,
'value'
=> {
'altitude'
=>
'null'
,
'latitude'
=> 49.6398383,
'longitude'
=> 18.1484031,
'precision'
=> 1e-07,
},
};
# Get object.
my
$obj
= struct2obj(
$struct_hr
);
# Get globe.
my
$globe
=
$obj
->globe;
# Get longitude.
my
$longitude
=
$obj
->longitude;
# Get latitude.
my
$latitude
=
$obj
->latitude;
# Get precision.
my
$precision
=
$obj
->precision;
# Get type.
my
$type
=
$obj
->type;
# Get value.
my
$value_ar
=
$obj
->value;
# Print out.
"Globe: $globe\n"
;
"Latitude: $latitude\n"
;
"Longitude: $longitude\n"
;
"Precision: $precision\n"
;
"Type: $type\n"
;
'Value: '
.(
join
', '
, @{
$value_ar
}).
"\n"
;
# Output:
# Globe: Q2
# Latitude: 49.6398383
# Longitude: 18.1484031
# Precision: 1e-07
# Type: globecoordinate
# Value: 49.6398383, 18.1484031
DEPENDENCIES
Error::Pure, Exporter, Readonly, URI, Wikibase::Datatype::Value::Globecoordinate.
SEE ALSO
- Wikibase::Datatype::Struct
-
Wikibase structure serialization.
- Wikibase::Datatype::Value::Globecoordinate
-
Wikibase globe coordinate value datatype.
REPOSITORY
https://github.com/michal-josef-spacek/Wikibase-Datatype-Struct
AUTHOR
Michal Josef Špaček mailto:skim@cpan.org
LICENSE AND COPYRIGHT
© 2020-2025 Michal Josef Špaček
BSD 2-Clause License
VERSION
0.14