Skip to content

Commit 5b2c8b0

Browse files
authored
Merge pull request #522 from following5/feature/gc-ocde-attrs
implemented attrs=gc_ocde:attrs for OCPL; updates #346
2 parents 43bc7ed + 05ab0c3 commit 5b2c8b0

File tree

7 files changed

+116
-42
lines changed

7 files changed

+116
-42
lines changed

okapi/services/attrs/AttrHelper.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ public static function refresh_from_string($xml)
9595
$attr = array(
9696
'acode' => (string)$attrnode['acode'],
9797
'gc_equivs' => array(),
98+
'gc_ocde_equiv' => null,
9899
'internal_id' => null,
99100
'names' => array(),
100101
'descriptions' => array(),
@@ -146,6 +147,18 @@ public static function refresh_from_string($xml)
146147
$attr['descriptions'][$lang] = self::cleanup_string($innerxml);
147148
}
148149
}
150+
foreach ($attrnode->ocgs as $ocgsnode)
151+
{
152+
if (isset($attr['gc_ocde_equiv']))
153+
throw new Exception("Duplicate ocgs entries for ".$attr['acode']);
154+
if (!isset($attr['names']['en']))
155+
throw new Exception("(English) name is missing for ".$attr['acode']." ocgs entry.");
156+
$attr['gc_ocde_equiv'] = array(
157+
'id' => (int)$ocgsnode['id'],
158+
'inc' => in_array((string)$ocgsnode['inc'], array("true", "1")) ? 1 : 0,
159+
'name' => $attr['names']['en']
160+
);
161+
}
149162
$cachedvalue['attr_dict'][$attr['acode']] = $attr;
150163
}
151164

okapi/services/attrs/attribute-definitions.xml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,12 @@ https://gist.github.com/DieBatzen/5814dc7368c1034470c8/
132132
133133
*** These are special attributes, not available to the regular user.
134134
135+
For Opencaching attributes which have no Groundspeak equivalents, additional
136+
Pseudo-Groundspeak IDs ("ocgs" IDs) have been defined, which are used to
137+
store these attributes in GPX <groundspeak:attribute> elements.
138+
See OCDE htdocs/lib2/search/search.gpx.inc.php and OCPL lib/format.gpx.inc.php
139+
for the original implementations.
140+
135141
-->
136142

137143
<xml>
@@ -141,6 +147,7 @@ https://gist.github.com/DieBatzen/5814dc7368c1034470c8/
141147
-->
142148

143149
<attr acode="A1" categories="de-listing">
150+
<ocgs id="106" inc="true" />
144151
<opencaching schema="OCDE" id="6" />
145152
<opencaching schema="OCNL" id="6" />
146153
<opencaching schema="OCRO" id="6" />
@@ -199,6 +206,7 @@ https://gist.github.com/DieBatzen/5814dc7368c1034470c8/
199206
</attr>
200207

201208
<attr acode="A2" categories="de-cache-types">
209+
<ocgs id="117" inc="true" />
202210
<opencaching schema="OCPL" id="54" />
203211
<opencaching schema="OCNL" id="54" />
204212
<opencaching schema="OCRO" id="54" />
@@ -237,6 +245,7 @@ https://gist.github.com/DieBatzen/5814dc7368c1034470c8/
237245
</attr>
238246

239247
<attr acode="A3" categories="de-cache-types">
248+
<ocgs id="118" inc="true" />
240249
<opencaching schema="OCPL" id="55" />
241250
<opencaching schema="OCRO" id="55" />
242251
<lang id="en">
@@ -275,6 +284,7 @@ https://gist.github.com/DieBatzen/5814dc7368c1034470c8/
275284
</attr>
276285

277286
<attr acode="A4" categories="de-cache-types">
287+
<ocgs id="108" inc="true" />
278288
<opencaching schema="OCDE" id="8" />
279289
<opencaching schema="OCPL" id="56" />
280290
<opencaching schema="OCNL" id="56" />
@@ -344,6 +354,7 @@ https://gist.github.com/DieBatzen/5814dc7368c1034470c8/
344354
</attr>
345355

