From 2334576f180bf15618487e65915d4697cacc7388 Mon Sep 17 00:00:00 2001 From: Mihkel Oviir Date: Wed, 29 Apr 2020 18:04:48 +0300 Subject: [PATCH] #91 detailed cache information and logs --- package-lock.json | 28 +++--- src/config/settings.js | 17 ++-- src/config/translations.json | 16 +-- src/geop/components/featureinfo/Popup.js | 1 + src/geop/components/geocache/Geocache.js | 12 ++- src/geop/components/geocache/GeocacheGPX.js | 39 +++++++- src/geop/components/geocache/GeocacheInfo.js | 99 +++++++++++++++++++ .../components/geocache/GeocacheInfo.styl | 38 +++++++ src/geop/components/geocache/GeocacheList.js | 57 ----------- .../components/geocache/GeocacheList.styl | 14 --- src/geop/components/geocache/GeopeitusJSON.js | 78 ++++++++------- 11 files changed, 257 insertions(+), 142 deletions(-) create mode 100644 src/geop/components/geocache/GeocacheInfo.js create mode 100644 src/geop/components/geocache/GeocacheInfo.styl delete mode 100644 src/geop/components/geocache/GeocacheList.js delete mode 100644 src/geop/components/geocache/GeocacheList.styl diff --git a/package-lock.json b/package-lock.json index afc00aa..7ae18fe 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2043,7 +2043,7 @@ }, "chalk": { "version": "1.1.3", - "resolved": "http://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", "dev": true, "requires": { @@ -2205,7 +2205,7 @@ }, "babel-plugin-syntax-object-rest-spread": { "version": "6.13.0", - "resolved": "http://registry.npmjs.org/babel-plugin-syntax-object-rest-spread/-/babel-plugin-syntax-object-rest-spread-6.13.0.tgz", + "resolved": "https://registry.npmjs.org/babel-plugin-syntax-object-rest-spread/-/babel-plugin-syntax-object-rest-spread-6.13.0.tgz", "integrity": "sha1-/WU28rzhODb/o6VFjEkDpZe7O/U=", "dev": true }, @@ -2461,7 +2461,7 @@ }, "browserify-aes": { "version": "1.2.0", - "resolved": "http://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz", + "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz", "integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==", "dev": true, "requires": { @@ -2498,7 +2498,7 @@ }, "browserify-rsa": { "version": "4.0.1", - "resolved": "http://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz", + "resolved": "https://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz", "integrity": "sha1-IeCr+vbyApzy+vsTNWenAdQTVSQ=", "dev": true, "requires": { @@ -3104,7 +3104,7 @@ }, "create-hash": { "version": "1.2.0", - "resolved": "http://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz", + "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz", "integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==", "dev": true, "requires": { @@ -3117,7 +3117,7 @@ }, "create-hmac": { "version": "1.1.7", - "resolved": "http://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz", + "resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz", "integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==", "dev": true, "requires": { @@ -3218,7 +3218,7 @@ }, "css-select": { "version": "1.2.0", - "resolved": "http://registry.npmjs.org/css-select/-/css-select-1.2.0.tgz", + "resolved": "https://registry.npmjs.org/css-select/-/css-select-1.2.0.tgz", "integrity": "sha1-KzoRBTnFNV8c2NMUYj6HCxIeyFg=", "dev": true, "requires": { @@ -3495,7 +3495,7 @@ }, "diffie-hellman": { "version": "5.0.3", - "resolved": "http://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz", + "resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz", "integrity": "sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==", "dev": true, "requires": { @@ -5582,7 +5582,7 @@ }, "html-webpack-plugin": { "version": "3.2.0", - "resolved": "http://registry.npmjs.org/html-webpack-plugin/-/html-webpack-plugin-3.2.0.tgz", + "resolved": "https://registry.npmjs.org/html-webpack-plugin/-/html-webpack-plugin-3.2.0.tgz", "integrity": "sha1-sBq71yOsqqeze2r0SS69oD2d03s=", "dev": true, "requires": { @@ -6060,7 +6060,7 @@ }, "is-obj": { "version": "1.0.1", - "resolved": "http://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", + "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", "integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8=", "dev": true }, @@ -6613,7 +6613,7 @@ }, "media-typer": { "version": "0.3.0", - "resolved": "http://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=", "dev": true }, @@ -8014,7 +8014,7 @@ }, "readable-stream": { "version": "2.3.6", - "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "dev": true, "requires": { @@ -8606,7 +8606,7 @@ }, "sha.js": { "version": "2.4.11", - "resolved": "http://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", + "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", "dev": true, "requires": { @@ -9560,7 +9560,7 @@ }, "through": { "version": "2.3.8", - "resolved": "http://registry.npmjs.org/through/-/through-2.3.8.tgz", + "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", "dev": true }, diff --git a/src/config/settings.js b/src/config/settings.js index c33aa2d..163f1ad 100644 --- a/src/config/settings.js +++ b/src/config/settings.js @@ -64,16 +64,21 @@ export const apiUrls = { } } export const geocache = { - authUrl: 'http://geopeitus.ee', + authUrl: 'https://geopeitus.ee', downloadUrl: { - page: 'http://www.geopeitus.ee/index.php?p=300', - geojson: 'http://www.geopeitus.ee/index.php?p=301&status[]=1&format=2', + page: 'https://www.geopeitus.ee/index.php?p=300', + geojson: 'https://www.geopeitus.ee/index.php?p=301&status[]=1&format=2', gpx: { - gpxActive: 'http://www.geopeitus.ee/index.php?p=301&status[]=1&format=1', - gpxAll: 'http://www.geopeitus.ee/index.php?p=301&status[]=1&status[]=2&status[]=3&format=1' + gpxActive: 'https://www.geopeitus.ee/index.php?p=301&status[]=1&status[]=3&format=1', + gpxActiveLogs: 'https://www.geopeitus.ee/index.php?p=301&status[]=1&status[]=3&format=1&gpx_events=2', + gpxAll: 'https://www.geopeitus.ee/index.php?p=301&status[]=1&status[]=2&status[]=3&format=1' } }, - cacheUrl: 'http://geopeitus.ee/aare/', + cacheUrl: 'https://geopeitus.ee/aare/', + logUrl: { + 'geopeitus.ee': 'https://www.geopeitus.ee/logs/new/c/{id}', + 'geocaching.com': 'https://www.geocaching.com/seek/log.aspx?ID={id}&lcn=1' + }, radiusStyle: { maxResolution: 30, radius: 160 diff --git a/src/config/translations.json b/src/config/translations.json index 6a21b67..74f0a09 100644 --- a/src/config/translations.json +++ b/src/config/translations.json @@ -64,7 +64,7 @@ "Find streetview link and measure tools from context menu.": "Find streetview link and measure tools from context menu.", "Found": "Found", "Geocache importing": "Geocache importing", - "GeocacheList": "Caches", + "GeocacheInfo": "Info", "GeocacheLoader": "", "Geocaches": "Geocaches", "Geocache|Event Cache": "Event Cache", @@ -75,13 +75,14 @@ "Geocache|Unknown Cache": "Unknown Cache", "Geocache|Virtual Cache": "Virtual Cache", "Geocache|Webcam Cache": "Webcam Cache", - "Geocache|Whereigo Cache": "Whereigo Cache", + "Geocache|Wherigo Cache": "Wherigo Cache", "Geop is progressive web application with partial offline support.": "Geop is progressive web application with partial offline support.", "Geotrip": "Geotrip", "Geotrip reordered by optimum path": "Geotrip reordered by optimum path", "Go to": "Go to", "gpxActive": "Active caches", - "gpxAll": "All caches (active, archived, unavailable)", + "gpxActiveLogs": "Active caches with logs", + "gpxAll": "All caches (with archived, w.o logs)", "here": "here", "Hiking": "Hiking", "Imported": "Imported", @@ -100,6 +101,7 @@ "Less than 2 pair of coordinates, aborting!": "Less than 2 pair of coordinates, aborting!", "Limit address search with comma separated list of country codes (ee,fi - Estonia, Finland). Empty means no limit.": "Limit address search with comma separated list of country codes (ee,fi - Estonia, Finland). Empty means no limit.", "Location information is unavailable.": "Location information is unavailable.", + "Logs": "Logs", "Map": "Map", "Measure": "Measure", "Micro": "Micro", @@ -252,7 +254,7 @@ "Find streetview link and measure tools from context menu.": "Parema kliki menüüst leiad tänavavaate ja mõõtmise tööriistad.", "Found": "Leitud", "Geocache importing": "Aarete importimine", - "GeocacheList": "Aarded", + "GeocacheInfo": "Info", "GeocacheLoader": "", "Geocaches": "Aarded", "Geocache|Event Cache": "Sündmusaare", @@ -263,13 +265,14 @@ "Geocache|Unknown Cache": "Mõistatusaare", "Geocache|Virtual Cache": "Virtuaalne aare", "Geocache|Webcam Cache": "Veebikaamera aare", - "Geocache|Whereigo Cache": "Whereigo aare", + "Geocache|Wherigo Cache": "Wherigo aare", "Geop is progressive web application with partial offline support.": "Geop on progressiivne veebirakendus (PWA) osalise võrguta töötamise toega.", "Geotrip": "Geotuur", "Geotrip reordered by optimum path": "Geotuur järjestatud lühima teekonna järgi", "Go to": "Mine", "gpxActive": "Aktiivsed aarded", - "gpxAll": "Kõik aarded (aktiivsed, arhiveeritud, ajutiselt kättesaamatud)", + "gpxActiveLogs": "Aktiivsed aarded koos logidega", + "gpxAll": "Kõik aarded (k.a arhiveeritud, ilma logideta)", "here": "siit", "Hiking": "Matk", "Imported": "Imporditud", @@ -288,6 +291,7 @@ "Less than 2 pair of coordinates, aborting!": "Peab olema vähemalt kaks punkti, lõpetan!", "Limit address search with comma separated list of country codes (ee,fi - Estonia, Finland). Empty means no limit.": "Piira aadressiotsingut riigiti. Mitme riigi otsingu jaoks eralda komaga (ee,fi - Eesti, Soome). Tühi otsib üle maailma.", "Location information is unavailable.": "Asukoha info ei ole kättesaadav.", + "Logs": "Logid", "Map": "Kaart", "Measure": "Mõõda", "Micro": "Mikro", diff --git a/src/geop/components/featureinfo/Popup.js b/src/geop/components/featureinfo/Popup.js index 33157a5..269334f 100644 --- a/src/geop/components/featureinfo/Popup.js +++ b/src/geop/components/featureinfo/Popup.js @@ -89,6 +89,7 @@ class Popup extends Component { popContent.onHide(evt) }) this.el.popover('show') + setState('popup/show', { layerId: hit[0].get('id'), feature: hit[1] }) } open (e) { let coords = e.coordinate diff --git a/src/geop/components/geocache/Geocache.js b/src/geop/components/geocache/Geocache.js index 1c6e088..7f319bc 100644 --- a/src/geop/components/geocache/Geocache.js +++ b/src/geop/components/geocache/Geocache.js @@ -7,7 +7,7 @@ import { toLonLat } from 'ol/proj' import Component from 'Geop/Component' import Sidebar from 'Components/sidebar/Sidebar' import GeocacheLoader from './GeocacheLoader' -import GeocacheList from './GeocacheList' +import GeocacheInfo from './GeocacheInfo' import Filter from './Filter' import Geotrip from './Geotrip' import { createStyle } from 'Components/layer/StyleBuilder' @@ -30,7 +30,6 @@ const state = { layerOnMap: false, styleCache: {}, styleConfig: cacheConf.styles, - currentUser: getState('app/account'), cacheFormatParser: null, stat: { 'Not Found': 'far fa-square', @@ -67,7 +66,7 @@ class Geocache extends Component { position: 'left', components: { GeocacheLoader, - GeocacheList, + GeocacheInfo, Filter, Geotrip }, @@ -111,7 +110,10 @@ class Geocache extends Component { } }) state.layer.getSource().on('clear', listenLayer) - onchange('geocache/filter', listenLayer) + onchange('geocache/filter', () => { + listenLayer() + setState('layerchange', ['overlays', state.layer.get('id')]) + }) listenLayer() } createLayer (layer = null) { @@ -292,7 +294,7 @@ export function importCaches (features, disableLog = false) { features: features, newCacheDays: cacheConf.newCacheDays, mapping: cacheConf.mapping, - user: state.currentUser, + user: getState('app/account'), uid: uid, url: cacheConf.cacheUrl, date: formatDate diff --git a/src/geop/components/geocache/GeocacheGPX.js b/src/geop/components/geocache/GeocacheGPX.js index fcfd014..ba7425d 100644 --- a/src/geop/components/geocache/GeocacheGPX.js +++ b/src/geop/components/geocache/GeocacheGPX.js @@ -1,15 +1,21 @@ export default { test: features => { - const test = features.filter(f => { + return features.filter(f => { return (f.get('wpt') && f.get('wpt')['groundspeak:cache']) - }) - return test.length > 0 + }).length > 0 }, formatFeatures: opts => { const today = new Date() opts.features.forEach(feature => { const wpt = feature.get('wpt') - if (wpt['groundspeak:cache']) { + // format always + if (feature.get('isCache')) { + if (opts.user && opts.user === feature.get('owner')) { + const fstatus = 'Geocache Owner' + feature.set('fstatus', opts.mapping.fstatusGPX[fstatus] || fstatus) + } + } + if (typeof feature.get('isCache') === 'undefined' && wpt['groundspeak:cache']) { const cacheData = {} Object.keys(wpt['groundspeak:cache']).forEach(i => { if (i !== '_text') { @@ -56,12 +62,35 @@ export default { ) const newCache = (feature.get('fstatus') === 'Not Found' && testDate > today) ? 'New Cache' : null feature.set('newCache', newCache) - } else { + // description + if (cacheData.long_description) { + feature.set('description', cacheData.long_description) + } + if (cacheData.logs && cacheData.logs['groundspeak:log']) { + // in case of one log, it is object, not array + if (typeof cacheData.logs['groundspeak:log'] === 'object' && '@id' in cacheData.logs['groundspeak:log']) { + cacheData.logs['groundspeak:log'] = [cacheData.logs['groundspeak:log']] + } + feature.set('logs', cacheData.logs['groundspeak:log'].map(log => { + return { + type: log['groundspeak:type']['_text'], + date: log['groundspeak:date']['_text'], + finder: log['groundspeak:finder']['_text'], + text: log['groundspeak:text']['_text'] + } + })) + } + feature.set('wpt', { + 'groundspeak:cache': true + }) + } + if (typeof feature.get('isCachePoint') === 'undefined' && !wpt['groundspeak:cache']) { // assume waypoint // name feature.set('name', feature.get('type')) // url feature.set('url', wpt.url['_text']) + feature.set('isCachePoint', true) } if (!feature.getId()) { feature.setId(opts.uid()) diff --git a/src/geop/components/geocache/GeocacheInfo.js b/src/geop/components/geocache/GeocacheInfo.js new file mode 100644 index 0000000..ee10831 --- /dev/null +++ b/src/geop/components/geocache/GeocacheInfo.js @@ -0,0 +1,99 @@ +import { t } from 'Utilities/translate' +import { geocache as cacheConf } from 'Conf/settings' +import { onchange } from 'Utilities/store' +import { formatDate } from 'Utilities/util' +import Component from 'Geop/Component' +import './GeocacheInfo.styl' +import $ from 'jquery' + +class GeocacheInfo extends Component { + constructor (target) { + super(target) + this.id = 'tab-cacheinfo' + this.icon = 'fa fa-cube' + this.el = $(` +
+
+ `) + this.state = { + layer: null, + cache: null, + logType: { + 'Found it': 'found', + "Didn't find it": 'notfound', + 'Needs Maintenance': 'problem' + } + } + this.create() + onchange('geocache/loadend', layer => { + this.state.layer = layer + }) + onchange('popup/show', ({ layerId, feature }) => { + if (this.state.layer && this.state.layer.get('id') === layerId) { + this.state.cache = feature + this.render() + } + }) + } + render () { + this.el.html(` + + ${(this.state.layer && this.state.cache) + ? this.renderLogs() : ''} + `) + // fix all images + this.el.find('img').addClass('img-fluid') + } + renderCacheInfo () { + const info = this.state.layer.get('_featureInfo') + const title = typeof info.title === 'function' ? info.title(this.state.cache) : info.title + const content = typeof info.content === 'function' ? info.content(this.state.cache) : info.content + const description = this.state.cache.get('description') + return ` +
  • + ${title} +
  • +
  • + ${content} +
  • + ${description ? ` +
  • + ${description} +
  • ` : ''}` + } + renderLogs () { + const logs = this.state.cache.get('logs') || [] + const cacheUrl = this.state.cache.get('url') + const key = Object.keys(cacheConf.logUrl).find(key => cacheUrl.indexOf(key) > -1) + const logUrl = cacheConf.logUrl[key].replace('{id}', this.state.cache.get('id')) + + return ` + ` + } +} + +export default GeocacheInfo diff --git a/src/geop/components/geocache/GeocacheInfo.styl b/src/geop/components/geocache/GeocacheInfo.styl new file mode 100644 index 0000000..aa6dc28 --- /dev/null +++ b/src/geop/components/geocache/GeocacheInfo.styl @@ -0,0 +1,38 @@ +#tab-cacheinfo + .header + white-space: nowrap + overflow: hidden + font-weight: bold + a + font-weight: bold + color: inherit + .tools + display: none + .content + .toggle-found + cursor: pointer + margin-bottom: 0 + .distance + cursor: pointer + position: absolute + bottom: 0.5rem + right: 0.75rem + .description + overflow-wrap: break-word + word-wrap: break-word + -ms-word-break: break-all + word-break: break-word + -ms-hyphens: auto + -moz-hyphens: auto + -webkit-hyphens: auto + hyphens: auto + .fstatus + color: #ddd + font-size: 0.8rem + padding: 4px 6px + .fstatus.found + color: #4c9900 + .fstatus.notfound + color: #206fd6 + .fstatus.problem + color: red diff --git a/src/geop/components/geocache/GeocacheList.js b/src/geop/components/geocache/GeocacheList.js deleted file mode 100644 index c796cad..0000000 --- a/src/geop/components/geocache/GeocacheList.js +++ /dev/null @@ -1,57 +0,0 @@ -import { t } from 'Utilities/translate' -import { onchange } from 'Utilities/store' -import { formatDate, formatTime } from 'Utilities/util' -import Component from 'Geop/Component' -import './GeocacheList.styl' -import $ from 'jquery' - -class GeocacheLoader extends Component { - constructor (target) { - super(target) - this.id = 'tab-cachelist' - this.icon = 'fa fa-cube' - this.el = $(` -
    -
    - `) - this.state = { - collection: [] - } - this.create() - onchange('geocache/loadend', layer => { - this.state.collection = layer.getSource().getFeatures() - this.render() - }) - } - render () { - this.el.html(` - - `) - } - renderList (collection) { - return collection.map((f, i) => { - return ` -
  • - ${t(f.get('name'))} - - ${f.get('fstatus_timestamp') - ? `
    - ${t('Found')}: - ${formatDate(f.get('fstatus_timestamp'), true) + ' ' + - formatTime(f.get('fstatus_timestamp'))}
    ` : ''} -
  • ` - }).join('') - } -} - -export default GeocacheLoader diff --git a/src/geop/components/geocache/GeocacheList.styl b/src/geop/components/geocache/GeocacheList.styl deleted file mode 100644 index 8d3f669..0000000 --- a/src/geop/components/geocache/GeocacheList.styl +++ /dev/null @@ -1,14 +0,0 @@ -#tab-cachelist - ul - li - .fstatus - position: absolute - top: 0.75rem - right: 0.75rem - color: #ddd - font-size: 0.8rem - padding: 4px 6px - .fstatus.found - color: #4c9900 - .timestamp - padding-left: 23px diff --git a/src/geop/components/geocache/GeopeitusJSON.js b/src/geop/components/geocache/GeopeitusJSON.js index 1ae1bfc..0b3e6f7 100644 --- a/src/geop/components/geocache/GeopeitusJSON.js +++ b/src/geop/components/geocache/GeopeitusJSON.js @@ -1,50 +1,58 @@ export default { test: features => { - const test = features.filter(f => { + return features.filter(f => { return ( typeof f.get('fstatus') !== 'undefined' && typeof f.get('type') !== 'undefined' && + typeof f.get('wpt') === 'undefined' && f.get('date_hidden') ) - }) - return test.length > 0 + }).length > 0 }, formatFeatures: opts => { const today = new Date() opts.features.forEach(feature => { - // id - // type - feature.set('type', opts.mapping.type[feature.get('type')] || feature.get('type')) - feature.set('isCache', feature.get('type').substring(0, 8) === 'Geocache') - // fstatus - feature.set('fstatus', opts.mapping.fstatusJSON[feature.get('fstatus')] || feature.get('fstatus')) - // status ? currently not available - feature.set('status', 'Available') - // time - feature.set('time', feature.get('date_hidden')) - feature.unset('date_hidden') - // name - // url - feature.set('url', opts.url + feature.get('id')) - // owner - feature.set('owner', feature.get('user_id')) - feature.unset('user_id') - // container - feature.set('container', opts.mapping.container[feature.get('size')] || feature.get('size')) - feature.unset('size') - // difficulty - // terrain - // new cache - const date = new Date(feature.get('date_hidden')) - const testDate = new Date( - date.getFullYear(), - date.getMonth(), - date.getDate() + opts.newCacheDays - ) - const newCache = (feature.get('fstatus') === 'Not Found' && testDate > today) ? 'New Cache' : null - if (!feature.get('newCache')) { - feature.set('newCache', newCache) + // format always + if (feature.get('isCache')) { + if (opts.user && opts.user === feature.get('owner')) { + const fstatus = 'Geocache Owner' + feature.set('fstatus', opts.mapping.fstatusGPX[fstatus] || fstatus) + } + } + if (typeof feature.get('isCache') === 'undefined') { + // type + feature.set('type', opts.mapping.type[feature.get('type')] || feature.get('type')) + feature.set('isCache', feature.get('type').substring(0, 8) === 'Geocache') + // fstatus + feature.set('fstatus', opts.mapping.fstatusJSON[feature.get('fstatus')] || feature.get('fstatus')) + // status ? currently not available + feature.set('status', 'Available') + // time + feature.set('time', feature.get('date_hidden')) + // name + // url + feature.set('url', opts.url + feature.get('id')) + // owner + feature.set('owner', feature.get('user_id')) + feature.unset('user_id') + // container + feature.set('container', opts.mapping.container[feature.get('size')] || feature.get('size')) + feature.unset('size') + // difficulty + // terrain + // new cache + const date = new Date(feature.get('date_hidden')) + const testDate = new Date( + date.getFullYear(), + date.getMonth(), + date.getDate() + opts.newCacheDays + ) + const newCache = (feature.get('fstatus') === 'Not Found' && testDate > today) ? 'New Cache' : null + if (!feature.get('newCache')) { + feature.set('newCache', newCache) + } } + // id if (!feature.getId()) { feature.setId(opts.uid())