Recent Changes - Search:

add Cookbook page

hide Cookbook

Cookbook


hide Topics

Topics

show Changed

Changed

Visitor's book Site map pmwiki-2.3.37

NZ DoC

NZDoC version 2024-04-10

Summary: Use DoC API to retrieve campsites, huts, and tracks information to display in PmWiki
Version: 2020-06-10
Prerequisites: PmWiki 2.2.130 (PHP 7.4 compatible)
Status: Production
Maintainer: skiwi
Licence: GPL3[1]
Categories: Images Includes PHP74
Users: (view? / edit)
Discussion: NZDoC-Talk?

Questions answered by this recipe

How do I display information from Te Papa AtawhaiNew Zealand's Department of Conservation on campsites, huts, and tracks information on a PmWiki page?

Description

This recipe generates the markup for the display of Department of Conservation information The recipe uses the DoC API to retrieve campsites, huts, and tracks information to display in a PmWiki wiki.

Installation

  • download 2020-06-10-nzdoc.php Δ
  • copy to the /cookbook/ directory as nzdoc.php
  • add to config.php the line
    include_once($FarmD/cookbook/nzdoc.php);

Usage

Place the directive, as described below, in your PmWiki page.

The recipe provides a page variable {$NZDoCVersion} which contains the current version, and page variable $NZDoC for a (:if enabled NZDoC:) recipe installation check.

DoC regions

You have to ask to find these out, they are not provided in DoC's information about the API

CODEREGION
NZ-NTLNorthland
NZ-AUKAuckland
NZ-WKOWaikato
DOC-CORCoromandel
NZ-BOPBay of Plenty
NZ-GISEast Coast
NZ-TKITaranaki
NZ-MWTManawatu/Whanganui
DOC-CNICentral North Island
NZ-HKBHawke's Bay
NZ-WGNWellington/Kapiti
DOC-WPAWairarapa
NZ-CITChatham Islands
NZ-NSNNelson/Tasman
NZ-MBHMarlborough
NZ-WTCWest Coast
NZ-CANCanterbury
NZ-OTAOtago
NZ-STLSouthland
DOC-FILFiordland

Configuration

(:nzdoc '''type'''=''type'' 
'''content'''=''detail''
'''id'''=''identifier''
'''height'''=''pixels'' '''width'''=''pixels'' 
'''float'''=''left|right'' '''clear'''=''both|right|left'':) 
'''h'''=''level''
  • type= -- hut, track, campsite
  • content= -- alert, detail, region, all, dump, check, list
  • id= -- id for hut, track, campsite, or region
  • clear= -- clear image to left, right, or both
  • h= -- heading level, must be 3 or greater

Parameters are case-insensitive.

config.php settings

You can change the following in config.php. For example

$NZDoCAPIKey = 10; # key obtained from DoC API website
$NZDoCDebug = true; # results may vary

Styling output

Style the output using CSS. Add the css to local.css. To assist the following classes are applied

  • output is encapsulated by <div class='nzdoc':>
  • tables are defined with <table class='nzdocdata'>
  • the following classes are used for data: nzdocalert, inspect the html output for other classes

DoC API notes

The DoC API offering the following resources:
v2-huts [ Base URL: api.doc.govt.nz/v2 ]
/huts
[{assetId, name, status, region, lat, lon}]
/huts/alerts
[{assetId, name, alerts[{displayDate, heading, detail}]}]
Notes: detail has html formatting; displayDate is duplicated in text; ''Bug: URLS are not fully qualified;
/huts/{id}/alerts
[{assetId, name, alerts[{displayDate, heading, detail}]}]
/huts/{id}/detail
{assetId, name, locationString, numberOfBunks, facilities[], hutCategory, proximityToRoadEnd, bookable, introduction, introductionThumbnail, staticLink, region, place, status, lat, lon}
Notes: bookable is a boolean
v2-campsites [ Base URL: api.doc.govt.nz/v2 ]
/campsites
[{assetId, name, status, region, lat, lon}]
/campsites/alerts
[{assetId, name, alerts[{displayDate, heading, detail}]}]
/campsites/{id}/alerts
[{assetId, name, alerts[{displayDate, heading, detail}]}]
Notes: detail has html formatting; displayDate is duplicated in text; Bug: URLS are not fully qualified;
/campsites/{id}/detail
{assetId, name, locationString, introduction, introductionThumbnail, landscape[], campsiteCategory, access[]; facilities[], activities[], dogsAllowed, numberOfPoweredSites, numberOfUnpoweredSites, bookable, staticLink, region, place, status, lat, lon
Notes: bookable is a boolean
v1-tracks [ Base URL: api.doc.govt.nz/v1 ]
/tracks
/tracks/alerts
/tracks/region/{regionId}
/tracks/{id}/alerts
/tracks/{id}/detail

DoC API quirks

Some facilities shown on DoCs website are not available, e.g. Lodges.

Change log / Release notes

2020-06-10 Initial version

See also

Contributors

Special thanks to Gavin Harriss for the use of NZ Topo Map

Comments

See discussion at NZDoC-Talk?

tahi Page last modified on 2024 Oct 06 12:02

Edit - History - Recent Changes - WikiHelp - Search - DoC API -> mailto:?Subject="KiwiWiki: NZ Do C"&Body="From KiwiWiki: NZ Do C (https://kiwiwiki [period] nz/Cookbook/NZDoC) - Use [[https://api [period] doc [period] govt [period] nz/getting-started to retrieve campsites, huts, and tracks information to display in PmWiki" | email page as link ]]