added aggregated results
This commit is contained in:
1 parent
f6809a20e6
commit
0da4c99d9f
6 files changed
+122
-26
No files matched your search
@@ -1,32 +1,50 @@
|
||||
root = this;
|
||||
mapCenter =
|
||||
lat: 46.1227
|
||||
lng: -72.6169
|
||||
zoom: 7
|
||||
|
||||
getSingleDataUrl = (routeParams) ->
|
||||
url = "/api/#{ routeParams.server }/#{ routeParams.database }/#{ routeParams.collection }"
|
||||
if routeParams.query
|
||||
url = "#{url}/query/#{ routeParams.query }"
|
||||
return "#{ url }/idx/#{ Number(routeParams.idx) - 1 }"
|
||||
|
||||
getAllDataUrl = (routeParams) ->
|
||||
url = "/api/#{ routeParams.server }/#{ routeParams.database }/#{ routeParams.collection }"
|
||||
if routeParams.query
|
||||
url = "#{url}/query/#{ routeParams.query }"
|
||||
return "#{ url }/all"
|
||||
|
||||
getDocumentUrl = (routeParams, id) ->
|
||||
return "/#{ routeParams.server }/#{ routeParams.database }/#{ routeParams.collection }/_id/#{ id }"
|
||||
|
||||
transformListOfGeoJsonToGeometryCollection = (resData, routeParams) ->
|
||||
ret =
|
||||
type: "GeometryCollection"
|
||||
geometries: []
|
||||
for doc in resData.document
|
||||
geojson = doc[routeParams.key]
|
||||
if not geojson.properties
|
||||
geojson.properties = {}
|
||||
geojson.properties["_vulture_url_link"] = getDocumentUrl(routeParams, doc._id)
|
||||
ret.geometries.push(geojson)
|
||||
return ret
|
||||
|
||||
|
||||
root.controllers.controller('geojsonmapCtrl', ['$scope', '$routeParams', '$location', '$http', ($scope, $routeParams, $location, $http) ->
|
||||
$scope.geojson = {}
|
||||
$scope.geojsonData = {}
|
||||
$scope.idx = Number($routeParams.idx)
|
||||
$scope.center = # experimental point around Québec
|
||||
lat: 46.1227
|
||||
lng: -72.6169
|
||||
zoom: 7
|
||||
|
||||
url = "/api/#{ $routeParams.server }/#{ $routeParams.database }/#{ $routeParams.collection }"
|
||||
if $routeParams.query
|
||||
url = "#{url}/query/#{$routeParams.query}"
|
||||
url = "#{ url }/idx/#{$routeParams.idx - 1}"
|
||||
$http.get(url).then((res) ->
|
||||
$scope.geojson = res.data.document[$routeParams.key]
|
||||
if not $scope.geojson.properties
|
||||
$scope.geojson.properties = {}
|
||||
url = "/#{ $routeParams.server }/#{ $routeParams.database }/#{ $routeParams.collection }/_id/#{ res.data.document._id }"
|
||||
$scope.geojson.properties["_vulture_url_link"] = url
|
||||
$scope.meta = res.data.meta
|
||||
$scope.geojsonData =
|
||||
data: $scope.geojson
|
||||
style: undefined
|
||||
resetStyleOnMouseout: true
|
||||
)
|
||||
$scope.center = mapCenter
|
||||
|
||||
$scope.getAggredatedUrl = () ->
|
||||
url = "#/#{ $routeParams.server }/#{ $routeParams.database }/#{ $routeParams.collection }/idx/all"
|
||||
if $routeParams.query
|
||||
url = "#{url}/query/#{$routeParams.query}"
|
||||
"#{url}/geojson/#{$routeParams.key}"
|
||||
|
||||
|
||||
$scope.previousDocumentUrl = () ->
|
||||
url = "#/#{ $routeParams.server }/#{ $routeParams.database }/#{ $routeParams.collection }/idx/#{$scope.idx - 1}"
|
||||
if $routeParams.query
|
||||
@@ -44,6 +62,34 @@ root.controllers.controller('geojsonmapCtrl', ['$scope', '$routeParams', '$locat
|
||||
|
||||
$scope.$on "leafletDirectiveMap.geojsonClick", (ev, featureSelected, leafletEvent) ->
|
||||
$location.url(featureSelected.properties._vulture_url_link);
|
||||
|
||||
|
||||
$scope.initSingleDocument = ()->
|
||||
url = getSingleDataUrl($routeParams)
|
||||
$http.get(url).then (res) ->
|
||||
geojson = res.data.document[$routeParams.key]
|
||||
if not geojson.properties
|
||||
geojson.properties = {}
|
||||
geojson.properties["_vulture_url_link"] = getDocumentUrl($routeParams, res.data.document._id)
|
||||
$scope.meta = res.data.meta
|
||||
$scope.geojsonData =
|
||||
data: geojson
|
||||
style: undefined
|
||||
resetStyleOnMouseout: true
|
||||
|
||||
$scope.initAllDocuments = () ->
|
||||
url = getAllDataUrl($routeParams)
|
||||
$http.get(url).then (res) ->
|
||||
$scope.meta = res.data.meta
|
||||
$scope.geojsonData =
|
||||
data: transformListOfGeoJsonToGeometryCollection(res.data, $routeParams)
|
||||
style: undefined
|
||||
resetStyleOnMouseout: true
|
||||
|
||||
if $routeParams.idx
|
||||
$scope.mode = 'single_document'
|
||||
$scope.initSingleDocument()
|
||||
else
|
||||
$scope.mode = 'all'
|
||||
$scope.initAllDocuments()
|
||||
])
|
||||
|
||||
@@ -11,7 +11,7 @@ root.controllers.controller('topBarCtrl', ['$scope', '$location', ($scope, $loca
|
||||
$scope.path = joinArray($scope.path[0...6], $scope.path[7...-1])
|
||||
$scope.getHistoryUrl = (idx) ->
|
||||
ret = "#/" + ($scope.path[i] for i in [0...idx]).join("/")
|
||||
if _.indexOf(["idx", "geojson", "query", "_id", "field"], $scope.path[idx]) != -1
|
||||
if _.indexOf(["idx", "geojson", "query", "_id", "field", "all"], $scope.path[idx]) != -1
|
||||
return ""
|
||||
if idx == 0
|
||||
ret += "servers"
|
||||
|
||||
@@ -19,7 +19,9 @@ config(['$routeProvider', ($routeProvider) ->
|
||||
$routeProvider.when('/:server/:database/:collection/_id/:id/field/:field', {templateUrl: 'partials/field.html', controller: 'fieldCtrl'})
|
||||
$routeProvider.when('/:server/:database/:collection/idx/:idx', {templateUrl: 'partials/document.html', controller: 'documentCtrl'})
|
||||
$routeProvider.when('/:server/:database/:collection/idx/:idx/query/:query', {templateUrl: 'partials/document.html', controller: 'documentCtrl'})
|
||||
$routeProvider.when('/:server/:database/:collection/idx/all/geojson/:key', {templateUrl: 'partials/geojsonmap.html', controller: 'geojsonmapCtrl'})
|
||||
$routeProvider.when('/:server/:database/:collection/idx/:idx/geojson/:key', {templateUrl: 'partials/geojsonmap.html', controller: 'geojsonmapCtrl'})
|
||||
$routeProvider.when('/:server/:database/:collection/idx/all/query/:query/geojson/:key', {templateUrl: 'partials/geojsonmap.html', controller: 'geojsonmapCtrl'})
|
||||
$routeProvider.when('/:server/:database/:collection/idx/:idx/query/:query/geojson/:key', {templateUrl: 'partials/geojsonmap.html', controller: 'geojsonmapCtrl'})
|
||||
|
||||
$routeProvider.otherwise({redirectTo: '/servers'})
|
||||
|
||||
@@ -1,13 +1,25 @@
|
||||
<div class="row">
|
||||
<div class="row" ng-show="mode=='single_document'">
|
||||
<div class="large-12 columns" style="text-align: center;">
|
||||
<a class="fa fa-chevron-left" ng-href="{{ previousDocumentUrl() }}" ng-show="{{ hasPreviousDocument() }}"></a>
|
||||
<kbd>{{idx}} / {{ meta.count}}</kbd>
|
||||
<kbd>{{idx}} / {{ meta.count }}</kbd>
|
||||
<a class="fa fa-chevron-right" ng-href="{{ nextDocumentUrl() }}"></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row" ng-show="mode=='all'">
|
||||
<div class="large-12 columns" style="text-align: center;">
|
||||
<span>Showing a data set of {{geojsonData.data.geometries.length}} datum.</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="columns large-12">
|
||||
<leaflet width="100%" height="500px" geojson="geojsonData" center="center"></leaflet>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row" ng-show="mode=='single_document' && idx + meta.count < 1000">
|
||||
<div class="large-12 columns" style="text-align: center;" >
|
||||
<a ng-href="{{ getAggredatedUrl() }}">Aggregated representation</a>
|
||||
</div>
|
||||
</div>
|
||||
Reference in new issue
Block a user