346356
<attr acode="A5" categories="de-cache-types">
357+
<ocgs id="112" inc="true" />
347358
<opencaching schema="OCPL" id="43" />
348359
<opencaching schema="OCRO" id="43" />
349360
<opencaching schema="OCNL" id="43" />
@@ -386,6 +397,7 @@ https://gist.github.com/DieBatzen/5814dc7368c1034470c8/
386397
</attr>
387398

388399
<attr acode="A6" categories="de-cache-types">
400+
<ocgs id="149" inc="true" />
389401
<opencaching schema="OCPL" id="49" />
390402
<opencaching schema="OCRO" id="49" />
391403
<opencaching schema="OCNL" id="49" />
@@ -422,6 +434,7 @@ https://gist.github.com/DieBatzen/5814dc7368c1034470c8/
422434
</attr>
423435

424436
<attr acode="A7" categories="de-cache-types">
437+
<ocgs id="114" inc="true" />
425438
<opencaching schema="OCPL" id="50" />
426439
<opencaching schema="OCRO" id="50" />
427440
<opencaching schema="OCNL" id="50" />
@@ -464,6 +477,7 @@ https://gist.github.com/DieBatzen/5814dc7368c1034470c8/
464477
</attr>
465478

466479
<attr acode="A8" categories="de-cache-types">
480+
<ocgs id="115" inc="true" />
467481
<opencaching schema="OCPL" id="51" />
468482
<opencaching schema="OCRO" id="51" />
469483
<lang id="en">
@@ -541,6 +555,7 @@ https://gist.github.com/DieBatzen/5814dc7368c1034470c8/
541555
</attr>
542556

543557
<attr acode="A10" categories="de-cache-types">
558+
<ocgs id="116" inc="true" />
544559
<opencaching schema="OCPL" id="53" />
545560
<opencaching schema="OCRO" id="53" />
546561
<opencaching schema="OCNL" id="53" />
@@ -590,6 +605,7 @@ https://gist.github.com/DieBatzen/5814dc7368c1034470c8/
590605
</attr>
591606

592607
<attr acode="A11" categories="de-cache-types">
608+
<ocgs id="131" inc="true" />
593609
<opencaching schema="OCDE" id="31" />
594610
<opencaching schema="OCUK" id="31" />
595611
<lang id="en">
@@ -634,6 +650,7 @@ https://gist.github.com/DieBatzen/5814dc7368c1034470c8/
634650
</attr>
635651

636652
<attr acode="A12" categories="de-cache-types">
653+
<ocgs id="132" inc="true" />
637654
<opencaching schema="OCDE" id="32" />
638655
<opencaching schema="OCUK" id="32" />
639656
<lang id="en">
@@ -677,6 +694,7 @@ https://gist.github.com/DieBatzen/5814dc7368c1034470c8/
677694
</attr>
678695

679696
<attr acode="A13" categories="de-cache-types">
697+
<ocgs id="157" inc="true" />
680698
<opencaching schema="OCDE" id="57" />
681699
<opencaching schema="OCUK" id="57" />
682700
<lang id="en">
@@ -709,6 +727,7 @@ https://gist.github.com/DieBatzen/5814dc7368c1034470c8/
709727
</attr>
710728

711729
<attr acode="A14" categories="de-preconditions">
730+
<ocgs id="154" inc="true" />
712731
<opencaching schema="OCDE" id="54" />
713732
<opencaching schema="OCUK" id="54" />
714733
<lang id="en">
@@ -778,6 +797,7 @@ https://gist.github.com/DieBatzen/5814dc7368c1034470c8/
778797
</attr>
779798

