Browse Source

improve pie markers system, add extra layer of this type

master
o.moresis 2 years ago
parent
commit
75deba74ac
  1. 33
      public/js/annual_fisheries.js
  2. 10
      public/js/constants.js
  3. 9
      public/js/extras.js
  4. 17
      public/js/layers.js
  5. 7
      public/js/treeview.js
  6. 3
      src/Controllers/InterfaceController.php
  7. 36
      src/Controllers/StatsController.php
  8. 4
      src/Routing/controls.php

33
public/js/annual_fisheries.js

@ -1,17 +1,22 @@ @@ -1,17 +1,22 @@
function createPie(data, year) {
console.debug(data);
var charts = L.featureGroup();
let features = data.features.filter(f => {
return f.properties.YR == year;
});
let newData = {};
features.forEach(f => {
let latlng = f.geometry.coordinates;
for (property in f.properties) {
const mapKey = fisheriesMap.get(property);
if (mapKey) {
newData[mapKey] = f.properties[property];
}
}
for (var i = 0; i < data.features.length; i++) {
  var d = data.features[i].properties;
var latlng = data.features[i].geometry.coordinates;
  if (d.YR == year) {
    var pieData = {values: [
      d.TrawlPerc,
      d.PursesPerc,
      d.BoatsePerc,
d.otherPerc
    ], labels: ['trawl', 'purses', 'boatse', 'other']};
    var pieData = {values: Object.values(newData), labels: Object.keys(newData)};
    let chart = new PieChartMarker([latlng[1], latlng[0]], pieData, {
icon: L.divIcon({className: 'leaflet-pie-chart-marker'}),
width: 60,
@ -19,9 +24,7 @@ function createPie(data, year) { @@ -19,9 +24,7 @@ function createPie(data, year) {
colors: ['#ff0000', '#00ff00', '#0000ff', '#ff00ff']
});
charts.addLayer(chart);
  }
}
});
return charts;
}

10
public/js/constants.js

@ -58,4 +58,14 @@ const hiddenRows = [ @@ -58,4 +58,14 @@ const hiddenRows = [
'id', 'notes'
];
const fisheriesMap = new Map([
['TrawlPerc', 'trawl'],
['PursesPerc', 'purses'],
['BoatsePerc', 'boatse'],
['otherPerc', 'other'],
['TAXON_B', 'taxon_b'],
['TAXON_C', 'taxon_c'],
['TAXON_F', 'taxon_f'],
['TAXON_M', 'taxon_m']
]);
const EDITABLE = false;

9
public/js/extras.js

@ -463,21 +463,20 @@ async function downloadShapefile(layerName, srs) { @@ -463,21 +463,20 @@ async function downloadShapefile(layerName, srs) {
}
async function getFisheriesProduct() {
async function getFisheriesProduct(layerCode) {
// Create timeline slider control
const group = L.layerGroup();
// load contours in JSON
const bgLayer = L.tileLayer.betterWms(BASE_URL + '/geoserver/wms', { layers: 'nssg_areas', transparent: true, format: "image/png"});
const url = BASE_URL + "/interface/charts/afppy";
try {
const response = await fetch(url);
const data = await response.json();
const data = await fetchGeoJson(layerCode);
console.debug("fisheries json: ", data);
let pies;
// Add the custom control to the map
pies = createPie(data, 1990).addTo(group);
layerControls['AFPPY'] = L.control.slider(value => {
layerControls[layerCode] = L.control.slider(value => {
pies.remove();
pies = createPie(data, value);
group.addLayer(pies);

17
public/js/layers.js

@ -341,8 +341,16 @@ var layersList = [ @@ -341,8 +341,16 @@ var layersList = [
format: 'image',
leafletid: null,
},{
name: 'Annual Fisheries Production per year',
code: 'AFPPY',
name: 'Annual Fisheries Production per Gear',
code: 'nssg-annual_prod_per_gear_1990-2019',
minSuffix: '1990',
maxSuffix: '2019',
active: false,
format: 'image',
leafletid: null
},{
name: 'Annual Fisheries Production per Species',
code: 'nssg-annual_prod_per_species_1990-2019',
active: false,
format: 'image',
leafletid: null
@ -360,6 +368,7 @@ async function layerTreeSwitch(node) { @@ -360,6 +368,7 @@ async function layerTreeSwitch(node) {
let leafletId = layer.leafletid;
let l;
console.debug(intId);
if (!layer.active && node.checkStatus) {
if (intId === 'DPTH') {
l = getBathymetry();
@ -370,8 +379,8 @@ async function layerTreeSwitch(node) { @@ -370,8 +379,8 @@ async function layerTreeSwitch(node) {
l = getHabitat(layer.code);
} else if (layer.isProduct) {
l = getProduct(layer);
} else if (intId === 'AFPPY') {
l = await getFisheriesProduct();
} else if (intId === 'nssg-annual_prod_per_gear_1990-2019' || intId === 'nssg-annual_prod_per_species_1990-2019') {
l = await getFisheriesProduct(intId);
} else if (intId === 'PHPL') {
l = getWMSSeries(node.checkStatus);
} else if (intId.substr(0,3) === 'wfd') {

7
public/js/treeview.js

@ -303,7 +303,12 @@ const myData = [{ @@ -303,7 +303,12 @@ const myData = [{
},{
n_id: 3111,
n_title: 'Annual Fisheries Production per fishing gear per NSSG area (NSSG: National Statistical Service of Greece)',
code: 'AFPPY',
code: 'nssg-annual_prod_per_gear_1990-2019',
n_parentid: 311,
},{
n_id: 3112,
n_title: 'Annual Fisheries Production per Species per NSSG area (NSSG: National Statistical Service of Greece)',
code: 'nssg-annual_prod_per_species_1990-2019',
n_parentid: 311,
},{
n_id: 321 ,

3
src/Controllers/InterfaceController.php

@ -33,7 +33,6 @@ class InterfaceController { @@ -33,7 +33,6 @@ class InterfaceController {
public function geojson($data) {
$layer = $data['layer'];
switch ($layer) {
@ -136,5 +135,3 @@ function convertToGeoJSON($json, $lon_alias, $lat_alias) { @@ -136,5 +135,3 @@ function convertToGeoJSON($json, $lon_alias, $lat_alias) {
// encode the GeoJSON feature collection as a JSON string and return it
return json_encode($geoJSON);
}

36
src/Controllers/StatsController.php

@ -0,0 +1,36 @@ @@ -0,0 +1,36 @@
<?php
namespace MSFD\Controllers;
use MSFD\Services\PgSql;
class StatsController {
public function fetchStats() {
if (!in_array(5, $_SESSION['user_groups'])) {
header('HTTP/1.1 403 Forbidden');
die();
}
require __DIR__.'/../Data/users.php';
}
public function countTypes() {
$sql = "SELECT * FROM webapp.stats_count_per_type";
$result = PgSql::getJson($sql);
echo $result;
}
public function countTotal() {
$sql = "SELECT * FROM webapp.stats_total_inserts";
$result = PgSql::getJson($sql);
echo $result;
}
public function countFiles() {
$sql = "SELECT * FROM webapp.stats_total_files";
$result = PgSql::getJson($sql);
echo $result;
}
}

4
src/Routing/controls.php

@ -11,4 +11,6 @@ $router->map('GET', '/actions/requests/[i:id]?', 'MSFD\Controllers\ActionControl @@ -11,4 +11,6 @@ $router->map('GET', '/actions/requests/[i:id]?', 'MSFD\Controllers\ActionControl
// STATS
$router->map('GET', '/interface/stats/typecount', 'MSFD\Controllers\StatsController@countTypes', 'stat_types');
$router->map('GET', '/interface/stats/totalrows', 'MSFD\Controllers\StatsController@countTotal', 'stat_total');

Loading…
Cancel
Save