Skip to content

Instantly share code, notes, and snippets.

View dbauszus-glx's full-sized avatar

Dennis Bauszus dbauszus-glx

View GitHub Profile
const provider = require('../provider')
const templates = {
//views
_desktop: require('./views/desktop'),
_mobile: require('./views/mobile'),
_login: require('./views/login'),
_register: require('./views/register'),
admin_user: require('./views/admin_user'),
const auth = require('../mod/auth/handler')({
public: true,
login: true
})
const _templates = require('../mod/workspace/templates')
const templates = {}
module.exports = async (req, res) => {
# _z is the XYZ tiles zoom level of the request
# _resolution is a resolution factor applied to determine the grid spacing
# _r = parseInt(40075016.68 / Math.pow(2, _z) * _resolution)
# _size is a numeric value for the calculation of a cell's size property
# _cat is a numeric value for the calculation of a cell's graduated colour property
# _table is the table name
# _geom is the geometry field of points in the table
# The _width of a hexagon is equal to _r
# The _height of a hexagon envelope is _r - ((_r * 2 / sqrt(3)) - _r) / 2;
# The geometries SRID is assumed to be 3857
# _z is the XYZ tiles zoom level of the request
# _resolution is a resolution factor applied to determine the grid spacing
# _r = parseInt(40075016.68 / Math.pow(2, _z) * _resolution)
# _size is a numeric value for the calculation of a cell's size property
# _cat is a numeric value for the calculation of a cell's graduated colour property
# _table is the table name
# _geom is the geometry field of points in the table
# The geometries SRID is assumed to be 3857
SELECT
_xyz.mapview.highlight = {
feature: null,
layer: null,
};
function pointermove(e){
// Get features from layers which have a highlight style.
const featureArray = _xyz.map.getFeaturesAtPixel(e.pixel,{
// Filter for layers which have a highlight style.
@dbauszus-glx
dbauszus-glx / OL.drawFeature.js
Created June 15, 2019 16:37
Draw a feature on vector layer and update MVT source on drawend.
let drawInteraction;
let activeButton;
const btnPoly = document.getElementById('btnPoly');
btnPoly.onclick = () => drawMethod(btnPoly, 'Polygon');
const btnLine = document.getElementById('btnLine');
@dbauszus-glx
dbauszus-glx / OL.deleteFeature.js
Created June 15, 2019 16:30
Delete the current feature from vector source and XYZ data source.
btnDelete.onclick = function() {
btnDelete.classList.remove('active');
if (!currentFeature) return;
const xhr = new XMLHttpRequest();
xhr.open('GET', 'https://geolytix.xyz/dev/api/location/edit/delete?locale=GB&layer=Scratch&table=dev.scratch&id=' + currentFeature.getProperties().id);
@dbauszus-glx
dbauszus-glx / OL.modifyInteraction.js
Created June 15, 2019 16:16
OpenLayers modify geometry interaction and XYZ update via XHR.
const modifyInteraction = new ol.interaction.Modify({
source: sourceVector
});
modifyInteraction.on('modifyend', e => {
const feature = JSON.parse(geoJSON.writeFeature(e.features.getArray()[0]));
const xhr = new XMLHttpRequest();
@dbauszus-glx
dbauszus-glx / OL.initMVTeditMap.js
Last active June 17, 2019 14:57
Defines base, vector and MVT layer to be added to a OpenLayers map object.
const layerBase = new ol.layer.Tile({
source: new ol.source.OSM({
url: 'https://cartodb-basemaps-{a-d}.global.ssl.fastly.net/dark_nolabels/{z}/{x}/{y}.png',
opaque: false,
attributions: []
})
});
const sourceMVT = new ol.source.VectorTile({
cacheSize: 0,
@dbauszus-glx
dbauszus-glx / OL.selectFeatureById.js
Created June 15, 2019 15:35
Select a feature at pixel from XYZ endpoint with OpenLayers
let currentFeature;
map.on('click', select);
function select(e) {
sourceVector.clear();
map.removeInteraction(drawInteraction);