780799
<attr acode="A16" categories="de-preconditions">
800+
<ocgs id="156" inc="true" />
781801
<opencaching schema="OCDE" id="56" />
782802
<opencaching schema="OCUK" id="56" />
783803
<lang id="en">
@@ -812,6 +832,7 @@ https://gist.github.com/DieBatzen/5814dc7368c1034470c8/
812832
</attr>
813833

814834
<attr acode="A17" categories="de-preconditions">
835+
<ocgs id="158" inc="true" />
815836
<opencaching schema="OCDE" id="58" />
816837
<opencaching schema="OCUK" id="58" />
817838
<lang id="en">
@@ -914,6 +935,7 @@ https://gist.github.com/DieBatzen/5814dc7368c1034470c8/
914935
</attr>
915936

916937
<attr acode="A20" categories="de-accessibility">
938+
<ocgs id="122" inc="true" />
917939
<opencaching schema="OCPL" id="84" />
918940
<opencaching schema="OCRO" id="84" />
919941
<opencaching schema="OCNL" id="84" />
@@ -1037,6 +1059,7 @@ https://gist.github.com/DieBatzen/5814dc7368c1034470c8/
10371059
</attr>
10381060

10391061
<attr acode="A23" categories="de-accessibility">
1062+
<ocgs id="127" inc="true" />
10401063
<opencaching schema="OCDE" id="27" />
10411064
<opencaching schema="OCUK" id="27" />
10421065
<lang id="en">
@@ -1215,6 +1238,7 @@ https://gist.github.com/DieBatzen/5814dc7368c1034470c8/
12151238
</attr>
12161239

12171240
<attr acode="A28" categories="de-location">
1241+
<ocgs id="119" inc="true" />
12181242
<opencaching schema="OCPL" id="60" />
12191243
<opencaching schema="OCNL" id="60" />
12201244
<opencaching schema="OCRO" id="60" />
@@ -1254,6 +1278,7 @@ https://gist.github.com/DieBatzen/5814dc7368c1034470c8/
12541278
</attr>
12551279

12561280
<attr acode="A29" categories="de-location">
1281+
<ocgs id="120" inc="true" />
12571282
<opencaching schema="OCPL" id="61" />
12581283
<opencaching schema="OCNL" id="61" />
12591284
<opencaching schema="OCRO" id="61" />
@@ -1295,6 +1320,7 @@ https://gist.github.com/DieBatzen/5814dc7368c1034470c8/
12951320
</attr>
12961321

12971322
<attr acode="A30" categories="de-location">
1323+
<ocgs id="130" inc="true" />
12981324
<opencaching schema="OCDE" id="30" />
12991325
<opencaching schema="OCUK" id="30" />
13001326
<lang id="en">
@@ -1348,6 +1374,7 @@ https://gist.github.com/DieBatzen/5814dc7368c1034470c8/
13481374
</attr>
13491375

13501376
<attr acode="A31" categories="de-location">
1377+
<ocgs id="133" inc="true" />
13511378
<opencaching schema="OCDE" id="33" />
13521379
<opencaching schema="OCUK" id="33" />
13531380
<lang id="en">
@@ -1381,6 +1408,7 @@ https://gist.github.com/DieBatzen/5814dc7368c1034470c8/
13811408
</attr>
13821409

13831410
<attr acode="A32" categories="de-location">
1411+
<ocgs id="134" inc="true" />
13841412
<opencaching schema="OCDE" id="34" />
13851413
<opencaching schema="OCUK" id="34" />
13861414
<lang id="en">
@@ -1606,6 +1634,7 @@ https://gist.github.com/DieBatzen/5814dc7368c1034470c8/
16061634
</attr>
16071635

16081636
<attr acode="A38" categories="de-facilities">
1637+
<ocgs id="123" inc="true" />
16091638
<opencaching schema="OCDE" id="23" />
16101639
<opencaching schema="OCUK" id="23" />
16111640
<lang id="en">
@@ -1920,6 +1949,7 @@ https://gist.github.com/DieBatzen/5814dc7368c1034470c8/
19201949
</attr>
19211950

