nakarte

Source code of https://map.sikmir.ru (fork)
git clone git://git.sikmir.ru/nakarte
Log | Files | Refs | LICENSE

commit 617f50067ca7f684c4adfacc5dabf9672dd09cde
parent b794d5ca106966aac16e328a22b48f0ab62d127c
Author: Sergej Orlov <wladimirych@gmail.com>
Date:   Sun,  3 Apr 2022 22:45:18 +0200

tracks: remove support for loading movescount moves and routes

Movescount was closed

Diffstat:
Msrc/lib/leaflet.control.track-list/lib/services/index.js | 3---
Dsrc/lib/leaflet.control.track-list/lib/services/movescount.js | 116-------------------------------------------------------------------------------
Msrc/lib/leaflet.control.track-list/track-list.js | 2+-
Mtest/test_track_load.js | 3---
Dtest/track_load_data/testcases/movescount_route_not_exists.json | 5-----
Dtest/track_load_data/testcases/movescount_route_private.json | 12------------
Dtest/track_load_data/testcases/movescount_route_with_title.json | 31-------------------------------
7 files changed, 1 insertion(+), 171 deletions(-)

diff --git a/src/lib/leaflet.control.track-list/lib/services/index.js b/src/lib/leaflet.control.track-list/lib/services/index.js @@ -6,7 +6,6 @@ import Strava from './strava'; import Tracedetrail from './tracedetrail'; import {YandexRuler} from './yandex'; import {NakarteTrack, NakarteUrl} from './nakarte'; -import {MovescountMove, MovescountRoute} from './movescount'; import {GarminActivity, GarminRoute} from './garmin'; import {SportsTrackerActivity} from './sportstracker'; import OpenStreetMapRu from './openstreetmapRu'; @@ -21,8 +20,6 @@ const services = [ Osm, Strava, Tracedetrail, - MovescountMove, - MovescountRoute, GarminActivity, GarminRoute, SportsTrackerActivity, diff --git a/src/lib/leaflet.control.track-list/lib/services/movescount.js b/src/lib/leaflet.control.track-list/lib/services/movescount.js @@ -1,116 +0,0 @@ -import BaseService from './baseService'; -import urlViaCorsProxy from '~/lib/CORSProxy'; - -class MovescountBase extends BaseService { - isOurUrl() { - return this.urlRe.test(this.origUrl); - } -} - -class MovescountRoute extends MovescountBase { - urlRe = /^https?:\/\/(?:www\.)?movescount\.com\/([a-z]{2}\/)?map.*[?&]route=(\d+)/u; - - requestOptions() { - const m = this.urlRe.exec(this.origUrl); - const trackId = this.trackId = m[2]; - return [{ - url: urlViaCorsProxy(`http://www.movescount.com/Move/Route/${trackId}`), - options: { - responseType: 'json', - isResponseSuccess: (xhr) => xhr.status === 200 || xhr.status === 403 - }, - }]; - } - - parseResponse(responses) { - const response = responses[0]; - if (response.status === 403) { - return [{error: 'Movescount user disabled viewing this route'}]; - } - let name = `Movescount route ${this.trackId}`; - const data = response.responseJSON; - if (!data) { - return [{name, error: 'UNSUPPORTED'}]; - } - - let points = []; - let track = []; - - for (let i = 0; i < data.points.latitudes.length; i++) { - const latlng = { - lat: data.points.latitudes[i], - lng: data.points.longitudes[i] - }; - track.push(latlng); - const point = data.points.data[i]; - if (point) { - points.push({...latlng, name: point.name}); - } - } - - name = data.routeName ? data.routeName : name; - - return [{ - name, - points, - tracks: [track] - }]; - } -} - -class MovescountMove extends MovescountBase { - urlRe = /^https?:\/\/(?:www\.)?movescount\.com\/([a-z]{2}\/)?moves\/move(\d+)/u; - - requestOptions() { - const m = this.urlRe.exec(this.origUrl); - const trackId = this.trackId = m[2]; - return [ - { - url: urlViaCorsProxy(`http://www.movescount.com/Move/Track2/${trackId}`), - options: { - responseType: 'json', - isResponseSuccess: (xhr) => xhr.status === 200 || xhr.status === 403 - } - }, - { - url: urlViaCorsProxy(`https://www.movescount.com/moves/move${trackId}`), - options: { - isResponseSuccess: (xhr) => xhr.status === 200 || xhr.status === 403 || xhr.status === 404 - } - } - ]; - } - - parseResponse(responses) { - const [trackResponse, pageResponse] = responses; - if (trackResponse.status === 403) { - return [{error: 'Movescount user disabled viewing this activity'}]; - } - let name = `Movescount move ${this.trackId}`; - const data = trackResponse.responseJSON; - if (!data) { - return [{name, error: 'UNSUPPORTED'}]; - } - - const track = data.TrackPoints.map((trackPoint) => ({ - lat: trackPoint.Latitude, - lng: trackPoint.Longitude - }) - ); - - const dom = (new DOMParser()).parseFromString(pageResponse.response, "text/html"); - try { - const title = dom.querySelector('title').text.trim(); - name = title ? title : name; - } catch (_) { - // use previously constructed name - } - - return [{ - name, - tracks: [track] - }]; - } -} - -export {MovescountRoute, MovescountMove}; diff --git a/src/lib/leaflet.control.track-list/track-list.js b/src/lib/leaflet.control.track-list/track-list.js @@ -130,7 +130,7 @@ L.Control.TrackList = L.Control.extend({ <div class="leaflet-control-content"> <div class="header"> <div class="hint" - title="gpx kml Ozi zip YandexMaps Strava GPSLib Etomesto Movescount GarminConnect SportsTracker OSM Tracedetrail OpenStreetMap.ru Wikiloc"> + title="gpx kml Ozi zip YandexMaps Strava GPSLib Etomesto GarminConnect SportsTracker OSM Tracedetrail OpenStreetMap.ru Wikiloc"> gpx kml Ozi zip YandexMaps Strava <span class="formats-hint-more">&hellip;</span> </div> diff --git a/test/test_track_load.js b/test/test_track_load.js @@ -48,9 +48,6 @@ suite('Load tracks from services'); 'garmin_connect_route_with_title', 'garmin_connect_route_private', 'garmin_connect_route_not_exists', - 'movescount_route_with_title', - 'movescount_route_private', - 'movescount_route_not_exists', // 'gpslib_with_title', // 'gpslib_without_title', // 'gpslib_not_exists', diff --git a/test/track_load_data/testcases/movescount_route_not_exists.json b/test/track_load_data/testcases/movescount_route_not_exists.json @@ -1,4 +0,0 @@ -{ - "query": ["http://www.movescount.com/ru/map?route=561450712"], - "geodata": [{"error":"Movescount user disabled viewing this route"}] -} -\ No newline at end of file diff --git a/test/track_load_data/testcases/movescount_route_private.json b/test/track_load_data/testcases/movescount_route_private.json @@ -1,11 +0,0 @@ -{ - "query": [ - "http://www.movescount.com/ru/map?route=5615101", - "https://www.movescount.com/ru/map?route=5615101", - "http://movescount.com/ru/map?route=5615101", - "http://www.movescount.com/fr/map?route=5615101", - "http://www.movescount.com/ru/map?route=5615101", - "http://www.movescount.com/map?route=5615101" - ], - "geodata": [{"error":"Movescount user disabled viewing this route"}] -} -\ No newline at end of file diff --git a/test/track_load_data/testcases/movescount_route_with_title.json b/test/track_load_data/testcases/movescount_route_with_title.json @@ -1,31 +0,0 @@ -{ - "query": [ - "http://www.movescount.com/ru/map?route=5614507", - "http://www.movescount.com/fr/map?route=5614507", - "http://www.movescount.com/map?route=5614507", - "http://movescount.com/ru/map?route=5614507", - "https://www.movescount.com/ru/map?route=5614507", - "http://www.movescount.com/ru/map?route=5614507&lat=55.26588383711808&lon=38.863759835918586&zoom=11.649307666194886&activity=991&style=suunto-offroad", - "http://www.movescount.com/ru/map?lat=55.26588383711808&lon=38.863759835918586&zoom=11.649307666194886&activity=991&style=suunto-offroad&route=5614507" - ], - "geodata": [ - { - "name": "Test - HORNÁÍ", - "points": [ - {"lat": 56.5269602928, "lng": 28.9624775201, "name": "Point 1"}, - {"lat": 56.5270016156, "lng": 28.9624936972, "name": "WP-HORNÁÍ"} - ], - "tracks": [ - [ - {"lat": 56.5269457083, "lng": 28.9624827169}, - {"lat": 56.5269602928, "lng": 28.9624775201}, - {"lat": 56.5270105843, "lng": 28.9624504466}, - {"lat": 56.5270208102, "lng": 28.9624960441}, - {"lat": 56.5270130988, "lng": 28.9625022467}, - {"lat": 56.5270016156, "lng": 28.9624936972}, - {"lat": 56.5270193852, "lng": 28.9625258837} - ] - ] - } - ] -}