File Coverage

blib/lib/WWW/MetaForge/GameMapData/Result/MapMarker.pm
Criterion Covered Total %
statement 18 18 100.0
branch 2 2 100.0
condition n/a
subroutine 10 10 100.0
pod 5 7 71.4
total 35 37 94.5


line stmt bran cond sub pod time code
1             package WWW::MetaForge::GameMapData::Result::MapMarker;
2             our $AUTHORITY = 'cpan:GETTY';
3             # ABSTRACT: Base map marker result object for MetaForge Game Map Data API
4             our $VERSION = '0.002';
5 8     8   99799 use Moo;
  8         5756  
  8         71  
6 8     8   10093 use Types::Standard qw(Str Num Int HashRef Maybe);
  8         1077100  
  8         201  
7 8     8   32901 use namespace::clean;
  8         25413  
  8         86  
8              
9             # Generic fields common to all game map data
10              
11             has id => (
12             is => 'ro',
13             isa => Str,
14             required => 1,
15             );
16              
17             has lat => (
18             is => 'ro',
19             isa => Num,
20             required => 1,
21             );
22              
23             has lng => (
24             is => 'ro',
25             isa => Num,
26             required => 1,
27             );
28              
29             has zlayers => (
30             is => 'ro',
31             isa => Maybe[Int],
32             );
33              
34             has mapID => (
35             is => 'ro',
36             isa => Maybe[Str],
37             );
38              
39             has updated_at => (
40             is => 'ro',
41             isa => Maybe[Str],
42             );
43              
44             has added_by => (
45             is => 'ro',
46             isa => Maybe[Str],
47             );
48              
49             has last_edited_by => (
50             is => 'ro',
51             isa => Maybe[Str],
52             );
53              
54             has _raw => (
55             is => 'ro',
56             isa => HashRef,
57             );
58              
59             sub from_hashref {
60 25     25 1 381319 my ($class, $data) = @_;
61              
62             return $class->new(
63             id => $data->{id},
64             lat => $data->{lat},
65             lng => $data->{lng},
66             zlayers => $data->{zlayers},
67             mapID => $data->{mapID},
68             updated_at => $data->{updated_at},
69             added_by => $data->{added_by},
70             last_edited_by => $data->{last_edited_by},
71 25         931 _raw => $data,
72             );
73             }
74              
75             # Convenience accessors
76              
77 5     5 1 254 sub x { shift->lng }
78 5     5 1 34 sub y { shift->lat }
79 1     1 1 6 sub z { shift->zlayers }
80              
81             # Subclasses should override to provide marker type
82 2     2 0 4895 sub type { undef }
83 1     1 0 3 sub name { undef }
84              
85             sub coordinates {
86 3     3 1 771 my ($self) = @_;
87             return {
88 3 100       39 x => $self->lng,
89             y => $self->lat,
90             defined $self->zlayers ? (z => $self->zlayers) : (),
91             };
92             }
93              
94             1;
95              
96             __END__
97              
98             =pod
99              
100             =encoding UTF-8
101              
102             =head1 NAME
103              
104             WWW::MetaForge::GameMapData::Result::MapMarker - Base map marker result object for MetaForge Game Map Data API
105              
106             =head1 VERSION
107              
108             version 0.002
109              
110             =head1 SYNOPSIS
111              
112             my $markers = $api->map_data(map => 'dam');
113             for my $marker (@$markers) {
114             say "Marker at " . $marker->lng . ", " . $marker->lat;
115             }
116              
117             =head1 DESCRIPTION
118              
119             Base class for map marker objects from the MetaForge Game Map Data API.
120             Contains only generic fields common to all games.
121              
122             Game-specific distributions should subclass this to add game-specific
123             attributes (like category, subcategory for ARC Raiders).
124              
125             =head2 id
126              
127             Unique marker identifier (UUID).
128              
129             =head2 lat
130              
131             Latitude (Y coordinate) on the map.
132              
133             =head2 lng
134              
135             Longitude (X coordinate) on the map.
136              
137             =head2 zlayers
138              
139             Z-layer value for elevation/floor.
140              
141             =head2 mapID
142              
143             Map identifier (e.g., "dam", "spaceport").
144              
145             =head2 updated_at
146              
147             ISO timestamp of last update.
148              
149             =head2 added_by
150              
151             Username who added this marker.
152              
153             =head2 last_edited_by
154              
155             Username who last edited this marker.
156              
157             =head2 from_hashref
158              
159             my $marker = WWW::MetaForge::GameMapData::Result::MapMarker->from_hashref(\%data);
160              
161             Construct from API response hash. Subclasses should override this to
162             handle game-specific fields.
163              
164             =head2 x
165              
166             Alias for C<lng>.
167              
168             =head2 y
169              
170             Alias for C<lat>.
171              
172             =head2 z
173              
174             Alias for C<zlayers>.
175              
176             =head2 coordinates
177              
178             my $coords = $marker->coordinates;
179             # { x => 123.5, y => 78.1 }
180              
181             Returns HashRef of coordinates.
182              
183             =head1 SUPPORT
184              
185             =head2 Issues
186              
187             Please report bugs and feature requests on GitHub at
188             L<https://github.com/Getty/p5-www-metaforge/issues>.
189              
190             =head2 IRC
191              
192             You can reach Getty on C<irc.perl.org> for questions and support.
193              
194             =head1 CONTRIBUTING
195              
196             Contributions are welcome! Please fork the repository and submit a pull request.
197              
198             =head1 AUTHOR
199              
200             Torsten Raudssus <torsten@raudssus.de>
201              
202             =head1 COPYRIGHT AND LICENSE
203              
204             This software is copyright (c) 2026 by Torsten Raudssus.
205              
206             This is free software; you can redistribute it and/or modify it under
207             the same terms as the Perl 5 programming language system itself.
208              
209             =cut