19221951
<attr acode="A46" categories="de-time-and-seasons">
1952+
<ocgs id="143" inc="true" />
19231953
<opencaching schema="OCDE" id="43" />
19241954
<opencaching schema="OCUK" id="43" />
19251955
<lang id="en">
@@ -1999,6 +2029,7 @@ https://gist.github.com/DieBatzen/5814dc7368c1034470c8/
19992029
</attr>
20002030

20012031
<attr acode="A48" categories="de-time-and-seasons">
2032+
<ocgs id="142" inc="true" /><!-- Yes! Not 141. -->
20022033
<opencaching schema="OCDE" id="41" />
20032034
<opencaching schema="OCUK" id="41" />
20042035
<lang id="en">
@@ -2019,6 +2050,7 @@ https://gist.github.com/DieBatzen/5814dc7368c1034470c8/
20192050
</attr>
20202051

20212052
<attr acode="A49" categories="de-tools">
2053+
<ocgs id="147" inc="true" />
20222054
<opencaching schema="OCPL" id="47" />
20232055
<opencaching schema="OCDE" id="47" />
20242056
<opencaching schema="OCNL" id="47" />
@@ -2068,6 +2100,7 @@ https://gist.github.com/DieBatzen/5814dc7368c1034470c8/
20682100
</attr>
20692101

20702102
<attr acode="A50" categories="de-tools">
2103+
<ocgs id="113" inc="true" />
20712104
<opencaching schema="OCPL" id="48" />
20722105
<opencaching schema="OCNL" id="48" />
20732106
<opencaching schema="OCRO" id="48" />
@@ -2102,6 +2135,7 @@ https://gist.github.com/DieBatzen/5814dc7368c1034470c8/
21022135
</attr>
21032136

21042137
<attr acode="A51" categories="de-tools">
2138+
<ocgs id="121" inc="true" />
21052139
<opencaching schema="OCPL" id="81" />
21062140
<opencaching schema="OCRO" id="81" />
21072141
<opencaching schema="OCNL" id="81" />
@@ -2220,6 +2254,7 @@ https://gist.github.com/DieBatzen/5814dc7368c1034470c8/
22202254
</attr>
22212255

22222256
<attr acode="A54" categories="de-tools">
2257+
<ocgs id="150" inc="true" />
22232258
<opencaching schema="OCDE" id="50" />
22242259
<opencaching schema="OCUK" id="50" />
22252260
<lang id="en">
@@ -2424,6 +2459,7 @@ https://gist.github.com/DieBatzen/5814dc7368c1034470c8/
24242459
</attr>
24252460

24262461
<attr acode="A58" categories="de-tools">
2462+
<ocgs id="135" inc="true" />
24272463
<opencaching schema="OCDE" id="35" />
24282464
<opencaching schema="OCUK" id="35" />
24292465
<lang id="en">
@@ -2521,6 +2557,7 @@ https://gist.github.com/DieBatzen/5814dc7368c1034470c8/
25212557
</attr>
25222558

25232559
<attr acode="A60" categories="de-dangers">
2560+
<ocgs id="110" inc="true" />
25242561
<opencaching schema="OCDE" id="10" />
25252562
<opencaching schema="OCUK" id="10" />
25262563
<lang id="en">
@@ -2873,6 +2910,7 @@ https://gist.github.com/DieBatzen/5814dc7368c1034470c8/
28732910
</attr>
28742911

28752912
<attr acode="A68" categories="de-rating">
2913+
<ocgs id="111" inc="true" />
28762914
<opencaching schema="OCPL" id="40" />
28772915
<opencaching schema="OCRO" id="40" />
28782916
<opencaching schema="OCNL" id="40" />
@@ -2909,6 +2947,7 @@ https://gist.github.com/DieBatzen/5814dc7368c1034470c8/
29092947
</attr>
29102948

