Permalink
Browse files

feat(ltData): fetch object location via GeoData

  • Loading branch information...
simon04 committed Mar 11, 2018
1 parent c1d43f5 commit d4068efe40ebe2f1e76f5b1296df25f9ce881752
Showing with 14 additions and 3 deletions.
  1. +14 −3 src/static/app/api/ltData.js
@@ -24,13 +24,15 @@ export default function data($http, $httpParamSerializer, $parse, $sce, $q, limi
}
const params = {
prop: 'coordinates',
coprop: 'type|name',
coprimary: 'all',
titles: titles.join('|').replace(/_/g, ' ')
};
return $query(params).then(data => {
const pages = (data && data.query && data.query.pages) || {};
const coordsGetter = $parse('{lat: coordinates[0].lat, lng: coordinates[0].lon}');
return Object.keys(pages).map(pageid => {
const page = pages[pageid];
const coordinates = page.coordinates || [];
return {
pageid: parseInt(pageid),
file: page.title,
@@ -46,10 +48,19 @@ export default function data($http, $httpParamSerializer, $parse, $sce, $q, limi
return `${url}?width=1024`;
}
},
coordinates: new LatLng('Location', coordsGetter(page)),
objectLocation: new LatLng('Object location', {})
coordinates: new LatLng(
'Location',
toLatLng(coordinates.find(c => c.primary === '' && c.type === 'camera'))
),
objectLocation: new LatLng(
'Object location',
toLatLng(coordinates.find(c => c.type === 'object'))
)
};
});
function toLatLng(c) {
return angular.isObject(c) ? {lat: c.lat, lng: c.lon} : {};
}
});
}
function getCoordinatesChunkByChunk(titles) {

0 comments on commit d4068ef

Please sign in to comment.