From b3691fb2918f66c17af10b74d513b52b24c9c3bf Mon Sep 17 00:00:00 2001 From: phillimorland <5871230+phillimorland@users.noreply.github.com> Date: Thu, 2 Dec 2021 17:09:54 +0100 Subject: [PATCH 1/2] apps/maps: rm map files to a4 and update imports and deps --- .../apps/maps/assets/i18n-leaflet-draw.js | 106 ------- meinberlin/apps/maps/assets/map-address.js | 155 --------- .../assets/map_choose_polygon_with_preset.js | 295 ------------------ meinberlin/assets/js/app.js | 4 +- package.json | 2 - webpack.common.js | 2 +- 6 files changed, 4 insertions(+), 560 deletions(-) delete mode 100644 meinberlin/apps/maps/assets/i18n-leaflet-draw.js delete mode 100644 meinberlin/apps/maps/assets/map-address.js delete mode 100644 meinberlin/apps/maps/assets/map_choose_polygon_with_preset.js diff --git a/meinberlin/apps/maps/assets/i18n-leaflet-draw.js b/meinberlin/apps/maps/assets/i18n-leaflet-draw.js deleted file mode 100644 index d93ea705b1..0000000000 --- a/meinberlin/apps/maps/assets/i18n-leaflet-draw.js +++ /dev/null @@ -1,106 +0,0 @@ -window.L.drawLocal = { - draw: { - toolbar: { - actions: { - title: 'Bereich entfernen', - text: 'Abbrechen' - }, - finish: { - title: 'Bereich übernehmen', - text: 'Übernehmen' - }, - undo: { - title: 'Letzten Punkt entfernen', - text: 'Letzten Punkt entfernen' - }, - buttons: { - polyline: 'Draw a polyline', - polygon: 'Einen Bereich einzeichnen', - rectangle: 'Ein Rechteck einzeichnen', - circle: 'Draw a circle', - marker: 'Draw a marker', - circlemarker: 'Draw a circlemarker' - } - }, - handlers: { - circle: { - tooltip: { - start: 'Click and drag to draw circle.' - }, - radius: 'Radius' - }, - circlemarker: { - tooltip: { - start: 'Click map to place circle marker.' - } - }, - marker: { - tooltip: { - start: 'Click map to place marker.' - } - }, - polygon: { - tooltip: { - start: 'Klicken, um den Bereich anzufangen.', - cont: 'Klicken, um hier einen Punkt zu setzen.', - end: 'Den ersten Punkt anklicken, um den Bereich abzuschließen.' - } - }, - polyline: { - error: 'Error: shape edges cannot cross!', - tooltip: { - start: 'Click to start drawing line.', - cont: 'Click to continue drawing line.', - end: 'Click last point to finish line.' - } - }, - rectangle: { - tooltip: { - start: 'Klicken und ziehen um ein Rechteck zu zeichnen.' - } - }, - simpleshape: { - tooltip: { - end: 'Maustaste loslassen um den Bereich abzuschließen.' - } - } - } - }, - edit: { - toolbar: { - actions: { - save: { - title: 'Änderungen speichern', - text: 'Speichern' - }, - cancel: { - title: 'Bearbeitung abbrechen, Änderungen verwerfen', - text: 'Abbrechen' - }, - clearAll: { - title: 'Alle Ebenen entfernen', - text: 'Alles entfernen' - } - }, - buttons: { - edit: 'Ebenen bearbeiten', - editDisabled: 'Keine Ebenen zum Bearbeiten', - remove: 'Ebenen löschen', - removeDisabled: 'Keine Ebenen zum Löschen' - } - }, - handlers: { - edit: { - tooltip: { - text: 'Die Eckpunkte ziehen um den Bereich zu ändern.', - subtext: 'Abbrechen klicken um die Änderungen zu verwerfen..' - } - }, - remove: { - tooltip: { - text: 'Einen Bereich anklicken um ihn zu entfernen.' - } - } - } - } -} diff --git a/meinberlin/apps/maps/assets/map-address.js b/meinberlin/apps/maps/assets/map-address.js deleted file mode 100644 index 91f2329dff..0000000000 --- a/meinberlin/apps/maps/assets/map-address.js +++ /dev/null @@ -1,155 +0,0 @@ -/* global django */ - -const apiUrl = 'https://bplan-prod.liqd.net/api/addresses/' - -function pointInPolygon (point, polygon) { - const x = point[0] - const y = point[1] - - // Algorithm comes from: - // https://github.com/substack/point-in-polygon/blob/master/index.js - let inside = false - - for (let p = 0; p < polygon.length; p++) { - const ring = polygon[p] - - for (let i = 0; i < ring.length - 1; i++) { - const xi = ring[i][0] - const yi = ring[i][1] - const xj = ring[i + 1][0] - const yj = ring[i + 1][1] - - // * - // / - // *--/----------->> - // * - // Check that - // - // 1. yi and yj are on opposite sites of a ray to the right - // 2. the intersection of the ray and the segment is right of x - const intersect = ((yi > y) !== (yj > y)) && - (x < (xj - xi) * (y - yi) / (yj - yi) + xi) - if (intersect) inside = !inside - } - } - return inside -} - -const pointInObject = function (point, geojson, failByDefault) { - if (geojson.type === 'MultiPolygon') { - return geojson.coordinates.some(function (polygon) { - return pointInPolygon(point, polygon) - }) - } else if (geojson.type === 'Polygon') { - return pointInPolygon(point, geojson.coordinates) - } else if (geojson.type === 'Feature') { - return pointInObject(point, geojson.geometry, failByDefault) - } else if (geojson.type === 'FeatureCollection') { - return geojson.features.some(function (feature) { - return pointInObject(point, feature, true) - }) - } else { - return !failByDefault - } -} - -const setBusy = function ($group, busy) { - $group.attr('aria-busy', busy) - $group.find('input').attr('disabled', busy) - $group.find('button').attr('disabled', busy) - if (busy) { - $group.find('.fa, .fas, .far') - .addClass('fa-spinner fa-pulse') - .removeClass('fa-search') - } else { - $group.find('.fa, .fas, .far') - .addClass('fa-search') - .removeClass('fa-spinner fa-pulse') - } -} - -const getPoints = function (address, cb) { - $.ajax(apiUrl, { - data: { address: address }, - success: function (geojson) { - cb(geojson.features) - }, - error: function () { - const points = [] - cb(points) - } - }) -} - -const renderPoints = function (points) { - if (points.length === 0) { - return $('') - .text(django.gettext('No matches found within the project area')) - } else { - const $list = $('