diff --git a/intervention/forms/forms.py b/intervention/forms/forms.py index b83c4fba..b85ba101 100644 --- a/intervention/forms/forms.py +++ b/intervention/forms/forms.py @@ -216,6 +216,10 @@ class NewInterventionForm(BaseForm): identifier = tmp_intervention.generate_new_identifier() self.initialize_form_field("identifier", identifier) + def is_valid(self): + super_valid_result = super().is_valid() + return super_valid_result + def save(self, user: User, geom_form: SimpleGeomForm): with transaction.atomic(): # Fetch data from cleaned POST values diff --git a/konova/forms.py b/konova/forms.py index d64ab364..0d7f02fe 100644 --- a/konova/forms.py +++ b/konova/forms.py @@ -5,18 +5,20 @@ Contact: michel.peltriaux@sgdnord.rlp.de Created on: 16.11.20 """ - +import json from abc import abstractmethod from bootstrap_modal_forms.forms import BSModalForm from bootstrap_modal_forms.utils import is_ajax from django import forms from django.contrib import messages +from django.contrib.gis import gdal from django.db.models.fields.files import FieldFile +from konova.sub_settings.lanis_settings import DEFAULT_SRID_RLP from user.models import User from django.contrib.gis.forms import OSMWidget, MultiPolygonField -from django.contrib.gis.geos import MultiPolygon +from django.contrib.gis.geos import MultiPolygon, GEOSGeometry, Polygon from django.db import transaction from django.http import HttpRequest, HttpResponseRedirect from django.shortcuts import render @@ -274,7 +276,7 @@ class SimpleGeomForm(BaseForm): """ read_only = True geom = MultiPolygonField( - srid=DEFAULT_SRID, + srid=DEFAULT_SRID_RLP, label=_("Geometry"), help_text=_(""), label_suffix="", @@ -289,15 +291,47 @@ class SimpleGeomForm(BaseForm): # Initialize geometry try: geom = self.instance.geometry.geom + geom.transform(ct=DEFAULT_SRID_RLP) self.empty = geom.empty + geom = geom.geojson except AttributeError: # If no geometry exists for this form, we simply set the value to None and zoom to the maximum level - geom = None + geom = "" self.empty = True self.fields["geom"].widget.attrs["default_zoom"] = 1 self.initialize_form_field("geom", geom) + def is_valid(self): + super_valid = super().is_valid() + is_valid = True + + # Get geojson from form + geom = self.data["geom"] + geom = json.loads(geom) + + # Read geojson into gdal geometry + features = [] + features_json = geom["features"] + for feature in features_json: + g = gdal.OGRGeometry(json.dumps(feature["geometry"]), srs=DEFAULT_SRID_RLP) + if g.geom_type not in ["Polygon", "MultiPolygon"]: + self.add_error("geom", _("Only surfaces allowed. Points or lines must be buffered.")) + is_valid = False + return is_valid + features.append(g) + if len(features) > 0: + form_geom = features[0] + for g in features[1:]: + form_geom = form_geom.union(g) + form_geom.transform(coord_trans=DEFAULT_SRID) + if form_geom.geom_type != "MultiPolygon": + form_geom = MultiPolygon(MultiPolygon.from_ewkt(form_geom.ewkt)) + self.cleaned_data = { + "geom": form_geom.wkt + } + return is_valid + def save(self, action: UserActionLogEntry): """ Saves the form's geometry diff --git a/templates/map/client/config.json b/templates/map/client/config.json index 2121bc55..ca1c31f8 100644 --- a/templates/map/client/config.json +++ b/templates/map/client/config.json @@ -6,7 +6,7 @@ { "folder": 0, "type": "WMS", "title": "KOM Flächen", "url": "https://geodaten.naturschutz.rlp.de/kartendienste_naturschutz/mod_ogc/wms_getmap.php?mapfile=kom_f&", "name": "kom_f" }, { "folder": 1, "type": "WMS", "title": "Lagebezeichnungen", "url": "https://geo5.service24.rlp.de/wms/liegenschaften_rp.fcgi?", "name": "Lagebezeichnungen" }, - { "folder": 1, "type": "WMS", "title": "Flurstücke", "url": "https://geo5.service24.rlp.de/wms/liegenschaften_rp.fcgi?", "name": "Flurstueck" }, + { "folder": 1, "type": "WMS", "title": "Flurstücke", "url": "https://geo5.service24.rlp.de/wms/liegenschaften_rp.fcgi?", "name": "Flurstueck", "username": "abc", "password": "123" }, { "folder": 1, "type": "WMS", "title": "Gebäude / Bauwerke", "url": "https://geo5.service24.rlp.de/wms/liegenschaften_rp.fcgi?", "name": "GebaeudeBauwerke" }, { "folder": 1, "type": "WMS", "title": "Nutzung", "url": "https://geo5.service24.rlp.de/wms/liegenschaften_rp.fcgi?", "name": "Nutzung" }, @@ -34,13 +34,18 @@ "projection": "EPSG:25832", "center": [ 385000, 5543000 ], "minZoom": 5, - "maxZoom": 19, + "maxZoom": 25, "zoom": 8, "attribution": "LANIS RLP" }, "output": { - "id": "id_geom" + "id": "netgis-storage" + }, + + "search": + { + "url": "./proxy.php?https://www.geoportal.rlp.de/mapbender/geoportal/gaz_geom_mobile.php?outputFormat=json&resultTarget=web&searchEPSG={epsg}&maxResults=5&maxRows=5&featureClass=P&style=full&searchText={q}&name_startsWith={q}" } } \ No newline at end of file diff --git a/templates/map/client/index.html b/templates/map/client/index.html index 277b8b92..3afa8e30 100644 --- a/templates/map/client/index.html +++ b/templates/map/client/index.html @@ -12,8 +12,7 @@ - -
{{geom_form.fields.geom.initial}}
+ diff --git a/templates/map/client/netgis.min.js b/templates/map/client/netgis.min.js index dfe72cae..8295dd66 100644 --- a/templates/map/client/netgis.min.js +++ b/templates/map/client/netgis.min.js @@ -1,15 +1,15 @@ -var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.SIMPLE_FROUND_POLYFILL=!1;$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,c){a!=Array.prototype&&a!=Object.prototype&&(a[b]=c.value)}; -$jscomp.getGlobal=function(a){a=["object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global,a];for(var b=0;bthis.callbacks[a].length&&delete this.callbacks[a]}else delete this.callbacks[a]}; +netgis.Client.prototype.load=function(){for(var a=0;athis.callbacks[a].length&&delete this.callbacks[a]}else delete this.callbacks[a]}; netgis.Client.prototype.invoke=function(a,b){console.info("EVENT:",a,b);if(netgis.util.isDefined(this.callbacks[a]))for(var c=0;c=g;g++)for(c=0;c";a.title="Hineinzoomen";a.addEventListener("click",this.onZoomIn.bind(this));this.root.appendChild(a);a=document.createElement("button");a.innerHTML="";a.title="Herauszoomen";a.addEventListener("click",this.onZoomOut.bind(this));this.root.appendChild(a);this.client.root.appendChild(this.root)}; -netgis.Controls.prototype.onZoomIn=function(a){this.client.invoke(netgis.Events.MAP_CHANGE_ZOOM,1)};netgis.Controls.prototype.onZoomOut=function(a){this.client.invoke(netgis.Events.MAP_CHANGE_ZOOM,-1)};netgis.Controls.prototype.onSettings=function(a){alert("TODO: settings dialog")};netgis=netgis||{}; -netgis.Events=Object.freeze({CONTEXT_UPDATE:"CONTEXT_UPDATE",SET_MODE:"SET_MODE",LAYER_LIST_TOGGLE:"LAYER_LIST_TOGGLE",PANEL_TOGGLE:"PANEL_TOGGLE",PANEL_SHOW:"PANEL_SHOW",PANEL_HIDE:"PANEL_HIDE",LAYER_SHOW:"LAYER_SHOW",LAYER_HIDE:"LAYER_HIDE",LAYER_CREATED:"LAYER_CREATED",MAP_SET_EXTENT:"MAP_SET_EXTENT",MAP_CHANGE_ZOOM:"MAP_CHANGE_ZOOM",MAP_MODE_POINTS:"MAP_MODE_POINTS",MAP_MODE_LINES:"MAP_MODE_LINES",MAP_MODE_POLYGONS:"MAP_MODE_POLYGONS",EDIT_FEATURES_CHANGE:"EDIT_FEATURES_CHANGE",SEARCH_PLACE_REQUEST:"SEARCH_PLACE_REQUEST", -SEARCH_PLACE_RESPONSE:"SEARCH_PLACE_RESPONSE",BUFFER_CHANGE:"BUFFER_CHANGE",BUFFER_ACCEPT:"BUFFER_ACCEPT",BUFFER_CANCEL:"BUFFER_CANCEL",SNAP_ON:"SNAP_ON",SNAP_OFF:"SNAP_OFF",IMPORT_SHAPEFILE_SHOW:"IMPORT_SHAPEFILE_SHOW",IMPORT_GEOJSON_SHOW:"IMPORT_GEOJSON_SHOW",IMPORT_GML_SHOW:"IMPORT_GML_SHOW",IMPORT_SHAPEFILE:"IMPORT_SHAPEFILE",IMPORT_GEOJSON:"IMPORT_GEOJSON",IMPORT_GML:"IMPORT_GML"});netgis=netgis||{};netgis.Head=function(){this.root=this.client=null;this.sections=[]}; +netgis.Controls.prototype.load=function(){this.root=document.createElement("section");this.root.className="netgis-controls";var a=document.createElement("button");a.setAttribute("type","button");a.innerHTML="";a.title="Hineinzoomen";a.addEventListener("click",this.onZoomIn.bind(this));this.root.appendChild(a);a=document.createElement("button");a.setAttribute("type","button");a.innerHTML="";a.title="Herauszoomen";a.addEventListener("click", +this.onZoomOut.bind(this));this.root.appendChild(a);this.client.root.appendChild(this.root)};netgis.Controls.prototype.onZoomIn=function(a){this.client.invoke(netgis.Events.MAP_CHANGE_ZOOM,1)};netgis.Controls.prototype.onZoomOut=function(a){this.client.invoke(netgis.Events.MAP_CHANGE_ZOOM,-1)};netgis.Controls.prototype.onSettings=function(a){alert("TODO: settings dialog")};netgis=netgis||{}; +netgis.Events=Object.freeze({CONTEXT_UPDATE:"CONTEXT_UPDATE",SET_MODE:"SET_MODE",LAYER_LIST_TOGGLE:"LAYER_LIST_TOGGLE",PANEL_TOGGLE:"PANEL_TOGGLE",PANEL_SHOW:"PANEL_SHOW",PANEL_HIDE:"PANEL_HIDE",LAYER_SHOW:"LAYER_SHOW",LAYER_HIDE:"LAYER_HIDE",LAYER_CREATED:"LAYER_CREATED",MAP_SET_EXTENT:"MAP_SET_EXTENT",MAP_CHANGE_ZOOM:"MAP_CHANGE_ZOOM",MAP_MODE_POINTS:"MAP_MODE_POINTS",MAP_MODE_LINES:"MAP_MODE_LINES",MAP_MODE_POLYGONS:"MAP_MODE_POLYGONS",EDIT_FEATURES_LOADED:"EDIT_FEATURES_LOADED",EDIT_FEATURES_CHANGE:"EDIT_FEATURES_CHANGE", +SEARCH_PLACE_REQUEST:"SEARCH_PLACE_REQUEST",SEARCH_PLACE_RESPONSE:"SEARCH_PLACE_RESPONSE",BUFFER_CHANGE:"BUFFER_CHANGE",BUFFER_ACCEPT:"BUFFER_ACCEPT",BUFFER_CANCEL:"BUFFER_CANCEL",SNAP_ON:"SNAP_ON",SNAP_OFF:"SNAP_OFF",IMPORT_SHAPEFILE_SHOW:"IMPORT_SHAPEFILE_SHOW",IMPORT_GEOJSON_SHOW:"IMPORT_GEOJSON_SHOW",IMPORT_GML_SHOW:"IMPORT_GML_SHOW",IMPORT_SHAPEFILE:"IMPORT_SHAPEFILE",IMPORT_GEOJSON:"IMPORT_GEOJSON",IMPORT_GML:"IMPORT_GML"});netgis=netgis||{};netgis.Head=function(){this.root=this.client=null;this.sections=[]}; netgis.Head.prototype.load=function(){this.root=document.createElement("header");this.root.className="netgis-head netgis-primary netgis-shadow";var a=this.createButton('Ebenen',!0);a.addEventListener("click",this.onToggleClick.bind(this));this.root.appendChild(a);a=this.createButton('Suche',!0);a.addEventListener("click",this.onSearchPlaceClick.bind(this));this.root.appendChild(a);if(this.client.editable){a= this.createMenu('Zeichnen');var b=a.getElementsByTagName("ul")[0];this.root.appendChild(a);b.appendChild(this.createMenuItem('Punkte',this.onDrawPointClick.bind(this)));b.appendChild(this.createMenuItem('Linien',this.onDrawLineClick.bind(this)));b.appendChild(this.createMenuItem('Polygone',this.onDrawPolygonClick.bind(this)));a=this.createMenu('Bearbeiten'); -b=a.getElementsByTagName("ul")[0];this.root.appendChild(a);b.appendChild(this.createMenuItem('Ausschneiden',this.onCutFeatureClick.bind(this)));b.appendChild(this.createMenuItem('Verschieben',this.onModifyFeaturesClick.bind(this)));b.appendChild(this.createMenuItem('L\u00f6schen',this.onDeleteFeaturesClick.bind(this)));b.appendChild(this.createMenuItem('Puffern',this.onBufferFeatureClick.bind(this)))}a= -this.createMenu('Import');b=a.getElementsByTagName("ul")[0];this.root.appendChild(a);b.appendChild(this.createMenuItem('GeoJSON',this.onImportGeoJSONClick.bind(this)));b.appendChild(this.createMenuItem('GML',this.onImportGMLClick.bind(this)));b.appendChild(this.createMenuItem('Shapefile',this.onImportShapefileClick.bind(this)));this.client.root.appendChild(this.root)}; -netgis.Head.prototype.createButton=function(a,b){var c=document.createElement("button");c.className="netgis-primary netgis-hover-primary";b&&(c.className+=" netgis-right");c.innerHTML=a;return c}; -netgis.Head.prototype.createMenu=function(a){var b=document.createElement("div");b.className="netgis-dropdown";var c=document.createElement("button");c.className="netgis-primary netgis-hover-primary";c.innerHTML=a;b.appendChild(c);a=document.createElement("ul");a.className="netgis-dropdown-content netgis-dialog netgis-shadow";b.appendChild(a);return b}; -netgis.Head.prototype.createMenuItem=function(a,b){var c=document.createElement("li");c.className="netgis-hover-light";var d=document.createElement("button");d.innerHTML=a;d.addEventListener("click",b);c.appendChild(d);return c};netgis.Head.prototype.onToggleClick=function(a){this.client.invoke(netgis.Events.LAYER_LIST_TOGGLE,null)};netgis.Head.prototype.onDrawPointClick=function(a){this.client.invoke(netgis.Events.SET_MODE,netgis.Modes.DRAW_POINTS)}; +b=a.getElementsByTagName("ul")[0];this.root.appendChild(a);b.appendChild(this.createMenuItem('Ausschneiden',this.onCutFeatureClick.bind(this)));b.appendChild(this.createMenuItem('Verschieben',this.onModifyFeaturesClick.bind(this)));b.appendChild(this.createMenuItem('L\u00f6schen',this.onDeleteFeaturesClick.bind(this)));b.appendChild(this.createMenuItem('Puffern',this.onBufferFeatureClick.bind(this))); +a=this.createMenu('Import');b=a.getElementsByTagName("ul")[0];this.root.appendChild(a);b.appendChild(this.createMenuItem('GeoJSON',this.onImportGeoJSONClick.bind(this)));b.appendChild(this.createMenuItem('GML',this.onImportGMLClick.bind(this)));b.appendChild(this.createMenuItem('Shapefile',this.onImportShapefileClick.bind(this)))}this.client.root.appendChild(this.root)}; +netgis.Head.prototype.createButton=function(a,b){var c=document.createElement("button");c.setAttribute("type","button");c.className="netgis-primary netgis-hover-primary";b&&(c.className+=" netgis-right");c.innerHTML=a;return c}; +netgis.Head.prototype.createMenu=function(a){var b=document.createElement("div");b.className="netgis-dropdown";var c=document.createElement("button");c.setAttribute("type","button");c.className="netgis-primary netgis-hover-primary";c.innerHTML=a;b.appendChild(c);a=document.createElement("ul");a.className="netgis-dropdown-content netgis-dialog netgis-shadow";b.appendChild(a);return b}; +netgis.Head.prototype.createMenuItem=function(a,b){var c=document.createElement("li");c.className="netgis-hover-light";var d=document.createElement("button");d.setAttribute("type","button");d.innerHTML=a;d.addEventListener("click",b);c.appendChild(d);return c};netgis.Head.prototype.onToggleClick=function(a){this.client.invoke(netgis.Events.LAYER_LIST_TOGGLE,null)};netgis.Head.prototype.onDrawPointClick=function(a){this.client.invoke(netgis.Events.SET_MODE,netgis.Modes.DRAW_POINTS)}; netgis.Head.prototype.onDrawLineClick=function(a){this.client.invoke(netgis.Events.SET_MODE,netgis.Modes.DRAW_LINES)};netgis.Head.prototype.onDrawPolygonClick=function(a){this.client.invoke(netgis.Events.SET_MODE,netgis.Modes.DRAW_POLYGONS)};netgis.Head.prototype.onCutFeatureClick=function(a){this.client.invoke(netgis.Events.SET_MODE,netgis.Modes.CUT_FEATURE_BEGIN)};netgis.Head.prototype.onModifyFeaturesClick=function(a){this.client.invoke(netgis.Events.SET_MODE,netgis.Modes.MODIFY_FEATURES)}; netgis.Head.prototype.onDeleteFeaturesClick=function(a){this.client.invoke(netgis.Events.SET_MODE,netgis.Modes.DELETE_FEATURES)};netgis.Head.prototype.onBufferFeatureClick=function(a){this.client.invoke(netgis.Events.SET_MODE,netgis.Modes.BUFFER_FEATURE_BEGIN)};netgis.Head.prototype.onSearchPlaceClick=function(a){this.client.invoke(netgis.Events.SET_MODE,netgis.Modes.SEARCH_PLACE)};netgis.Head.prototype.onSearchDataClick=function(a){alert("TODO: data search interface")}; netgis.Head.prototype.onImportOWSClick=function(a){alert("TODO: ows import interface, try setting url parameter '?ows='")};netgis.Head.prototype.onImportShapefileClick=function(a){this.client.invoke(netgis.Events.IMPORT_SHAPEFILE_SHOW,null)};netgis.Head.prototype.onImportGeoJSONClick=function(a){this.client.invoke(netgis.Events.IMPORT_GEOJSON_SHOW,null)};netgis.Head.prototype.onImportKMLClick=function(a){alert("TODO: kml import interface")}; netgis.Head.prototype.onImportGMLClick=function(a){this.client.invoke(netgis.Events.IMPORT_GML_SHOW,null)};netgis=netgis||{};netgis.LayerTree=function(){this.folderDraw=this.folderImport=this.list=this.root=this.client=null}; netgis.LayerTree.prototype.load=function(){this.root=document.createElement("section");this.root.className="netgis-layer-list netgis-dialog netgis-shadow netgis-hide";this.list=document.createElement("ul");this.list.className="root";this.root.appendChild(this.list);this.client.root.appendChild(this.root);this.client.on(netgis.Events.CONTEXT_UPDATE,this.onContextUpdate.bind(this));this.client.on(netgis.Events.LAYER_LIST_TOGGLE,this.onLayerListToggle.bind(this));this.client.on(netgis.Events.LAYER_CREATED, this.onLayerCreated.bind(this))}; -netgis.LayerTree.prototype.createFolder=function(a){var b=document.createElement("li");b.className="netgis-folder netgis-hover-light";b.setAttribute("title",a);var c=document.createElement("label");c.className="netgis-icon";b.appendChild(c);var d=document.createElement("input");d.setAttribute("type","checkbox");d.addEventListener("change",this.onFolderChange.bind(this));c.appendChild(d);c=document.createElement("button");c.className="netgis-clip-text netgis-hover-text-primary";c.innerHTML=''+ -a;c.addEventListener("click",this.onFolderClick.bind(this));b.appendChild(c);a=document.createElement("ul");b.appendChild(a);return b}; +netgis.LayerTree.prototype.createFolder=function(a){var b=document.createElement("li");b.className="netgis-folder netgis-hover-light";b.setAttribute("title",a);var c=document.createElement("label");c.className="netgis-icon";b.appendChild(c);var d=document.createElement("input");d.setAttribute("type","checkbox");d.addEventListener("change",this.onFolderChange.bind(this));c.appendChild(d);c=document.createElement("button");c.setAttribute("type","button");c.className="netgis-clip-text netgis-hover-text-primary"; +c.innerHTML=''+a;c.addEventListener("click",this.onFolderClick.bind(this));b.appendChild(c);a=document.createElement("ul");b.appendChild(a);return b}; netgis.LayerTree.prototype.createLayer=function(a,b,c){var d=document.createElement("li");d.setAttribute("title",b);d.className="netgis-folder-item netgis-hover-text-primary";var e=document.createElement("label");e.className="netgis-label netgis-clip-text";d.appendChild(e);var f=document.createElement("span");f.className="netgis-icon";e.appendChild(f);var g=document.createElement("input");g.setAttribute("type","checkbox");g.dataset.id=a;g.checked=c;g.addEventListener("change",this.onItemChange.bind(this)); f.appendChild(g);a=document.createElement("i");a.className="fas fa-th-large";e.appendChild(a);b=document.createTextNode(b);e.appendChild(b);return d};netgis.LayerTree.prototype.addToFolder=function(a,b,c){a?(a=a.getElementsByTagName("ul")[0],a.appendChild(b)):a=this.list;c?a.insertBefore(b,a.firstChild):a.appendChild(b)};netgis.LayerTree.prototype.onFolderClick=function(a){a.currentTarget.parentElement.classList.toggle("netgis-active")}; netgis.LayerTree.prototype.onFolderChange=function(a){var b=a.currentTarget;a=b.checked;b=b.parentElement.parentElement;for(var c=b.getElementsByTagName("input"),d=1;d
  • World Geodetic System 1984 (EPSG:4326)
  • ETRS89 / UTM zone 32N (EPSG:25832)
  • ");this.createInputFile(a,"Datei ausw\u00e4hlen / ablegen:",".gml,.xml",this.onImportGMLChange.bind(this));this.createSpace(a);this.createButton(a,"Importieren",this.onImportGMLAccept.bind(this));return a}; netgis.Modal.prototype.createImportShapefile=function(){var a=this.createContainer("Import Shapefile");this.createText(a,"Unterst\u00fctzte Koordinatensysteme:","
    • World Geodetic System 1984 (EPSG:4326)
    • ETRS89 / UTM zone 32N (EPSG:25832)
    ");this.createInputFile(a,"Datei ausw\u00e4hlen / ablegen:","application/zip",this.onImportShapefileChange.bind(this));this.createSpace(a);this.createButton(a,"Importieren",this.onImportShapefileAccept.bind(this)); return a};netgis.Modal.prototype.show=function(a){this.root.classList.add("netgis-show");for(var b=this.root.getElementsByClassName("netgis-dialog"),c=0;c";d.addEventListener("click",this.onHeaderClick.bind(this));c.appendChild(d);a=document.createElement("span");a.innerHTML="";d.appendChild(a);b.appendChild(c);c=document.createElement("div"); -c.className="netgis-modal-content";b.appendChild(c);d=document.createElement("table");c.appendChild(d);return b};netgis.Modal.prototype.createSpace=function(a){var b=document.createElement("tr");b.className="netgis-space";var c=document.createElement("td");c.setAttribute("colspan",100);b.appendChild(c);a.getElementsByClassName("netgis-modal-content")[0].getElementsByTagName("table")[0].appendChild(b);return c}; -netgis.Modal.prototype.createButton=function(a,b,c){var d=document.createElement("tr"),e=document.createElement("td");e.setAttribute("colspan",100);d.appendChild(e);var f=document.createElement("button");f.className="netgis-primary netgis-hover-primary";f.innerHTML=b;c&&f.addEventListener("click",c);e.appendChild(f);a.getElementsByClassName("netgis-modal-content")[0].getElementsByTagName("table")[0].appendChild(d);return f}; +netgis.Modal.prototype.createContainer=function(a){var b=document.createElement("section");b.className="netgis-dialog netgis-shadow";var c=document.createElement("header"),d=document.createElement("button");d.setAttribute("type","button");d.className="netgis-primary netgis-hover-primary";d.innerHTML="

    "+a+"

    ";d.addEventListener("click",this.onHeaderClick.bind(this));c.appendChild(d);a=document.createElement("span");a.innerHTML="";d.appendChild(a);b.appendChild(c); +c=document.createElement("div");c.className="netgis-modal-content";b.appendChild(c);d=document.createElement("table");c.appendChild(d);return b};netgis.Modal.prototype.createSpace=function(a){var b=document.createElement("tr");b.className="netgis-space";var c=document.createElement("td");c.setAttribute("colspan",100);b.appendChild(c);a.getElementsByClassName("netgis-modal-content")[0].getElementsByTagName("table")[0].appendChild(b);return c}; +netgis.Modal.prototype.createButton=function(a,b,c){var d=document.createElement("tr"),e=document.createElement("td");e.setAttribute("colspan",100);d.appendChild(e);var f=document.createElement("button");f.setAttribute("type","button");f.className="netgis-primary netgis-hover-primary";f.innerHTML=b;c&&f.addEventListener("click",c);e.appendChild(f);a.getElementsByClassName("netgis-modal-content")[0].getElementsByTagName("table")[0].appendChild(d);return f}; netgis.Modal.prototype.createInputText=function(a,b){var c=document.createElement("tr"),d=document.createElement("th");d.className="netgis-padding";var e=document.createElement("label");e.innerHTML=b;d.appendChild(e);c.appendChild(d);b=document.createElement("td");b.className="netgis-padding";d=document.createElement("input");d.setAttribute("type","text");b.appendChild(d);c.appendChild(b);e.htmlFor=d;a.getElementsByClassName("netgis-modal-content")[0].getElementsByTagName("table")[0].appendChild(c); return d}; netgis.Modal.prototype.createInputFile=function(a,b,c,d){var e=document.createElement("tr"),f=document.createElement("th");f.className="netgis-padding";var g=document.createElement("label");g.innerHTML=b;f.appendChild(g);e.appendChild(f);b=document.createElement("td");b.className="netgis-padding";f=document.createElement("input");f.setAttribute("type","file");f.setAttribute("accept",c);d&&f.addEventListener("change",d);b.appendChild(f);e.appendChild(b);a.getElementsByClassName("netgis-modal-content")[0].getElementsByTagName("table")[0].appendChild(e);return f}; @@ -105,19 +106,19 @@ netgis.Modal.prototype.onImportGeoJSONShow=function(a){a=this.importGeoJSON.getE netgis.Modal.prototype.onImportGeoJSONAccept=function(a){a=this.importGeoJSON.getElementsByTagName("input")[0].files[0];this.client.invoke(netgis.Events.IMPORT_GEOJSON,a);this.hide()};netgis.Modal.prototype.onImportGMLShow=function(a){a=this.importGML.getElementsByTagName("input")[0];var b=this.importGML.getElementsByTagName("button")[1];a.value="";b.disabled=!0;this.show(this.importGML)}; netgis.Modal.prototype.onImportGMLChange=function(a){a=this.importGML.getElementsByTagName("input")[0];this.importGML.getElementsByTagName("button")[1].disabled=a.value&&0Punkte zeichnen:',this.onToolbarClose.bind(this))),this.toolbars[netgis.Modes.DRAW_POINTS].appendChild(this.createToolbarCheckbox("Einrasten",this.onSnapChange.bind(this))),this.root.appendChild(this.toolbars[netgis.Modes.DRAW_POINTS]), -this.toolbars[netgis.Modes.DRAW_LINES]=this.createToolbar(),this.toolbars[netgis.Modes.DRAW_LINES].appendChild(this.createToolbarButton('Linien zeichnen:',this.onToolbarClose.bind(this))),this.toolbars[netgis.Modes.DRAW_LINES].appendChild(this.createToolbarCheckbox("Einrasten",this.onSnapChange.bind(this))),this.root.appendChild(this.toolbars[netgis.Modes.DRAW_LINES]),this.toolbars[netgis.Modes.DRAW_POLYGONS]=this.createToolbar(),this.toolbars[netgis.Modes.DRAW_POLYGONS].appendChild(this.createToolbarButton('Polygone zeichnen:', -this.onToolbarClose.bind(this))),this.toolbars[netgis.Modes.DRAW_POLYGONS].appendChild(this.createToolbarCheckbox("Einrasten",this.onSnapChange.bind(this))),this.root.appendChild(this.toolbars[netgis.Modes.DRAW_POLYGONS]),this.toolbars[netgis.Modes.CUT_FEATURE_BEGIN]=this.createToolbar(),this.toolbars[netgis.Modes.CUT_FEATURE_BEGIN].appendChild(this.createToolbarButton('Feature zum Ausschneiden w\u00e4hlen:',this.onToolbarClose.bind(this))),this.root.appendChild(this.toolbars[netgis.Modes.CUT_FEATURE_BEGIN]), -this.toolbars[netgis.Modes.CUT_FEATURE_DRAW]=this.createToolbar(),this.toolbars[netgis.Modes.CUT_FEATURE_DRAW].appendChild(this.createToolbarButton('Fl\u00e4che zum Ausschneiden zeichnen:',this.onToolbarClose.bind(this))),this.root.appendChild(this.toolbars[netgis.Modes.CUT_FEATURE_DRAW]),this.toolbars[netgis.Modes.MODIFY_FEATURES]=this.createToolbar(),this.toolbars[netgis.Modes.MODIFY_FEATURES].appendChild(this.createToolbarButton('Features verschieben:', -this.onToolbarClose.bind(this))),this.root.appendChild(this.toolbars[netgis.Modes.MODIFY_FEATURES]),this.toolbars[netgis.Modes.DELETE_FEATURES]=this.createToolbar(),this.toolbars[netgis.Modes.DELETE_FEATURES].appendChild(this.createToolbarButton('Features l\u00f6schen:',this.onToolbarClose.bind(this))),this.root.appendChild(this.toolbars[netgis.Modes.DELETE_FEATURES]),this.toolbars[netgis.Modes.BUFFER_FEATURE_BEGIN]=this.createToolbar(),this.toolbars[netgis.Modes.BUFFER_FEATURE_BEGIN].appendChild(this.createToolbarButton('Feature zum Puffern w\u00e4hlen:', -this.onToolbarClose.bind(this))),this.root.appendChild(this.toolbars[netgis.Modes.BUFFER_FEATURE_BEGIN]),this.toolbars[netgis.Modes.BUFFER_FEATURE_EDIT]=this.createToolbar(),this.toolbars[netgis.Modes.BUFFER_FEATURE_EDIT].appendChild(this.createToolbarButton('Feature puffern:',this.onBufferCancel.bind(this))),this.toolbars[netgis.Modes.BUFFER_FEATURE_EDIT].appendChild(this.createToolbarInput("Radius in Meter:",1E3,this.onBufferChange.bind(this))),this.toolbars[netgis.Modes.BUFFER_FEATURE_EDIT].getElementsByTagName("input")[0].addEventListener("keyup", -this.onBufferKeyUp.bind(this)),this.toolbars[netgis.Modes.BUFFER_FEATURE_EDIT].appendChild(this.createToolbarButton('OK',this.onBufferAccept.bind(this))),this.root.appendChild(this.toolbars[netgis.Modes.BUFFER_FEATURE_EDIT]));this.toolbars[netgis.Modes.SEARCH_PLACE]=this.createToolbar();this.toolbars[netgis.Modes.SEARCH_PLACE].appendChild(this.createToolbarButton('Suche:',this.onToolbarClose.bind(this)));var a=this.createToolbarInputText("Adresse...", -"",null);a.style.position="relative";this.searchInput=a.getElementsByTagName("input")[0];this.searchInput.addEventListener("keyup",this.onSearchKeyUp.bind(this));this.searchInput.addEventListener("focus",this.onSearchFocus.bind(this));this.searchInput.addEventListener("blur",this.onSearchBlur.bind(this));this.toolbars[netgis.Modes.SEARCH_PLACE].appendChild(a);this.searchList=document.createElement("ul");this.searchList.className="netgis-dropdown-content netgis-search-list netgis-dialog netgis-shadow netgis-hide"; -a.appendChild(this.searchList);this.toolbars[netgis.Modes.SEARCH_PLACE].appendChild(this.createToolbarButton('',this.onSearchClear.bind(this)));this.root.appendChild(this.toolbars[netgis.Modes.SEARCH_PLACE]);this.client.root.appendChild(this.root);this.client.on(netgis.Events.SET_MODE,this.onSetMode.bind(this));this.client.on(netgis.Events.SEARCH_PLACE_RESPONSE,this.onSearchPlaceResponse.bind(this))}; -netgis.Toolbar.prototype.createToolbar=function(){var a=document.createElement("div");a.className="netgis-toolbar netgis-dialog netgis-shadow netgis-hide";return a};netgis.Toolbar.prototype.createToolbarButton=function(a,b){var c=document.createElement("button");c.className="netgis-hover-light";c.innerHTML=a;c.addEventListener("click",b);return c}; +netgis.Toolbar.prototype.load=function(){this.root=document.createElement("section");this.root.className="netgis-toolbars";if(this.client.editable){this.toolbars[netgis.Modes.DRAW_POINTS]=this.createToolbar();this.toolbars[netgis.Modes.DRAW_POINTS].appendChild(this.createToolbarButton('Punkte zeichnen:',this.onToolbarClose.bind(this)));this.toolbars[netgis.Modes.DRAW_POINTS].appendChild(this.createToolbarCheckbox("Einrasten",this.onSnapChange.bind(this))); +this.root.appendChild(this.toolbars[netgis.Modes.DRAW_POINTS]);this.toolbars[netgis.Modes.DRAW_LINES]=this.createToolbar();this.toolbars[netgis.Modes.DRAW_LINES].appendChild(this.createToolbarButton('Linien zeichnen:',this.onToolbarClose.bind(this)));this.toolbars[netgis.Modes.DRAW_LINES].appendChild(this.createToolbarCheckbox("Einrasten",this.onSnapChange.bind(this)));this.root.appendChild(this.toolbars[netgis.Modes.DRAW_LINES]);this.toolbars[netgis.Modes.DRAW_POLYGONS]= +this.createToolbar();this.toolbars[netgis.Modes.DRAW_POLYGONS].appendChild(this.createToolbarButton('Polygone zeichnen:',this.onToolbarClose.bind(this)));this.toolbars[netgis.Modes.DRAW_POLYGONS].appendChild(this.createToolbarCheckbox("Einrasten",this.onSnapChange.bind(this)));this.root.appendChild(this.toolbars[netgis.Modes.DRAW_POLYGONS]);this.toolbars[netgis.Modes.CUT_FEATURE_BEGIN]=this.createToolbar();this.toolbars[netgis.Modes.CUT_FEATURE_BEGIN].appendChild(this.createToolbarButton('Feature zum Ausschneiden w\u00e4hlen:', +this.onToolbarClose.bind(this)));this.root.appendChild(this.toolbars[netgis.Modes.CUT_FEATURE_BEGIN]);this.toolbars[netgis.Modes.CUT_FEATURE_DRAW]=this.createToolbar();this.toolbars[netgis.Modes.CUT_FEATURE_DRAW].appendChild(this.createToolbarButton('Fl\u00e4che zum Ausschneiden zeichnen:',this.onToolbarClose.bind(this)));this.root.appendChild(this.toolbars[netgis.Modes.CUT_FEATURE_DRAW]);this.toolbars[netgis.Modes.MODIFY_FEATURES]=this.createToolbar();this.toolbars[netgis.Modes.MODIFY_FEATURES].appendChild(this.createToolbarButton('Features verschieben:', +this.onToolbarClose.bind(this)));this.root.appendChild(this.toolbars[netgis.Modes.MODIFY_FEATURES]);this.toolbars[netgis.Modes.DELETE_FEATURES]=this.createToolbar();this.toolbars[netgis.Modes.DELETE_FEATURES].appendChild(this.createToolbarButton('Features l\u00f6schen:',this.onToolbarClose.bind(this)));this.root.appendChild(this.toolbars[netgis.Modes.DELETE_FEATURES]);this.toolbars[netgis.Modes.BUFFER_FEATURE_BEGIN]=this.createToolbar();this.toolbars[netgis.Modes.BUFFER_FEATURE_BEGIN].appendChild(this.createToolbarButton('Feature zum Puffern w\u00e4hlen:', +this.onToolbarClose.bind(this)));this.root.appendChild(this.toolbars[netgis.Modes.BUFFER_FEATURE_BEGIN]);this.toolbars[netgis.Modes.BUFFER_FEATURE_EDIT]=this.createToolbar();this.toolbars[netgis.Modes.BUFFER_FEATURE_EDIT].appendChild(this.createToolbarButton('Feature puffern:',this.onBufferCancel.bind(this)));this.toolbars[netgis.Modes.BUFFER_FEATURE_EDIT].appendChild(this.createToolbarInput("Radius in Meter:",1E3,this.onBufferChange.bind(this)));this.toolbars[netgis.Modes.BUFFER_FEATURE_EDIT].appendChild(this.createToolbarInput("Segmente:", +5,this.onBufferChange.bind(this)));var a=this.toolbars[netgis.Modes.BUFFER_FEATURE_EDIT].getElementsByTagName("input");a[0].addEventListener("keyup",this.onBufferKeyUp.bind(this));a[1].addEventListener("keyup",this.onBufferKeyUp.bind(this));a[1].setAttribute("min",1);this.toolbars[netgis.Modes.BUFFER_FEATURE_EDIT].appendChild(this.createToolbarButton('OK',this.onBufferAccept.bind(this)));this.root.appendChild(this.toolbars[netgis.Modes.BUFFER_FEATURE_EDIT])}this.toolbars[netgis.Modes.SEARCH_PLACE]= +this.createToolbar();this.toolbars[netgis.Modes.SEARCH_PLACE].appendChild(this.createToolbarButton('Suche:',this.onToolbarClose.bind(this)));a=this.createToolbarInputText("Adresse...","",null);a.style.position="relative";this.searchInput=a.getElementsByTagName("input")[0];this.searchInput.addEventListener("keyup",this.onSearchKeyUp.bind(this));this.searchInput.addEventListener("focus",this.onSearchFocus.bind(this));this.searchInput.addEventListener("blur", +this.onSearchBlur.bind(this));this.toolbars[netgis.Modes.SEARCH_PLACE].appendChild(a);this.searchList=document.createElement("ul");this.searchList.className="netgis-dropdown-content netgis-search-list netgis-dialog netgis-shadow netgis-hide";a.appendChild(this.searchList);this.toolbars[netgis.Modes.SEARCH_PLACE].appendChild(this.createToolbarButton('',this.onSearchClear.bind(this)));this.root.appendChild(this.toolbars[netgis.Modes.SEARCH_PLACE]);this.client.root.appendChild(this.root); +this.client.on(netgis.Events.SET_MODE,this.onSetMode.bind(this));this.client.on(netgis.Events.SEARCH_PLACE_RESPONSE,this.onSearchPlaceResponse.bind(this))};netgis.Toolbar.prototype.createToolbar=function(){var a=document.createElement("div");a.className="netgis-toolbar netgis-dialog netgis-shadow netgis-hide";return a}; +netgis.Toolbar.prototype.createToolbarButton=function(a,b){var c=document.createElement("button");c.setAttribute("type","button");c.className="netgis-hover-light";c.innerHTML=a;c.addEventListener("click",b);return c}; netgis.Toolbar.prototype.createToolbarCheckbox=function(a,b){var c=document.createElement("label");c.className="netgis-hover-light";var d=document.createElement("input");d.setAttribute("type","checkbox");d.addEventListener("change",b);c.appendChild(d);a=document.createTextNode(a);c.appendChild(a);return c}; netgis.Toolbar.prototype.createToolbarInput=function(a,b,c){var d=document.createElement("label");d.className="netgis-hover-light";a=document.createTextNode(a);d.appendChild(a);a=document.createElement("input");a.setAttribute("type","number");a.setAttribute("min",0);a.value=b;a.addEventListener("change",c);d.appendChild(a);return d}; netgis.Toolbar.prototype.createToolbarInputText=function(a,b,c){var d=document.createElement("label");d.className="netgis-hover-light";var e=document.createElement("input");e.setAttribute("type","text");e.setAttribute("placeholder",a);e.value=b;c&&e.addEventListener("change",c);d.appendChild(e);return d}; @@ -125,9 +126,9 @@ netgis.Toolbar.prototype.onSetMode=function(a){var b=!this.toolbars[netgis.Modes netgis.Toolbar.prototype.onToolbarClose=function(a){this.client.invoke(netgis.Events.SET_MODE,netgis.Modes.VIEW)};netgis.Toolbar.prototype.searchRequest=function(a){a=a.trim();a!==this.searchValue&&(this.searchValue=a,0")},create:function(a){var b=document.createElement("tbody");b.innerHTML= diff --git a/templates/map/geom_form.html b/templates/map/geom_form.html index 287319fd..5bfc4f7a 100644 --- a/templates/map/geom_form.html +++ b/templates/map/geom_form.html @@ -10,6 +10,15 @@ {% endif %} +{% if geom_form.geom.errors %} +
    + {% for error in geom_form.geom.errors %} + {{ error }} +
    + {% endfor %} +
    +{% endif %} +
    {% include 'map/client/index.html' %}