29112949
<attr acode="A69" categories="de-rating">
2950+
<ocgs id="137" inc="true" />
29122951
<opencaching schema="OCDE" id="37" />
29132952
<opencaching schema="OCUK" id="37" />
29142953
<lang id="en">
@@ -3035,6 +3074,7 @@ https://gist.github.com/DieBatzen/5814dc7368c1034470c8/
30353074
</attr>
30363075

30373076
<attr acode="A72" categories="de-cache-types">
3077+
<ocgs id="161" inc="true" />
30383078
<opencaching schema="OCDE" id="61" />
30393079
<lang id="en">
30403080
<name>Reverse Cache</name>
@@ -3124,6 +3164,7 @@ https://gist.github.com/DieBatzen/5814dc7368c1034470c8/
31243164
</attr>
31253165

31263166
<attr acode="A75" categories="de-tools">
3167+
<ocgs id="153" inc="true" />
31273168
<opencaching schema="OCDE" id="53" /><!-- deprecated -->
31283169
<opencaching schema="OCUK" id="156" />
31293170
<lang id="en">
@@ -3166,6 +3207,7 @@ https://gist.github.com/DieBatzen/5814dc7368c1034470c8/
31663207
</attr>
31673208

31683209
<attr acode="A76" categories="de-accessibility">
3210+
<ocgs id="125" inc="true" />
31693211
<opencaching schema="OCUK" id="157" />
31703212
<lang id="en">
31713213
<name>Rated on Handicaching.com</name>
@@ -3205,6 +3247,7 @@ https://gist.github.com/DieBatzen/5814dc7368c1034470c8/
32053247
</attr>
32063248

32073249
<attr acode="A77" categories="de-cache-types">
3250+
<ocgs id="126" inc="true" />
32083251
<opencaching schema="OCUK" id="158" />
32093252
<lang id="en">
32103253
<name>Contains a Munzee</name>

okapi/services/attrs/attribute/docs.xml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,33 @@
9595
<p>Note that one gc_equivs list may have multiple items on it, and
9696
that one Geocaching.com ID may be present in many gc_equivs.</p>
9797
</li>
98+
<li>
99+
<p><b>gc_ocde_equiv</b> - a Groundspeak-like attribute with ID &gt;
100+
100, which may be included in GPX files if there is no <em>gc_equiv</em>
101+
for the OC attribute; either <b>null</b> or a dictionary of the
102+
following structure:</p>
103+
104+
<ul>
105+
<li><b>id</b> - Groundspeak-like ID of the attribute,</li>
106+
<li>
107+
<b>inc</b> - integer, either 1 or 0, to be included in GPX
108+
files,
109+
</li>
110+
<li>
111+
<b>name</b> - the name of the attribute to be included in
112+
GPX files.
113+
</li>
114+
</ul>
115+
116+
<p>Note: We cannot guarantee that the ID of these Groundspeak-like
117+
attributes will forever stay the same. If you need a unique attribute
118+
ID, use the <b>acode</b> instead.</p>
119+
<p>The naming "ocde_" is for historical reasons. This field is
120+
available on all up-to-date OKAPI installations and covers all OC
121+
attributes without native GC equivalents. See the
122+
<a href='%OKAPI:methodargref:services/caches/formatters/gpx%'>caches/formatters/gpx</a>
123+
<em>attrs=gc_ocde:attrs</em> option for more explanation.</p>
124+
</li>
98125
<li>
99126
<p><b>is_locally_used</b> - boolean, indicates if the attribute is <i>currently</i>
100127
used by <i>this</i> Opencaching server. Or, to be more specific, <b>true</b>

okapi/services/attrs/attributes/WebService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public static function options()
2020
}
2121

2222
private static $valid_field_names = array(
23-
'acode', 'name', 'names', 'description', 'descriptions', 'gc_equivs',
23+
'acode', 'name', 'names', 'description', 'descriptions', 'gc_equivs', 'gc_ocde_equiv',
2424
'is_locally_used', 'is_deprecated', 'local_icon_url', 'is_discontinued'
2525
);
2626

0 commit comments

Comments
 (0)